summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-02-03 21:04:02 +0100
committerHans de Goede <hdegoede@redhat.com>2013-02-04 14:08:00 +0100
commit3343d67d73df8c22e755a1e5a17e4a1024b2e1a1 (patch)
treeb80114f4b6b1d3bc0999fcf11ec410cbdaffbbf6 /src
parent8c1b3c056d6b64e65e93a9895f66ff927f81a5e8 (diff)
downloadvd_agent-3343d67d73df8c22e755a1e5a17e4a1024b2e1a1.tar.gz
vd_agent-3343d67d73df8c22e755a1e5a17e4a1024b2e1a1.tar.xz
vd_agent-3343d67d73df8c22e755a1e5a17e4a1024b2e1a1.zip
randr: Refactor send_daemon_guest_xorg_res()
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/vdagent-x11-randr.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c
index 88abb56..4710603 100644
--- a/src/vdagent-x11-randr.c
+++ b/src/vdagent-x11-randr.c
@@ -831,27 +831,21 @@ exit:
void vdagent_x11_send_daemon_guest_xorg_res(struct vdagent_x11 *x11)
{
struct vdagentd_guest_xorg_resolution *res = NULL;
- XineramaScreenInfo *screen_info = NULL;
int i, screen_count = 0;
if (x11->has_xinerama) {
+ XineramaScreenInfo *screen_info = NULL;
+
/* Xinerama reports the same information RANDR reports, so stay
* with Xinerama for support of Xinerama only setups */
screen_info = XineramaQueryScreens(x11->display, &screen_count);
- }
-
- if (screen_count == 0)
- screen_count = 1;
-
- res = malloc(screen_count * sizeof(*res));
- if (!res) {
- syslog(LOG_ERR, "out of memory while trying to send resolutions, not sending resolutions.");
- if (screen_info)
+ if (!screen_info)
+ goto no_info;
+ res = malloc(screen_count * sizeof(*res));
+ if (!res) {
XFree(screen_info);
- return;
- }
-
- if (screen_info) {
+ goto no_mem;
+ }
for (i = 0; i < screen_count; i++) {
if (screen_info[i].screen_number >= screen_count) {
syslog(LOG_ERR, "Invalid screen number in xinerama screen info (%d >= %d)",
@@ -867,13 +861,27 @@ void vdagent_x11_send_daemon_guest_xorg_res(struct vdagent_x11 *x11)
}
XFree(screen_info);
} else {
+no_info:
+ screen_count = 1;
+ res = malloc(screen_count * sizeof(*res));
+ if (!res)
+ goto no_mem;
res[0].width = x11->width;
res[0].height = x11->height;
res[0].x = 0;
res[0].y = 0;
}
+ if (x11->debug) {
+ for (i = 0; i < screen_count; i++)
+ syslog(LOG_DEBUG, "Screen %d %dx%d%+d%+d", i, res[i].width,
+ res[i].height, res[i].x, res[i].y);
+ }
+
udscs_write(x11->vdagentd, VDAGENTD_GUEST_XORG_RESOLUTION, x11->width,
x11->height, (uint8_t *)res, screen_count * sizeof(*res));
free(res);
+ return;
+no_mem:
+ syslog(LOG_ERR, "out of memory while trying to send resolutions, not sending resolutions.");
}