Skip to content

Commit 90883c6

Browse files
ids1024Drakulix
authored andcommitted
Add cosmic_atspi_v1 protocol
Used to provide a backend for `AtspiDevice` in `at-spi2-core`, so Orca keybindings can work.
1 parent eb64fda commit 90883c6

File tree

9 files changed

+561
-3
lines changed

9 files changed

+561
-3
lines changed

Cargo.lock

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ wayland-scanner = "0.31.1"
5454
xcursor = "0.3.3"
5555
xdg = "^2.1"
5656
xdg-user = "0.2.1"
57-
xkbcommon = "0.7"
57+
xkbcommon = "0.8"
5858
zbus = "4.4.0"
5959
profiling = { version = "1.0" }
6060
rustix = { version = "0.38.32", features = ["process"] }
6161
smallvec = "1.13.2"
6262
rand = "0.8.5"
63+
reis = { version = "0.4", features = ["calloop"] }
6364
drm-ffi = "0.8.0"
6465

6566
[dependencies.id_tree]

src/config/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ fn config_changed(config: cosmic_config::Config, keys: Vec<String>, state: &mut
640640
}
641641
}
642642
}
643+
state.common.atspi_ei.update_keymap(value.clone());
643644
state.common.config.cosmic_conf.xkb_config = value;
644645
}
645646
"input_default" => {

src/input/mod.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,13 @@ impl State {
14641464
.unwrap_or(false)
14651465
});
14661466

1467+
self.common.atspi_ei.input(
1468+
modifiers,
1469+
&handle,
1470+
event.state(),
1471+
event.time() as u64 * 1000,
1472+
);
1473+
14671474
// Leave move overview mode, if any modifier was released
14681475
if let Some(Trigger::KeyboardMove(action_modifiers)) =
14691476
shell.overview_mode().0.active_trigger()
@@ -1625,6 +1632,57 @@ impl State {
16251632
)));
16261633
}
16271634

1635+
if event.state() == KeyState::Released {
1636+
let removed = self
1637+
.common
1638+
.atspi_ei
1639+
.active_virtual_mods
1640+
.remove(&event.key_code());
1641+
// If `Caps_Lock` is a virtual modifier, and is in locked state, clear it
1642+
if removed && handle.modified_sym() == Keysym::Caps_Lock {
1643+
if (modifiers.serialized.locked & 2) != 0 {
1644+
let serial = SERIAL_COUNTER.next_serial();
1645+
let time = self.common.clock.now().as_millis();
1646+
keyboard.input(
1647+
self,
1648+
event.key_code(),
1649+
KeyState::Pressed,
1650+
serial,
1651+
time,
1652+
|_, _, _| FilterResult::<()>::Forward,
1653+
);
1654+
let serial = SERIAL_COUNTER.next_serial();
1655+
keyboard.input(
1656+
self,
1657+
event.key_code(),
1658+
KeyState::Released,
1659+
serial,
1660+
time,
1661+
|_, _, _| FilterResult::<()>::Forward,
1662+
);
1663+
}
1664+
}
1665+
} else if event.state() == KeyState::Pressed
1666+
&& self
1667+
.common
1668+
.atspi_ei
1669+
.virtual_mods
1670+
.contains(&event.key_code())
1671+
{
1672+
self.common
1673+
.atspi_ei
1674+
.active_virtual_mods
1675+
.insert(event.key_code());
1676+
1677+
tracing::debug!(
1678+
"active virtual mods: {:?}",
1679+
self.common.atspi_ei.active_virtual_mods
1680+
);
1681+
seat.supressed_keys().add(&handle, None);
1682+
1683+
return FilterResult::Intercept(None);
1684+
}
1685+
16281686
// Skip released events for initially surpressed keys
16291687
if event.state() == KeyState::Released {
16301688
if let Some(tokens) = seat.supressed_keys().filter(&handle) {
@@ -1649,6 +1707,15 @@ impl State {
16491707
return FilterResult::Intercept(None);
16501708
}
16511709

1710+
if self.common.atspi_ei.has_keyboard_grab()
1711+
|| self
1712+
.common
1713+
.atspi_ei
1714+
.has_key_grab(modifiers.serialized.layout_effective, event.key_code())
1715+
{
1716+
return FilterResult::Intercept(None);
1717+
}
1718+
16521719
// handle the rest of the global shortcuts
16531720
let mut clear_queue = true;
16541721
if !shortcuts_inhibited {

src/state.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{
1212
shell::{grabs::SeatMoveGrabState, CosmicSurface, SeatExt, Shell},
1313
utils::prelude::OutputExt,
1414
wayland::protocols::{
15+
atspi::AtspiState,
1516
drm::WlDrmState,
1617
image_source::ImageSourceState,
1718
output_configuration::OutputConfigurationState,
@@ -229,6 +230,9 @@ pub struct Common {
229230
pub xwayland_state: Option<XWaylandState>,
230231
pub xwayland_shell_state: XWaylandShellState,
231232
pub pointer_focus_state: Option<PointerFocusState>,
233+
234+
pub atspi_state: AtspiState,
235+
pub atspi_ei: crate::wayland::handlers::atspi::AtspiEiState,
232236
}
233237

234238
#[derive(Debug)]
@@ -559,6 +563,9 @@ impl State {
559563
tracing::warn!(?err, "Failed to initialize dbus handlers");
560564
}
561565

566+
// TODO: Restrict to only specific client?
567+
let atspi_state = AtspiState::new::<State, _>(dh, client_is_privileged);
568+
562569
State {
563570
common: Common {
564571
config,
@@ -615,6 +622,9 @@ impl State {
615622
xwayland_state: None,
616623
xwayland_shell_state,
617624
pointer_focus_state: None,
625+
626+
atspi_state,
627+
atspi_ei: Default::default(),
618628
},
619629
backend: BackendData::Unset,
620630
ready: Once::new(),

0 commit comments

Comments
 (0)