Skip to content

Commit 5580125

Browse files
committed
virtual_mods
1 parent 68ee755 commit 5580125

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/dbus/a11y_keyboard_monitor.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/data/dbus-interfaces/org.freedesktop.a11y.xml
22
//
33
// TODO: Restrict protocol acccess?
4+
// TODO remove client when not connected to server
45

56
use futures_executor::ThreadPool;
67
use smithay::backend::input::KeyState;
@@ -97,7 +98,7 @@ impl A11yKeyboardMonitorState {
9798
}
9899
}
99100

100-
pub fn has_virtual_modifier(&self, keysym: Keysym) -> bool {
101+
pub fn has_virtual_mod(&self, keysym: Keysym) -> bool {
101102
self.clients
102103
.lock()
103104
.unwrap()
@@ -106,7 +107,11 @@ impl A11yKeyboardMonitorState {
106107
.any(|client| client.virtual_mods.contains(&keysym))
107108
}
108109

109-
pub fn remove_active_virtual_modifier(&mut self, keysym: Keysym) -> bool {
110+
pub fn add_active_virtual_mod(&mut self, keysym: Keysym) {
111+
self.active_virtual_mods.insert(keysym);
112+
}
113+
114+
pub fn remove_active_virtual_mod(&mut self, keysym: Keysym) -> bool {
110115
self.active_virtual_mods.remove(&keysym)
111116
}
112117

src/input/mod.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,11 +1729,15 @@ impl State {
17291729
}
17301730

17311731
if event.state() == KeyState::Released {
1732-
let removed = self
1732+
let mut removed = self
17331733
.common
17341734
.atspi_ei
17351735
.active_virtual_mods
17361736
.remove(&event.key_code());
1737+
removed |= self
1738+
.common
1739+
.a11y_keyboard_monitor_state
1740+
.remove_active_virtual_mod(handle.modified_sym());
17371741
// If `Caps_Lock` is a virtual modifier, and is in locked state, clear it
17381742
if removed && handle.modified_sym() == Keysym::Caps_Lock {
17391743
if (modifiers.serialized.locked & 2) != 0 {
@@ -1759,16 +1763,23 @@ impl State {
17591763
}
17601764
}
17611765
} else if event.state() == KeyState::Pressed
1762-
&& self
1766+
&& (self
17631767
.common
17641768
.atspi_ei
17651769
.virtual_mods
17661770
.contains(&event.key_code())
1771+
|| self
1772+
.common
1773+
.a11y_keyboard_monitor_state
1774+
.has_virtual_mod(handle.modified_sym()))
17671775
{
17681776
self.common
17691777
.atspi_ei
17701778
.active_virtual_mods
17711779
.insert(event.key_code());
1780+
self.common
1781+
.a11y_keyboard_monitor_state
1782+
.add_active_virtual_mod(handle.modified_sym());
17721783

17731784
tracing::debug!(
17741785
"active virtual mods: {:?}",

0 commit comments

Comments
 (0)