Skip to content

keybindings: Reject accelerators without keysym and fail invalid custom keybindings - #872

Open
DerLinke wants to merge 1 commit into
linuxmint:masterfrom
DerLinke:fix-custom-keybinding-invalid-accel
Open

DerLinke wants to merge 1 commit into
linuxmint:masterfrom
DerLinke:fix-custom-keybinding-invalid-accel

Conversation

@DerLinke

Copy link
Copy Markdown

When parsing an accelerator string like <Print> or <Control> that lacks a keysym or keycode, accelerator_parse() previously skipped unrecognized bracketed tokens and returned TRUE with combo->keysym == 0 and combo->keycode == 0. This caused meta_parse_accelerator() to treat unparseable strings as valid, preventing diagnostic warnings from being emitted.

Furthermore, meta_prefs_add_keybinding() returned TRUE unconditionally even when no valid key combos were parsed. For dynamic custom keybindings without a GSettings backend, this resulted in meta_display_add_custom_keybinding() returning a valid non-zero action ID for a dead shortcut with no grab installed, failing to report META_KEYBINDING_ACTION_NONE to the caller.

Fix

  1. Ensures meta_parse_accelerator() returns FALSE when both keysym and keycode are 0.
  2. In meta_prefs_add_keybinding(), rejects dynamic custom keybindings when provided bindings cannot be parsed into any combo, returning FALSE so the caller can handle and report the failure.
  3. Updates the warning in update_binding() so it accurately reflects both GSettings and custom runtime bindings.

Fixes #867

…om keybindings

When parsing an accelerator string like '<Print>' or '<Control>' that lacks
a keysym or keycode, accelerator_parse() previously skipped unrecognized
bracketed tokens and returned TRUE with combo->keysym == 0 and combo->keycode == 0.
This caused meta_parse_accelerator() to treat unparseable strings as valid,
preventing diagnostic warnings from being emitted.

Furthermore, meta_prefs_add_keybinding() returned TRUE unconditionally even when
no valid key combos were parsed. For dynamic custom keybindings without a
GSettings backend, this resulted in meta_display_add_custom_keybinding()
returning a valid non-zero action ID for a dead shortcut with no grab installed,
failing to report META_KEYBINDING_ACTION_NONE to the caller.

Fix this by:
1. Ensuring meta_parse_accelerator() returns FALSE when both keysym and keycode are 0.
2. In meta_prefs_add_keybinding(), rejecting dynamic custom keybindings when
   provided bindings cannot be parsed into any combo, returning FALSE so the caller
   can handle and report the failure.
3. Updating the warning in update_binding() so it accurately reflects both
   GSettings and custom runtime bindings.

Fixes linuxmint#867
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.

add_custom_keybinding() returns a valid action id for an unparseable accelerator: no grab, no warning, dead shortcut

1 participant