feat(window_management): add show active window hint button
This commit is contained in:
parent
c6d6f5e788
commit
a944359656
4 changed files with 53 additions and 49 deletions
|
|
@ -1784,7 +1784,7 @@ pub fn interface_density() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("interface-density"))
|
.title(fl!("interface-density"))
|
||||||
.descriptions(descriptions)
|
.descriptions(descriptions)
|
||||||
.view::<Page>(move |_binder, page, section| {
|
.view::<Page>(move |_binder, _page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
||||||
let density = cosmic::config::interface_density();
|
let density = cosmic::config::interface_density();
|
||||||
|
|
|
||||||
|
|
@ -8,33 +8,15 @@ pub mod wallpaper;
|
||||||
pub mod window_management;
|
pub mod window_management;
|
||||||
pub mod workspaces;
|
pub mod workspaces;
|
||||||
|
|
||||||
use cosmic::{config::CosmicTk, cosmic_config::CosmicConfigEntry};
|
|
||||||
use cosmic_settings_page as page;
|
use cosmic_settings_page as page;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
pub struct Page {
|
pub struct Page {}
|
||||||
pub cosmic_config: Option<cosmic::cosmic_config::Config>,
|
|
||||||
pub cosmic_tk: CosmicTk,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Page {
|
impl Default for Page {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let (cosmic_tk, cosmic_config) = CosmicTk::config().map_or_else(
|
Self {}
|
||||||
|why| {
|
|
||||||
tracing::error!(?why, "failed to read CosmicTk config");
|
|
||||||
(CosmicTk::default(), None)
|
|
||||||
},
|
|
||||||
|config| match CosmicTk::get_entry(&config) {
|
|
||||||
Ok(tk) => (tk, Some(config)),
|
|
||||||
Err((_errors, tk)) => (tk, Some(config)),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Self {
|
|
||||||
cosmic_config,
|
|
||||||
cosmic_tk,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,25 +38,8 @@ impl page::AutoBind<crate::pages::Message> for Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum Message {
|
pub enum Message {}
|
||||||
ShowMaximizeButton(bool),
|
|
||||||
ShowMinimizeButton(bool),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
pub fn update(&mut self, message: Message) {
|
pub fn update(&mut self, _message: Message) {}
|
||||||
match message {
|
|
||||||
Message::ShowMaximizeButton(value) => {
|
|
||||||
if let Some(config) = self.cosmic_config.as_mut() {
|
|
||||||
let _res = self.cosmic_tk.set_show_maximize(config, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Message::ShowMinimizeButton(value) => {
|
|
||||||
if let Some(config) = self.cosmic_config.as_mut() {
|
|
||||||
let _res = self.cosmic_tk.set_show_minimize(config, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ pub enum Message {
|
||||||
SaveFocusFollowsCursorDelay(bool),
|
SaveFocusFollowsCursorDelay(bool),
|
||||||
SetFocusFollowsCursorDelay(String),
|
SetFocusFollowsCursorDelay(String),
|
||||||
SetCursorFollowsFocus(bool),
|
SetCursorFollowsFocus(bool),
|
||||||
|
ShowActiveWindowHint(bool),
|
||||||
|
ShowMaximizeButton(bool),
|
||||||
|
ShowMinimizeButton(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
|
|
@ -32,6 +35,7 @@ pub struct Page {
|
||||||
focus_follows_cursor_delay: u64,
|
focus_follows_cursor_delay: u64,
|
||||||
focus_delay_text: String,
|
focus_delay_text: String,
|
||||||
cursor_follows_focus: bool,
|
cursor_follows_focus: bool,
|
||||||
|
show_active_hint: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Page {
|
impl Default for Page {
|
||||||
|
|
@ -63,6 +67,15 @@ impl Default for Page {
|
||||||
})
|
})
|
||||||
.unwrap_or(250);
|
.unwrap_or(250);
|
||||||
|
|
||||||
|
let show_active_hint = comp_config
|
||||||
|
.get("active_hint")
|
||||||
|
.inspect_err(|err| {
|
||||||
|
if !matches!(err, cosmic_config::Error::NoConfigDirectory) {
|
||||||
|
error!(?err, "Failed to read config 'active_hint'")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unwrap_or(true);
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
super_key_selections: vec![
|
super_key_selections: vec![
|
||||||
fl!("super-key", "launcher"),
|
fl!("super-key", "launcher"),
|
||||||
|
|
@ -76,6 +89,7 @@ impl Default for Page {
|
||||||
focus_follows_cursor_delay,
|
focus_follows_cursor_delay,
|
||||||
focus_delay_text: format!("{focus_follows_cursor_delay}"),
|
focus_delay_text: format!("{focus_follows_cursor_delay}"),
|
||||||
cursor_follows_focus,
|
cursor_follows_focus,
|
||||||
|
show_active_hint,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -132,6 +146,28 @@ impl Page {
|
||||||
error!(?err, "Failed to set config 'cursor_follows_focus'");
|
error!(?err, "Failed to set config 'cursor_follows_focus'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::ShowMaximizeButton(value) => {
|
||||||
|
if let Ok(config) = cosmic::config::CosmicTk::config() {
|
||||||
|
let _res = cosmic::config::COSMIC_TK
|
||||||
|
.write()
|
||||||
|
.unwrap()
|
||||||
|
.set_show_maximize(&config, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Message::ShowMinimizeButton(value) => {
|
||||||
|
if let Ok(config) = cosmic::config::CosmicTk::config() {
|
||||||
|
let _res = cosmic::config::COSMIC_TK
|
||||||
|
.write()
|
||||||
|
.unwrap()
|
||||||
|
.set_show_minimize(&config, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Message::ShowActiveWindowHint(value) => {
|
||||||
|
self.show_active_hint = value;
|
||||||
|
if let Err(err) = self.comp_config.set("active_hint", value) {
|
||||||
|
error!(?err, "Failed to set config 'active_hint'");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -194,36 +230,38 @@ pub fn window_controls() -> Section<crate::pages::Message> {
|
||||||
|
|
||||||
let maximize = descriptions.insert(fl!("window-controls", "maximize"));
|
let maximize = descriptions.insert(fl!("window-controls", "maximize"));
|
||||||
let minimize = descriptions.insert(fl!("window-controls", "minimize"));
|
let minimize = descriptions.insert(fl!("window-controls", "minimize"));
|
||||||
|
let active_window_hint = descriptions.insert(fl!("window-controls", "active-window-hint"));
|
||||||
|
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("window-controls"))
|
.title(fl!("window-controls"))
|
||||||
.descriptions(descriptions)
|
.descriptions(descriptions)
|
||||||
.view::<Page>(move |binder, _page, section| {
|
.view::<Page>(move |_binder, page, section| {
|
||||||
let desktop = binder
|
|
||||||
.page::<super::Page>()
|
|
||||||
.expect("desktop page not found");
|
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
|
|
||||||
settings::section()
|
settings::section()
|
||||||
.title(§ion.title)
|
.title(§ion.title)
|
||||||
|
.add(settings::item(
|
||||||
|
&descriptions[active_window_hint],
|
||||||
|
toggler(None, page.show_active_hint, Message::ShowActiveWindowHint),
|
||||||
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[maximize],
|
&descriptions[maximize],
|
||||||
toggler(
|
toggler(
|
||||||
None,
|
None,
|
||||||
desktop.cosmic_tk.show_maximize,
|
cosmic::config::show_maximize(),
|
||||||
super::Message::ShowMaximizeButton,
|
Message::ShowMaximizeButton,
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.add(settings::item(
|
.add(settings::item(
|
||||||
&descriptions[minimize],
|
&descriptions[minimize],
|
||||||
toggler(
|
toggler(
|
||||||
None,
|
None,
|
||||||
desktop.cosmic_tk.show_minimize,
|
cosmic::config::show_minimize(),
|
||||||
super::Message::ShowMinimizeButton,
|
Message::ShowMinimizeButton,
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::Desktop)
|
.map(crate::pages::Message::WindowManagement)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -307,6 +307,7 @@ super-key = Super key action
|
||||||
window-controls = Window Controls
|
window-controls = Window Controls
|
||||||
.maximize = Show maximize button
|
.maximize = Show maximize button
|
||||||
.minimize = Show minimize button
|
.minimize = Show minimize button
|
||||||
|
.active-window-hint = Show active window hint
|
||||||
|
|
||||||
focus-navigation = Focus Navigation
|
focus-navigation = Focus Navigation
|
||||||
.focus-follows-cursor = Focus follows cursor
|
.focus-follows-cursor = Focus follows cursor
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue