mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
fix: Disable quick terminal on linux when gtk4-layer-shell version is incompatible
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
const c = @cImport({
|
const c = @cImport({
|
||||||
@cInclude("gtk4-layer-shell.h");
|
@cInclude("gtk4-layer-shell.h");
|
||||||
});
|
});
|
||||||
|
const std = @import("std");
|
||||||
const gtk = @import("gtk");
|
const gtk = @import("gtk");
|
||||||
|
|
||||||
pub const ShellLayer = enum(c_uint) {
|
pub const ShellLayer = enum(c_uint) {
|
||||||
@ -23,14 +24,27 @@ pub const KeyboardMode = enum(c_uint) {
|
|||||||
on_demand = c.GTK_LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND,
|
on_demand = c.GTK_LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Returns True if the platform is Wayland and Wayland compositor supports the
|
||||||
|
/// zwlr_layer_shell_v1 protocol.
|
||||||
pub fn isProtocolSupported() bool {
|
pub fn isProtocolSupported() bool {
|
||||||
return c.gtk_layer_is_supported() != 0;
|
return c.gtk_layer_is_supported() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the version of the zwlr_layer_shell_v1 protocol supported by the
|
||||||
|
/// compositor or 0 if the protocol is not supported.
|
||||||
pub fn getProtocolVersion() c_uint {
|
pub fn getProtocolVersion() c_uint {
|
||||||
return c.gtk_layer_get_protocol_version();
|
return c.gtk_layer_get_protocol_version();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the runtime version of the GTK Layer Shell library
|
||||||
|
pub fn getRuntimeVersion() std.SemanticVersion {
|
||||||
|
return std.SemanticVersion{
|
||||||
|
.major = c.gtk_layer_get_major_version(),
|
||||||
|
.minor = c.gtk_layer_get_minor_version(),
|
||||||
|
.patch = c.gtk_layer_get_micro_version(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn initForWindow(window: *gtk.Window) void {
|
pub fn initForWindow(window: *gtk.Window) void {
|
||||||
c.gtk_layer_init_for_window(@ptrCast(window));
|
c.gtk_layer_init_for_window(@ptrCast(window));
|
||||||
}
|
}
|
||||||
|
10
src/apprt/gtk/gtk_layer_version.zig
Normal file
10
src/apprt/gtk/gtk_layer_version.zig
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const gtk4_layer_shell = @import("gtk4-layer-shell");
|
||||||
|
const VersionChecked = @import("version.zig").VersionChecked;
|
||||||
|
|
||||||
|
pub const getRuntimeVersion = gtk4_layer_shell.getRuntimeVersion;
|
||||||
|
const LayerShellVersion = VersionChecked("gtk4-layer-shell", std.log.scoped(.gtk), getRuntimeVersion, null);
|
||||||
|
|
||||||
|
pub const atLeast = LayerShellVersion.atLeast;
|
||||||
|
pub const runtimeAtLeast = LayerShellVersion.runtimeAtLeast;
|
||||||
|
pub const logVersion = LayerShellVersion.logVersion;
|
@ -10,6 +10,8 @@ const gtk = @import("gtk");
|
|||||||
const layer_shell = @import("gtk4-layer-shell");
|
const layer_shell = @import("gtk4-layer-shell");
|
||||||
const wayland = @import("wayland");
|
const wayland = @import("wayland");
|
||||||
|
|
||||||
|
const gtk_version = @import("../gtk_version.zig");
|
||||||
|
const gtk_layer_version = @import("../gtk_layer_version.zig");
|
||||||
const Config = @import("../../../config.zig").Config;
|
const Config = @import("../../../config.zig").Config;
|
||||||
const input = @import("../../../input.zig");
|
const input = @import("../../../input.zig");
|
||||||
const ApprtWindow = @import("../Window.zig");
|
const ApprtWindow = @import("../Window.zig");
|
||||||
@ -37,6 +39,7 @@ pub const App = struct {
|
|||||||
default_deco_mode: ?org.KdeKwinServerDecorationManager.Mode = null,
|
default_deco_mode: ?org.KdeKwinServerDecorationManager.Mode = null,
|
||||||
|
|
||||||
xdg_activation: ?*xdg.ActivationV1 = null,
|
xdg_activation: ?*xdg.ActivationV1 = null,
|
||||||
|
xdg_wm_dialog: ?*xdg.WmDialogV1 = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
@ -95,11 +98,19 @@ pub const App = struct {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn supportsQuickTerminal(_: App) bool {
|
pub fn supportsQuickTerminal(self: App) bool {
|
||||||
if (!layer_shell.isProtocolSupported()) {
|
if (!layer_shell.isProtocolSupported()) {
|
||||||
log.warn("your compositor does not support the wlr-layer-shell protocol; disabling quick terminal", .{});
|
log.warn("your compositor does not support the wlr-layer-shell protocol; disabling quick terminal", .{});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// GTK4 >= 4.16.0 uses xdg_wm_dialog protocol if available which breaks gtk_layer_shell < 1.0.4
|
||||||
|
// See: https://github.com/wmww/gtk4-layer-shell/issues/50
|
||||||
|
if (self.context.xdg_wm_dialog) |_| {
|
||||||
|
if (gtk_version.atLeast(4, 16, 0) and !gtk_layer_version.atLeast(1, 0, 4)) {
|
||||||
|
log.warn("Your gtk4-layer-shell version is too old for your compositor and gtk4 version; disabling quick terminal", .{});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,12 +620,15 @@ fn addGTK(
|
|||||||
plasma_wayland_protocols_dep.path("src/protocols/slide.xml"),
|
plasma_wayland_protocols_dep.path("src/protocols/slide.xml"),
|
||||||
);
|
);
|
||||||
scanner.addSystemProtocol("staging/xdg-activation/xdg-activation-v1.xml");
|
scanner.addSystemProtocol("staging/xdg-activation/xdg-activation-v1.xml");
|
||||||
|
scanner.addCustomProtocol(wayland_protocols_dep.path("staging/xdg-dialog/xdg-dialog-v1.xml"));
|
||||||
|
scanner.addCustomProtocol(wayland_protocols_dep.path("stable/xdg-shell/xdg-shell.xml"));
|
||||||
|
|
||||||
scanner.generate("wl_compositor", 1);
|
scanner.generate("wl_compositor", 1);
|
||||||
scanner.generate("org_kde_kwin_blur_manager", 1);
|
scanner.generate("org_kde_kwin_blur_manager", 1);
|
||||||
scanner.generate("org_kde_kwin_server_decoration_manager", 1);
|
scanner.generate("org_kde_kwin_server_decoration_manager", 1);
|
||||||
scanner.generate("org_kde_kwin_slide_manager", 1);
|
scanner.generate("org_kde_kwin_slide_manager", 1);
|
||||||
scanner.generate("xdg_activation_v1", 1);
|
scanner.generate("xdg_activation_v1", 1);
|
||||||
|
scanner.generate("xdg_wm_dialog_v1", 1);
|
||||||
|
|
||||||
step.root_module.addImport("wayland", b.createModule(.{
|
step.root_module.addImport("wayland", b.createModule(.{
|
||||||
.root_source_file = scanner.result,
|
.root_source_file = scanner.result,
|
||||||
|
Reference in New Issue
Block a user