Skip to content

Commit

Permalink
🐞 Fix window snapping on multi-display setups
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKai77 committed Jun 28, 2024
1 parent 62da023 commit dd9dc33
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Loop/Managers/WindowDragManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ class WindowDragManager {
}

private func setCurrentDraggingWindow() {
guard let screen = NSScreen.screenWithMouse else {
return
}

let mousePosition = NSEvent.mouseLocation.flipY(screen: screen)
let mousePosition = NSEvent.mouseLocation.flipY(screen: NSScreen.screens[0])

do {
guard
Expand Down Expand Up @@ -131,19 +127,23 @@ class WindowDragManager {
guard let screen = NSScreen.screenWithMouse else {
return
}
let mousePosition = NSEvent.mouseLocation.flipY(maxY: screen.frame.maxY)
let screenFrame = screen.frame.flipY(maxY: screen.frame.maxY)

let mainScreen = NSScreen.screens[0]
let mousePosition = NSEvent.mouseLocation.flipY(screen: mainScreen)
let screenFrame = screen.frame.flipY(screen: mainScreen)

previewController.setScreen(to: screen)

let insets: CGFloat = 2
let topInset = screen.menubarHeight / 2
let inset: CGFloat = 2
let topInset = max(screen.menubarHeight / 2, inset)
var ignoredFrame = screenFrame

ignoredFrame.origin.x += insets
ignoredFrame.size.width -= insets * 2
ignoredFrame.origin.x += inset
ignoredFrame.size.width -= inset * 2
ignoredFrame.origin.y += topInset
ignoredFrame.size.height -= insets + topInset
ignoredFrame.size.height -= inset + topInset

print(ignoredFrame.minY, screenFrame.minY)

let oldDirection = direction

Expand Down

0 comments on commit dd9dc33

Please sign in to comment.