atspi_common/events/
window.rs

1#[cfg(feature = "zbus")]
2use crate::{
3	error::AtspiError,
4	events::{MessageConversion, MessageConversionExt},
5	ObjectRef,
6};
7use crate::{
8	events::{BusProperties, EventBodyOwned},
9	EventProperties,
10};
11use zbus_names::UniqueName;
12use zvariant::ObjectPath;
13
14use super::EventBodyQtOwned;
15
16#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
17pub struct PropertyChangeEvent {
18	/// The [`crate::ObjectRef`] which the event applies to.
19	pub item: crate::events::ObjectRef,
20	pub property: String,
21}
22
23/// The window has been minimized.
24#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
25pub struct MinimizeEvent {
26	/// The application which has been minimized.
27	pub item: crate::events::ObjectRef,
28}
29
30/// The window has been maximized.
31#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
32pub struct MaximizeEvent {
33	/// The application which has been maximized.
34	pub item: crate::events::ObjectRef,
35}
36
37#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
38pub struct RestoreEvent {
39	/// The [`crate::ObjectRef`] which the event applies to.
40	pub item: crate::events::ObjectRef,
41}
42
43/// A window has been closed.
44#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
45pub struct CloseEvent {
46	/// The application which has been closed.
47	pub item: crate::events::ObjectRef,
48}
49
50/// A new window has been created.
51#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
52pub struct CreateEvent {
53	/// An application to query for additional events from.
54	pub item: crate::events::ObjectRef,
55}
56
57#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
58pub struct ReparentEvent {
59	/// The [`crate::ObjectRef`] which the event applies to.
60	pub item: crate::events::ObjectRef,
61}
62
63/// A new virtual desktop has been created.
64#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
65pub struct DesktopCreateEvent {
66	/// A reference to a new desktop
67	pub item: crate::events::ObjectRef,
68}
69
70/// A virtual desktop has been deleted.
71#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
72pub struct DesktopDestroyEvent {
73	/// A reference to the destroyed desktop.
74	pub item: crate::events::ObjectRef,
75}
76
77#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
78pub struct DestroyEvent {
79	/// The [`crate::ObjectRef`] which the event applies to.
80	pub item: crate::events::ObjectRef,
81}
82
83#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
84pub struct ActivateEvent {
85	/// The [`crate::ObjectRef`] which the event applies to.
86	pub item: crate::events::ObjectRef,
87}
88
89#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
90pub struct DeactivateEvent {
91	/// The [`crate::ObjectRef`] which the event applies to.
92	pub item: crate::events::ObjectRef,
93}
94
95#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
96pub struct RaiseEvent {
97	/// The [`crate::ObjectRef`] which the event applies to.
98	pub item: crate::events::ObjectRef,
99}
100
101#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
102pub struct LowerEvent {
103	/// The [`crate::ObjectRef`] which the event applies to.
104	pub item: crate::events::ObjectRef,
105}
106
107#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
108pub struct MoveEvent {
109	/// The [`crate::ObjectRef`] which the event applies to.
110	pub item: crate::events::ObjectRef,
111}
112
113/// A window has been resized.
114#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
115pub struct ResizeEvent {
116	/// The application which has been resized.
117	pub item: crate::events::ObjectRef,
118}
119
120#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
121pub struct ShadeEvent {
122	/// The [`crate::ObjectRef`] which the event applies to.
123	pub item: crate::events::ObjectRef,
124}
125
126#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
127pub struct UUshadeEvent {
128	/// The [`crate::ObjectRef`] which the event applies to.
129	pub item: crate::events::ObjectRef,
130}
131
132#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
133pub struct RestyleEvent {
134	/// The [`crate::ObjectRef`] which the event applies to.
135	pub item: crate::events::ObjectRef,
136}
137
138impl BusProperties for PropertyChangeEvent {
139	const DBUS_MEMBER: &'static str = "PropertyChange";
140	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
141	const MATCH_RULE_STRING: &'static str =
142		"type='signal',interface='org.a11y.atspi.Event.Window',member='PropertyChange'";
143	const REGISTRY_EVENT_STRING: &'static str = "Window:";
144}
145
146#[cfg(feature = "zbus")]
147impl MessageConversion for PropertyChangeEvent {
148	type Body = EventBodyOwned;
149
150	fn from_message_unchecked_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
151		Ok(Self { item, property: body.kind })
152	}
153	fn from_message_unchecked(msg: &zbus::Message) -> Result<Self, AtspiError> {
154		let item = msg.try_into()?;
155		// TODO: Check the likely path first. also, deserialize already checks the signature
156		let body = if msg.body().signature() == crate::events::QSPI_EVENT_SIGNATURE {
157			msg.body().deserialize::<EventBodyQtOwned>()?.into()
158		} else {
159			msg.body().deserialize()?
160		};
161		Self::from_message_unchecked_parts(item, body)
162	}
163	fn body(&self) -> Self::Body {
164		let copy = self.clone();
165		copy.into()
166	}
167}
168
169impl BusProperties for MinimizeEvent {
170	const DBUS_MEMBER: &'static str = "Minimize";
171	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
172	const MATCH_RULE_STRING: &'static str =
173		"type='signal',interface='org.a11y.atspi.Event.Window',member='Minimize'";
174	const REGISTRY_EVENT_STRING: &'static str = "Window:";
175}
176
177impl BusProperties for MaximizeEvent {
178	const DBUS_MEMBER: &'static str = "Maximize";
179	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
180	const MATCH_RULE_STRING: &'static str =
181		"type='signal',interface='org.a11y.atspi.Event.Window',member='Maximize'";
182	const REGISTRY_EVENT_STRING: &'static str = "Window:";
183}
184
185impl BusProperties for RestoreEvent {
186	const DBUS_MEMBER: &'static str = "Restore";
187	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
188	const MATCH_RULE_STRING: &'static str =
189		"type='signal',interface='org.a11y.atspi.Event.Window',member='Restore'";
190	const REGISTRY_EVENT_STRING: &'static str = "Window:";
191}
192
193impl BusProperties for CloseEvent {
194	const DBUS_MEMBER: &'static str = "Close";
195	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
196	const MATCH_RULE_STRING: &'static str =
197		"type='signal',interface='org.a11y.atspi.Event.Window',member='Close'";
198	const REGISTRY_EVENT_STRING: &'static str = "Window:";
199}
200
201impl BusProperties for CreateEvent {
202	const DBUS_MEMBER: &'static str = "Create";
203	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
204	const MATCH_RULE_STRING: &'static str =
205		"type='signal',interface='org.a11y.atspi.Event.Window',member='Create'";
206	const REGISTRY_EVENT_STRING: &'static str = "Window:";
207}
208
209impl BusProperties for ReparentEvent {
210	const DBUS_MEMBER: &'static str = "Reparent";
211	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
212	const MATCH_RULE_STRING: &'static str =
213		"type='signal',interface='org.a11y.atspi.Event.Window',member='Reparent'";
214	const REGISTRY_EVENT_STRING: &'static str = "Window:";
215}
216
217impl BusProperties for DesktopCreateEvent {
218	const DBUS_MEMBER: &'static str = "DesktopCreate";
219	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
220	const MATCH_RULE_STRING: &'static str =
221		"type='signal',interface='org.a11y.atspi.Event.Window',member='DesktopCreate'";
222	const REGISTRY_EVENT_STRING: &'static str = "Window:";
223}
224
225impl BusProperties for DesktopDestroyEvent {
226	const DBUS_MEMBER: &'static str = "DesktopDestroy";
227	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
228	const MATCH_RULE_STRING: &'static str =
229		"type='signal',interface='org.a11y.atspi.Event.Window',member='DesktopDestroy'";
230	const REGISTRY_EVENT_STRING: &'static str = "Window:";
231}
232
233impl BusProperties for DestroyEvent {
234	const DBUS_MEMBER: &'static str = "Destroy";
235	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
236	const MATCH_RULE_STRING: &'static str =
237		"type='signal',interface='org.a11y.atspi.Event.Window',member='Destroy'";
238	const REGISTRY_EVENT_STRING: &'static str = "Window:";
239}
240
241impl BusProperties for ActivateEvent {
242	const DBUS_MEMBER: &'static str = "Activate";
243	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
244	const MATCH_RULE_STRING: &'static str =
245		"type='signal',interface='org.a11y.atspi.Event.Window',member='Activate'";
246	const REGISTRY_EVENT_STRING: &'static str = "Window:";
247}
248
249impl BusProperties for DeactivateEvent {
250	const DBUS_MEMBER: &'static str = "Deactivate";
251	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
252	const MATCH_RULE_STRING: &'static str =
253		"type='signal',interface='org.a11y.atspi.Event.Window',member='Deactivate'";
254	const REGISTRY_EVENT_STRING: &'static str = "Window:";
255}
256
257impl BusProperties for RaiseEvent {
258	const DBUS_MEMBER: &'static str = "Raise";
259	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
260	const MATCH_RULE_STRING: &'static str =
261		"type='signal',interface='org.a11y.atspi.Event.Window',member='Raise'";
262	const REGISTRY_EVENT_STRING: &'static str = "Window:";
263}
264
265impl BusProperties for LowerEvent {
266	const DBUS_MEMBER: &'static str = "Lower";
267	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
268	const MATCH_RULE_STRING: &'static str =
269		"type='signal',interface='org.a11y.atspi.Event.Window',member='Lower'";
270	const REGISTRY_EVENT_STRING: &'static str = "Window:";
271}
272
273impl BusProperties for MoveEvent {
274	const DBUS_MEMBER: &'static str = "Move";
275	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
276	const MATCH_RULE_STRING: &'static str =
277		"type='signal',interface='org.a11y.atspi.Event.Window',member='Move'";
278	const REGISTRY_EVENT_STRING: &'static str = "Window:";
279}
280
281impl BusProperties for ResizeEvent {
282	const DBUS_MEMBER: &'static str = "Resize";
283	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
284	const MATCH_RULE_STRING: &'static str =
285		"type='signal',interface='org.a11y.atspi.Event.Window',member='Resize'";
286	const REGISTRY_EVENT_STRING: &'static str = "Window:";
287}
288
289impl BusProperties for ShadeEvent {
290	const DBUS_MEMBER: &'static str = "Shade";
291	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
292	const MATCH_RULE_STRING: &'static str =
293		"type='signal',interface='org.a11y.atspi.Event.Window',member='Shade'";
294	const REGISTRY_EVENT_STRING: &'static str = "Window:";
295}
296
297impl BusProperties for UUshadeEvent {
298	const DBUS_MEMBER: &'static str = "uUshade";
299	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
300	const MATCH_RULE_STRING: &'static str =
301		"type='signal',interface='org.a11y.atspi.Event.Window',member='uUshade'";
302	const REGISTRY_EVENT_STRING: &'static str = "Window:";
303}
304
305impl BusProperties for RestyleEvent {
306	const DBUS_MEMBER: &'static str = "Restyle";
307	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
308	const MATCH_RULE_STRING: &'static str =
309		"type='signal',interface='org.a11y.atspi.Event.Window',member='Restyle'";
310	const REGISTRY_EVENT_STRING: &'static str = "Window:";
311}
312
313event_test_cases!(PropertyChangeEvent);
314impl_to_dbus_message!(PropertyChangeEvent);
315impl_from_dbus_message!(PropertyChangeEvent);
316impl_event_properties!(PropertyChangeEvent);
317impl From<PropertyChangeEvent> for EventBodyOwned {
318	fn from(event: PropertyChangeEvent) -> Self {
319		EventBodyOwned { kind: event.property, ..Default::default() }
320	}
321}
322
323event_test_cases!(MinimizeEvent);
324impl_to_dbus_message!(MinimizeEvent);
325impl_from_dbus_message!(MinimizeEvent);
326impl_event_properties!(MinimizeEvent);
327impl_from_object_ref!(MinimizeEvent);
328
329event_test_cases!(MaximizeEvent);
330impl_to_dbus_message!(MaximizeEvent);
331impl_from_dbus_message!(MaximizeEvent);
332impl_event_properties!(MaximizeEvent);
333impl_from_object_ref!(MaximizeEvent);
334
335event_test_cases!(RestoreEvent);
336impl_to_dbus_message!(RestoreEvent);
337impl_from_dbus_message!(RestoreEvent);
338impl_event_properties!(RestoreEvent);
339impl_from_object_ref!(RestoreEvent);
340
341event_test_cases!(CloseEvent);
342impl_to_dbus_message!(CloseEvent);
343impl_from_dbus_message!(CloseEvent);
344impl_event_properties!(CloseEvent);
345impl_from_object_ref!(CloseEvent);
346
347event_test_cases!(CreateEvent);
348impl_to_dbus_message!(CreateEvent);
349impl_from_dbus_message!(CreateEvent);
350impl_event_properties!(CreateEvent);
351impl_from_object_ref!(CreateEvent);
352
353event_test_cases!(ReparentEvent);
354impl_to_dbus_message!(ReparentEvent);
355impl_from_dbus_message!(ReparentEvent);
356impl_event_properties!(ReparentEvent);
357impl_from_object_ref!(ReparentEvent);
358
359event_test_cases!(DesktopCreateEvent);
360impl_to_dbus_message!(DesktopCreateEvent);
361impl_from_dbus_message!(DesktopCreateEvent);
362impl_event_properties!(DesktopCreateEvent);
363impl_from_object_ref!(DesktopCreateEvent);
364
365event_test_cases!(DesktopDestroyEvent);
366impl_to_dbus_message!(DesktopDestroyEvent);
367impl_from_dbus_message!(DesktopDestroyEvent);
368impl_event_properties!(DesktopDestroyEvent);
369impl_from_object_ref!(DesktopDestroyEvent);
370
371event_test_cases!(DestroyEvent);
372impl_to_dbus_message!(DestroyEvent);
373impl_from_dbus_message!(DestroyEvent);
374impl_event_properties!(DestroyEvent);
375impl_from_object_ref!(DestroyEvent);
376
377event_test_cases!(ActivateEvent);
378impl_to_dbus_message!(ActivateEvent);
379impl_from_dbus_message!(ActivateEvent);
380impl_event_properties!(ActivateEvent);
381impl_from_object_ref!(ActivateEvent);
382
383event_test_cases!(DeactivateEvent);
384impl_to_dbus_message!(DeactivateEvent);
385impl_from_dbus_message!(DeactivateEvent);
386impl_event_properties!(DeactivateEvent);
387impl_from_object_ref!(DeactivateEvent);
388
389event_test_cases!(RaiseEvent);
390impl_to_dbus_message!(RaiseEvent);
391impl_from_dbus_message!(RaiseEvent);
392impl_event_properties!(RaiseEvent);
393impl_from_object_ref!(RaiseEvent);
394
395event_test_cases!(LowerEvent);
396impl_to_dbus_message!(LowerEvent);
397impl_from_dbus_message!(LowerEvent);
398impl_event_properties!(LowerEvent);
399impl_from_object_ref!(LowerEvent);
400
401event_test_cases!(MoveEvent);
402impl_to_dbus_message!(MoveEvent);
403impl_from_dbus_message!(MoveEvent);
404impl_event_properties!(MoveEvent);
405impl_from_object_ref!(MoveEvent);
406
407event_test_cases!(ResizeEvent);
408impl_to_dbus_message!(ResizeEvent);
409impl_from_dbus_message!(ResizeEvent);
410impl_event_properties!(ResizeEvent);
411impl_from_object_ref!(ResizeEvent);
412
413event_test_cases!(ShadeEvent);
414impl_to_dbus_message!(ShadeEvent);
415impl_from_dbus_message!(ShadeEvent);
416impl_event_properties!(ShadeEvent);
417impl_from_object_ref!(ShadeEvent);
418
419event_test_cases!(UUshadeEvent);
420impl_to_dbus_message!(UUshadeEvent);
421impl_from_dbus_message!(UUshadeEvent);
422impl_event_properties!(UUshadeEvent);
423impl_from_object_ref!(UUshadeEvent);
424
425event_test_cases!(RestyleEvent);
426impl_to_dbus_message!(RestyleEvent);
427impl_from_dbus_message!(RestyleEvent);
428impl_event_properties!(RestyleEvent);
429impl_from_object_ref!(RestyleEvent);