Show if caps lock is active, fixes #115
This commit is contained in:
parent
b16be3c5ae
commit
b38bcd296a
6 changed files with 719 additions and 433 deletions
1131
Cargo.lock
generated
1131
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -132,9 +132,6 @@ git = "https://github.com/pop-os/libcosmic"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
# [patch.'https://github.com/pop-os/libcosmic']
|
# [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" }
|
# libcosmic = { path = "../libcosmic" }
|
||||||
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
||||||
# cosmic-theme = { path = "../libcosmic/cosmic-theme" }
|
# cosmic-theme = { path = "../libcosmic/cosmic-theme" }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
cancel = Cancel
|
cancel = Cancel
|
||||||
|
caps-lock = Caps lock is active.
|
||||||
keyboard-layout = Keyboard layout
|
keyboard-layout = Keyboard layout
|
||||||
restart = Restart
|
restart = Restart
|
||||||
restart-now = Restart now?
|
restart-now = Restart now?
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ pub struct ActiveLayout {
|
||||||
pub struct Common<M> {
|
pub struct Common<M> {
|
||||||
pub active_layouts: Vec<ActiveLayout>,
|
pub active_layouts: Vec<ActiveLayout>,
|
||||||
pub active_surface_id_opt: Option<SurfaceId>,
|
pub active_surface_id_opt: Option<SurfaceId>,
|
||||||
|
pub caps_lock: bool,
|
||||||
pub comp_config_handler: Option<cosmic_config::Config>,
|
pub comp_config_handler: Option<cosmic_config::Config>,
|
||||||
pub core: Core,
|
pub core: Core,
|
||||||
pub error_opt: Option<String>,
|
pub error_opt: Option<String>,
|
||||||
|
|
@ -49,6 +50,7 @@ pub struct Common<M> {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Message {
|
pub enum Message {
|
||||||
|
CapsLock(bool),
|
||||||
Focus(SurfaceId),
|
Focus(SurfaceId),
|
||||||
Key(Modifiers, Key, Option<SmolStr>),
|
Key(Modifiers, Key, Option<SmolStr>),
|
||||||
NetworkIcon(Option<&'static str>),
|
NetworkIcon(Option<&'static str>),
|
||||||
|
|
@ -92,6 +94,7 @@ impl<M: From<Message> + Send + 'static> Common<M> {
|
||||||
let app = Self {
|
let app = Self {
|
||||||
active_layouts: Vec::new(),
|
active_layouts: Vec::new(),
|
||||||
active_surface_id_opt: None,
|
active_surface_id_opt: None,
|
||||||
|
caps_lock: false,
|
||||||
comp_config_handler,
|
comp_config_handler,
|
||||||
core,
|
core,
|
||||||
error_opt: None,
|
error_opt: None,
|
||||||
|
|
@ -236,6 +239,9 @@ impl<M: From<Message> + Send + 'static> Common<M> {
|
||||||
|
|
||||||
pub fn update(&mut self, message: Message) -> Task<M> {
|
pub fn update(&mut self, message: Message) -> Task<M> {
|
||||||
match message {
|
match message {
|
||||||
|
Message::CapsLock(caps_lock) => {
|
||||||
|
self.caps_lock = caps_lock;
|
||||||
|
}
|
||||||
Message::Focus(surface_id) => {
|
Message::Focus(surface_id) => {
|
||||||
self.active_surface_id_opt = Some(surface_id);
|
self.active_surface_id_opt = Some(surface_id);
|
||||||
if let Some(text_input_id) = self
|
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::Ignored => Some(Message::Key(modifiers, key, text)),
|
||||||
event::Status::Captured => None,
|
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(
|
iced::Event::PlatformSpecific(iced::event::PlatformSpecific::Wayland(
|
||||||
wayland_event,
|
wayland_event,
|
||||||
)) => match wayland_event {
|
)) => match wayland_event {
|
||||||
|
|
|
||||||
|
|
@ -644,6 +644,10 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
column = column.push(text_input);
|
column = column.push(text_input);
|
||||||
|
|
||||||
|
if self.common.caps_lock {
|
||||||
|
column = column.push(widget::text(fl!("caps-lock")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
column = column.push(
|
column = column.push(
|
||||||
|
|
|
||||||
|
|
@ -430,6 +430,10 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
column = column.push(text_input);
|
column = column.push(text_input);
|
||||||
|
|
||||||
|
if self.common.caps_lock {
|
||||||
|
column = column.push(widget::text(fl!("caps-lock")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
column = column.push(widget::text(prompt));
|
column = column.push(widget::text(prompt));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue