Fix Wayland internal UI lifecycle edge cases
This commit is contained in:
1 parent
fc25f7e7e8
commit
ac7f7acc43
12 files changed
+477
-90
No files matched your search
@@ -484,3 +484,14 @@ func (router *CommandRouter) ReplaceBindings(bindings CommandBindings) {
|
||||
router.bindings[chord] = command
|
||||
}
|
||||
}
|
||||
|
||||
// ReplaceConfiguration updates the modifier set and bindings without losing
|
||||
// held-key or multi-press state. Grab-only transitions need that continuity
|
||||
// when capture changes while the initiating chord is still held.
|
||||
func (router *CommandRouter) ReplaceConfiguration(modifiers []uint32, bindings CommandBindings) {
|
||||
router.modifiers = make(map[uint32]bool, len(modifiers))
|
||||
for _, symbol := range modifiers {
|
||||
router.modifiers[symbol] = true
|
||||
}
|
||||
router.ReplaceBindings(bindings)
|
||||
}
|
||||
@@ -68,6 +68,17 @@ func TestBindingTableRoutesPreferencesOnPress(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplaceConfigurationPreservesHeldModifier(t *testing.T) {
|
||||
router := NewCommandRouter([]uint32{0xff63}, DefaultCommandBindings(DesktopKeyboardLayout))
|
||||
if consumed, command := router.Handle(0xff63, 118, 0, true); !consumed || command != "" {
|
||||
t.Fatalf("modifier press = %v %q", consumed, command)
|
||||
}
|
||||
router.ReplaceConfiguration([]uint32{0xff63}, DefaultCommandBindings(DesktopKeyboardLayout))
|
||||
if consumed, command := router.Handle('t', 20, 0, true); !consumed || command != PresentTime {
|
||||
t.Fatalf("held modifier was lost across reconfiguration: %v %q", consumed, command)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplicationPreferencesShortcut(t *testing.T) {
|
||||
router := NewCommandRouter([]uint32{0xff63}, DefaultCommandBindings(DesktopKeyboardLayout))
|
||||
if consumed, command := router.Handle(0xff63, 90, 0, true); !consumed || command != "" {
|
||||
|
||||
Reference in new issue
Block a user