Fix window snapping when crossing between displays

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-08-12 17:57:20 +02:00
parent 223726d873
commit 9a8a8a02ad
6 changed files with 345 additions and 89 deletions
+16 -9
View File
@@ -143,16 +143,23 @@ class AppDelegate: FlutterAppDelegate {
}
result(nil)
case "getScreenBounds":
// The visible frame of the primary screen (menu bar and dock excluded),
// converted to window_manager's top-left origin coordinates.
if let screen = NSScreen.screens.first {
let f = screen.frame
let v = screen.visibleFrame
// The union of every screen's visible frame (menu bar and dock
// excluded), converted to window_manager's top-left origin coordinates.
// The primary screen's full frame is the origin reference, so displays
// arranged above it map to negative Y and displays below it to Y beyond
// the primary's height — the drag clamp/snap then span the whole desktop.
let screens = NSScreen.screens
if !screens.isEmpty {
let f = screens[0].frame
var union = screens[0].visibleFrame
for screen in screens.dropFirst() {
union = union.union(screen.visibleFrame)
}
result([
"x": v.origin.x,
"y": f.height - v.origin.y - v.height,
"width": v.width,
"height": v.height,
"x": union.origin.x,
"y": f.height - union.origin.y - union.height,
"width": union.width,
"height": union.height,
])
} else {
result(nil)