Skip to content

Commit

Permalink
🐛 #314 Make more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKai77 committed May 22, 2024
1 parent 66d1626 commit 14506fa
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Loop/Managers/LoopManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import SwiftUI
import Defaults

// swiftlint:disable:next type_body_length
class LoopManager: ObservableObject {
// Size Adjustment
static var sidesToAdjust: Edge.Set?
Expand Down Expand Up @@ -306,10 +307,14 @@ class LoopManager: ObservableObject {

let triggerKey = Defaults[.triggerKey]
let wasKeyDown = (event.type == .keyDown || currentlyPressedModifiers.count > previousModifiers.count)
let keybindIsValid = (
Defaults[.triggerKey].contains(event.keyCode) ||
Defaults[.keybinds].contains {
$0.keybind.contains(event.keyCode)
}
)

if wasKeyDown,
triggerKey.isSubset(of: currentlyPressedModifiers) {

if wasKeyDown, keybindIsValid, triggerKey.isSubset(of: currentlyPressedModifiers) {
guard
!isLoopActive,
currentlyPressedModifiers.count <= triggerKey.count
Expand Down Expand Up @@ -351,10 +356,6 @@ class LoopManager: ObservableObject {
for key in flags where CGKeyCode.keyToImage.contains(where: { $0.key == key }) {
if !self.currentlyPressedModifiers.map({ $0.baseModifier }).contains(key) {
self.currentlyPressedModifiers.insert(key)

// if key.isOnRightSide {
// print("\(key) is on right side")
// }
}
}
}
Expand Down Expand Up @@ -399,8 +400,6 @@ class LoopManager: ObservableObject {
self.keybindMonitor.stop()
self.mouseMovedEventMonitor!.stop()

self.currentlyPressedModifiers = []

if self.targetWindow != nil,
self.screenToResizeOn != nil,
forceClose == false,
Expand Down

0 comments on commit 14506fa

Please sign in to comment.