From 4aeb130affbad5bca058a2dc03bd3e41b2b39666 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 30 Jan 2013 11:24:15 +0100 Subject: randr: Handle XRRSetScreenSize failing better Usually XRRSetScreenSize failing simply means that we don't have enough video memory, out current handling of this has 2 issues: 1) It leaves things in an inconsistent state 2) It sets x11->set_crtc_config_not_functional causing any futher monitor configs send by the client to get ignored This patch fixes these issues by: 1) Rolling back all changes made when XRRSetScreenSize fails 2) Not setting x11->set_crtc_config_not_functional on XRRSetScreenSize failure Signed-off-by: Hans de Goede --- src/vdagent-x11-randr.c | 12 +++++++++--- src/vdagent-x11.h | 2 +- src/vdagent.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c index 7edf7b4..9577ec4 100644 --- a/src/vdagent-x11-randr.c +++ b/src/vdagent-x11-randr.c @@ -696,7 +696,8 @@ static void dump_monitors_config(struct vdagent_x11 *x11, * invalid configuration request from client. */ void vdagent_x11_set_monitor_config(struct vdagent_x11 *x11, - VDAgentMonitorsConfig *mon_config) + VDAgentMonitorsConfig *mon_config, + int fallback) { int width, height; int x, y; @@ -780,8 +781,13 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 *x11, DisplayWidthMM(x11->display, x11->screen), DisplayHeightMM(x11->display, x11->screen)); if (check_error_handler(x11)) { - syslog(LOG_ERR, "failed to XRRSetScreenSize"); - x11->set_crtc_config_not_functional = 1; + syslog(LOG_ERR, "XRRSetScreenSize failed, not enough mem?"); + if (!fallback && curr) { + syslog(LOG_WARNING, "Restoring previous config"); + vdagent_x11_set_monitor_config(x11, curr, 1); + free(curr); + return; + } } } diff --git a/src/vdagent-x11.h b/src/vdagent-x11.h index 9e61508..20e770a 100644 --- a/src/vdagent-x11.h +++ b/src/vdagent-x11.h @@ -36,7 +36,7 @@ int vdagent_x11_get_fd(struct vdagent_x11 *x11); void vdagent_x11_do_read(struct vdagent_x11 *x11); void vdagent_x11_set_monitor_config(struct vdagent_x11 *x11, - VDAgentMonitorsConfig *mon_config); + VDAgentMonitorsConfig *mon_config, int fallback); void vdagent_x11_clipboard_grab(struct vdagent_x11 *x11, uint8_t selection, uint32_t *types, uint32_t type_count); void vdagent_x11_clipboard_request(struct vdagent_x11 *x11, diff --git a/src/vdagent.c b/src/vdagent.c index e2ceddd..430407e 100644 --- a/src/vdagent.c +++ b/src/vdagent.c @@ -52,7 +52,7 @@ void daemon_read_complete(struct udscs_connection **connp, { switch (header->type) { case VDAGENTD_MONITORS_CONFIG: - vdagent_x11_set_monitor_config(x11, (VDAgentMonitorsConfig *)data); + vdagent_x11_set_monitor_config(x11, (VDAgentMonitorsConfig *)data, 0); free(data); break; case VDAGENTD_CLIPBOARD_REQUEST: -- cgit