From 567ba5a25e2f69c906aeff783653d26fcf04e0a3 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Mon, 3 Jul 2023 06:38:14 +0200 Subject: [PATCH] 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. --- src/apprt/gtk.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/apprt/gtk.zig b/src/apprt/gtk.zig index a722c8e09..69a9634b4 100644 --- a/src/apprt/gtk.zig +++ b/src/apprt/gtk.zig @@ -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. fn focusCurrentTab(self: *Window) void { const page_idx = c.gtk_notebook_get_current_page(self.notebook); @@ -795,6 +805,10 @@ pub const Surface = struct { c.gtk_widget_show(alert); } + pub fn toggleFullscreen(self: *Surface) void { + self.window.toggleFullscreen(); + } + pub fn newTab(self: *Surface) !void { try self.window.newTab(); }