Commit 8deda7bd authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

nxagent: Prevent resize loop

This only happened with certain window managers like mutter. Fixes ArcticaProject/nx-libs#925
parent abe5e847
...@@ -588,7 +588,7 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) ...@@ -588,7 +588,7 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen)
nxagentLaunchDialog(DIALOG_ENABLE_DESKTOP_RESIZE_MODE); nxagentLaunchDialog(DIALOG_ENABLE_DESKTOP_RESIZE_MODE);
nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentOption(Height)); nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentOption(Height), True);
if (nxagentOption(ClientOs) == ClientOsWinnt) if (nxagentOption(ClientOs) == ClientOsWinnt)
{ {
...@@ -2082,7 +2082,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already ...@@ -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]) X.xmap.window == nxagentDefaultWindows[nxagentScreen(X.xmap.window)->myNum])
{ {
nxagentChangeScreenConfig(nxagentScreen(X.xmap.window)->myNum, nxagentOption(Width), nxagentChangeScreenConfig(nxagentScreen(X.xmap.window)->myNum, nxagentOption(Width),
nxagentOption(Height)); nxagentOption(Height), True);
} }
break; break;
...@@ -3412,9 +3412,16 @@ int nxagentHandleConfigureNotify(XEvent* X) ...@@ -3412,9 +3412,16 @@ int nxagentHandleConfigureNotify(XEvent* X)
fprintf(stderr,"%s: Width %d Height %d.\n", __func__, fprintf(stderr,"%s: Width %d Height %d.\n", __func__,
nxagentOption(Width), nxagentOption(Height)); nxagentOption(Width), nxagentOption(Height));
#endif #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), nxagentChangeScreenConfig(0, nxagentOption(Width),
nxagentOption(Height)); nxagentOption(Height), False);
} }
} }
...@@ -3435,7 +3442,7 @@ int nxagentHandleConfigureNotify(XEvent* X) ...@@ -3435,7 +3442,7 @@ int nxagentHandleConfigureNotify(XEvent* X)
nxagentChangeOption(RootHeight, X -> xconfigure.height); nxagentChangeOption(RootHeight, X -> xconfigure.height);
nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentChangeScreenConfig(0, nxagentOption(Width),
nxagentOption(Height)); nxagentOption(Height), True);
return 1; return 1;
} }
...@@ -4310,7 +4317,7 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X) ...@@ -4310,7 +4317,7 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X)
#endif #endif
nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)], Xr -> width, Xr -> height, 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, nxagentShadowCreateMainWindow(screenInfo.screens[DefaultScreen(nxagentDisplay)], screenInfo.screens[0]->root,
Xr -> width, Xr -> height); Xr -> width, Xr -> height);
......
...@@ -378,7 +378,7 @@ int nxagentRandRSetConfig(ScreenPtr pScreen, Rotation rotation, ...@@ -378,7 +378,7 @@ int nxagentRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
*/ */
int r = nxagentResizeScreen(pScreen, pSize -> width, pSize -> height, int r = nxagentResizeScreen(pScreen, pSize -> width, pSize -> height,
pSize -> mmWidth, pSize -> mmHeight); pSize -> mmWidth, pSize -> mmHeight, True);
nxagentMoveViewport(pScreen, 0, 0); nxagentMoveViewport(pScreen, 0, 0);
...@@ -448,7 +448,7 @@ int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, ...@@ -448,7 +448,7 @@ int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height,
nxagentChangeOption(Height, 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 && if (result == 1 && nxagentOption(DesktopResize) == 1 &&
nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0) nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0)
......
...@@ -633,7 +633,7 @@ Bool nxagentReconnectSession(void) ...@@ -633,7 +633,7 @@ Bool nxagentReconnectSession(void)
if (nxagentResizeDesktopAtStartup || nxagentOption(Rootless) == True || nxagentOption(Xinerama) == True) if (nxagentResizeDesktopAtStartup || nxagentOption(Rootless) == True || nxagentOption(Xinerama) == True)
{ {
nxagentChangeScreenConfig(0, nxagentOption(RootWidth), nxagentChangeScreenConfig(0, nxagentOption(RootWidth),
nxagentOption(RootHeight)); nxagentOption(RootHeight), True);
nxagentResizeDesktopAtStartup = False; nxagentResizeDesktopAtStartup = False;
} }
......
...@@ -2243,7 +2243,7 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) ...@@ -2243,7 +2243,7 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable)
} }
Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
int mmWidth, int mmHeight) int mmWidth, int mmHeight, Bool doresize)
{ {
#ifdef TEST #ifdef TEST
nxagentPrintAgentGeometry("Before Resize Screen", "nxagentResizeScreen:"); nxagentPrintAgentGeometry("Before Resize Screen", "nxagentResizeScreen:");
...@@ -2365,10 +2365,19 @@ FIXME: We should try to restore the previously ...@@ -2365,10 +2365,19 @@ FIXME: We should try to restore the previously
{ {
nxagentSetWMNormalHints(pScreen->myNum, width, height); 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) 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); XResizeWindow(nxagentDisplay, nxagentInputWindows[pScreen -> myNum], width, height);
} }
} }
...@@ -2691,7 +2700,7 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) ...@@ -2691,7 +2700,7 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin)
AddResource(accessWindowID, RT_WINDOW, (void *)nxagentShadowWindowPtr); 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); nxagentShadowCreateMainWindow(pScreen, pWin, nxagentShadowWidth, nxagentShadowHeight);
...@@ -3646,10 +3655,10 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen) ...@@ -3646,10 +3655,10 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen)
RRScreenSizeNotify(pScreen); RRScreenSizeNotify(pScreen);
} }
int nxagentChangeScreenConfig(int screen, int width, int height) int nxagentChangeScreenConfig(int screen, int width, int height, Bool doresize)
{ {
#ifdef DEBUG #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 #endif
#ifdef TEST #ifdef TEST
...@@ -3697,7 +3706,7 @@ int nxagentChangeScreenConfig(int screen, int width, int height) ...@@ -3697,7 +3706,7 @@ int nxagentChangeScreenConfig(int screen, int width, int height)
fprintf(stderr, "nxagentChangeScreenConfig: Changing config to %d x %d\n", width, height); fprintf(stderr, "nxagentChangeScreenConfig: Changing config to %d x %d\n", width, height);
#endif #endif
int r = nxagentResizeScreen(pScreen, width, height, 0, 0); int r = nxagentResizeScreen(pScreen, width, height, 0, 0, doresize);
if (r != 0) if (r != 0)
{ {
......
...@@ -110,9 +110,9 @@ Window nxagentCreateIconWindow(void); ...@@ -110,9 +110,9 @@ Window nxagentCreateIconWindow(void);
Bool nxagentMagicPixelZone(int x, int y); Bool nxagentMagicPixelZone(int x, int y);
Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, 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); int nxagentAdjustRandRXinerama(ScreenPtr pScreen);
......
...@@ -891,7 +891,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) ...@@ -891,7 +891,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
if (nxagentOption(Shadow) == 0) if (nxagentOption(Shadow) == 0)
{ {
nxagentChangeScreenConfig(0, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), nxagentChangeScreenConfig(0, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)),
HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)), True);
} }
else else
{ {
...@@ -945,7 +945,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) ...@@ -945,7 +945,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
if (nxagentOption(Shadow) == 0) if (nxagentOption(Shadow) == 0)
{ {
nxagentChangeScreenConfig(0, nxagentOption(RootWidth), nxagentChangeScreenConfig(0, nxagentOption(RootWidth),
nxagentOption(RootHeight)); nxagentOption(RootHeight), True);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment