Add config setting to turn non-native fullscreen on or off

This commit is contained in:
Thorsten Ball
2023-07-29 21:05:49 +02:00
committed by Mitchell Hashimoto
parent 850bf3e945
commit b56ffa6285
9 changed files with 45 additions and 14 deletions

View File

@@ -146,6 +146,7 @@ const DerivedConfig = struct {
clipboard_trim_trailing_spaces: bool,
confirm_close_surface: bool,
mouse_interval: u64,
macos_non_native_fullscreen: bool,
pub fn init(alloc_gpa: Allocator, config: *const configpkg.Config) !DerivedConfig {
var arena = ArenaAllocator.init(alloc_gpa);
@@ -160,6 +161,7 @@ const DerivedConfig = struct {
.clipboard_trim_trailing_spaces = config.@"clipboard-trim-trailing-spaces",
.confirm_close_surface = config.@"confirm-close-surface",
.mouse_interval = config.@"click-repeat-interval" * 1_000_000, // 500ms
.macos_non_native_fullscreen = config.@"macos-non-native-fullscreen",
// Assignments happen sequentially so we have to do this last
// so that the memory is captured from allocs above.
@@ -1213,7 +1215,7 @@ pub fn keyCallback(
.toggle_fullscreen => {
if (@hasDecl(apprt.Surface, "toggleFullscreen")) {
self.rt_surface.toggleFullscreen();
self.rt_surface.toggleFullscreen(self.config.macos_non_native_fullscreen);
} else log.warn("runtime doesn't implement toggleFullscreen", .{});
},

View File

@@ -66,7 +66,7 @@ pub const App = struct {
goto_tab: ?*const fn (SurfaceUD, usize) callconv(.C) void = null,
/// Toggle fullscreen for current window.
toggle_fullscreen: ?*const fn (SurfaceUD) callconv(.C) void = null,
toggle_fullscreen: ?*const fn (SurfaceUD, bool) callconv(.C) void = null,
};
core_app: *CoreApp,
@@ -374,13 +374,13 @@ pub const Surface = struct {
func(self.opts.userdata, n);
}
pub fn toggleFullscreen(self: *Surface) void {
pub fn toggleFullscreen(self: *Surface, nonNativeFullscreen: bool) void {
const func = self.app.opts.toggle_fullscreen orelse {
log.info("runtime embedder does not toggle_fullscreen", .{});
return;
};
func(self.opts.userdata);
func(self.opts.userdata, nonNativeFullscreen);
}
/// The cursor position from the host directly is in screen coordinates but

View File

@@ -483,7 +483,7 @@ const Window = struct {
}
/// Toggle fullscreen for this window.
fn toggleFullscreen(self: *Window) void {
fn toggleFullscreen(self: *Window, _: bool) void {
const is_fullscreen = c.gtk_window_is_fullscreen(self.window);
if (is_fullscreen == 0) {
c.gtk_window_fullscreen(self.window);

View File

@@ -221,6 +221,12 @@ pub const Config = struct {
/// The default value is "detect".
@"shell-integration": ShellIntegration = .detect,
/// If true, fullscreen mode on macOS will not use the native fullscreen,
/// but make the window fullscreen without animations and using a new space.
/// That's faster than the native fullscreen mode since it doesn't use
/// animations.
@"macos-non-native-fullscreen": bool = false,
/// This is set by the CLI parser for deinit.
_arena: ?ArenaAllocator = null,