Fix three keyboard-related issues (#13787)#13789
Conversation
- Add _calculatePosition() + set_position() in onComplete of the animation path to ensure the menu snaps to the correct position immediately after the visual transition finishes. Without this, _allocationChanged is blocked by this.animating during the animation, so any deferred layout changes (e.g. app buttons shown via Mainloop.idle_add) cannot correct the position until after the animation ends and the next allocation change fires. - Replace separate this.actor.x / this.actor.y assignments with this.actor.set_position() in the non-animation path to avoid a race where setting x triggers _allocationChanged synchronously, which calls set_position(), and then the subsequent y assignment overwrites the corrected Y coordinate with the stale value. Closes linuxmint#13780
Issue 1: Ctrl+Shift order-dependence (layout switching) - In _stageEventHandler, when a modifier key press doesn't match a binding and a previous modifier was tracked, try the reverse order: use the previous modifier's keycode with the current key's modifier mask. This handles bindings like <Control>Shift where pressing Shift first then Ctrl would otherwise fail to match. - Added _lastModifierKeyCode tracking and _modifierMaskForKeySymbol helper. Issue 2: Super+Space closes Start Menu - Clear _modifierOnlyAction when an unmatched modifier key is pressed. Previously, pressing Super (overlay) set _modifierOnlyAction, and if the user then pressed another modifier (e.g. Ctrl) that didn't match, _modifierOnlyAction was never cleared, causing the overlay to fire on Super release even though the key was part of a modifier combo. Issue 3: Ctrl+A does not select all text in search field - Added Ctrl+A handling in _onMenuKeyPress in the menu applet. ClutterText does not implement select-all via Ctrl+A by default, so we explicitly set the selection from 0 to text length.
…in completeModalSetup
Edge-case review completedI reviewed the 5 concerns raised during review. Two real bugs were found and fixed in commit 12717ad:
All 5 originally flagged concerns were confirmed as already correct: cleanup on release/non-modifier keys, |
Summary
Fix #13787 - three keyboard and shortcut issues in the modal event handler
and menu search field.
Issue 1: Ctrl+Shift order-dependent for layout switching
Root cause: In
_stageEventHandler(js/ui/main.js), when the userpresses two modifier keys (e.g., Ctrl+Shift) and the keybinding is stored
as
<Control>Shift, only "Ctrl first, then Shift" triggers the binding."Shift first, then Ctrl" fails because
get_keybinding_action(ctrl_keycode, Shift_mask)checks for a binding where Ctrl is the trigger key, but thebinding has Shift as the trigger key.
Fix: Track the previous modifier keycode (
_lastModifierKeyCode) when amodifier press doesn't match a binding. When the next modifier is pressed,
try the reverse combination:
get_keybinding_action(prev_keycode, modifierState | current_mask). This correctly matches<Control>Shiftwhen Shift is pressed first.
Issue 2: Super+Space closes the Start Menu
Root cause: When Super (the overlay key) is pressed,
_stageEventHandlerstores its action in
_modifierOnlyAction, deferred to key-release. If theuser then presses another modifier key that doesn't match a binding,
_modifierOnlyActionwas never cleared, causing the overlay toggle to fireon Super release - closing the menu while the user intended Super as part
of a combo (Super+Space for layout switching).
Fix: Clear
_modifierOnlyActionin the modifier key press handler whenthe press doesn't match any binding. Also clear it when a non-modifier key
press arrives. This ensures a subsequent modifier-only action only fires if
no other key was pressed between press and release.
Issue 3: Ctrl+A does not select all text in search field
Root cause: The menu applet's
_onMenuKeyPresshandler connects to thesearch entry
clutter_text'skey-press-event. ClutterText does notimplement Ctrl+A (select all) by default in the version used by Cinnamon.
The event propagated but no built-in handler acted on it.
Fix: Add
Clutter.KEY_A/Clutter.KEY_acases in the_onMenuKeyPressswitch statement. When ctrlKey is held, call
this.searchEntryText.set_selection(0, textLen)to select all text.Files changed
js/ui/main.js(+51, -5): Fix Issues 1 and 2 in_stageEventHandlerfiles/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js(+8, -0): Fix Issue 3 in_onMenuKeyPressTesting
open, press Shift first then Ctrl (both orders). Layout should switch
regardless of order.
(or whatever the layout switch combo is). The menu should stay open
and the layout should switch. Solo Super press/release should still
toggle the menu.
Ctrl+A. All text should be selected.