[mutter/bilelmoussaoui/untangle-window: 2/2] window: Move surface property to it subclasses




commit 8ca5c1f27541f0c46efff7a4d0c03cdfca9f0d1f
Author: Bilal Elmoussaoui <belmouss redhat com>
Date:   Wed May 18 13:51:44 2022 +0200

    window: Move surface property to it subclasses
    
    As we have specific window types per display server,
    having it in the parent class makes building without wayland
    harder to achieve

 src/compositor/meta-window-actor.c             | 29 ++++++--
 src/core/display.c                             | 18 ++++-
 src/core/window-private.h                      |  1 -
 src/core/window.c                              | 36 +++++-----
 src/wayland/meta-wayland-client.c              |  5 +-
 src/wayland/meta-wayland-pointer-constraints.c |  4 +-
 src/wayland/meta-wayland.c                     | 15 +++-
 src/wayland/meta-window-wayland.c              | 98 +++++++++++++++++++-------
 src/wayland/meta-window-wayland.h              | 21 ++++++
 src/wayland/meta-window-xwayland.c             | 23 +++---
 src/wayland/meta-window-xwayland.h             | 10 +++
 src/wayland/meta-xwayland-dnd.c                |  6 +-
 src/wayland/meta-xwayland-surface.c            | 13 ++--
 13 files changed, 207 insertions(+), 72 deletions(-)
---
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index ae1fa4d903..eef0c18590 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -38,9 +38,14 @@
 
 #ifdef HAVE_WAYLAND
 #include "compositor/meta-surface-actor-wayland.h"
+#include "wayland/meta-window-wayland.h"
 #include "wayland/meta-wayland-surface.h"
 #endif
 
+#ifdef HAVE_XWAYLAND
+#include "wayland/meta-window-xwayland.h"
+#endif
+
 typedef enum
 {
   INITIALLY_FROZEN,
@@ -387,16 +392,28 @@ init_surface_actor (MetaWindowActor *self)
   MetaWindowActorPrivate *priv =
     meta_window_actor_get_instance_private (self);
   MetaWindow *window = priv->window;
-  MetaSurfaceActor *surface_actor;
-
+  MetaSurfaceActor *surface_actor = NULL;
   if (!meta_is_wayland_compositor ())
     surface_actor = meta_surface_actor_x11_new (window);
+  else
+    {
+#ifdef HAVE_XWAYLAND
+      if (G_TYPE_CHECK_INSTANCE_TYPE (window, META_TYPE_WINDOW_XWAYLAND))
+        {
+          MetaWindowXwayland *wl_window = META_WINDOW_XWAYLAND (window);
+          if (wl_window->surface)
+            surface_actor = meta_wayland_surface_get_actor (wl_window->surface);
+        }
+#endif
 #ifdef HAVE_WAYLAND
-  else if (window->surface)
-    surface_actor = meta_wayland_surface_get_actor (window->surface);
+      if (G_TYPE_CHECK_INSTANCE_TYPE (window, META_TYPE_WINDOW_WAYLAND))
+        {
+          MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+          if (wl_window->surface)
+            surface_actor = meta_wayland_surface_get_actor (wl_window->surface);
+        }
 #endif
-  else
-    surface_actor = NULL;
+    }
 
   if (surface_actor)
     meta_window_actor_assign_surface_actor (self, surface_actor);
diff --git a/src/core/display.c b/src/core/display.c
index 14b3903469..42549c5739 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -81,11 +81,16 @@
 #ifdef HAVE_WAYLAND
 #include "compositor/meta-compositor-native.h"
 #include "compositor/meta-compositor-server.h"
+#include "wayland/meta-window-wayland.h"
 #include "wayland/meta-xwayland-private.h"
 #include "wayland/meta-wayland-tablet-seat.h"
 #include "wayland/meta-wayland-tablet-pad.h"
 #endif
 
+#ifdef HAVE_XWAYLAND
+#include "wayland/meta-window-xwayland.h"
+#endif
+
 #ifdef HAVE_NATIVE_BACKEND
 #include "backends/native/meta-backend-native.h"
 #endif
@@ -1438,8 +1443,17 @@ meta_display_sync_wayland_input_focus (MetaDisplay *display)
     focus_window = NULL;
   else if (clutter_stage_get_grab_actor (CLUTTER_STAGE (stage)))
     focus_window = NULL;
-  else if (display->focus_window && display->focus_window->surface)
-    focus_window = display->focus_window;
+  else if (display->focus_window)
+    if (display->focus_window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
+      {
+        MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (display->focus_window);
+        focus_window = wl_window->surface ? focus_window : NULL;
+      }
+    else
+      {
+        MetaWindowXwayland *wl_window = META_WINDOW_XWAYLAND (display->focus_window);
+        focus_window = wl_window->surface ? focus_window : NULL;
+      }
   else
     meta_topic (META_DEBUG_FOCUS, "Focus change has no effect, because there is no matching wayland 
surface");
 
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 86986f6903..e909834015 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -169,7 +169,6 @@ struct _MetaWindow
   MetaLogicalMonitor *monitor;
   MetaWorkspace *workspace;
   MetaWindowClientType client_type;
-  MetaWaylandSurface *surface;
   Window xwindow;
   /* may be NULL! not all windows get decorated */
   MetaFrame *frame;
diff --git a/src/core/window.c b/src/core/window.c
index 0bfbd42840..81383363e6 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -205,7 +205,6 @@ enum
   PROP_IS_ALIVE,
   PROP_DISPLAY,
   PROP_EFFECT,
-  PROP_SURFACE,
   PROP_XWINDOW,
 
   PROP_LAST,
@@ -426,9 +425,6 @@ meta_window_get_property(GObject         *object,
     case PROP_EFFECT:
       g_value_set_int (value, win->pending_compositor_effect);
       break;
-    case PROP_SURFACE:
-      g_value_set_pointer (value, win->surface);
-      break;
     case PROP_XWINDOW:
       g_value_set_ulong (value, win->xwindow);
       break;
@@ -454,9 +450,6 @@ meta_window_set_property(GObject         *object,
     case PROP_EFFECT:
       win->pending_compositor_effect = g_value_get_int (value);
       break;
-    case PROP_SURFACE:
-      win->surface = g_value_get_pointer (value);
-      break;
     case PROP_XWINDOW:
       win->xwindow = g_value_get_ulong (value);
       break;
@@ -543,9 +536,12 @@ static gboolean
 client_window_should_be_mapped (MetaWindow *window)
 {
 #ifdef HAVE_WAYLAND
-  if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND &&
-      !meta_wayland_surface_get_buffer (window->surface))
-    return FALSE;
+  if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
+    {
+      MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+      if (!meta_wayland_surface_get_buffer (wl_window->surface))
+        return FALSE;
+    }
 #endif
 
   return !window->shaded;
@@ -1298,12 +1294,6 @@ meta_window_class_init (MetaWindowClass *klass)
                       META_COMP_EFFECT_NONE,
                       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
 
-  obj_props[PROP_SURFACE] =
-    g_param_spec_pointer ("surface",
-                          "Surface",
-                          "The corresponding Wayland surface",
-                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE);
-
   obj_props[PROP_XWINDOW] =
     g_param_spec_ulong ("xwindow",
                         "X Window",
@@ -1704,9 +1694,12 @@ meta_window_should_be_showing (MetaWindow  *window)
   MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
 
 #ifdef HAVE_WAYLAND
-  if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND &&
-      !meta_wayland_surface_get_buffer (window->surface))
-    return FALSE;
+  if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
+    {
+      MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+      if (!meta_wayland_surface_get_buffer (wl_window->surface))
+        return FALSE;
+    }
 #endif
 
   /* Windows should be showing if they're located on the
@@ -4472,7 +4465,10 @@ meta_window_transient_can_focus (MetaWindow *window)
 {
 #ifdef HAVE_WAYLAND
   if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
-    return meta_wayland_surface_get_buffer (window->surface) != NULL;
+    {
+      MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+      return meta_wayland_surface_get_buffer (wl_window->surface) != NULL;
+    }
 #endif
 
   return TRUE;
diff --git a/src/wayland/meta-wayland-client.c b/src/wayland/meta-wayland-client.c
index 69c7b83335..cef52da5f7 100644
--- a/src/wayland/meta-wayland-client.c
+++ b/src/wayland/meta-wayland-client.c
@@ -41,6 +41,7 @@
 #include "meta/util.h"
 #include "wayland/meta-wayland-private.h"
 #include "wayland/meta-wayland-types.h"
+#include "wayland/meta-window-wayland.h"
 
 struct _MetaWaylandClient
 {
@@ -291,12 +292,14 @@ meta_wayland_client_owns_window (MetaWaylandClient *client,
                                  MetaWindow        *window)
 {
   MetaWaylandSurface *surface;
+  MetaWindowWayland *wl_window;
 
   g_return_val_if_fail (meta_is_wayland_compositor (), FALSE);
   g_return_val_if_fail (client->subprocess != NULL, FALSE);
   g_return_val_if_fail (client->process_running, FALSE);
 
-  surface = window->surface;
+  wl_window = META_WINDOW_WAYLAND (window);
+  surface = wl_window->surface;
   if (surface == NULL)
     return FALSE;
 
diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c
index 965b95ddad..194ebb9da4 100644
--- a/src/wayland/meta-wayland-pointer-constraints.c
+++ b/src/wayland/meta-wayland-pointer-constraints.c
@@ -40,6 +40,7 @@
 #include "wayland/meta-wayland-region.h"
 #include "wayland/meta-wayland-seat.h"
 #include "wayland/meta-wayland-surface.h"
+#include "wayland/meta-window-wayland.h"
 #include "wayland/meta-xwayland.h"
 
 #include "pointer-constraints-unstable-v1-server-protocol.h"
@@ -574,7 +575,8 @@ meta_wayland_pointer_constraint_maybe_remove_for_seat (MetaWaylandSeat *seat,
 static void
 meta_wayland_pointer_constraint_maybe_enable_for_window (MetaWindow *window)
 {
-  MetaWaylandSurface *surface = window->surface;
+  MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+  MetaWaylandSurface *surface = wl_window->surface;
   MetaWaylandSurfacePointerConstraintsData *surface_data;
   GList *l;
 
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index afea5e875c..3d88377ed8 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -47,6 +47,8 @@
 #include "wayland/meta-wayland-subsurface.h"
 #include "wayland/meta-wayland-tablet-manager.h"
 #include "wayland/meta-wayland-xdg-foreign.h"
+#include "wayland/meta-window-wayland.h"
+#include "wayland/meta-window-xwayland.h"
 #include "wayland/meta-xwayland-grab-keyboard.h"
 #include "wayland/meta-xwayland-private.h"
 #include "wayland/meta-xwayland.h"
@@ -143,7 +145,18 @@ void
 meta_wayland_compositor_set_input_focus (MetaWaylandCompositor *compositor,
                                          MetaWindow            *window)
 {
-  MetaWaylandSurface *surface = window ? window->surface : NULL;
+  MetaWaylandSurface *surface = NULL;
+
+  if (meta_is_wayland_compositor ())
+    {
+      MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+      surface = wl_window ? wl_window->surface : NULL;
+    }
+  else
+    {
+      MetaWindowXwayland *wl_window = META_WINDOW_XWAYLAND (window);
+      surface = wl_window ? wl_window->surface : NULL;
+    }
 
   meta_wayland_seat_set_input_focus (compositor->seat, surface);
 }
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index 4138b44f40..31b9031229 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -44,25 +44,17 @@
 #include "wayland/meta-wayland-window-configuration.h"
 #include "wayland/meta-wayland-xdg-shell.h"
 
-struct _MetaWindowWayland
+enum
 {
-  MetaWindow parent;
+  PROP_0,
 
-  int geometry_scale;
-
-  GList *pending_configurations;
-  gboolean has_pending_state_change;
-
-  gboolean has_last_sent_configuration;
-  MetaRectangle last_sent_rect;
-  int last_sent_rel_x;
-  int last_sent_rel_y;
-  int last_sent_geometry_scale;
-  MetaGravity last_sent_gravity;
+  PROP_SURFACE,
 
-  gboolean has_been_shown;
+  PROP_LAST
 };
 
+static GParamSpec *obj_props[PROP_LAST];
+
 struct _MetaWindowWaylandClass
 {
   MetaWindowClass parent_class;
@@ -110,7 +102,7 @@ meta_window_wayland_manage (MetaWindow *window)
                                    0);
   }
 
-  meta_wayland_surface_window_managed (window->surface, window);
+  meta_wayland_surface_window_managed (wl_window->surface, window);
 }
 
 static void
@@ -129,20 +121,23 @@ static void
 meta_window_wayland_ping (MetaWindow *window,
                           guint32     serial)
 {
-  meta_wayland_surface_ping (window->surface, serial);
+  MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+  meta_wayland_surface_ping (wl_window->surface, serial);
 }
 
 static void
 meta_window_wayland_delete (MetaWindow *window,
                             guint32     timestamp)
 {
-  meta_wayland_surface_delete (window->surface);
+  MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+  meta_wayland_surface_delete (wl_window->surface);
 }
 
 static void
 meta_window_wayland_kill (MetaWindow *window)
 {
-  MetaWaylandSurface *surface = window->surface;
+  MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+  MetaWaylandSurface *surface = wl_window->surface;
   struct wl_resource *resource = surface->resource;
 
   /* Send the client an unrecoverable error to kill the client. */
@@ -168,9 +163,7 @@ static void
 meta_window_wayland_configure (MetaWindowWayland              *wl_window,
                                MetaWaylandWindowConfiguration *configuration)
 {
-  MetaWindow *window = META_WINDOW (wl_window);
-
-  meta_wayland_surface_configure_notify (window->surface, configuration);
+  meta_wayland_surface_configure_notify (wl_window->surface, configuration);
 
   wl_window->pending_configurations =
     g_list_prepend (wl_window->pending_configurations, configuration);
@@ -358,7 +351,7 @@ meta_window_wayland_move_resize_internal (MetaWindow                *window,
           int bounds_width;
           int bounds_height;
 
-          if (!meta_wayland_surface_get_buffer (window->surface) &&
+          if (!meta_wayland_surface_get_buffer (wl_window->surface) &&
               !META_WINDOW_MAXIMIZED (window) &&
               window->tile_mode == META_TILE_NONE &&
               !meta_window_is_fullscreen (window))
@@ -469,6 +462,7 @@ meta_window_wayland_update_main_monitor (MetaWindow                   *window,
   MetaBackend *backend = meta_get_backend ();
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
+  MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
   MetaWindow *toplevel_window;
   MetaLogicalMonitor *from;
   MetaLogicalMonitor *to;
@@ -481,7 +475,7 @@ meta_window_wayland_update_main_monitor (MetaWindow                   *window,
 
   /* If the window is not a toplevel window (i.e. it's a popup window) just use
    * the monitor of the toplevel. */
-  toplevel_window = meta_wayland_surface_get_toplevel_window (window->surface);
+  toplevel_window = meta_wayland_surface_get_toplevel_window (wl_window->surface);
   if (toplevel_window != window)
     {
       meta_window_update_monitor (toplevel_window, flags);
@@ -599,7 +593,7 @@ meta_window_wayland_main_monitor_changed (MetaWindow               *window,
                                         window,
                                         TRUE);
 
-  surface = window->surface;
+  surface = wl_window->surface;
   if (surface)
     {
       MetaWaylandActorSurface *actor_surface =
@@ -615,7 +609,8 @@ meta_window_wayland_main_monitor_changed (MetaWindow               *window,
 static pid_t
 meta_window_wayland_get_client_pid (MetaWindow *window)
 {
-  MetaWaylandSurface *surface = window->surface;
+  MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+  MetaWaylandSurface *surface = wl_window->surface;
   struct wl_resource *resource = surface->resource;
   pid_t pid;
 
@@ -695,7 +690,8 @@ meta_window_wayland_can_ping (MetaWindow *window)
 static gboolean
 meta_window_wayland_is_stackable (MetaWindow *window)
 {
-  return meta_wayland_surface_get_buffer (window->surface) != NULL;
+  MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
+  return meta_wayland_surface_get_buffer (wl_window->surface) != NULL;
 }
 
 static gboolean
@@ -766,6 +762,45 @@ meta_window_wayland_finalize (GObject *object)
   G_OBJECT_CLASS (meta_window_wayland_parent_class)->finalize (object);
 }
 
+
+static void
+meta_window_wayland_get_property (GObject    *object,
+                                  guint       prop_id,
+                                  GValue     *value,
+                                  GParamSpec *pspec)
+{
+  MetaWindowWayland *window = META_WINDOW_WAYLAND (object);
+
+  switch (prop_id)
+    {
+    case PROP_SURFACE:
+      g_value_set_object (value, window->surface);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+meta_window_wayland_set_property (GObject      *object,
+                                  guint         prop_id,
+                                  const GValue *value,
+                                  GParamSpec   *pspec)
+{
+  MetaWindowWayland *window = META_WINDOW_WAYLAND (object);
+
+  switch (prop_id)
+    {
+    case PROP_SURFACE:
+      window->surface = g_value_get_object (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
 static void
 meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
 {
@@ -773,6 +808,8 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
   MetaWindowClass *window_class = META_WINDOW_CLASS (klass);
 
   object_class->finalize = meta_window_wayland_finalize;
+  object_class->get_property = meta_window_wayland_get_property;
+  object_class->set_property = meta_window_wayland_set_property;
   object_class->constructed = meta_window_wayland_constructed;
 
   window_class->manage = meta_window_wayland_manage;
@@ -797,6 +834,15 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
   window_class->map = meta_window_wayland_map;
   window_class->unmap = meta_window_wayland_unmap;
   window_class->is_focus_async = meta_window_wayland_is_focus_async;
+
+  obj_props[PROP_SURFACE] =
+    g_param_spec_object ("surface",
+                         "Surface",
+                         "The corresponding Wayland surface",
+                         META_TYPE_WAYLAND_SURFACE,
+                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+  g_object_class_install_properties (object_class, PROP_LAST, obj_props);
 }
 
 MetaWindow *
diff --git a/src/wayland/meta-window-wayland.h b/src/wayland/meta-window-wayland.h
index 154e9a6f21..1c0757c5a8 100644
--- a/src/wayland/meta-window-wayland.h
+++ b/src/wayland/meta-window-wayland.h
@@ -36,6 +36,27 @@ G_DECLARE_FINAL_TYPE (MetaWindowWayland, meta_window_wayland,
                       META, WINDOW_WAYLAND,
                       MetaWindow)
 
+struct _MetaWindowWayland
+{
+  MetaWindow parent;
+
+  int geometry_scale;
+
+  MetaWaylandSurface *surface;
+
+  GList *pending_configurations;
+  gboolean has_pending_state_change;
+
+  gboolean has_last_sent_configuration;
+  MetaRectangle last_sent_rect;
+  int last_sent_rel_x;
+  int last_sent_rel_y;
+  int last_sent_geometry_scale;
+  MetaGravity last_sent_gravity;
+
+  gboolean has_been_shown;
+};
+
 MetaWindow * meta_window_wayland_new       (MetaDisplay        *display,
                                             MetaWaylandSurface *surface);
 
diff --git a/src/wayland/meta-window-xwayland.c b/src/wayland/meta-window-xwayland.c
index 54ccc91fe4..25608c3624 100644
--- a/src/wayland/meta-window-xwayland.c
+++ b/src/wayland/meta-window-xwayland.c
@@ -27,26 +27,20 @@
 #include "x11/xprops.h"
 #include "wayland/meta-window-xwayland.h"
 #include "wayland/meta-wayland.h"
+#include "wayland/meta-wayland-surface.h"
 
 enum
 {
   PROP_0,
 
   PROP_XWAYLAND_MAY_GRAB_KEYBOARD,
+  PROP_SURFACE,
 
   PROP_LAST
 };
 
 static GParamSpec *obj_props[PROP_LAST];
 
-struct _MetaWindowXwayland
-{
-  MetaWindowX11 parent;
-
-  gboolean xwayland_may_grab_keyboard;
-  int freeze_count;
-};
-
 struct _MetaWindowXwaylandClass
 {
   MetaWindowX11Class parent_class;
@@ -251,6 +245,9 @@ meta_window_xwayland_get_property (GObject    *object,
     case PROP_XWAYLAND_MAY_GRAB_KEYBOARD:
       g_value_set_boolean (value, window->xwayland_may_grab_keyboard);
       break;
+    case PROP_SURFACE:
+      g_value_set_object (value, window->surface);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -270,6 +267,9 @@ meta_window_xwayland_set_property (GObject      *object,
     case PROP_XWAYLAND_MAY_GRAB_KEYBOARD:
       window->xwayland_may_grab_keyboard = g_value_get_boolean (value);
       break;
+    case PROP_SURFACE:
+      window->surface = g_value_get_object (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -301,5 +301,12 @@ meta_window_xwayland_class_init (MetaWindowXwaylandClass *klass)
                           FALSE,
                           G_PARAM_READWRITE);
 
+  obj_props[PROP_SURFACE] =
+    g_param_spec_object ("surface",
+                         "Surface",
+                         "The corresponding Wayland surface",
+                         META_TYPE_WAYLAND_SURFACE,
+                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
   g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
 }
diff --git a/src/wayland/meta-window-xwayland.h b/src/wayland/meta-window-xwayland.h
index 5ea6041d44..e07ef77099 100644
--- a/src/wayland/meta-window-xwayland.h
+++ b/src/wayland/meta-window-xwayland.h
@@ -29,6 +29,16 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (MetaWindowXwayland, meta_window_xwayland,
                       META, WINDOW_XWAYLAND, MetaWindowX11)
 
+struct _MetaWindowXwayland
+{
+  MetaWindowX11 parent;
+
+  MetaWaylandSurface *surface;
+
+  gboolean xwayland_may_grab_keyboard;
+  int freeze_count;
+};
+
 G_END_DECLS
 
 #endif
diff --git a/src/wayland/meta-xwayland-dnd.c b/src/wayland/meta-xwayland-dnd.c
index 0aa4c5efba..a3c923c33e 100644
--- a/src/wayland/meta-xwayland-dnd.c
+++ b/src/wayland/meta-xwayland-dnd.c
@@ -37,6 +37,7 @@
 #include "core/meta-workspace-manager-private.h"
 #include "meta/meta-x11-errors.h"
 #include "wayland/meta-wayland-data-device.h"
+#include "wayland/meta-window-xwayland.h"
 #include "wayland/meta-xwayland-private.h"
 #include "wayland/meta-xwayland-dnd-private.h"
 #include "wayland/meta-xwayland.h"
@@ -723,6 +724,7 @@ pick_drop_surface (MetaWaylandCompositor *compositor,
   MetaWorkspaceManager *workspace_manager = display->workspace_manager;
   MetaWorkspace *workspace = workspace_manager->active_workspace;
   MetaWindow *focus_window = NULL;
+  MetaWindowXwayland *xwayland_window = NULL;
   graphene_point_t pos;
 
   clutter_event_get_coords (event, &pos.x, &pos.y);
@@ -730,7 +732,9 @@ pick_drop_surface (MetaWaylandCompositor *compositor,
                                                                workspace,
                                                                NULL,
                                                                pos.x, pos.y);
-  return focus_window ? focus_window->surface : NULL;
+  xwayland_window = META_WINDOW_XWAYLAND (focus_window);
+
+  return xwayland_window ? xwayland_window->surface : NULL;
 }
 
 static void
diff --git a/src/wayland/meta-xwayland-surface.c b/src/wayland/meta-xwayland-surface.c
index d0325e957c..733707c12c 100644
--- a/src/wayland/meta-xwayland-surface.c
+++ b/src/wayland/meta-xwayland-surface.c
@@ -26,6 +26,7 @@
 #include "compositor/meta-surface-actor-wayland.h"
 #include "compositor/meta-window-actor-private.h"
 #include "wayland/meta-wayland-actor-surface.h"
+#include "wayland/meta-window-xwayland.h"
 #include "wayland/meta-xwayland-private.h"
 
 enum
@@ -58,14 +59,15 @@ clear_window (MetaXwaylandSurface *xwayland_surface)
   MetaWaylandSurface *surface =
     meta_wayland_surface_role_get_surface (surface_role);
   MetaSurfaceActor *surface_actor;
+  MetaWindowXwayland *xwayland_window;
 
   if (!xwayland_surface->window)
     return;
 
   g_clear_signal_handler (&xwayland_surface->unmanaging_handler_id,
                           xwayland_surface->window);
-
-  xwayland_surface->window->surface = NULL;
+  xwayland_window = META_WINDOW_XWAYLAND (xwayland_surface->window);
+  xwayland_window->surface = NULL;
   xwayland_surface->window = NULL;
 
   surface_actor = meta_wayland_surface_get_actor (surface);
@@ -90,6 +92,7 @@ meta_xwayland_surface_associate_with_window (MetaXwaylandSurface *xwayland_surfa
     META_WAYLAND_SURFACE_ROLE (xwayland_surface);
   MetaWaylandSurface *surface =
     meta_wayland_surface_role_get_surface (surface_role);
+  MetaWindowXwayland *xwayland_window = META_WINDOW_XWAYLAND (window);
   MetaSurfaceActor *surface_actor;
   MetaWindowActor *window_actor;
 
@@ -98,15 +101,15 @@ meta_xwayland_surface_associate_with_window (MetaXwaylandSurface *xwayland_surfa
    * decorating the window, then we need to detach the window from its old
    * surface.
    */
-  if (window->surface)
+  if (xwayland_window->surface)
     {
       MetaXwaylandSurface *other_xwayland_surface;
 
-      other_xwayland_surface = META_XWAYLAND_SURFACE (window->surface->role);
+      other_xwayland_surface = META_XWAYLAND_SURFACE (xwayland_window->surface->role);
       clear_window (other_xwayland_surface);
     }
 
-  window->surface = surface;
+  xwayland_window->surface = surface;
   xwayland_surface->window = window;
 
   surface_actor = meta_wayland_surface_get_actor (surface);


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