From 47ebbb21909ac0b36a31d335502fe83a410939dd Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 7 Jan 2013 19:57:44 +0100 Subject: [PATCH] randr: Properly update things if the number of monitors changes If the number of monitors changes, and the remaining monitors are the same as before, then same_monitor_configs() would wrongly return true, causing monitor-reconfiguarion to be skipped. Signed-off-by: Hans de Goede --- src/vdagent-x11-priv.h | 1 + src/vdagent-x11-randr.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/vdagent-x11-priv.h b/src/vdagent-x11-priv.h index 2f447f6..a65dcb3 100644 --- a/src/vdagent-x11-priv.h +++ b/src/vdagent-x11-priv.h @@ -111,6 +111,7 @@ struct vdagent_x11 { int max_width; int min_height; int max_height; + int num_monitors; } randr; /* NB: we cache this assuming the driver isn't changed under our feet */ diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c index 016775d..6a9a4ed 100644 --- a/src/vdagent-x11-randr.c +++ b/src/vdagent-x11-randr.c @@ -106,6 +106,7 @@ static void free_randr_resources(struct vdagent_x11 *x11) x11->randr.res = NULL; x11->randr.outputs = NULL; x11->randr.crtcs = NULL; + x11->randr.num_monitors = 0; } static void update_randr_res(struct vdagent_x11 *x11) @@ -120,6 +121,8 @@ static void update_randr_res(struct vdagent_x11 *x11) for (i = 0 ; i < x11->randr.res->noutput; ++i) { x11->randr.outputs[i] = XRRGetOutputInfo(x11->display, x11->randr.res, x11->randr.res->outputs[i]); + if (x11->randr.outputs[i]->connection == RR_Connected) + x11->randr.num_monitors++; } for (i = 0 ; i < x11->randr.res->ncrtc; ++i) { x11->randr.crtcs[i] = XRRGetCrtcInfo(x11->display, x11->randr.res, @@ -606,6 +609,9 @@ static int same_monitor_configs(struct vdagent_x11 *x11, if (x11->width != primary_w || x11->height != primary_h) return 0; + if (x11->randr.num_monitors != mon->num_of_monitors) + return 0; + for (i = 0 ; i < mon->num_of_monitors; ++i) { if (x11->randr.outputs[i]->ncrtc == 0) { return 0; -- 2.11.4.GIT