aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Window.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Window.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Window.c269
1 files changed, 53 insertions, 216 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c
index 449458ade..2403390b8 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Window.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c
@@ -692,235 +692,87 @@ void nxagentRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib)
void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn)
{
- Window w;
- XSetWindowAttributes attributes;
- unsigned long valuemask;
+ XEvent e;
+ XSizeHints sizeHints;
- if (nxagentOption(Rootless))
+ if (nxagentOption(Rootless) == 1)
{
return;
}
- if (!switchOn)
+ if (switchOn == 0)
{
nxagentWMDetect();
- if (!nxagentWMIsRunning)
- {
- #ifdef WARNING
- fprintf(stderr, "Warning: Can't switch to window mode, no window manager has been detected.\n");
- #endif
-
- return;
- }
- }
-
- w = nxagentDefaultWindows[pScreen -> myNum];
- attributes.override_redirect = switchOn;
- valuemask = CWOverrideRedirect;
- XUnmapWindow(nxagentDisplay, w);
- XChangeWindowAttributes(nxagentDisplay, w, valuemask, &attributes);
-
- if (switchOn)
- {
- /*
- * Change to fullscreen mode.
- */
-
- struct timeval timeout;
- int i;
- XEvent e;
-
/*
- * Wait for window manager reparenting the default window.
+ * The smart scheduler could be stopped while
+ * waiting for the reply. In this case we need
+ * to yield explicitly to avoid to be stuck in
+ * the dispatch loop forever.
*/
- for (i = 0; i < 100 && nxagentWMIsRunning; i++)
- {
- #ifdef TEST
- fprintf(stderr, "nxagentSwitchFullscreen: WARNING! Going to wait for the ReparentNotify event.\n");
- #endif
-
- if (XCheckTypedWindowEvent(nxagentDisplay, w, ReparentNotify, &e))
- {
- break;
- }
-
- /*
- * This should also flush
- * the NX link for us.
- */
-
- XSync(nxagentDisplay, 0);
-
- timeout.tv_sec = 0;
- timeout.tv_usec = 50 * 1000;
-
- nxagentWaitEvents(nxagentDisplay, &timeout);
- }
-
- if (i < 100)
- {
- /*
- * The window manager has done with the reparent
- * operation. We can resize and map the window.
- */
-
- nxagentChangeOption(Fullscreen, True);
-
- /*
- * Save the window-mode configuration.
- */
-
- nxagentChangeOption(SavedX, nxagentOption(X));
- nxagentChangeOption(SavedY, nxagentOption(Y));
- nxagentChangeOption(SavedWidth, nxagentOption(Width));
- nxagentChangeOption(SavedHeight, nxagentOption(Height));
- nxagentChangeOption(SavedRootWidth, nxagentOption(RootWidth));
- nxagentChangeOption(SavedRootHeight, nxagentOption(RootHeight));
-
- /*
- * Reconf the Default window.
- */
-
- nxagentChangeOption(X, 0);
- nxagentChangeOption(Y, 0);
- nxagentChangeOption(Width, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)));
- nxagentChangeOption(Height, HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)));
-
- /*
- * Move the root window.
- */
-
- nxagentChangeOption(RootX, (nxagentOption(Width) - nxagentOption(RootWidth)) / 2);
- nxagentChangeOption(RootY, (nxagentOption(Height) - nxagentOption(RootHeight)) / 2);
- nxagentChangeOption(ViewportXSpan, nxagentOption(Width) - nxagentOption(RootWidth));
- nxagentChangeOption(ViewportYSpan, nxagentOption(Height) - nxagentOption(RootHeight));
-
- XMoveResizeWindow(nxagentDisplay, w, nxagentOption(X), nxagentOption(Y),
- nxagentOption(Width), nxagentOption(Height));
-
- nxagentUpdateViewportFrame(0, 0, nxagentOption(RootWidth), nxagentOption(RootHeight));
-
- XMoveWindow(nxagentDisplay, nxagentWindow(WindowTable[pScreen -> myNum]),
- nxagentOption(RootX), nxagentOption(RootY));
-
- /*
- * We disable the screensaver when changing
- * mode to fullscreen. Is it really needed?
- */
-
- XSetScreenSaver(nxagentDisplay, 0, 0, DefaultExposures, DefaultBlanking);
+ isItTimeToYield = 1;
- if (nxagentIconWindow == None)
- {
- nxagentIconWindow = nxagentCreateIconWindow();
-
- XMapWindow(nxagentDisplay, nxagentIconWindow);
- }
-
- XMapRaised(nxagentDisplay, w);
- XSetInputFocus(nxagentDisplay, w, RevertToParent, CurrentTime);
- XCheckTypedWindowEvent(nxagentDisplay, w, LeaveNotify, &e);
- nxagentFullscreenWindow = w;
-
- if (nxagentOption(DesktopResize) == 1)
- {
- if (nxagentOption(Shadow) == 0)
- {
- nxagentRRSetScreenConfig(pScreen, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)),
- HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)));
- }
- else
- {
- nxagentShadowAdaptToRatio();
- }
- }
- }
- else
+ if (nxagentWMIsRunning == 0)
{
- /*
- * We have waited for a reparent event unsuccessfully.
- * Something happened to the window manager.
- */
-
#ifdef WARNING
- fprintf(stderr, "nxagentSwitchFullscreen: WARNING! Expected ReparentNotify event missing.\n");
+ fprintf(stderr, "Warning: Can't switch to window mode, no window manager "
+ "has been detected.\n");
#endif
- nxagentWMIsRunning = False;
- attributes.override_redirect = False;
- XChangeWindowAttributes(nxagentDisplay, w, valuemask, &attributes);
- XMapWindow(nxagentDisplay, w);
+ return;
}
}
- else
- {
- /*
- * FIXME:
- * It could be necessary:
- * - To restore screensaver.
- * - To set or reset nxagentForceBackingStore flag.
- * - To grab keyboard.
- * - To propagate device settings to the X server if no WM is running.
- */
-
- /*
- * Change to windowed mode.
- */
- nxagentChangeOption(Fullscreen, False);
- XDestroyWindow(nxagentDisplay, nxagentIconWindow);
- nxagentIconWindow = nxagentFullscreenWindow = None;
+ #ifdef TEST
+ fprintf(stderr, "nxagentSwitchFullscreen: Switching to %s mode.\n",
+ switchOn ? "fullscreen" : "windowed");
+ #endif
- if (nxagentOption(DesktopResize) == 1)
- {
- nxagentChangeOption(RootWidth, nxagentOption(SavedRootWidth));
- nxagentChangeOption(RootHeight, nxagentOption(SavedRootHeight));
+ nxagentChangeOption(Fullscreen, switchOn);
- if (nxagentOption(Shadow) == 0)
- {
- nxagentRRSetScreenConfig(pScreen, nxagentOption(RootWidth), nxagentOption(RootHeight));
- }
- }
+ if (nxagentOption(DesktopResize) == 1)
+ {
+ sizeHints.flags = PSize;
- if (nxagentOption(WMBorderWidth) > 0 && nxagentOption(WMTitleHeight) > 0)
+ if (switchOn == 1)
{
- nxagentChangeOption(X, nxagentOption(SavedX) -
- nxagentOption(WMBorderWidth));
- nxagentChangeOption(Y, nxagentOption(SavedY) -
- nxagentOption(WMTitleHeight));
+ sizeHints.width =
+ WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
+ sizeHints.height =
+ HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
}
else
{
- nxagentChangeOption(X, nxagentOption(SavedX));
- nxagentChangeOption(Y, nxagentOption(SavedY));
+ sizeHints.width = nxagentOption(RootWidth);
+ sizeHints.height = nxagentOption(RootHeight);
}
- nxagentChangeOption(Width, nxagentOption(SavedWidth));
- nxagentChangeOption(Height, nxagentOption(SavedHeight));
-
- if (nxagentOption(Shadow) == 1 && nxagentOption(DesktopResize) == 1)
- {
- nxagentShadowAdaptToRatio();
- }
+ XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen -> myNum],
+ &sizeHints);
+ }
- XMoveResizeWindow(nxagentDisplay, w, nxagentOption(X), nxagentOption(Y),
- nxagentOption(Width), nxagentOption(Height));
+ memset(&e, 0, sizeof(e));
- nxagentUpdateViewportFrame(0, 0, nxagentOption(Width), nxagentOption(Height));
+ e.xclient.type = ClientMessage;
+ e.xclient.message_type = nxagentAtoms[13]; /* _NET_WM_STATE */
+ e.xclient.display = nxagentDisplay;
+ e.xclient.window = nxagentDefaultWindows[pScreen -> myNum];
+ e.xclient.format = 32;
+ e.xclient.data.l[0] = nxagentOption(Fullscreen) ? 1 : 0;
+ e.xclient.data.l[1] = nxagentAtoms[14]; /* _NET_WM_STATE_FULLSCREEN */
- XMoveWindow(nxagentDisplay, nxagentWindow(WindowTable[pScreen -> myNum]), 0, 0);
- XMapWindow(nxagentDisplay, w);
+ XSendEvent(nxagentDisplay, DefaultRootWindow(nxagentDisplay), False,
+ SubstructureRedirectMask, &e);
- nxagentChangeOption(RootX, 0);
- nxagentChangeOption(RootY, 0);
+ if (switchOn == 1)
+ {
+ nxagentFullscreenWindow = nxagentDefaultWindows[pScreen -> myNum];
}
-
- XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0,
- nxagentOption(Width), nxagentOption(Height));
-
- nxagentSetPrintGeometry(pScreen -> myNum);
+ else
+ {
+ nxagentFullscreenWindow = None;
+ }
}
#ifdef VIEWPORT_FRAME
@@ -2422,6 +2274,11 @@ void nxagentMapDefaultWindows()
#endif
XMapWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum]);
+
+ if (nxagentOption(Fullscreen) == 1 && nxagentWMIsRunning == 1)
+ {
+ nxagentSwitchFullscreen(pScreen, 1);
+ }
}
/*
@@ -2452,26 +2309,6 @@ void nxagentMapDefaultWindows()
}
/*
- * Map the icon window.
- */
-
- if (nxagentIconWindow != 0)
- {
- #ifdef TEST
- fprintf(stderr, "nxagentMapDefaultWindows: Mapping icon window id [%ld].\n",
- nxagentIconWindow);
- #endif
-
- XMapWindow(nxagentDisplay, nxagentIconWindow);
-
- if (nxagentIpaq != 0)
- {
- XIconifyWindow(nxagentDisplay, nxagentIconWindow,
- DefaultScreen(nxagentDisplay));
- }
- }
-
- /*
* Ensure that the fullscreen window gets the focus.
*/