From 09b46029faac6b82db512ec9a069862e5d147465 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Fri, 12 Sep 2014 10:33:46 -0400 Subject: [PATCH] Fix multi-monitor backgrounds The texture area was meant to be in monitor-relative coordinates, but that was not consistently followed throughout the code - fix. https://bugzilla.gnome.org/show_bug.cgi?id=736568 --- src/compositor/meta-background.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/compositor/meta-background.c b/src/compositor/meta-background.c index 1fab45e74..d78603c1c 100644 --- a/src/compositor/meta-background.c +++ b/src/compositor/meta-background.c @@ -330,6 +330,16 @@ meta_background_init (MetaBackground *self) MetaBackgroundPrivate); } +static void +set_texture_area_from_monitor_area (cairo_rectangle_int_t *monitor_area, + cairo_rectangle_int_t *texture_area) +{ + texture_area->x = 0; + texture_area->y = 0; + texture_area->width = monitor_area->width; + texture_area->height = monitor_area->height; +} + static void get_texture_area (MetaBackground *self, cairo_rectangle_int_t *monitor_rect, @@ -352,7 +362,7 @@ get_texture_area (MetaBackground *self, /* paint region is whole actor, and the texture * is scaled disproportionately to fit the actor */ - *texture_area = *monitor_rect; + set_texture_area_from_monitor_area (monitor_rect, texture_area); break; case G_DESKTOP_BACKGROUND_STYLE_WALLPAPER: meta_screen_get_size (priv->screen, &screen_width, &screen_height); @@ -376,8 +386,8 @@ get_texture_area (MetaBackground *self, * and the texture is scaled to the original image size */ image_area.width = texture_width; image_area.height = texture_height; - image_area.x = monitor_rect->x + monitor_rect->width / 2 - image_area.width / 2; - image_area.y = monitor_rect->y + monitor_rect->height / 2 - image_area.height / 2; + image_area.x = monitor_rect->width / 2 - image_area.width / 2; + image_area.y = monitor_rect->height / 2 - image_area.height / 2; *texture_area = image_area; break; @@ -402,8 +412,8 @@ get_texture_area (MetaBackground *self, image_area.height = texture_height * monitor_x_scale; /* Position image centered vertically in actor */ - image_area.x = monitor_rect->x; - image_area.y = monitor_rect->y + monitor_rect->height / 2 - image_area.height / 2; + image_area.x = 0; + image_area.y = monitor_rect->height / 2 - image_area.height / 2; } else { @@ -412,8 +422,8 @@ get_texture_area (MetaBackground *self, image_area.height = monitor_rect->height; /* Position image centered horizontally in actor */ - image_area.x = monitor_rect->x + monitor_rect->width / 2 - image_area.width / 2; - image_area.y = monitor_rect->y; + image_area.x = monitor_rect->width / 2 - image_area.width / 2; + image_area.y = 0; } *texture_area = image_area; @@ -696,7 +706,7 @@ meta_background_get_texture (MetaBackground *self, { ensure_color_texture (self); if (texture_area) - *texture_area = monitor_area; + set_texture_area_from_monitor_area (&monitor_area, texture_area); if (wrap_mode) *wrap_mode = COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE; return priv->color_texture; @@ -802,7 +812,8 @@ meta_background_get_texture (MetaBackground *self, } if (texture_area) - *texture_area = monitor_area; + set_texture_area_from_monitor_area (&monitor_area, texture_area); + if (wrap_mode) *wrap_mode = COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE; return monitor->texture;