As it is really unlikely that in normal use case someone would need this feature, it is now conditional code, which is not enabled by default; the configure scripts now propose a '--enable-wmreplace' option to enable the corresponding code, as people making package for distributions may want to enable the feature to provide users the ability to give a try of all the window managers.
Suggested-by: Carlos R. Mafra <crma...@gmail.com> Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- configure.ac | 14 ++++++++++++++ doc/build/Compilation.texi | 6 ++++++ src/WindowMaker.h | 2 ++ src/event.c | 8 ++++++++ src/main.c | 4 ++++ src/screen.c | 6 ++++++ src/screen.h | 2 ++ 7 files changed, 42 insertions(+) diff --git a/configure.ac b/configure.ac index 491bdc7..40f76fb 100644 --- a/configure.ac +++ b/configure.ac @@ -526,6 +526,20 @@ AS_IF([test "x$enable_xdnd" = "xyes"], AM_CONDITIONAL([USE_DOCK_XDND], [test "x$enable_dock_xdnd" != "xno"]) +dnl Support for ICCCM 2.0 Window Manager replacement +dnl ================================================ +AC_ARG_ENABLE([wmreplace], + [AS_HELP_STRING([--enable-wmreplace], [support for ICCCM window manager replacement])], + [AS_CASE([$enableval], + [yes|no], [], + [AC_MSG_ERROR([bad value '$enableval' for --enable-wmreplace])])], + [enable_wmreplace=no]) +AS_IF([test "x$enable_wmreplace" = "xyes"], + [AC_DEFINE([USE_ICCCM_WMREPLACE], [1], + [define to support ICCCM protocol for window manager replacement]) + supported_xext="$supported_xext WMReplace"]) + + dnl XShape support dnl ============== AC_ARG_ENABLE([shape], diff --git a/doc/build/Compilation.texi b/doc/build/Compilation.texi index 095718c..2ab7598 100644 --- a/doc/build/Compilation.texi +++ b/doc/build/Compilation.texi @@ -575,6 +575,12 @@ Disable support for Motif's MWM Window Manager hints. These attributes were introduced by the Motif toolkit to ask for special window appearance requests. Nowadays this is covered by the NetWM/EWMH specification, but there are still applications that rely on MWM Hints. +@item --enable-wmreplace +Add support for the @emph{ICCCM} protocol for cooperative window manager replacement. +This feature is disabled by default because you probably don't need to switch seamlessly the window manager; +if you are making a package for a distribution you'd probably want to enable this because it allows users to give +a try to different window managers without restarting everything for an extra cost that is not really big. + @item --disable-xdnd Disable support for dragging and dropping files on the dock, which launches a user-specified command with that file. diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 606298d..37e3fc0 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -463,7 +463,9 @@ extern struct WPreferences { char show_clip_title; struct { +#ifdef USE_ICCCM_WMREPLACE unsigned int replace:1; /* replace existing window manager */ +#endif unsigned int nodock:1; /* don't display the dock */ unsigned int noclip:1; /* don't display the clip */ unsigned int clip_merged_in_dock:1; /* disable clip, switch workspaces with dock */ diff --git a/src/event.c b/src/event.c index 1e100f7..71450fc 100644 --- a/src/event.c +++ b/src/event.c @@ -1894,6 +1894,7 @@ static void handleVisibilityNotify(XEvent * event) static void handle_selection_clear(XSelectionClearEvent *event) { +#ifdef USE_ICCCM_WMREPLACE WScreen *scr = wScreenForWindow(event->window); if (!scr) @@ -1904,4 +1905,11 @@ static void handle_selection_clear(XSelectionClearEvent *event) wmessage(_("another window manager is replacing us!")); Shutdown(WSExitMode); +#else + /* + * If the support for ICCCM window manager replacement was not enabled, we should not receive + * this kind of event, so we simply do nothing. + */ + (void) event; +#endif } diff --git a/src/main.c b/src/main.c index b68c5b6..d7aee3d 100644 --- a/src/main.c +++ b/src/main.c @@ -435,7 +435,9 @@ static void print_help(void) puts(_("The Window Maker window manager for the X window system")); puts(""); puts(_(" -display host:dpy display to use")); +#ifdef USE_ICCCM_WMREPLACE puts(_(" --replace replace running window manager")); +#endif puts(_(" --no-dock do not open the application Dock")); puts(_(" --no-clip do not open the workspace Clip")); puts(_(" --no-autolaunch do not autolaunch applications")); @@ -652,8 +654,10 @@ static int real_main(int argc, char **argv) wPreferences.flags.noclip = 1; } else if (strcmp(argv[i], "-nodrawer") == 0 || strcmp(argv[i], "--no-drawer") == 0) { wPreferences.flags.nodrawer = 1; +#ifdef USE_ICCCM_WMREPLACE } else if (strcmp(argv[i], "-replace") == 0 || strcmp(argv[i], "--replace") == 0) { wPreferences.flags.replace = 1; +#endif } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "--version") == 0) { printf("Window Maker %s\n", VERSION); exit(0); diff --git a/src/screen.c b/src/screen.c index 1f246c4..01571c0 100644 --- a/src/screen.c +++ b/src/screen.c @@ -66,7 +66,9 @@ |SubstructureRedirectMask|ButtonPressMask|ButtonReleaseMask\ |KeyPressMask|KeyReleaseMask) +#ifdef USE_ICCCM_WMREPLACE #define REPLACE_WM_TIMEOUT 15 +#endif #define STIPPLE_WIDTH 2 #define STIPPLE_HEIGHT 2 @@ -108,6 +110,7 @@ static void make_keys(void) */ static Bool replace_existing_wm(WScreen *scr) { +#ifdef USE_ICCCM_WMREPLACE char atomName[16]; Window wm; XSetWindowAttributes attribs; @@ -139,10 +142,12 @@ static Bool replace_existing_wm(WScreen *scr) if (!XChangeWindowAttributes(dpy, wm, CWEventMask, &attribs)) wm = None; } +#endif /* for our window manager info notice board and the selection owner */ scr->info_window = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 10, 10, 0, 0, 0); +#ifdef USE_ICCCM_WMREPLACE /* Try to acquire the selection */ current_time = CurrentTime; ret = XSetSelectionOwner(dpy, scr->sn_atom, scr->info_window, current_time); @@ -188,6 +193,7 @@ static Bool replace_existing_wm(WScreen *scr) event.data.l[4] = (long) 0L; event.window = scr->root_win; XSendEvent(dpy, scr->root_win, False, StructureNotifyMask, (XEvent *) &event); +#endif return True; } diff --git a/src/screen.h b/src/screen.h index f3fc6fb..4d846c5 100644 --- a/src/screen.h +++ b/src/screen.h @@ -69,7 +69,9 @@ typedef struct WDrawerChain { typedef struct _WScreen { int screen; /* screen number */ Window info_window; /* for our window manager info stuff */ +#ifdef USE_ICCCM_WMREPLACE Atom sn_atom; /* window manager selection */ +#endif int scr_width; /* size of the screen */ int scr_height; -- 2.1.4 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.