Commit 39357fc2 authored by Jasper St. Pierre's avatar Jasper St. Pierre

window-props: Don't make another round-trip to fetch the opaque region

We already have the property value from our property fetching.
parent 799de4f0
......@@ -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
......
......@@ -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,
&region, &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)
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment