From 568f1f9d720365ee6e5d7b3c71c85b5f9774ccf9 Mon Sep 17 00:00:00 2001 From: Adam Wolf Date: Sun, 29 Dec 2024 21:33:44 -0600 Subject: [PATCH] chore: removed setInitialWindowPosition from gtk and renamed window-position-{x,y} to start-position-{x,y} for clarity --- src/Surface.zig | 4 ++-- src/apprt/gtk/App.zig | 15 --------------- src/apprt/gtk/Surface.zig | 6 ------ src/config/Config.zig | 7 +++++-- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index ace392bb3..ccc3ba0ce 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -621,8 +621,8 @@ pub fn init( const width = @max(config.@"window-width" * cell_size.width, 640); const width_f32: f32 = @floatFromInt(width); const height_f32: f32 = @floatFromInt(height); - const position_x = config.@"window-position-x"; - const position_y = config.@"window-position-y"; + const position_x = config.@"start-position-x"; + const position_y = config.@"start-position-y"; // The final values are affected by content scale and we need to // account for the padding so we get the exact correct grid size. diff --git a/src/apprt/gtk/App.zig b/src/apprt/gtk/App.zig index c7331968f..3d05bc2c5 100644 --- a/src/apprt/gtk/App.zig +++ b/src/apprt/gtk/App.zig @@ -474,7 +474,6 @@ pub fn performAction( .pwd => try self.setPwd(target, value), .present_terminal => self.presentTerminal(target), .initial_size => try self.setInitialSize(target, value), - .initial_position => self.setInitialPosition(target, value), .mouse_visibility => self.setMouseVisibility(target, value), .mouse_shape => try self.setMouseShape(target, value), .mouse_over_link => self.setMouseOverLink(target, value), @@ -788,20 +787,6 @@ fn setInitialSize( } } -fn setInitialPosition( - _: *App, - target: apprt.Target, - value: apprt.action.InitialPosition, -) void { - switch (target) { - .app => {}, - .surface => |v| try v.rt_surface.setInitialWindowPosition( - value.x, - value.y, - ), - } -} - fn showDesktopNotification( self: *App, target: apprt.Target, diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index 546d5ac33..079cdbd81 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -840,12 +840,6 @@ pub fn setInitialWindowSize(self: *const Surface, width: u32, height: u32) !void ); } -pub fn setInitialWindowPosition(self: *const Surface, x: i32, y: i32) !void { - // We need the surface's window to set the position. - const window = self.container.window() orelse return; - c.gtk_window_move(@ptrCast(window.window), x, y); -} - pub fn grabFocus(self: *Surface) void { if (self.container.tab()) |tab| { // If any other surface was focused and zoomed in, set it to non zoomed in diff --git a/src/config/Config.zig b/src/config/Config.zig index 13a25ad5a..5ff110cf4 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -1117,9 +1117,12 @@ keybind: Keybinds = .{}, /// to be a certain position to fit within the grid. There is nothing Ghostty /// will do about this, but it will make an effort. /// +/// Important note: Setting this value will only work on macOs and glfw builds +/// on Linux. GTK 4.0 does not support setting the window position. +/// /// This will default to the top-left corner of the screen if not set (0, 0). -@"window-position-x": i32 = 0, -@"window-position-y": i32 = 0, +@"start-position-x": i32 = 0, +@"start-position-y": i32 = 0, /// Whether to enable saving and restoring window state. Window state includes /// their position, size, tabs, splits, etc. Some window state requires shell