From 0f8ed4d103b3f68d5cedaa611b47b7cdb1e0517c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 11 May 2020 18:33:01 +0200 Subject: Screen.c: fix resizing bug with mutter window manager Not really sure why I introduced the client check years ago. Grabbed is grabbed, so I don't see a reason implementing it this way. Fixes ArcticaProject/nx-libs#925. --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 2bdc4bde5..4654bbfcd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3675,7 +3675,7 @@ int nxagentChangeScreenConfig(int screen, int width, int height) fprintf(stderr, "nxagentChangeScreenConfig: grabstate [UNKNOWN], client [%p]\n", (void *) nxagentGrabServerInfo.client); #endif - if (nxagentGrabServerInfo.grabstate == SERVER_GRABBED && nxagentGrabServerInfo.client != NULL) + if (nxagentGrabServerInfo.grabstate == SERVER_GRABBED) { /* * If any client grabbed the server it won't expect screen -- cgit v1.2.3 From abe5e8479aca9f53ed4778336978bf7bd623c56a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 15 May 2020 18:25:07 +0200 Subject: Display.c: factor out confinement window creation --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 54 +++++++++++++--------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 55e40b461..2db83e9db 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -1105,6 +1105,28 @@ void nxagentResetSignalHandlers(void) nxagentInitTimer(); } +/* + * currently unused it seems + */ +void nxagentOpenConfineWindow(void) +{ + nxagentConfineWindow = XCreateWindow(nxagentDisplay, + DefaultRootWindow(nxagentDisplay), + 0, 0, 1, 1, 0, 0, + InputOnly, + CopyFromParent, + 0L, NULL); + + if (nxagentReportWindowIds) { + fprintf(stderr, "NXAGENT_WINDOW_ID: CONFINEMENT_WINDOW,WID:[0x%x]\n", + nxagentConfineWindow); + } + + #ifdef TEST + fprintf(stderr, "%s: Created agent's confine window with id [0x%x].\n", __func__, nxagentConfineWindow); + #endif +} + void nxagentOpenDisplay(int argc, char *argv[]) { if (!nxagentDoFullGeneration) @@ -1298,21 +1320,7 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. We need fprintf(stderr, "nxagentOpenDisplay: Going to create agent's confine window.\n"); #endif - nxagentConfineWindow = XCreateWindow(nxagentDisplay, - DefaultRootWindow(nxagentDisplay), - 0, 0, 1, 1, 0, 0, - InputOnly, - CopyFromParent, - 0L, NULL); - - if (nxagentReportWindowIds) { - fprintf(stderr, "NXAGENT_WINDOW_ID: CONFINEMENT_WINDOW,WID:[0x%x]\n", - nxagentConfineWindow); - } - #ifdef TEST - fprintf(stderr, "nxagentOpenDisplay: Created agent's confine window with id [0x%x].\n", - nxagentConfineWindow); - #endif + nxagentOpenConfineWindow(); if (!(nxagentUserGeometry.flag & XValue)) { @@ -2665,21 +2673,7 @@ Bool nxagentReconnectDisplay(void *p0) fprintf(stderr, "nxagentReconnectDisplay: Going to create agent's confine window.\n"); #endif - nxagentConfineWindow = XCreateWindow(nxagentDisplay, - DefaultRootWindow(nxagentDisplay), - 0, 0, 1, 1, 0, 0, - InputOnly, - CopyFromParent, - 0L, NULL); - - if (nxagentReportWindowIds) { - fprintf(stderr, "NXAGENT_WINDOW_ID: CONFINEMENT_WINDOW,WID:[0x%x]\n", - nxagentConfineWindow); - } - #ifdef TEST - fprintf(stderr, "nxagentReconnectDisplay: Created agent's confine window with id [0x%x].\n", - nxagentConfineWindow); - #endif + nxagentOpenConfineWindow(); useXpmIcon = nxagentMakeIcon(nxagentDisplay, &nxagentIconPixmap, &nxagentIconShape); -- cgit v1.2.3 From 8deda7bd4f1ada976010c2edcd7cab9a4bdf8140 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 19 May 2020 20:59:02 +0200 Subject: nxagent: Prevent resize loop This only happened with certain window managers like mutter. Fixes ArcticaProject/nx-libs#925 --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 19 +++++++++++++------ nx-X11/programs/Xserver/hw/nxagent/Extensions.c | 4 ++-- nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 21 +++++++++++++++------ nx-X11/programs/Xserver/hw/nxagent/Screen.h | 4 ++-- nx-X11/programs/Xserver/hw/nxagent/Window.c | 4 ++-- 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 847d40918..bf6e20e20 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -588,7 +588,7 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) nxagentLaunchDialog(DIALOG_ENABLE_DESKTOP_RESIZE_MODE); - nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentOption(Height)); + nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentOption(Height), True); if (nxagentOption(ClientOs) == ClientOsWinnt) { @@ -2082,7 +2082,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already X.xmap.window == nxagentDefaultWindows[nxagentScreen(X.xmap.window)->myNum]) { nxagentChangeScreenConfig(nxagentScreen(X.xmap.window)->myNum, nxagentOption(Width), - nxagentOption(Height)); + nxagentOption(Height), True); } break; @@ -3412,9 +3412,16 @@ int nxagentHandleConfigureNotify(XEvent* X) fprintf(stderr,"%s: Width %d Height %d.\n", __func__, nxagentOption(Width), nxagentOption(Height)); #endif - + /* + * we are processing a ConfigureNotifyEvent that brought us + * the current window size. If we issue a XResizeWindow() + * again with these values we might end up in loop if the + * window manager adjusts the size, which is perfectly + * legal for it to do. So we prevent the XResizeWindow call + * from happening. + */ nxagentChangeScreenConfig(0, nxagentOption(Width), - nxagentOption(Height)); + nxagentOption(Height), False); } } @@ -3435,7 +3442,7 @@ int nxagentHandleConfigureNotify(XEvent* X) nxagentChangeOption(RootHeight, X -> xconfigure.height); nxagentChangeScreenConfig(0, nxagentOption(Width), - nxagentOption(Height)); + nxagentOption(Height), True); return 1; } @@ -4310,7 +4317,7 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X) #endif nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)], Xr -> width, Xr -> height, - Xr -> mwidth, Xr -> mheight); + Xr -> mwidth, Xr -> mheight, True); nxagentShadowCreateMainWindow(screenInfo.screens[DefaultScreen(nxagentDisplay)], screenInfo.screens[0]->root, Xr -> width, Xr -> height); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c index 239d84b85..52c3b0375 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c @@ -378,7 +378,7 @@ int nxagentRandRSetConfig(ScreenPtr pScreen, Rotation rotation, */ int r = nxagentResizeScreen(pScreen, pSize -> width, pSize -> height, - pSize -> mmWidth, pSize -> mmHeight); + pSize -> mmWidth, pSize -> mmHeight, True); nxagentMoveViewport(pScreen, 0, 0); @@ -448,7 +448,7 @@ int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, nxagentChangeOption(Height, height); } - int result = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight); + int result = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight, True); if (result == 1 && nxagentOption(DesktopResize) == 1 && nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index 90e796772..602351d10 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -633,7 +633,7 @@ Bool nxagentReconnectSession(void) if (nxagentResizeDesktopAtStartup || nxagentOption(Rootless) == True || nxagentOption(Xinerama) == True) { nxagentChangeScreenConfig(0, nxagentOption(RootWidth), - nxagentOption(RootHeight)); + nxagentOption(RootHeight), True); nxagentResizeDesktopAtStartup = False; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 4654bbfcd..52ecea854 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -2243,7 +2243,7 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) } Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, - int mmWidth, int mmHeight) + int mmWidth, int mmHeight, Bool doresize) { #ifdef TEST nxagentPrintAgentGeometry("Before Resize Screen", "nxagentResizeScreen:"); @@ -2365,10 +2365,19 @@ FIXME: We should try to restore the previously { nxagentSetWMNormalHints(pScreen->myNum, width, height); - XResizeWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], width, height); + if (doresize) + { + #ifdef DEBUG + fprintf(stderr, "%s: resizing DefaultWindow to [%d]x[%d]\n", __func__, width, height); + #endif + XResizeWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], width, height); + } if (nxagentOption(Rootless) == 0) { + #ifdef DEBUG + fprintf(stderr, "%s: resizing InputWindow to [%d]x[%d]\n", __func__, width, height); + #endif XResizeWindow(nxagentDisplay, nxagentInputWindows[pScreen -> myNum], width, height); } } @@ -2691,7 +2700,7 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) AddResource(accessWindowID, RT_WINDOW, (void *)nxagentShadowWindowPtr); - nxagentResizeScreen(pScreen, nxagentShadowWidth, nxagentShadowHeight, pScreen -> mmWidth, pScreen -> mmHeight); + nxagentResizeScreen(pScreen, nxagentShadowWidth, nxagentShadowHeight, pScreen -> mmWidth, pScreen -> mmHeight, True); nxagentShadowCreateMainWindow(pScreen, pWin, nxagentShadowWidth, nxagentShadowHeight); @@ -3646,10 +3655,10 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen) RRScreenSizeNotify(pScreen); } -int nxagentChangeScreenConfig(int screen, int width, int height) +int nxagentChangeScreenConfig(int screen, int width, int height, Bool doresize) { #ifdef DEBUG - fprintf(stderr, "nxagentChangeScreenConfig: called for screen [%d], width [%d] height [%d]\n", screen, width, height); + fprintf(stderr, "nxagentChangeScreenConfig: called for screen [%d], width [%d] height [%d] doresize [%d]\n", screen, width, height, doresize); #endif #ifdef TEST @@ -3697,7 +3706,7 @@ int nxagentChangeScreenConfig(int screen, int width, int height) fprintf(stderr, "nxagentChangeScreenConfig: Changing config to %d x %d\n", width, height); #endif - int r = nxagentResizeScreen(pScreen, width, height, 0, 0); + int r = nxagentResizeScreen(pScreen, width, height, 0, 0, doresize); if (r != 0) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.h b/nx-X11/programs/Xserver/hw/nxagent/Screen.h index 6d775e1cc..3eb16ea3c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.h @@ -110,9 +110,9 @@ Window nxagentCreateIconWindow(void); Bool nxagentMagicPixelZone(int x, int y); Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, - int mmWidth, int mmHeight); + int mmWidth, int mmHeight, Bool doresize); -int nxagentChangeScreenConfig(int screen, int width, int height); +int nxagentChangeScreenConfig(int screen, int width, int height, Bool doresize); 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 e6b9c03df..56ca30c4e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -891,7 +891,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) if (nxagentOption(Shadow) == 0) { nxagentChangeScreenConfig(0, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), - HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); + HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), True); } else { @@ -945,7 +945,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) if (nxagentOption(Shadow) == 0) { nxagentChangeScreenConfig(0, nxagentOption(RootWidth), - nxagentOption(RootHeight)); + nxagentOption(RootHeight), True); } } -- cgit v1.2.3 From 337afd839b99733baed52e7b1d01d24c737a8849 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 18:36:21 +0200 Subject: Events.c: add more DEBUG output --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 89 +++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 11 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index bf6e20e20..899afcce6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -3135,8 +3135,26 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X) return 1; } +#define DEBUG +#define TEST + int nxagentHandleConfigureNotify(XEvent* X) { + #ifdef DEBUG + fprintf(stderr, "%s: Event info:\n", __func__); + fprintf(stderr, "%s: X->serial [%ld]\n", __func__, X->xconfigure.serial); + fprintf(stderr, "%s: X->override_redirect [%d]\n", __func__, X->xconfigure.override_redirect); + fprintf(stderr, "%s: X->border_width [%d]\n", __func__, X->xconfigure.border_width); + fprintf(stderr, "%s: X->send_event [%d]\n", __func__, X->xconfigure.send_event); + fprintf(stderr, "%s: X->window [0x%lx]\n", __func__, X->xconfigure.window); + fprintf(stderr, "%s: X->event [0x%lx]\n", __func__, X->xconfigure.event); + fprintf(stderr, "%s: X->x, X->y [%d][%d]\n", __func__, X->xconfigure.x, X->xconfigure.y); + fprintf(stderr, "%s: X->width, X->height [%d][%d]\n", __func__, X->xconfigure.width, X->xconfigure.height); + fprintf(stderr, "%s: References:\n", __func__); + fprintf(stderr, "%s: DefaultWindow[0]: [0x%x]\n", __func__, nxagentDefaultWindows[0]); + fprintf(stderr, "%s: DefaultRootWindow(DISPLAY) [0x%lx]\n", __func__, DefaultRootWindow(nxagentDisplay)); +#endif + if (nxagentOption(Rootless) == True) { int sendEventAnyway = 0; @@ -3326,6 +3344,10 @@ int nxagentHandleConfigureNotify(XEvent* X) if (!nxagentWMIsRunning || X -> xconfigure.send_event) { updatePos = True; + #ifdef DEBUG + fprintf(stderr, "%s: Accumulating event %d: x [%d] y [%d] width [%d] height [%d]\n", __func__, count, + X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width, X -> xconfigure.height); + #endif newX = X -> xconfigure.x; newY = X -> xconfigure.y; } @@ -3340,10 +3362,11 @@ int nxagentHandleConfigureNotify(XEvent* X) } } - if (updatePos) + if (updatePos && (nxagentOption(X) != newX || nxagentOption(Y) != newY)) { #ifdef DEBUG - fprintf(stderr, "%s: Updating nxagent window position [%d,%d]\n", __func__, newX, newY); + fprintf(stderr, "%s: Updating nxagent window position [%d,%d] -> [%d,%d]\n", __func__, + nxagentOption(X), nxagentOption(Y), newX, newY); #endif nxagentChangeOption(X, newX); nxagentChangeOption(Y, newY); @@ -3356,8 +3379,16 @@ int nxagentHandleConfigureNotify(XEvent* X) nxagentShadowResize = 1; } - nxagentChangeOption(Width, X -> xconfigure.width); - nxagentChangeOption(Height, X -> xconfigure.height); + if (nxagentOption(Width) != X->xconfigure.width || nxagentOption(Height) != X->xconfigure.height) + { + #ifdef DEBUG + fprintf(stderr, "%s: Updating width and height [%d,%d] -> [%d,%d]\n", __func__, + nxagentOption(Width), nxagentOption(Height), + X->xconfigure.width, X->xconfigure.height); + #endif + nxagentChangeOption(Width, X -> xconfigure.width); + nxagentChangeOption(Height, X -> xconfigure.height); + } nxagentChangeOption(ViewportXSpan, (int) X -> xconfigure.width - (int) nxagentOption(RootWidth)); @@ -3378,9 +3409,6 @@ int nxagentHandleConfigureNotify(XEvent* X) doRandR = False; } - nxagentChangeOption(Width, X -> xconfigure.width); - nxagentChangeOption(Height, X -> xconfigure.height); - XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0, X -> xconfigure.width, X -> xconfigure.height); @@ -3449,13 +3477,31 @@ int nxagentHandleConfigureNotify(XEvent* X) } } + #ifdef TEST + fprintf(stderr, "%s: received for unexpected window [%ld]\n", __func__, X -> xconfigure.window); + #endif + return 0; } int nxagentHandleReparentNotify(XEvent* X) { #ifdef TEST - fprintf(stderr, "%s: Going to handle a new reparent event.\n", __func__); + fprintf(stderr, "%s: Going to handle a new reparent event (serial [%ld].\n", __func__, X->xreparent.serial); + #endif + + #ifdef DEBUG + fprintf(stderr, "%s: Event info:\n", __func__); + fprintf(stderr, "%s: X->send_event [%d]\n", __func__, X->xreparent.send_event); + fprintf(stderr, "%s: X->event [0x%lx]\n", __func__, X->xreparent.event); + fprintf(stderr, "%s: X->window [0x%lx]\n", __func__, X->xreparent.window); + fprintf(stderr, "%s: X->parent [0x%lx]\n", __func__, X->xreparent.parent); + fprintf(stderr, "%s: X->x, X->y [%d][%d]\n", __func__, X->xreparent.x, X->xreparent.y); + fprintf(stderr, "%s: X->override_redirect [%d]\n", __func__, X->xreparent.override_redirect); + fprintf(stderr, "%s: References:\n", __func__); + fprintf(stderr, "%s: DefaultWindow[0]: [0x%x]\n", __func__, nxagentDefaultWindows[0]); + fprintf(stderr, "%s: RootWindow(DISPLAY, 0): [0x%lx]\n", __func__, RootWindow(nxagentDisplay, 0)); + fprintf(stderr, "%s: DefaultRootWindow(DISPLAY): [0x%lx]\n", __func__, DefaultRootWindow(nxagentDisplay)); #endif if (nxagentOption(Rootless)) @@ -3560,21 +3606,30 @@ int nxagentHandleReparentNotify(XEvent* X) &attributes) == 0)) { #ifdef WARNING - fprintf(stderr, "%s: WARNING! XGetWindowAttributes failed.\n", __func__); + fprintf(stderr, "%s: WARNING! XGetWindowAttributes for parent window failed.\n", __func__); #endif return 1; } + XlibWindow junk; int x = attributes.x; int y = attributes.y; - XlibWindow junk; + #ifdef DEBUG + int before_x = x; + int before_y = y; + #endif + XTranslateCoordinates(nxagentDisplay, X -> xreparent.window, attributes.root, -attributes.border_width, -attributes.border_width, &x, &y, &junk); - /* + #ifdef DEBUG + fprintf(stderr, "%s: translated coordinates x,y [%d,%d] -> [%d,%d].\n", __func__, before_x, before_y, x, y); + #endif + + /* * Calculate the parent X and parent Y. */ @@ -3623,6 +3678,18 @@ int nxagentHandleReparentNotify(XEvent* X) nxagentChangeOption(WMBorderWidth, (x - attributes.x)); nxagentChangeOption(WMTitleHeight, (y - attributes.y)); + + #ifdef DEBUG + fprintf(stderr, "%s: WMBorderWidth [%d]\n", __func__, nxagentOption(WMBorderWidth)); + fprintf(stderr, "%s: WMTitleHeight [%d]\n", __func__, nxagentOption(WMTitleHeight)); + fprintf(stderr, "%s: win_gravity [%d]\n", __func__, attributes.win_gravity); + fprintf(stderr, "%s: bit_gravity [%d]\n", __func__, attributes.bit_gravity); + fprintf(stderr, "%s: border_width [%d]\n", __func__, attributes.border_width); + fprintf(stderr, "%s: height [%d]\n", __func__, attributes.height); + fprintf(stderr, "%s: width [%d]\n", __func__, attributes.width); + fprintf(stderr, "%s: x [%d]\n", __func__, attributes.x); + fprintf(stderr, "%s: y [%d]\n", __func__, attributes.y); + #endif } } -- cgit v1.2.3 From ffbc63f918d1ae1f340a67b96f89906ccc88758e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 18:49:53 +0200 Subject: Events.c: add some comments/FIXMEs --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 899afcce6..bfce2f012 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -3275,7 +3275,7 @@ int nxagentHandleConfigureNotify(XEvent* X) return 1; } } - else + else /* (nxagentOption(Rootless) == True) */ { /* * Save the position of the agent default window. Don't save the @@ -3298,7 +3298,7 @@ int nxagentHandleConfigureNotify(XEvent* X) { /* * - WITHOUT window manager any position change is relevant - * - WITH window manager only synthetic position changes send + * - WITH window manager only synthetic position changes sent * by the window manager are relevant, see ICCCM Chapter 4, * "Configuring the Window" */ @@ -3414,6 +3414,7 @@ int nxagentHandleConfigureNotify(XEvent* X) if (nxagentOption(Fullscreen) == 0) { + /* FIXME: has already been done some lines above */ nxagentMoveViewport(pScreen, 0, 0); } else -- cgit v1.2.3 From a4dd6a462d79c5c85ba43923fb5414cef62574f3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 18:52:36 +0200 Subject: Events.c: store parent window from event to meaningful variable --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index bfce2f012..172715987 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -3602,9 +3602,9 @@ int nxagentHandleReparentNotify(XEvent* X) * Calculate the absolute upper-left X e Y */ + XlibWindow parent = X -> xreparent.parent; XWindowAttributes attributes; - if ((XGetWindowAttributes(nxagentDisplay, X -> xreparent.window, - &attributes) == 0)) + if ((XGetWindowAttributes(nxagentDisplay, parent, &attributes) == 0)) { #ifdef WARNING fprintf(stderr, "%s: WARNING! XGetWindowAttributes for parent window failed.\n", __func__); @@ -3622,7 +3622,7 @@ int nxagentHandleReparentNotify(XEvent* X) int before_y = y; #endif - XTranslateCoordinates(nxagentDisplay, X -> xreparent.window, + XTranslateCoordinates(nxagentDisplay, parent, attributes.root, -attributes.border_width, -attributes.border_width, &x, &y, &junk); @@ -3634,9 +3634,7 @@ int nxagentHandleReparentNotify(XEvent* X) * Calculate the parent X and parent Y. */ - XlibWindow w = X -> xreparent.parent; - - if (w != DefaultRootWindow(nxagentDisplay)) + if (parent != DefaultRootWindow(nxagentDisplay)) { XlibWindow rootReturn = 0; XlibWindow parentReturn = 0; @@ -3645,7 +3643,7 @@ int nxagentHandleReparentNotify(XEvent* X) do { - Status result = XQueryTree(nxagentDisplay, w, &rootReturn, &parentReturn, + Status result = XQueryTree(nxagentDisplay, parent, &rootReturn, &parentReturn, &childrenReturn, &nchildrenReturn); SAFE_XFree(childrenReturn); @@ -3655,7 +3653,7 @@ int nxagentHandleReparentNotify(XEvent* X) break; } - w = parentReturn; + parent = parentReturn; } while (True); @@ -3663,7 +3661,7 @@ int nxagentHandleReparentNotify(XEvent* X) * WM reparented. Find edge of the frame. */ - if (XGetWindowAttributes(nxagentDisplay, w, &attributes) == 0) + if (XGetWindowAttributes(nxagentDisplay, parent, &attributes) == 0) { #ifdef WARNING fprintf(stderr, "%s: WARNING! XGetWindowAttributes failed for parent window.\n", __func__); -- cgit v1.2.3 From 210db316300c9a24f74963fc90d0eb59db9555a5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 19:31:29 +0200 Subject: Display.c: disable confine window We are not using it anywhere so let's disable it via a macro for now. --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 4 ++++ nx-X11/programs/Xserver/hw/nxagent/Display.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 2db83e9db..5ba3d5d12 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -159,6 +159,7 @@ Pixmap nxagentScreenSaverPixmap; XlibGC nxagentBitmapGC; +#ifdef NX_CONFINE_WINDOW /* * The "confine" window is used in the nxagentConstrainCursor * procedure. We are currently overriding the original Xnest @@ -166,6 +167,7 @@ XlibGC nxagentBitmapGC; */ Window nxagentConfineWindow; +#endif Pixmap nxagentIconPixmap; Pixmap nxagentIconShape; @@ -1110,6 +1112,7 @@ void nxagentResetSignalHandlers(void) */ void nxagentOpenConfineWindow(void) { +#ifdef NX_CONFINE_WINDOW nxagentConfineWindow = XCreateWindow(nxagentDisplay, DefaultRootWindow(nxagentDisplay), 0, 0, 1, 1, 0, 0, @@ -1125,6 +1128,7 @@ void nxagentOpenConfineWindow(void) #ifdef TEST fprintf(stderr, "%s: Created agent's confine window with id [0x%x].\n", __func__, nxagentConfineWindow); #endif +#endif } void nxagentOpenDisplay(int argc, char *argv[]) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.h b/nx-X11/programs/Xserver/hw/nxagent/Display.h index 759b0de35..2d4119a46 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.h @@ -59,6 +59,7 @@ extern Pixel nxagentWhitePixel; extern Drawable nxagentDefaultDrawables[MAXDEPTH + 1]; extern Pixmap nxagentScreenSaverPixmap; +#ifdef NX_CONFINE_WINDOW /* * The "confine" window is used in nxagentConstrainCursor(). * We are currently overriding the original Xnest behaviour @@ -66,6 +67,7 @@ extern Pixmap nxagentScreenSaverPixmap; */ extern Window nxagentConfineWindow; +#endif /* * Keyboard and pointer are handled as they were hardware -- cgit v1.2.3 From ce649c02747e45208dedfed1ee7a329a24652ecd Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 19:54:15 +0200 Subject: nxagent: add names to some windows in DEBUG mode --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 12 +++++++ nx-X11/programs/Xserver/hw/nxagent/Screen.c | 51 ++++++++++++++++++++++++---- nx-X11/programs/Xserver/hw/nxagent/Window.c | 26 ++++++++++++++ 3 files changed, 83 insertions(+), 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 5ba3d5d12..9adc67a21 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -1125,6 +1125,18 @@ void nxagentOpenConfineWindow(void) nxagentConfineWindow); } + #ifdef DEBUG + { + char *winname = NULL; + if (-1 != asprintf(&winname, "%s Confine", nxagentWindowName)) + { + Xutf8SetWMProperties(nxagentDisplay, nxagentConfineWindow, + winname, winname, NULL , 0 , NULL, NULL, NULL); + SAFE_free(winname); + } + } + #endif + #ifdef TEST fprintf(stderr, "%s: Created agent's confine window with id [0x%x].\n", __func__, nxagentConfineWindow); #endif diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 52ecea854..e2ceede23 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -466,9 +466,23 @@ Window nxagentCreateIconWindow(void) } } + char *winname = NULL; + #ifdef DEBUG + if (-1 == asprintf(&winname, "%s Icon", nxagentWindowName)) + { + /* If memory allocation wasn't possible, or some other error + occurs, these functions will return -1, and the contents of + winname are undefined. */ + winname = NULL; + } + #endif + Xutf8SetWMProperties(nxagentDisplay, w, - nxagentWindowName, nxagentWindowName, - NULL , 0 , sizeHints, wmHints, NULL); + winname ? winname : nxagentWindowName, + winname ? winname : nxagentWindowName, + NULL , 0 , sizeHints, wmHints, NULL); + + SAFE_free(winname); SAFE_XFree(sizeHints); SAFE_XFree(wmHints); @@ -1768,6 +1782,18 @@ N/A fprintf(stderr, "NXAGENT_WINDOW_ID: INPUT_WINDOW:[%d],WID:[0x%x]\n", pScreen->myNum, nxagentInputWindows[pScreen->myNum]); } + #ifdef DEBUG + { + char *winname = NULL; + if (-1 != asprintf(&winname, "%s Input", nxagentWindowName)) + { + Xutf8SetWMProperties(nxagentDisplay, nxagentInputWindows[pScreen->myNum], + winname, winname, NULL , 0 , NULL, NULL, NULL); + SAFE_free(winname); + } + } + #endif + #ifdef TEST fprintf(stderr, "nxagentOpenScreen: Created new input window for screen [%d] with id [0x%x].\n", pScreen->myNum, nxagentInputWindows[pScreen->myNum]); @@ -1873,11 +1899,24 @@ N/A } } + char *winname = NULL; + #ifdef DEBUG + if (-1 == asprintf(&winname, "%s Default[%d]", nxagentWindowName, pScreen->myNum)) + { + /* If memory allocation wasn't possible, or some other error + occurs, these functions will return -1, and the contents of + winname are undefined. */ + winname = NULL; + } + #endif + Xutf8SetWMProperties(nxagentDisplay, - nxagentDefaultWindows[pScreen->myNum], - nxagentWindowName, - nxagentWindowName, - argv , argc , sizeHints, wmHints, NULL); + nxagentDefaultWindows[pScreen->myNum], + winname ? winname : nxagentWindowName, + winname ? winname : nxagentWindowName, + argv , argc , sizeHints, wmHints, NULL); + + SAFE_free(winname); SAFE_XFree(sizeHints); SAFE_XFree(wmHints); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 56ca30c4e..97c4700e4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -403,6 +403,19 @@ Bool nxagentCreateWindow(WindowPtr pWin) { fprintf(stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x],INT:[0x%x]\n", nxagentWindowPriv(pWin)->window, pWin->drawable.id); } + + #ifdef DEBUG + { + char *winname = NULL; + if (-1 != asprintf(&winname, "%s Private[0x%lx]", nxagentWindowName, pWin->drawable.id)) + { + Xutf8SetWMProperties(nxagentDisplay, nxagentWindowPriv(pWin)->window, + winname, winname, NULL , 0 , NULL, NULL, NULL); + SAFE_free(winname); + } + } + #endif + #ifdef TEST fprintf(stderr, "nxagentCreateWindow: Created new window with id [0x%x].\n", nxagentWindowPriv(pWin)->window); @@ -2995,6 +3008,19 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer { fprintf(stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x],INT:[0x%x]\n", nxagentWindowPriv(pWin)->window, pWin->drawable.id); } + + #ifdef DEBUG + { + char *winname = NULL; + if (-1 != asprintf(&winname, "%s Private[0x%lx]", nxagentWindowName, pWin->drawable.id)) + { + Xutf8SetWMProperties(nxagentDisplay, nxagentWindowPriv(pWin)->window, + winname, winname, NULL , 0 , NULL, NULL, NULL); + SAFE_free(winname); + } + } + #endif + #ifdef TEST fprintf(stderr, "nxagentReconnectWindow: Created new window with id [0x%x].\n", nxagentWindowPriv(pWin)->window); -- cgit v1.2.3 From e48ceedcce8d9560b53bc8b58cf8bf3d23b1b63e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 20:19:26 +0200 Subject: Screen.c: improve debug output --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 42 ++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index e2ceede23..4db4785df 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1757,7 +1757,7 @@ N/A } #ifdef TEST - fprintf(stderr, "nxagentOpenScreen: Created new default window for screen [%d] with id [0x%x].\n", + fprintf(stderr, "%s: Created new default window for screen [%d] with id [0x%x].\n", __func__, pScreen->myNum, nxagentDefaultWindows[pScreen->myNum]); #endif @@ -1795,7 +1795,7 @@ N/A #endif #ifdef TEST - fprintf(stderr, "nxagentOpenScreen: Created new input window for screen [%d] with id [0x%x].\n", + fprintf(stderr, "%s: Created new input window for screen [%d] with id [0x%x].\n", __func__, pScreen->myNum, nxagentInputWindows[pScreen->myNum]); #endif } @@ -2284,6 +2284,11 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, int mmWidth, int mmHeight, Bool doresize) { + #ifdef DEBUG + fprintf(stderr, "%s: called with w [%d] (%dmm) h [%d] (%dmm) doresize [%d]\n", + __func__, width, mmWidth, height, mmHeight, doresize); + #endif + #ifdef TEST nxagentPrintAgentGeometry("Before Resize Screen", "nxagentResizeScreen:"); #endif @@ -2345,6 +2350,11 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, pScreen -> mmWidth = mmWidth; pScreen -> mmHeight = mmHeight; + #ifdef DEBUG + fprintf(stderr, "%s: old w [%d] (%dmm) h [%d] (%dmm) new w [%d] (%dmm) h [%d] (%dmm)\n", + __func__, oldWidth, oldMmWidth, oldHeight, oldMmHeight, width, mmWidth, height, mmHeight); + #endif + PixmapPtr pPixmap = fbGetScreenPixmap(pScreen); char *fbBits = realloc(pPixmap -> devPrivate.ptr, PixmapBytePad(width, pScreen->rootDepth) * @@ -2368,15 +2378,13 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, FIXME: We should try to restore the previously reallocated frame buffer pixmap. */ - - pScreen -> width = oldWidth; - pScreen -> height = oldHeight; - pScreen -> mmWidth = oldMmWidth; - pScreen -> mmHeight = oldMmHeight; - goto nxagentResizeScreenError; } + #ifdef DEBUG + fprintf(stderr, "%s: setting RootWidth/Height to [%d]x[%d]\n", __func__, width, height); + #endif + nxagentChangeOption(RootWidth, width); nxagentChangeOption(RootHeight, height); @@ -2437,10 +2445,18 @@ FIXME: We should try to restore the previously RegionInit(&pScreen->root -> clipList, &box, 1); RegionInit(&pScreen->root -> borderClip, &box, 1); + #ifdef DEBUG + fprintf(stderr, "%s: calling PositionWindow() [0,0] for root Window\n", __func__); + #endif + (*pScreen -> PositionWindow)(pScreen->root, 0, 0); nxagentSetRootClip(pScreen, 1); + #ifdef DEBUG + fprintf(stderr, "%s: moving root window to [%d,%d]\n", __func__, nxagentOption(RootX), nxagentOption(RootY)); + #endif + XMoveWindow(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), nxagentOption(RootX), nxagentOption(RootY)); @@ -2807,7 +2823,7 @@ int nxagentShadowCreateMainWindow(ScreenPtr pScreen, WindowPtr pWin, int width, nxagentShadowPixmapPtr -> drawable.id = accessPixmapID; #ifdef TEST - fprintf(stderr, "nxagentShadowCreateMainWindow: nxagentShadowPixmapPtr [%p] PixmapM -> drawable.id [%lu].\n", + fprintf(stderr, "nxagentShadowCreateMainWindow: nxagentShadowPixmapPtr [%p] PixmapM -> drawable.id [%u].\n", (void *)nxagentShadowPixmapPtr, nxagentShadowPixmapPtr -> drawable.id); fprintf(stderr, "nxagentShadowCreateMainWindow: Create pixmap with width [%d] height [%d] depth [%d].\n", nxagentShadowWidth, nxagentShadowHeight, (int)nxagentShadowDepth); @@ -2884,10 +2900,10 @@ int nxagentShadowCreateMainWindow(ScreenPtr pScreen, WindowPtr pWin, int width, { #ifdef TEST fprintf(stderr, "nxagentShadowCreateMainWindow: Create window with nxagentShadowWindowPtr [%p]" - "nxagentShadowWindowPtr -> drawable.id [%lu].\n", (void *) nxagentShadowWindowPtr, + "nxagentShadowWindowPtr -> drawable.id [%u].\n", (void *) nxagentShadowWindowPtr, nxagentShadowWindowPtr -> drawable.id); - fprintf(stderr, "nxagentShadowCreateMainWindow: parent nxagentShadowWindowPtr [%p] parent -> drawable.id [%lu].\n", + fprintf(stderr, "nxagentShadowCreateMainWindow: parent nxagentShadowWindowPtr [%p] parent -> drawable.id [%u].\n", (void *)nxagentShadowWindowPtr->parent, nxagentShadowWindowPtr -> parent -> drawable.id); #endif @@ -3669,8 +3685,8 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen) } #ifdef TEST - fprintf(stderr, "%s: Going to destroy mode %p with refcnt %d.\n", - __func__, nxagentRRCustomMode, nxagentRRCustomMode->refcnt); + fprintf(stderr, "%s: Going to destroy mode [%p] with refcnt [%d].\n", + __func__, (void *)nxagentRRCustomMode, nxagentRRCustomMode->refcnt); #endif RRModeDestroy(nxagentRRCustomMode); -- cgit v1.2.3 From 1af470a235b5ab46ba486d6dda143808f47512d9 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 21:55:03 +0200 Subject: Screen.c: improve output of nxagentPrintAgentGeometry --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 20 ++++++++++++-------- nx-X11/programs/Xserver/hw/nxagent/Window.c | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 4db4785df..18e5410a0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -780,32 +780,36 @@ void nxagentPrintAgentGeometry(char *hdrMessage, char *prefix) if (hdrMessage) { - fprintf(stderr, "--------------- %s -----------------.\n", hdrMessage); + fprintf(stderr, "%s /--------------- %s -----------------.\n", prefix, hdrMessage); } - fprintf(stderr, "%s Root window at offset (%d,%d) size (%d,%d).\n", prefix, + fprintf(stderr, "%s | Root window at offset (%d,%d) size (%d,%d).\n", prefix, nxagentOption(RootX), nxagentOption(RootY), nxagentOption(RootWidth), nxagentOption(RootHeight)); - fprintf(stderr, "%s Default window at offset (%d,%d) size (%d,%d) border size %d.\n", prefix, + fprintf(stderr, "%s | Default window at offset (%d,%d) size (%d,%d) border size %d.\n", prefix, nxagentOption(X), nxagentOption(Y), nxagentOption(Width), nxagentOption(Height), nxagentOption(BorderWidth)); - fprintf(stderr, "%s Span between root window and default window is (%d,%d).\n", prefix, + fprintf(stderr, "%s | Span between root window and default window is (%d,%d).\n", prefix, nxagentOption(ViewportXSpan), nxagentOption(ViewportYSpan)); - fprintf(stderr, "%s Default window in window mode has offset (%d,%d) and size (%d,%d).\n", prefix, + fprintf(stderr, "%s | Default window in window mode has offset (%d,%d) and size (%d,%d).\n", prefix, nxagentOption(SavedX), nxagentOption(SavedY), nxagentOption(SavedWidth), nxagentOption(SavedHeight)); - fprintf(stderr, "%s Fullscreen is %s.\n", prefix, + fprintf(stderr, "%s | Fullscreen is %s.\n", prefix, nxagentOption(Fullscreen) ? "ON" : "OFF"); - fprintf(stderr, "%s Desktop resize mode is %s.\n", prefix, + fprintf(stderr, "%s | Desktop resize mode is %s.\n", prefix, nxagentOption(DesktopResize) ? "ON" : "OFF"); - fprintf(stderr, "%s Resize desktop at startup is %s.\n", prefix, + fprintf(stderr, "%s | Resize desktop at startup is %s.\n", prefix, nxagentResizeDesktopAtStartup ? "ON" : "OFF"); + if (hdrMessage) + { + fprintf(stderr, "%s \\--------------- %s -----------------.\n", prefix, hdrMessage); + } #endif } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 97c4700e4..f528696d8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -417,7 +417,7 @@ Bool nxagentCreateWindow(WindowPtr pWin) #endif #ifdef TEST - fprintf(stderr, "nxagentCreateWindow: Created new window with id [0x%x].\n", + fprintf(stderr, "%s: Created new window with id [0x%x].\n", __func__, nxagentWindowPriv(pWin)->window); #endif @@ -817,7 +817,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) for (i = 0; i < 100 && nxagentWMIsRunning; i++) { #ifdef TEST - fprintf(stderr, "nxagentSwitchAllScreens: WARNING! Going to wait for the ReparentNotify event.\n"); + fprintf(stderr, "%s: WARNING! Going to wait for the ReparentNotify event.\n", __func__); #endif if (XCheckTypedWindowEvent(nxagentDisplay, w, ReparentNotify, &e)) @@ -920,7 +920,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) */ #ifdef WARNING - fprintf(stderr, "nxagentSwitchAllScreens: WARNING! Expected ReparentNotify event missing.\n"); + fprintf(stderr, "%s: WARNING! Expected ReparentNotify event missing.\n", __func__); #endif nxagentWMIsRunning = False; -- cgit v1.2.3 From 2ada71fba786be79a09b4ab657d8d46a5719ce5a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 22:20:43 +0200 Subject: Screen.c: simplify nxagentResizeScreen --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 18e5410a0..0c1c177d6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -2310,26 +2310,25 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, pScreen -> height = height; /* - * Compute screen dimensions if they aren't given. + * Compute screen dimensions if they aren't provided. */ if (mmWidth == 0) { if (monitorResolution < 0) { - mmWidth = width * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) / - DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay)); + mmWidth = width * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) / + DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay)); } else { - mmWidth = (width * 254 + monitorResolution * 5) / (monitorResolution * 10); + mmWidth = (width * 254 + monitorResolution * 5) / (monitorResolution * 10); } if (mmWidth < 1) { mmWidth = 1; } - } if (mmHeight == 0) @@ -2348,7 +2347,6 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, { mmHeight = 1; } - } pScreen -> mmWidth = mmWidth; @@ -2362,14 +2360,9 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, PixmapPtr pPixmap = fbGetScreenPixmap(pScreen); char *fbBits = realloc(pPixmap -> devPrivate.ptr, PixmapBytePad(width, pScreen->rootDepth) * - height * BitsPerPixel(pScreen->rootDepth) / 8); + height * BitsPerPixel(pScreen->rootDepth) / 8); if (fbBits == NULL) { - pScreen -> width = oldWidth; - pScreen -> height = oldHeight; - pScreen -> mmWidth = oldMmWidth; - pScreen -> mmHeight = oldMmHeight; - goto nxagentResizeScreenError; } @@ -2481,6 +2474,14 @@ FIXME: We should try to restore the previously return 1; nxagentResizeScreenError: + #ifdef DEBUG + fprintf(stderr, "%s: nxagentResizeScreenError\n", __func__); + #endif + + pScreen -> width = oldWidth; + pScreen -> height = oldHeight; + pScreen -> mmWidth = oldMmWidth; + pScreen -> mmHeight = oldMmHeight; return 0; } -- cgit v1.2.3 From 2a92ed0f53b15d15e3b309f9ebc992ee98eb426e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 23:48:04 +0200 Subject: Window.c: -reportprivatewids reports root window as such and not as a "private" window like all others. --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index f528696d8..7620284fb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -401,13 +401,18 @@ Bool nxagentCreateWindow(WindowPtr pWin) if (nxagentReportPrivateWindowIds) { - fprintf(stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x],INT:[0x%x]\n", nxagentWindowPriv(pWin)->window, pWin->drawable.id); + fprintf(stderr, "NXAGENT_WINDOW_ID: %s_WINDOW,WID:[0x%x],INT:[0x%x]\n", + (pWin->drawable.id == pWin->drawable.pScreen->root->drawable.id) ? "ROOT" : "PRIVATE", + nxagentWindowPriv(pWin)->window, pWin->drawable.id); } #ifdef DEBUG { char *winname = NULL; - if (-1 != asprintf(&winname, "%s Private[0x%lx]", nxagentWindowName, pWin->drawable.id)) + + if (-1 != asprintf(&winname, "%s %s[0x%lx]", nxagentWindowName, + (pWin->drawable.id == pWin->drawable.pScreen->root->drawable.id) ? "Root" : "Private", + pWin->drawable.id)) { Xutf8SetWMProperties(nxagentDisplay, nxagentWindowPriv(pWin)->window, winname, winname, NULL , 0 , NULL, NULL, NULL); @@ -3006,13 +3011,18 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer if (nxagentReportPrivateWindowIds) { - fprintf(stderr, "NXAGENT_WINDOW_ID: PRIVATE_WINDOW,WID:[0x%x],INT:[0x%x]\n", nxagentWindowPriv(pWin)->window, pWin->drawable.id); + fprintf(stderr, "NXAGENT_WINDOW_ID: %s_WINDOW,WID:[0x%x],INT:[0x%x]\n", + (pWin->drawable.id == pWin->drawable.pScreen->root->drawable.id) ? "ROOT" : "PRIVATE", + nxagentWindowPriv(pWin)->window, pWin->drawable.id); } #ifdef DEBUG { char *winname = NULL; - if (-1 != asprintf(&winname, "%s Private[0x%lx]", nxagentWindowName, pWin->drawable.id)) + + if (-1 != asprintf(&winname, "%s %s[0x%lx]", nxagentWindowName, + (pWin->drawable.id == pWin->drawable.pScreen->root->drawable.id) ? "Root" : "Private", + pWin->drawable.id)) { Xutf8SetWMProperties(nxagentDisplay, nxagentWindowPriv(pWin)->window, winname, winname, NULL , 0 , NULL, NULL, NULL); -- cgit v1.2.3 From 601a57849582ff635289e84bf919ebce8fd2fbcf Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 23:49:25 +0200 Subject: Window.c: simplify setting of isMapped private var --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 7620284fb..94a1bb9ee 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -380,6 +380,8 @@ Bool nxagentCreateWindow(WindowPtr pWin) if (nxagentOption(Rootless) == 1) { + nxagentWindowPriv(pWin) -> isMapped = 0; + if (pWin != nxagentRootlessWindow) { WindowPtr pParent = pWin -> parent; @@ -388,14 +390,6 @@ Bool nxagentCreateWindow(WindowPtr pWin) { nxagentWindowPriv(pWin) -> isMapped = 1; } - else - { - nxagentWindowPriv(pWin) -> isMapped = 0; - } - } - else - { - nxagentWindowPriv(pWin) -> isMapped = 0; } } -- cgit v1.2.3 From 832e0281131667de253bf5e64b6afa384ed56943 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 25 May 2020 23:58:50 +0200 Subject: NXwindow.c: fix some format specifiers --- nx-X11/programs/Xserver/hw/nxagent/NXwindow.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index 43d00a21d..a8d1849ae 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -149,7 +149,7 @@ InitRootWindow(WindowPtr pWin) if (nxagentOption(Rootless)) { #ifdef TEST - fprintf(stderr, "InitRootWindow: Assigned agent root to window at [%p][%ld] with parent [%p].\n", + fprintf(stderr, "InitRootWindow: Assigned agent root to window at [%p][%d] with parent [%p].\n", (void *) pWin, nxagentWindowPriv(pWin)->window, (void *) pWin -> parent); #endif @@ -381,13 +381,12 @@ ConfigureWindow(register WindowPtr pWin, register Mask mask, XID *vlist, ClientP #ifdef TEST if (nxagentWindowTopLevel(pWin)) { - - fprintf(stderr, "ConfigureWindow: pWin [%p] mask [%lu] client [%p]\n", - pWin, mask, client); + fprintf(stderr, "ConfigureWindow: pWin [%p] mask [%u] client [%p]\n", + (void *)pWin, mask, (void *)client); fprintf(stderr, "ConfigureWindow: x [%d] y [%d] w [%d] h [%d] CWStackMode [%d] " "smode [%d] pSib [%p]\n", - x, y, w, h, (mask & CWStackMode) ? 1 : 0, smode, pSib); + x, y, w, h, (mask & CWStackMode) ? 1 : 0, smode, (void *)pSib); } #endif @@ -683,7 +682,7 @@ MapWindow(register WindowPtr pWin, ClientPtr client) #ifdef TEST if (nxagentWindowTopLevel(pWin)) { - fprintf(stderr, "MapWindow: pWin [%p] client [%p]\n", pWin, client); + fprintf(stderr, "MapWindow: pWin [%p] client [%p]\n", (void *)pWin, (void *)client); } #endif #endif -- cgit v1.2.3 From 3a7c375932d5f34be61347c58739e2e47f59aae5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 00:05:51 +0200 Subject: Init.c: small simplification --- nx-X11/programs/Xserver/hw/nxagent/Init.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index 804c8c43b..b06d8e239 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -405,10 +405,8 @@ void nxagentNotifyConnection(int fd, int ready, void *data) void InitInput(int argc, char *argv[]) { - void *ptr, *kbd; - - ptr = AddInputDevice(nxagentPointerProc, True); - kbd = AddInputDevice(nxagentKeyboardProc, True); + void *ptr = AddInputDevice(nxagentPointerProc, True); + void *kbd = AddInputDevice(nxagentKeyboardProc, True); RegisterPointerDevice(ptr); RegisterKeyboardDevice(kbd); -- cgit v1.2.3 From 00d60a82e7b1b5ba62073ed891266709a59343f3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 00:06:40 +0200 Subject: Screen.c: cleanup auto dpi handling new code is easier to read --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 0c1c177d6..dbe1d5d56 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1332,13 +1332,16 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, rootDepth, (long unsigned int)defaultVisual); #endif - if ((monitorResolution < 1) && (nxagentAutoDPI == False)) + if (monitorResolution < 1) { - monitorResolution = NXAGENT_DEFAULT_DPI; - } - else if ((monitorResolution < 1) && (nxagentAutoDPI == True)) - { - monitorResolution = NXAGENT_AUTO_DPI; + if (nxagentAutoDPI) + { + monitorResolution = NXAGENT_AUTO_DPI; + } + else + { + monitorResolution = NXAGENT_DEFAULT_DPI; + } } if (!fbScreenInit(pScreen, pFrameBufferBits, nxagentOption(RootWidth), nxagentOption(RootHeight), -- cgit v1.2.3 From ed4cbaeda12e0d8324c406ae3986274227f5f69f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 00:08:03 +0200 Subject: Screen.c: scope improvement --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index dbe1d5d56..909a34b2d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -846,7 +846,6 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int depthIndex; unsigned long valuemask; XSetWindowAttributes attributes; - XWindowAttributes gattributes; Mask mask; Bool resetAgentPosition = False; @@ -1424,6 +1423,8 @@ N/A * and a GetGeometry (asynchronous) reply. */ + XWindowAttributes gattributes; + XGetWindowAttributes(nxagentDisplay, nxagentParentWindow, &gattributes); nxagentChangeOption(Width, gattributes.width); -- cgit v1.2.3 From 2c6b9117fecd23ec683bff2986a894ad75f54e36 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 00:37:58 +0200 Subject: Screen.c: remove code that will have no effect setting a value for an attribute in the structure is pointless if you do not set the valuemask accordingly. Adding the missing valuemask code here would also be pointless because the valuemask is set to a fixed value later on. Therefore we can drop this code here. --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 909a34b2d..172598779 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1431,11 +1431,6 @@ N/A nxagentChangeOption(Height, gattributes.height); } - if (nxagentOption(AllScreens)) - { - attributes.override_redirect = True; - } - if (nxagentOption(Fullscreen)) { /* -- cgit v1.2.3 From d07c788813d6e72882e9a30821007be49157adea Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 00:43:44 +0200 Subject: Screen.c: remove another pointless code block Setting nxagentDefaultWindow[pScreen->myNum] is pointless because it is overwritten in the next code block... --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 172598779..494750038 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1727,16 +1727,6 @@ N/A * handling the splash screen. */ - if (nxagentOption(Rootless) == True) - { - nxagentDefaultWindows[pScreen->myNum] = DefaultRootWindow(nxagentDisplay); - - #ifdef TEST - fprintf(stderr, "nxagentOpenScreen: Using root window id [%ld].\n", - (long int)nxagentDefaultWindows[pScreen->myNum]); - #endif - } - #ifdef TEST fprintf(stderr, "nxagentOpenScreen: Going to create new default window.\n"); #endif -- cgit v1.2.3 From d7a091a6402f625c9213b6d403b8e19f0e133b49 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 00:46:18 +0200 Subject: Screen.c: drop unneccessary mask variable --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 494750038..c7e158636 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -846,7 +846,6 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int depthIndex; unsigned long valuemask; XSetWindowAttributes attributes; - Mask mask; Bool resetAgentPosition = False; VisualID defaultVisual; @@ -1714,9 +1713,7 @@ N/A { nxagentDefaultWindows[pScreen->myNum] = nxagentParentWindow; - mask = nxagentGetDefaultEventMask(); - - XSelectInput(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], mask); + XSelectInput(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], nxagentGetDefaultEventMask()); } else { @@ -1757,8 +1754,7 @@ N/A if (nxagentOption(Rootless) == 0) { valuemask = CWEventMask; - mask = PointerMotionMask; - attributes.event_mask = mask; + attributes.event_mask = PointerMotionMask; nxagentInputWindows[pScreen->myNum] = XCreateWindow(nxagentDisplay, @@ -1845,9 +1841,7 @@ N/A strlen("X-AGENT")); } - mask = nxagentGetDefaultEventMask(); - - XSelectInput(nxagentDisplay, nxagentFullscreenWindow, mask); + XSelectInput(nxagentDisplay, nxagentFullscreenWindow, nxagentGetDefaultEventMask()); } XSizeHints* sizeHints = XAllocSizeHints(); -- cgit v1.2.3 From f534a48601a2b239db48ebb8b984f2951c57dc3e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 00:51:58 +0200 Subject: Screen.c: move attributes/valuemask to inner scopes --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index c7e158636..5c543da19 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -844,8 +844,6 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, DepthPtr depths; int numVisuals, numDepths; int depthIndex; - unsigned long valuemask; - XSetWindowAttributes attributes; Bool resetAgentPosition = False; VisualID defaultVisual; @@ -1678,15 +1676,16 @@ N/A if (nxagentDoFullGeneration == 1 || nxagentReconnectTrap == 1) { - valuemask = CWBackPixel | CWEventMask | CWColormap | - (nxagentOption(AllScreens) == 1 ? CWOverrideRedirect : 0); - - attributes.background_pixel = nxagentBlackPixel; - attributes.event_mask = nxagentGetDefaultEventMask(); - attributes.colormap = nxagentDefaultVisualColormap(nxagentDefaultVisual(pScreen)); + unsigned long valuemask = CWBackPixel | CWEventMask | CWColormap; + XSetWindowAttributes attributes = { + .background_pixel = nxagentBlackPixel, + .event_mask = nxagentGetDefaultEventMask(), + .colormap = nxagentDefaultVisualColormap(nxagentDefaultVisual(pScreen)) + }; if (nxagentOption(AllScreens) == 1) { + valuemask |= CWOverrideRedirect; attributes.override_redirect = True; } @@ -1753,8 +1752,7 @@ N/A if (nxagentOption(Rootless) == 0) { - valuemask = CWEventMask; - attributes.event_mask = PointerMotionMask; + XSetWindowAttributes inpattributes = {.event_mask = PointerMotionMask}; nxagentInputWindows[pScreen->myNum] = XCreateWindow(nxagentDisplay, @@ -1764,7 +1762,7 @@ N/A nxagentOption(Height), 0, 0, InputOnly, nxagentDefaultVisual(pScreen), - valuemask , &attributes); + CWEventMask, &inpattributes); if (nxagentReportWindowIds) { -- cgit v1.2.3 From 42fb683315d1472e7aeec6cc98d453d6663803f4 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 00:53:32 +0200 Subject: Screen.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 38 ++++++++++------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 5c543da19..98add8add 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -837,24 +837,10 @@ void freeDepths(DepthPtr depths, int num) SAFE_free(depths); } -Bool nxagentOpenScreen(ScreenPtr pScreen, - int argc, char *argv[]) +Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) { - VisualPtr visuals; - DepthPtr depths; - int numVisuals, numDepths; - int depthIndex; Bool resetAgentPosition = False; - VisualID defaultVisual; - int rootDepth; - - void * pFrameBufferBits; - int bitsPerPixel; - int sizeInBytes; - - int defaultVisualIndex = 0; - #ifdef TEST fprintf(stderr, "nxagentOpenScreen: Called for screen index [%d].\n", pScreen->myNum); @@ -1161,7 +1147,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, * Initialize the depths. */ - depths = (DepthPtr) malloc(nxagentNumDepths * sizeof(DepthRec)); + DepthPtr depths = (DepthPtr) malloc(nxagentNumDepths * sizeof(DepthRec)); for (int i = 0; i < nxagentNumDepths; i++) { @@ -1179,10 +1165,12 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, "[%d].\n", nxagentNumVisuals); #endif - numVisuals = 0; - numDepths = nxagentNumDepths; + int numVisuals = 0; + int numDepths = nxagentNumDepths; - visuals = (VisualPtr) malloc(nxagentNumVisuals * sizeof(VisualRec)); + VisualPtr visuals = (VisualPtr) malloc(nxagentNumVisuals * sizeof(VisualRec)); + + int defaultVisualIndex = 0; for (int i = 0; i < nxagentNumVisuals; i++) { @@ -1231,10 +1219,9 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, if (j < numVisuals) continue; - } - depthIndex = UNDEFINED; + int depthIndex = UNDEFINED; #if defined(DEBUG) || defined(DEBUG_COLORMAP) fprintf(stderr, "Debug: Added visual [%lu].\n" , @@ -1292,12 +1279,13 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, visuals[defaultVisualIndex].nplanes); #endif - defaultVisual = visuals[defaultVisualIndex].vid; - rootDepth = visuals[defaultVisualIndex].nplanes; + VisualID defaultVisual = visuals[defaultVisualIndex].vid; + int rootDepth = visuals[defaultVisualIndex].nplanes; nxagentInitAlphaVisual(); - bitsPerPixel = nxagentBitsPerPixel(rootDepth); + int bitsPerPixel = nxagentBitsPerPixel(rootDepth); + int sizeInBytes; if (bitsPerPixel == 1) { @@ -1313,7 +1301,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, "[%d] bitsPerPixel [%d] sizeInBytes [%d]\n", rootDepth, bitsPerPixel, sizeInBytes); #endif - pFrameBufferBits = (char *) malloc(sizeInBytes); + void * pFrameBufferBits = (char *) malloc(sizeInBytes); if (!pFrameBufferBits) { -- cgit v1.2.3 From 199c32eaf3f02d58d9ec560b2838be52608471ef Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 00:54:02 +0200 Subject: Screen.c: some more (cosmetic) changes --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 110 +++++++++++++--------------- 1 file changed, 49 insertions(+), 61 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 98add8add..f8507aa59 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -177,7 +177,7 @@ void nxagentPrintAgentGeometry(char *hdrMessage, char *prefix); */ int nxagentShadowResize = 0; - + WindowPtr nxagentShadowWindowPtr = NULL; static XID accessPixmapID; @@ -971,7 +971,6 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) #endif nxagentChangeOption(Fullscreen, False); - nxagentChangeOption(AllScreens, False); nxagentFullscreenWindow = 0; @@ -1162,7 +1161,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) #if defined(DEBUG) || defined(DEBUG_COLORMAP) fprintf(stderr, "Debug: Setting up visuals. Original array has size " - "[%d].\n", nxagentNumVisuals); + "[%d].\n", nxagentNumVisuals); #endif int numVisuals = 0; @@ -1196,7 +1195,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) #if defined(DEBUG) || defined(DEBUG_COLORMAP) fprintf(stderr, "Debug: Set default visual index [%d].\n" , - defaultVisualIndex); + defaultVisualIndex); #endif } else @@ -1216,7 +1215,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) visuals[numVisuals].offsetBlue == visuals[j].offsetBlue) break; } - + if (j < numVisuals) continue; } @@ -1225,7 +1224,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) #if defined(DEBUG) || defined(DEBUG_COLORMAP) fprintf(stderr, "Debug: Added visual [%lu].\n" , - (long unsigned int)visuals[numVisuals].vid); + (long unsigned int)visuals[numVisuals].vid); #endif for (int j = 0; j < numDepths; j++) @@ -1265,7 +1264,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) #if defined(DEBUG) || defined(DEBUG_COLORMAP) fprintf(stderr, "Debug: Registered visual [%lu] for depth [%d (%d)].\n" , (long unsigned int)visuals[numVisuals].vid, depthIndex, - depths[depthIndex].depth); + depths[depthIndex].depth); #endif numVisuals++; @@ -1276,7 +1275,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) defaultVisualIndex, (long unsigned int)visuals[defaultVisualIndex].vid); fprintf(stderr, "Debug: Setting root depth [%d].\n", - visuals[defaultVisualIndex].nplanes); + visuals[defaultVisualIndex].nplanes); #endif VisualID defaultVisual = visuals[defaultVisualIndex].vid; @@ -1343,9 +1342,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) #endif /* - * Complete the initialization of the GLX - * extension. This will add the GLX visuals - * and will modify numVisuals and numDepths. + * Complete the initialization of the GLX extension. This will add + * the GLX visuals and will modify numVisuals and numDepths. */ #if defined(DEBUG) || defined(DEBUG_COLORMAP) @@ -1364,8 +1362,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) #endif /* - * Replace the visuals and depths initialized - * by fbScreenInit with our own. + * Replace the visuals and depths initialized by fbScreenInit with + * our own. */ freeDepths(pScreen->allowedDepths, pScreen->numDepths); @@ -1379,9 +1377,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) pScreen -> rootVisual = defaultVisual; /* - * Set up the internal structures used for - * tracking the proxy resources associated - * to the unpack and split operations. + * Set up the internal structures used for tracking the proxy + * resources associated to the unpack and split operations. */ nxagentInitSplitResources(); @@ -1419,9 +1416,9 @@ N/A if (nxagentOption(Fullscreen)) { /* - * We need to disable the host's screensaver or - * it will otherwise grab the screen even if it - * is under agent's control. + * We need to disable the host's screensaver or it will + * otherwise grab the screen even if it is under agent's + * control. */ XSetScreenSaver(nxagentDisplay, 0, 0, DefaultExposures, DefaultBlanking); @@ -1444,7 +1441,7 @@ N/A * * if (!miScreenInit(pScreen, NULL, nxagentOption(RootWidth), * nxagentOption(RootHeight), 1, 1, nxagentOption(RootWidth), - * visuals[nxagentDefaultVisualIndex].nplanes, / * Root depth. * / + * visuals[nxagentDefaultVisualIndex].nplanes, / * Root depth. * / * numDepths, depths, * visuals[nxagentDefaultVisualIndex].vid,* Root visual. * / * numVisuals, visuals)) @@ -1494,7 +1491,7 @@ N/A /* * Window Procedures. - * + * * Note that the following functions are not * replaced with nxagent counterparts: * @@ -1528,9 +1525,8 @@ N/A pScreen->DestroyPixmap = nxagentDestroyPixmap; /* - * This is originally miModifyPixmapHeader() - * from miscrinit.c. It is used to recycle - * the scratch pixmap for this screen. + * This is originally miModifyPixmapHeader() from miscrinit.c. It + * is used to recycle the scratch pixmap for this screen. */ pScreen->ModifyPixmapHeader = nxagentModifyPixmapHeader; @@ -1599,18 +1595,16 @@ N/A #ifdef RENDER /* - * Initialize picture support. This have to be - * placed here because miDCInitialize calls - * DamageSetup, that should wrap the picture - * screen functions. So PictureInit has to be - * called before. + * Initialize picture support. This have to be placed here because + * miDCInitialize calls DamageSetup, that should wrap the picture + * screen functions. So PictureInit has to be called before. */ if (nxagentRenderEnable && !nxagentReconnectTrap) { if (!nxagentPictureInit(pScreen, 0, 0)) { - nxagentRenderEnable = False; + nxagentRenderEnable = False; return FALSE; } @@ -1650,8 +1644,7 @@ N/A nxagentOption(Height)) / 32) /* - * Complete the initialization of the RANDR - * extension. + * Complete the initialization of the RANDR extension. */ nxagentInitRandRExtension(pScreen); @@ -1686,7 +1679,6 @@ N/A * it will otherwise grab the screen even if it * is under agent's control. */ - XSetScreenSaver(nxagentDisplay, 0, 0, DefaultExposures, DefaultBlanking); } } @@ -1705,10 +1697,9 @@ N/A else { /* - * Create any top-level window as a child of the - * real root of the remote display. See also the - * InitRootWindow() procedure and the function - * handling the splash screen. + * Create any top-level window as a child of the real root of + * the remote display. See also the InitRootWindow() procedure + * and the function handling the splash screen. */ #ifdef TEST @@ -1943,10 +1934,9 @@ N/A } /* - * The purpose of this check is to verify if there - * is a window manager running. Unfortunately due - * to the way we manage the intern atoms call, the - * atom will always exist. + * The purpose of this check is to verify if there is a window + * manager running. Unfortunately due to the way we manage the + * intern atoms call, the atom will always exist. */ if (nxagentWMIsRunning) @@ -1988,9 +1978,9 @@ N/A else { /* - * We should always enable the configuration of the - * remote X server's devices if we are running full- - * screen and there is no WM running. + * We should always enable the configuration of the remote X + * server's devices if we are running fullscreen and there is no + * WM running. */ if (nxagentOption(Fullscreen)) @@ -2004,9 +1994,8 @@ N/A } /* - * Inform the user whether the agent's clients will - * be able to change the real X server's keyboard - * and pointer settings. + * Inform the user whether the agent's clients will be able to + * change the real X server's keyboard and pointer settings. */ if (nxagentOption(DeviceControl) == False) @@ -2040,9 +2029,8 @@ N/A #endif /* RENDER */ /* - * Check if the composite extension is - * supported on the remote display and - * prepare the agent for its use. + * Check if the composite extension is supported on the remote + * display and prepare the agent for its use. */ nxagentCompositeExtensionInit(); @@ -2265,7 +2253,7 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, #ifdef TEST nxagentPrintAgentGeometry("Before Resize Screen", "nxagentResizeScreen:"); #endif - + /* * Change screen properties. */ @@ -2487,7 +2475,7 @@ void nxagentShadowSetWindowsSize(void) XResizeWindow(nxagentDisplay, nxagentDefaultWindows[0], nxagentOption(Width), nxagentOption(Height)); - XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0, + XMoveResizeWindow(nxagentDisplay, nxagentInputWindows[0], 0, 0, nxagentOption(Width), nxagentOption(Height)); } @@ -3439,7 +3427,7 @@ Bool nxagentReconnectScreen(void *p0) return False; } - nxagentPixmap(pPixmap) = XCreatePixmap(nxagentDisplay, + nxagentPixmap(pPixmap) = XCreatePixmap(nxagentDisplay, nxagentDefaultWindows[nxagentDefaultScreen->myNum], pPixmap -> drawable.width, pPixmap -> drawable.height, @@ -3453,10 +3441,10 @@ Bool nxagentReconnectScreen(void *p0) CARD16 h = 16; (*nxagentDefaultScreen->QueryBestSize)(StippleShape, &w, &h, nxagentDefaultScreen); if (!(nxagentPixmap(nxagentDefaultScreen->PixmapPerDepth[0]) = - XCreatePixmap(nxagentDisplay, + XCreatePixmap(nxagentDisplay, nxagentDefaultDrawables[1], - w, - h, + w, + h, 1))); Mask mask = nxagentGetDefaultEventMask(); @@ -3478,7 +3466,7 @@ Bool nxagentReconnectScreen(void *p0) nxagentSetTimeoutTimer(0); - return True; + return True; } /* intersect two rectangles */ @@ -3945,7 +3933,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) sprintf(name, "NX%d", i+1); output = RROutputCreate(pScreen, name, strlen(name), NULL); /* will be done later - RROutputSetConnection(output, RR_Disconnected); + RROutputSetConnection(output, RR_Disconnected); */ #ifdef DEBUG fprintf(stderr, "nxagentAdjustRandRXinerama: created new output [%s]\n", name); @@ -4658,7 +4646,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, XImage *image = XGetImage(nxagentDisplay, nxagentPixmap(pPixmap), xSrc, ySrc, width, height, AllPlanes, format); */ - + if (image == NULL) { #ifdef WARNING @@ -4683,9 +4671,9 @@ FIXME #ifdef WARNING fprintf(stderr, "nxagentFbRestoreArea: WARNING! Visual not found. Using default visual.\n"); #endif - + pVisual = nxagentVisuals[nxagentDefaultVisualIndex].visual; - } + } image = XCreateImage(nxagentDisplay, pVisual, depth, format, 0, (char *) data, -- cgit v1.2.3 From 4c6940cddb10c03127cf7775299e799960581e40 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 26 May 2020 01:08:50 +0200 Subject: Window.c: some more TEST and DEBUG output --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 94a1bb9ee..2dea31af0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -821,6 +821,9 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) if (XCheckTypedWindowEvent(nxagentDisplay, w, ReparentNotify, &e)) { + #ifdef TEST + fprintf(stderr, "%s: found ReparentNotify event in iteration [%d].\n", __func__, i); + #endif break; } @@ -970,6 +973,9 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) if (nxagentOption(WMBorderWidth) > 0) { + #ifdef DEBUG + fprintf(stderr, "%s: WMBorderWidth [%d]\n", __func__, nxagentOption(WMBorderWidth)); + #endif nxagentChangeOption(X, nxagentOption(SavedX) - nxagentOption(WMBorderWidth)); } else @@ -979,6 +985,9 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) if (nxagentOption(WMTitleHeight) > 0) { + #ifdef DEBUG + fprintf(stderr, "%s: WMTitleHeight [%d]\n", __func__, nxagentOption(WMTitleHeight)); + #endif nxagentChangeOption(Y, nxagentOption(SavedY) - nxagentOption(WMTitleHeight)); } else -- cgit v1.2.3 From 2d99cdd1cf5d8d0e8248d94bc07dca8ff32e4058 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 27 Jul 2020 18:29:40 +0200 Subject: Events.c: More cosmetics --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 172715987..4d9d32bb2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -3402,9 +3402,9 @@ int nxagentHandleConfigureNotify(XEvent* X) /* FIXME: Comment makes no sense */ if (nxagentOption(Shadow) == 1 || (nxagentOption(Width) == nxagentOption(RootWidth) && - nxagentOption(Height) == nxagentOption(RootHeight) && - nxagentOption(X) == nxagentOption(RootX) && - nxagentOption(Y) == nxagentOption(RootY))) + nxagentOption(Height) == nxagentOption(RootHeight) && + nxagentOption(X) == nxagentOption(RootX) && + nxagentOption(Y) == nxagentOption(RootY))) { doRandR = False; } @@ -4382,11 +4382,13 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X) fprintf(stderr, "%s: Called.\n", __func__); #endif - nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)], Xr -> width, Xr -> height, - Xr -> mwidth, Xr -> mheight, True); + nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)], + Xr -> width, Xr -> height, + Xr -> mwidth, Xr -> mheight, True); - nxagentShadowCreateMainWindow(screenInfo.screens[DefaultScreen(nxagentDisplay)], screenInfo.screens[0]->root, - Xr -> width, Xr -> height); + nxagentShadowCreateMainWindow(screenInfo.screens[DefaultScreen(nxagentDisplay)], + screenInfo.screens[0]->root, + Xr -> width, Xr -> height); nxagentShadowSetWindowsSize(); -- cgit v1.2.3