Skip to content

Commit

Permalink
🔀 Merge pull request #479 from `MrKai77/mrkai77/loop-562-fullscreen-w…
Browse files Browse the repository at this point in the history
…indow-snap-doesnt-work-on-second-monitor`

🐞 Fix window snapping on multi-display setups
  • Loading branch information
MrKai77 committed Jun 28, 2024
2 parents 62da023 + dd9dc33 commit 831a59d
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 831a59d

Please sign in to comment.