From d94dec2384c0fb4b147bce134b139cf4a70fdc55 Mon Sep 17 00:00:00 2001 From: Daniel Fox Date: Thu, 9 Jan 2025 14:43:05 -0800 Subject: [PATCH 1/4] Add gtk-tabs-can-focus bool config --- src/config/Config.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/config/Config.zig b/src/config/Config.zig index 1e1bca74af..0a295dff9c 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -2132,6 +2132,16 @@ keybind: Keybinds = .{}, /// and shown when the titlebar is unmaximized. GTK only. @"gtk-titlebar-hide-when-maximized": bool = false, +/// Determines whether or not we allow the tabs in the tab bar to be focussed. +/// +/// If true (the default), users can focus tabs in the tab bar by clicking them, +/// and then use arrow keys to navigate, but focus in the main surface will be +/// lost, requiring the user to change focus back in order to use the terminal. +/// +/// If false, the tab bar will never take focus, keeping the focus on the main +/// window surface. +@"gtk-tabs-can-focus": bool = true, + /// Determines the appearance of the top and bottom bars when using the /// Adwaita tab bar. This requires `gtk-adwaita` to be enabled (it is /// by default). From 1e579c0dbde2b7f2e1048afaa8e516dc33b415f6 Mon Sep 17 00:00:00 2001 From: Daniel Fox Date: Thu, 9 Jan 2025 14:44:43 -0800 Subject: [PATCH 2/4] Add gtk-tabs-can-focus functionality --- src/apprt/gtk/Window.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index 58f5659f0d..2acbd589aa 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -294,6 +294,10 @@ pub fn init(self: *Window, app: *App) !void { const tab_bar = c.adw_tab_bar_new(); c.adw_tab_bar_set_view(tab_bar, self.notebook.adw.tab_view); + if (!app.config.@"gtk-tabs-can-focus") { + c.gtk_widget_set_can_focus(@ptrCast(@alignCast(tab_bar)), 0); + } + if (!app.config.@"gtk-wide-tabs") c.adw_tab_bar_set_expand_tabs(tab_bar, 0); const tab_bar_widget: *c.GtkWidget = @ptrCast(@alignCast(tab_bar)); @@ -348,6 +352,10 @@ pub fn init(self: *Window, app: *App) !void { } c.adw_tab_bar_set_view(tab_bar, adw.tab_view); + if (!app.config.@"gtk-tabs-can-focus") { + c.gtk_widget_set_can_focus(@ptrCast(@alignCast(tab_bar)), 0); + } + if (!app.config.@"gtk-wide-tabs") c.adw_tab_bar_set_expand_tabs(tab_bar, 0); }, From 7c6fac10916c0f30c6a91d0f55459f870548a7d6 Mon Sep 17 00:00:00 2001 From: Daniel Fox Date: Tue, 28 Jan 2025 12:01:10 -0800 Subject: [PATCH 3/4] Revert "Add gtk-tabs-can-focus bool config" This reverts commit d94dec2384c0fb4b147bce134b139cf4a70fdc55. --- src/config/Config.zig | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/config/Config.zig b/src/config/Config.zig index 0a295dff9c..1e1bca74af 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -2132,16 +2132,6 @@ keybind: Keybinds = .{}, /// and shown when the titlebar is unmaximized. GTK only. @"gtk-titlebar-hide-when-maximized": bool = false, -/// Determines whether or not we allow the tabs in the tab bar to be focussed. -/// -/// If true (the default), users can focus tabs in the tab bar by clicking them, -/// and then use arrow keys to navigate, but focus in the main surface will be -/// lost, requiring the user to change focus back in order to use the terminal. -/// -/// If false, the tab bar will never take focus, keeping the focus on the main -/// window surface. -@"gtk-tabs-can-focus": bool = true, - /// Determines the appearance of the top and bottom bars when using the /// Adwaita tab bar. This requires `gtk-adwaita` to be enabled (it is /// by default). From b56dc8724d04c032c80ad64c5f38774d426971fe Mon Sep 17 00:00:00 2001 From: Daniel Fox Date: Tue, 28 Jan 2025 12:01:24 -0800 Subject: [PATCH 4/4] Remove references to configuration option --- src/apprt/gtk/Window.zig | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index 2acbd589aa..551de3495d 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -294,9 +294,7 @@ pub fn init(self: *Window, app: *App) !void { const tab_bar = c.adw_tab_bar_new(); c.adw_tab_bar_set_view(tab_bar, self.notebook.adw.tab_view); - if (!app.config.@"gtk-tabs-can-focus") { - c.gtk_widget_set_can_focus(@ptrCast(@alignCast(tab_bar)), 0); - } + c.gtk_widget_set_can_focus(@ptrCast(@alignCast(tab_bar)), 0); if (!app.config.@"gtk-wide-tabs") c.adw_tab_bar_set_expand_tabs(tab_bar, 0); @@ -352,9 +350,7 @@ pub fn init(self: *Window, app: *App) !void { } c.adw_tab_bar_set_view(tab_bar, adw.tab_view); - if (!app.config.@"gtk-tabs-can-focus") { - c.gtk_widget_set_can_focus(@ptrCast(@alignCast(tab_bar)), 0); - } + c.gtk_widget_set_can_focus(@ptrCast(@alignCast(tab_bar)), 0); if (!app.config.@"gtk-wide-tabs") c.adw_tab_bar_set_expand_tabs(tab_bar, 0); },