initial window size needs to take into account window chrome

This commit is contained in:
Mitchell Hashimoto
2023-09-30 21:35:50 -07:00
parent cc8e1cd936
commit a1a8aeb104
6 changed files with 97 additions and 87 deletions

View File

@@ -125,7 +125,8 @@ extension Ghostty {
focus_split_cb: { userdata, direction in AppState.focusSplit(userdata, direction: direction) },
toggle_split_zoom_cb: { userdata in AppState.toggleSplitZoom(userdata) },
goto_tab_cb: { userdata, n in AppState.gotoTab(userdata, n: n) },
toggle_fullscreen_cb: { userdata, nonNativeFullscreen in AppState.toggleFullscreen(userdata, nonNativeFullscreen: nonNativeFullscreen) }
toggle_fullscreen_cb: { userdata, nonNativeFullscreen in AppState.toggleFullscreen(userdata, nonNativeFullscreen: nonNativeFullscreen) },
set_initial_window_size_cb: { userdata, width, height in AppState.setInitialWindowSize(userdata, width: width, height: height) }
)
// Create the ghostty app.
@@ -413,6 +414,12 @@ extension Ghostty {
]
)
}
static func setInitialWindowSize(_ userdata: UnsafeMutableRawPointer?, width: UInt32, height: UInt32) {
// We need a window to set the frame
guard let surfaceView = self.surfaceUserdata(from: userdata) else { return }
surfaceView.initialSize = NSMakeSize(Double(width), Double(height))
}
static func newTab(_ userdata: UnsafeMutableRawPointer?, config: ghostty_surface_config_s) {
guard let surface = self.surfaceUserdata(from: userdata) else { return }