gtk: handle ctrl+return to toggle fullscreen

This is a follow-up to #172 and adds fullscreen handling to the GTK
apprt.

Works reliably for the current window and mimics exactly what happens
when F11 is pressed, which seems to be the standard keybinding for GTK
apps to toggle fullscreen.
This commit is contained in:
Thorsten Ball
2023-07-03 06:38:14 +02:00
parent 8ca9e14d89
commit 567ba5a25e

View File

@ -459,6 +459,16 @@ const Window = struct {
} }
} }
/// Toggle fullscreen for this window.
fn toggleFullscreen(self: *Window) void {
const is_fullscreen = c.gtk_window_is_fullscreen(self.window);
if (is_fullscreen == 0) {
c.gtk_window_fullscreen(self.window);
} else {
c.gtk_window_unfullscreen(self.window);
}
}
/// Grabs focus on the currently selected tab. /// Grabs focus on the currently selected tab.
fn focusCurrentTab(self: *Window) void { fn focusCurrentTab(self: *Window) void {
const page_idx = c.gtk_notebook_get_current_page(self.notebook); const page_idx = c.gtk_notebook_get_current_page(self.notebook);
@ -795,6 +805,10 @@ pub const Surface = struct {
c.gtk_widget_show(alert); c.gtk_widget_show(alert);
} }
pub fn toggleFullscreen(self: *Surface) void {
self.window.toggleFullscreen();
}
pub fn newTab(self: *Surface) !void { pub fn newTab(self: *Surface) !void {
try self.window.newTab(); try self.window.newTab();
} }