compositor-x11: Fix Weston running on a secondary X screen

When DISPLAY is anything other than #.0 weston would still use .0

Fixes
https://bugs.freedesktop.org/show_bug.cgi?id=90532
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
dev
Marko 9 years ago committed by Derek Foreman
parent 6ce78992a0
commit 61b4d3ea44
  1. 34
      src/compositor-x11.c

@ -130,6 +130,20 @@ struct window_delete_data {
struct gl_renderer_interface *gl_renderer; struct gl_renderer_interface *gl_renderer;
static xcb_screen_t *
x11_compositor_get_default_screen(struct x11_backend *b)
{
xcb_screen_iterator_t iter;
int i, screen_nbr = XDefaultScreen(b->dpy);
iter = xcb_setup_roots_iterator(xcb_get_setup(b->conn));
for (i = 0; iter.rem; xcb_screen_next(&iter), i++)
if (i == screen_nbr)
return iter.data;
return xcb_setup_roots_iterator(xcb_get_setup(b->conn)).data;
}
static struct xkb_keymap * static struct xkb_keymap *
x11_backend_get_keymap(struct x11_backend *b) x11_backend_get_keymap(struct x11_backend *b)
{ {
@ -668,8 +682,8 @@ static int
x11_output_init_shm(struct x11_backend *b, struct x11_output *output, x11_output_init_shm(struct x11_backend *b, struct x11_output *output,
int width, int height) int width, int height)
{ {
xcb_screen_iterator_t iter;
xcb_visualtype_t *visual_type; xcb_visualtype_t *visual_type;
xcb_screen_t *screen;
xcb_format_iterator_t fmt; xcb_format_iterator_t fmt;
xcb_void_cookie_t cookie; xcb_void_cookie_t cookie;
xcb_generic_error_t *err; xcb_generic_error_t *err;
@ -686,8 +700,8 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output,
return -1; return -1;
} }
iter = xcb_setup_roots_iterator(xcb_get_setup(b->conn)); screen = x11_compositor_get_default_screen(b);
visual_type = find_visual_by_id(iter.data, iter.data->root_visual); visual_type = find_visual_by_id(screen, screen->root_visual);
if (!visual_type) { if (!visual_type) {
weston_log("Failed to lookup visual for root window\n"); weston_log("Failed to lookup visual for root window\n");
errno = ENOENT; errno = ENOENT;
@ -698,7 +712,7 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output,
visual_type->red_mask, visual_type->red_mask,
visual_type->green_mask, visual_type->green_mask,
visual_type->blue_mask); visual_type->blue_mask);
output->depth = get_depth_of_visual(iter.data, iter.data->root_visual); output->depth = get_depth_of_visual(screen, screen->root_visual);
weston_log("Visual depth is %d\n", output->depth); weston_log("Visual depth is %d\n", output->depth);
for (fmt = xcb_setup_pixmap_formats_iterator(xcb_get_setup(b->conn)); for (fmt = xcb_setup_pixmap_formats_iterator(xcb_get_setup(b->conn));
@ -774,7 +788,7 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,
static const char class[] = "weston-1\0Weston Compositor"; static const char class[] = "weston-1\0Weston Compositor";
char title[32]; char title[32];
struct x11_output *output; struct x11_output *output;
xcb_screen_iterator_t iter; xcb_screen_t *screen;
struct wm_normal_hints normal_hints; struct wm_normal_hints normal_hints;
struct wl_event_loop *loop; struct wl_event_loop *loop;
int output_width, output_height, width_mm, height_mm; int output_width, output_height, width_mm, height_mm;
@ -825,16 +839,16 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,
values[1] = b->null_cursor; values[1] = b->null_cursor;
output->window = xcb_generate_id(b->conn); output->window = xcb_generate_id(b->conn);
iter = xcb_setup_roots_iterator(xcb_get_setup(b->conn)); screen = x11_compositor_get_default_screen(b);
xcb_create_window(b->conn, xcb_create_window(b->conn,
XCB_COPY_FROM_PARENT, XCB_COPY_FROM_PARENT,
output->window, output->window,
iter.data->root, screen->root,
0, 0, 0, 0,
output_width, output_height, output_width, output_height,
0, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_WINDOW_CLASS_INPUT_OUTPUT,
iter.data->root_visual, screen->root_visual,
mask, values); mask, values);
if (fullscreen) { if (fullscreen) {
@ -1529,7 +1543,6 @@ x11_backend_create(struct weston_compositor *compositor,
struct x11_backend *b; struct x11_backend *b;
struct x11_output *output; struct x11_output *output;
struct weston_config_section *section; struct weston_config_section *section;
xcb_screen_iterator_t s;
int i, x = 0, output_count = 0; int i, x = 0, output_count = 0;
int width, height, scale, count; int width, height, scale, count;
const char *section_name; const char *section_name;
@ -1556,8 +1569,7 @@ x11_backend_create(struct weston_compositor *compositor,
if (xcb_connection_has_error(b->conn)) if (xcb_connection_has_error(b->conn))
goto err_xdisplay; goto err_xdisplay;
s = xcb_setup_roots_iterator(xcb_get_setup(b->conn)); b->screen = x11_compositor_get_default_screen(b);
b->screen = s.data;
wl_array_init(&b->keys); wl_array_init(&b->keys);
x11_backend_get_resources(b); x11_backend_get_resources(b);

Loading…
Cancel
Save