fix(input): hold floating profile shortcuts
- commit
- 49f66aa0b04ec790a6c165241a68fbed7e05ea90
- author
- brice · · 2026-05-24 13:34 UTC
- parent
- 8769cd0
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +18 -1
M internal/ui/input/global_shortcuts.go +5 -1
| @@ -605,7 +605,11 @@ func (h *GlobalShortcutHandler) suppressRepeatedShortcut(action Action, now time | |||
| 605 | 605 | } | |
| 606 | 606 | ||
| 607 | 607 | func isHeldGlobalShortcutSuppressed(action Action) bool { | |
| 608 | - | return isRepeatedGlobalShortcutSuppressed(action) || isModeAction(action) | |
| 608 | + | if isRepeatedGlobalShortcutSuppressed(action) || isModeAction(action) { | |
| 609 | + | return true | |
| 610 | + | } | |
| 611 | + | _, ok := ParseFloatingProfileTarget(action) | |
| 612 | + | return ok | |
| 609 | 613 | } | |
| 610 | 614 | ||
| 611 | 615 | func isRepeatedGlobalShortcutSuppressed(action Action) bool { | |
| @@ -605,7 +605,11 @@ func (h *GlobalShortcutHandler) suppressRepeatedShortcut(action Action, now time | |||||
| 605 | } | 605 | } | ||
| 606 | 606 | ||||
| 607 | func isHeldGlobalShortcutSuppressed(action Action) bool { | 607 | func isHeldGlobalShortcutSuppressed(action Action) bool { | ||
| 608 | - | return isRepeatedGlobalShortcutSuppressed(action) || isModeAction(action) | 608 | + | if isRepeatedGlobalShortcutSuppressed(action) || isModeAction(action) { |
| 609 | + | return true | |||
| 610 | + | } | |||
| 611 | + | _, ok := ParseFloatingProfileTarget(action) | |||
| 612 | + | return ok | |||
| 609 | } | 613 | } | ||
| 610 | 614 | ||||
| 611 | func isRepeatedGlobalShortcutSuppressed(action Action) bool { | 615 | func isRepeatedGlobalShortcutSuppressed(action Action) bool { | ||
M internal/ui/input/global_shortcuts_test.go +13 -0
| @@ -222,6 +222,19 @@ func TestGlobalShortcutHandlerSuppressesHeldModeAction(t *testing.T) { | |||
| 222 | 222 | } | |
| 223 | 223 | } | |
| 224 | 224 | ||
| 225 | + | func TestGlobalShortcutHandlerSuppressesHeldFloatingProfileAction(t *testing.T) { | |
| 226 | + | h := &GlobalShortcutHandler{heldShortcuts: make(map[globalShortcutHoldKey]time.Time)} | |
| 227 | + | info := globalShortcutEventInfo{hasCurrentEvent: true, eventType: gdk.KeyPressValue, eventKeyval: uint('o'), eventKeycode: 32} | |
| 228 | + | action := NewFloatingProfileAction("work", "https://example.com") | |
| 229 | + | ||
| 230 | + | if h.suppressHeldShortcut(action, info, time.Unix(100, 0)) { | |
| 231 | + | t.Fatal("first floating-profile shortcut dispatch was suppressed") | |
| 232 | + | } | |
| 233 | + | if !h.suppressHeldShortcut(action, info, time.Unix(101, 0)) { | |
| 234 | + | t.Fatal("held floating-profile shortcut repeat was not suppressed") | |
| 235 | + | } | |
| 236 | + | } | |
| 237 | + | ||
| 225 | 238 | func TestShouldDispatchGlobalShortcutEventRequiresCurrentKeyEvent(t *testing.T) { | |
| 226 | 239 | if shouldDispatchGlobalShortcutEvent(globalShortcutEventInfo{}) { | |
| 227 | 240 | t.Fatal("global shortcut without current event should not dispatch") | |
| @@ -222,6 +222,19 @@ func TestGlobalShortcutHandlerSuppressesHeldModeAction(t *testing.T) { | |||||
| 222 | } | 222 | } | ||
| 223 | } | 223 | } | ||
| 224 | 224 | ||||
| 225 | + | func TestGlobalShortcutHandlerSuppressesHeldFloatingProfileAction(t *testing.T) { | |||
| 226 | + | h := &GlobalShortcutHandler{heldShortcuts: make(map[globalShortcutHoldKey]time.Time)} | |||
| 227 | + | info := globalShortcutEventInfo{hasCurrentEvent: true, eventType: gdk.KeyPressValue, eventKeyval: uint('o'), eventKeycode: 32} | |||
| 228 | + | action := NewFloatingProfileAction("work", "https://example.com") | |||
| 229 | + | ||||
| 230 | + | if h.suppressHeldShortcut(action, info, time.Unix(100, 0)) { | |||
| 231 | + | t.Fatal("first floating-profile shortcut dispatch was suppressed") | |||
| 232 | + | } | |||
| 233 | + | if !h.suppressHeldShortcut(action, info, time.Unix(101, 0)) { | |||
| 234 | + | t.Fatal("held floating-profile shortcut repeat was not suppressed") | |||
| 235 | + | } | |||
| 236 | + | } | |||
| 237 | + | ||||
| 225 | func TestShouldDispatchGlobalShortcutEventRequiresCurrentKeyEvent(t *testing.T) { | 238 | func TestShouldDispatchGlobalShortcutEventRequiresCurrentKeyEvent(t *testing.T) { | ||
| 226 | if shouldDispatchGlobalShortcutEvent(globalShortcutEventInfo{}) { | 239 | if shouldDispatchGlobalShortcutEvent(globalShortcutEventInfo{}) { | ||
| 227 | t.Fatal("global shortcut without current event should not dispatch") | 240 | t.Fatal("global shortcut without current event should not dispatch") | ||