Skip to content

Fix three keyboard-related issues (#13787)#13789

Open
H09-0 wants to merge 3 commits into
linuxmint:masterfrom
H09-0:fix/keybinding-issues
Open

Fix three keyboard-related issues (#13787)#13789
H09-0 wants to merge 3 commits into
linuxmint:masterfrom
H09-0:fix/keybinding-issues

Conversation

@H09-0
Copy link
Copy Markdown

@H09-0 H09-0 commented May 29, 2026

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 user
presses 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 the
binding has Shift as the trigger key.

Fix: Track the previous modifier keycode (_lastModifierKeyCode) when a
modifier 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>Shift
when Shift is pressed first.

Issue 2: Super+Space closes the Start Menu

Root cause: When Super (the overlay key) is pressed, _stageEventHandler
stores its action in _modifierOnlyAction, deferred to key-release. If the
user then presses another modifier key that doesn't match a binding,
_modifierOnlyAction was never cleared, causing the overlay toggle to fire
on Super release - closing the menu while the user intended Super as part
of a combo (Super+Space for layout switching).

Fix: Clear _modifierOnlyAction in the modifier key press handler when
the 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 _onMenuKeyPress handler connects to the
search entry clutter_text's key-press-event. ClutterText does not
implement 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_a cases in the _onMenuKeyPress
switch 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 _stageEventHandler
  • files/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js (+8, -0): Fix Issue 3 in _onMenuKeyPress

Testing

  1. Issue 1: Set Ctrl+Shift as layout switching shortcut. With the menu
    open, press Shift first then Ctrl (both orders). Layout should switch
    regardless of order.
  2. Issue 2: Open the Start Menu (by mouse click). Press Super+Space
    (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.
  3. Issue 3: Open the Start Menu, type text in the search field, press
    Ctrl+A. All text should be selected.

H09-0 added 3 commits May 28, 2026 15:59
- 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.
@H09-0
Copy link
Copy Markdown
Author

H09-0 commented May 29, 2026

Edge-case review completed

I reviewed the 5 concerns raised during review. Two real bugs were found and fixed in commit 12717ad:

  1. Reverse-match modifier state was wrong: The old code passed modifierState | currentMask as the modifier state for the reverse lookup. Since modifierState already contains the held modifier's mask (whose keycode is _lastModifierKeyCode), this created a self-referential mismatch for bindings like <Control>Shift. Fixed to pass only currentMask.

  2. Stale _lastModifierKeyCode across modal sessions: Added _lastModifierKeyCode = 0 to _completeModalSetup() to prevent stale keycodes from causing false reverse matches when a new modal session starts.

All 5 originally flagged concerns were confirmed as already correct: cleanup on release/non-modifier keys, _modifierOnlyAction clearing on successful combos, three-modifier graceful degradation, left/right modifier distinction, and Ctrl+A ctrlKey-only strictness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some hotkeys work incorrectly: ctrl+shift, super+space, ctrl+a.

1 participant