Skip to content

Commit

Permalink
Run refreshAndLayout when mouse clicks outside of the focused window …
Browse files Browse the repository at this point in the history
…rectangle

#445 (comment)
  • Loading branch information
nikitabobko committed Nov 4, 2024
1 parent 0ab5fde commit 00cbb63
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Sources/AppBundle/GlobalObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,20 @@ class GlobalObserver {

NSEvent.addGlobalMonitorForEvents(matching: [.leftMouseUp]) { _ in
resetManipulatedWithMouseIfPossible()
// Detect clicks on desktop of different monitors
let mouseLocation = mouseLocation
let clickedMonitor = mouseLocation.monitorApproximation
if clickedMonitor.activeWorkspace != focus.workspace {
_ = refreshSession {
clickedMonitor.activeWorkspace.focusWorkspace()
}
let focus = focus
switch () {
// Detect clicks on desktop of different monitors
case _ where clickedMonitor.activeWorkspace != focus.workspace:
_ = refreshSession {
clickedMonitor.activeWorkspace.focusWorkspace()
}
// Detect close button clicks for unfocused windows
case _ where focus.windowOrNil?.getRect()?.contains(mouseLocation) == false: // todo replace getRect with preflushRect when it later becomes available
refreshAndLayout()
default:
break
}
}
}
Expand Down

0 comments on commit 00cbb63

Please sign in to comment.