mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
gtk: implement quick-terminal-autohide
This commit is contained in:
@ -80,6 +80,7 @@ pub const DerivedConfig = struct {
|
|||||||
gtk_toolbar_style: configpkg.Config.GtkToolbarStyle,
|
gtk_toolbar_style: configpkg.Config.GtkToolbarStyle,
|
||||||
|
|
||||||
quick_terminal_position: configpkg.Config.QuickTerminalPosition,
|
quick_terminal_position: configpkg.Config.QuickTerminalPosition,
|
||||||
|
quick_terminal_autohide: bool,
|
||||||
|
|
||||||
maximize: bool,
|
maximize: bool,
|
||||||
fullscreen: bool,
|
fullscreen: bool,
|
||||||
@ -97,6 +98,7 @@ pub const DerivedConfig = struct {
|
|||||||
.gtk_toolbar_style = config.@"gtk-toolbar-style",
|
.gtk_toolbar_style = config.@"gtk-toolbar-style",
|
||||||
|
|
||||||
.quick_terminal_position = config.@"quick-terminal-position",
|
.quick_terminal_position = config.@"quick-terminal-position",
|
||||||
|
.quick_terminal_autohide = config.@"quick-terminal-autohide",
|
||||||
|
|
||||||
.maximize = config.maximize,
|
.maximize = config.maximize,
|
||||||
.fullscreen = config.fullscreen,
|
.fullscreen = config.fullscreen,
|
||||||
@ -246,6 +248,7 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
|
|
||||||
_ = c.g_signal_connect_data(self.window, "notify::maximized", c.G_CALLBACK(>kWindowNotifyMaximized), self, null, c.G_CONNECT_DEFAULT);
|
_ = c.g_signal_connect_data(self.window, "notify::maximized", c.G_CALLBACK(>kWindowNotifyMaximized), self, null, c.G_CONNECT_DEFAULT);
|
||||||
_ = c.g_signal_connect_data(self.window, "notify::fullscreened", c.G_CALLBACK(>kWindowNotifyFullscreened), self, null, c.G_CONNECT_DEFAULT);
|
_ = c.g_signal_connect_data(self.window, "notify::fullscreened", c.G_CALLBACK(>kWindowNotifyFullscreened), self, null, c.G_CONNECT_DEFAULT);
|
||||||
|
_ = c.g_signal_connect_data(self.window, "notify::is-active", c.G_CALLBACK(>kWindowNotifyIsActive), self, null, c.G_CONNECT_DEFAULT);
|
||||||
|
|
||||||
// If Adwaita is enabled and is older than 1.4.0 we don't have the tab overview and so we
|
// If Adwaita is enabled and is older than 1.4.0 we don't have the tab overview and so we
|
||||||
// need to stick the headerbar into the content box.
|
// need to stick the headerbar into the content box.
|
||||||
@ -728,6 +731,20 @@ fn gtkWindowNotifyFullscreened(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn gtkWindowNotifyIsActive(
|
||||||
|
_: *c.GObject,
|
||||||
|
_: *c.GParamSpec,
|
||||||
|
ud: ?*anyopaque,
|
||||||
|
) callconv(.C) void {
|
||||||
|
const self = userdataSelf(ud orelse return);
|
||||||
|
if (!self.isQuickTerminal()) return;
|
||||||
|
|
||||||
|
// Hide when we're unfocused
|
||||||
|
if (self.config.quick_terminal_autohide and c.gtk_window_is_active(self.window) == 0) {
|
||||||
|
self.toggleVisibility();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Note: we MUST NOT use the GtkButton parameter because gtkActionNewTab
|
// Note: we MUST NOT use the GtkButton parameter because gtkActionNewTab
|
||||||
// sends an undefined value.
|
// sends an undefined value.
|
||||||
fn gtkTabNewClick(_: *c.GtkButton, ud: ?*anyopaque) callconv(.C) void {
|
fn gtkTabNewClick(_: *c.GtkButton, ud: ?*anyopaque) callconv(.C) void {
|
||||||
|
@ -1677,8 +1677,6 @@ keybind: Keybinds = .{},
|
|||||||
|
|
||||||
/// Automatically hide the quick terminal when focus shifts to another window.
|
/// Automatically hide the quick terminal when focus shifts to another window.
|
||||||
/// Set it to false for the quick terminal to remain open even when it loses focus.
|
/// Set it to false for the quick terminal to remain open even when it loses focus.
|
||||||
///
|
|
||||||
/// Only implemented on macOS.
|
|
||||||
@"quick-terminal-autohide": bool = true,
|
@"quick-terminal-autohide": bool = true,
|
||||||
|
|
||||||
/// This configuration option determines the behavior of the quick terminal
|
/// This configuration option determines the behavior of the quick terminal
|
||||||
|
Reference in New Issue
Block a user