Commit 6657b8cc authored by Ulrich Sibiller's avatar Ulrich Sibiller

nxagentMaximizeToFullScreen: only reparent if necessary

This fixes problems with kwin and compiz when using the switch-all-screens keystroke. The fullscreen would appear shortly and then vanish again. Fixes ArcticaProject/nx-libs#458
parent d3270688
...@@ -336,6 +336,14 @@ void nxagentMinimizeFromFullScreen(ScreenPtr pScreen) ...@@ -336,6 +336,14 @@ void nxagentMinimizeFromFullScreen(ScreenPtr pScreen)
} }
} }
/*
* This is the opposite function to nxagentMinimizeFromFullscreen. It
* will map the fullscreen window and unmap the icon window. It is
* only called if fullscreen mode was active when the minimize
* keystroke was pressed.
* Some window managers tend to do 'interesting' things with the
* icon window, which we try to counterfeit here.
*/
void nxagentMaximizeToFullScreen(ScreenPtr pScreen) void nxagentMaximizeToFullScreen(ScreenPtr pScreen)
{ {
if (nxagentIpaq) if (nxagentIpaq)
...@@ -349,36 +357,51 @@ void nxagentMaximizeToFullScreen(ScreenPtr pScreen) ...@@ -349,36 +357,51 @@ void nxagentMaximizeToFullScreen(ScreenPtr pScreen)
/* /*
XUnmapWindow(nxagentDisplay, nxagentIconWindow); XUnmapWindow(nxagentDisplay, nxagentIconWindow);
*/ */
Window root = RootWindow(nxagentDisplay, DefaultScreen(nxagentDisplay));
/* /*
FIXME: We'll check for ReparentNotify and LeaveNotify events after XReparentWindow() FIXME: We'll check for ReparentNotify and LeaveNotify events after
in order to avoid the session window is iconified. XReparentWindow() in order to avoid the session window being
We could avoid the session window is iconified when a LeaveNotify event is received, iconified. We could avoid the session window being iconified
so this check would be unnecessary. when a LeaveNotify event is received, so this check would be
unnecessary.
*/ */
struct timeval timeout;
int i;
XEvent e;
XReparentWindow(nxagentDisplay, nxagentFullscreenWindow, /* only reparent if necessary. FIXME: also check if the desired coordinates match */
RootWindow(nxagentDisplay, DefaultScreen(nxagentDisplay)), 0, 0);
for (i = 0; i < 100 && nxagentWMIsRunning; i++) if (!nxagentIsParentOf(nxagentDisplay, root, nxagentFullscreenWindow))
{ {
#ifdef TEST XReparentWindow(nxagentDisplay, nxagentFullscreenWindow,
fprintf(stderr, "nxagentMaximizeToFullscreen: WARNING! Going to wait for the ReparentNotify event.\n"); root, 0, 0);
#endif
if (XCheckTypedWindowEvent(nxagentDisplay, nxagentFullscreenWindow, ReparentNotify, &e)) for (int i = 0; i < 100 && nxagentWMIsRunning; i++)
{ {
break; struct timeval timeout;
} XEvent e;
#ifdef TEST
fprintf(stderr, "nxagentMaximizeToFullscreen: WARNING! Going to wait for the ReparentNotify event [%d].\n", i);
#endif
XSync(nxagentDisplay, 0); if (XCheckTypedWindowEvent(nxagentDisplay, nxagentFullscreenWindow, ReparentNotify, &e))
{
break;
}
timeout.tv_sec = 0; XSync(nxagentDisplay, 0);
timeout.tv_usec = 50 * 1000;
nxagentWaitEvents(nxagentDisplay, &timeout); timeout.tv_sec = 0;
timeout.tv_usec = 50 * 1000;
nxagentWaitEvents(nxagentDisplay, &timeout);
}
}
else
{
#ifdef TEST
fprintf(stderr, "%s: FullscreenWindow already is child of root window - skipping reparenting,\n", __func__);
#endif
} }
XMapRaised(nxagentDisplay, nxagentFullscreenWindow); XMapRaised(nxagentDisplay, nxagentFullscreenWindow);
...@@ -386,7 +409,19 @@ FIXME: We'll check for ReparentNotify and LeaveNotify events after XReparentWind ...@@ -386,7 +409,19 @@ FIXME: We'll check for ReparentNotify and LeaveNotify events after XReparentWind
XIconifyWindow(nxagentDisplay, nxagentIconWindow, XIconifyWindow(nxagentDisplay, nxagentIconWindow,
DefaultScreen(nxagentDisplay)); DefaultScreen(nxagentDisplay));
while (XCheckTypedWindowEvent(nxagentDisplay, nxagentFullscreenWindow, LeaveNotify, &e)); /* swallow all LeaveNotify events for the FullscreenWindow;
Normally this does not swallow anything these days, but when
using fvwm you see one of these events here. */
while (1)
{
XEvent e;
if (!XCheckTypedWindowEvent(nxagentDisplay, nxagentFullscreenWindow, LeaveNotify, &e))
break;
#ifdef TEST
fprintf(stderr, "%d: swallowing LeaveNotify event\m", __func__);
#endif
}
/* /*
XMapWindow(nxagentDisplay, nxagentIconWindow); XMapWindow(nxagentDisplay, nxagentIconWindow);
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment