cosmic-settings-daemon icon indicating copy to clipboard operation
cosmic-settings-daemon copied to clipboard

fix(shortcuts): improve key binding validity checks

Open Triton171 opened this issue 6 months ago • 0 comments

  • Return true from Binding::is_set if the binding consists only of the Super key. This fixes https://github.com/pop-os/cosmic-settings/issues/394.
  • In Binding::from_str, accept bindings without a key to allow setting Super as a shortcut. I also changed it to reject bindings that contain several keys. The old implementation would just ignore everything after the first one.

As far as I can tell, both these functions are only used by cosmic-settings which i tested without finding any new issues. If there's anything else I should test, let me know.

I also noticed that in cosmic-settings, the code that focuses any existing invalid keybinding when adding a new one calls Binding::from_str without then checking Binding::is_set for the parsed binding. This should probably also be replaced by Binding::from_str(&shortcut.input).map_or(false, |b| b.is_set()), unless I'm missing something.

Triton171 avatar Aug 08 '24 12:08 Triton171