river: only expose xwayland_shell_v1 to Xwayland

This is a private protocol only intended for the Xwayland client.
This commit is contained in:
Isaac Freund 2024-03-02 17:37:04 +01:00
parent 0eacde7d01
commit 60f4cafad0
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -168,6 +168,8 @@ pub fn init(self: *Self, runtime_xwayland: bool) !void {
_ = try wlr.SinglePixelBufferManagerV1.create(self.wl_server);
_ = try wlr.Viewporter.create(self.wl_server);
_ = try wlr.FractionalScaleManagerV1.create(self.wl_server, 1);
self.wl_server.setGlobalFilter(*Self, globalFilter, self);
}
/// Free allocated memory and clean up. Note: order is important here
@ -222,6 +224,22 @@ pub fn start(self: Self) !void {
}
}
fn globalFilter(client: *const wl.Client, global: *const wl.Global, self: *Self) bool {
// Only expose the xwalyand_shell_v1 global to the Xwayland process.
if (build_options.xwayland) {
if (self.xwayland) |xwayland| {
if (global == xwayland.shell_v1.global) {
if (xwayland.server) |server| {
return client == server.client;
}
return false;
}
}
}
return true;
}
/// Handle SIGINT and SIGTERM by gracefully stopping the server
fn terminate(_: c_int, wl_server: *wl.Server) c_int {
wl_server.terminate();