From 9937fbdf5385373c4ea2105efb3a88cac8b78a51 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 10 Apr 2018 23:32:57 +0200 Subject: Screen.c: replace XSetWMNormalHints code block by already existing function nxagentSetWMNormalHints was slightly adapted therefore --- nx-X11/programs/Xserver/hw/nxagent/Extensions.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 41 +++---------------------- nx-X11/programs/Xserver/hw/nxagent/Screen.h | 2 +- 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c index 05a4b4f13..d4f195bb4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c @@ -470,7 +470,7 @@ int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0) { nxagentRandRSetWindowsSize(width, height); - nxagentSetWMNormalHints(pScreen -> myNum); + nxagentSetWMNormalHints(pScreen -> myNum, nxagentOption(Width), nxagentOption(Height)); } nxagentMoveViewport(pScreen, 0, 0); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 675389705..b374b202b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -2281,7 +2281,6 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, int mmWidth, int mmHeight) { BoxRec box; - XSizeHints sizeHints; PixmapPtr pPixmap; char *fbBits; @@ -2407,37 +2406,7 @@ FIXME: We should try to restore the previously if ((nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0)) { - sizeHints.flags = PPosition | PMinSize | PMaxSize; - sizeHints.x = nxagentOption(X); - sizeHints.y = nxagentOption(Y); - - sizeHints.min_width = MIN_NXAGENT_WIDTH; - sizeHints.min_height = MIN_NXAGENT_HEIGHT; - sizeHints.width = width; - sizeHints.height = height; - - if (nxagentOption(DesktopResize) == 1) - { - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - } - else - { - sizeHints.max_width = nxagentOption(RootWidth); - sizeHints.max_height = nxagentOption(RootHeight); - } - - if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue) - { - sizeHints.flags |= USPosition; - } - - if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) - { - sizeHints.flags |= USSize; - } - - XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &sizeHints); + nxagentSetWMNormalHints(pScreen->myNum, width, height); XResizeWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], width, height); @@ -2838,7 +2807,7 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) { nxagentShadowSetWindowsSize(); - nxagentSetWMNormalHints(0); + nxagentSetWMNormalHints(0, nxagentOption(Width), nxagentOption(Height)); } XMapWindow(nxagentDisplay, nxagentDefaultWindows[0]); @@ -4557,7 +4526,7 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, return; } -void nxagentSetWMNormalHints(int screen) +void nxagentSetWMNormalHints(int screen, int width, int height) { XSizeHints sizeHints; @@ -4572,8 +4541,8 @@ void nxagentSetWMNormalHints(int screen) sizeHints.min_width = MIN_NXAGENT_WIDTH; sizeHints.min_height = MIN_NXAGENT_HEIGHT; - sizeHints.width = nxagentOption(Width); - sizeHints.height = nxagentOption(Height); + sizeHints.width = width; + sizeHints.height = height; if (nxagentOption(DesktopResize) == 1) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.h b/nx-X11/programs/Xserver/hw/nxagent/Screen.h index 3df586fa8..416136e53 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.h @@ -130,7 +130,7 @@ int nxagentShadowPoll(PixmapPtr, GCPtr, unsigned char, int, int, char *, int *, void nxagentShadowSetWindowsSize(void); -void nxagentSetWMNormalHints(int); +void nxagentSetWMNormalHints(int, int, int); void nxagentShadowSetRatio(float, float); -- cgit v1.2.3 From 82c4c28ea726444c355835a5a0850b9dd6865e9a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 10 Apr 2018 23:34:14 +0200 Subject: Screen.c/Events.c: add some FIXMEs --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 1 + nx-X11/programs/Xserver/hw/nxagent/Screen.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 5e598f5bc..177860d84 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -3248,6 +3248,7 @@ int nxagentHandleConfigureNotify(XEvent* X) pClient = wClient(pWinWindow); + /* FIXME: override_redirect is always FALSE here */ if (X -> xconfigure.send_event || !nxagentWMIsRunning || X -> xconfigure.override_redirect) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index b374b202b..39a5b7763 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1891,6 +1891,7 @@ N/A if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) sizeHints.flags |= USSize; + /* FIXME: deprecated, replaced by XSetWmProperties() */ XSetStandardProperties(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], nxagentWindowName, @@ -1976,6 +1977,8 @@ N/A deleteWMatom); #endif + /* FIXME: This doing the same thing in both cases. The + comments do not seem accurate (anymore?) */ if (nxagentOption(Rootless) == False) { /* -- cgit v1.2.3 From 82dc00539c12323bb8daa8e0ada6e8eab8561e09 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 11 Apr 2018 00:10:20 +0200 Subject: nxagent: use XAllocSizeHints() instead of XSizeHints struct This is the preferred way. It ensures, that a) the data is zeroed b) a correct size in case xlib is changing the size of the structure in future releases --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 37 ++---- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 188 +++++++++++++++++----------- nx-X11/programs/Xserver/hw/nxagent/Screen.h | 2 + 3 files changed, 130 insertions(+), 97 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 177860d84..9ded855d6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -575,8 +575,6 @@ void nxagentInternalWindowsTree(WindowPtr pWin, int indent) void nxagentSwitchResizeMode(ScreenPtr pScreen) { - XSizeHints sizeHints; - #ifdef DEBUG fprintf(stderr, "nxagentSwitchResizeMode called.\n"); #endif @@ -585,8 +583,6 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) nxagentChangeOption(DesktopResize, !desktopResize); - sizeHints.flags = PMaxSize; - if (nxagentOption(DesktopResize) == 0) { fprintf(stderr,"Info: Disabled desktop resize mode in agent.\n"); @@ -595,11 +591,9 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) if (nxagentOption(Fullscreen) == 0) { - sizeHints.max_width = nxagentOption(RootWidth); - sizeHints.max_height = nxagentOption(RootHeight); - - XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], - &sizeHints); + nxagentSetWMNormalHintsMaxsize(pScreen, + nxagentOption(RootWidth), + nxagentOption(RootHeight)); } } else @@ -616,24 +610,18 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) NXSetExposeParameters(nxagentDisplay, 0, 0, 0); } - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - - XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], - &sizeHints); + nxagentSetWMNormalHintsMaxsize(pScreen, + WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), + HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); } } void nxagentShadowSwitchResizeMode(ScreenPtr pScreen) { - XSizeHints sizeHints; - int desktopResize = nxagentOption(DesktopResize); nxagentChangeOption(DesktopResize, !desktopResize); - sizeHints.flags = PMaxSize; - if (nxagentOption(DesktopResize) == 0) { nxagentShadowSetRatio(1.0, 1.0); @@ -641,8 +629,9 @@ void nxagentShadowSwitchResizeMode(ScreenPtr pScreen) nxagentShadowCreateMainWindow(screenInfo.screens[DefaultScreen(nxagentDisplay)], screenInfo.screens[0]->root, screenInfo.screens[0]->root -> drawable.width, screenInfo.screens[0]->root -> drawable.height); - sizeHints.max_width = nxagentOption(RootWidth); - sizeHints.max_height = nxagentOption(RootHeight); + nxagentSetWMNormalHintsMaxsize(pScreen, + nxagentOption(RootWidth), + nxagentOption(RootHeight)); fprintf(stderr,"Info: Disabled resize mode in shadow agent.\n"); } @@ -657,14 +646,12 @@ void nxagentShadowSwitchResizeMode(ScreenPtr pScreen) screenInfo.screens[0]->root, screenInfo.screens[0]->root -> drawable.width, screenInfo.screens[0]->root -> drawable.height); - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + nxagentSetWMNormalHintsMaxsize(pScreen, + WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), + HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); fprintf(stderr,"Info: Enabled resize mode in shadow agent.\n"); } - - XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], - &sizeHints); } static void nxagentSwitchDeferMode(void) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 39a5b7763..cd50c9698 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -376,8 +376,8 @@ Window nxagentCreateIconWindow(void) unsigned long valuemask; char* window_name; XTextProperty windowName; - XSizeHints sizeHints; - XWMHints wmHints; + XSizeHints* sizeHints; + XWMHints* wmHints; Window w; Mask mask; @@ -416,26 +416,40 @@ Window nxagentCreateIconWindow(void) 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) + + if ((sizeHints = XAllocSizeHints())) { - wmHints.icon_mask = nxagentIconShape; - wmHints.flags = IconPixmapHint | IconMaskHint; + sizeHints->flags = PMinSize | PMaxSize; + sizeHints->min_width = sizeHints->max_width = 1; + sizeHints->min_height = sizeHints->max_height = 1; } - else + + if ((wmHints = XAllocWMHints())) { - wmHints.flags = StateHint | IconPixmapHint; + 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); + NULL , 0 , sizeHints, wmHints, NULL); + + if (sizeHints) + XFree(sizeHints); + + if (wmHints) + XFree(wmHints); /* * Enable events from the icon window. @@ -839,8 +853,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, unsigned long valuemask; XSetWindowAttributes attributes; XWindowAttributes gattributes; - XSizeHints sizeHints; - XWMHints wmHints; + XSizeHints* sizeHints; + XWMHints* wmHints; Mask mask; Bool resetAgentPosition = False; @@ -1866,52 +1880,61 @@ N/A XSelectInput(nxagentDisplay, nxagentFullscreenWindow, mask); } - sizeHints.flags = PPosition | PMinSize | PMaxSize; - sizeHints.x = nxagentOption(X) + POSITION_OFFSET; - sizeHints.y = nxagentOption(Y) + POSITION_OFFSET; - sizeHints.min_width = MIN_NXAGENT_WIDTH; - sizeHints.min_height = MIN_NXAGENT_HEIGHT; - - sizeHints.width = nxagentOption(RootWidth); - sizeHints.height = nxagentOption(RootHeight); - - if (nxagentOption(DesktopResize) == 1 || nxagentOption(Fullscreen) == 1) - { - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - } - else + if ((sizeHints = XAllocSizeHints())) { - sizeHints.max_width = nxagentOption(RootWidth); - sizeHints.max_height = nxagentOption(RootHeight); - } + sizeHints->flags = PPosition | PMinSize | PMaxSize; + sizeHints->x = nxagentOption(X) + POSITION_OFFSET; + sizeHints->y = nxagentOption(Y) + POSITION_OFFSET; + sizeHints->min_width = MIN_NXAGENT_WIDTH; + sizeHints->min_height = MIN_NXAGENT_HEIGHT; + + sizeHints->width = nxagentOption(RootWidth); + sizeHints->height = nxagentOption(RootHeight); - if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue) - sizeHints.flags |= USPosition; - if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) - sizeHints.flags |= USSize; + if (nxagentOption(DesktopResize) == 1 || nxagentOption(Fullscreen) == 1) + { + sizeHints->max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints->max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + } + else + { + sizeHints->max_width = nxagentOption(RootWidth); + sizeHints->max_height = nxagentOption(RootHeight); + } + if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue) + sizeHints->flags |= USPosition; + if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) + sizeHints->flags |= USSize; + } /* FIXME: deprecated, replaced by XSetWmProperties() */ XSetStandardProperties(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], nxagentWindowName, nxagentWindowName, nxagentIconPixmap, - argv, argc, &sizeHints); + argv, argc, sizeHints); - wmHints.icon_pixmap = nxagentIconPixmap; + if (sizeHints) + XFree(sizeHints); - if (useXpmIcon) - { - wmHints.icon_mask = nxagentIconShape; - wmHints.flags = IconPixmapHint | IconMaskHint; - } - else + if ((wmHints = XAllocWMHints())) { - wmHints.flags = IconPixmapHint; - } + wmHints->icon_pixmap = nxagentIconPixmap; - XSetWMHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &wmHints); + if (useXpmIcon) + { + wmHints->icon_mask = nxagentIconShape; + wmHints->flags = IconPixmapHint | IconMaskHint; + } + else + { + wmHints->flags = IconPixmapHint; + } + + XSetWMHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], wmHints); + XFree(wmHints); + } /* * Clear the window but let it unmapped. We'll map it @@ -4531,49 +4554,73 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, void nxagentSetWMNormalHints(int screen, int width, int height) { - XSizeHints sizeHints; + XSizeHints* sizeHints = XAllocSizeHints(); + + if (!sizeHints) + return; /* * Change agent window size and size hints. */ - sizeHints.flags = PPosition | PMinSize | PMaxSize; - sizeHints.x = nxagentOption(X); - sizeHints.y = nxagentOption(Y); + sizeHints->flags = PPosition | PMinSize | PMaxSize; + sizeHints->x = nxagentOption(X); + sizeHints->y = nxagentOption(Y); - sizeHints.min_width = MIN_NXAGENT_WIDTH; - sizeHints.min_height = MIN_NXAGENT_HEIGHT; + sizeHints->min_width = MIN_NXAGENT_WIDTH; + sizeHints->min_height = MIN_NXAGENT_HEIGHT; - sizeHints.width = width; - sizeHints.height = height; + sizeHints->width = width; + sizeHints->height = height; if (nxagentOption(DesktopResize) == 1) { - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints->max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints->max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); } else { - sizeHints.max_width = nxagentOption(RootWidth); - sizeHints.max_height = nxagentOption(RootHeight); + sizeHints->max_width = nxagentOption(RootWidth); + sizeHints->max_height = nxagentOption(RootHeight); } if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue) { - sizeHints.flags |= USPosition; + sizeHints->flags |= USPosition; } if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) { - sizeHints.flags |= USSize; + sizeHints->flags |= USSize; } - XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[screen], &sizeHints); + XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[screen], sizeHints); + + XFree(sizeHints); +} + +/* + set maxsize in WMNormalSizeHints + Note: this will _drop_ all existing hints since XSetWMNormalHints() + replaces any existing property +*/ +void nxagentSetWMNormalHintsMaxsize(ScreenPtr pScreen, int maxwidth, int maxheight) +{ + XSizeHints* sizeHints; + + if ((sizeHints = XAllocSizeHints())) + { + sizeHints->flags = PMaxSize; + sizeHints->max_width = maxwidth; + sizeHints->max_height = maxheight; + XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], + sizeHints); + XFree(sizeHints); + } } void nxagentShadowAdaptToRatio(void) { - XSizeHints sizeHints; ScreenPtr pScreen; RegionRec region; BoxRec box; @@ -4585,12 +4632,9 @@ void nxagentShadowAdaptToRatio(void) nxagentShadowCreateMainWindow(pScreen, screenInfo.screens[0]->root, nxagentShadowWidth, nxagentShadowHeight); - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - - sizeHints.flags = PMaxSize; - - XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &sizeHints); + nxagentSetWMNormalHintsMaxsize(pScreen, + WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), + HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); box.x1 = 0; box.y1 = 0; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.h b/nx-X11/programs/Xserver/hw/nxagent/Screen.h index 416136e53..8e5865f06 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.h @@ -132,6 +132,8 @@ void nxagentShadowSetWindowsSize(void); void nxagentSetWMNormalHints(int, int, int); +void nxagentSetWMNormalHintsMaxsize(ScreenPtr, int, int); + void nxagentShadowSetRatio(float, float); /* -- cgit v1.2.3 From 845ae6eab1794976943e484c202d3d10c673cc30 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 11 Apr 2018 00:28:04 +0200 Subject: Screen.c/Events.c: fix some comments --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 3 +-- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Window.c | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 9ded855d6..0408c4e03 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -3365,8 +3365,7 @@ int nxagentHandleConfigureNotify(XEvent* X) nxagentWaitEvents(nxagentDisplay, &timeout); /* - * This should also flush - * the NX link for us. + * This should also flush the NX link for us. */ XSync(nxagentDisplay, 0); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index cd50c9698..75ecbfad1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -2471,7 +2471,7 @@ FIXME: We should try to restore the previously nxagentMoveViewport(pScreen, 0, 0); /* - * Update void * bounds. + * Update pointer bounds. */ ScreenRestructured(pScreen); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 073021ed8..ca0de468b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -869,8 +869,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) } /* - * This should also flush - * the NX link for us. + * This should also flush the NX link for us. */ XSync(nxagentDisplay, 0); -- cgit v1.2.3 From 00c1f05efd043fb6f2dba342694c7091dad342cb Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 11 Apr 2018 00:39:40 +0200 Subject: nxagent: remove mmwidth/mmheight from nxagentChangeScreenConfig Was 0,0 on every call... --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 7 +++---- nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 8 ++++---- nx-X11/programs/Xserver/hw/nxagent/Screen.h | 2 +- nx-X11/programs/Xserver/hw/nxagent/Window.c | 4 ++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 0408c4e03..34d1d314a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -602,8 +602,7 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) nxagentLaunchDialog(DIALOG_ENABLE_DESKTOP_RESIZE_MODE); - nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentOption(Height), - 0, 0); + nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentOption(Height)); if (nxagentOption(ClientOs) == ClientOsWinnt) { @@ -3451,7 +3450,7 @@ int nxagentHandleConfigureNotify(XEvent* X) #endif nxagentChangeScreenConfig(0, nxagentOption(Width), - nxagentOption(Height), 0, 0); + nxagentOption(Height)); } } @@ -3471,7 +3470,7 @@ int nxagentHandleConfigureNotify(XEvent* X) nxagentChangeOption(RootHeight, X -> xconfigure.height); nxagentChangeScreenConfig(0, nxagentOption(Width), - nxagentOption(Height), 0, 0); + nxagentOption(Height)); return 1; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index 56ac017ad..9a6cbf28b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -626,7 +626,7 @@ Bool nxagentReconnectSession(void) if (nxagentResizeDesktopAtStartup || nxagentOption(Rootless) == True || nxagentOption(Xinerama) == True) { nxagentChangeScreenConfig(0, nxagentOption(RootWidth), - nxagentOption(RootHeight), 0, 0); + nxagentOption(RootHeight)); nxagentResizeDesktopAtStartup = False; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 75ecbfad1..c29df9275 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3834,13 +3834,13 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen) RRScreenSizeNotify(pScreen); } -int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, int mmHeight) +int nxagentChangeScreenConfig(int screen, int width, int height) { ScreenPtr pScreen; int r; #ifdef DEBUG - fprintf(stderr, "nxagentChangeScreenConfig: called for screen [%d], width [%d] height [%d] mmWidth [%d] mmHeight [%d]\n", screen, width, height, mmWidth, mmHeight); + fprintf(stderr, "nxagentChangeScreenConfig: called for screen [%d], width [%d] height [%d]\n", screen, width, height); #endif #ifdef TEST @@ -3885,10 +3885,10 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in pScreen = screenInfo.screens[screen] -> root -> drawable.pScreen; #ifdef TEST - fprintf(stderr, "nxagentChangeScreenConfig: Changing config to %d x %d (%dmm x %dmm).\n", width, height, mmWidth, mmHeight); + fprintf(stderr, "nxagentChangeScreenConfig: Changing config to %d x %d\n", width, height); #endif - r = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight); + r = nxagentResizeScreen(pScreen, width, height, 0, 0); if (r != 0) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.h b/nx-X11/programs/Xserver/hw/nxagent/Screen.h index 8e5865f06..14b20a7d0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.h @@ -110,7 +110,7 @@ Bool nxagentMagicPixelZone(int x, int y); Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, int mmWidth, int mmHeight); -int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, int mmHeight); +int nxagentChangeScreenConfig(int screen, int width, int height); int nxagentAdjustRandRXinerama(ScreenPtr pScreen); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index ca0de468b..b12fe76de 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -952,7 +952,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) if (nxagentOption(Shadow) == 0) { nxagentChangeScreenConfig(0, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), - HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), 0, 0); + HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); } else { @@ -1006,7 +1006,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) if (nxagentOption(Shadow) == 0) { nxagentChangeScreenConfig(0, nxagentOption(RootWidth), - nxagentOption(RootHeight), 0, 0); + nxagentOption(RootHeight)); } } -- cgit v1.2.3 From f9bae755424cc413707e9657c8baf84a6cd8effe Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 4 May 2018 22:29:55 +0200 Subject: Events.c: catch intermediate window position changes nxagentHandleConfigureNotify() has an optimization that accumulates ConfigureNotify events from the queue to only perform the changes of the last ConfigureNotify event in the queue. But that code used to ignore position changes and only adapt the new window position if the last event happened to contain a position change. This change ensures the latest position change - if any - found in the queue will be applied after the accumulation. Fixes: ArticaProject/nx-libs#688 (second part) --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 40 +++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 34d1d314a..dee8dd7e0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -3341,13 +3341,26 @@ int nxagentHandleConfigureNotify(XEvent* X) { if (nxagentOption(AllScreens) == 0) { + /* + * - WITHOUT window manager any position change is relevant + * - WITH window manager only synthetic position changes send + * by the window manager are relevant, see ICCCM Chapter 4, + * "Configuring the Window" + */ + Bool updatePos = (nxagentWMIsRunning == 0 || X -> xconfigure.send_event != 0); + int newX = X -> xconfigure.x; + int newY = X -> xconfigure.y; + if (nxagentOption(DesktopResize) == 1) { if (nxagentOption(Width) != X -> xconfigure.width || nxagentOption(Height) != X -> xconfigure.height || - nxagentOption(X) != X -> xconfigure.x || - nxagentOption(Y) != X -> xconfigure.y) + (updatePos && (nxagentOption(X) != newX || + nxagentOption(Y) != newY))) { + #ifdef DEBUG + int count = 0; + #endif Bool newEvents = False; doRandR = True; @@ -3372,17 +3385,34 @@ int nxagentHandleConfigureNotify(XEvent* X) while (XCheckTypedWindowEvent(nxagentDisplay, nxagentDefaultWindows[pScreen -> myNum], ConfigureNotify, X)) { + #ifdef DEBUG + count++; + #endif + + if (nxagentWMIsRunning == 0 || X -> xconfigure.send_event) + { + updatePos = True; + newX = X -> xconfigure.x; + newY = X -> xconfigure.y; + } newEvents = True; } } while (newEvents); + + #ifdef DEBUG + fprintf(stderr, "%s: accumulated %d events\n", __func__, count); + #endif } } - if (nxagentWMIsRunning == 0 || X -> xconfigure.send_event) + if (updatePos) { - nxagentChangeOption(X, X -> xconfigure.x); - nxagentChangeOption(Y, X -> xconfigure.y); + #ifdef DEBUG + fprintf(stderr, "%s: Updating nxagent window position [%d,%d]\n", __func__, newX, newY); + #endif + nxagentChangeOption(X, newX); + nxagentChangeOption(Y, newY); } if (nxagentOption(Shadow) == 1 && nxagentOption(DesktopResize) == 1 && -- cgit v1.2.3 From 0167591986a482dc516d0ae62cda87aa421d4dc9 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 5 May 2018 20:13:20 +0200 Subject: Screen.c: simplify setting of window name/class --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index c29df9275..db8e713b2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1812,20 +1812,6 @@ N/A * we need it to properly display all window parameters by some WMs * (for example on Maemo) */ - if(nxagentX2go) - { - #ifdef TEST - fprintf(stderr, "nxagentOpenScreen: Setting WM_CLASS and WM_NAME for window with id [%ld].\n", - (long int)nxagentDefaultWindows[pScreen->myNum]); - #endif - XClassHint hint; - hint.res_name = strdup("X2GoAgent"); - hint.res_class = strdup("X2GoAgent"); - XSetClassHint(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &hint); - free(hint.res_name); - free(hint.res_class); - } - else { #ifdef TEST fprintf(stderr, "nxagentOpenScreen: Setting WM_CLASS and WM_NAME for window with id [%ld].\n", @@ -1833,8 +1819,17 @@ N/A #endif XClassHint hint; - hint.res_name = strdup("NXAgent"); - hint.res_class = strdup("NXAgent"); + + if(nxagentX2go) + { + hint.res_name = strdup("X2GoAgent"); + hint.res_class = strdup("X2GoAgent"); + } + else + { + hint.res_name = strdup("NXAgent"); + hint.res_class = strdup("NXAgent"); + } XSetClassHint(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &hint); free(hint.res_name); free(hint.res_class); -- cgit v1.2.3 From 9138a9e3bf6f1b0962c20a29735c4f89dc80d572 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 5 May 2018 20:14:04 +0200 Subject: whitespace fixes --- nx-X11/programs/Xserver/hw/nxagent/Events.h | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 4 ++-- nx-X11/programs/Xserver/hw/nxagent/Screen.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.h b/nx-X11/programs/Xserver/hw/nxagent/Events.h index bf9d10c74..5175be1ce 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.h @@ -231,7 +231,7 @@ Bool nxagentPendingEvents(Display *dpy); XEventsQueued((display), QueuedAfterReading) #define nxagentCheckEvents(display, event, predicate, argument) \ - XCheckIfEventNoFlush((display), (event), (predicate), (argument)) + XCheckIfEventNoFlush((display), (event), (predicate), (argument)) int nxagentWaitEvents(Display *, struct timeval *); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index db8e713b2..6eae711f5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1864,8 +1864,8 @@ N/A nxagentDefaultWindows[pScreen->myNum], nxagentAtoms[8], /* NX_AGENT_SIGNATURE */ XA_STRING, - 8, - PropModeReplace, + 8, + PropModeReplace, (unsigned char*) "X-AGENT", strlen("X-AGENT")); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.h b/nx-X11/programs/Xserver/hw/nxagent/Screen.h index 14b20a7d0..2f93105ef 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.h @@ -48,7 +48,7 @@ is" without express or implied warranty. #define nxagentSetPrintGeometry(screen) \ nxagentPrintGeometryFlags = (1 << (screen)); - + extern int nxagentClients; extern int nxagentAutoDisconnectTimeout; -- cgit v1.2.3