Skip to content

Commit b290781

Browse files
committed
mac/title: fix mouse position when snapped to position from title bar
when the window is snapped to a position by dragging the title bar the corresponding left mouse up event is prevented by the system snap event, which leads to the window moving state not being reset and no mouse position changes being reported. which makes UI elements unresponsive. explicitly subscribe to left mouse up events for the whole app instead of the mouse events from the title bar and reset the moving state. Fixes mpv-player#16732
1 parent b9ceaf2 commit b290781

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

video/out/mac/title_bar.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ class TitleBar: NSVisualEffectView {
6161
set(appearance: option.mac.macos_title_bar_appearance)
6262
set(material: option.mac.macos_title_bar_material)
6363
set(color: option.mac.macos_title_bar_color)
64+
65+
// workaround for mouse up events that are prevented by system events like snap to position
66+
NSEvent.addLocalMonitorForEvents(matching: .leftMouseUp) { (event) -> NSEvent? in
67+
self.common.window?.isMoving = false
68+
return event
69+
}
6470
}
6571

6672
required init?(coder: NSCoder) {
@@ -87,8 +93,6 @@ class TitleBar: NSVisualEffectView {
8793
window?.zoom(self)
8894
}
8995
}
90-
91-
common.window?.isMoving = false
9296
}
9397

9498
func set(appearance: Int32) {

0 commit comments

Comments
 (0)