[metacity] xrender: move overlay window to MetaCompositor
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] xrender: move overlay window to MetaCompositor
- Date: Wed, 15 Mar 2017 15:40:32 +0000 (UTC)
commit bd2f1660e7c0b5f9ff1a816a592ce07cfaa63861
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Wed Mar 15 17:31:15 2017 +0200
xrender: move overlay window to MetaCompositor
src/compositor/meta-compositor-private.h | 12 +++--
src/compositor/meta-compositor-xrender.c | 56 +-----------------------
src/compositor/meta-compositor.c | 69 ++++++++++++++++++++++++++++++
3 files changed, 78 insertions(+), 59 deletions(-)
---
diff --git a/src/compositor/meta-compositor-private.h b/src/compositor/meta-compositor-private.h
index eec2fc2..0f48511 100644
--- a/src/compositor/meta-compositor-private.h
+++ b/src/compositor/meta-compositor-private.h
@@ -74,13 +74,15 @@ struct _MetaCompositorClass
Window xwindow);
};
-gboolean meta_compositor_check_extensions (MetaCompositor *compositor,
- GError **error);
+gboolean meta_compositor_check_extensions (MetaCompositor *compositor,
+ GError **error);
-gboolean meta_compositor_set_selection (MetaCompositor *compositor,
- GError **error);
+gboolean meta_compositor_set_selection (MetaCompositor *compositor,
+ GError **error);
-MetaDisplay *meta_compositor_get_display (MetaCompositor *compositor);
+Window meta_compositor_get_overlay_window (MetaCompositor *compositor);
+
+MetaDisplay *meta_compositor_get_display (MetaCompositor *compositor);
G_END_DECLS
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c
index 4857531..474dbeb 100644
--- a/src/compositor/meta-compositor-xrender.c
+++ b/src/compositor/meta-compositor-xrender.c
@@ -2453,39 +2453,6 @@ update_shadows (MetaPreference pref,
}
static void
-show_overlay_window (MetaCompositorXRender *xrender,
- Display *xdisplay)
-{
- XserverRegion region;
-
- region = XFixesCreateRegion (xdisplay, NULL, 0);
-
- XFixesSetWindowShapeRegion (xdisplay, xrender->overlay_window,
- ShapeBounding, 0, 0, 0);
-
- XFixesSetWindowShapeRegion (xdisplay, xrender->overlay_window,
- ShapeInput, 0, 0, region);
-
- XFixesDestroyRegion (xdisplay, region);
-
- damage_screen (xrender);
-}
-
-static void
-hide_overlay_window (MetaCompositorXRender *xrender,
- Display *xdisplay)
-{
- XserverRegion region;
-
- region = XFixesCreateRegion (xdisplay, NULL, 0);
-
- XFixesSetWindowShapeRegion (xdisplay, xrender->overlay_window,
- ShapeBounding, 0, 0, region);
-
- XFixesDestroyRegion (xdisplay, region);
-}
-
-static void
meta_compositor_xrender_constructed (GObject *object)
{
MetaCompositor *compositor;
@@ -2521,8 +2488,6 @@ meta_compositor_xrender_finalize (GObject *object)
xrender->prefs_listener_added = FALSE;
}
- hide_overlay_window (xrender, xdisplay);
-
/* Destroy the windows */
for (index = xrender->windows; index; index = index->next)
{
@@ -2547,7 +2512,6 @@ meta_compositor_xrender_finalize (GObject *object)
}
XCompositeUnredirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
- XCompositeReleaseOverlayWindow (xdisplay, xrender->overlay_window);
G_OBJECT_CLASS (meta_compositor_xrender_parent_class)->finalize (object);
}
@@ -2576,14 +2540,6 @@ meta_compositor_xrender_manage (MetaCompositor *compositor,
return FALSE;
}
- if (!display->have_xfixes)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Missing xfixes extension required for compositing");
-
- return FALSE;
- }
-
if (!meta_compositor_set_selection (compositor, error))
return FALSE;
@@ -2613,8 +2569,7 @@ meta_compositor_xrender_manage (MetaCompositor *compositor,
return FALSE;
}
- xrender->overlay_window = XCompositeGetOverlayWindow (xdisplay, xroot);
- XSelectInput (xdisplay, xrender->overlay_window, ExposureMask);
+ xrender->overlay_window = meta_compositor_get_overlay_window (compositor);
pa.subwindow_mode = IncludeInferiors;
xrender->root_picture = XRenderCreatePicture (xdisplay,
@@ -2653,7 +2608,7 @@ meta_compositor_xrender_manage (MetaCompositor *compositor,
XClearArea (xdisplay, xrender->overlay_window, 0, 0, 0, 0, TRUE);
- show_overlay_window (xrender, xdisplay);
+ damage_screen (xrender);
meta_prefs_add_listener (update_shadows, xrender);
xrender->prefs_listener_added = TRUE;
@@ -3111,13 +3066,6 @@ static gboolean
meta_compositor_xrender_is_our_xwindow (MetaCompositor *compositor,
Window xwindow)
{
- MetaCompositorXRender *xrender;
-
- xrender = META_COMPOSITOR_XRENDER (compositor);
-
- if (xrender->overlay_window == xwindow)
- return TRUE;
-
return FALSE;
}
diff --git a/src/compositor/meta-compositor.c b/src/compositor/meta-compositor.c
index d64bf8e..4b8af1e 100644
--- a/src/compositor/meta-compositor.c
+++ b/src/compositor/meta-compositor.c
@@ -18,6 +18,10 @@
#include "config.h"
+#include <X11/extensions/shape.h>
+#include <X11/extensions/Xcomposite.h>
+#include <X11/extensions/Xfixes.h>
+
#include "display-private.h"
#include "meta-compositor-none.h"
#include "meta-compositor-xrender.h"
@@ -32,6 +36,9 @@ typedef struct
Atom cm_atom;
Window cm_window;
guint32 cm_timestamp;
+
+ /* XCompositeGetOverlayWindow */
+ Window overlay_window;
} MetaCompositorPrivate;
enum
@@ -83,6 +90,21 @@ meta_compositor_finalize (GObject *object)
priv = meta_compositor_get_instance_private (compositor);
xdisplay = priv->display->xdisplay;
+ if (priv->overlay_window != None)
+ {
+ Window overlay;
+ XserverRegion region;
+
+ overlay = priv->overlay_window;
+
+ region = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesSetWindowShapeRegion (xdisplay, overlay, ShapeBounding, 0, 0, region);
+ XFixesDestroyRegion (xdisplay, region);
+
+ XCompositeReleaseOverlayWindow (xdisplay, overlay);
+ priv->overlay_window = None;
+ }
+
if (priv->cm_window != None)
{
XSetSelectionOwner (xdisplay, priv->cm_atom, None, priv->cm_timestamp);
@@ -364,6 +386,9 @@ meta_compositor_is_our_xwindow (MetaCompositor *compositor,
if (priv->cm_window == xwindow)
return TRUE;
+ if (priv->overlay_window == xwindow)
+ return TRUE;
+
return compositor_class->is_our_xwindow (compositor, xwindow);
}
@@ -397,6 +422,14 @@ meta_compositor_check_extensions (MetaCompositor *compositor,
return FALSE;
}
+ if (!priv->display->have_xfixes)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Missing xfixes extension required for compositing");
+
+ return FALSE;
+ }
+
return TRUE;
}
@@ -434,6 +467,42 @@ meta_compositor_set_selection (MetaCompositor *compositor,
return TRUE;
}
+Window
+meta_compositor_get_overlay_window (MetaCompositor *compositor)
+{
+ MetaCompositorPrivate *priv;
+ Display *xdisplay;
+ Window xroot;
+ Window overlay;
+ XserverRegion region;
+
+ priv = meta_compositor_get_instance_private (compositor);
+
+ if (priv->overlay_window != None)
+ return priv->overlay_window;
+
+ xdisplay = priv->display->xdisplay;
+ xroot = DefaultRootWindow (xdisplay);
+
+ overlay = XCompositeGetOverlayWindow (xdisplay, xroot);
+
+ /* Get Expose events about window regions that have lost contents. */
+ XSelectInput (xdisplay, overlay, ExposureMask);
+
+ /* Make sure there isn't any left-over output shape on the overlay
+ * window by setting the whole screen to be an output region.
+ */
+ XFixesSetWindowShapeRegion (xdisplay, overlay, ShapeBounding, 0, 0, 0);
+
+ /* Allow events to pass through the overlay */
+ region = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesSetWindowShapeRegion (xdisplay, overlay, ShapeInput, 0, 0, region);
+ XFixesDestroyRegion (xdisplay, region);
+
+ priv->overlay_window = overlay;
+ return overlay;
+}
+
MetaDisplay *
meta_compositor_get_display (MetaCompositor *compositor)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]