[PATCH v2 weston] compositor-x11: Fix Weston running on a secondary X screen

Bryce Harrington bryce at osg.samsung.com
Mon Oct 5 18:38:09 PDT 2015


On Mon, Oct 05, 2015 at 05:27:54PM -0500, Derek Foreman wrote:
> From: Marko <bgz.marko at gmail.com>
> 
> When DISPLAY is anything other than #.0 weston would still use .0
> 
> Fixes
> https://bugs.freedesktop.org/show_bug.cgi?id=90532
> 
> ---
> 
> This has been around for far too long and it fixes a real bug...
> 
> Marko, if you're still paying attention, would you mind testing this?
> Also, can we get your "Signed-off-by" for the commit?
> 
> I've rebased it against weston git master, made the totally gratuitous
> changes I wanted to the loop, fixed the formatting, and handled all
> the libweston changes...
> 
> It works for me, anyone that wants to test it...
> 
> Xephyr -screen 640x480 -screen 640x480 :1
> 
> DISPLAY=:1.0 weston
> and
> DISPLAY=:1.1 weston
> will do the same thing before the patch is applied, and will work
> properly after.
> 
> 
>  src/compositor-x11.c | 34 +++++++++++++++++++++++-----------
>  1 file changed, 23 insertions(+), 11 deletions(-)

LGTM,
Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>

 
> diff --git a/src/compositor-x11.c b/src/compositor-x11.c
> index 1c53e3b..9a23996 100644
> --- a/src/compositor-x11.c
> +++ b/src/compositor-x11.c
> @@ -130,6 +130,20 @@ struct window_delete_data {
>  
>  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 *
>  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,
>  	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;
> @@ -686,8 +700,8 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output,
>  		return -1;
>  	}
>  
> -	iter = xcb_setup_roots_iterator(xcb_get_setup(b->conn));
> -	visual_type = find_visual_by_id(iter.data, iter.data->root_visual);
> +	screen = x11_compositor_get_default_screen(b);
> +	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;
> @@ -698,7 +712,7 @@ x11_output_init_shm(struct x11_backend *b, 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(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";
>  	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;
> @@ -825,16 +839,16 @@ x11_backend_create_output(struct x11_backend *b, int x, int y,
>  
>  	values[1] = b->null_cursor;
>  	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_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) {
> @@ -1529,7 +1543,6 @@ x11_backend_create(struct weston_compositor *compositor,
>  	struct x11_backend *b;
>  	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;
> @@ -1556,8 +1569,7 @@ x11_backend_create(struct weston_compositor *compositor,
>  	if (xcb_connection_has_error(b->conn))
>  		goto err_xdisplay;
>  
> -	s = xcb_setup_roots_iterator(xcb_get_setup(b->conn));
> -	b->screen = s.data;
> +	b->screen = x11_compositor_get_default_screen(b);
>  	wl_array_init(&b->keys);
>  
>  	x11_backend_get_resources(b);
> -- 
> 2.5.3
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list