aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-02-08 21:13:38 +0100
committerMihai Moldovan <ionic@ionic.de>2017-03-01 15:19:12 +0100
commitbaf7a926716192cdaea7a52b76bb61decf5cda0d (patch)
tree9a2ee3c078978334c93f9383c19d958679544217 /nx-X11/programs
parentda82328b2c3e19df546a875c62a5d7e8731a764e (diff)
downloadnx-libs-baf7a926716192cdaea7a52b76bb61decf5cda0d.tar.gz
nx-libs-baf7a926716192cdaea7a52b76bb61decf5cda0d.tar.bz2
nx-libs-baf7a926716192cdaea7a52b76bb61decf5cda0d.zip
Screen.c: Ensure that an output is unused before destroying it
Fixes ArcticaProject/nx-libs#293
Diffstat (limited to 'nx-X11/programs')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Screen.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c
index 0e0cd0b21..2f6381696 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c
@@ -3741,6 +3741,27 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in
return r;
}
+/*
+ Destroy an output after removing it from any crtc that might reference it
+ */
+void nxagentDropOutput(RROutputPtr o) {
+ RRCrtcPtr c = o->crtc;
+ if (c) {
+ for (int i = 0; i < c->numOutputs; i++) {
+ if (c->outputs[i] == o) {
+#ifdef DEBUG
+ fprintf(stderr, "nxagentDropOutput: output [%s] is in use by crtc [%p], removing it from there\n", o->name, c);
+#endif
+ RRCrtcSet(c, NULL, 0, 0, RR_Rotate_0, 0, NULL);
+ }
+ }
+ }
+#ifdef DEBUG
+ fprintf(stderr, "nxagentDropOutput: destroying output [%s]\n", o->name);
+#endif
+ RROutputDestroy(o);
+}
+
int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
{
rrScrPrivPtr pScrPriv;
@@ -3858,6 +3879,8 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
#ifdef DEBUG
fprintf(stderr, "nxagentAdjustRandRXinerama: destroying crtc\n");
#endif
+ /* first reset the crtc to free possible outputs, then destroy the crtc */
+ RRCrtcSet(pScrPriv->crtcs[pScrPriv->numCrtcs - 1], NULL, 0, 0, RR_Rotate_0, 0, NULL);
RRCrtcDestroy(pScrPriv->crtcs[pScrPriv->numCrtcs - 1]);
}
else
@@ -3886,22 +3909,13 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
}
/* delete superfluous non-NX outputs */
- for (i = pScrPriv->numOutputs - 1; i >= 0; i--) {
- if (strncmp(pScrPriv->outputs[i]->name, "NX", 2)) {
- #ifdef DEBUG
- fprintf(stderr, "nxagentAdjustRandRXinerama: destroying output [%s]\n", pScrPriv->outputs[i]->name);
- #endif
- RROutputDestroy(pScrPriv->outputs[i]);
- }
- }
+ for (i = pScrPriv->numOutputs - 1; i >= 0; i--)
+ if (strncmp(pScrPriv->outputs[i]->name, "NX", 2))
+ nxagentDropOutput(pScrPriv->outputs[i]);
/* at this stage only NX outputs are left - we delete the superfluous ones */
- for (i = pScrPriv->numOutputs - 1; i >= number; i--) {
- #ifdef DEBUG
- fprintf(stderr, "nxagentAdjustRandRXinerama: destroying nx output [%s]\n", pScrPriv->outputs[i]->name);
- #endif
- RROutputDestroy(pScrPriv->outputs[i]);
- }
+ for (i = pScrPriv->numOutputs - 1; i >= number; i--)
+ nxagentDropOutput(pScrPriv->outputs[i]);
/* add and init outputs */
for (i = 0; i < number; i++) {