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(-) (limited to 'nx-X11/programs/Xserver/hw') 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