Server: fix filtering of newly created globals

Fixes: https://codeberg.org/river/river/issues/1068
This commit is contained in:
Isaac Freund 2024-05-15 09:48:55 +02:00
parent bed50f0dd2
commit b5a80c7b9b
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -289,21 +289,17 @@ fn allowlist(server: *Server, global: *const wl.Global) bool {
if (server.drm) |drm| if (global == drm.global) return true; if (server.drm) |drm| if (global == drm.global) return true;
if (server.linux_dmabuf) |linux_dmabuf| if (global == linux_dmabuf.global) return true; if (server.linux_dmabuf) |linux_dmabuf| if (global == linux_dmabuf.global) return true;
{ // We must use the getInterface() approach for dynamically created globals
var it = server.root.all_outputs.iterator(.forward); // such as wl_output and wl_seat since the wl_global_create() function will
while (it.next()) |output| { // advertise the global to clients and invoke this filter before returning
if (global == output.wlr_output.global) return true; // the new global pointer.
} //
} // For other globals I like the current pointer comparison approach as it
// should catch river accidentally exposing multiple copies of e.g. wl_shm
{ // with an assertion failure.
var it = server.input_manager.seats.first; return global.getInterface() == wl.Output.getInterface() or
while (it) |node| : (it = node.next) { global.getInterface() == wl.Seat.getInterface() or
if (global == node.data.wlr_seat.global) return true; global == hackGlobal(server.shm) or
}
}
return global == hackGlobal(server.shm) or
global == hackGlobal(server.single_pixel_buffer_manager) or global == hackGlobal(server.single_pixel_buffer_manager) or
global == server.viewporter.global or global == server.viewporter.global or
global == server.fractional_scale_manager.global or global == server.fractional_scale_manager.global or