Skip to content

Commit

Permalink
WIP ei socket for at-spi2-core
Browse files Browse the repository at this point in the history
This works with the `receive` example of `reis` using
`LIBEI_SOCKET=/tmp/atspi-ei-kb.socket`. I've also worked on changes to
at-spi2-core, so I'll now be able to try testing it...

If a version of this is ultimately used, it will need a secure way to
pass the socket to accessibility tools. Putting it in `/tmp` is a
placeholder.

WIP

initial modifiers

start_emulating

fix keycode offset

WIP use cosmic-atspi-unstable-v1 protocol

Now client has a way to communicate grabs, but they still need to be
handled here.

WIP grabs

WIP keycode offset

atspi grabs

SealedFile

add_keyboard

Update reis with improved api

WIP update_keymap

WIP update keymap

WIP grab keyboardt

Multiple clients

reis update; serial
  • Loading branch information
ids1024 committed Oct 4, 2024
1 parent a96394f commit 42e616e
Show file tree
Hide file tree
Showing 9 changed files with 533 additions and 7 deletions.
22 changes: 16 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bytemuck = "1.12"
calloop = {version = "0.14.1", features = ["executor"]}
cosmic-comp-config = {path = "cosmic-comp-config"}
cosmic-config = {git = "https://github.com/pop-os/libcosmic/", features = ["calloop", "macro"]}
cosmic-protocols = {git = "https://github.com/pop-os/cosmic-protocols", branch = "main", default-features = false, features = ["server"]}
cosmic-protocols = {git = "https://github.com/pop-os/cosmic-protocols", branch = "atspi-ei", default-features = false, features = ["server"]}
cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon" }
edid-rs = {version = "0.1"}
egui = {version = "0.29.0", optional = true}
Expand Down Expand Up @@ -60,6 +60,7 @@ profiling = { version = "1.0" }
rustix = { version = "0.38.32", features = ["process"] }
smallvec = "1.13.2"
rand = "0.8.5"
reis = { git = "https://github.com/ids1024/reis", features = ["calloop"] }

[dependencies.id_tree]
branch = "feature/copy_clone"
Expand Down
1 change: 1 addition & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ fn config_changed(config: cosmic_config::Config, keys: Vec<String>, state: &mut
}
}
}
state.common.atspi_ei.update_keymap(value.clone());
state.common.config.cosmic_conf.xkb_config = value;
}
"input_default" => {
Expand Down
43 changes: 43 additions & 0 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,13 @@ impl State {
.unwrap_or(false)
});

self.common.atspi_ei.input(
modifiers,
&handle,
event.state(),
event.time() as u64 * 1000,
);

// Leave move overview mode, if any modifier was released
if let Some(Trigger::KeyboardMove(action_modifiers)) =
shell.overview_mode().0.active_trigger()
Expand Down Expand Up @@ -1611,6 +1618,32 @@ impl State {
)));
}

if event.state() == KeyState::Released {
self.common
.atspi_ei
.active_virtual_mods
.remove(&event.key_code());
} else if event.state() == KeyState::Pressed
&& self
.common
.atspi_ei
.virtual_mods
.contains(&event.key_code())
{
self.common
.atspi_ei
.active_virtual_mods
.insert(event.key_code());

tracing::error!(
"active virtual mods: {:?}",
self.common.atspi_ei.active_virtual_mods
);
seat.supressed_keys().add(&handle, None);

return FilterResult::Intercept(None);
}

// Skip released events for initially surpressed keys
if event.state() == KeyState::Released {
if let Some(tokens) = seat.supressed_keys().filter(&handle) {
Expand All @@ -1635,6 +1668,16 @@ impl State {
return FilterResult::Intercept(None);
}

// TODO modifiers queue
if self.common.atspi_ei.has_keyboard_grab()
|| self
.common
.atspi_ei
.has_key_grab(modifiers.serialized.layout_effective, event.key_code())
{
return FilterResult::Intercept(None);
}

// handle the rest of the global shortcuts
let mut clear_queue = true;
if !shortcuts_inhibited {
Expand Down
10 changes: 10 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
shell::{grabs::SeatMoveGrabState, CosmicSurface, SeatExt, Shell},
utils::prelude::OutputExt,
wayland::protocols::{
atspi::AtspiState,
drm::WlDrmState,
image_source::ImageSourceState,
output_configuration::OutputConfigurationState,
Expand Down Expand Up @@ -227,6 +228,9 @@ pub struct Common {
pub xwayland_state: Option<XWaylandState>,
pub xwayland_shell_state: XWaylandShellState,
pub pointer_focus_state: Option<PointerFocusState>,

pub atspi_state: AtspiState,
pub atspi_ei: crate::wayland::handlers::atspi::AtspiEiState,
}

#[derive(Debug)]
Expand Down Expand Up @@ -567,6 +571,9 @@ impl State {
tracing::warn!(?err, "Failed to initialize dbus handlers");
}

// TODO: Restrict to only specific client?
let atspi_state = AtspiState::new::<State, _>(dh, client_is_privileged);

State {
common: Common {
config,
Expand Down Expand Up @@ -622,6 +629,9 @@ impl State {
xwayland_state: None,
xwayland_shell_state,
pointer_focus_state: None,

atspi_state,
atspi_ei: Default::default(),
},
backend: BackendData::Unset,
ready: Once::new(),
Expand Down
Loading

0 comments on commit 42e616e

Please sign in to comment.