Show if caps lock is active, fixes #115

This commit is contained in:
Jeremy Soller 2025-05-15 14:18:08 -06:00
parent b16be3c5ae
commit b38bcd296a
No known key found for this signature in database
GPG key ID: 670FDFB5428E05CA
6 changed files with 719 additions and 433 deletions

1131
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -132,9 +132,6 @@ git = "https://github.com/pop-os/libcosmic"
default-features = false
# [patch.'https://github.com/pop-os/libcosmic']
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
# cosmic-theme = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
# libcosmic = { path = "../libcosmic" }
# cosmic-config = { path = "../libcosmic/cosmic-config" }
# cosmic-theme = { path = "../libcosmic/cosmic-theme" }

View file

@ -1,4 +1,5 @@
cancel = Cancel
caps-lock = Caps lock is active.
keyboard-layout = Keyboard layout
restart = Restart
restart-now = Restart now?

View file

@ -27,6 +27,7 @@ pub struct ActiveLayout {
pub struct Common<M> {
pub active_layouts: Vec<ActiveLayout>,
pub active_surface_id_opt: Option<SurfaceId>,
pub caps_lock: bool,
pub comp_config_handler: Option<cosmic_config::Config>,
pub core: Core,
pub error_opt: Option<String>,
@ -49,6 +50,7 @@ pub struct Common<M> {
#[derive(Clone, Debug)]
pub enum Message {
CapsLock(bool),
Focus(SurfaceId),
Key(Modifiers, Key, Option<SmolStr>),
NetworkIcon(Option<&'static str>),
@ -92,6 +94,7 @@ impl<M: From<Message> + Send + 'static> Common<M> {
let app = Self {
active_layouts: Vec::new(),
active_surface_id_opt: None,
caps_lock: false,
comp_config_handler,
core,
error_opt: None,
@ -236,6 +239,9 @@ impl<M: From<Message> + Send + 'static> Common<M> {
pub fn update(&mut self, message: Message) -> Task<M> {
match message {
Message::CapsLock(caps_lock) => {
self.caps_lock = caps_lock;
}
Message::Focus(surface_id) => {
self.active_surface_id_opt = Some(surface_id);
if let Some(text_input_id) = self
@ -325,6 +331,9 @@ impl<M: From<Message> + Send + 'static> Common<M> {
event::Status::Ignored => Some(Message::Key(modifiers, key, text)),
event::Status::Captured => None,
},
iced::Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
Some(Message::CapsLock(modifiers.contains(Modifiers::CAPS_LOCK)))
}
iced::Event::PlatformSpecific(iced::event::PlatformSpecific::Wayland(
wayland_event,
)) => match wayland_event {

View file

@ -644,6 +644,10 @@ impl App {
}
column = column.push(text_input);
if self.common.caps_lock {
column = column.push(widget::text(fl!("caps-lock")));
}
}
None => {
column = column.push(

View file

@ -430,6 +430,10 @@ impl App {
}
column = column.push(text_input);
if self.common.caps_lock {
column = column.push(widget::text(fl!("caps-lock")));
}
}
None => {
column = column.push(widget::text(prompt));