Skip to content

Commit

Permalink
🔀 Merge pull request #241 from MrKai77/232-haptic-feedback
Browse files Browse the repository at this point in the history
✨ #232 Window Snapping Haptic feedback
  • Loading branch information
MrKai77 authored Mar 8, 2024
2 parents 6bd1388 + b4da51b commit 0a57fec
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Loop/Managers/WindowDragManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class WindowDragManager {
self.previewController.setScreen(to: screen)
let ignoredFrame = screenFrame.insetBy(dx: 20, dy: 20) // 10px of snap area on each side

let oldDirection = self.direction

if !ignoredFrame.contains(mousePosition) {
self.direction = WindowDirection.processSnap(
mouseLocation: mousePosition,
Expand All @@ -143,6 +145,15 @@ class WindowDragManager {
self.direction = .noAction
self.previewController.close()
}

if self.direction != oldDirection {
if Defaults[.hapticFeedback] {
NSHapticFeedbackManager.defaultPerformer.perform(
NSHapticFeedbackManager.FeedbackPattern.alignment,
performanceTime: NSHapticFeedbackManager.PerformanceTime.now
)
}
}
}

private func attemptWindowSnap(_ window: Window) {
Expand All @@ -154,6 +165,7 @@ class WindowDragManager {

DispatchQueue.main.async {
WindowEngine.resize(window, to: .init(self.direction), on: screen)
self.direction = .noAction
}
}
}

0 comments on commit 0a57fec

Please sign in to comment.