gtk(wayland): fallback when on-demand mode isn't supported

This shouldn't be a real problem anymore since as of now (May 2025)
all major compositors support at least version 4, but let's do this
just in case.
This commit is contained in:
Leah Amelia Chen
2025-05-30 14:44:29 +02:00
parent 4d18c06804
commit 6fac355363
2 changed files with 11 additions and 1 deletions

View File

@@ -27,6 +27,10 @@ pub fn isSupported() bool {
return c.gtk_layer_is_supported() != 0;
}
pub fn getProtocolVersion() c_uint {
return c.gtk_layer_get_protocol_version();
}
pub fn initForWindow(window: *gtk.Window) void {
c.gtk_layer_init_for_window(@ptrCast(window));
}

View File

@@ -369,7 +369,13 @@ pub const Window = struct {
window,
switch (config.quick_terminal_keyboard_interactivity) {
.none => .none,
.@"on-demand" => .on_demand,
.@"on-demand" => on_demand: {
if (gtk4_layer_shell.getProtocolVersion() < 4) {
log.warn("your compositor does not support on-demand keyboard access; falling back to exclusive access", .{});
break :on_demand .exclusive;
}
break :on_demand .on_demand;
},
.exclusive => .exclusive,
},
);