Added feature "action on typing", i.e. cosmic-workspaces opens cosmic-launcher or cosmic-app-library, if the setting is set.
When opened by typing, cosmic-launcher or cosmic-app-library are closed when existing the workspaces overview. Changed exiting workspaces overview by pressing Escape from KeyReleased to KeyPressed to improve interaction between cosmic-workspaces and cosmic-launcher/cosmic-app-library.
This commit is contained in:
parent
2108269d2e
commit
f31e33ad30
1 changed files with 64 additions and 5 deletions
69
src/main.rs
69
src/main.rs
|
|
@ -38,6 +38,7 @@ use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
mem,
|
mem,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
|
process::Command,
|
||||||
str,
|
str,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
@ -118,6 +119,7 @@ enum Msg {
|
||||||
DBus(dbus::Event),
|
DBus(dbus::Event),
|
||||||
PanelContainerEntries(Vec<String>),
|
PanelContainerEntries(Vec<String>),
|
||||||
PanelConfig(CosmicPanelConfig),
|
PanelConfig(CosmicPanelConfig),
|
||||||
|
ActionOnTyping(String),
|
||||||
Ignore,
|
Ignore,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,6 +200,7 @@ struct App {
|
||||||
scroll: DiscreteScrollState,
|
scroll: DiscreteScrollState,
|
||||||
dbus_interface: Option<dbus::Interface>,
|
dbus_interface: Option<dbus::Interface>,
|
||||||
panel_configs: HashMap<String, Option<CosmicPanelConfig>>,
|
panel_configs: HashMap<String, Option<CosmicPanelConfig>>,
|
||||||
|
action_on_typing_activated: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
@ -303,6 +306,33 @@ impl App {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.action_on_typing_activated {
|
||||||
|
let cmd = match self.conf.workspace_config.action_on_typing {
|
||||||
|
cosmic_comp_config::workspace::Action::None => return Task::none(),
|
||||||
|
cosmic_comp_config::workspace::Action::OpenLauncher => {
|
||||||
|
// self.common.config.system_actions.get(&Launcher)
|
||||||
|
Some("cosmic-launcher \"$@\"".to_string())
|
||||||
|
}
|
||||||
|
cosmic_comp_config::workspace::Action::OpenApplications => {
|
||||||
|
// self.common.config.system_actions.get(&Applications)
|
||||||
|
Some("cosmic-app-library \"$@\"".to_string())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Some(cmd) = cmd {
|
||||||
|
tokio::spawn(async {
|
||||||
|
let mut child = Command::new("/bin/sh")
|
||||||
|
.arg("-c")
|
||||||
|
.arg(cmd)
|
||||||
|
.arg("_")
|
||||||
|
.arg("close")
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
let _ = child.wait().unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.action_on_typing_activated = false;
|
||||||
|
|
||||||
self.visible = false;
|
self.visible = false;
|
||||||
self.update_capture_filter();
|
self.update_capture_filter();
|
||||||
self.drag_surface = None;
|
self.drag_surface = None;
|
||||||
|
|
@ -750,6 +780,31 @@ impl Application for App {
|
||||||
Msg::PanelConfig(config) => {
|
Msg::PanelConfig(config) => {
|
||||||
self.panel_configs.insert(config.name.clone(), Some(config));
|
self.panel_configs.insert(config.name.clone(), Some(config));
|
||||||
}
|
}
|
||||||
|
Msg::ActionOnTyping(input) => {
|
||||||
|
let cmd = match self.conf.workspace_config.action_on_typing {
|
||||||
|
cosmic_comp_config::workspace::Action::None => return Task::none(),
|
||||||
|
cosmic_comp_config::workspace::Action::OpenLauncher => {
|
||||||
|
Some("cosmic-launcher \"$@\"".to_string())
|
||||||
|
}
|
||||||
|
cosmic_comp_config::workspace::Action::OpenApplications => {
|
||||||
|
Some("cosmic-app-library \"$@\"".to_string())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Some(cmd) = cmd {
|
||||||
|
tokio::spawn(async {
|
||||||
|
let mut child = Command::new("/bin/sh")
|
||||||
|
.arg("-c")
|
||||||
|
.arg(cmd)
|
||||||
|
.arg("_")
|
||||||
|
.arg("input")
|
||||||
|
.arg(input)
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
let _ = child.wait().unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self.action_on_typing_activated = true;
|
||||||
|
}
|
||||||
Msg::Ignore => {}
|
Msg::Ignore => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -776,13 +831,17 @@ impl Application for App {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iced::Event::Keyboard(iced::keyboard::Event::KeyReleased {
|
iced::Event::Keyboard(iced::keyboard::Event::KeyPressed {
|
||||||
key: Key::Named(Named::Escape),
|
key: Key::Named(Named::Escape),
|
||||||
modifiers: _,
|
..
|
||||||
location: _,
|
|
||||||
modified_key: _,
|
|
||||||
physical_key: _,
|
|
||||||
}) => Some(Msg::Close),
|
}) => Some(Msg::Close),
|
||||||
|
iced::Event::Keyboard(iced::keyboard::Event::KeyPressed {
|
||||||
|
key: Key::Character(key),
|
||||||
|
modifiers,
|
||||||
|
..
|
||||||
|
}) if !modifiers.control() && !modifiers.alt() && !modifiers.logo() => {
|
||||||
|
Some(Msg::ActionOnTyping(key.to_string()))
|
||||||
|
}
|
||||||
// XXX Workaround for `on_finish`/`on_cancel` not being called, seemingly
|
// XXX Workaround for `on_finish`/`on_cancel` not being called, seemingly
|
||||||
// due to state diffing behavior.
|
// due to state diffing behavior.
|
||||||
iced::Event::Dnd(DndEvent::Source(SourceEvent::Finished | SourceEvent::Cancelled)) => {
|
iced::Event::Dnd(DndEvent::Source(SourceEvent::Finished | SourceEvent::Cancelled)) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue