wayland: Don't access MetaWaylandSurface::window directly

It'll be moved to the role owning it, accessed via a helper function
implemented by the role. Currently it still just fetches the field in
MetaWaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
This commit is contained in:
Jonas Ådahl 2019-10-09 09:37:04 +02:00 committed by Robert Mader
parent 5149e1e43a
commit c0c74484bc
17 changed files with 198 additions and 126 deletions

View File

@ -696,6 +696,7 @@ meta_pointer_confinement_wayland_new (MetaWaylandPointerConstraint *constraint)
GObject *object; GObject *object;
MetaPointerConfinementWayland *confinement; MetaPointerConfinementWayland *confinement;
MetaWaylandSurface *surface; MetaWaylandSurface *surface;
MetaWindow *window;
object = g_object_new (META_TYPE_POINTER_CONFINEMENT_WAYLAND, NULL); object = g_object_new (META_TYPE_POINTER_CONFINEMENT_WAYLAND, NULL);
confinement = META_POINTER_CONFINEMENT_WAYLAND (object); confinement = META_POINTER_CONFINEMENT_WAYLAND (object);
@ -708,9 +709,11 @@ meta_pointer_confinement_wayland_new (MetaWaylandPointerConstraint *constraint)
G_CALLBACK (surface_geometry_changed), G_CALLBACK (surface_geometry_changed),
confinement, confinement,
0); 0);
if (surface->window)
window = meta_wayland_surface_get_window (surface);
if (window)
{ {
g_signal_connect_object (surface->window, g_signal_connect_object (window,
"position-changed", "position-changed",
G_CALLBACK (window_position_changed), G_CALLBACK (window_position_changed),
confinement, confinement,

View File

@ -150,6 +150,7 @@ meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor
MetaShapedTexture *stex; MetaShapedTexture *stex;
MetaWaylandBuffer *buffer; MetaWaylandBuffer *buffer;
cairo_rectangle_int_t surface_rect; cairo_rectangle_int_t surface_rect;
MetaWindow *window;
MetaWaylandSurface *subsurface_surface; MetaWaylandSurface *subsurface_surface;
surface_actor = priv->actor; surface_actor = priv->actor;
@ -194,8 +195,9 @@ meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor
meta_surface_actor_set_input_region (surface_actor, NULL); meta_surface_actor_set_input_region (surface_actor, NULL);
} }
if (surface->window && window = meta_wayland_surface_get_window (surface);
surface->window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND) if (window &&
window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
{ {
if (surface->opaque_region) if (surface->opaque_region)
{ {

View File

@ -83,7 +83,7 @@ gtk_surface_set_dbus_properties (struct wl_client *client,
MetaWaylandSurface *surface = gtk_surface->surface; MetaWaylandSurface *surface = gtk_surface->surface;
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -104,7 +104,7 @@ gtk_surface_set_modal (struct wl_client *client,
MetaWaylandSurface *surface = gtk_surface->surface; MetaWaylandSurface *surface = gtk_surface->surface;
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -123,7 +123,7 @@ gtk_surface_unset_modal (struct wl_client *client,
MetaWaylandSurface *surface = gtk_surface->surface; MetaWaylandSurface *surface = gtk_surface->surface;
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -143,7 +143,7 @@ gtk_surface_present (struct wl_client *client,
MetaWaylandSurface *surface = gtk_surface->surface; MetaWaylandSurface *surface = gtk_surface->surface;
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -162,7 +162,7 @@ gtk_surface_request_focus (struct wl_client *client,
MetaStartupSequence *sequence = NULL; MetaStartupSequence *sequence = NULL;
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -313,11 +313,14 @@ static void
on_configure (MetaWaylandSurface *surface, on_configure (MetaWaylandSurface *surface,
MetaWaylandGtkSurface *gtk_surface) MetaWaylandGtkSurface *gtk_surface)
{ {
send_configure (gtk_surface, surface->window); MetaWindow *window;
window = meta_wayland_surface_get_window (surface);
send_configure (gtk_surface, window);
if (wl_resource_get_version (gtk_surface->resource) >= GTK_SURFACE1_CONFIGURE_EDGES_SINCE_VERSION) if (wl_resource_get_version (gtk_surface->resource) >=
send_configure_edges (gtk_surface, surface->window); GTK_SURFACE1_CONFIGURE_EDGES_SINCE_VERSION)
send_configure_edges (gtk_surface, window);
} }
static void static void
@ -387,11 +390,13 @@ gtk_shell_system_bell (struct wl_client *client,
MetaWaylandGtkSurface *gtk_surface = MetaWaylandGtkSurface *gtk_surface =
wl_resource_get_user_data (gtk_surface_resource); wl_resource_get_user_data (gtk_surface_resource);
MetaWaylandSurface *surface = gtk_surface->surface; MetaWaylandSurface *surface = gtk_surface->surface;
MetaWindow *window;
if (!surface->window) window = meta_wayland_surface_get_window (surface);
if (!window)
return; return;
meta_bell_notify (display, surface->window); meta_bell_notify (display, window);
} }
else else
{ {

View File

@ -189,7 +189,7 @@ zxdg_toplevel_v6_set_parent (struct wl_client *client,
MetaWindow *transient_for = NULL; MetaWindow *transient_for = NULL;
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -198,7 +198,7 @@ zxdg_toplevel_v6_set_parent (struct wl_client *client,
MetaWaylandSurface *parent_surface = MetaWaylandSurface *parent_surface =
surface_from_xdg_surface_resource (parent_resource); surface_from_xdg_surface_resource (parent_resource);
transient_for = parent_surface->window; transient_for = meta_wayland_surface_get_window (parent_surface);
} }
meta_window_set_transient_for (window, transient_for); meta_window_set_transient_for (window, transient_for);
@ -212,7 +212,7 @@ zxdg_toplevel_v6_set_title (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -230,7 +230,7 @@ zxdg_toplevel_v6_set_app_id (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -253,7 +253,7 @@ zxdg_toplevel_v6_show_window_menu (struct wl_client *client,
MetaWindow *window; MetaWindow *window;
int monitor_scale; int monitor_scale;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -277,7 +277,7 @@ zxdg_toplevel_v6_move (struct wl_client *client,
MetaWindow *window; MetaWindow *window;
gfloat x, y; gfloat x, y;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -323,7 +323,7 @@ zxdg_toplevel_v6_resize (struct wl_client *client,
gfloat x, y; gfloat x, y;
MetaGrabOp grab_op; MetaGrabOp grab_op;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -344,7 +344,7 @@ zxdg_toplevel_v6_set_max_size (struct wl_client *client,
MetaWaylandSurfaceState *pending; MetaWaylandSurfaceState *pending;
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -373,7 +373,7 @@ zxdg_toplevel_v6_set_min_size (struct wl_client *client,
MetaWaylandSurfaceState *pending; MetaWaylandSurfaceState *pending;
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -399,7 +399,7 @@ zxdg_toplevel_v6_set_maximized (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -417,7 +417,7 @@ zxdg_toplevel_v6_unset_maximized (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -432,7 +432,7 @@ zxdg_toplevel_v6_set_fullscreen (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -453,7 +453,7 @@ zxdg_toplevel_v6_unset_fullscreen (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -467,7 +467,7 @@ zxdg_toplevel_v6_set_minimized (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -600,10 +600,13 @@ meta_wayland_zxdg_toplevel_v6_send_configure (MetaWaylandZxdgToplevelV6 *xd
META_WAYLAND_SURFACE_ROLE (xdg_toplevel); META_WAYLAND_SURFACE_ROLE (xdg_toplevel);
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaWindow *window;
struct wl_array states; struct wl_array states;
window = meta_wayland_surface_get_window (surface);
wl_array_init (&states); wl_array_init (&states);
fill_states (&states, surface->window); fill_states (&states, window);
zxdg_toplevel_v6_send_configure (xdg_toplevel->resource, zxdg_toplevel_v6_send_configure (xdg_toplevel->resource,
configuration->width, configuration->width,
@ -662,7 +665,7 @@ meta_wayland_zxdg_toplevel_v6_apply_state (MetaWaylandSurfaceRole *surface_role
MetaRectangle old_geometry; MetaRectangle old_geometry;
gboolean geometry_changed; gboolean geometry_changed;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
{ {
meta_wayland_surface_cache_pending_frame_callbacks (surface, pending); meta_wayland_surface_cache_pending_frame_callbacks (surface, pending);
@ -845,9 +848,11 @@ static void
scale_placement_rule (MetaPlacementRule *placement_rule, scale_placement_rule (MetaPlacementRule *placement_rule,
MetaWaylandSurface *surface) MetaWaylandSurface *surface)
{ {
MetaWindow *window;
int geometry_scale; int geometry_scale;
geometry_scale = meta_window_wayland_get_geometry_scale (surface->window); window = meta_wayland_surface_get_window (surface);
geometry_scale = meta_window_wayland_get_geometry_scale (window);
placement_rule->anchor_rect.x *= geometry_scale; placement_rule->anchor_rect.x *= geometry_scale;
placement_rule->anchor_rect.y *= geometry_scale; placement_rule->anchor_rect.y *= geometry_scale;
@ -885,7 +890,7 @@ finish_popup_setup (MetaWaylandZxdgPopupV6 *xdg_popup)
xdg_popup->setup.parent_surface = NULL; xdg_popup->setup.parent_surface = NULL;
xdg_popup->setup.grab_seat = NULL; xdg_popup->setup.grab_seat = NULL;
if (!parent_surface->window) if (!meta_wayland_surface_get_window (parent_surface))
{ {
zxdg_popup_v6_send_popup_done (xdg_popup->resource); zxdg_popup_v6_send_popup_done (xdg_popup->resource);
return; return;
@ -964,6 +969,7 @@ meta_wayland_zxdg_popup_v6_apply_state (MetaWaylandSurfaceRole *surface_role,
MetaWaylandSurfaceRoleClass *surface_role_class; MetaWaylandSurfaceRoleClass *surface_role_class;
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaWindow *window;
if (xdg_popup->setup.parent_surface) if (xdg_popup->setup.parent_surface)
finish_popup_setup (xdg_popup); finish_popup_setup (xdg_popup);
@ -973,7 +979,8 @@ meta_wayland_zxdg_popup_v6_apply_state (MetaWaylandSurfaceRole *surface_role,
surface_role_class->apply_state (surface_role, pending); surface_role_class->apply_state (surface_role, pending);
/* If the window disappeared the surface is not coming back. */ /* If the window disappeared the surface is not coming back. */
if (!surface->window) window = meta_wayland_surface_get_window (surface);
if (!window)
return; return;
if (!pending->newly_attached) if (!pending->newly_attached)
@ -988,7 +995,7 @@ meta_wayland_zxdg_popup_v6_apply_state (MetaWaylandSurfaceRole *surface_role,
window_geometry = window_geometry =
meta_wayland_zxdg_surface_v6_get_window_geometry (xdg_surface); meta_wayland_zxdg_surface_v6_get_window_geometry (xdg_surface);
meta_window_wayland_finish_move_resize (surface->window, meta_window_wayland_finish_move_resize (window,
window_geometry, window_geometry,
pending); pending);
} }
@ -1013,7 +1020,8 @@ meta_wayland_zxdg_popup_v6_configure (MetaWaylandShellSurface *shell_surf
META_WAYLAND_ZXDG_POPUP_V6 (shell_surface); META_WAYLAND_ZXDG_POPUP_V6 (shell_surface);
MetaWaylandZxdgSurfaceV6 *xdg_surface = MetaWaylandZxdgSurfaceV6 *xdg_surface =
META_WAYLAND_ZXDG_SURFACE_V6 (xdg_popup); META_WAYLAND_ZXDG_SURFACE_V6 (xdg_popup);
MetaWindow *parent_window = xdg_popup->parent_surface->window; MetaWindow *parent_window =
meta_wayland_surface_get_window (xdg_popup->parent_surface);
int geometry_scale; int geometry_scale;
int x, y; int x, y;
@ -1048,7 +1056,8 @@ meta_wayland_zxdg_popup_v6_managed (MetaWaylandShellSurface *shell_surface,
g_assert (parent); g_assert (parent);
meta_window_set_transient_for (window, parent->window); meta_window_set_transient_for (window,
meta_wayland_surface_get_window (parent));
meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU); meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU);
} }
@ -1328,7 +1337,7 @@ meta_wayland_zxdg_surface_v6_apply_state (MetaWaylandSurfaceRole *surface_role,
meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface); meta_wayland_zxdg_surface_v6_get_instance_private (xdg_surface);
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaWindow *window = surface->window; MetaWindow *window = meta_wayland_surface_get_window (surface);
MetaWaylandSurfaceRoleClass *surface_role_class; MetaWaylandSurfaceRoleClass *surface_role_class;
surface_role_class = surface_role_class =

View File

@ -164,25 +164,29 @@ window_associated (MetaWaylandSurfaceRole *surface_role,
MetaWaylandSurfacePointerConstraintsData *data) MetaWaylandSurfacePointerConstraintsData *data)
{ {
MetaWaylandSurface *surface = data->surface; MetaWaylandSurface *surface = data->surface;
MetaWindow *window;
connect_window (data, surface->window); window = meta_wayland_surface_get_window (surface);
connect_window (data, window);
g_clear_signal_handler (&data->window_associated_handler_id, surface); g_clear_signal_handler (&data->window_associated_handler_id, surface);
meta_wayland_pointer_constraint_maybe_enable_for_window (surface->window); meta_wayland_pointer_constraint_maybe_enable_for_window (window);
} }
static MetaWaylandSurfacePointerConstraintsData * static MetaWaylandSurfacePointerConstraintsData *
surface_constraint_data_new (MetaWaylandSurface *surface) surface_constraint_data_new (MetaWaylandSurface *surface)
{ {
MetaWaylandSurfacePointerConstraintsData *data; MetaWaylandSurfacePointerConstraintsData *data;
MetaWindow *window;
data = g_new0 (MetaWaylandSurfacePointerConstraintsData, 1); data = g_new0 (MetaWaylandSurfacePointerConstraintsData, 1);
data->surface = surface; data->surface = surface;
if (surface->window) window = meta_wayland_surface_get_window (surface);
if (window)
{ {
connect_window (data, surface->window); connect_window (data, window);
} }
else if (meta_xwayland_is_xwayland_surface (surface)) else if (meta_xwayland_is_xwayland_surface (surface))
{ {
@ -280,8 +284,9 @@ static void
pointer_focus_surface_changed (MetaWaylandPointer *pointer, pointer_focus_surface_changed (MetaWaylandPointer *pointer,
MetaWaylandPointerConstraint *constraint) MetaWaylandPointerConstraint *constraint)
{ {
MetaWindow *window = constraint->surface->window; MetaWindow *window;
window = meta_wayland_surface_get_window (constraint->surface);
if (window) if (window)
{ {
MetaWaylandSeat *seat = meta_wayland_pointer_get_seat (pointer); MetaWaylandSeat *seat = meta_wayland_pointer_get_seat (pointer);
@ -453,7 +458,7 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
{ {
MetaWindow *window; MetaWindow *window;
window = constraint->surface->window; window = meta_wayland_surface_get_window (constraint->surface);
if (!window) if (!window)
{ {
/* /*
@ -494,8 +499,6 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
} }
else else
{ {
MetaWindow *window = constraint->surface->window;
if (!meta_window_appears_focused (window)) if (!meta_window_appears_focused (window))
return FALSE; return FALSE;
} }
@ -610,7 +613,7 @@ meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerCo
if (constraint->region) if (constraint->region)
cairo_region_intersect (region, constraint->region); cairo_region_intersect (region, constraint->region);
window = constraint->surface->window; window = meta_wayland_surface_get_window (constraint->surface);
if (window && window->frame) if (window && window->frame)
{ {
MetaFrame *frame = window->frame; MetaFrame *frame = window->frame;

View File

@ -927,6 +927,7 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
{ {
struct wl_client *client = wl_resource_get_client (surface->resource); struct wl_client *client = wl_resource_get_client (surface->resource);
graphene_point_t pos; graphene_point_t pos;
MetaWindow *focus_window;
pointer->focus_surface = surface; pointer->focus_surface = surface;
@ -937,8 +938,9 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
clutter_input_device_get_coords (pointer->device, NULL, &pos); clutter_input_device_get_coords (pointer->device, NULL, &pos);
if (pointer->focus_surface->window) focus_window = meta_wayland_surface_get_window (pointer->focus_surface);
meta_window_handle_enter (pointer->focus_surface->window, if (focus_window)
meta_window_handle_enter (focus_window,
/* XXX -- can we reliably get a timestamp for setting focus? */ /* XXX -- can we reliably get a timestamp for setting focus? */
clutter_get_current_event_time (), clutter_get_current_event_time (),
pos.x, pos.y); pos.x, pos.y);

View File

@ -186,7 +186,7 @@ meta_wayland_popup_grab_begin (MetaWaylandPopupGrab *grab,
MetaWaylandSurface *surface) MetaWaylandSurface *surface)
{ {
MetaWaylandPointer *pointer = grab->generic.pointer; MetaWaylandPointer *pointer = grab->generic.pointer;
MetaWindow *window = surface->window; MetaWindow *window = meta_wayland_surface_get_window (surface);
meta_wayland_pointer_start_grab (pointer, (MetaWaylandPointerGrab*)grab); meta_wayland_pointer_start_grab (pointer, (MetaWaylandPointerGrab*)grab);
meta_display_begin_grab_op (window->display, meta_display_begin_grab_op (window->display,

View File

@ -154,7 +154,7 @@ meta_wayland_shell_surface_surface_apply_state (MetaWaylandSurfaceRole *surface
if (!buffer) if (!buffer)
return; return;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -174,7 +174,7 @@ meta_wayland_shell_surface_notify_subsurface_state_changed (MetaWaylandSurfaceRo
MetaWindow *window; MetaWindow *window;
MetaWindowActor *window_actor; MetaWindowActor *window_actor;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -207,11 +207,13 @@ meta_wayland_shell_surface_sync_actor_state (MetaWaylandActorSurface *actor_surf
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaWaylandActorSurfaceClass *actor_surface_class = MetaWaylandActorSurfaceClass *actor_surface_class =
META_WAYLAND_ACTOR_SURFACE_CLASS (meta_wayland_shell_surface_parent_class); META_WAYLAND_ACTOR_SURFACE_CLASS (meta_wayland_shell_surface_parent_class);
MetaWaylandSurface *toplevel_surface; MetaWindow *toplevel_window;
toplevel_surface = meta_wayland_surface_get_toplevel (surface); toplevel_window = meta_wayland_surface_get_toplevel_window (surface);
if (toplevel_surface && toplevel_surface->window) if (!toplevel_window)
actor_surface_class->sync_actor_state (actor_surface); return;
actor_surface_class->sync_actor_state (actor_surface);
} }
void void
@ -225,14 +227,14 @@ meta_wayland_shell_surface_destroy_window (MetaWaylandShellSurface *shell_surfac
MetaDisplay *display; MetaDisplay *display;
uint32_t timestamp; uint32_t timestamp;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
display = meta_window_get_display (window); display = meta_window_get_display (window);
timestamp = meta_display_get_current_time_roundtrip (display); timestamp = meta_display_get_current_time_roundtrip (display);
meta_window_unmanage (surface->window, timestamp); meta_window_unmanage (window, timestamp);
g_assert (!surface->window); g_assert (!meta_wayland_surface_get_window (surface));
} }
static void static void

View File

@ -299,7 +299,7 @@ meta_wayland_subsurface_sync_actor_state (MetaWaylandActorSurface *actor_surface
MetaWaylandSurface *toplevel_surface; MetaWaylandSurface *toplevel_surface;
toplevel_surface = meta_wayland_surface_get_toplevel (surface); toplevel_surface = meta_wayland_surface_get_toplevel (surface);
if (toplevel_surface && toplevel_surface->window) if (toplevel_surface && meta_wayland_surface_get_window (toplevel_surface))
actor_surface_class->sync_actor_state (actor_surface); actor_surface_class->sync_actor_state (actor_surface);
sync_actor_subsurface_state (surface); sync_actor_subsurface_state (surface);

View File

@ -633,8 +633,11 @@ meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
if (state->newly_attached) if (state->newly_attached)
{ {
if (!surface->buffer_ref.buffer && surface->window) MetaWindow *window;
meta_window_queue (surface->window, META_QUEUE_CALC_SHOWING);
window = meta_wayland_surface_get_window (surface);
if (!surface->buffer_ref.buffer && window)
meta_window_queue (window, META_QUEUE_CALC_SHOWING);
/* Always release any previously held buffer. If the buffer held is same /* Always release any previously held buffer. If the buffer held is same
* as the newly attached buffer, we still need to release it here, because * as the newly attached buffer, we still need to release it here, because
@ -1128,8 +1131,11 @@ static const struct wl_surface_interface meta_wayland_wl_surface_interface = {
static void static void
sync_drag_dest_funcs (MetaWaylandSurface *surface) sync_drag_dest_funcs (MetaWaylandSurface *surface)
{ {
if (surface->window && MetaWindow *window;
surface->window->client_type == META_WINDOW_CLIENT_TYPE_X11)
window = meta_wayland_surface_get_window (surface);
if (window &&
window->client_type == META_WINDOW_CLIENT_TYPE_X11)
surface->dnd.funcs = meta_xwayland_selection_get_drag_dest_funcs (); surface->dnd.funcs = meta_xwayland_selection_get_drag_dest_funcs ();
else else
surface->dnd.funcs = meta_wayland_data_device_get_drag_dest_funcs (); surface->dnd.funcs = meta_wayland_data_device_get_drag_dest_funcs ();
@ -1434,7 +1440,7 @@ meta_wayland_surface_begin_grab_op (MetaWaylandSurface *surface,
gfloat x, gfloat x,
gfloat y) gfloat y)
{ {
MetaWindow *window = surface->window; MetaWindow *window = meta_wayland_surface_get_window (surface);
if (grab_op == META_GRAB_OP_NONE) if (grab_op == META_GRAB_OP_NONE)
return FALSE; return FALSE;
@ -1574,7 +1580,7 @@ meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface)
toplevel = meta_wayland_surface_get_toplevel (surface); toplevel = meta_wayland_surface_get_toplevel (surface);
if (toplevel) if (toplevel)
return toplevel->window; return meta_wayland_surface_get_window (toplevel);
else else
return NULL; return NULL;
} }
@ -1586,6 +1592,8 @@ meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface,
float *sx, float *sx,
float *sy) float *sy)
{ {
MetaWindow *window;
/* Using clutter API to transform coordinates is only accurate right /* Using clutter API to transform coordinates is only accurate right
* after a clutter layout pass but this function is used e.g. to * after a clutter layout pass but this function is used e.g. to
* deliver pointer motion events which can happen at any time. This * deliver pointer motion events which can happen at any time. This
@ -1594,12 +1602,13 @@ meta_wayland_surface_get_relative_coordinates (MetaWaylandSurface *surface,
* coordinates if a client is moving a window in response to motion * coordinates if a client is moving a window in response to motion
* events. * events.
*/ */
if (surface->window && window = meta_wayland_surface_get_window (surface);
surface->window->client_type == META_WINDOW_CLIENT_TYPE_X11) if (window &&
window->client_type == META_WINDOW_CLIENT_TYPE_X11)
{ {
MetaRectangle window_rect; MetaRectangle window_rect;
meta_window_get_buffer_rect (surface->window, &window_rect); meta_window_get_buffer_rect (window, &window_rect);
*sx = abs_x - window_rect.x; *sx = abs_x - window_rect.x;
*sy = abs_y - window_rect.y; *sy = abs_y - window_rect.y;
} }
@ -1822,6 +1831,12 @@ meta_wayland_surface_role_get_toplevel (MetaWaylandSurfaceRole *surface_role)
return NULL; return NULL;
} }
MetaWindow *
meta_wayland_surface_get_window (MetaWaylandSurface *surface)
{
return surface->window;
}
static gboolean static gboolean
meta_wayland_surface_role_should_cache_state (MetaWaylandSurfaceRole *surface_role) meta_wayland_surface_role_should_cache_state (MetaWaylandSurfaceRole *surface_role)
{ {

View File

@ -273,6 +273,8 @@ void meta_wayland_surface_update_outputs (MetaWaylandSurface *sur
MetaWaylandSurface *meta_wayland_surface_get_toplevel (MetaWaylandSurface *surface); MetaWaylandSurface *meta_wayland_surface_get_toplevel (MetaWaylandSurface *surface);
MetaWindow * meta_wayland_surface_get_window (MetaWaylandSurface *surface);
gboolean meta_wayland_surface_should_cache_state (MetaWaylandSurface *surface); gboolean meta_wayland_surface_should_cache_state (MetaWaylandSurface *surface);
MetaWindow * meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface); MetaWindow * meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface);

View File

@ -224,10 +224,12 @@ wl_shell_surface_set_state (MetaWaylandSurface *surface,
MetaWaylandWlShellSurface *wl_shell_surface = MetaWaylandWlShellSurface *wl_shell_surface =
META_WAYLAND_WL_SHELL_SURFACE (surface->role); META_WAYLAND_WL_SHELL_SURFACE (surface->role);
MetaWlShellSurfaceState old_state = wl_shell_surface->state; MetaWlShellSurfaceState old_state = wl_shell_surface->state;
MetaWindow *window;
wl_shell_surface->state = state; wl_shell_surface->state = state;
if (surface->window && old_state != state) window = meta_wayland_surface_get_window (surface);
if (window && old_state != state)
{ {
if (old_state == META_WL_SHELL_SURFACE_STATE_POPUP && if (old_state == META_WL_SHELL_SURFACE_STATE_POPUP &&
wl_shell_surface->popup) wl_shell_surface->popup)
@ -237,14 +239,14 @@ wl_shell_surface_set_state (MetaWaylandSurface *surface,
} }
if (state == META_WL_SHELL_SURFACE_STATE_FULLSCREEN) if (state == META_WL_SHELL_SURFACE_STATE_FULLSCREEN)
meta_window_make_fullscreen (surface->window); meta_window_make_fullscreen (window);
else else
meta_window_unmake_fullscreen (surface->window); meta_window_unmake_fullscreen (window);
if (state == META_WL_SHELL_SURFACE_STATE_MAXIMIZED) if (state == META_WL_SHELL_SURFACE_STATE_MAXIMIZED)
meta_window_maximize (surface->window, META_MAXIMIZE_BOTH); meta_window_maximize (window, META_MAXIMIZE_BOTH);
else else
meta_window_unmaximize (surface->window, META_MAXIMIZE_BOTH); meta_window_unmaximize (window, META_MAXIMIZE_BOTH);
} }
} }
@ -302,7 +304,8 @@ wl_shell_surface_set_transient (struct wl_client *client,
wl_shell_surface->x = x; wl_shell_surface->x = x;
wl_shell_surface->y = y; wl_shell_surface->y = y;
if (surface->window && parent_surf->window) if (meta_wayland_surface_get_window (surface) &&
meta_wayland_surface_get_window (parent_surf))
sync_wl_shell_parent_relationship (surface, parent_surf); sync_wl_shell_parent_relationship (surface, parent_surf);
} }
@ -377,7 +380,8 @@ wl_shell_surface_set_popup (struct wl_client *client,
wl_shell_surface->y = y; wl_shell_surface->y = y;
wl_shell_surface->pending_popup = TRUE; wl_shell_surface->pending_popup = TRUE;
if (surface->window && parent_surf->window) if (meta_wayland_surface_get_window (surface) &&
meta_wayland_surface_get_window (parent_surf))
sync_wl_shell_parent_relationship (surface, parent_surf); sync_wl_shell_parent_relationship (surface, parent_surf);
} }
@ -402,6 +406,7 @@ wl_shell_surface_set_title (struct wl_client *client,
META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource)); META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource));
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
surface_from_wl_shell_surface_resource (resource); surface_from_wl_shell_surface_resource (resource);
MetaWindow *window;
g_clear_pointer (&wl_shell_surface->title, g_free); g_clear_pointer (&wl_shell_surface->title, g_free);
@ -410,8 +415,9 @@ wl_shell_surface_set_title (struct wl_client *client,
wl_shell_surface->title = g_strdup (title); wl_shell_surface->title = g_strdup (title);
if (surface->window) window = meta_wayland_surface_get_window (surface);
meta_window_set_title (surface->window, title); if (window)
meta_window_set_title (window, title);
} }
static void static void
@ -423,6 +429,7 @@ wl_shell_surface_set_class (struct wl_client *client,
META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource)); META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource));
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
surface_from_wl_shell_surface_resource (resource); surface_from_wl_shell_surface_resource (resource);
MetaWindow *window;
g_clear_pointer (&wl_shell_surface->wm_class, g_free); g_clear_pointer (&wl_shell_surface->wm_class, g_free);
@ -431,8 +438,9 @@ wl_shell_surface_set_class (struct wl_client *client,
wl_shell_surface->wm_class = g_strdup (class_); wl_shell_surface->wm_class = g_strdup (class_);
if (surface->window) window = meta_wayland_surface_get_window (surface);
meta_window_set_wm_class (surface->window, class_, class_); if (window)
meta_window_set_wm_class (window, class_, class_);
} }
static const struct wl_shell_surface_interface meta_wayland_wl_shell_surface_interface = { static const struct wl_shell_surface_interface meta_wayland_wl_shell_surface_interface = {
@ -454,13 +462,17 @@ sync_wl_shell_parent_relationship (MetaWaylandSurface *surface,
{ {
MetaWaylandWlShellSurface *wl_shell_surface = MetaWaylandWlShellSurface *wl_shell_surface =
META_WAYLAND_WL_SHELL_SURFACE (surface->role); META_WAYLAND_WL_SHELL_SURFACE (surface->role);
MetaWindow *window;
MetaWindow *parent_window;
meta_window_set_transient_for (surface->window, parent->window); window = meta_wayland_surface_get_window (surface);
parent_window = meta_wayland_surface_get_window (parent);
meta_window_set_transient_for (window, parent_window);
if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP || if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP ||
wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_TRANSIENT) wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_TRANSIENT)
meta_window_wayland_place_relative_to (surface->window, meta_window_wayland_place_relative_to (window,
parent->window, parent_window,
wl_shell_surface->x, wl_shell_surface->x,
wl_shell_surface->y); wl_shell_surface->y);
@ -487,21 +499,21 @@ create_wl_shell_surface_window (MetaWaylandSurface *surface)
meta_wayland_shell_surface_set_window (shell_surface, window); meta_wayland_shell_surface_set_window (shell_surface, window);
if (wl_shell_surface->title) if (wl_shell_surface->title)
meta_window_set_title (surface->window, wl_shell_surface->title); meta_window_set_title (window, wl_shell_surface->title);
if (wl_shell_surface->wm_class) if (wl_shell_surface->wm_class)
meta_window_set_wm_class (surface->window, meta_window_set_wm_class (window,
wl_shell_surface->wm_class, wl_shell_surface->wm_class,
wl_shell_surface->wm_class); wl_shell_surface->wm_class);
parent = wl_shell_surface->parent_surface; parent = wl_shell_surface->parent_surface;
if (parent && parent->window) if (parent && meta_wayland_surface_get_window (parent))
sync_wl_shell_parent_relationship (surface, parent); sync_wl_shell_parent_relationship (surface, parent);
for (l = wl_shell_surface->children; l; l = l->next) for (l = wl_shell_surface->children; l; l = l->next)
{ {
MetaWaylandSurface *child = l->data; MetaWaylandSurface *child = l->data;
if (child->window) if (meta_wayland_surface_get_window (child))
sync_wl_shell_parent_relationship (child, surface); sync_wl_shell_parent_relationship (child, surface);
} }
} }
@ -575,7 +587,7 @@ wl_shell_surface_role_apply_state (MetaWaylandSurfaceRole *surface_role,
MetaWaylandSurfaceRoleClass *surface_role_class; MetaWaylandSurfaceRoleClass *surface_role_class;
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaWindow *window = surface->window; MetaWindow *window = meta_wayland_surface_get_window (surface);
cairo_region_t *input_region; cairo_region_t *input_region;
MetaRectangle geom = { 0 }; MetaRectangle geom = { 0 };

View File

@ -144,7 +144,8 @@ xdg_exporter_export (struct wl_client *client,
MetaWaylandXdgExported *exported; MetaWaylandXdgExported *exported;
char *handle; char *handle;
if (!surface->role || !surface->window || if (!surface->role ||
!meta_wayland_surface_get_window (surface) ||
!(META_IS_WAYLAND_XDG_SURFACE (surface->role) || !(META_IS_WAYLAND_XDG_SURFACE (surface->role) ||
META_IS_WAYLAND_ZXDG_SURFACE_V6 (surface->role))) META_IS_WAYLAND_ZXDG_SURFACE_V6 (surface->role)))
{ {
@ -256,7 +257,7 @@ is_valid_child (MetaWaylandSurface *surface)
!META_IS_WAYLAND_ZXDG_TOPLEVEL_V6 (surface->role)) !META_IS_WAYLAND_ZXDG_TOPLEVEL_V6 (surface->role))
return FALSE; return FALSE;
if (!surface->window) if (!meta_wayland_surface_get_window (surface))
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -294,12 +295,18 @@ xdg_imported_set_parent_of (struct wl_client *client,
if (surface) if (surface)
{ {
MetaWindow *window;
MetaWindow *exported_window;
imported->parent_of_unmapped_handler_id = imported->parent_of_unmapped_handler_id =
g_signal_connect (surface, "unmapped", g_signal_connect (surface, "unmapped",
G_CALLBACK (imported_parent_of_unmapped), G_CALLBACK (imported_parent_of_unmapped),
imported); imported);
meta_window_set_transient_for (surface->window,
imported->exported->surface->window); window = meta_wayland_surface_get_window (surface);
exported_window =
meta_wayland_surface_get_window (imported->exported->surface);
meta_window_set_transient_for (window, exported_window);
} }
} }
@ -329,7 +336,7 @@ meta_wayland_xdg_imported_destroy (MetaWaylandXdgImported *imported)
g_clear_signal_handler (&imported->parent_of_unmapped_handler_id, g_clear_signal_handler (&imported->parent_of_unmapped_handler_id,
imported->parent_of); imported->parent_of);
window = imported->parent_of->window; window = meta_wayland_surface_get_window (imported->parent_of);
if (window) if (window)
meta_window_set_transient_for (window, NULL); meta_window_set_transient_for (window, NULL);
} }

View File

@ -196,7 +196,7 @@ xdg_toplevel_set_parent (struct wl_client *client,
MetaWindow *transient_for = NULL; MetaWindow *transient_for = NULL;
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -205,7 +205,7 @@ xdg_toplevel_set_parent (struct wl_client *client,
MetaWaylandSurface *parent_surface = MetaWaylandSurface *parent_surface =
surface_from_xdg_surface_resource (parent_resource); surface_from_xdg_surface_resource (parent_resource);
transient_for = parent_surface->window; transient_for = meta_wayland_surface_get_window (parent_surface);
} }
meta_window_set_transient_for (window, transient_for); meta_window_set_transient_for (window, transient_for);
@ -219,7 +219,7 @@ xdg_toplevel_set_title (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -237,7 +237,7 @@ xdg_toplevel_set_app_id (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -260,7 +260,7 @@ xdg_toplevel_show_window_menu (struct wl_client *client,
MetaWindow *window; MetaWindow *window;
int monitor_scale; int monitor_scale;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -284,7 +284,7 @@ xdg_toplevel_move (struct wl_client *client,
MetaWindow *window; MetaWindow *window;
float x, y; float x, y;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -330,7 +330,7 @@ xdg_toplevel_resize (struct wl_client *client,
gfloat x, y; gfloat x, y;
MetaGrabOp grab_op; MetaGrabOp grab_op;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -398,7 +398,7 @@ xdg_toplevel_set_maximized (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -416,7 +416,7 @@ xdg_toplevel_unset_maximized (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -431,7 +431,7 @@ xdg_toplevel_set_fullscreen (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -456,7 +456,7 @@ xdg_toplevel_unset_fullscreen (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -470,7 +470,7 @@ xdg_toplevel_set_minimized (struct wl_client *client,
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource); MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -604,7 +604,7 @@ fill_states (MetaWaylandXdgToplevel *xdg_toplevel,
META_WAYLAND_SURFACE_ROLE (xdg_toplevel); META_WAYLAND_SURFACE_ROLE (xdg_toplevel);
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaWindow *window = surface->window; MetaWindow *window = meta_wayland_surface_get_window (surface);
if (META_WINDOW_MAXIMIZED (window)) if (META_WINDOW_MAXIMIZED (window))
add_state_value (states, XDG_TOPLEVEL_STATE_MAXIMIZED); add_state_value (states, XDG_TOPLEVEL_STATE_MAXIMIZED);
@ -694,7 +694,7 @@ meta_wayland_xdg_toplevel_apply_state (MetaWaylandSurfaceRole *surface_role,
MetaRectangle old_geometry; MetaRectangle old_geometry;
gboolean geometry_changed; gboolean geometry_changed;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
{ {
meta_wayland_surface_cache_pending_frame_callbacks (surface, pending); meta_wayland_surface_cache_pending_frame_callbacks (surface, pending);
@ -904,9 +904,10 @@ static void
scale_placement_rule (MetaPlacementRule *placement_rule, scale_placement_rule (MetaPlacementRule *placement_rule,
MetaWaylandSurface *surface) MetaWaylandSurface *surface)
{ {
MetaWindow *window = meta_wayland_surface_get_window (surface);
int geometry_scale; int geometry_scale;
geometry_scale = meta_window_wayland_get_geometry_scale (surface->window); geometry_scale = meta_window_wayland_get_geometry_scale (window);
placement_rule->anchor_rect.x *= geometry_scale; placement_rule->anchor_rect.x *= geometry_scale;
placement_rule->anchor_rect.y *= geometry_scale; placement_rule->anchor_rect.y *= geometry_scale;
@ -926,12 +927,13 @@ meta_wayland_xdg_popup_place (MetaWaylandXdgPopup *xdg_popup,
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaPlacementRule scaled_placement_rule; MetaPlacementRule scaled_placement_rule;
MetaWindow *window;
scaled_placement_rule = *placement_rule; scaled_placement_rule = *placement_rule;
scale_placement_rule (&scaled_placement_rule, surface); scale_placement_rule (&scaled_placement_rule, surface);
meta_window_place_with_placement_rule (surface->window, window = meta_wayland_surface_get_window (surface);
&scaled_placement_rule); meta_window_place_with_placement_rule (window, &scaled_placement_rule);
} }
static void static void
@ -958,7 +960,7 @@ finish_popup_setup (MetaWaylandXdgPopup *xdg_popup)
xdg_popup->setup.parent_surface = NULL; xdg_popup->setup.parent_surface = NULL;
xdg_popup->setup.grab_seat = NULL; xdg_popup->setup.grab_seat = NULL;
if (!parent_surface->window) if (!meta_wayland_surface_get_window (parent_surface))
{ {
xdg_popup_send_popup_done (xdg_popup->resource); xdg_popup_send_popup_done (xdg_popup->resource);
return; return;
@ -1065,7 +1067,7 @@ meta_wayland_xdg_popup_apply_state (MetaWaylandSurfaceRole *surface_role,
} }
/* If the window disappeared the surface is not coming back. */ /* If the window disappeared the surface is not coming back. */
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (!window) if (!window)
return; return;
@ -1083,7 +1085,7 @@ meta_wayland_xdg_popup_apply_state (MetaWaylandSurfaceRole *surface_role,
meta_window_wayland_finish_move_resize (window, window_geometry, pending); meta_window_wayland_finish_move_resize (window, window_geometry, pending);
} }
parent_window = xdg_popup->parent_surface->window; parent_window = meta_wayland_surface_get_window (xdg_popup->parent_surface);
meta_window_get_buffer_rect (window, &buffer_rect); meta_window_get_buffer_rect (window, &buffer_rect);
meta_window_get_buffer_rect (parent_window, &parent_buffer_rect); meta_window_get_buffer_rect (parent_window, &parent_buffer_rect);
if (!meta_rectangle_overlap (&buffer_rect, &parent_buffer_rect) && if (!meta_rectangle_overlap (&buffer_rect, &parent_buffer_rect) &&
@ -1126,7 +1128,8 @@ meta_wayland_xdg_popup_configure (MetaWaylandShellSurface *shell_surface,
{ {
MetaWaylandXdgPopup *xdg_popup = META_WAYLAND_XDG_POPUP (shell_surface); MetaWaylandXdgPopup *xdg_popup = META_WAYLAND_XDG_POPUP (shell_surface);
MetaWaylandXdgSurface *xdg_surface = META_WAYLAND_XDG_SURFACE (xdg_popup); MetaWaylandXdgSurface *xdg_surface = META_WAYLAND_XDG_SURFACE (xdg_popup);
MetaWindow *parent_window = xdg_popup->parent_surface->window; MetaWindow *parent_window =
meta_wayland_surface_get_window (xdg_popup->parent_surface);
int geometry_scale; int geometry_scale;
int x, y; int x, y;
@ -1160,7 +1163,8 @@ meta_wayland_xdg_popup_managed (MetaWaylandShellSurface *shell_surface,
g_assert (parent); g_assert (parent);
meta_window_set_transient_for (window, parent->window); meta_window_set_transient_for (window,
meta_wayland_surface_get_window (parent));
meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU); meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU);
} }
@ -1447,7 +1451,7 @@ meta_wayland_xdg_surface_apply_state (MetaWaylandSurfaceRole *surface_role,
meta_wayland_xdg_surface_get_instance_private (xdg_surface); meta_wayland_xdg_surface_get_instance_private (xdg_surface);
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
MetaWindow *window = surface->window; MetaWindow *window = meta_wayland_surface_get_window (surface);
MetaWaylandSurfaceRoleClass *surface_role_class; MetaWaylandSurfaceRoleClass *surface_role_class;
surface_role_class = surface_role_class =

View File

@ -471,7 +471,7 @@ meta_x11_drag_dest_focus_in (MetaWaylandDataDevice *data_device,
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
MetaXWaylandDnd *dnd = compositor->xwayland_manager.dnd; MetaXWaylandDnd *dnd = compositor->xwayland_manager.dnd;
dnd->dnd_dest = surface->window->xwindow; dnd->dnd_dest = meta_wayland_surface_get_window (surface)->xwindow;
xdnd_send_enter (dnd, dnd->dnd_dest); xdnd_send_enter (dnd, dnd->dnd_dest);
} }
@ -619,6 +619,7 @@ repick_drop_surface (MetaWaylandCompositor *compositor,
Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
MetaXWaylandDnd *dnd = compositor->xwayland_manager.dnd; MetaXWaylandDnd *dnd = compositor->xwayland_manager.dnd;
MetaWaylandSurface *focus = NULL; MetaWaylandSurface *focus = NULL;
MetaWindow *focus_window;
focus = pick_drop_surface (compositor, event); focus = pick_drop_surface (compositor, event);
if (dnd->focus_surface == focus) if (dnd->focus_surface == focus)
@ -626,15 +627,20 @@ repick_drop_surface (MetaWaylandCompositor *compositor,
dnd->focus_surface = focus; dnd->focus_surface = focus;
if (focus && if (focus)
focus->window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND) focus_window = meta_wayland_surface_get_window (focus);
else
focus_window = NULL;
if (focus_window &&
focus_window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
{ {
XMapRaised (xdisplay, dnd->dnd_window); XMapRaised (xdisplay, dnd->dnd_window);
XMoveResizeWindow (xdisplay, dnd->dnd_window, XMoveResizeWindow (xdisplay, dnd->dnd_window,
focus->window->rect.x, focus_window->rect.x,
focus->window->rect.y, focus_window->rect.y,
focus->window->rect.width, focus_window->rect.width,
focus->window->rect.height); focus_window->rect.height);
} }
else else
{ {

View File

@ -228,7 +228,7 @@ static void
meta_xwayland_keyboard_grab_activate (MetaXwaylandKeyboardActiveGrab *active_grab) meta_xwayland_keyboard_grab_activate (MetaXwaylandKeyboardActiveGrab *active_grab)
{ {
MetaWaylandSurface *surface = active_grab->surface; MetaWaylandSurface *surface = active_grab->surface;
MetaWindow *window = surface->window; MetaWindow *window = meta_wayland_surface_get_window (surface);
MetaWaylandSeat *seat = active_grab->seat; MetaWaylandSeat *seat = active_grab->seat;
if (meta_xwayland_grab_is_granted (window)) if (meta_xwayland_grab_is_granted (window))
@ -259,7 +259,7 @@ zwp_xwayland_keyboard_grab_manager_grab (struct wl_client *client,
struct wl_resource *seat_resource) struct wl_resource *seat_resource)
{ {
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource); MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
MetaWindow *window = surface->window; MetaWindow *window = meta_wayland_surface_get_window (surface);
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
MetaXwaylandKeyboardActiveGrab *active_grab; MetaXwaylandKeyboardActiveGrab *active_grab;
struct wl_resource *grab_resource; struct wl_resource *grab_resource;

View File

@ -102,7 +102,7 @@ meta_xwayland_surface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
MetaWaylandActorSurfaceClass *actor_surface_class = MetaWaylandActorSurfaceClass *actor_surface_class =
META_WAYLAND_ACTOR_SURFACE_CLASS (meta_xwayland_surface_parent_class); META_WAYLAND_ACTOR_SURFACE_CLASS (meta_xwayland_surface_parent_class);
if (surface->window) if (meta_wayland_surface_get_window (surface))
actor_surface_class->sync_actor_state (actor_surface); actor_surface_class->sync_actor_state (actor_surface);
} }
@ -117,7 +117,7 @@ meta_xwayland_surface_finalize (GObject *object)
G_OBJECT_CLASS (meta_xwayland_surface_parent_class); G_OBJECT_CLASS (meta_xwayland_surface_parent_class);
MetaWindow *window; MetaWindow *window;
window = surface->window; window = meta_wayland_surface_get_window (surface);
if (window) if (window)
{ {
meta_wayland_surface_set_window (surface, NULL); meta_wayland_surface_set_window (surface, NULL);