bind: add toggle_tab_overview binding

This commit is contained in:
Paul Berg
2024-09-27 09:36:45 +02:00
committed by Mitchell Hashimoto
parent 7b8b58110c
commit f1474c220d
6 changed files with 42 additions and 0 deletions

View File

@ -3830,6 +3830,12 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
{},
),
.toggle_tab_overview => try self.rt_app.performAction(
.{ .surface = self },
.toggle_tab_overview,
{},
),
.toggle_secure_input => try self.rt_app.performAction(
.{ .surface = self },
.secure_input,

View File

@ -87,6 +87,9 @@ pub const Action = union(Key) {
/// Toggle fullscreen mode.
toggle_fullscreen: Fullscreen,
/// Toggle tab overview.
toggle_tab_overview,
/// Toggle whether window directions are shown.
toggle_window_decorations,

View File

@ -194,6 +194,7 @@ pub const App = struct {
.toggle_split_zoom,
.present_terminal,
.close_all_windows,
.toggle_tab_overview,
.toggle_window_decorations,
.goto_tab,
.inspector,

View File

@ -372,6 +372,7 @@ pub fn performAction(
.mouse_visibility => self.setMouseVisibility(target, value),
.mouse_shape => try self.setMouseShape(target, value),
.mouse_over_link => self.setMouseOverLink(target, value),
.toggle_tab_overview => self.toggleTabOverview(target),
.toggle_window_decorations => self.toggleWindowDecorations(target),
.quit_timer => self.quitTimer(value),
@ -534,6 +535,23 @@ fn toggleFullscreen(
}
}
fn toggleTabOverview(_: *App, target: apprt.Target) void {
switch (target) {
.app => {},
.surface => |v| {
const window = v.rt_surface.container.window() orelse {
log.info(
"toggleTabOverview invalid for container={s}",
.{@tagName(v.rt_surface.container)},
);
return;
};
window.toggleTabOverview();
},
}
}
fn toggleWindowDecorations(
_: *App,
target: apprt.Target,

View File

@ -457,6 +457,15 @@ pub fn gotoTab(self: *Window, n: usize) void {
}
}
/// Toggle tab overview (if present)
pub fn toggleTabOverview(self: *Window) void {
if (self.tab_overview) |tab_overview_widget| {
if (comptime !adwaita.versionAtLeast(1, 4, 0)) unreachable;
const tab_overview: *c.AdwTabOverview = @ptrCast(@alignCast(tab_overview_widget));
c.adw_tab_overview_set_open(tab_overview, 1 - c.adw_tab_overview_get_open(tab_overview));
}
}
/// Toggle fullscreen for this window.
pub fn toggleFullscreen(self: *Window) void {
const is_fullscreen = c.gtk_window_is_fullscreen(self.window);

View File

@ -298,6 +298,10 @@ pub const Action = union(enum) {
/// Go to the tab with the specific number, 1-indexed.
goto_tab: usize,
/// Toggle the tab overview.
/// This only works with libadwaita enabled currently.
toggle_tab_overview: void,
/// Create a new split in the given direction. The new split will appear in
/// the direction given.
new_split: SplitDirection,
@ -607,6 +611,7 @@ pub const Action = union(enum) {
.next_tab,
.last_tab,
.goto_tab,
.toggle_tab_overview,
.new_split,
.goto_split,
.toggle_split_zoom,