diff options
author | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:59:00 +0200 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:59:00 +0200 |
commit | 39b738a67a14dde67b2a811d56ac84934fcef52d (patch) | |
tree | 514ab67cc6147ba0853b5908ddf78e4115ffef1d /nx-X11/programs/Xserver/hw/nxagent/Screen.c | |
parent | e6db7e93608570765b3b6133ebb60d746c81aeeb (diff) | |
download | nx-libs-39b738a67a14dde67b2a811d56ac84934fcef52d.tar.gz nx-libs-39b738a67a14dde67b2a811d56ac84934fcef52d.tar.bz2 nx-libs-39b738a67a14dde67b2a811d56ac84934fcef52d.zip |
Imported nxagent-3.5.0-2.tar.gznxagent/3.5.0-2
Summary: Imported nxagent-3.5.0-2.tar.gz
Keywords:
Imported nxagent-3.5.0-2.tar.gz
into Git repository
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Screen.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Screen.c | 195 |
1 files changed, 191 insertions, 4 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 2db7df8fe..0a0d409eb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1,6 +1,6 @@ /**************************************************************************/ /* */ -/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */ +/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ /* */ /* NXAGENT, NX protocol compression and NX extensions to this software */ /* are copyright of NoMachine. Redistribution and use of the present */ @@ -160,6 +160,7 @@ void nxagentPropagateArtsdProperties(ScreenPtr pScreen, char *port); #endif +Window nxagentIconWindow = None; Window nxagentFullscreenWindow = None; #ifdef VIEWPORT_FRAME @@ -287,6 +288,166 @@ void nxagentSetPixmapFormats(ScreenInfo *screenInfo) } } +void nxagentMinimizeFromFullScreen(ScreenPtr pScreen) +{ + XUnmapWindow(nxagentDisplay, nxagentFullscreenWindow); + + if (nxagentIpaq) + { + XMapWindow(nxagentDisplay, nxagentIconWindow); + XIconifyWindow(nxagentDisplay, nxagentIconWindow, + DefaultScreen(nxagentDisplay)); + } + else + { + XIconifyWindow(nxagentDisplay, nxagentIconWindow, + DefaultScreen(nxagentDisplay)); + } +} + +void nxagentMaximizeToFullScreen(ScreenPtr pScreen) +{ + if (nxagentIpaq) + { + XUnmapWindow(nxagentDisplay, nxagentIconWindow); + + XMapWindow(nxagentDisplay, nxagentFullscreenWindow); + } + else + { +/* + XUnmapWindow(nxagentDisplay, nxagentIconWindow); +*/ +/* +FIXME: We'll chech for ReparentNotify and LeaveNotify events after XReparentWindow() + in order to avoid the session window is iconified. + We could avoid the sesssion window is iconified when a LeaveNotify event is received, + so this check would be unnecessary. +*/ + struct timeval timeout; + int i; + XEvent e; + + XReparentWindow(nxagentDisplay, nxagentFullscreenWindow, + RootWindow(nxagentDisplay, DefaultScreen(nxagentDisplay)), 0, 0); + + for (i = 0; i < 100 && nxagentWMIsRunning; i++) + { + #ifdef TEST + fprintf(stderr, "nxagentMaximizeToFullscreen: WARNING! Going to wait for the ReparentNotify event.\n"); + #endif + + if (XCheckTypedWindowEvent(nxagentDisplay, nxagentFullscreenWindow, ReparentNotify, &e)) + { + break; + } + + XSync(nxagentDisplay, 0); + + timeout.tv_sec = 0; + timeout.tv_usec = 50 * 1000; + + nxagentWaitEvents(nxagentDisplay, &timeout); + } + + XMapRaised(nxagentDisplay, nxagentFullscreenWindow); + + XIconifyWindow(nxagentDisplay, nxagentIconWindow, + DefaultScreen(nxagentDisplay)); + + while (XCheckTypedWindowEvent(nxagentDisplay, nxagentFullscreenWindow, LeaveNotify, &e)); +/* + XMapWindow(nxagentDisplay, nxagentIconWindow); +*/ + } +} + +Window nxagentCreateIconWindow() +{ + XSetWindowAttributes attributes; + unsigned long valuemask; + char* window_name; + XTextProperty windowName; + XSizeHints sizeHints; + XWMHints wmHints; + Window w; + Mask mask; + + /* + * Create icon window. + */ + + attributes.override_redirect = False; + attributes.colormap = DefaultColormap(nxagentDisplay, DefaultScreen(nxagentDisplay)); + attributes.background_pixmap = nxagentScreenSaverPixmap; + valuemask = CWOverrideRedirect | CWBackPixmap | CWColormap; + + #ifdef TEST + fprintf(stderr, "nxagentCreateIconWindow: Going to create new icon window.\n"); + #endif + + w = XCreateWindow(nxagentDisplay, DefaultRootWindow(nxagentDisplay), + 0, 0, 1, 1, 0, + DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)), + InputOutput, + DefaultVisual(nxagentDisplay, DefaultScreen(nxagentDisplay)), + valuemask, &attributes); + + #ifdef TEST + fprintf(stderr, "nxagentCreateIconWindow: Created new icon window with id [%ld].\n", + nxagentIconWindow); + #endif + + /* + * Set hints to the window manager for the icon window. + */ + + window_name = nxagentWindowName; + XStringListToTextProperty(&window_name, 1, &windowName); + sizeHints.flags = PMinSize | PMaxSize; + sizeHints.min_width = sizeHints.max_width = 1; + sizeHints.min_height = sizeHints.max_height = 1; + wmHints.flags = IconPixmapHint | IconMaskHint; + wmHints.initial_state = IconicState; + wmHints.icon_pixmap = nxagentIconPixmap; + + if (useXpmIcon) + { + wmHints.icon_mask = nxagentIconShape; + wmHints.flags = IconPixmapHint | IconMaskHint; + } + else + { + wmHints.flags = StateHint | IconPixmapHint; + } + + XSetWMProperties(nxagentDisplay, w, + &windowName, &windowName, + NULL , 0 , &sizeHints, &wmHints, NULL); + + /* + * Enable events from the icon window. + */ + + nxagentGetDefaultEventMask(&mask); + + XSelectInput(nxagentDisplay, w, (mask & ~(KeyPressMask | + KeyReleaseMask)) | StructureNotifyMask); + + /* + * Notify to client if user closes icon window. + */ + + if (nxagentWMIsRunning && !nxagentOption(Rootless)) + { + XlibAtom deleteWMAtom = nxagentAtoms[2]; /* WM_DELETE_WINDOW */ + + XSetWMProtocols(nxagentDisplay, w, &deleteWMAtom, 1); + } + + return w; +} + Bool nxagentMagicPixelZone(int x, int y) { return (x >= nxagentOption(Width) - 1 && y < 1); @@ -816,6 +977,8 @@ Bool nxagentOpenScreen(int index, ScreenPtr pScreen, nxagentChangeOption(Fullscreen, False); + nxagentChangeOption(AllScreens, False); + nxagentFullscreenWindow = 0; resetAgentPosition = True; @@ -1221,6 +1384,11 @@ N/A nxagentChangeOption(Height, gattributes.height); } + if (nxagentOption(AllScreens)) + { + attributes.override_redirect = True; + } + if (nxagentOption(Fullscreen)) { /* @@ -1448,7 +1616,8 @@ N/A if (nxagentDoFullGeneration == 1 || nxagentReconnectTrap == 1) { - valuemask = CWBackPixel | CWEventMask | CWColormap; + valuemask = CWBackPixel | CWEventMask | CWColormap | + (nxagentOption(AllScreens) == 1 ? CWOverrideRedirect : 0); attributes.background_pixel = nxagentBlackPixel; @@ -1456,6 +1625,11 @@ N/A attributes.colormap = nxagentDefaultVisualColormap(nxagentDefaultVisual(pScreen)); + if (nxagentOption(AllScreens) == 1) + { + attributes.override_redirect = True; + } + if (nxagentOption(Fullscreen) == 1) { if (nxagentReconnectTrap) @@ -1635,6 +1809,21 @@ N/A XClearWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum]); + if (nxagentOption(AllScreens)) + { + if (nxagentReconnectTrap) + { + XGrabKeyboard(nxagentDisplay, nxagentFullscreenWindow, True, GrabModeAsync, + GrabModeAsync, CurrentTime); + } + + nxagentIconWindow = nxagentCreateIconWindow(); + } + else + { + nxagentIconWindow = 0; + } + /* * When we don't have window manager we grab keyboard * to let nxagent get keyboard events. @@ -1983,8 +2172,6 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, int oldMmWidth; int oldMmHeight; - RegionPtr pRootWinSize; - #ifdef TEST nxagentPrintAgentGeometry("Before Resize Screen", "nxagentResizeScreen:"); #endif |