diff --git a/src/compositor-x11.c b/src/compositor-x11.c index 3565677..253be25 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -124,6 +124,23 @@ struct window_delete_data { struct gl_renderer_interface *gl_renderer; +static xcb_screen_t* x11_compositor_get_default_screen(struct x11_compositor* c) +{ + int i = 0; + xcb_screen_iterator_t iter; + for (iter = xcb_setup_roots_iterator(xcb_get_setup(c->conn)) ; + iter.rem ; + xcb_screen_next(&iter), i++) + { + if (i == XDefaultScreen(c->dpy)) + { + xcb_screen_t* screen = iter.data; + return screen; + } + } + return xcb_setup_roots_iterator(xcb_get_setup(c->conn)).data; +} + static struct xkb_keymap * x11_compositor_get_keymap(struct x11_compositor *c) { @@ -658,8 +675,8 @@ static int x11_output_init_shm(struct x11_compositor *c, struct x11_output *output, int width, int height) { - xcb_screen_iterator_t iter; xcb_visualtype_t *visual_type; + xcb_screen_t* screen; xcb_format_iterator_t fmt; xcb_void_cookie_t cookie; xcb_generic_error_t *err; @@ -676,8 +693,8 @@ x11_output_init_shm(struct x11_compositor *c, struct x11_output *output, return -1; } - iter = xcb_setup_roots_iterator(xcb_get_setup(c->conn)); - visual_type = find_visual_by_id(iter.data, iter.data->root_visual); + screen = x11_compositor_get_default_screen(c); + visual_type = find_visual_by_id(screen, screen->root_visual); if (!visual_type) { weston_log("Failed to lookup visual for root window\n"); errno = ENOENT; @@ -688,7 +705,7 @@ x11_output_init_shm(struct x11_compositor *c, struct x11_output *output, visual_type->red_mask, visual_type->green_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); for (fmt = xcb_setup_pixmap_formats_iterator(xcb_get_setup(c->conn)); @@ -763,7 +780,7 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y, static const char class[] = "weston-1\0Weston Compositor"; char title[32]; struct x11_output *output; - xcb_screen_iterator_t iter; + xcb_screen_t* screen; struct wm_normal_hints normal_hints; struct wl_event_loop *loop; int output_width, output_height, width_mm, height_mm; @@ -812,16 +829,16 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y, values[1] = c->null_cursor; output->window = xcb_generate_id(c->conn); - iter = xcb_setup_roots_iterator(xcb_get_setup(c->conn)); + screen = x11_compositor_get_default_screen(c); xcb_create_window(c->conn, XCB_COPY_FROM_PARENT, output->window, - iter.data->root, + screen->root, 0, 0, output_width, output_height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, - iter.data->root_visual, + screen->root_visual, mask, values); if (fullscreen) { @@ -1509,7 +1526,6 @@ x11_compositor_create(struct wl_display *display, struct x11_compositor *c; struct x11_output *output; struct weston_config_section *section; - xcb_screen_iterator_t s; int i, x = 0, output_count = 0; int width, height, scale, count; const char *section_name; @@ -1538,8 +1554,7 @@ x11_compositor_create(struct wl_display *display, if (xcb_connection_has_error(c->conn)) goto err_xdisplay; - s = xcb_setup_roots_iterator(xcb_get_setup(c->conn)); - c->screen = s.data; + c->screen = x11_compositor_get_default_screen(c); wl_array_init(&c->keys); x11_compositor_get_resources(c);