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

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

parents 4214a719 d16a5fbb
...@@ -1356,7 +1356,7 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. ...@@ -1356,7 +1356,7 @@ FIXME: Use of nxagentParentWindow is strongly deprecated.
{ {
if (!(nxagentUserGeometry.flag & WidthValue)) if (!(nxagentUserGeometry.flag & WidthValue))
{ {
if (nxagentOption(Fullscreen)) if (nxagentOption(Fullscreen) || nxagentOption(Rootless))
{ {
nxagentChangeOption(RootWidth, DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay))); nxagentChangeOption(RootWidth, DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay)));
} }
...@@ -1369,7 +1369,7 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. ...@@ -1369,7 +1369,7 @@ FIXME: Use of nxagentParentWindow is strongly deprecated.
if (!(nxagentUserGeometry.flag & HeightValue)) if (!(nxagentUserGeometry.flag & HeightValue))
{ {
if (nxagentOption(Fullscreen)) if (nxagentOption(Fullscreen) || nxagentOption(Rootless))
{ {
nxagentChangeOption(RootHeight, DisplayHeight(nxagentDisplay, DefaultScreen(nxagentDisplay))); nxagentChangeOption(RootHeight, DisplayHeight(nxagentDisplay, DefaultScreen(nxagentDisplay)));
} }
......
...@@ -269,40 +269,30 @@ int nxagentRandRGetInfo(ScreenPtr pScreen, Rotation *pRotations) ...@@ -269,40 +269,30 @@ int nxagentRandRGetInfo(ScreenPtr pScreen, Rotation *pRotations)
static int nxagentRandRInitSizes(ScreenPtr pScreen) static int nxagentRandRInitSizes(ScreenPtr pScreen)
{ {
RRScreenSizePtr pSize; const int refresh_rate = 60;
RRScreenSizePtr pSize = NULL;
int width; /*
int height; Index[0]: default size
Index[nsizes-1]: current size
int maxWidth; Index[nsizes-2]: max size
int maxHeight; */
/* /*
int w[] = {0, 160, 320, 640, 800, 1024, 1152, 1280, 1280, 1280, 1280, 1280, int w[] = {0, 160, 320, 640, 800, 1024, 1152, 1280, 1280, 1280, 1280, 1280,
1280, 1360, 1440, 1600, 1600, 1680, 1920, 1920, 0, 0}; 1280, 1360, 1440, 1600, 1600, 1680, 1920, 1920, 0, 0};
int h[] = {0, 120, 240, 480, 600, 768, 864, 600, 720, 800, 854, 960, int h[] = {0, 120, 240, 480, 600, 768, 864, 600, 720, 800, 854, 960,
1024, 768, 900, 900, 1200, 1050, 1080, 1200, 0, 0}; 1024, 768, 900, 900, 1200, 1050, 1080, 1200, 0, 0};
*/ */
int w[] = {0, 320, 640, 640, 800, 800, 1024, 1024, 1152, 1280, 1280, 1280, 1360, int w[] = {0, 320, 640, 640, 800, 800, 1024, 1024, 1152, 1280, 1280, 1280, 1360,
1440, 1600, 1600, 1680, 1920, 1920, 0, 0}; 1440, 1600, 1600, 1680, 1920, 1920, 0, 0};
int h[] = {0, 240, 360, 480, 480, 600, 600, 768, 864, 720, 800, 1024, 768, int h[] = {0, 240, 360, 480, 480, 600, 600, 768, 864, 720, 800, 1024, 768,
900, 900, 1200, 1050, 1080, 1200, 0, 0}; 900, 900, 1200, 1050, 1080, 1200, 0, 0};
int i; int maxWidth = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
int nSizes; int maxHeight = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
int mmWidth;
int mmHeight;
/*
* Register all the supported sizes. The third
* parameter is the refresh rate.
*/
maxWidth = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
maxHeight = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
nSizes = sizeof w / sizeof(int); int nSizes = sizeof w / sizeof(int);
/* /*
* Add current and max sizes. * Add current and max sizes.
...@@ -318,10 +308,10 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen) ...@@ -318,10 +308,10 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen)
* Compute default size. * Compute default size.
*/ */
w[0] = w[2]; w[0] = w[1];
h[0] = h[2]; h[0] = h[1];
for (i = 3; i < nSizes - 1; i++) for (int i = 2; i < nSizes - 1; i++)
{ {
if ((w[i] <= maxWidth * 3 / 4) && if ((w[i] <= maxWidth * 3 / 4) &&
(h[i] <= maxHeight * 3 / 4) && (h[i] <= maxHeight * 3 / 4) &&
...@@ -333,47 +323,46 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen) ...@@ -333,47 +323,46 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen)
} }
} }
for (i = 0; i < nSizes; i++) /*
* Register all the supported sizes at a fixed refresh rate.
*/
for (int i = 0; i < nSizes; i++)
{ {
width = w[i]; int mmWidth, mmHeight;
height = h[i];
if (monitorResolution < 0) if (monitorResolution < 0)
{ {
mmWidth = width * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) / mmWidth = w[i] * DisplayWidthMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) /
DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay)); DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay));
mmHeight = height * DisplayHeightMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) / mmHeight = h[i] * DisplayHeightMM(nxagentDisplay, DefaultScreen(nxagentDisplay)) /
DisplayHeight(nxagentDisplay, DefaultScreen(nxagentDisplay)); DisplayHeight(nxagentDisplay, DefaultScreen(nxagentDisplay));
} }
else else
{ {
mmWidth = (width * 254 + monitorResolution * 5) / (monitorResolution * 10); mmWidth = (w[i] * 254 + monitorResolution * 5) / (monitorResolution * 10);
mmHeight = (height * 254 + monitorResolution * 5) / (monitorResolution * 10); mmHeight = (h[i] * 254 + monitorResolution * 5) / (monitorResolution * 10);
}
if (mmWidth < 1)
{
mmWidth = 1;
}
if (mmHeight < 1)
{
mmHeight = 1;
} }
pSize = RRRegisterSize(pScreen, width, height, mmWidth, mmHeight); pSize = RRRegisterSize(pScreen, w[i], h[i], mmWidth < 1 ? 1 : mmWidth, mmHeight < 1 ? 1 : mmHeight);
if (pSize == NULL) if (pSize == NULL)
{ {
return 0; return 0;
} }
RRRegisterRate (pScreen, pSize, 60); RRRegisterRate (pScreen, pSize, refresh_rate);
} }
RRSetCurrentConfig(pScreen, RR_Rotate_0, 60, pSize); /*
* the last registered size should be the current size
*/
if (pSize)
{
RRSetCurrentConfig(pScreen, RR_Rotate_0, refresh_rate, pSize);
}
return 1; return 1;
} }
......
...@@ -885,8 +885,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -885,8 +885,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
#endif #endif
/* /*
* Forced geometry parameter * Forced geometry parameter to user geometry.
* to user geometry.
*/ */
if (nxagentResizeDesktopAtStartup) if (nxagentResizeDesktopAtStartup)
...@@ -903,32 +902,26 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -903,32 +902,26 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
if (nxagentUserGeometry.flag & WidthValue) if (nxagentUserGeometry.flag & WidthValue)
{ {
nxagentChangeOption(Width, nxagentUserGeometry.Width); int uw = nxagentUserGeometry.Width;
nxagentChangeOption(RootWidth, nxagentUserGeometry.Width);
if (nxagentOption(SavedWidth) > nxagentUserGeometry.Width) nxagentChangeOption(Width, uw);
{ nxagentChangeOption(RootWidth, uw);
nxagentChangeOption(SavedWidth, nxagentUserGeometry.Width); nxagentChangeOption(SavedWidth, min(nxagentOption(SavedWidth), uw));
}
} }
if (nxagentUserGeometry.flag & HeightValue) if (nxagentUserGeometry.flag & HeightValue)
{ {
nxagentChangeOption(Height, nxagentUserGeometry.Height); int uh = nxagentUserGeometry.Height;
nxagentChangeOption(RootHeight, nxagentUserGeometry.Height);
if (nxagentOption(SavedHeight) > nxagentUserGeometry.Height) nxagentChangeOption(Height, uh);
{ nxagentChangeOption(RootHeight, uh);
nxagentChangeOption(SavedHeight, nxagentUserGeometry.Height); nxagentChangeOption(SavedHeight, min(nxagentOption(SavedHeight), uh));
}
} }
} }
/* /*
* This is first time the * This is first time the screen is initialized.
* screen is initialized. * Filling the geometry parameter from user geometry.
* Filling the geometry parameter
* from user geometry.
*/ */
if (nxagentReconnectTrap == False) if (nxagentReconnectTrap == False)
...@@ -971,10 +964,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -971,10 +964,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
} }
/* /*
* Determine the size of the root window. * Determine the size of the root window. It is the maximum size of
* It is the maximum size of the screen * the screen if we are either in rootless or in fullscreen mode.
* if we are either in rootless or in
* fullscreen mode.
*/ */
if (nxagentOption(Rootless) == False && !nxagentWMIsRunning) if (nxagentOption(Rootless) == False && !nxagentWMIsRunning)
...@@ -1011,48 +1002,59 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -1011,48 +1002,59 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
resetAgentPosition = True; resetAgentPosition = True;
} }
nxagentChangeOption(BorderWidth, 0);
/* get the screen size of the real X server once */
int w = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
int h = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay));
if (nxagentOption(Fullscreen)) if (nxagentOption(Fullscreen))
{ {
nxagentChangeOption(X, 0); nxagentChangeOption(X, 0);
nxagentChangeOption(Y, 0); nxagentChangeOption(Y, 0);
nxagentChangeOption(Width, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); nxagentChangeOption(Width, w);
nxagentChangeOption(Height, HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); nxagentChangeOption(Height, h);
nxagentChangeOption(BorderWidth, 0);
/* first time screen initialization or resize during reconnect */
if (nxagentReconnectTrap == False || nxagentResizeDesktopAtStartup) if (nxagentReconnectTrap == False || nxagentResizeDesktopAtStartup)
{ {
nxagentChangeOption(RootWidth, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); if (nxagentOption(RootWidth) >= w)
nxagentChangeOption(RootHeight, HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)));
if (nxagentOption(RootWidth) > WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)))
{ {
nxagentChangeOption(SavedWidth, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)) * 3 / 4); nxagentChangeOption(SavedWidth, w * 3 / 4);
} }
else else
{ {
nxagentChangeOption(SavedWidth, nxagentOption(RootWidth)); nxagentChangeOption(SavedWidth, nxagentOption(RootWidth));
} }
if (nxagentOption(RootHeight) > HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))) if (nxagentOption(RootHeight) >= h)
{ {
nxagentChangeOption(SavedHeight, HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)) * 3 / 4); nxagentChangeOption(SavedHeight, h * 3 / 4);
} }
else else
{ {
nxagentChangeOption(SavedHeight, nxagentOption(RootHeight)); nxagentChangeOption(SavedHeight, nxagentOption(RootHeight));
} }
}
nxagentChangeOption(RootX, ((WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)) - nxagentChangeOption(RootWidth, w);
nxagentOption(RootWidth)) / 2)); nxagentChangeOption(RootHeight, h);
nxagentChangeOption(RootY, ((HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)) -
nxagentOption(RootHeight)) / 2)); nxagentChangeOption(RootX, 0);
nxagentChangeOption(RootY, 0);
}
else
{
/* center */
nxagentChangeOption(RootX, (w - nxagentOption(RootWidth)) / 2);
nxagentChangeOption(RootY, (h - nxagentOption(RootHeight)) / 2);
}
} }
else else
{ {
nxagentChangeOption(BorderWidth, 0); /*
* screen is initialized for the first time
*/
if (nxagentReconnectTrap == False) if (nxagentReconnectTrap == False)
{ {
...@@ -1064,53 +1066,58 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -1064,53 +1066,58 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
} }
/* /*
* Be sure that the agent window won't be bigger * Ensure that the agent window won't be bigger
* than the root window. * than the root window.
*/ */
if (nxagentOption(Width) > nxagentOption(RootWidth)) nxagentChangeOption(Width, min(nxagentOption(Width), nxagentOption(RootWidth)));
{ nxagentChangeOption(Height, min(nxagentOption(Height), nxagentOption(RootHeight)));
nxagentChangeOption(Width, nxagentOption(RootWidth));
}
if (nxagentOption(Height) > nxagentOption(RootHeight))
{
nxagentChangeOption(Height, nxagentOption(RootHeight));
}
/* /*
* Be sure that the agent window won't be bigger * Be sure that the agent window won't be bigger
* than the X server root window. * than the X server root window.
*/ */
if (nxagentOption(Width) > WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay))) if (nxagentOption(Width) > w)
{ {
nxagentChangeOption(Width, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)) * 3 / 4); if (nxagentOption(Rootless))
{
nxagentChangeOption(Width, w);
}
else
{
nxagentChangeOption(Width, w * 3 / 4);
}
} }
if (nxagentOption(Height) > HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))) if (nxagentOption(Height) > h)
{ {
nxagentChangeOption(Height, HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)) * 3 / 4); if (nxagentOption(Rootless))
{
nxagentChangeOption(Height, h);
}
else
{
nxagentChangeOption(Height, h * 3 / 4);
}
} }
/* /*
* Forcing the agent window geometry to be equal to * Forcing the agent window geometry to be equal to the root
* the root window geometry the first time the * window geometry the first time the screen is initialized if the
* screen is initialized if the geometry hasn't been * geometry hasn't been explicitly set in the option file and if
* esplicitly set in the option file and if * the root window isn't bigger than the X server root window..
* the root window isn't bigger than the X server
* root window..
*/ */
if (nxagentReconnectTrap == False) if (nxagentReconnectTrap == False)
{ {
if ((nxagentOption(RootWidth) < WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay))) && if ((nxagentOption(RootWidth) < w) &&
!(nxagentUserGeometry.flag & WidthValue)) !(nxagentUserGeometry.flag & WidthValue))
{ {
nxagentChangeOption(Width, nxagentOption(RootWidth)); nxagentChangeOption(Width, nxagentOption(RootWidth));
} }
if ((nxagentOption(RootHeight) < HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))) && if ((nxagentOption(RootHeight) < h) &&
!(nxagentUserGeometry.flag & HeightValue)) !(nxagentUserGeometry.flag & HeightValue))
{ {
nxagentChangeOption(Height, nxagentOption(RootHeight)); nxagentChangeOption(Height, nxagentOption(RootHeight));
...@@ -1119,11 +1126,9 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -1119,11 +1126,9 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
if (resetAgentPosition) if (resetAgentPosition)
{ {
nxagentChangeOption(X, ((WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)) - /* center */
nxagentOption(Width)) / 2)); nxagentChangeOption(X, (w - nxagentOption(Width)) / 2);
nxagentChangeOption(Y, (h - nxagentOption(Height)) / 2);
nxagentChangeOption(Y, ((HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)) -
nxagentOption(Height)) / 2));
} }
nxagentChangeOption(SavedWidth, nxagentOption(RootWidth)); nxagentChangeOption(SavedWidth, nxagentOption(RootWidth));
...@@ -1132,8 +1137,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, ...@@ -1132,8 +1137,8 @@ Bool nxagentOpenScreen(ScreenPtr pScreen,
if (nxagentOption(Rootless)) if (nxagentOption(Rootless))
{ {
nxagentChangeOption(RootWidth, WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); nxagentChangeOption(RootWidth, w);
nxagentChangeOption(RootHeight, HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay))); nxagentChangeOption(RootHeight, h);
} }
nxagentChangeOption(SavedRootWidth, nxagentOption(RootWidth)); nxagentChangeOption(SavedRootWidth, nxagentOption(RootWidth));
......
...@@ -1822,6 +1822,18 @@ Bool nxagentChangeWindowAttributes(WindowPtr pWin, unsigned long mask) ...@@ -1822,6 +1822,18 @@ Bool nxagentChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
return 1; return 1;
} }
void nxagentSetWMState(WindowPtr pWin, CARD32 desired)
{
Atom prop = MakeAtom("WM_STATE", strlen("WM_STATE"), True);
nxagentWMStateRec wmState = {.state = desired, .icon = None};
if (ChangeWindowProperty(pWin, prop, prop, 32, 0, 2, &wmState, 1) != Success)
{
#ifdef WARNING
fprintf(stderr, "%s: Changing WM_STATE failed.\n", __func__);
#endif
}
}
Bool nxagentRealizeWindow(WindowPtr pWin) Bool nxagentRealizeWindow(WindowPtr pWin)
{ {
if (nxagentScreenTrap == 1) if (nxagentScreenTrap == 1)
...@@ -1843,14 +1855,7 @@ Bool nxagentRealizeWindow(WindowPtr pWin) ...@@ -1843,14 +1855,7 @@ Bool nxagentRealizeWindow(WindowPtr pWin)
/* add by dimbor */ /* add by dimbor */
if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin)) if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin))
{ {
Atom prop = MakeAtom("WM_STATE", strlen("WM_STATE"), True); nxagentSetWMState(pWin, NormalState);
nxagentWMStateRec wmState;
wmState.state = 1; /* NormalState */
wmState.icon = None;
if (ChangeWindowProperty(pWin, prop, prop, 32, 0, 2, &wmState, 1) != Success)
{
fprintf(stderr, "nxagentRealizeWindow: Adding WM_STATE fail.\n");
}
} }
/* /*
...@@ -1878,7 +1883,7 @@ Bool nxagentRealizeWindow(WindowPtr pWin) ...@@ -1878,7 +1883,7 @@ Bool nxagentRealizeWindow(WindowPtr pWin)
#ifdef TEST #ifdef TEST
if (nxagentOption(Rootless) && nxagentLastWindowDestroyed) if (nxagentOption(Rootless) && nxagentLastWindowDestroyed)
{ {
fprintf(stderr, "nxagentRealizeWindow: Window realized. Stopped termination for rootless session.\n"); fprintf(stderr, "%s: Window realized. Stopped termination for rootless session.\n", __func__);
} }
#endif #endif
...@@ -1899,14 +1904,11 @@ Bool nxagentUnrealizeWindow(WindowPtr pWin) ...@@ -1899,14 +1904,11 @@ Bool nxagentUnrealizeWindow(WindowPtr pWin)
/* add by dimbor */ /* add by dimbor */
if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin)) if (nxagentOption(Rootless) && nxagentWindowTopLevel(pWin))
{ {
Atom prop = MakeAtom("WM_STATE", strlen("WM_STATE"), True); /*
nxagentWMStateRec wmState; * The original _comment_ was WithdrawnState, while the _value_
wmState.state = 3; /* WithdrawnState */ * was 3, which is IconicState.
wmState.icon = None; */
if (ChangeWindowProperty(pWin, prop, prop, 32, 0, 2, &wmState, 1) != Success) nxagentSetWMState(pWin, IconicState);
{
fprintf(stderr, "nxagentUnRealizeWindow: Changing WM_STATE failed.\n");
}
} }
XUnmapWindow(nxagentDisplay, nxagentWindow(pWin)); XUnmapWindow(nxagentDisplay, nxagentWindow(pWin));
......
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