cosmic-settings-daemon
cosmic-settings-daemon copied to clipboard
fix(shortcuts): improve key binding validity checks
- Return
true
fromBinding::is_set
if the binding consists only of theSuper
key. This fixes https://github.com/pop-os/cosmic-settings/issues/394. - In
Binding::from_str
, accept bindings without a key to allow settingSuper
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.