Commit 9b87a384 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Screen.c: restructure xinerama code, much shorter now

parent 359f48dd
...@@ -1780,7 +1780,9 @@ N/A ...@@ -1780,7 +1780,9 @@ N/A
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);
} else { }
else
{
#ifdef TEST #ifdef TEST
fprintf(stderr, "nxagentOpenScreen: Setting WM_CLASS and WM_NAME for window withid [%ld].\n", fprintf(stderr, "nxagentOpenScreen: Setting WM_CLASS and WM_NAME for window withid [%ld].\n",
nxagentDefaultWindows[pScreen->myNum]); nxagentDefaultWindows[pScreen->myNum]);
...@@ -3888,7 +3890,6 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -3888,7 +3890,6 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
RROutputSetCrtcs(pScrPriv->outputs[i], &(pScrPriv->crtcs[i]), 1); RROutputSetCrtcs(pScrPriv->outputs[i], &(pScrPriv->crtcs[i]), 1);
if (disable_output) { if (disable_output) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: no (valid) intersection - disconnecting\n", i); fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: no (valid) intersection - disconnecting\n", i);
...@@ -3899,32 +3900,21 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -3899,32 +3900,21 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
* Tests revealed that some window managers (e.g. LXDE) also * Tests revealed that some window managers (e.g. LXDE) also
* take disconnected outputs into account when calculating * take disconnected outputs into account when calculating
* stuff like wallpaper tile size and maximum window * stuff like wallpaper tile size and maximum window
* size. This is problematic when the disconnected output is * size. This is problematic when a disconnected output is
* smaller than any of the connected ones. Solution: unset * smaller than any of the connected ones. Solution: unset the
* the mode of the output's crtc. This also leads to * mode of the output's crtc. This also leads to xinerama not
* xinerama not showing the disconnected head anymore. * showing the disconnected head anymore.
*/ */
if (prevmode) { if (prevmode) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from ctrc %d\n", i);
#endif
RRCrtcSet(pScrPriv->crtcs[i], NULL, 0, 0, RR_Rotate_0, 1, &(pScrPriv->outputs[i]));
#ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from output %d\n", i); fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from output %d\n", i);
#endif #endif
RROutputSetModes(pScrPriv->outputs[i], NULL, 0, 0); RROutputSetModes(pScrPriv->outputs[i], NULL, 0, 0);
/* throw away the previous mode, we do not need it
anymore. If refcnt is 1 we call FreeResource() to ensure
the system will not try to free it again on shutdown */
if (prevmode->refcnt == 1) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s] ([%p])\n", prevmode->name, prevmode); fprintf(stderr, "nxagentAdjustRandRXinerama: removing mode from ctrc %d\n", i);
#endif #endif
FreeResource(prevmode->mode.id, 0); RRCrtcSet(pScrPriv->crtcs[i], NULL, 0, 0, RR_Rotate_0, 1, &(pScrPriv->outputs[i]));
}
} }
} }
else else
...@@ -3935,14 +3925,17 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -3935,14 +3925,17 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
RROutputSetConnection(pScrPriv->outputs[i], RR_Connected); RROutputSetConnection(pScrPriv->outputs[i], RR_Connected);
memset(&modeInfo, '\0', sizeof(modeInfo)); memset(&modeInfo, '\0', sizeof(modeInfo));
#ifdef NX_USE_MODE_PREFIX
/* avoid collisions with pre-existing default modes by using a /* avoid collisions with pre-existing default modes by using a
separate namespace. If we'd simply use XxY we could not separate namespace. If we'd simply use XxY we could not
distinguish between pre-existing modes which should stay distinguish between pre-existing modes which should stay
and our own modes that should be removed after use. */ and our own modes that should be removed after use. */
sprintf(name, "nx_%dx%d", new_w, new_h);*/
/*sprintf(name, "nx%d", i+1);*/ /*sprintf(name, "nx%d", i+1);*/
#else
sprintf(name, "%dx%d", new_w, new_h); sprintf(name, "%dx%d", new_w, new_h);
/*sprintf(name, "nx_%dx%d", new_w, new_h);*/ #endif
modeInfo.width = new_w; modeInfo.width = new_w;
modeInfo.height = new_h; modeInfo.height = new_h;
modeInfo.hTotal = new_w; modeInfo.hTotal = new_w;
...@@ -3962,9 +3955,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -3962,9 +3955,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: mode [%s] creation failed!\n", i, name); fprintf(stderr, "nxagentAdjustRandRXinerama: output %d: mode [%s] creation failed!\n", i, name);
} }
#endif #endif
if (prevmode) { if (prevmode && mymode == prevmode) {
if (mymode == prevmode)
{
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: mymode [%s] ([%p]) == prevmode [%s] ([%p])\n", mymode->name, mymode, prevmode->name, prevmode); fprintf(stderr, "nxagentAdjustRandRXinerama: mymode [%s] ([%p]) == prevmode [%s] ([%p])\n", mymode->name, mymode, prevmode->name, prevmode);
#endif #endif
...@@ -3973,9 +3964,9 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -3973,9 +3964,9 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
refcnt by 1. We decrease it again by calling only refcnt by 1. We decrease it again by calling only
RRModeDestroy() and forget about prevmode */ RRModeDestroy() and forget about prevmode */
RRModeDestroy(mymode); RRModeDestroy(mymode);
}
} else { else
{
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for output %d\n", mymode->name, mymode, mymode->refcnt, i); fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for output %d\n", mymode->name, mymode, mymode->refcnt, i);
#endif #endif
...@@ -3986,37 +3977,22 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) ...@@ -3986,37 +3977,22 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
#endif #endif
RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i]));
/* throw away the mode if otherwise unused. We do not need
it anymore. We call FreeResource() to ensure the system
will not try to free it again on shutdown */
if (prevmode->refcnt == 1) {
#ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s]\n", prevmode->name);
#endif
FreeResource(prevmode->mode.id, 0);
}
} }
} } /* if disable_output */
else
{
/* we do not have a previous mode, so there's no need to handle it here */
#ifdef DEBUG /* throw away the mode if otherwise unused. We do not need it
fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for output %d\n", mymode->name, mymode, mymode->refcnt, i); anymore. We call FreeResource() to ensure the system will not
#endif try to free it again on shutdown */
RROutputSetModes(pScrPriv->outputs[i], &mymode, 1, 0);
if (prevmode && prevmode->refcnt == 1) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: setting mode [%s] ([%p]) refcnt [%d] for crtc %d\n", mymode->name, mymode, mymode->refcnt, i); fprintf(stderr, "nxagentAdjustRandRXinerama: destroying prevmode [%s]\n", prevmode->name);
#endif #endif
RRCrtcSet(pScrPriv->crtcs[i], mymode, new_x, new_y, RR_Rotate_0, 1, &(pScrPriv->outputs[i])); FreeResource(prevmode->mode.id, 0);
} }
} /* if disable_output */
RROutputChanged(pScrPriv->outputs[i], TRUE); RROutputChanged(pScrPriv->outputs[i], TRUE);
RRCrtcChanged(pScrPriv->crtcs[i], TRUE); RRCrtcChanged(pScrPriv->crtcs[i], TRUE);
} }
/* release allocated memory */ /* release allocated memory */
......
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