fix(shortcuts): handling of super modifier and search
This commit is contained in:
parent
252a2d5938
commit
e3e1c5b204
5 changed files with 72 additions and 21 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1745,7 +1745,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-settings-config"
|
name = "cosmic-settings-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-settings-daemon#8b3343794fb572e86fb835ec3b81648d67502288"
|
source = "git+https://github.com/pop-os/cosmic-settings-daemon?branch=fix-super-binding#d10f77afc1f4d7adce53caaa00079c621aed59f1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
"ron 0.11.0",
|
"ron 0.11.0",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ cosmic-panel-config = { workspace = true, optional = true }
|
||||||
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", optional = true }
|
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", optional = true }
|
||||||
cosmic-randr-shell.workspace = true
|
cosmic-randr-shell.workspace = true
|
||||||
cosmic-randr = { workspace = true, optional = true }
|
cosmic-randr = { workspace = true, optional = true }
|
||||||
cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon", optional = true }
|
cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon", optional = true, branch = "fix-super-binding" }
|
||||||
|
# cosmic-settings-config = { path = "../../cosmic-settings-daemon/config", optional = true }
|
||||||
cosmic-settings-page = { path = "../page" }
|
cosmic-settings-page = { path = "../page" }
|
||||||
cosmic-settings-subscriptions = { workspace = true, optional = true }
|
cosmic-settings-subscriptions = { workspace = true, optional = true }
|
||||||
cosmic-settings-system = { path = "../pages/system", optional = true }
|
cosmic-settings-system = { path = "../pages/system", optional = true }
|
||||||
|
|
|
||||||
|
|
@ -529,16 +529,25 @@ impl Model {
|
||||||
let old =
|
let old =
|
||||||
std::mem::replace(&mut shortcut.pending.modifiers, cfg_modifiers);
|
std::mem::replace(&mut shortcut.pending.modifiers, cfg_modifiers);
|
||||||
|
|
||||||
if shortcut.pending.keycode.is_none()
|
if shortcut.pending.keycode.is_none() && modifiers.is_empty() {
|
||||||
&& modifiers.is_empty()
|
if old.logo {
|
||||||
&& (old.alt || old.ctrl || old.shift || old.logo)
|
shortcut.pending.modifiers = old;
|
||||||
{
|
shortcut.input = shortcut.pending.to_string();
|
||||||
self.editing = None;
|
// XX for now avoid applying the keycode
|
||||||
shortcut.reset();
|
shortcut.binding.keycode = None;
|
||||||
return Task::batch(vec![
|
return Task::batch(vec![
|
||||||
cosmic::widget::text_input::focus(self.add_keybindings_button_id.clone()),
|
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard(),
|
||||||
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard()
|
self.submit_binding(id),
|
||||||
]);
|
cosmic::widget::text_input::focus(self.add_keybindings_button_id.clone()),
|
||||||
|
]);
|
||||||
|
} else if old.alt || old.ctrl || old.shift {
|
||||||
|
self.editing = None;
|
||||||
|
shortcut.reset();
|
||||||
|
return Task::batch(vec![
|
||||||
|
cosmic::widget::text_input::focus(self.add_keybindings_button_id.clone()),
|
||||||
|
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard()
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
shortcut.input = shortcut.pending.to_string();
|
shortcut.input = shortcut.pending.to_string();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -248,16 +248,47 @@ impl Page {
|
||||||
let old =
|
let old =
|
||||||
std::mem::replace(&mut self.add_shortcut.binding.modifiers, cfg_modifiers);
|
std::mem::replace(&mut self.add_shortcut.binding.modifiers, cfg_modifiers);
|
||||||
|
|
||||||
if self.add_shortcut.binding.keycode.is_none()
|
if self.add_shortcut.binding.keycode.is_none() && modifiers.is_empty() {
|
||||||
&& modifiers.is_empty()
|
if old.logo {
|
||||||
&& (old.alt || old.ctrl || old.shift || old.logo)
|
// XX for now avoid applying the keycode
|
||||||
{
|
let binding = Binding {
|
||||||
self.add_shortcut = Default::default();
|
modifiers: self.add_shortcut.binding.modifiers.clone(),
|
||||||
_ = self.model.on_enter();
|
key: self.add_shortcut.binding.key,
|
||||||
|
keycode: None,
|
||||||
|
description: None,
|
||||||
|
};
|
||||||
|
let Some(k) = self
|
||||||
|
.add_shortcut
|
||||||
|
.keys
|
||||||
|
.get_mut(self.add_shortcut.editing.unwrap())
|
||||||
|
else {
|
||||||
|
return iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard();
|
||||||
|
};
|
||||||
|
k.0 = binding.to_string();
|
||||||
|
|
||||||
return Task::batch(vec![
|
if self.add_shortcut.name.trim().is_empty()
|
||||||
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard()
|
|| self.add_shortcut.task.trim().is_empty()
|
||||||
]);
|
{
|
||||||
|
return Task::batch(vec![
|
||||||
|
widget::text_input::focus(widget::Id::unique()),
|
||||||
|
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
self.add_shortcut(binding);
|
||||||
|
_ = 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(),
|
||||||
|
]);
|
||||||
|
} else if (old.alt || old.ctrl || old.shift) {
|
||||||
|
self.add_shortcut = Default::default();
|
||||||
|
_ = self.model.on_enter();
|
||||||
|
|
||||||
|
return Task::batch(vec![
|
||||||
|
iced_winit::platform_specific::commands::keyboard_shortcuts_inhibit::inhibit_shortcuts(false).discard()
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(k) = self
|
if let Some(k) = self
|
||||||
.add_shortcut
|
.add_shortcut
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,16 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
self.clear();
|
self.clear();
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
|
fn subscription(
|
||||||
|
&self,
|
||||||
|
core: &cosmic::Core,
|
||||||
|
) -> cosmic::iced::Subscription<crate::pages::Message> {
|
||||||
|
self.search_model
|
||||||
|
.subscription(core)
|
||||||
|
.map(|m| crate::pages::Message::KeyboardShortcuts(Message::SearchShortcut(m)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue