From 5afab7a51438cc73b2631f5f09d494ab314d24a6 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 2 Jan 2016 21:29:58 +0000 Subject: [PATCH] tools/intel-virtual-output: Respond to expose events on target displays If the destination screen is exposed (for example screensavers), we need to redraw. So enable the ExposeEvent on the target and synthesize damage to any clones on that display in order to trigger a redraw. Reported-by: Raffael Herzog References: https://bugs.freedesktop.org/show_bug.cgi?id=93562 Signed-off-by: Chris Wilson --- tools/virtual.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tools/virtual.c b/tools/virtual.c index ffda54a..57223dd 100644 --- a/tools/virtual.c +++ b/tools/virtual.c @@ -2382,6 +2382,8 @@ static int add_display(struct context *ctx, Display *dpy) display->depth = DefaultDepth(dpy, DefaultScreen(dpy)); display->visual = DefaultVisual(dpy, DefaultScreen(dpy)); + XSelectInput(dpy, display->root, ExposureMask); + display->has_shm = can_use_shm(dpy, display->root, &display->shm_event, &display->shm_opcode, @@ -3526,7 +3528,32 @@ int main(int argc, char **argv) XNextEvent(ctx.display[i].dpy, &e); DBG(POLL, ("%s received event %d\n", DisplayString(ctx.display[i].dpy), e.type)); - if (ctx.display[i].rr_active && e.type == ctx.display[i].rr_event + RRNotify) { + if (e.type == Expose) { + XExposeEvent *xe = (XExposeEvent *)&e; + struct clone *clone; + int damaged = 0; + + DBG(DAMAGE, ("%s exposed: (%d, %d)x(%d, %d)\n", + DisplayString(ctx.display[i].dpy), + xe->x, xe->y, xe->width, xe->height)); + + for (clone = ctx.active; clone; clone = clone->active) { + XRectangle r; + + if (clone->dst.display != &ctx.display[i]) + continue; + + r.x = clone->dst.x + xe->x; + r.y = clone->dst.y + xe->y; + r.width = xe->width; + r.height = xe->height; + clone_damage(clone, &r); + damaged++; + } + + if (damaged) + context_enable_timer(&ctx); + } else if (ctx.display[i].rr_active && e.type == ctx.display[i].rr_event + RRNotify) { XRRNotifyEvent *re = (XRRNotifyEvent *)&e; DBG(XRR, ("%s received RRNotify, type %d\n", DisplayString(ctx.display[i].dpy), re->subtype)); -- 1.9.1