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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2418>
This commit is contained in:
Bilal Elmoussaoui 2022-05-18 13:51:44 +02:00 committed by Marge Bot
parent c3a01e4e18
commit 6b77532a23
13 changed files with 193 additions and 45 deletions

View File

@ -375,16 +375,19 @@ init_surface_actor (MetaWindowActor *self)
MetaWindowActorPrivate *priv = MetaWindowActorPrivate *priv =
meta_window_actor_get_instance_private (self); meta_window_actor_get_instance_private (self);
MetaWindow *window = priv->window; MetaWindow *window = priv->window;
MetaSurfaceActor *surface_actor; MetaSurfaceActor *surface_actor = NULL;
if (!meta_is_wayland_compositor ()) if (!meta_is_wayland_compositor ())
{
surface_actor = meta_surface_actor_x11_new (window); surface_actor = meta_surface_actor_x11_new (window);
}
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
else if (window->surface)
surface_actor = meta_wayland_surface_get_actor (window->surface);
#endif
else else
surface_actor = NULL; {
MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
surface_actor = surface ? meta_wayland_surface_get_actor (surface) : NULL;
}
#endif
if (surface_actor) if (surface_actor)
meta_window_actor_assign_surface_actor (self, surface_actor); meta_window_actor_assign_surface_actor (self, surface_actor);

View File

@ -1437,8 +1437,11 @@ meta_display_sync_wayland_input_focus (MetaDisplay *display)
focus_window = NULL; focus_window = NULL;
else if (clutter_stage_get_grab_actor (CLUTTER_STAGE (stage))) else if (clutter_stage_get_grab_actor (CLUTTER_STAGE (stage)))
focus_window = NULL; focus_window = NULL;
else if (display->focus_window && display->focus_window->surface) #ifdef HAVE_WAYLAND
else if (display->focus_window &&
meta_window_get_wayland_surface (display->focus_window))
focus_window = display->focus_window; focus_window = display->focus_window;
#endif
else else
meta_topic (META_DEBUG_FOCUS, "Focus change has no effect, because there is no matching wayland surface"); meta_topic (META_DEBUG_FOCUS, "Focus change has no effect, because there is no matching wayland surface");

View File

@ -170,7 +170,6 @@ struct _MetaWindow
MetaLogicalMonitor *monitor; MetaLogicalMonitor *monitor;
MetaWorkspace *workspace; MetaWorkspace *workspace;
MetaWindowClientType client_type; MetaWindowClientType client_type;
MetaWaylandSurface *surface;
Window xwindow; Window xwindow;
/* may be NULL! not all windows get decorated */ /* may be NULL! not all windows get decorated */
MetaFrame *frame; MetaFrame *frame;
@ -619,6 +618,10 @@ struct _MetaWindowClass
MetaStackLayer (*calculate_layer) (MetaWindow *window); MetaStackLayer (*calculate_layer) (MetaWindow *window);
#ifdef HAVE_WAYLAND
MetaWaylandSurface * (*get_wayland_surface) (MetaWindow *window);
#endif
void (* map) (MetaWindow *window); void (* map) (MetaWindow *window);
void (* unmap) (MetaWindow *window); void (* unmap) (MetaWindow *window);
}; };
@ -722,6 +725,11 @@ gboolean meta_window_can_ping (MetaWindow *window);
MetaStackLayer meta_window_calculate_layer (MetaWindow *window); MetaStackLayer meta_window_calculate_layer (MetaWindow *window);
#ifdef HAVE_WAYLAND
META_EXPORT_TEST
MetaWaylandSurface * meta_window_get_wayland_surface (MetaWindow *window);
#endif
void meta_window_current_workspace_changed (MetaWindow *window); void meta_window_current_workspace_changed (MetaWindow *window);
void meta_window_show_menu (MetaWindow *window, void meta_window_show_menu (MetaWindow *window,

View File

@ -197,7 +197,6 @@ enum
PROP_IS_ALIVE, PROP_IS_ALIVE,
PROP_DISPLAY, PROP_DISPLAY,
PROP_EFFECT, PROP_EFFECT,
PROP_SURFACE,
PROP_XWINDOW, PROP_XWINDOW,
PROP_LAST, PROP_LAST,
@ -418,9 +417,6 @@ meta_window_get_property(GObject *object,
case PROP_EFFECT: case PROP_EFFECT:
g_value_set_int (value, win->pending_compositor_effect); g_value_set_int (value, win->pending_compositor_effect);
break; break;
case PROP_SURFACE:
g_value_set_pointer (value, win->surface);
break;
case PROP_XWINDOW: case PROP_XWINDOW:
g_value_set_ulong (value, win->xwindow); g_value_set_ulong (value, win->xwindow);
break; break;
@ -446,9 +442,6 @@ meta_window_set_property(GObject *object,
case PROP_EFFECT: case PROP_EFFECT:
win->pending_compositor_effect = g_value_get_int (value); win->pending_compositor_effect = g_value_get_int (value);
break; break;
case PROP_SURFACE:
win->surface = g_value_get_pointer (value);
break;
case PROP_XWINDOW: case PROP_XWINDOW:
win->xwindow = g_value_get_ulong (value); win->xwindow = g_value_get_ulong (value);
break; break;
@ -834,9 +827,12 @@ static gboolean
client_window_should_be_mapped (MetaWindow *window) client_window_should_be_mapped (MetaWindow *window)
{ {
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND && if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
!meta_wayland_surface_get_buffer (window->surface)) {
MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
if (!meta_wayland_surface_get_buffer (surface))
return FALSE; return FALSE;
}
#endif #endif
return !window->shaded; return !window->shaded;
@ -1683,9 +1679,12 @@ meta_window_should_be_showing (MetaWindow *window)
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager; MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND && if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
!meta_wayland_surface_get_buffer (window->surface)) {
MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
if (!meta_wayland_surface_get_buffer (surface))
return FALSE; return FALSE;
}
#endif #endif
/* Windows should be showing if they're located on the /* Windows should be showing if they're located on the
@ -4503,7 +4502,10 @@ meta_window_transient_can_focus (MetaWindow *window)
{ {
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND) if (window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
return meta_wayland_surface_get_buffer (window->surface) != NULL; {
MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
return meta_wayland_surface_get_buffer (surface) != NULL;
}
#endif #endif
return TRUE; return TRUE;
@ -8526,6 +8528,17 @@ meta_window_calculate_layer (MetaWindow *window)
return META_WINDOW_GET_CLASS (window)->calculate_layer (window); return META_WINDOW_GET_CLASS (window)->calculate_layer (window);
} }
#ifdef HAVE_WAYLAND
MetaWaylandSurface *
meta_window_get_wayland_surface (MetaWindow *window)
{
MetaWindowClass *klass = META_WINDOW_GET_CLASS (window);
g_return_val_if_fail (klass->get_wayland_surface != NULL, NULL);
return klass->get_wayland_surface (window);
}
#endif
/** /**
* meta_window_get_id: * meta_window_get_id:
* @window: a #MetaWindow * @window: a #MetaWindow

View File

@ -37,10 +37,10 @@ static MetaWindow *test_window = NULL;
#define assert_wayland_surface_size(window, width, height) \ #define assert_wayland_surface_size(window, width, height) \
{ \ { \
g_assert_cmpint (meta_wayland_surface_get_width (window->surface), \ g_assert_cmpint (meta_wayland_surface_get_width (meta_window_get_wayland_surface (window)), \
==, \ ==, \
width); \ width); \
g_assert_cmpint (meta_wayland_surface_get_height (window->surface), \ g_assert_cmpint (meta_wayland_surface_get_height (meta_window_get_wayland_surface (window)), \
==, \ ==, \
height); \ height); \
} }

View File

@ -41,6 +41,7 @@
#include "meta/util.h" #include "meta/util.h"
#include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-private.h"
#include "wayland/meta-wayland-types.h" #include "wayland/meta-wayland-types.h"
#include "wayland/meta-window-wayland.h"
struct _MetaWaylandClient struct _MetaWaylandClient
{ {
@ -296,7 +297,7 @@ meta_wayland_client_owns_window (MetaWaylandClient *client,
g_return_val_if_fail (client->subprocess != NULL, FALSE); g_return_val_if_fail (client->subprocess != NULL, FALSE);
g_return_val_if_fail (client->process_running, FALSE); g_return_val_if_fail (client->process_running, FALSE);
surface = window->surface; surface = meta_window_get_wayland_surface (window);
if (surface == NULL) if (surface == NULL)
return FALSE; return FALSE;

View File

@ -574,7 +574,7 @@ meta_wayland_pointer_constraint_maybe_remove_for_seat (MetaWaylandSeat *seat,
static void static void
meta_wayland_pointer_constraint_maybe_enable_for_window (MetaWindow *window) meta_wayland_pointer_constraint_maybe_enable_for_window (MetaWindow *window)
{ {
MetaWaylandSurface *surface = window->surface; MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
MetaWaylandSurfacePointerConstraintsData *surface_data; MetaWaylandSurfacePointerConstraintsData *surface_data;
GList *l; GList *l;

View File

@ -143,8 +143,12 @@ void
meta_wayland_compositor_set_input_focus (MetaWaylandCompositor *compositor, meta_wayland_compositor_set_input_focus (MetaWaylandCompositor *compositor,
MetaWindow *window) MetaWindow *window)
{ {
MetaWaylandSurface *surface = window ? window->surface : NULL; MetaWaylandSurface *surface;
if (window)
surface = meta_window_get_wayland_surface (window);
else
surface = NULL;
meta_wayland_seat_set_input_focus (compositor->seat, surface); meta_wayland_seat_set_input_focus (compositor->seat, surface);
} }

View File

@ -44,12 +44,25 @@
#include "wayland/meta-wayland-window-configuration.h" #include "wayland/meta-wayland-window-configuration.h"
#include "wayland/meta-wayland-xdg-shell.h" #include "wayland/meta-wayland-xdg-shell.h"
enum
{
PROP_0,
PROP_SURFACE,
PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST];
struct _MetaWindowWayland struct _MetaWindowWayland
{ {
MetaWindow parent; MetaWindow parent;
int geometry_scale; int geometry_scale;
MetaWaylandSurface *surface;
GList *pending_configurations; GList *pending_configurations;
gboolean has_pending_state_change; gboolean has_pending_state_change;
@ -112,7 +125,7 @@ meta_window_wayland_manage (MetaWindow *window)
0); 0);
} }
meta_wayland_surface_window_managed (window->surface, window); meta_wayland_surface_window_managed (wl_window->surface, window);
} }
static void static void
@ -131,20 +144,24 @@ static void
meta_window_wayland_ping (MetaWindow *window, meta_window_wayland_ping (MetaWindow *window,
guint32 serial) 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 static void
meta_window_wayland_delete (MetaWindow *window, meta_window_wayland_delete (MetaWindow *window,
guint32 timestamp) guint32 timestamp)
{ {
meta_wayland_surface_delete (window->surface); MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
meta_wayland_surface_delete (wl_window->surface);
} }
static void static void
meta_window_wayland_kill (MetaWindow *window) meta_window_wayland_kill (MetaWindow *window)
{ {
MetaWaylandSurface *surface = window->surface; MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
struct wl_resource *resource = surface->resource; struct wl_resource *resource = surface->resource;
/* Send the client an unrecoverable error to kill the client. */ /* Send the client an unrecoverable error to kill the client. */
@ -170,9 +187,7 @@ static void
meta_window_wayland_configure (MetaWindowWayland *wl_window, meta_window_wayland_configure (MetaWindowWayland *wl_window,
MetaWaylandWindowConfiguration *configuration) MetaWaylandWindowConfiguration *configuration)
{ {
MetaWindow *window = META_WINDOW (wl_window); meta_wayland_surface_configure_notify (wl_window->surface, configuration);
meta_wayland_surface_configure_notify (window->surface, configuration);
wl_window->pending_configurations = wl_window->pending_configurations =
g_list_prepend (wl_window->pending_configurations, configuration); g_list_prepend (wl_window->pending_configurations, configuration);
@ -378,7 +393,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
int bounds_width; int bounds_width;
int bounds_height; int bounds_height;
if (!meta_wayland_surface_get_buffer (window->surface) && if (!meta_wayland_surface_get_buffer (wl_window->surface) &&
!META_WINDOW_MAXIMIZED (window) && !META_WINDOW_MAXIMIZED (window) &&
window->tile_mode == META_TILE_NONE && window->tile_mode == META_TILE_NONE &&
!meta_window_is_fullscreen (window)) !meta_window_is_fullscreen (window))
@ -489,6 +504,7 @@ meta_window_wayland_update_main_monitor (MetaWindow *window,
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
MetaMonitorManager *monitor_manager = MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend); meta_backend_get_monitor_manager (backend);
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
MetaWindow *toplevel_window; MetaWindow *toplevel_window;
MetaLogicalMonitor *from; MetaLogicalMonitor *from;
MetaLogicalMonitor *to; MetaLogicalMonitor *to;
@ -501,7 +517,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 /* If the window is not a toplevel window (i.e. it's a popup window) just use
* the monitor of the toplevel. */ * 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) if (toplevel_window != window)
{ {
meta_window_update_monitor (toplevel_window, flags); meta_window_update_monitor (toplevel_window, flags);
@ -622,7 +638,7 @@ meta_window_wayland_main_monitor_changed (MetaWindow *window,
window, window,
TRUE); TRUE);
surface = window->surface; surface = wl_window->surface;
if (surface) if (surface)
{ {
MetaWaylandActorSurface *actor_surface = MetaWaylandActorSurface *actor_surface =
@ -638,7 +654,7 @@ meta_window_wayland_main_monitor_changed (MetaWindow *window,
static pid_t static pid_t
meta_window_wayland_get_client_pid (MetaWindow *window) meta_window_wayland_get_client_pid (MetaWindow *window)
{ {
MetaWaylandSurface *surface = window->surface; MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
struct wl_resource *resource = surface->resource; struct wl_resource *resource = surface->resource;
pid_t pid; pid_t pid;
@ -718,7 +734,8 @@ meta_window_wayland_can_ping (MetaWindow *window)
static gboolean static gboolean
meta_window_wayland_is_stackable (MetaWindow *window) 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 static gboolean
@ -735,6 +752,14 @@ meta_window_wayland_is_focus_async (MetaWindow *window)
return FALSE; return FALSE;
} }
static MetaWaylandSurface *
meta_window_wayland_get_wayland_surface (MetaWindow *window)
{
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
return wl_window->surface;
}
static MetaStackLayer static MetaStackLayer
meta_window_wayland_calculate_layer (MetaWindow *window) meta_window_wayland_calculate_layer (MetaWindow *window)
{ {
@ -793,6 +818,44 @@ meta_window_wayland_finalize (GObject *object)
G_OBJECT_CLASS (meta_window_wayland_parent_class)->finalize (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 static void
meta_window_wayland_class_init (MetaWindowWaylandClass *klass) meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
{ {
@ -800,6 +863,8 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
MetaWindowClass *window_class = META_WINDOW_CLASS (klass); MetaWindowClass *window_class = META_WINDOW_CLASS (klass);
object_class->finalize = meta_window_wayland_finalize; 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; object_class->constructed = meta_window_wayland_constructed;
window_class->manage = meta_window_wayland_manage; window_class->manage = meta_window_wayland_manage;
@ -824,6 +889,16 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
window_class->map = meta_window_wayland_map; window_class->map = meta_window_wayland_map;
window_class->unmap = meta_window_wayland_unmap; window_class->unmap = meta_window_wayland_unmap;
window_class->is_focus_async = meta_window_wayland_is_focus_async; window_class->is_focus_async = meta_window_wayland_is_focus_async;
window_class->get_wayland_surface = meta_window_wayland_get_wayland_surface;
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 * MetaWindow *

View File

@ -27,12 +27,14 @@
#include "x11/xprops.h" #include "x11/xprops.h"
#include "wayland/meta-window-xwayland.h" #include "wayland/meta-window-xwayland.h"
#include "wayland/meta-wayland.h" #include "wayland/meta-wayland.h"
#include "wayland/meta-wayland-surface.h"
enum enum
{ {
PROP_0, PROP_0,
PROP_XWAYLAND_MAY_GRAB_KEYBOARD, PROP_XWAYLAND_MAY_GRAB_KEYBOARD,
PROP_SURFACE,
PROP_LAST PROP_LAST
}; };
@ -43,6 +45,8 @@ struct _MetaWindowXwayland
{ {
MetaWindowX11 parent; MetaWindowX11 parent;
MetaWaylandSurface *surface;
gboolean xwayland_may_grab_keyboard; gboolean xwayland_may_grab_keyboard;
int freeze_count; int freeze_count;
}; };
@ -164,6 +168,14 @@ meta_window_xwayland_shortcuts_inhibited (MetaWindow *window,
return meta_wayland_compositor_is_shortcuts_inhibited (compositor, source); return meta_wayland_compositor_is_shortcuts_inhibited (compositor, source);
} }
static MetaWaylandSurface *
meta_window_xwayland_get_wayland_surface (MetaWindow *window)
{
MetaWindowXwayland *xwayland_window = META_WINDOW_XWAYLAND (window);
return xwayland_window->surface;
}
static void static void
apply_allow_commits_x11_property (MetaWindowXwayland *xwayland_window, apply_allow_commits_x11_property (MetaWindowXwayland *xwayland_window,
gboolean allow_commits) gboolean allow_commits)
@ -251,6 +263,9 @@ meta_window_xwayland_get_property (GObject *object,
case PROP_XWAYLAND_MAY_GRAB_KEYBOARD: case PROP_XWAYLAND_MAY_GRAB_KEYBOARD:
g_value_set_boolean (value, window->xwayland_may_grab_keyboard); g_value_set_boolean (value, window->xwayland_may_grab_keyboard);
break; break;
case PROP_SURFACE:
g_value_set_object (value, window->surface);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -270,6 +285,9 @@ meta_window_xwayland_set_property (GObject *object,
case PROP_XWAYLAND_MAY_GRAB_KEYBOARD: case PROP_XWAYLAND_MAY_GRAB_KEYBOARD:
window->xwayland_may_grab_keyboard = g_value_get_boolean (value); window->xwayland_may_grab_keyboard = g_value_get_boolean (value);
break; break;
case PROP_SURFACE:
window->surface = g_value_get_object (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -286,6 +304,7 @@ meta_window_xwayland_class_init (MetaWindowXwaylandClass *klass)
window_class->adjust_fullscreen_monitor_rect = meta_window_xwayland_adjust_fullscreen_monitor_rect; window_class->adjust_fullscreen_monitor_rect = meta_window_xwayland_adjust_fullscreen_monitor_rect;
window_class->force_restore_shortcuts = meta_window_xwayland_force_restore_shortcuts; window_class->force_restore_shortcuts = meta_window_xwayland_force_restore_shortcuts;
window_class->shortcuts_inhibited = meta_window_xwayland_shortcuts_inhibited; window_class->shortcuts_inhibited = meta_window_xwayland_shortcuts_inhibited;
window_class->get_wayland_surface = meta_window_xwayland_get_wayland_surface;
window_x11_class->freeze_commits = meta_window_xwayland_freeze_commits; window_x11_class->freeze_commits = meta_window_xwayland_freeze_commits;
window_x11_class->thaw_commits = meta_window_xwayland_thaw_commits; window_x11_class->thaw_commits = meta_window_xwayland_thaw_commits;
@ -301,5 +320,19 @@ meta_window_xwayland_class_init (MetaWindowXwaylandClass *klass)
FALSE, FALSE,
G_PARAM_READWRITE); 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); g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
} }
void
meta_window_xwayland_set_surface (MetaWindowXwayland *window,
MetaWaylandSurface *surface)
{
window->surface = surface;
}

View File

@ -29,6 +29,10 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (MetaWindowXwayland, meta_window_xwayland, G_DECLARE_FINAL_TYPE (MetaWindowXwayland, meta_window_xwayland,
META, WINDOW_XWAYLAND, MetaWindowX11) META, WINDOW_XWAYLAND, MetaWindowX11)
void meta_window_xwayland_set_surface (MetaWindowXwayland *window,
MetaWaylandSurface *surface);
G_END_DECLS G_END_DECLS
#endif #endif

View File

@ -730,7 +730,7 @@ pick_drop_surface (MetaWaylandCompositor *compositor,
focus_window = meta_workspace_get_default_focus_window_at_point (workspace, focus_window = meta_workspace_get_default_focus_window_at_point (workspace,
NULL, NULL,
pos.x, pos.y); pos.x, pos.y);
return focus_window ? focus_window->surface : NULL; return focus_window ? meta_window_get_wayland_surface (focus_window) : NULL;
} }
static void static void

View File

@ -26,6 +26,7 @@
#include "compositor/meta-surface-actor-wayland.h" #include "compositor/meta-surface-actor-wayland.h"
#include "compositor/meta-window-actor-private.h" #include "compositor/meta-window-actor-private.h"
#include "wayland/meta-wayland-actor-surface.h" #include "wayland/meta-wayland-actor-surface.h"
#include "wayland/meta-window-xwayland.h"
#include "wayland/meta-xwayland-private.h" #include "wayland/meta-xwayland-private.h"
enum enum
@ -58,14 +59,15 @@ clear_window (MetaXwaylandSurface *xwayland_surface)
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaSurfaceActor *surface_actor; MetaSurfaceActor *surface_actor;
MetaWindowXwayland *xwayland_window;
if (!xwayland_surface->window) if (!xwayland_surface->window)
return; return;
g_clear_signal_handler (&xwayland_surface->unmanaging_handler_id, g_clear_signal_handler (&xwayland_surface->unmanaging_handler_id,
xwayland_surface->window); xwayland_surface->window);
xwayland_window = META_WINDOW_XWAYLAND (xwayland_surface->window);
xwayland_surface->window->surface = NULL; meta_window_xwayland_set_surface (xwayland_window, NULL);
xwayland_surface->window = NULL; xwayland_surface->window = NULL;
surface_actor = meta_wayland_surface_get_actor (surface); surface_actor = meta_wayland_surface_get_actor (surface);
@ -90,6 +92,8 @@ meta_xwayland_surface_associate_with_window (MetaXwaylandSurface *xwayland_surfa
META_WAYLAND_SURFACE_ROLE (xwayland_surface); META_WAYLAND_SURFACE_ROLE (xwayland_surface);
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaWindowXwayland *xwayland_window = META_WINDOW_XWAYLAND (window);
MetaWaylandSurface *window_surface = meta_window_get_wayland_surface (window);
MetaSurfaceActor *surface_actor; MetaSurfaceActor *surface_actor;
MetaWindowActor *window_actor; MetaWindowActor *window_actor;
@ -98,15 +102,15 @@ meta_xwayland_surface_associate_with_window (MetaXwaylandSurface *xwayland_surfa
* decorating the window, then we need to detach the window from its old * decorating the window, then we need to detach the window from its old
* surface. * surface.
*/ */
if (window->surface) if (window_surface)
{ {
MetaXwaylandSurface *other_xwayland_surface; MetaXwaylandSurface *other_xwayland_surface;
other_xwayland_surface = META_XWAYLAND_SURFACE (window->surface->role); other_xwayland_surface = META_XWAYLAND_SURFACE (window_surface->role);
clear_window (other_xwayland_surface); clear_window (other_xwayland_surface);
} }
window->surface = surface; meta_window_xwayland_set_surface (xwayland_window, surface);
xwayland_surface->window = window; xwayland_surface->window = window;
surface_actor = meta_wayland_surface_get_actor (surface); surface_actor = meta_wayland_surface_get_actor (surface);