[metacity] compositor: pass MetaSurface to get_window_surface functions



commit 300755a802c866ccd93998ab0f3a71dd64cd381e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Oct 4 16:47:05 2019 +0300

    compositor: pass MetaSurface to get_window_surface functions

 src/compositor/meta-compositor-none.c    |  2 +-
 src/compositor/meta-compositor-private.h |  2 +-
 src/compositor/meta-compositor-vulkan.c  |  2 +-
 src/compositor/meta-compositor-xrender.c | 31 ++++++++++++++-----------------
 src/compositor/meta-compositor.c         |  9 ++++++++-
 5 files changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/src/compositor/meta-compositor-none.c b/src/compositor/meta-compositor-none.c
index e8fd3035..6659b4b1 100644
--- a/src/compositor/meta-compositor-none.c
+++ b/src/compositor/meta-compositor-none.c
@@ -94,7 +94,7 @@ meta_compositor_none_process_event (MetaCompositor *compositor,
 
 static cairo_surface_t *
 meta_compositor_none_get_window_surface (MetaCompositor *compositor,
-                                         MetaWindow     *window)
+                                         MetaSurface    *surface)
 {
   return NULL;
 }
diff --git a/src/compositor/meta-compositor-private.h b/src/compositor/meta-compositor-private.h
index ded9ce67..b5625e4a 100644
--- a/src/compositor/meta-compositor-private.h
+++ b/src/compositor/meta-compositor-private.h
@@ -64,7 +64,7 @@ struct _MetaCompositorClass
                                                       MetaWindow         *window);
 
   cairo_surface_t * (* get_window_surface)           (MetaCompositor     *compositor,
-                                                      MetaWindow         *window);
+                                                      MetaSurface        *surface);
 
   void              (* maximize_window)              (MetaCompositor     *compositor,
                                                       MetaWindow         *window);
diff --git a/src/compositor/meta-compositor-vulkan.c b/src/compositor/meta-compositor-vulkan.c
index 026998d0..2e2e794a 100644
--- a/src/compositor/meta-compositor-vulkan.c
+++ b/src/compositor/meta-compositor-vulkan.c
@@ -1329,7 +1329,7 @@ meta_compositor_vulkan_process_event (MetaCompositor *compositor,
 
 static cairo_surface_t *
 meta_compositor_vulkan_get_window_surface (MetaCompositor *compositor,
-                                           MetaWindow     *window)
+                                           MetaSurface    *surface)
 {
   return NULL;
 }
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c
index 4ca9df5e..4c125657 100644
--- a/src/compositor/meta-compositor-xrender.c
+++ b/src/compositor/meta-compositor-xrender.c
@@ -2024,8 +2024,9 @@ notify_decorated_cb (MetaWindow            *window,
 }
 
 static cairo_surface_t *
-get_window_surface (MetaCompWindow *cw)
+get_window_surface (MetaSurface *surface)
 {
+  MetaCompWindow *cw;
   MetaFrame *frame;
   MetaDisplay *display;
   Display *xdisplay;
@@ -2035,6 +2036,8 @@ get_window_surface (MetaCompWindow *cw)
   cairo_surface_t *window_surface;
   cairo_t *cr;
 
+  cw = g_object_get_data (G_OBJECT (surface), "cw");
+
   frame = meta_window_get_frame (cw->window);
   display = meta_window_get_display (cw->window);
   xdisplay = meta_display_get_xdisplay (display);
@@ -2121,16 +2124,13 @@ get_window_surface (MetaCompWindow *cw)
 }
 
 static void
-notify_shaded_cb (MetaWindow            *window,
-                  GParamSpec            *pspec,
-                  MetaCompositorXRender *xrender)
+notify_shaded_cb (MetaWindow  *window,
+                  GParamSpec  *pspec,
+                  MetaSurface *surface)
 {
   MetaCompWindow *cw;
 
-  cw = find_comp_window_by_window (xrender, window);
-
-  if (cw == NULL)
-    return;
+  cw = g_object_get_data (G_OBJECT (surface), "cw");
 
   if (cw->shaded_surface != NULL)
     {
@@ -2139,7 +2139,7 @@ notify_shaded_cb (MetaWindow            *window,
     }
 
   if (meta_window_is_shaded (cw->window))
-    cw->shaded_surface = get_window_surface (cw);
+    cw->shaded_surface = get_window_surface (surface);
 }
 
 /* event processors must all be called with an error trap in place */
@@ -2459,7 +2459,7 @@ meta_compositor_xrender_add_window (MetaCompositor *compositor,
 
   g_signal_connect_object (window, "notify::shaded",
                            G_CALLBACK (notify_shaded_cb),
-                           xrender, 0);
+                           surface, 0);
 
   cw->back_pixmap = None;
   cw->mask_pixmap = None;
@@ -2719,16 +2719,13 @@ meta_compositor_xrender_process_event (MetaCompositor *compositor,
 
 static cairo_surface_t *
 meta_compositor_xrender_get_window_surface (MetaCompositor *compositor,
-                                            MetaWindow     *window)
+                                            MetaSurface    *surface)
 {
   MetaCompWindow *cw;
 
-  cw = find_comp_window_by_window (META_COMPOSITOR_XRENDER (compositor), window);
+  cw = g_object_get_data (G_OBJECT (surface), "cw");
 
-  if (cw == NULL)
-    return NULL;
-
-  if (meta_window_is_shaded (window))
+  if (meta_window_is_shaded (cw->window))
     {
       if (cw->shaded_surface != NULL)
         return cairo_surface_reference (cw->shaded_surface);
@@ -2736,7 +2733,7 @@ meta_compositor_xrender_get_window_surface (MetaCompositor *compositor,
         return NULL;
     }
 
-  return get_window_surface (cw);
+  return get_window_surface (surface);
 }
 
 static void
diff --git a/src/compositor/meta-compositor.c b/src/compositor/meta-compositor.c
index a430d450..2606f316 100644
--- a/src/compositor/meta-compositor.c
+++ b/src/compositor/meta-compositor.c
@@ -476,11 +476,18 @@ cairo_surface_t *
 meta_compositor_get_window_surface (MetaCompositor *compositor,
                                     MetaWindow     *window)
 {
+  MetaCompositorPrivate *priv;
   MetaCompositorClass *compositor_class;
+  MetaSurface *surface;
 
+  priv = meta_compositor_get_instance_private (compositor);
   compositor_class = META_COMPOSITOR_GET_CLASS (compositor);
 
-  return compositor_class->get_window_surface (compositor, window);
+  surface = g_hash_table_lookup (priv->surfaces, window);
+  if (surface == NULL)
+    return NULL;
+
+  return compositor_class->get_window_surface (compositor, surface);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]