diff --git a/src/x11/window-props.c b/src/x11/window-props.c index c0fc3804d..88c7beb70 100644 --- a/src/x11/window-props.c +++ b/src/x11/window-props.c @@ -607,12 +607,72 @@ reload_wm_name (MetaWindow *window, } } +static void +meta_window_set_opaque_region (MetaWindow *window, + cairo_region_t *region) +{ + if (cairo_region_equal (window->opaque_region, region)) + return; + + g_clear_pointer (&window->opaque_region, cairo_region_destroy); + + if (region != NULL) + window->opaque_region = cairo_region_reference (region); + + meta_compositor_window_shape_changed (window->display->compositor, window); +} + static void reload_opaque_region (MetaWindow *window, MetaPropValue *value, gboolean initial) { - meta_window_x11_update_opaque_region (window); + cairo_region_t *opaque_region = NULL; + + if (value->type != META_PROP_VALUE_INVALID) + { + gulong *region = value->v.cardinal_list.cardinals; + int nitems = value->v.cardinal_list.n_cardinals; + + cairo_rectangle_int_t *rects; + int i, rect_index, nrects; + + if (nitems % 4 != 0) + { + meta_verbose ("_NET_WM_OPAQUE_REGION does not have a list of 4-tuples."); + goto out; + } + + /* empty region */ + if (nitems == 0) + goto out; + + nrects = nitems / 4; + + rects = g_new (cairo_rectangle_int_t, nrects); + + rect_index = 0; + i = 0; + while (i < nitems) + { + cairo_rectangle_int_t *rect = &rects[rect_index]; + + rect->x = region[i++]; + rect->y = region[i++]; + rect->width = region[i++]; + rect->height = region[i++]; + + rect_index++; + } + + opaque_region = cairo_region_create_rectangles (rects, nrects); + + g_free (rects); + } + + out: + meta_window_set_opaque_region (window, opaque_region); + cairo_region_destroy (opaque_region); } static void diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 4b48342c9..76098ec5c 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -1585,76 +1585,6 @@ meta_window_x11_set_net_wm_state (MetaWindow *window) } } -static void -meta_window_set_opaque_region (MetaWindow *window, - cairo_region_t *region) -{ - if (cairo_region_equal (window->opaque_region, region)) - return; - - g_clear_pointer (&window->opaque_region, cairo_region_destroy); - - if (region != NULL) - window->opaque_region = cairo_region_reference (region); - - meta_compositor_window_shape_changed (window->display->compositor, window); -} - -void -meta_window_x11_update_opaque_region (MetaWindow *window) -{ - cairo_region_t *opaque_region = NULL; - gulong *region = NULL; - int nitems; - - if (meta_prop_get_cardinal_list (window->display, - window->xwindow, - window->display->atom__NET_WM_OPAQUE_REGION, - ®ion, &nitems)) - { - cairo_rectangle_int_t *rects; - int i, rect_index, nrects; - - if (nitems % 4 != 0) - { - meta_verbose ("_NET_WM_OPAQUE_REGION does not have a list of 4-tuples."); - goto out; - } - - /* empty region */ - if (nitems == 0) - goto out; - - nrects = nitems / 4; - - rects = g_new (cairo_rectangle_int_t, nrects); - - rect_index = 0; - i = 0; - while (i < nitems) - { - cairo_rectangle_int_t *rect = &rects[rect_index]; - - rect->x = region[i++]; - rect->y = region[i++]; - rect->width = region[i++]; - rect->height = region[i++]; - - rect_index++; - } - - opaque_region = cairo_region_create_rectangles (rects, nrects); - - g_free (rects); - } - - out: - meta_XFree (region); - - meta_window_set_opaque_region (window, opaque_region); - cairo_region_destroy (opaque_region); -} - static cairo_region_t * region_create_from_x_rectangles (const XRectangle *rects, int n_rects) diff --git a/src/x11/window-x11.h b/src/x11/window-x11.h index affd15e81..a2637a0df 100644 --- a/src/x11/window-x11.h +++ b/src/x11/window-x11.h @@ -55,7 +55,6 @@ void meta_window_x11_destroy_sync_request_alarm (MetaWindow *window); void meta_window_x11_update_sync_request_counter (MetaWindow *window, gint64 new_counter_value); -void meta_window_x11_update_opaque_region (MetaWindow *window); void meta_window_x11_update_input_region (MetaWindow *window); void meta_window_x11_update_shape_region (MetaWindow *window);