From 82d5482838be53450248b563b08ec0b65014da47 Mon Sep 17 00:00:00 2001 From: David Nusinow Date: Wed, 27 Feb 2008 21:42:01 -0500 Subject: [PATCH] Implement WM_CLASS hints in Xephyr (bug #10016) --- hw/kdrive/ephyr/ephyr.h | 1 + hw/kdrive/ephyr/ephyrinit.c | 19 +++++++++++++++++++ hw/kdrive/ephyr/hostx.c | 27 +++++++++++++++++++++++++++ hw/kdrive/ephyr/hostx.h | 3 +++ 4 files changed, 50 insertions(+), 0 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h index 8ed7e23..5d58a21 100644 --- a/hw/kdrive/ephyr/ephyr.h +++ b/hw/kdrive/ephyr/ephyr.h @@ -28,6 +28,7 @@ #include #include #include +#include #include "os.h" /* for OsSignal() */ #include "kdrive.h" diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 6196996..47ddb3d 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -109,6 +109,7 @@ ddxUseMsg (void) ErrorF("-nodri do not use DRI\n"); #endif ErrorF("-noxv do not use XV\n"); + ErrorF("-name [name] define the name in the WM_CLASS property\n"); ErrorF("\n"); exit(1); @@ -148,6 +149,11 @@ ddxProcessArgument (int argc, char **argv, int i) { EPHYR_DBG("mark argv[%d]='%s'", i, argv[i] ); + if (i == 1) + { + hostx_use_resname(basename(argv[0]), 0); + } + if (!strcmp (argv[i], "-parent")) { if(i+1 < argc) @@ -223,6 +229,19 @@ ddxProcessArgument (int argc, char **argv, int i) EPHYR_LOG ("no XVideo enabled\n") ; return 1 ; } + else if (!strcmp (argv[i], "-name")) + { + if (i+1 < argc && argv[i+1][0] != '-') + { + hostx_use_resname(argv[i+1], 1); + return 2; + } + else + { + UseMsg(); + return 0; + } + } else if (argv[i][0] == ':') { hostx_set_display_name(argv[i]); diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index ae1bb4b..194893b 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -74,6 +74,7 @@ struct EphyrHostScreen void *info; /* Pointer to the screen this is associated with */ int mynum; /* Screen number */ + XClassHint *class_hint; }; struct EphyrHostXVars @@ -107,6 +108,9 @@ extern EphyrKeySyms ephyrKeySyms; extern int monitorResolution; +char *ephyrResName = NULL; +int ephyrResNameFromCmd = 0; + static void hostx_set_fullscreen_hint(void); @@ -296,6 +300,13 @@ hostx_handle_signal (int signum) HostXWantDamageDebug); } +void +hostx_use_resname (char *name, int fromcmd) +{ + ephyrResName = name; + ephyrResNameFromCmd = fromcmd; +} + int hostx_init (void) { @@ -304,6 +315,7 @@ hostx_init (void) Pixmap cursor_pxm; XColor col; int index; + char *tmpstr; attr.event_mask = ButtonPressMask @@ -389,6 +401,21 @@ hostx_init (void) hostx_set_fullscreen_hint(); } + + host_screen->class_hint = XAllocClassHint(); + if (host_screen->class_hint) + { + tmpstr = getenv("RESOURCE_NAME"); + if (tmpstr && (!ephyrResNameFromCmd)) + ephyrResName = tmpstr; + host_screen->class_hint->res_name = ephyrResName; + host_screen->class_hint->res_class = "Xephyr"; + XSetClassHint(hostx_get_display(), host_screen->win, host_screen->class_hint); + XFree(host_screen->class_hint); + host_screen->class_hint = NULL; + + } + } } diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index f72cfe7..4c8ea9c 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -144,6 +144,9 @@ hostx_want_preexisting_window(EphyrScreenInfo screen); void hostx_use_preexisting_window(unsigned long win_id); +void +hostx_use_resname (char *name, int fromcmd); + void hostx_handle_signal(int signum); -- 1.5.4.3