wayland/x11-interop: Make allow list more declarative

Declare allowed service client types in a list, and loop through them,
instead of doing it manually.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4173>
This commit is contained in:
Jonas Ådahl 2024-12-06 09:16:59 +01:00 committed by Marge Bot
parent a2fdeac9e7
commit 0f195078cb

View File

@ -96,20 +96,22 @@ x11_interop_filter (const struct wl_client *client,
MetaContext *context = meta_wayland_compositor_get_context (compositor); MetaContext *context = meta_wayland_compositor_get_context (compositor);
MetaServiceChannel *service_channel = MetaServiceChannel *service_channel =
meta_context_get_service_channel (context); meta_context_get_service_channel (context);
MetaWaylandClient *service_client; MetaServiceClientType allowed_client_types[] = {
META_SERVICE_CLIENT_TYPE_PORTAL_BACKEND,
META_SERVICE_CLIENT_TYPE_FILECHOOSER_PORTAL_BACKEND,
};
size_t i;
service_client = for (i = 0; i < G_N_ELEMENTS (allowed_client_types); i++)
meta_service_channel_get_service_client (service_channel, {
META_SERVICE_CLIENT_TYPE_PORTAL_BACKEND); MetaWaylandClient *service_client;
if (service_client && meta_wayland_client_matches (service_client, client)) service_client =
return META_WAYLAND_ACCESS_ALLOWED; meta_service_channel_get_service_client (service_channel,
allowed_client_types[i]);
service_client = if (service_client && meta_wayland_client_matches (service_client, client))
meta_service_channel_get_service_client (service_channel, return META_WAYLAND_ACCESS_ALLOWED;
META_SERVICE_CLIENT_TYPE_FILECHOOSER_PORTAL_BACKEND); }
if (service_client && meta_wayland_client_matches (service_client, client))
return META_WAYLAND_ACCESS_ALLOWED;
return META_WAYLAND_ACCESS_DENIED; return META_WAYLAND_ACCESS_DENIED;
} }