diff options
author | Hans de Goede <hans@localhost.localdomain> | 2013-04-10 17:05:11 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-04-10 17:48:54 +0200 |
commit | cc6f3d5a72d01a87a3630acb3f79e860ddf79901 (patch) | |
tree | 5c15d0dadb4f66e6d487e83d6a10c32c5e2d93e4 /src | |
parent | 60ce72321b1144826c624f8e587c1809c3a7a989 (diff) |
vdagent-x11: Change root_window, width and height to an array
This is a preparation patch for handling setups where there are multiple
qxl-devices each mapped to a separate screen.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vdagent-x11-priv.h | 8 | ||||
-rw-r--r-- | src/vdagent-x11-randr.c | 42 | ||||
-rw-r--r-- | src/vdagent-x11.c | 23 |
3 files changed, 36 insertions, 37 deletions
diff --git a/src/vdagent-x11-priv.h b/src/vdagent-x11-priv.h index ee04b04..71c26b9 100644 --- a/src/vdagent-x11-priv.h +++ b/src/vdagent-x11-priv.h @@ -21,6 +21,7 @@ } \ } while (0) +#define MAX_SCREENS 16 /* Same as qxl_dev.h client_monitors_config.heads count */ #define MONITOR_SIZE_COUNT 64 @@ -82,15 +83,14 @@ struct vdagent_x11 { Atom targets_atom; Atom incr_atom; Atom multiple_atom; - Window root_window; + Window root_window[MAX_SCREENS]; Window selection_window; struct udscs_connection *vdagentd; char *net_wm_name; int debug; int fd; - int screen; - int width; - int height; + int width[MAX_SCREENS]; + int height[MAX_SCREENS]; int has_xfixes; int xfixes_event_base; int max_prop_size; diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c index 5a299d1..1d609bd 100644 --- a/src/vdagent-x11-randr.c +++ b/src/vdagent-x11-randr.c @@ -94,9 +94,9 @@ static void update_randr_res(struct vdagent_x11 *x11, int poll) free_randr_resources(x11); if (poll) - x11->randr.res = XRRGetScreenResources(x11->display, x11->root_window); + x11->randr.res = XRRGetScreenResources(x11->display, x11->root_window[0]); else - x11->randr.res = XRRGetScreenResourcesCurrent(x11->display, x11->root_window); + x11->randr.res = XRRGetScreenResourcesCurrent(x11->display, x11->root_window[0]); x11->randr.outputs = malloc(x11->randr.res->noutput * sizeof(*x11->randr.outputs)); x11->randr.crtcs = malloc(x11->randr.res->ncrtc * sizeof(*x11->randr.crtcs)); for (i = 0 ; i < x11->randr.res->noutput; ++i) { @@ -110,7 +110,7 @@ static void update_randr_res(struct vdagent_x11 *x11, int poll) x11->randr.res->crtcs[i]); } /* XXX is this dynamic? should it be cached? */ - if (XRRGetScreenSizeRange(x11->display, x11->root_window, + if (XRRGetScreenSizeRange(x11->display, x11->root_window[0], &x11->randr.min_width, &x11->randr.min_height, &x11->randr.max_width, @@ -316,7 +316,7 @@ static XRRModeInfo *create_new_mode(struct vdagent_x11 *x11, int output_index, mode.modeFlags = 0; mode.id = 0; vdagent_x11_set_error_handler(x11, error_handler); - XRRCreateMode (x11->display, x11->root_window, &mode); + XRRCreateMode (x11->display, x11->root_window[0], &mode); // ignore race error, if mode is created by others vdagent_x11_restore_error_handler(x11); @@ -408,7 +408,7 @@ static int set_screen_to_best_size(struct vdagent_x11 *x11, int width, int heigh XRRScreenConfiguration *config; Rotation rotation; - sizes = XRRSizes(x11->display, x11->screen, &num_sizes); + sizes = XRRSizes(x11->display, 0, &num_sizes); if (!sizes || !num_sizes) { syslog(LOG_ERR, "XRRSizes failed"); return 0; @@ -436,13 +436,13 @@ static int set_screen_to_best_size(struct vdagent_x11 *x11, int width, int heigh return 0; } - config = XRRGetScreenInfo(x11->display, x11->root_window); + config = XRRGetScreenInfo(x11->display, x11->root_window[0]); if(!config) { syslog(LOG_ERR, "get screen info failed"); return 0; } XRRConfigCurrentConfiguration(config, &rotation); - XRRSetScreenConfig(x11->display, config, x11->root_window, best, + XRRSetScreenConfig(x11->display, config, x11->root_window[0], best, rotation, CurrentTime); XRRFreeScreenConfigInfo(config); @@ -457,7 +457,7 @@ static int set_screen_to_best_size(struct vdagent_x11 *x11, int width, int heigh void vdagent_x11_randr_handle_root_size_change(struct vdagent_x11 *x11, int width, int height) { - if (width == x11->width && height == x11->height) { + if (width == x11->width[0] && height == x11->height[0]) { return; } @@ -465,8 +465,8 @@ void vdagent_x11_randr_handle_root_size_change(struct vdagent_x11 *x11, syslog(LOG_DEBUG, "Root size changed to %dx%d send %d", width, height, !x11->dont_send_guest_xorg_res); - x11->width = width; - x11->height = height; + x11->width[0] = width; + x11->height[0] = height; if (!x11->dont_send_guest_xorg_res) { vdagent_x11_send_daemon_guest_xorg_res(x11, 1); } @@ -730,7 +730,7 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 *x11, curr = get_current_mon_config(x11); if (same_monitor_configs(mon_config, curr) && - x11->width == primary_w && x11->height == primary_h) { + x11->width[0] == primary_w && x11->height[0] == primary_h) { goto exit; } @@ -760,14 +760,14 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 *x11, } } - if (primary_w != x11->width || primary_h != x11->height) { + if (primary_w != x11->width[0] || primary_h != x11->height[0]) { if (x11->debug) syslog(LOG_DEBUG, "Changing screen size to %dx%d", primary_w, primary_h); vdagent_x11_set_error_handler(x11, error_handler); - XRRSetScreenSize(x11->display, x11->root_window, primary_w, primary_h, - DisplayWidthMM(x11->display, x11->screen), - DisplayHeightMM(x11->display, x11->screen)); + XRRSetScreenSize(x11->display, x11->root_window[0], primary_w, primary_h, + DisplayWidthMM(x11->display, 0), + DisplayHeightMM(x11->display, 0)); if (vdagent_x11_restore_error_handler(x11)) { syslog(LOG_ERR, "XRRSetScreenSize failed, not enough mem?"); if (!fallback && curr) { @@ -790,8 +790,8 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 *x11, update: update_randr_res(x11, x11->randr.num_monitors != enabled_monitors(mon_config)); - x11->width = primary_w; - x11->height = primary_h; + x11->width[0] = primary_w; + x11->height[0] = primary_h; /* Flush output buffers and consume any pending events (ConfigureNotify) */ x11->dont_send_guest_xorg_res = 1; @@ -866,8 +866,8 @@ no_info: res = malloc(screen_count * sizeof(*res)); if (!res) goto no_mem; - res[0].width = x11->width; - res[0].height = x11->height; + res[0].width = x11->width[0]; + res[0].height = x11->height[0]; res[0].x = 0; res[0].y = 0; } @@ -878,8 +878,8 @@ no_info: 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)); + udscs_write(x11->vdagentd, VDAGENTD_GUEST_XORG_RESOLUTION, x11->width[0], + x11->height[0], (uint8_t *)res, screen_count * sizeof(*res)); free(res); return; no_mem: diff --git a/src/vdagent-x11.c b/src/vdagent-x11.c index f81c8ca..51f9315 100644 --- a/src/vdagent-x11.c +++ b/src/vdagent-x11.c @@ -127,7 +127,7 @@ static void vdagent_x11_get_wm_name(struct vdagent_x11 *x11) vdagent_x11_set_error_handler(x11, vdagent_x11_ignore_bad_window_handler); /* Get the window manager SUPPORTING_WM_CHECK window */ - if (XGetWindowProperty(x11->display, x11->root_window, + if (XGetWindowProperty(x11->display, x11->root_window[0], XInternAtom(x11->display, "_NET_SUPPORTING_WM_CHECK", False), 0, LONG_MAX, False, XA_WINDOW, &type_ret, &format_ret, &len, &remain, &data) == Success) { @@ -136,7 +136,7 @@ static void vdagent_x11_get_wm_name(struct vdagent_x11 *x11) XFree(data); } if (sup_window == None && - XGetWindowProperty(x11->display, x11->root_window, + XGetWindowProperty(x11->display, x11->root_window[0], XInternAtom(x11->display, "_WIN_SUPPORTING_WM_CHECK", False), 0, LONG_MAX, False, XA_CARDINAL, &type_ret, &format_ret, &len, &remain, &data) == Success) { @@ -201,8 +201,7 @@ struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd, XSynchronize(x11->display, True); } - x11->screen = DefaultScreen(x11->display); - x11->root_window = RootWindow(x11->display, x11->screen); + x11->root_window[0] = RootWindow(x11->display, 0); x11->fd = ConnectionNumber(x11->display); x11->clipboard_atom = XInternAtom(x11->display, "CLIPBOARD", False); x11->clipboard_primary_atom = XInternAtom(x11->display, "PRIMARY", False); @@ -221,7 +220,7 @@ struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd, } /* We should not store properties (for selections) on the root window */ - x11->selection_window = XCreateSimpleWindow(x11->display, x11->root_window, + x11->selection_window = XCreateSimpleWindow(x11->display, x11->root_window[0], 0, 0, 1, 1, 0, 0, 0); if (x11->debug) syslog(LOG_DEBUG, "Selection window: %u", (int)x11->selection_window); @@ -231,12 +230,12 @@ struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd, if (XFixesQueryExtension(x11->display, &x11->xfixes_event_base, &i) && XFixesQueryVersion(x11->display, &major, &minor) && major >= 1) { x11->has_xfixes = 1; - XFixesSelectSelectionInput(x11->display, x11->root_window, + XFixesSelectSelectionInput(x11->display, x11->root_window[0], x11->clipboard_atom, XFixesSetSelectionOwnerNotifyMask| XFixesSelectionWindowDestroyNotifyMask| XFixesSelectionClientCloseNotifyMask); - XFixesSelectSelectionInput(x11->display, x11->root_window, + XFixesSelectSelectionInput(x11->display, x11->root_window[0], x11->clipboard_primary_atom, XFixesSetSelectionOwnerNotifyMask| XFixesSelectionWindowDestroyNotifyMask| @@ -255,12 +254,12 @@ struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd, x11->max_prop_size = 262144; /* Catch resolution changes */ - XSelectInput(x11->display, x11->root_window, StructureNotifyMask); + XSelectInput(x11->display, x11->root_window[0], StructureNotifyMask); /* Get the current resolution */ - XGetWindowAttributes(x11->display, x11->root_window, &attrib); - x11->width = attrib.width; - x11->height = attrib.height; + XGetWindowAttributes(x11->display, x11->root_window[0], &attrib); + x11->width[0] = attrib.width; + x11->height[0] = attrib.height; vdagent_x11_send_daemon_guest_xorg_res(x11, 1); /* Get net_wm_name, since we are started at the same time as the wm, @@ -494,7 +493,7 @@ static void vdagent_x11_handle_event(struct vdagent_x11 *x11, XEvent event) switch (event.type) { case ConfigureNotify: // TODO: handle CrtcConfigureNotify, OutputConfigureNotify can be ignored. - if (event.xconfigure.window != x11->root_window) + if (event.xconfigure.window != x11->root_window[0]) break; handled = 1; |