Unverified Commit c0f67abb authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/cleanup_window_hints' into 3.6.x

parents 985bed95 9138a9e3
...@@ -575,8 +575,6 @@ void nxagentInternalWindowsTree(WindowPtr pWin, int indent) ...@@ -575,8 +575,6 @@ void nxagentInternalWindowsTree(WindowPtr pWin, int indent)
void nxagentSwitchResizeMode(ScreenPtr pScreen) void nxagentSwitchResizeMode(ScreenPtr pScreen)
{ {
XSizeHints sizeHints;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentSwitchResizeMode called.\n"); fprintf(stderr, "nxagentSwitchResizeMode called.\n");
#endif #endif
...@@ -585,8 +583,6 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) ...@@ -585,8 +583,6 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen)
nxagentChangeOption(DesktopResize, !desktopResize); nxagentChangeOption(DesktopResize, !desktopResize);
sizeHints.flags = PMaxSize;
if (nxagentOption(DesktopResize) == 0) if (nxagentOption(DesktopResize) == 0)
{ {
fprintf(stderr,"Info: Disabled desktop resize mode in agent.\n"); fprintf(stderr,"Info: Disabled desktop resize mode in agent.\n");
...@@ -595,11 +591,9 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) ...@@ -595,11 +591,9 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen)
if (nxagentOption(Fullscreen) == 0) if (nxagentOption(Fullscreen) == 0)
{ {
sizeHints.max_width = nxagentOption(RootWidth); nxagentSetWMNormalHintsMaxsize(pScreen,
sizeHints.max_height = nxagentOption(RootHeight); nxagentOption(RootWidth),
nxagentOption(RootHeight));
XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum],
&sizeHints);
} }
} }
else else
...@@ -608,32 +602,25 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) ...@@ -608,32 +602,25 @@ 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));
0, 0);
if (nxagentOption(ClientOs) == ClientOsWinnt) if (nxagentOption(ClientOs) == ClientOsWinnt)
{ {
NXSetExposeParameters(nxagentDisplay, 0, 0, 0); NXSetExposeParameters(nxagentDisplay, 0, 0, 0);
} }
sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); nxagentSetWMNormalHintsMaxsize(pScreen,
sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)),
HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)));
XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum],
&sizeHints);
} }
} }
void nxagentShadowSwitchResizeMode(ScreenPtr pScreen) void nxagentShadowSwitchResizeMode(ScreenPtr pScreen)
{ {
XSizeHints sizeHints;
int desktopResize = nxagentOption(DesktopResize); int desktopResize = nxagentOption(DesktopResize);
nxagentChangeOption(DesktopResize, !desktopResize); nxagentChangeOption(DesktopResize, !desktopResize);
sizeHints.flags = PMaxSize;
if (nxagentOption(DesktopResize) == 0) if (nxagentOption(DesktopResize) == 0)
{ {
nxagentShadowSetRatio(1.0, 1.0); nxagentShadowSetRatio(1.0, 1.0);
...@@ -641,8 +628,9 @@ void nxagentShadowSwitchResizeMode(ScreenPtr pScreen) ...@@ -641,8 +628,9 @@ void nxagentShadowSwitchResizeMode(ScreenPtr pScreen)
nxagentShadowCreateMainWindow(screenInfo.screens[DefaultScreen(nxagentDisplay)], screenInfo.screens[0]->root, nxagentShadowCreateMainWindow(screenInfo.screens[DefaultScreen(nxagentDisplay)], screenInfo.screens[0]->root,
screenInfo.screens[0]->root -> drawable.width, screenInfo.screens[0]->root -> drawable.height); screenInfo.screens[0]->root -> drawable.width, screenInfo.screens[0]->root -> drawable.height);
sizeHints.max_width = nxagentOption(RootWidth); nxagentSetWMNormalHintsMaxsize(pScreen,
sizeHints.max_height = nxagentOption(RootHeight); nxagentOption(RootWidth),
nxagentOption(RootHeight));
fprintf(stderr,"Info: Disabled resize mode in shadow agent.\n"); fprintf(stderr,"Info: Disabled resize mode in shadow agent.\n");
} }
...@@ -657,14 +645,12 @@ void nxagentShadowSwitchResizeMode(ScreenPtr pScreen) ...@@ -657,14 +645,12 @@ void nxagentShadowSwitchResizeMode(ScreenPtr pScreen)
screenInfo.screens[0]->root, screenInfo.screens[0]->root -> drawable.width, screenInfo.screens[0]->root, screenInfo.screens[0]->root -> drawable.width,
screenInfo.screens[0]->root -> drawable.height); screenInfo.screens[0]->root -> drawable.height);
sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); nxagentSetWMNormalHintsMaxsize(pScreen,
sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)),
HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)));
fprintf(stderr,"Info: Enabled resize mode in shadow agent.\n"); fprintf(stderr,"Info: Enabled resize mode in shadow agent.\n");
} }
XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum],
&sizeHints);
} }
static void nxagentSwitchDeferMode(void) static void nxagentSwitchDeferMode(void)
...@@ -3248,6 +3234,7 @@ int nxagentHandleConfigureNotify(XEvent* X) ...@@ -3248,6 +3234,7 @@ int nxagentHandleConfigureNotify(XEvent* X)
pClient = wClient(pWinWindow); pClient = wClient(pWinWindow);
/* FIXME: override_redirect is always FALSE here */
if (X -> xconfigure.send_event || !nxagentWMIsRunning || if (X -> xconfigure.send_event || !nxagentWMIsRunning ||
X -> xconfigure.override_redirect) X -> xconfigure.override_redirect)
{ {
...@@ -3354,13 +3341,26 @@ int nxagentHandleConfigureNotify(XEvent* X) ...@@ -3354,13 +3341,26 @@ int nxagentHandleConfigureNotify(XEvent* X)
{ {
if (nxagentOption(AllScreens) == 0) 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(DesktopResize) == 1)
{ {
if (nxagentOption(Width) != X -> xconfigure.width || if (nxagentOption(Width) != X -> xconfigure.width ||
nxagentOption(Height) != X -> xconfigure.height || nxagentOption(Height) != X -> xconfigure.height ||
nxagentOption(X) != X -> xconfigure.x || (updatePos && (nxagentOption(X) != newX ||
nxagentOption(Y) != X -> xconfigure.y) nxagentOption(Y) != newY)))
{ {
#ifdef DEBUG
int count = 0;
#endif
Bool newEvents = False; Bool newEvents = False;
doRandR = True; doRandR = True;
...@@ -3377,8 +3377,7 @@ int nxagentHandleConfigureNotify(XEvent* X) ...@@ -3377,8 +3377,7 @@ int nxagentHandleConfigureNotify(XEvent* X)
nxagentWaitEvents(nxagentDisplay, &timeout); nxagentWaitEvents(nxagentDisplay, &timeout);
/* /*
* This should also flush * This should also flush the NX link for us.
* the NX link for us.
*/ */
XSync(nxagentDisplay, 0); XSync(nxagentDisplay, 0);
...@@ -3386,17 +3385,34 @@ int nxagentHandleConfigureNotify(XEvent* X) ...@@ -3386,17 +3385,34 @@ int nxagentHandleConfigureNotify(XEvent* X)
while (XCheckTypedWindowEvent(nxagentDisplay, nxagentDefaultWindows[pScreen -> myNum], while (XCheckTypedWindowEvent(nxagentDisplay, nxagentDefaultWindows[pScreen -> myNum],
ConfigureNotify, X)) 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; newEvents = True;
} }
} while (newEvents); } 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); #ifdef DEBUG
nxagentChangeOption(Y, X -> xconfigure.y); 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 && if (nxagentOption(Shadow) == 1 && nxagentOption(DesktopResize) == 1 &&
...@@ -3464,7 +3480,7 @@ int nxagentHandleConfigureNotify(XEvent* X) ...@@ -3464,7 +3480,7 @@ int nxagentHandleConfigureNotify(XEvent* X)
#endif #endif
nxagentChangeScreenConfig(0, nxagentOption(Width), nxagentChangeScreenConfig(0, nxagentOption(Width),
nxagentOption(Height), 0, 0); nxagentOption(Height));
} }
} }
...@@ -3484,7 +3500,7 @@ int nxagentHandleConfigureNotify(XEvent* X) ...@@ -3484,7 +3500,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), 0, 0); nxagentOption(Height));
return 1; return 1;
} }
......
...@@ -231,7 +231,7 @@ Bool nxagentPendingEvents(Display *dpy); ...@@ -231,7 +231,7 @@ Bool nxagentPendingEvents(Display *dpy);
XEventsQueued((display), QueuedAfterReading) XEventsQueued((display), QueuedAfterReading)
#define nxagentCheckEvents(display, event, predicate, argument) \ #define nxagentCheckEvents(display, event, predicate, argument) \
XCheckIfEventNoFlush((display), (event), (predicate), (argument)) XCheckIfEventNoFlush((display), (event), (predicate), (argument))
int nxagentWaitEvents(Display *, struct timeval *); int nxagentWaitEvents(Display *, struct timeval *);
......
...@@ -470,7 +470,7 @@ int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, ...@@ -470,7 +470,7 @@ int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height,
nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0) nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0)
{ {
nxagentRandRSetWindowsSize(width, height); nxagentRandRSetWindowsSize(width, height);
nxagentSetWMNormalHints(pScreen -> myNum); nxagentSetWMNormalHints(pScreen -> myNum, nxagentOption(Width), nxagentOption(Height));
} }
nxagentMoveViewport(pScreen, 0, 0); nxagentMoveViewport(pScreen, 0, 0);
......
...@@ -626,7 +626,7 @@ Bool nxagentReconnectSession(void) ...@@ -626,7 +626,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), 0, 0); nxagentOption(RootHeight));
nxagentResizeDesktopAtStartup = False; nxagentResizeDesktopAtStartup = False;
} }
......
...@@ -376,8 +376,8 @@ Window nxagentCreateIconWindow(void) ...@@ -376,8 +376,8 @@ Window nxagentCreateIconWindow(void)
unsigned long valuemask; unsigned long valuemask;
char* window_name; char* window_name;
XTextProperty windowName; XTextProperty windowName;
XSizeHints sizeHints; XSizeHints* sizeHints;
XWMHints wmHints; XWMHints* wmHints;
Window w; Window w;
Mask mask; Mask mask;
...@@ -416,26 +416,40 @@ Window nxagentCreateIconWindow(void) ...@@ -416,26 +416,40 @@ Window nxagentCreateIconWindow(void)
window_name = nxagentWindowName; window_name = nxagentWindowName;
XStringListToTextProperty(&window_name, 1, &windowName); XStringListToTextProperty(&window_name, 1, &windowName);
sizeHints.flags = PMinSize | PMaxSize;
sizeHints.min_width = sizeHints.max_width = 1; if ((sizeHints = XAllocSizeHints()))
sizeHints.min_height = sizeHints.max_height = 1;
wmHints.flags = IconPixmapHint | IconMaskHint;
wmHints.initial_state = IconicState;
wmHints.icon_pixmap = nxagentIconPixmap;
if (useXpmIcon)
{ {
wmHints.icon_mask = nxagentIconShape; sizeHints->flags = PMinSize | PMaxSize;
wmHints.flags = IconPixmapHint | IconMaskHint; 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, XSetWMProperties(nxagentDisplay, w,
&windowName, &windowName, &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. * Enable events from the icon window.
...@@ -839,8 +853,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -839,8 +853,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
unsigned long valuemask; unsigned long valuemask;
XSetWindowAttributes attributes; XSetWindowAttributes attributes;
XWindowAttributes gattributes; XWindowAttributes gattributes;
XSizeHints sizeHints; XSizeHints* sizeHints;
XWMHints wmHints; XWMHints* wmHints;
Mask mask; Mask mask;
Bool resetAgentPosition = False; Bool resetAgentPosition = False;
...@@ -1798,20 +1812,6 @@ N/A ...@@ -1798,20 +1812,6 @@ N/A
* we need it to properly display all window parameters by some WMs * we need it to properly display all window parameters by some WMs
* (for example on Maemo) * (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 #ifdef TEST
fprintf(stderr, "nxagentOpenScreen: Setting WM_CLASS and WM_NAME for window with id [%ld].\n", fprintf(stderr, "nxagentOpenScreen: Setting WM_CLASS and WM_NAME for window with id [%ld].\n",
...@@ -1819,8 +1819,17 @@ N/A ...@@ -1819,8 +1819,17 @@ N/A
#endif #endif
XClassHint hint; 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); XSetClassHint(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &hint);
free(hint.res_name); free(hint.res_name);
free(hint.res_class); free(hint.res_class);
...@@ -1855,8 +1864,8 @@ N/A ...@@ -1855,8 +1864,8 @@ N/A
nxagentDefaultWindows[pScreen->myNum], nxagentDefaultWindows[pScreen->myNum],
nxagentAtoms[8], /* NX_AGENT_SIGNATURE */ nxagentAtoms[8], /* NX_AGENT_SIGNATURE */
XA_STRING, XA_STRING,
8, 8,
PropModeReplace, PropModeReplace,
(unsigned char*) "X-AGENT", (unsigned char*) "X-AGENT",
strlen("X-AGENT")); strlen("X-AGENT"));
} }
...@@ -1866,51 +1875,61 @@ N/A ...@@ -1866,51 +1875,61 @@ N/A
XSelectInput(nxagentDisplay, nxagentFullscreenWindow, mask); XSelectInput(nxagentDisplay, nxagentFullscreenWindow, mask);
} }
sizeHints.flags = PPosition | PMinSize | PMaxSize; if ((sizeHints = XAllocSizeHints()))
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->flags = PPosition | PMinSize | PMaxSize;
sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); sizeHints->x = nxagentOption(X) + POSITION_OFFSET;
} sizeHints->y = nxagentOption(Y) + POSITION_OFFSET;
else sizeHints->min_width = MIN_NXAGENT_WIDTH;
{ sizeHints->min_height = MIN_NXAGENT_HEIGHT;
sizeHints.max_width = nxagentOption(RootWidth);
sizeHints.max_height = nxagentOption(RootHeight); sizeHints->width = nxagentOption(RootWidth);
} sizeHints->height = nxagentOption(RootHeight);
if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue) if (nxagentOption(DesktopResize) == 1 || nxagentOption(Fullscreen) == 1)
sizeHints.flags |= USPosition; {
if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) sizeHints->max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
sizeHints.flags |= USSize; 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, XSetStandardProperties(nxagentDisplay,
nxagentDefaultWindows[pScreen->myNum], nxagentDefaultWindows[pScreen->myNum],
nxagentWindowName, nxagentWindowName,
nxagentWindowName, nxagentWindowName,
nxagentIconPixmap, nxagentIconPixmap,
argv, argc, &sizeHints); argv, argc, sizeHints);
wmHints.icon_pixmap = nxagentIconPixmap; if (sizeHints)
XFree(sizeHints);
if (useXpmIcon) if ((wmHints = XAllocWMHints()))
{
wmHints.icon_mask = nxagentIconShape;
wmHints.flags = IconPixmapHint | IconMaskHint;
}
else
{ {
wmHints.flags = IconPixmapHint; wmHints->icon_pixmap = nxagentIconPixmap;
}
if (useXpmIcon)
{
wmHints->icon_mask = nxagentIconShape;
wmHints->flags = IconPixmapHint | IconMaskHint;
}
else
{
wmHints->flags = IconPixmapHint;
}
XSetWMHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &wmHints); XSetWMHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], wmHints);
XFree(wmHints);
}
/* /*
* Clear the window but let it unmapped. We'll map it * Clear the window but let it unmapped. We'll map it
...@@ -1976,6 +1995,8 @@ N/A ...@@ -1976,6 +1995,8 @@ N/A
deleteWMatom); deleteWMatom);
#endif #endif
/* FIXME: This doing the same thing in both cases. The
comments do not seem accurate (anymore?) */
if (nxagentOption(Rootless) == False) if (nxagentOption(Rootless) == False)
{ {
/* /*
...@@ -2281,7 +2302,6 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height, ...@@ -2281,7 +2302,6 @@ Bool nxagentResizeScreen(ScreenPtr pScreen, int width, int height,
int mmWidth, int mmHeight) int mmWidth, int mmHeight)
{ {
BoxRec box; BoxRec box;
XSizeHints sizeHints;
PixmapPtr pPixmap; PixmapPtr pPixmap;
char *fbBits; char *fbBits;
...@@ -2407,37 +2427,7 @@ FIXME: We should try to restore the previously ...@@ -2407,37 +2427,7 @@ FIXME: We should try to restore the previously
if ((nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0)) if ((nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0))
{ {
sizeHints.flags = PPosition | PMinSize | PMaxSize; nxagentSetWMNormalHints(pScreen->myNum, width, height);
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);
XResizeWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], width, height); XResizeWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], width, height);
...@@ -2476,7 +2466,7 @@ FIXME: We should try to restore the previously ...@@ -2476,7 +2466,7 @@ FIXME: We should try to restore the previously
nxagentMoveViewport(pScreen, 0, 0); nxagentMoveViewport(pScreen, 0, 0);
/* /*
* Update void * bounds. * Update pointer bounds.
*/ */
ScreenRestructured(pScreen); ScreenRestructured(pScreen);
...@@ -2838,7 +2828,7 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin) ...@@ -2838,7 +2828,7 @@ int nxagentShadowInit(ScreenPtr pScreen, WindowPtr pWin)
{ {
nxagentShadowSetWindowsSize(); nxagentShadowSetWindowsSize();
nxagentSetWMNormalHints(0); nxagentSetWMNormalHints(0, nxagentOption(Width), nxagentOption(Height));
} }
XMapWindow(nxagentDisplay, nxagentDefaultWindows[0]); XMapWindow(nxagentDisplay, nxagentDefaultWindows[0]);
...@@ -3839,13 +3829,13 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen) ...@@ -3839,13 +3829,13 @@ void nxagentAdjustCustomMode(ScreenPtr pScreen)
RRScreenSizeNotify(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; ScreenPtr pScreen;
int r; int r;
#ifdef DEBUG #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 #endif
#ifdef TEST #ifdef TEST
...@@ -3890,10 +3880,10 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in ...@@ -3890,10 +3880,10 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in
pScreen = screenInfo.screens[screen] -> root -> drawable.pScreen; pScreen = screenInfo.screens[screen] -> root -> drawable.pScreen;
#ifdef TEST #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 #endif
r = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight); r = nxagentResizeScreen(pScreen, width, height, 0, 0);
if (r != 0) if (r != 0)
{ {
...@@ -4557,51 +4547,75 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, ...@@ -4557,51 +4547,75 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg,
return; return;
} }
void nxagentSetWMNormalHints(int screen) void nxagentSetWMNormalHints(int screen, int width, int height)
{ {
XSizeHints sizeHints; XSizeHints* sizeHints = XAllocSizeHints();
if (!sizeHints)
return;
/* /*
* Change agent window size and size hints. * Change agent window size and size hints.
*/ */
sizeHints.flags = PPosition | PMinSize | PMaxSize; sizeHints->flags = PPosition | PMinSize | PMaxSize;
sizeHints.x = nxagentOption(X); sizeHints->x = nxagentOption(X);
sizeHints.y = nxagentOption(Y); sizeHints->y = nxagentOption(Y);
sizeHints.min_width = MIN_NXAGENT_WIDTH; sizeHints->min_width = MIN_NXAGENT_WIDTH;
sizeHints.min_height = MIN_NXAGENT_HEIGHT; sizeHints->min_height = MIN_NXAGENT_HEIGHT;
sizeHints.width = nxagentOption(Width); sizeHints->width = width;
sizeHints.height = nxagentOption(Height); sizeHints->height = height;
if (nxagentOption(DesktopResize) == 1) if (nxagentOption(DesktopResize) == 1)
{ {
sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); sizeHints->max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); sizeHints->max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
} }
else else
{ {
sizeHints.max_width = nxagentOption(RootWidth); sizeHints->max_width = nxagentOption(RootWidth);
sizeHints.max_height = nxagentOption(RootHeight); sizeHints->max_height = nxagentOption(RootHeight);
} }
if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue) if (nxagentUserGeometry.flag & XValue || nxagentUserGeometry.flag & YValue)
{ {
sizeHints.flags |= USPosition; sizeHints->flags |= USPosition;
} }
if (nxagentUserGeometry.flag & WidthValue || nxagentUserGeometry.flag & HeightValue) 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) void nxagentShadowAdaptToRatio(void)
{ {
XSizeHints sizeHints;
ScreenPtr pScreen; ScreenPtr pScreen;
RegionRec region; RegionRec region;
BoxRec box; BoxRec box;
...@@ -4613,12 +4627,9 @@ void nxagentShadowAdaptToRatio(void) ...@@ -4613,12 +4627,9 @@ void nxagentShadowAdaptToRatio(void)
nxagentShadowCreateMainWindow(pScreen, screenInfo.screens[0]->root, nxagentShadowWidth, nxagentShadowHeight); nxagentShadowCreateMainWindow(pScreen, screenInfo.screens[0]->root, nxagentShadowWidth, nxagentShadowHeight);
sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); nxagentSetWMNormalHintsMaxsize(pScreen,
sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)),
HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)));
sizeHints.flags = PMaxSize;
XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &sizeHints);
box.x1 = 0; box.x1 = 0;
box.y1 = 0; box.y1 = 0;
......
...@@ -48,7 +48,7 @@ is" without express or implied warranty. ...@@ -48,7 +48,7 @@ is" without express or implied warranty.
#define nxagentSetPrintGeometry(screen) \ #define nxagentSetPrintGeometry(screen) \
nxagentPrintGeometryFlags = (1 << (screen)); nxagentPrintGeometryFlags = (1 << (screen));
extern int nxagentClients; extern int nxagentClients;
extern int nxagentAutoDisconnectTimeout; extern int nxagentAutoDisconnectTimeout;
...@@ -110,7 +110,7 @@ Bool nxagentMagicPixelZone(int x, int y); ...@@ -110,7 +110,7 @@ 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);
int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, int mmHeight); int nxagentChangeScreenConfig(int screen, int width, int height);
int nxagentAdjustRandRXinerama(ScreenPtr pScreen); int nxagentAdjustRandRXinerama(ScreenPtr pScreen);
...@@ -130,7 +130,9 @@ int nxagentShadowPoll(PixmapPtr, GCPtr, unsigned char, int, int, char *, int *, ...@@ -130,7 +130,9 @@ int nxagentShadowPoll(PixmapPtr, GCPtr, unsigned char, int, int, char *, int *,
void nxagentShadowSetWindowsSize(void); void nxagentShadowSetWindowsSize(void);
void nxagentSetWMNormalHints(int); void nxagentSetWMNormalHints(int, int, int);
void nxagentSetWMNormalHintsMaxsize(ScreenPtr, int, int);
void nxagentShadowSetRatio(float, float); void nxagentShadowSetRatio(float, float);
......
...@@ -869,8 +869,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) ...@@ -869,8 +869,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn)
} }
/* /*
* This should also flush * This should also flush the NX link for us.
* the NX link for us.
*/ */
XSync(nxagentDisplay, 0); XSync(nxagentDisplay, 0);
...@@ -953,7 +952,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) ...@@ -953,7 +952,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)), 0, 0); HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)));
} }
else else
{ {
...@@ -1007,7 +1006,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) ...@@ -1007,7 +1006,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), 0, 0); nxagentOption(RootHeight));
} }
} }
......
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