[mutter] wayland: Let the roles handle their windows being managed



commit f8878ac907307b335cdbc2389ee50c5b3d5ef1ad
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Dec 15 22:09:20 2015 +0800

    wayland: Let the roles handle their windows being managed
    
    Move xdg_shell specific code from generic Wayland code into the xdg
    shell code unit by letting the roles handle the corresponding
    MetaWindow being managed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=757623
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763431

 src/wayland/meta-wayland-surface.c   |   24 ++++++++++++++++++++++++
 src/wayland/meta-wayland-surface.h   |    6 ++++++
 src/wayland/meta-wayland-wl-shell.c  |    7 +++++++
 src/wayland/meta-wayland-xdg-shell.c |   24 ++++++++++++++++++++++++
 src/wayland/meta-window-wayland.c    |   10 +---------
 5 files changed, 62 insertions(+), 9 deletions(-)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index b984671..5d1035a 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -149,6 +149,10 @@ meta_wayland_surface_role_shell_surface_close (MetaWaylandSurfaceRoleShellSurfac
 static void
 meta_wayland_surface_role_shell_surface_popup_done (MetaWaylandSurfaceRoleShellSurface *shell_surface_role);
 
+static void
+meta_wayland_surface_role_shell_surface_managed (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
+                                                 MetaWindow                         *window);
+
 gboolean
 meta_wayland_surface_assign_role (MetaWaylandSurface *surface,
                                   GType               role_type)
@@ -1727,6 +1731,16 @@ meta_wayland_surface_popup_done (MetaWaylandSurface *surface)
 }
 
 void
+meta_wayland_surface_window_managed (MetaWaylandSurface *surface,
+                                     MetaWindow         *window)
+{
+  MetaWaylandSurfaceRoleShellSurface *shell_surface_role =
+    META_WAYLAND_SURFACE_ROLE_SHELL_SURFACE (surface->role);
+
+  meta_wayland_surface_role_shell_surface_managed (shell_surface_role, window);
+}
+
+void
 meta_wayland_surface_drag_dest_focus_in (MetaWaylandSurface   *surface,
                                          MetaWaylandDataOffer *offer)
 {
@@ -1939,6 +1953,16 @@ meta_wayland_surface_role_shell_surface_popup_done (MetaWaylandSurfaceRoleShellS
   shell_surface_role_class->popup_done (shell_surface_role);
 }
 
+static void
+meta_wayland_surface_role_shell_surface_managed (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
+                                                 MetaWindow                         *window)
+{
+  MetaWaylandSurfaceRoleShellSurfaceClass *shell_surface_role_class =
+    META_WAYLAND_SURFACE_ROLE_SHELL_SURFACE_GET_CLASS (shell_surface_role);
+
+  shell_surface_role_class->managed (shell_surface_role, window);
+}
+
 void
 meta_wayland_surface_queue_pending_frame_callbacks (MetaWaylandSurface *surface)
 {
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index 190ee1f..920949e 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -94,6 +94,8 @@ struct _MetaWaylandSurfaceRoleShellSurfaceClass
                      int                                 new_width,
                      int                                 new_height,
                      MetaWaylandSerial                  *sent_serial);
+  void (*managed) (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
+                   MetaWindow                         *window);
   void (*ping) (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
                 uint32_t                            serial);
   void (*close) (MetaWaylandSurfaceRoleShellSurface *shell_surface_role);
@@ -348,4 +350,8 @@ gboolean            meta_wayland_surface_begin_grab_op (MetaWaylandSurface *surf
                                                         MetaGrabOp          grab_op,
                                                         gfloat              x,
                                                         gfloat              y);
+
+void                meta_wayland_surface_window_managed (MetaWaylandSurface *surface,
+                                                         MetaWindow         *window);
+
 #endif
diff --git a/src/wayland/meta-wayland-wl-shell.c b/src/wayland/meta-wayland-wl-shell.c
index 6933ebb..7a34909 100644
--- a/src/wayland/meta-wayland-wl-shell.c
+++ b/src/wayland/meta-wayland-wl-shell.c
@@ -529,6 +529,12 @@ wl_shell_surface_role_configure (MetaWaylandSurfaceRoleShellSurface *shell_surfa
 }
 
 static void
+wl_shell_surface_role_managed (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
+                               MetaWindow                         *window)
+{
+}
+
+static void
 wl_shell_surface_role_ping (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
                             guint32                             serial)
 {
@@ -574,6 +580,7 @@ meta_wayland_surface_role_wl_shell_surface_class_init (MetaWaylandSurfaceRoleWlS
   shell_surface_role_class =
     META_WAYLAND_SURFACE_ROLE_SHELL_SURFACE_CLASS (klass);
   shell_surface_role_class->configure = wl_shell_surface_role_configure;
+  shell_surface_role_class->managed = wl_shell_surface_role_managed;
   shell_surface_role_class->ping = wl_shell_surface_role_ping;
   shell_surface_role_class->close = wl_shell_surface_role_close;
   shell_surface_role_class->popup_done = wl_shell_surface_role_popup_done;
diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c
index cf1c7c7..94b488a 100644
--- a/src/wayland/meta-wayland-xdg-shell.c
+++ b/src/wayland/meta-wayland-xdg-shell.c
@@ -626,6 +626,12 @@ xdg_surface_role_configure (MetaWaylandSurfaceRoleShellSurface *shell_surface_ro
 }
 
 static void
+xdg_surface_role_managed (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
+                          MetaWindow                         *window)
+{
+}
+
+static void
 xdg_surface_role_ping (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
                        uint32_t                            serial)
 {
@@ -665,6 +671,7 @@ meta_wayland_surface_role_xdg_surface_class_init (MetaWaylandSurfaceRoleXdgSurfa
     META_WAYLAND_SURFACE_ROLE_SHELL_SURFACE_CLASS (klass);
 
   shell_surface_role_class->configure = xdg_surface_role_configure;
+  shell_surface_role_class->managed = xdg_surface_role_managed;
   shell_surface_role_class->ping = xdg_surface_role_ping;
   shell_surface_role_class->close = xdg_surface_role_close;
 }
@@ -705,6 +712,22 @@ xdg_popup_role_configure (MetaWaylandSurfaceRoleShellSurface *shell_surface_role
 }
 
 static void
+xdg_popup_role_managed (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
+                        MetaWindow                         *window)
+{
+  MetaWaylandSurfaceRole *surface_role =
+    META_WAYLAND_SURFACE_ROLE (shell_surface_role);
+  MetaWaylandSurface *surface =
+    meta_wayland_surface_role_get_surface (surface_role);
+  MetaWaylandSurface *parent = surface->popup.parent;
+
+  g_assert (parent);
+
+  meta_window_set_transient_for (window, parent->window);
+  meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU);
+}
+
+static void
 xdg_popup_role_ping (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
                 uint32_t                            serial)
 {
@@ -744,6 +767,7 @@ meta_wayland_surface_role_xdg_popup_class_init (MetaWaylandSurfaceRoleXdgPopupCl
     META_WAYLAND_SURFACE_ROLE_SHELL_SURFACE_CLASS (klass);
 
   shell_surface_role_class->configure = xdg_popup_role_configure;
+  shell_surface_role_class->managed = xdg_popup_role_managed;
   shell_surface_role_class->ping = xdg_popup_role_ping;
   shell_surface_role_class->popup_done = xdg_popup_role_popup_done;
 }
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index fb051a1..5b9b409 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -68,15 +68,7 @@ meta_window_wayland_manage (MetaWindow *window)
                                    0);
   }
 
-  if (META_IS_WAYLAND_SURFACE_ROLE_XDG_POPUP (window->surface->role))
-    {
-      MetaWaylandSurface *parent = window->surface->popup.parent;
-
-      g_assert (parent);
-
-      meta_window_set_transient_for (window, parent->window);
-      meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU);
-    }
+  meta_wayland_surface_window_managed (window->surface, window);
 }
 
 static void


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