[metacity] window: change shape_region type to XserverRegion
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] window: change shape_region type to XserverRegion
- Date: Sun, 13 Oct 2019 18:49:37 +0000 (UTC)
commit a412fda9c8865be32d804ea4f4d9a48d952fe4e5
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Oct 13 21:42:06 2019 +0300
window: change shape_region type to XserverRegion
src/compositor/meta-compositor-xrender.c | 6 ++--
src/core/window-private.h | 5 ++--
src/core/window.c | 48 ++++++++++++++++----------------
3 files changed, 30 insertions(+), 29 deletions(-)
---
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c
index 09b6fbb3..5f2d19ff 100644
--- a/src/compositor/meta-compositor-xrender.c
+++ b/src/compositor/meta-compositor-xrender.c
@@ -936,7 +936,7 @@ window_has_shadow (MetaCompositorXRender *xrender,
}
/* Never put a shadow around shaped windows */
- if (cw->window->shape_region != NULL)
+ if (cw->window->shape_region != None)
{
meta_verbose ("Window has no shadow as it is shaped\n");
return FALSE;
@@ -1055,7 +1055,7 @@ get_window_region (MetaDisplay *display,
XFixesTranslateRegion (xdisplay, region, cw->rect.x, cw->rect.y);
- if (cw->window->shape_region != NULL)
+ if (cw->window->shape_region != None)
{
XserverRegion tmp;
@@ -2309,7 +2309,7 @@ meta_compositor_xrender_sync_window_geometry (MetaCompositor *compositor,
if (xrender->debug)
{
fprintf (stderr, "configure notify %d %d %d\n", cw->damaged,
- cw->window->shape_region != NULL, cw->needs_shadow);
+ cw->window->shape_region != None, cw->needs_shadow);
dump_xserver_region (xrender, "\textents", cw->extents);
fprintf (stderr, "\txy (%d %d), wh (%d %d)\n",
cw->rect.x, cw->rect.y, cw->rect.width, cw->rect.height);
diff --git a/src/core/window-private.h b/src/core/window-private.h
index cc99b7a1..dfb67633 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -39,6 +39,7 @@
#include "stack.h"
#include "iconcache.h"
#include <X11/Xutil.h>
+#include <X11/extensions/Xfixes.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -347,8 +348,8 @@ struct _MetaWindow
/* if non-NULL, the bounds of the window frame */
cairo_region_t *frame_bounds;
- /* if non-NULL, the bounding shape region of the window */
- cairo_region_t *shape_region;
+ /* if non-None, the bounding shape region of the window */
+ XserverRegion shape_region;
/* if non-NULL, the opaque region _NET_WM_OPAQUE_REGION */
cairo_region_t *opaque_region;
diff --git a/src/core/window.c b/src/core/window.c
index b7c6bfa0..c632d14b 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -523,7 +523,7 @@ meta_window_new (MetaDisplay *display,
window->disable_sync = FALSE;
window->attached = FALSE;
window->frame_bounds = NULL;
- window->shape_region = NULL;
+ window->shape_region = None;
window->opaque_region = NULL;
window->opacity = 0xffffffff;
@@ -9162,7 +9162,8 @@ meta_window_is_toplevel_mapped (MetaWindow *window)
void
meta_window_update_shape_region (MetaWindow *window)
{
- cairo_region_t *shape_region;
+ Display *xdisplay;
+ XserverRegion shape_region;
int bshaped;
int xbs;
int ybs;
@@ -9174,9 +9175,13 @@ meta_window_update_shape_region (MetaWindow *window)
unsigned int wcs;
unsigned int hcs;
- if (!window->display->have_shape)
+ if (!window->display->have_shape ||
+ !window->display->have_xfixes)
return;
+ xdisplay = window->display->xdisplay;
+ shape_region = None;
+
meta_error_trap_push (window->display);
XShapeQueryExtents (window->display->xdisplay, window->xwindow,
@@ -9196,40 +9201,27 @@ meta_window_update_shape_region (MetaWindow *window)
if (rects)
{
- cairo_rectangle_int_t cairo_rects[n_rects];
- int i;
-
- for (i = 0; i < n_rects; i ++)
- {
- cairo_rects[i].x = rects[i].x;
- cairo_rects[i].y = rects[i].y;
- cairo_rects[i].width = rects[i].width;
- cairo_rects[i].height = rects[i].height;
- }
-
- shape_region = cairo_region_create_rectangles (cairo_rects, n_rects);
+ shape_region = XFixesCreateRegion (xdisplay, rects, n_rects);
XFree (rects);
}
- else
- {
- shape_region = NULL;
- }
}
else
{
window->has_shape = FALSE;
- shape_region = NULL;
}
meta_error_trap_pop (window->display);
- if (cairo_region_equal (window->shape_region, shape_region))
+ if (meta_xserver_region_equal (xdisplay, window->shape_region, shape_region))
{
- cairo_region_destroy (shape_region);
+ if (shape_region != None)
+ XFixesDestroyRegion (xdisplay, shape_region);
+
return;
}
- g_clear_pointer (&window->shape_region, cairo_region_destroy);
+ if (window->shape_region != None)
+ XFixesDestroyRegion (xdisplay, window->shape_region);
window->shape_region = shape_region;
meta_compositor_window_shape_region_changed (window->display->compositor, window);
@@ -9257,8 +9249,10 @@ static void
meta_window_finalize (GObject *object)
{
MetaWindow *window;
+ Display *xdisplay;
window = META_WINDOW (object);
+ xdisplay = meta_display_get_xdisplay (window->display);
if (window->reframe_id != 0)
{
@@ -9270,7 +9264,13 @@ meta_window_finalize (GObject *object)
g_clear_object (&window->mini_icon);
g_clear_pointer (&window->frame_bounds, cairo_region_destroy);
- g_clear_pointer (&window->shape_region, cairo_region_destroy);
+
+ if (window->shape_region != None)
+ {
+ XFixesDestroyRegion (xdisplay, window->shape_region);
+ window->shape_region = None;
+ }
+
g_clear_pointer (&window->opaque_region, cairo_region_destroy);
meta_icon_cache_free (&window->icon_cache);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]