[metacity] window: parse _NET_WM_OPAQUE_REGION property
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] window: parse _NET_WM_OPAQUE_REGION property
- Date: Mon, 6 Mar 2017 15:51:22 +0000 (UTC)
commit 339ce6a238ffdb9c67529869e8903e17f98480d5
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Mar 6 11:20:56 2017 +0200
window: parse _NET_WM_OPAQUE_REGION property
https://git.gnome.org/browse/mutter/commit/?id=a613a55658c5717481e1f2d34987715d5f0a5ca4
https://git.gnome.org/browse/mutter/commit/src/?id=39357fc242f6a02bab0af0176dc8d842b3d97020
src/core/atomnames.h | 1 +
src/core/window-private.h | 3 ++
src/core/window-props.c | 79 +++++++++++++++++++++++++++++++++++++++++++++
src/core/window.c | 4 ++
4 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/src/core/atomnames.h b/src/core/atomnames.h
index 087d27a..6e14219 100644
--- a/src/core/atomnames.h
+++ b/src/core/atomnames.h
@@ -164,6 +164,7 @@ item(_NET_WM_ACTION_BELOW)
item(_NET_WM_STATE_STICKY)
item(_NET_WM_FULLSCREEN_MONITORS)
item(_NET_WM_STATE_FOCUSED)
+item(_NET_WM_OPAQUE_REGION)
item(_NET_RESTACK_WINDOW)
item(_NET_WM_WINDOW_OPACITY)
diff --git a/src/core/window-private.h b/src/core/window-private.h
index e210270..65f98f9 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -343,6 +343,9 @@ struct _MetaWindow
/* if non-NULL, the bounds of the window frame */
cairo_region_t *frame_bounds;
+ /* if non-NULL, the opaque region _NET_WM_OPAQUE_REGION */
+ cairo_region_t *opaque_region;
+
/* Note: can be NULL */
GSList *struts;
diff --git a/src/core/window-props.c b/src/core/window-props.c
index 3366286..4007917 100644
--- a/src/core/window-props.c
+++ b/src/core/window-props.c
@@ -720,6 +720,79 @@ 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)
+{
+ int nitems, nrects, rect_index, i;
+ gulong *region;
+ cairo_rectangle_int_t *rects;
+ cairo_region_t *opaque_region;
+
+ if (value->type == META_PROP_VALUE_INVALID)
+ {
+ meta_window_set_opaque_region (window, NULL);
+ return;
+ }
+
+ nitems = value->v.cardinal_list.n_cardinals;
+ region = value->v.cardinal_list.cardinals;
+
+ if (nitems % 4 != 0)
+ {
+ meta_verbose ("_NET_WM_OPAQUE_REGION does not have a list of 4-tuples.");
+ meta_window_set_opaque_region (window, NULL);
+ return;
+ }
+
+ /* empty region */
+ if (nitems == 0)
+ {
+ meta_window_set_opaque_region (window, NULL);
+ return;
+ }
+
+ nrects = nitems / 4;
+ rects = g_new (cairo_rectangle_int_t, nrects);
+ rect_index = i = 0;
+
+ while (i < nitems)
+ {
+ cairo_rectangle_int_t *rect;
+
+ 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);
+
+ meta_window_set_opaque_region (window, opaque_region);
+ cairo_region_destroy (opaque_region);
+}
+
+static void
reload_net_wm_state (MetaWindow *window,
MetaPropValue *value,
gboolean initial)
@@ -1715,6 +1788,12 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
LOAD_INIT | INCLUDE_OR
},
{
+ display->atom__NET_WM_OPAQUE_REGION,
+ META_PROP_VALUE_CARDINAL_LIST,
+ reload_opaque_region,
+ LOAD_INIT | INCLUDE_OR
+ },
+ {
display->atom__NET_WM_DESKTOP,
META_PROP_VALUE_CARDINAL,
reload_net_wm_desktop,
diff --git a/src/core/window.c b/src/core/window.c
index 7fd7928..5b14b20 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -528,6 +528,7 @@ meta_window_new (MetaDisplay *display,
window->disable_sync = FALSE;
window->attached = FALSE;
window->frame_bounds = NULL;
+ window->opaque_region = NULL;
window->unmaps_pending = 0;
@@ -1274,6 +1275,9 @@ meta_window_free (MetaWindow *window,
if (window->frame_bounds)
cairo_region_destroy (window->frame_bounds);
+ if (window->opaque_region)
+ cairo_region_destroy (window->opaque_region);
+
meta_icon_cache_free (&window->icon_cache);
g_free (window->sm_client_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]