fix(a11y): close magnifier overlay and sync view moves

This commit is contained in:
Konstantinos 2025-12-24 06:25:07 +02:00 committed by GitHub
parent e2efacd3f8
commit 9795cf9c31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 79 additions and 3 deletions

View file

@ -39,6 +39,8 @@ use cosmic::{
settings, text_input, settings, text_input,
}, },
}; };
#[cfg(any(feature = "page-window-management", feature = "page-accessibility"))]
use cosmic_comp_config::CosmicCompConfig;
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
use cosmic_panel_config::CosmicPanelConfig; use cosmic_panel_config::CosmicPanelConfig;
use cosmic_settings_page::{self as page, section}; use cosmic_settings_page::{self as page, section};
@ -163,6 +165,8 @@ pub enum Message {
PageMessage(crate::pages::Message), PageMessage(crate::pages::Message),
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
PanelConfig(CosmicPanelConfig), PanelConfig(CosmicPanelConfig),
#[cfg(any(feature = "page-window-management", feature = "page-accessibility"))]
CompConfig(CosmicCompConfig),
SearchActivate, SearchActivate,
SearchChanged(String), SearchChanged(String),
SearchClear, SearchClear,
@ -343,6 +347,16 @@ impl cosmic::Application for SettingsApp {
Message::PanelConfig(update.config) Message::PanelConfig(update.config)
}), }),
page.subscription(self.core()).map(Message::PageMessage), page.subscription(self.core()).map(Message::PageMessage),
#[cfg(any(feature = "page-window-management", feature = "page-accessibility"))]
self.core()
.watch_config::<CosmicCompConfig>("com.system76.CosmicComp")
.map(|update| {
for why in update.errors {
tracing::error!(?why, "comp config load error");
}
Message::CompConfig(update.config)
}),
]; ];
Subscription::batch(subscriptions) Subscription::batch(subscriptions)
@ -754,6 +768,41 @@ impl cosmic::Application for SettingsApp {
return Task::batch(tasks); return Task::batch(tasks);
} }
#[cfg(any(feature = "page-window-management", feature = "page-accessibility"))]
Message::CompConfig(comp_config) => {
let mut tasks = Vec::new();
#[cfg(feature = "page-window-management")]
if let Some(page) = self
.pages
.page_mut::<crate::pages::desktop::window_management::Page>()
{
tasks.push(
page.update(
crate::pages::desktop::window_management::Message::CompConfigUpdate(
comp_config.clone(),
),
)
.map(Into::into),
);
}
#[cfg(feature = "page-accessibility")]
if let Some(page) = self.pages.page_mut::<accessibility::magnifier::Page>() {
tasks.push(
page.update(
self.active_page,
crate::pages::accessibility::magnifier::Message::CompConfigUpdate(
comp_config.clone(),
),
)
.map(Into::into),
);
}
return Task::batch(tasks);
}
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]
Message::PanelConfig(_) => {} Message::PanelConfig(_) => {}
#[cfg(feature = "wayland")] #[cfg(feature = "wayland")]

View file

@ -38,6 +38,7 @@ pub struct Page {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum Message { pub enum Message {
Event(wayland::AccessibilityEvent), Event(wayland::AccessibilityEvent),
CompConfigUpdate(cosmic_comp_config::CosmicCompConfig),
ProtocolUnavailable, ProtocolUnavailable,
SetMagnifier(bool), SetMagnifier(bool),
SetMouseShortcuts(bool), SetMouseShortcuts(bool),
@ -339,6 +340,23 @@ impl Page {
message: Message, message: Message,
) -> cosmic::iced::Task<crate::app::Message> { ) -> cosmic::iced::Task<crate::app::Message> {
match message { match message {
Message::CompConfigUpdate(comp_config) => {
if self.zoom_config.show_overlay != comp_config.accessibility_zoom.show_overlay {
self.zoom_config.show_overlay = comp_config.accessibility_zoom.show_overlay;
}
if self.zoom_config.increment != comp_config.accessibility_zoom.increment {
self.zoom_config.increment = comp_config.accessibility_zoom.increment;
self.increment_idx = self.increment_values.iter().position(|s| {
s.split('%').next().and_then(|val| str::parse(val).ok())
== Some(self.zoom_config.increment)
});
}
if self.zoom_config.view_moves != comp_config.accessibility_zoom.view_moves {
self.zoom_config.view_moves = comp_config.accessibility_zoom.view_moves;
}
}
Message::Event(AccessibilityEvent::Magnifier(value)) => { Message::Event(AccessibilityEvent::Magnifier(value)) => {
self.magnifier_state = value; self.magnifier_state = value;
} }

View file

@ -8,6 +8,7 @@ use cosmic::{
widget::{self, settings, toggler}, widget::{self, settings, toggler},
}; };
use cosmic_comp_config::CosmicCompConfig;
use cosmic_config::{ConfigGet, ConfigSet}; use cosmic_config::{ConfigGet, ConfigSet};
use cosmic_settings_config::{Action, Binding, Shortcuts, shortcuts}; use cosmic_settings_config::{Action, Binding, Shortcuts, shortcuts};
use cosmic_settings_page::Section; use cosmic_settings_page::Section;
@ -19,6 +20,7 @@ use tracing::error;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum Message { pub enum Message {
SuperKey(usize), SuperKey(usize),
CompConfigUpdate(CosmicCompConfig),
SetFocusFollowsCursor(bool), SetFocusFollowsCursor(bool),
SaveFocusFollowsCursorDelay(bool), SaveFocusFollowsCursorDelay(bool),
SetFocusFollowsCursorDelay(String), SetFocusFollowsCursorDelay(String),
@ -182,6 +184,11 @@ impl Page {
error!(?err, "Failed to set config 'active_hint'"); error!(?err, "Failed to set config 'active_hint'");
} }
} }
Message::CompConfigUpdate(comp_config) => {
if comp_config.active_hint != self.show_active_hint {
self.show_active_hint = comp_config.active_hint;
}
}
Message::SetEdgeSnapThreshold(value) => { Message::SetEdgeSnapThreshold(value) => {
self.edge_snap_threshold = value; self.edge_snap_threshold = value;
if let Err(err) = self.comp_config.set("edge_snap_threshold", value) { if let Err(err) = self.comp_config.set("edge_snap_threshold", value) {

View file

@ -404,7 +404,9 @@ fn get_lspci_gpu_names() -> HashMap<u32, String> {
// Extract the GPU name between ": " and the last "[" // Extract the GPU name between ": " and the last "["
if let Some(name_start) = line.find(": ") { if let Some(name_start) = line.find(": ") {
let full_name = line[name_start + 2..ids_start].trim(); let full_name = line[name_start + 2..ids_start].trim();
let gpu_name = full_name.replace(" Corporation", "").replace(" [Intel Graphics]", ""); let gpu_name = full_name
.replace(" Corporation", "")
.replace(" [Intel Graphics]", "");
if !gpu_name.is_empty() { if !gpu_name.is_empty() {
gpu_map.insert(device_id, gpu_name); gpu_map.insert(device_id, gpu_name);
} }