diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Events.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Events.c | 317 |
1 files changed, 179 insertions, 138 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 40b30308c..b9da934d6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.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 */ @@ -205,8 +205,6 @@ CARD32 nxagentLastEventTime = 0; CARD32 nxagentLastKeyPressTime = 0; Time nxagentLastServerTime = 0; -int nxagentPointerAndKeyboardGrabbed = 0; - /* * Used for storing windows that need to * receive expose events from the agent. @@ -582,6 +580,9 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) { sizeHints.max_width = nxagentOption(RootWidth); sizeHints.max_height = nxagentOption(RootHeight); + + XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], + &sizeHints); } } else @@ -590,6 +591,9 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) nxagentLaunchDialog(DIALOG_ENABLE_DESKTOP_RESIZE_MODE); + nxagentRRSetScreenConfig(pScreen, nxagentOption(Width), + nxagentOption(Height)); + if (nxagentOption(ClientOs) == ClientOsWinnt) { NXSetExposeParameters(nxagentDisplay, 0, 0, 0); @@ -597,10 +601,10 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - } - XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], - &sizeHints); + XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], + &sizeHints); + } } void nxagentShadowSwitchResizeMode(ScreenPtr pScreen) @@ -800,6 +804,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) Bool startKbd = False; Bool closeSession = False; Bool switchFullscreen = False; + Bool switchAllScreens = False; /* * Last entered top level window. @@ -984,6 +989,12 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) break; } + case doSwitchAllScreens: + { + switchAllScreens = TRUE; + + break; + } case doViewportMoveUp: { nxagentMoveViewport(pScreen, 0, -nxagentOption(Height)); @@ -1084,6 +1095,8 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) if (nxagentOption(ViewOnly) == 0 && nxagentOption(Shadow) == 1 && result == doNothing) { + X.xkey.keycode = nxagentConvertKeycode(X.xkey.keycode); + NXShadowEvent(nxagentDisplay, X); } @@ -1095,13 +1108,19 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) int sendKey = 0; /* +FIXME: If we don't flush the queue here, it could happen + that the inputInfo structure will not be up to date + when we perform the following check on down keys. +*/ + ProcessInputEvents(); + +/* FIXME: Don't enqueue the KeyRelease event if the key was not already pressed. This workaround avoids a fake KeyPress is enqueued by the XKEYBOARD extension. Another solution would be to let the events are enqueued and to remove the KeyPress afterwards. */ - if (BitIsOn(inputInfo.keyboard -> key -> down, nxagentConvertKeycode(X.xkey.keycode))) { @@ -1160,6 +1179,8 @@ FIXME: Don't enqueue the KeyRelease event if the key was if (nxagentOption(ViewOnly) == 0 && nxagentOption(Shadow)) { + X.xkey.keycode = nxagentConvertKeycode(X.xkey.keycode); + NXShadowEvent(nxagentDisplay, X); } } @@ -1177,23 +1198,6 @@ FIXME: Don't enqueue the KeyRelease event if the key was nxagentInputEvent = 1; - if (nxagentOption(ClientOs) == ClientOsMac && (X.xbutton.state & ControlMask) == ControlMask) - { - x.u.u.type = ButtonPress; - x.u.u.detail = inputInfo.pointer -> button -> map[3]; - x.u.keyButtonPointer.time = nxagentLastEventTime = GetTimeInMillis(); - - mieqEnqueue(&x); - - x.u.u.type = ButtonRelease; - x.u.u.detail = inputInfo.pointer -> button -> map[3]; - x.u.keyButtonPointer.time = nxagentLastEventTime = GetTimeInMillis(); - - mieqEnqueue(&x); - - break; - } - if (nxagentOption(Fullscreen)) { if (nxagentMagicPixelZone(X.xbutton.x, X.xbutton.y)) @@ -1297,11 +1301,6 @@ FIXME: Don't enqueue the KeyRelease event if the key was nxagentInputEvent = 1; - if (nxagentOption(ClientOs) == ClientOsMac && (X.xbutton.state & ControlMask) == ControlMask) - { - break; - } - if (viewportCursor) { /* @@ -1672,14 +1671,11 @@ FIXME: Don't enqueue the KeyRelease event if the key was nxagentScreenTrap = 0; } - if (nxagentOption(Fullscreen) == 1) + if (nxagentOption(Fullscreen) == 1 && + X.xcrossing.window == nxagentFullscreenWindow && + X.xcrossing.detail != NotifyInferior) { - if (X.xcrossing.window == nxagentDefaultWindows[0] && - X.xcrossing.detail != NotifyInferior && - X.xcrossing.mode == NotifyNormal) - { - nxagentGrabPointerAndKeyboard(&X); - } + nxagentGrabPointerAndKeyboard(&X); } if (X.xcrossing.detail != NotifyInferior) @@ -1986,7 +1982,8 @@ FIXME: Don't enqueue the KeyRelease event if the key was } if (nxagentUseNXTrans == 1 && nxagentOption(Rootless) == 0 && - nxagentOption(Nested) == 0) + nxagentOption(Nested) == 0 && + X.xmap.window != nxagentIconWindow) { nxagentVisibility = VisibilityFullyObscured; } @@ -2025,6 +2022,15 @@ FIXME: Don't enqueue the KeyRelease event if the key was } } + if (nxagentOption(AllScreens) == 1) + { + if (X.xmap.window == nxagentIconWindow) + { + pScreen = nxagentScreen(X.xmap.window); + nxagentMaximizeToFullScreen(pScreen); + } + } + if (nxagentOption(Fullscreen) == 1) { nxagentVisibility = VisibilityUnobscured; @@ -2120,14 +2126,40 @@ FIXME: Don't enqueue the KeyRelease event if the key was if (nxagentWMIsRunning) { - XIconifyWindow(nxagentDisplay, nxagentDefaultWindows[0], - DefaultScreen(nxagentDisplay)); + if (nxagentOption(AllScreens)) + { + nxagentMinimizeFromFullScreen(pScreen); + } + else + { + XIconifyWindow(nxagentDisplay, nxagentDefaultWindows[0], + DefaultScreen(nxagentDisplay)); + } } } if (switchFullscreen) { - nxagentSwitchFullscreen(pScreen, !nxagentOption(Fullscreen)); + if (nxagentOption(AllScreens) == 1 && nxagentOption(Fullscreen) == 1) + { + nxagentSwitchAllScreens(pScreen, 0); + } + else + { + nxagentSwitchFullscreen(pScreen, !nxagentOption(Fullscreen)); + } + } + + if (switchAllScreens) + { + if (nxagentOption(AllScreens) == 0 && nxagentOption(Fullscreen) == 1) + { + nxagentSwitchFullscreen(pScreen, 0); + } + else + { + nxagentSwitchAllScreens(pScreen, !nxagentOption(AllScreens)); + } } if (startKbd) @@ -2599,6 +2631,7 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) { + ScreenPtr pScreen; WindowPtr pWin; xEvent x; @@ -2714,8 +2747,20 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) fprintf(stderr, "Events: WM_DELETE_WINDOW arrived Atom = %ld.\n", wmAtom); #endif - if (X -> xclient.window == nxagentDefaultWindows[0] || - nxagentWMIsRunning == 0) + if (X -> xclient.window == nxagentIconWindow) + { + pScreen = nxagentScreen(X -> xmap.window); + + XMapRaised(nxagentDisplay, nxagentFullscreenWindow); + + XIconifyWindow(nxagentDisplay, nxagentIconWindow, + DefaultScreen(nxagentDisplay)); + + } + + if (X -> xclient.window == (nxagentOption(Fullscreen) ? + nxagentIconWindow : nxagentDefaultWindows[0]) || + nxagentWMIsRunning == 0) { *result = doCloseSession; } @@ -3312,110 +3357,113 @@ int nxagentHandleConfigureNotify(XEvent* X) if (X -> xconfigure.window == nxagentDefaultWindows[pScreen -> myNum]) { - if (nxagentOption(DesktopResize) == 1) + if (nxagentOption(AllScreens) == 0) { - if (nxagentOption(Width) != X -> xconfigure.width || - nxagentOption(Height) != X -> xconfigure.height) + if (nxagentOption(DesktopResize) == 1) { - Bool newEvents = False; + if (nxagentOption(Width) != X -> xconfigure.width || + nxagentOption(Height) != X -> xconfigure.height) + { + Bool newEvents = False; - doRandR = True; + doRandR = True; - NXFlushDisplay(nxagentDisplay, NXFlushLink); + NXFlushDisplay(nxagentDisplay, NXFlushLink); - do - { - newEvents = False; + do + { + newEvents = False; - timeout.tv_sec = 0; - timeout.tv_usec = 500 * 1000; + timeout.tv_sec = 0; + timeout.tv_usec = 500 * 1000; - nxagentWaitEvents(nxagentDisplay, &timeout); + nxagentWaitEvents(nxagentDisplay, &timeout); - /* - * This should also flush - * the NX link for us. - */ + /* + * This should also flush + * the NX link for us. + */ - XSync(nxagentDisplay, 0); + XSync(nxagentDisplay, 0); - while (XCheckTypedWindowEvent(nxagentDisplay, nxagentDefaultWindows[pScreen -> myNum], - ConfigureNotify, X)) - { - newEvents = True; - } + while (XCheckTypedWindowEvent(nxagentDisplay, nxagentDefaultWindows[pScreen -> myNum], + ConfigureNotify, X)) + { + newEvents = True; + } - } while (newEvents); + } while (newEvents); + } } - } - if (nxagentWMIsRunning == 0 || X -> xconfigure.send_event) - { - nxagentChangeOption(X, X -> xconfigure.x); - nxagentChangeOption(Y, X -> xconfigure.y); - } + if (nxagentWMIsRunning == 0 || X -> xconfigure.send_event) + { + nxagentChangeOption(X, X -> xconfigure.x); + nxagentChangeOption(Y, X -> xconfigure.y); + } - if (nxagentOption(Shadow) == 1 && nxagentOption(DesktopResize) == 1 && - (nxagentOption(Width) != X -> xconfigure.width || - nxagentOption(Height) != X -> xconfigure.height)) - { - nxagentShadowResize = 1; - } + if (nxagentOption(Shadow) == 1 && nxagentOption(DesktopResize) == 1 && + (nxagentOption(Width) != X -> xconfigure.width || + nxagentOption(Height) != X -> xconfigure.height)) + { + nxagentShadowResize = 1; + } - nxagentChangeOption(Width, X -> xconfigure.width); - nxagentChangeOption(Height, X -> xconfigure.height); + nxagentChangeOption(Width, X -> xconfigure.width); + nxagentChangeOption(Height, X -> xconfigure.height); - nxagentChangeOption(ViewportXSpan, (int) X -> xconfigure.width - - (int) nxagentOption(RootWidth)); - nxagentChangeOption(ViewportYSpan, (int) X -> xconfigure.height - - (int) nxagentOption(RootHeight)); + nxagentChangeOption(ViewportXSpan, (int) X -> xconfigure.width - + (int) nxagentOption(RootWidth)); + nxagentChangeOption(ViewportYSpan, (int) X -> xconfigure.height - + (int) nxagentOption(RootHeight)); - nxagentMoveViewport(pScreen, 0, 0); + nxagentMoveViewport(pScreen, 0, 0); - if (nxagentOption(Shadow) == 1 || - (nxagentOption(Width) == nxagentOption(RootWidth) && - nxagentOption(Height) == nxagentOption(RootHeight))) - { - doRandR = 0; - } + if (nxagentOption(Shadow) == 1 || + (nxagentOption(Width) == nxagentOption(RootWidth) && + nxagentOption(Height) == nxagentOption(RootHeight))) + { + doRandR = 0; + } - nxagentChangeOption(Width, X -> xconfigure.width); - nxagentChangeOption(Height, X -> xconfigure.height); + nxagentChangeOption(Width, X -> xconfigure.width); + nxagentChangeOption(Height, X -> xconfigure.height); - XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0, - X -> xconfigure.width, X -> xconfigure.height); + XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0, + X -> xconfigure.width, X -> xconfigure.height); - if (nxagentOption(Fullscreen) == 0) - { - nxagentMoveViewport(pScreen, 0, 0); - } - else - { - 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)); - - nxagentUpdateViewportFrame(0, 0, nxagentOption(RootWidth), - nxagentOption(RootHeight)); - - XMoveWindow(nxagentDisplay, nxagentWindow(WindowTable[pScreen -> myNum]), - nxagentOption(RootX), nxagentOption(RootY)); - } + if (nxagentOption(Fullscreen) == 0) + { + nxagentMoveViewport(pScreen, 0, 0); + } + else + { + 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)); + + nxagentUpdateViewportFrame(0, 0, nxagentOption(RootWidth), + nxagentOption(RootHeight)); + + XMoveWindow(nxagentDisplay, nxagentWindow(WindowTable[pScreen -> myNum]), + nxagentOption(RootX), nxagentOption(RootY)); + } - if (doRandR) - { - #ifdef TEST - fprintf(stderr,"nxagentHandleConfigureNotify: Width %d Height %d.\n", - nxagentOption(Width), nxagentOption(Height)); - #endif + if (doRandR) + { + #ifdef TEST + fprintf(stderr,"nxagentHandleConfigureNotify: Width %d Height %d.\n", + nxagentOption(Width), nxagentOption(Height)); + #endif - nxagentRRSetScreenConfig(screenInfo.screens[DefaultScreen(nxagentDisplay)], - nxagentOption(Width), nxagentOption(Height)); + nxagentRRSetScreenConfig(screenInfo.screens[DefaultScreen(nxagentDisplay)], + nxagentOption(Width), nxagentOption(Height)); + } } return 1; @@ -3782,10 +3830,7 @@ void nxagentGrabPointerAndKeyboard(XEvent *X) int resource; - if (nxagentPointerAndKeyboardGrabbed == 1) - { - return; - } + int result; #ifdef TEST fprintf(stderr, "nxagentGrabPointerAndKeyboard: Grabbing pointer and keyboard with event at [%p].\n", @@ -3805,8 +3850,13 @@ void nxagentGrabPointerAndKeyboard(XEvent *X) fprintf(stderr, "nxagentGrabPointerAndKeyboard: Going to grab the keyboard in context [B1].\n"); #endif - XGrabKeyboard(nxagentDisplay, nxagentFullscreenWindow, - True, GrabModeAsync, GrabModeAsync, now); + result = XGrabKeyboard(nxagentDisplay, nxagentFullscreenWindow, + True, GrabModeAsync, GrabModeAsync, now); + + if (result != GrabSuccess) + { + return; + } /* * The smart scheduler could be stopped while @@ -3844,19 +3894,12 @@ void nxagentGrabPointerAndKeyboard(XEvent *X) XSetInputFocus(nxagentDisplay, nxagentFullscreenWindow, RevertToParent, now); } - - nxagentPointerAndKeyboardGrabbed = 1; } void nxagentUngrabPointerAndKeyboard(XEvent *X) { unsigned long now; - if (nxagentPointerAndKeyboardGrabbed == 0) - { - return; - } - #ifdef TEST fprintf(stderr, "nxagentUngrabPointerAndKeyboard: Ungrabbing pointer and keyboard with event at [%p].\n", (void *) X); @@ -3882,8 +3925,6 @@ void nxagentUngrabPointerAndKeyboard(XEvent *X) #endif XUngrabPointer(nxagentDisplay, now); - - nxagentPointerAndKeyboardGrabbed = 0; } void nxagentDeactivatePointerGrab() |