wayland: Move surface check to MetaWaylandSurface

Allows dropping various HAVE_XWAYLAND ifdef as the function would always
return false if Mutter is built without XWayland

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
This commit is contained in:
Bilal Elmoussaoui 2022-06-01 10:45:20 +02:00
parent a27b9d9707
commit 02a436d607
7 changed files with 21 additions and 25 deletions

View File

@ -92,8 +92,7 @@ cursor_sprite_prepare_at (MetaCursorSprite *cursor_sprite,
MetaWaylandSurfaceRole *role = META_WAYLAND_SURFACE_ROLE (cursor_surface);
MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (role);
#ifdef HAVE_XWAYLAND
if (!meta_xwayland_is_xwayland_surface (surface))
if (!meta_wayland_surface_is_xwayland (surface))
{
MetaWaylandSurfaceRole *surface_role =
META_WAYLAND_SURFACE_ROLE (cursor_surface);
@ -123,7 +122,6 @@ cursor_sprite_prepare_at (MetaCursorSprite *cursor_sprite,
surface->buffer_transform);
}
}
#endif
meta_wayland_surface_update_outputs (surface);
}

View File

@ -193,7 +193,7 @@ surface_constraint_data_new (MetaWaylandSurface *surface)
connect_window (data, window);
}
#ifdef HAVE_XWAYLAND
else if (meta_xwayland_is_xwayland_surface (surface))
else if (meta_wayland_surface_is_xwayland (surface))
{
data->window_associated_handler_id =
g_signal_connect (surface->role, "window-associated",
@ -475,7 +475,7 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
* For subsurfaces the window of the ancestor might be gone already.
*/
#ifdef HAVE_XWAYLAND
g_warn_if_fail (meta_xwayland_is_xwayland_surface (constraint->surface) ||
g_warn_if_fail (meta_wayland_surface_is_xwayland (constraint->surface) ||
META_IS_WAYLAND_SUBSURFACE (constraint->surface->role));
#endif
return FALSE;
@ -488,8 +488,7 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
if (constraint->seat->pointer->focus_surface != constraint->surface)
return FALSE;
#ifdef HAVE_XWAYLAND
if (meta_xwayland_is_xwayland_surface (constraint->surface))
if (meta_wayland_surface_is_xwayland (constraint->surface))
{
MetaDisplay *display = meta_window_get_display (window);
@ -511,7 +510,6 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
display->focus_window->client_type != META_WINDOW_CLIENT_TYPE_X11)
return FALSE;
}
#endif
if (!meta_window_appears_focused (window))
return FALSE;
@ -632,9 +630,7 @@ meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerCo
MetaFrame *frame = window->frame;
int actual_width, actual_height;
#ifdef HAVE_XWAYLAND
g_assert (meta_xwayland_is_xwayland_surface (constraint->surface));
#endif
g_assert (meta_wayland_surface_is_xwayland (constraint->surface));
actual_width = window->buffer_rect.width - (frame->child_x +
frame->right_width);

View File

@ -2396,3 +2396,17 @@ meta_wayland_surface_get_compositor (MetaWaylandSurface *surface)
{
return surface->compositor;
}
gboolean
meta_wayland_surface_is_xwayland (MetaWaylandSurface *surface)
{
#ifdef HAVE_XWAYLAND
MetaWaylandCompositor *compositor = surface->compositor;
MetaXWaylandManager *manager = &compositor->xwayland_manager;
return surface->resource != NULL &&
wl_resource_get_client (surface->resource) == manager->client;
#else
return FALSE;
#endif
}

View File

@ -419,6 +419,7 @@ meta_wayland_surface_state_new (void)
{
return g_object_new (META_TYPE_WAYLAND_SURFACE_STATE, NULL);
}
gboolean meta_wayland_surface_is_xwayland (MetaWaylandSurface *surface);
static inline GNode *
meta_get_next_subsurface_sibling (GNode *n)

View File

@ -1033,7 +1033,7 @@ meta_xwayland_dnd_handle_xfixes_selection_notify (MetaWaylandCompositor *composi
focus = compositor->seat->pointer->focus_surface;
if (event->owner != None && event->owner != x11_display->selection.xwindow &&
focus && meta_xwayland_is_xwayland_surface (focus))
focus && meta_wayland_surface_is_xwayland (focus))
{
dnd->source = meta_wayland_data_source_xwayland_new (dnd, compositor);
meta_wayland_data_device_set_dnd_source (&compositor->seat->data_device,

View File

@ -146,16 +146,6 @@ meta_xwayland_handle_wl_surface_id (MetaWindow *window,
}
}
gboolean
meta_xwayland_is_xwayland_surface (MetaWaylandSurface *surface)
{
MetaWaylandCompositor *compositor = surface->compositor;
MetaXWaylandManager *manager = &compositor->xwayland_manager;
return surface->resource != NULL &&
wl_resource_get_client (surface->resource) == manager->client;
}
static gboolean
try_display (int display,
char **filename_out,

View File

@ -39,9 +39,6 @@ void
meta_xwayland_handle_wl_surface_id (MetaWindow *window,
guint32 surface_id);
gboolean
meta_xwayland_is_xwayland_surface (MetaWaylandSurface *surface);
void
meta_xwayland_handle_xwayland_grab (MetaWindow *window,
gboolean allow);