Fix window snapping when crossing between displays
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user