Skip to content

Commit

Permalink
Window Resizing — Expand inset for ignoresMouseEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
importRyan committed Aug 10, 2021
1 parent 357ffd2 commit a2e2529
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Mac App/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,15 @@ private extension ViewController {
}()
let mouseIsInView = viewBounds.contains(mouseLocationInView)

let resizeCornerSize = CGFloat(8)
let isInResizeRectY = viewBounds.offsetBy(dx: 0, dy: resizeCornerSize).contains(mouseLocationInView)
let isInResizeRectX = viewBounds.insetBy(dx: resizeCornerSize, dy: 0).contains(mouseLocationInView)
let newState = mouseIsInView && ( isInResizeRectY || isInResizeRectX )
// To allow more room to grab the window edges, calculate inset
// bottom and side bounds so that grabbing the window edge
// is easier
let resizeCornerSize = CGFloat(12)
let insetRectForEasierWindowResizing = viewBounds
.insetBy(dx: resizeCornerSize, dy: resizeCornerSize / 2)
.offsetBy(dx: 0, dy: resizeCornerSize)

let newState = mouseIsInView && insetRectForEasierWindowResizing.contains(mouseLocationInView)
self.view.window?.ignoresMouseEvents = newState
}

Expand Down

0 comments on commit a2e2529

Please sign in to comment.