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:
parent
a2fdeac9e7
commit
0f195078cb
@ -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);
|
||||||
|
MetaServiceClientType allowed_client_types[] = {
|
||||||
|
META_SERVICE_CLIENT_TYPE_PORTAL_BACKEND,
|
||||||
|
META_SERVICE_CLIENT_TYPE_FILECHOOSER_PORTAL_BACKEND,
|
||||||
|
};
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (allowed_client_types); i++)
|
||||||
|
{
|
||||||
MetaWaylandClient *service_client;
|
MetaWaylandClient *service_client;
|
||||||
|
|
||||||
service_client =
|
service_client =
|
||||||
meta_service_channel_get_service_client (service_channel,
|
meta_service_channel_get_service_client (service_channel,
|
||||||
META_SERVICE_CLIENT_TYPE_PORTAL_BACKEND);
|
allowed_client_types[i]);
|
||||||
|
|
||||||
if (service_client && meta_wayland_client_matches (service_client, client))
|
|
||||||
return META_WAYLAND_ACCESS_ALLOWED;
|
|
||||||
|
|
||||||
service_client =
|
|
||||||
meta_service_channel_get_service_client (service_channel,
|
|
||||||
META_SERVICE_CLIENT_TYPE_FILECHOOSER_PORTAL_BACKEND);
|
|
||||||
if (service_client && meta_wayland_client_matches (service_client, client))
|
if (service_client && meta_wayland_client_matches (service_client, client))
|
||||||
return META_WAYLAND_ACCESS_ALLOWED;
|
return META_WAYLAND_ACCESS_ALLOWED;
|
||||||
|
}
|
||||||
|
|
||||||
return META_WAYLAND_ACCESS_DENIED;
|
return META_WAYLAND_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user