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