feat(applications): Add xwayland global shortcuts configuration
This commit is contained in:
parent
44a9840fea
commit
582a94ce06
2 changed files with 121 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ use cosmic::{
|
||||||
iced::Length,
|
iced::Length,
|
||||||
widget::{self, text},
|
widget::{self, text},
|
||||||
};
|
};
|
||||||
|
use cosmic_comp_config::{EavesdroppingKeyboardMode, XwaylandEavesdropping};
|
||||||
use cosmic_settings_page::Section;
|
use cosmic_settings_page::Section;
|
||||||
use cosmic_settings_page::{self as page, section};
|
use cosmic_settings_page::{self as page, section};
|
||||||
use slab::Slab;
|
use slab::Slab;
|
||||||
|
|
@ -16,11 +17,14 @@ use tracing::error;
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Message {
|
pub enum Message {
|
||||||
SetXwaylandDescaling(bool),
|
SetXwaylandDescaling(bool),
|
||||||
|
SetXwaylandKeyboardMode(EavesdroppingKeyboardMode),
|
||||||
|
SetXwaylandMouseButtonMode(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
comp_config: cosmic_config::Config,
|
comp_config: cosmic_config::Config,
|
||||||
comp_config_descale_xwayland: bool,
|
comp_config_descale_xwayland: bool,
|
||||||
|
comp_config_xwayland_eavesdropping: XwaylandEavesdropping,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Page {
|
impl Default for Page {
|
||||||
|
|
@ -34,9 +38,20 @@ impl Default for Page {
|
||||||
|
|
||||||
false
|
false
|
||||||
});
|
});
|
||||||
|
let comp_config_xwayland_eavesdropping = comp_config
|
||||||
|
.get("xwayland_eavesdropping")
|
||||||
|
.unwrap_or_else(|err| {
|
||||||
|
if err.is_err() {
|
||||||
|
error!(?err, "Failed to read config 'xwayland_eavesdropping'");
|
||||||
|
}
|
||||||
|
|
||||||
|
Default::default()
|
||||||
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
comp_config,
|
comp_config,
|
||||||
comp_config_descale_xwayland,
|
comp_config_descale_xwayland,
|
||||||
|
comp_config_xwayland_eavesdropping,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -46,10 +61,10 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
&self,
|
&self,
|
||||||
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
|
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
|
||||||
) -> Option<page::Content> {
|
) -> Option<page::Content> {
|
||||||
Some(vec![sections.insert(
|
Some(vec![
|
||||||
// Xwayland scaling options
|
sections.insert(legacy_application_global_shortcuts()),
|
||||||
legacy_application_scaling(),
|
sections.insert(legacy_application_scaling()),
|
||||||
)])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn info(&self) -> page::Info {
|
fn info(&self) -> page::Info {
|
||||||
|
|
@ -76,10 +91,104 @@ impl Page {
|
||||||
error!(?err, "Failed to set config 'descale_xwayland'");
|
error!(?err, "Failed to set config 'descale_xwayland'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::SetXwaylandKeyboardMode(mode) => {
|
||||||
|
self.comp_config_xwayland_eavesdropping.keyboard = mode;
|
||||||
|
if let Err(err) = self.comp_config.set(
|
||||||
|
"xwayland_eavesdropping",
|
||||||
|
self.comp_config_xwayland_eavesdropping,
|
||||||
|
) {
|
||||||
|
error!(?err, "Failed to set config 'xwayland_eavesdropping'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Message::SetXwaylandMouseButtonMode(mode) => {
|
||||||
|
self.comp_config_xwayland_eavesdropping.pointer = mode;
|
||||||
|
if let Err(err) = self.comp_config.set(
|
||||||
|
"xwayland_eavesdropping",
|
||||||
|
self.comp_config_xwayland_eavesdropping,
|
||||||
|
) {
|
||||||
|
error!(?err, "Failed to set config 'xwayland_eavesdropping'");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn legacy_application_global_shortcuts() -> Section<crate::pages::Message> {
|
||||||
|
let mut descriptions = Slab::new();
|
||||||
|
|
||||||
|
let desc = descriptions.insert(fl!("legacy-app-global-shortcuts", "desc"));
|
||||||
|
let none = descriptions.insert(fl!("legacy-app-global-shortcuts", "none"));
|
||||||
|
let modifiers = descriptions.insert(fl!("legacy-app-global-shortcuts", "modifiers"));
|
||||||
|
let combination = descriptions.insert(fl!("legacy-app-global-shortcuts", "combination"));
|
||||||
|
let all = descriptions.insert(fl!("legacy-app-global-shortcuts", "all"));
|
||||||
|
let mouse = descriptions.insert(fl!("legacy-app-global-shortcuts", "mouse"));
|
||||||
|
|
||||||
|
Section::default()
|
||||||
|
.title(fl!("legacy-app-global-shortcuts"))
|
||||||
|
.descriptions(descriptions)
|
||||||
|
.view::<Page>(move |_binder, page, section| {
|
||||||
|
let title = widget::text::body(§ion.title).font(cosmic::font::bold());
|
||||||
|
let description = widget::text::body(§ion.descriptions[desc]);
|
||||||
|
|
||||||
|
let content = widget::settings::section()
|
||||||
|
.add(widget::settings::item_row(vec![
|
||||||
|
widget::radio(
|
||||||
|
text::body(§ion.descriptions[none]),
|
||||||
|
EavesdroppingKeyboardMode::None,
|
||||||
|
Some(page.comp_config_xwayland_eavesdropping.keyboard),
|
||||||
|
Message::SetXwaylandKeyboardMode,
|
||||||
|
)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.into(),
|
||||||
|
]))
|
||||||
|
.add(widget::settings::item_row(vec![
|
||||||
|
widget::radio(
|
||||||
|
text::body(§ion.descriptions[modifiers]),
|
||||||
|
EavesdroppingKeyboardMode::Modifiers,
|
||||||
|
Some(page.comp_config_xwayland_eavesdropping.keyboard),
|
||||||
|
Message::SetXwaylandKeyboardMode,
|
||||||
|
)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.into(),
|
||||||
|
]))
|
||||||
|
.add(widget::settings::item_row(vec![
|
||||||
|
widget::radio(
|
||||||
|
text::body(§ion.descriptions[combination]),
|
||||||
|
EavesdroppingKeyboardMode::Combinations,
|
||||||
|
Some(page.comp_config_xwayland_eavesdropping.keyboard),
|
||||||
|
Message::SetXwaylandKeyboardMode,
|
||||||
|
)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.into(),
|
||||||
|
]))
|
||||||
|
.add(widget::settings::item_row(vec![
|
||||||
|
widget::radio(
|
||||||
|
text::body(§ion.descriptions[all]),
|
||||||
|
EavesdroppingKeyboardMode::All,
|
||||||
|
Some(page.comp_config_xwayland_eavesdropping.keyboard),
|
||||||
|
Message::SetXwaylandKeyboardMode,
|
||||||
|
)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.into(),
|
||||||
|
]))
|
||||||
|
.add(widget::settings::item(
|
||||||
|
§ion.descriptions[mouse],
|
||||||
|
widget::toggler(page.comp_config_xwayland_eavesdropping.pointer)
|
||||||
|
.on_toggle(Message::SetXwaylandMouseButtonMode),
|
||||||
|
))
|
||||||
|
.apply(Element::from)
|
||||||
|
.map(crate::pages::Message::LegacyApplications);
|
||||||
|
|
||||||
|
widget::column::with_capacity(3)
|
||||||
|
.push(title)
|
||||||
|
.push(description)
|
||||||
|
.push(content)
|
||||||
|
.spacing(cosmic::theme::active().cosmic().spacing.space_xxs)
|
||||||
|
.apply(cosmic::Element::from)
|
||||||
|
.map(Into::into)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn legacy_application_scaling() -> Section<crate::pages::Message> {
|
pub fn legacy_application_scaling() -> Section<crate::pages::Message> {
|
||||||
let mut descriptions = Slab::new();
|
let mut descriptions = Slab::new();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -825,6 +825,14 @@ startup-apps = Startup Applications
|
||||||
legacy-applications = X11 Applications Compatibility
|
legacy-applications = X11 Applications Compatibility
|
||||||
.desc = X11 Window system application scaling and Global shortcuts.
|
.desc = X11 Window system application scaling and Global shortcuts.
|
||||||
|
|
||||||
|
legacy-app-global-shortcuts = Global Shortcuts in X11 Applications
|
||||||
|
.desc = Global shortcuts allows keystrokes and mouse button events performed in applications to be recognized by other applications for features like push-to-talk or push-to-mute. By default, this is disabled in X11 applications to ensure other applications can’t monitor for keyboard and mouse events containing sensitive information.
|
||||||
|
.none = No keys
|
||||||
|
.modifiers = Modifiers (Super, Shift, Control, Alt)
|
||||||
|
.combination = All keys while modifiers Super, Control or Alt are being pressed
|
||||||
|
.all = All keys
|
||||||
|
.mouse = Mouse button events in X11 applications
|
||||||
|
|
||||||
legacy-app-scaling = X11 Window System Application Scaling
|
legacy-app-scaling = X11 Window System Application Scaling
|
||||||
.scaled-by-system = Scale all X11 Applications
|
.scaled-by-system = Scale all X11 Applications
|
||||||
.system-description = X11 applications will appear blurry on HiDPI screens.
|
.system-description = X11 applications will appear blurry on HiDPI screens.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue