Revision: 3498 Author: lewis Date: 2015-11-15 09:32:03 -0800 (Sun, 15 Nov 2015) Log Message: ----------- Fix for Mantix 7833 by Nicolai Hess to support return from full screen mode on certain window managers that do not handle it properly. Also add command line parameter -fullscreenDirect and matching environment variable SQUEAK_FULLSCREEN_DIRECT to allow original behavior to be specified in the case of a simple window manager (e.g. twm) than does not understand the _NET_WM_STATE_FULLSCREEN window manager hint.
Modified Paths: -------------- trunk/platforms/unix/vm/sqUnixMain.c trunk/platforms/unix/vm-display-X11/sqUnixX11.c
Modified: trunk/platforms/unix/vm/sqUnixMain.c =================================================================== --- trunk/platforms/unix/vm/sqUnixMain.c 2015-11-14 20:16:45 UTC (rev 3497) +++ trunk/platforms/unix/vm/sqUnixMain.c 2015-11-15 17:32:03 UTC (rev 3498) @@ -1046,11 +1046,13 @@ if (!strcmp(argv[0], arg)) \ return parseModuleArgument(argc, argv, &type##Module, #type, name);
- moduleArg("-nodisplay", display, "null"); - moduleArg("-display", display, "X11"); - moduleArg("-headless", display, "X11"); - moduleArg("-quartz", display, "Quartz"); - moduleArg("-nosound", sound, "null"); + moduleArg("-nodisplay", display, "null"); + moduleArg("-display", display, "X11"); + moduleArg("-headless", display, "X11"); + moduleArg("-fullscreen", display, "X11"); + moduleArg("-fullscreenDirect", display, "X11"); + moduleArg("-quartz", display, "Quartz"); + moduleArg("-nosound", sound, "null");
# undef moduleArg
Modified: trunk/platforms/unix/vm-display-X11/sqUnixX11.c =================================================================== --- trunk/platforms/unix/vm-display-X11/sqUnixX11.c 2015-11-14 20:16:45 UTC (rev 3497) +++ trunk/platforms/unix/vm-display-X11/sqUnixX11.c 2015-11-15 17:32:03 UTC (rev 3498) @@ -335,6 +335,7 @@ int sleepWhenUnmapped= 0; int noTitle= 0; int fullScreen= 0; +int fullScreenDirect= 0; int iconified= 0; int closeQuit= 0; int withSpy= 0; @@ -3982,6 +3983,57 @@ }
+static void enterFullScreenMode(Window root) +{ + XSynchronize(stDisplay, True); + overrideRedirect(stDisplay, stWindow, True); + XReparentWindow(stDisplay, stWindow, root, 0, 0); +#if 1 + XResizeWindow(stDisplay, stWindow, scrW, scrH); +#else + XResizeWindow(stDisplay, stParent, scrW, scrH); +#endif + XLowerWindow(stDisplay, stParent); + XRaiseWindow(stDisplay, stWindow); + XSetInputFocus(stDisplay, stWindow, RevertToPointerRoot, CurrentTime); + XSynchronize(stDisplay, False); +} + + +static void returnFromFullScreenMode() +{ + XSynchronize(stDisplay, True); + XRaiseWindow(stDisplay, stParent); + XReparentWindow(stDisplay, stWindow, stParent, 0, 0); + overrideRedirect(stDisplay, stWindow, False); +#if 1 + XResizeWindow(stDisplay, stWindow, scrW, scrH); +#else + XResizeWindow(stDisplay, stParent, winW, winH); +#endif + XSetInputFocus(stDisplay, stWindow, RevertToPointerRoot, CurrentTime); + XSynchronize(stDisplay, False); +} + + +static void sendFullScreenHint(int enable) +{ + XEvent xev; + Atom wm_state = XInternAtom(stDisplay, "_NET_WM_STATE", False); + Atom fullscreen = XInternAtom(stDisplay, "_NET_WM_STATE_FULLSCREEN", False); + + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = stParent; + xev.xclient.message_type = wm_state; + xev.xclient.format = 32; + xev.xclient.data.l[0] = enable; /* 1 enable, 0 disable fullscreen */ + xev.xclient.data.l[1] = fullscreen; + xev.xclient.data.l[2] = 0; + XSendEvent(stDisplay, DefaultRootWindow(stDisplay), False, SubstructureNotifyMask, &xev); +} + + static sqInt display_ioSetFullScreen(sqInt fullScreen) { int winX, winY; @@ -4007,18 +4059,10 @@ winW= (winW / sizeof(void *)) * sizeof(void *); setSavedWindowSize((winW << 16) + (winH & 0xFFFF)); savedWindowOrigin= (winX << 16) + (winY & 0xFFFF); - XSynchronize(stDisplay, True); - overrideRedirect(stDisplay, stWindow, True); - XReparentWindow(stDisplay, stWindow, root, 0, 0); -# if 1 - XResizeWindow(stDisplay, stWindow, scrW, scrH); -# else - XResizeWindow(stDisplay, stParent, scrW, scrH); -# endif - XLowerWindow(stDisplay, stParent); - XRaiseWindow(stDisplay, stWindow); - XSetInputFocus(stDisplay, stWindow, RevertToPointerRoot, CurrentTime); - XSynchronize(stDisplay, False); + if (fullScreenDirect) + enterFullScreenMode(root); /* simple window manager, e.g. twm */ + else + sendFullScreenHint(1); /* Required for Compiz window manager */ windowState= WIN_ZOOMED; fullDisplayUpdate(); } @@ -4039,17 +4083,10 @@ winX= savedWindowOrigin >> 16; winY= savedWindowOrigin & 0xFFFF; savedWindowOrigin= -1; /* prevents consecutive full-screen disables */ - XSynchronize(stDisplay, True); - XRaiseWindow(stDisplay, stParent); - XReparentWindow(stDisplay, stWindow, stParent, 0, 0); - overrideRedirect(stDisplay, stWindow, False); -# if 1 - XResizeWindow(stDisplay, stWindow, scrW, scrH); -# else - XResizeWindow(stDisplay, stParent, winW, winH); -# endif - XSetInputFocus(stDisplay, stWindow, RevertToPointerRoot, CurrentTime); - XSynchronize(stDisplay, False); + if (fullScreenDirect) + returnFromFullScreenMode(); /* simple window manager, e.g. twm */ + else + sendFullScreenHint(0); /* Required for Compiz window manager */ windowState= WIN_CHANGED; } } @@ -5987,6 +6024,7 @@ printf(" -compositioninput enable overlay window for composed characters\n"); printf(" -display <dpy> display on <dpy> (default: $DISPLAY)\n"); printf(" -fullscreen occupy the entire screen\n"); + printf(" -fullscreenDirect simple window manager support for fullscreen\n"); #if (USE_X11_GLX) printf(" -glxdebug <n> set GLX debug verbosity level to <n>\n"); #endif @@ -6044,6 +6082,7 @@ if (getenv("SQUEAK_NOTITLE")) noTitle= 1; if (getenv("SQUEAK_NOXDND")) useXdnd= 0; if (getenv("SQUEAK_FULLSCREEN")) fullScreen= 1; + if (getenv("SQUEAK_FULLSCREEN_DIRECT")) fullScreenDirect= 1; if (getenv("SQUEAK_ICONIC")) iconified= 1; if (getenv("SQUEAK_CLOSEQUIT")) closeQuit= 1; if (getenv("SQUEAK_MAPDELBS")) mapDelBs= 1; @@ -6076,6 +6115,7 @@ else if (!strcmp(arg, "-mapdelbs")) mapDelBs= 1; else if (!strcmp(arg, "-swapbtn")) swapBtn= 1; else if (!strcmp(arg, "-fullscreen")) fullScreen= 1; + else if (!strcmp(arg, "-fullscreenDirect")) fullScreenDirect= 1; else if (!strcmp(arg, "-iconic")) iconified= 1; else if (!strcmp(arg, "-closequit")) closeQuit= 1; #if !defined (INIT_INPUT_WHEN_KEY_PRESSED)
vm-dev@lists.squeakfoundation.org