diff options
| author | Hans de Goede <hdegoede@redhat.com> | 2013-01-30 11:24:15 +0100 |
|---|---|---|
| committer | Hans de Goede <hdegoede@redhat.com> | 2013-01-30 17:04:56 +0100 |
| commit | 4aeb130affbad5bca058a2dc03bd3e41b2b39666 (patch) | |
| tree | 079ff0e8a87455487a4e6a7a13c05bb278ac5c7d /src | |
| parent | 2b1f1e45ce87a24c6dec0d18c50f14cc9e72e176 (diff) | |
| download | vd_agent-4aeb130affbad5bca058a2dc03bd3e41b2b39666.tar.gz vd_agent-4aeb130affbad5bca058a2dc03bd3e41b2b39666.tar.xz vd_agent-4aeb130affbad5bca058a2dc03bd3e41b2b39666.zip | |
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 <hdegoede@redhat.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/vdagent-x11-randr.c | 12 | ||||
| -rw-r--r-- | src/vdagent-x11.h | 2 | ||||
| -rw-r--r-- | src/vdagent.c | 2 |
3 files changed, 11 insertions, 5 deletions
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: |
