summaryrefslogtreecommitdiff
path: root/tools/virtual.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-02-12 16:19:25 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2014-02-12 16:21:30 +0000
commit564a766a6bbe8bcf2480248a54059e7d6727440d (patch)
tree1dedcb8962d6da9432ab628399c38e475a23b7be /tools/virtual.c
parent87b9d9f507885ed98d7249940218631b775d30ea (diff)
intel-virtual-output: Do not resize the screen whilst all outputs are off
If all the outputs are off, we try to resize the screen to 1x1, which is typically illegal. So, just keep the existing screen and xfer buffer for next time it is enabled. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tools/virtual.c')
-rw-r--r--tools/virtual.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/tools/virtual.c b/tools/virtual.c
index b891fd00..cba247bf 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -1073,17 +1073,34 @@ static int context_update(struct context *ctx)
y2 = v;
}
- x2 -= x1;
- y2 -= y1;
DBG(("%s fb bounds (%d, %d)x(%d, %d)\n", DisplayString(display->dpy),
x1, y1, x2, y2));
+ XGrabServer(display->dpy);
res = _XRRGetScreenResourcesCurrent(display->dpy, display->root);
if (res == NULL)
- continue;
+ goto ungrab;
- XGrabServer(display->dpy);
+ if (x2 <= x1 || y2 <= y1) {
+ /* Nothing enabled, preserve the current fb, and turn everything off */
+ for (clone = display->clone; clone; clone = clone->next) {
+ struct output *dst = &clone->dst;
+ if (!dst->rr_crtc)
+ continue;
+
+ DBG(("%s: disabling output '%s'\n",
+ DisplayString(dst->dpy), dst->name));
+ XRRSetCrtcConfig(dst->dpy, res, dst->rr_crtc, CurrentTime,
+ 0, 0, None, RR_Rotate_0, NULL, 0);
+ dst->rr_crtc = 0;
+ dst->mode.id = 0;
+ }
+ goto free_res;
+ }
+
+ x2 -= x1;
+ y2 -= y1;
DBG(("%s: current size %dx%d, need %dx%d\n",
DisplayString(display->dpy),
display->width, display->height,
@@ -1100,7 +1117,7 @@ static int context_update(struct context *ctx)
DBG(("%s: disabling output '%s'\n",
DisplayString(dst->dpy), dst->name));
XRRSetCrtcConfig(dst->dpy, res, dst->rr_crtc, CurrentTime,
- 0, 0, None, RR_Rotate_0, NULL, 0);
+ 0, 0, None, RR_Rotate_0, NULL, 0);
dst->rr_crtc = 0;
dst->mode.id = 0;
}
@@ -1230,9 +1247,10 @@ err:
dst->rr_crtc = rr_crtc;
(void)ret;
}
- XUngrabServer(display->dpy);
-
+free_res:
XRRFreeScreenResources(res);
+ungrab:
+ XUngrabServer(display->dpy);
}
ctx->active = NULL;