mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-22 00:51:23 +00:00
macos: set window resizeIncrements when cell size changes
The resizeIncrements property is only modified when the cell size of the focused window changes. If two splits have the same cell size then the property is not modified when focusing between the two splits.
This commit is contained in:
@@ -16,7 +16,7 @@ struct PrimaryView: View {
|
||||
|
||||
// We need access to our window to know if we're the key window to determine
|
||||
// if we show the quit confirmation or not.
|
||||
@State private var window: NSWindow?
|
||||
var window: NSWindow
|
||||
|
||||
// This handles non-native fullscreen
|
||||
@State private var fullScreen = FullScreenHandler()
|
||||
@@ -27,6 +27,7 @@ struct PrimaryView: View {
|
||||
@FocusedValue(\.ghosttySurfaceView) private var focusedSurface
|
||||
@FocusedValue(\.ghosttySurfaceTitle) private var surfaceTitle
|
||||
@FocusedValue(\.ghosttySurfaceZoomed) private var zoomedSplit
|
||||
@FocusedValue(\.ghosttySurfaceCellSize) private var cellSize
|
||||
|
||||
// The title for our window
|
||||
private var title: String {
|
||||
@@ -68,7 +69,6 @@ struct PrimaryView: View {
|
||||
Ghostty.TerminalSplit(onClose: Self.closeWindow, baseConfig: self.baseConfig)
|
||||
.ghosttyApp(ghostty.app!)
|
||||
.ghosttyConfig(ghostty.config!)
|
||||
.background(WindowAccessor(window: $window))
|
||||
.onReceive(gotoTab) { onGotoTab(notification: $0) }
|
||||
.onReceive(toggleFullscreen) { onToggleFullscreen(notification: $0) }
|
||||
.focused($focused)
|
||||
@@ -79,8 +79,11 @@ struct PrimaryView: View {
|
||||
.onChange(of: title) { newValue in
|
||||
// We need to handle this manually because we are using AppKit lifecycle
|
||||
// so navigationTitle no longer works.
|
||||
guard let window = self.window else { return }
|
||||
window.title = newValue
|
||||
self.window.title = newValue
|
||||
}
|
||||
.onChange(of: cellSize) { newValue in
|
||||
guard let size = newValue else { return }
|
||||
self.window.contentResizeIncrements = size
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,8 +98,7 @@ struct PrimaryView: View {
|
||||
// Notification center indiscriminately sends to every subscriber (makes sense)
|
||||
// but we only want to process this once. In order to process it once lets only
|
||||
// handle it if we're the focused window.
|
||||
guard let window = self.window else { return }
|
||||
guard window.isKeyWindow else { return }
|
||||
guard self.window.isKeyWindow else { return }
|
||||
|
||||
// Get the tab index from the notification
|
||||
guard let tabIndexAny = notification.userInfo?[Ghostty.Notification.GotoTabKey] else { return }
|
||||
@@ -135,8 +137,7 @@ struct PrimaryView: View {
|
||||
// Just like in `onGotoTab`, we might receive this multiple times. But
|
||||
// it's fine, because `toggleFullscreen` should only apply to the
|
||||
// currently focused window.
|
||||
guard let window = self.window else { return }
|
||||
guard window.isKeyWindow else { return }
|
||||
guard self.window.isKeyWindow else { return }
|
||||
|
||||
// Check whether we use non-native fullscreen
|
||||
guard let useNonNativeFullscreenAny = notification.userInfo?[Ghostty.Notification.NonNativeFullscreenKey] else { return }
|
||||
|
||||
@@ -41,7 +41,8 @@ class PrimaryWindow: NSWindow {
|
||||
ghostty: ghostty,
|
||||
appDelegate: appDelegate,
|
||||
focusedSurfaceWrapper: window.focusedSurfaceWrapper,
|
||||
baseConfig: baseConfig
|
||||
baseConfig: baseConfig,
|
||||
window: window
|
||||
))
|
||||
|
||||
// We do want to cascade when new windows are created
|
||||
|
||||
Reference in New Issue
Block a user