[mutter/gbsneto/cleanup-x11-from-meta-window: 2/5] window: Delegate map and unmap to subclasses



commit 6be714ab2c5177fcfb8018a900705b64e75653ba
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Dec 22 18:58:18 2018 -0200

    window: Delegate map and unmap to subclasses
    
    As of now, the base class MetaWindow is calling into X11
    API when mapping and unmapping a window. Even on purely
    Wayland clients.
    
    Fix that by moving those calls to MetaWindow subclasses.
    On MetaWindowX11, it calls into X11 APIs, and the Wayland
    implementation is stub.

 src/core/window-private.h         |  2 ++
 src/core/window.c                 |  7 +++----
 src/wayland/meta-window-wayland.c | 12 ++++++++++++
 src/x11/window-x11.c              | 24 ++++++++++++++++++++++++
 4 files changed, 41 insertions(+), 4 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 8b1a15f7a..481229ea5 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -521,6 +521,8 @@ struct _MetaWindowClass
 
   void (*manage)                 (MetaWindow *window);
   void (*unmanage)               (MetaWindow *window);
+  void (*map)                    (MetaWindow *window);
+  void (*unmap)                  (MetaWindow *window);
   void (*ping)                   (MetaWindow *window,
                                   guint32     serial);
   void (*delete)                 (MetaWindow *window,
diff --git a/src/core/window.c b/src/core/window.c
index 5c0264a21..0f3c44352 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -769,6 +769,7 @@ client_window_should_be_mapped (MetaWindow *window)
 static void
 sync_client_window_mapped (MetaWindow *window)
 {
+  MetaWindowClass *window_class = META_WINDOW_GET_CLASS (window);
   gboolean should_be_mapped = client_window_should_be_mapped (window);
 
   g_return_if_fail (!window->override_redirect);
@@ -778,17 +779,15 @@ sync_client_window_mapped (MetaWindow *window)
 
   window->mapped = should_be_mapped;
 
-  meta_x11_error_trap_push (window->display->x11_display);
   if (should_be_mapped)
     {
-      XMapWindow (window->display->x11_display->xdisplay, window->xwindow);
+      window_class->map (window);
     }
   else
     {
-      XUnmapWindow (window->display->x11_display->xdisplay, window->xwindow);
+      window_class->unmap (window);
       window->unmaps_pending ++;
     }
-  meta_x11_error_trap_pop (window->display->x11_display);
 }
 
 static gboolean
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index dffee486d..3cd4c7f36 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -111,6 +111,16 @@ meta_window_wayland_unmanage (MetaWindow *window)
   meta_display_unregister_wayland_window (window->display, window);
 }
 
+static void
+meta_window_wayland_map (MetaWindow *window)
+{
+}
+
+static void
+meta_window_wayland_unmap (MetaWindow *window)
+{
+}
+
 static void
 meta_window_wayland_ping (MetaWindow *window,
                           guint32     serial)
@@ -606,6 +616,8 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
 
   window_class->manage = meta_window_wayland_manage;
   window_class->unmanage = meta_window_wayland_unmanage;
+  window_class->map = meta_window_wayland_map;
+  window_class->unmap = meta_window_wayland_unmap;
   window_class->ping = meta_window_wayland_ping;
   window_class->delete = meta_window_wayland_delete;
   window_class->kill = meta_window_wayland_kill;
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 839220d4f..9ec28703c 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -688,6 +688,28 @@ meta_window_x11_unmanage (MetaWindow *window)
     }
 }
 
+static void
+meta_window_x11_map (MetaWindow *window)
+{
+  meta_x11_error_trap_push (window->display->x11_display);
+
+  XMapWindow (window->display->x11_display->xdisplay,
+              window->xwindow);
+
+  meta_x11_error_trap_pop (window->display->x11_display);
+}
+
+static void
+meta_window_x11_unmap (MetaWindow *window)
+{
+  meta_x11_error_trap_push (window->display->x11_display);
+
+  XUnmapWindow (window->display->x11_display->xdisplay,
+                window->xwindow);
+
+  meta_x11_error_trap_pop (window->display->x11_display);
+}
+
 static void
 meta_window_x11_ping (MetaWindow *window,
                       guint32     serial)
@@ -1668,6 +1690,8 @@ meta_window_x11_class_init (MetaWindowX11Class *klass)
 
   window_class->manage = meta_window_x11_manage;
   window_class->unmanage = meta_window_x11_unmanage;
+  window_class->map = meta_window_x11_map;
+  window_class->unmap = meta_window_x11_unmap;
   window_class->ping = meta_window_x11_ping;
   window_class->delete = meta_window_x11_delete;
   window_class->kill = meta_window_x11_kill;


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