atspi_proxies/
device_event_controller.rs

1//! # `DBus` interface proxy for: `org.a11y.atspi.DeviceEventController`
2//!
3//! This code was generated by `zbus-xmlgen` `2.0.1` from `DBus` introspection data.
4//! Source: `DeviceEventController.xml`.
5//!
6//! You may prefer to adapt it, instead of using it verbatim.
7//!
8//! More information can be found in the
9//! [Writing a client proxy](https://dbus.pages.freedesktop.org/zbus/client.html)
10//! section of the zbus documentation.
11//!
12
13use serde::{Deserialize, Serialize};
14use zbus::zvariant::Type;
15
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
17#[repr(u32)]
18pub enum EventType {
19	KeyPressed,
20	KeyReleased,
21	ButtonPressed,
22	ButtonReleased,
23}
24
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
26#[repr(u32)]
27pub enum KeySynthType {
28	Press,
29	Release,
30	Pressrelease,
31	Sym,
32	String,
33	Lockmodifiers,
34	Unlockmodifiers,
35}
36
37#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
38pub struct DeviceEvent<'a> {
39	pub event_type: EventType,
40	pub id: i32,
41	pub hw_code: i32,
42	pub modifiers: i32,
43	pub timestamp: i32,
44	pub event_string: &'a str,
45	pub is_text: bool,
46}
47
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
49pub struct EventListenerMode {
50	/// Whether events are delivered synchronously, before the currently focused application sees them.
51	/// If `false`, events may be delivered asynchronously, which means in some
52	/// cases they may already have been delivered to the
53	/// application before the AT client receives the notification.
54	pub synchronous: bool,
55	/// Whether events may be consumed by the AT client.
56	/// Requires [`EventListenerMode::synchronous`] to be set to `true`.
57	pub preemptive: bool,
58	/// If `true`, indicates that events are received not from the application toolkit layer,
59	/// but from the device driver or windowing system subsystem.
60	pub global: bool,
61}
62
63#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
64pub struct KeyDefinition<'a> {
65	pub keycode: i32,
66	pub keysym: i32,
67	pub keystring: &'a str,
68	pub unused: i32,
69}
70
71#[zbus::proxy(
72	interface = "org.a11y.atspi.DeviceEventController",
73	default_path = "/org/a11y/atspi/registry/deviceeventcontroller",
74	default_service = "org.a11y.atspi.Registry"
75)]
76pub trait DeviceEventController {
77	/// DeregisterDeviceEventListener method
78	fn deregister_device_event_listener(
79		&self,
80		listener: &zbus::zvariant::ObjectPath<'_>,
81		types: EventType,
82	) -> zbus::Result<()>;
83
84	/// DeregisterKeystrokeListener method
85	fn deregister_keystroke_listener(
86		&self,
87		listener: &zbus::zvariant::ObjectPath<'_>,
88		keys: &[KeyDefinition<'_>],
89		mask: u32,
90		type_: EventType,
91	) -> zbus::Result<()>;
92
93	/// GenerateKeyboardEvent method
94	fn generate_keyboard_event(
95		&self,
96		keycode: i32,
97		keystring: &str,
98		type_: KeySynthType,
99	) -> zbus::Result<()>;
100
101	/// GenerateMouseEvent method
102	fn generate_mouse_event(&self, x: i32, y: i32, event_name: &str) -> zbus::Result<()>;
103
104	/// NotifyListenersAsync method
105	fn notify_listeners_async(&self, event: &DeviceEvent<'_>) -> zbus::Result<()>;
106
107	/// NotifyListenersSync method
108	fn notify_listeners_sync(&self, event: &DeviceEvent<'_>) -> zbus::Result<bool>;
109
110	/// RegisterDeviceEventListener method
111	fn register_device_event_listener(
112		&self,
113		listener: &zbus::zvariant::ObjectPath<'_>,
114		types: EventType,
115	) -> zbus::Result<bool>;
116
117	/// RegisterKeystrokeListener method
118	fn register_keystroke_listener(
119		&self,
120		listener: &zbus::zvariant::ObjectPath<'_>,
121		keys: &[KeyDefinition<'_>],
122		mask: u32,
123		type_: &[EventType],
124		mode: &EventListenerMode,
125	) -> zbus::Result<bool>;
126}