diff --git a/Cargo.lock b/Cargo.lock index 330a0a5..f9ff403 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1529,7 +1529,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -1550,7 +1550,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "quote", "syn 2.0.106", @@ -1871,7 +1871,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "almost", "cosmic-config", @@ -3284,7 +3284,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core 0.62.0", + "windows-core 0.61.2", ] [[package]] @@ -3299,7 +3299,7 @@ dependencies = [ [[package]] name = "iced" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "dnd", "iced_accessibility", @@ -3317,7 +3317,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "accesskit", "accesskit_winit", @@ -3326,7 +3326,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "bitflags 2.9.4", "bytes", @@ -3351,7 +3351,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "futures", "iced_core", @@ -3377,7 +3377,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "bitflags 2.9.4", "bytemuck", @@ -3399,7 +3399,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -3411,7 +3411,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "bytes", "cosmic-client-toolkit", @@ -3427,7 +3427,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "bytemuck", "cosmic-text", @@ -3443,7 +3443,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "as-raw-xcb-connection", "bitflags 2.9.4", @@ -3474,7 +3474,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "cosmic-client-toolkit", "dnd", @@ -3494,7 +3494,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "cosmic-client-toolkit", "dnd", @@ -4550,7 +4550,7 @@ checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic//?branch=more-input-changes#53f9f463d4cc03b396aee7d27d9d6640af7d1640" +source = "git+https://github.com/pop-os/libcosmic#9ff208e9d7b538bc780bd2c4b13d342337780469" dependencies = [ "apply", "ashpd 0.12.0", @@ -8572,20 +8572,7 @@ dependencies = [ "windows-interface 0.59.1", "windows-link 0.1.3", "windows-result 0.3.4", - "windows-strings 0.4.2", -] - -[[package]] -name = "windows-core" -version = "0.62.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fe7168f7de578d2d8a05b07fd61870d2e73b4020e9f49aa00da8471723497c" -dependencies = [ - "windows-implement 0.60.0", - "windows-interface 0.59.1", - "windows-link 0.2.0", - "windows-result 0.4.0", - "windows-strings 0.5.0", + "windows-strings", ] [[package]] @@ -8683,15 +8670,6 @@ dependencies = [ "windows-link 0.1.3", ] -[[package]] -name = "windows-result" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" -dependencies = [ - "windows-link 0.2.0", -] - [[package]] name = "windows-strings" version = "0.4.2" @@ -8701,15 +8679,6 @@ dependencies = [ "windows-link 0.1.3", ] -[[package]] -name = "windows-strings" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" -dependencies = [ - "windows-link 0.2.0", -] - [[package]] name = "windows-sys" version = "0.45.0" diff --git a/cosmic-settings/src/pages/input/keyboard/shortcuts/custom.rs b/cosmic-settings/src/pages/input/keyboard/shortcuts/custom.rs index 02ebe11..e3e2cea 100644 --- a/cosmic-settings/src/pages/input/keyboard/shortcuts/custom.rs +++ b/cosmic-settings/src/pages/input/keyboard/shortcuts/custom.rs @@ -139,35 +139,33 @@ impl Page { let mut addable_bindings = Vec::new(); - for (_, (keys, ..)) in &self.add_shortcut.keys { - if keys.is_empty() { + for (index, (keys, id)) in &self.add_shortcut.keys { + if !keys.is_empty() { continue; } - let Ok(binding) = Binding::from_str(keys) else { - return Task::none(); - }; - - if !binding.is_set() { - return Task::none(); - } - - if let Some(action) = self.model.config_contains(&binding) { - let action_str = super::localize_action(&action); - self.replace_dialog.push((binding, action, action_str)); - continue; - } - - addable_bindings.push(binding); + addable_bindings.push((index, id.clone())); } - for mut binding in addable_bindings { - binding.keycode = None; - self.add_shortcut(binding); + if let Some((index, binding)) = addable_bindings.first() { + self.add_shortcut.editing = Some(*index); + return Task::batch(vec![ + widget::text_input::focus(binding.clone()), + iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard(), + ]); + } else { + // make a new empty binding if none exist + let new_id = widget::Id::unique(); + self.add_shortcut.editing = Some( + self.add_shortcut + .keys + .insert((String::new(), new_id.clone())), + ); + return Task::batch(vec![ + widget::text_input::focus(new_id.clone()), + iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(true).discard(), + ]); } - - self.add_shortcut.binding = Default::default(); - _ = self.model.on_enter(); } Message::EditCombination => { @@ -254,7 +252,6 @@ impl Page { && modifiers.is_empty() && (old.alt || old.ctrl || old.shift || old.logo) { - self.add_shortcut = Default::default(); self.add_shortcut = Default::default(); _ = self.model.on_enter(); @@ -309,10 +306,10 @@ impl Page { ]); } self.add_shortcut(binding); - self.add_shortcut = Default::default(); _ = self.model.on_enter(); return Task::batch(vec![ + widget::text_input::focus(widget::Id::unique()), iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard(), ]); } @@ -448,7 +445,11 @@ impl Page { } fn add_shortcut(&mut self, mut binding: Binding) { - self.add_shortcut.active = !self.replace_dialog.is_empty(); + if let Some(action) = self.model.config_contains(&binding) { + let action_str = super::localize_action(&action); + self.replace_dialog.push((binding, action, action_str)); + return; + } binding.description = Some(self.add_shortcut.name.clone()); let new_action = Action::Spawn(self.add_shortcut.task.clone()); self.model.config_add(new_action, binding);