mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-14 05:46:17 +00:00
macos: update accessory in the titlebar should not move the window
This is annoyingly easy to trigger, just disable this.
This commit is contained in:
@@ -167,6 +167,7 @@
|
|||||||
Helpers/KeyboardLayout.swift,
|
Helpers/KeyboardLayout.swift,
|
||||||
Helpers/LastWindowPosition.swift,
|
Helpers/LastWindowPosition.swift,
|
||||||
Helpers/MetalView.swift,
|
Helpers/MetalView.swift,
|
||||||
|
Helpers/NonDraggableHostingView.swift,
|
||||||
Helpers/PermissionRequest.swift,
|
Helpers/PermissionRequest.swift,
|
||||||
Helpers/Private/CGS.swift,
|
Helpers/Private/CGS.swift,
|
||||||
Helpers/Private/Dock.swift,
|
Helpers/Private/Dock.swift,
|
||||||
|
@@ -108,7 +108,7 @@ class TerminalWindow: NSWindow {
|
|||||||
// Create update notification accessory
|
// Create update notification accessory
|
||||||
if supportsUpdateAccessory {
|
if supportsUpdateAccessory {
|
||||||
updateAccessory.layoutAttribute = .right
|
updateAccessory.layoutAttribute = .right
|
||||||
updateAccessory.view = NSHostingView(rootView: UpdateAccessoryView(
|
updateAccessory.view = NonDraggableHostingView(rootView: UpdateAccessoryView(
|
||||||
viewModel: viewModel,
|
viewModel: viewModel,
|
||||||
model: appDelegate.updateViewModel
|
model: appDelegate.updateViewModel
|
||||||
))
|
))
|
||||||
|
13
macos/Sources/Helpers/NonDraggableHostingView.swift
Normal file
13
macos/Sources/Helpers/NonDraggableHostingView.swift
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
/// An NSHostingView subclass that prevents window dragging when clicking on the view.
|
||||||
|
///
|
||||||
|
/// By default, NSHostingViews in the titlebar allow the window to be dragged when
|
||||||
|
/// clicked. This subclass overrides `mouseDownCanMoveWindow` to return false,
|
||||||
|
/// preventing the window from being dragged when the user clicks on this view.
|
||||||
|
///
|
||||||
|
/// This is useful for titlebar accessories that contain interactive elements
|
||||||
|
/// (buttons, links, etc.) where you don't want accidental window dragging.
|
||||||
|
class NonDraggableHostingView<Content: View>: NSHostingView<Content> {
|
||||||
|
override var mouseDownCanMoveWindow: Bool { false }
|
||||||
|
}
|
Reference in New Issue
Block a user