atspi_common/events/
window.rs

1use crate::{
2	error::AtspiError,
3	events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef},
4	Event, EventProperties, EventTypeProperties,
5};
6use zbus_names::UniqueName;
7use zvariant::ObjectPath;
8
9/// All events on the `org.a11y.atspi.Event.Window` interface.
10#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)]
11pub enum WindowEvents {
12	/// See: [`PropertyChangeEvent`].
13	PropertyChange(PropertyChangeEvent),
14	/// See: [`MinimizeEvent`].
15	Minimize(MinimizeEvent),
16	/// See: [`MaximizeEvent`].
17	Maximize(MaximizeEvent),
18	/// See: [`RestoreEvent`].
19	Restore(RestoreEvent),
20	/// See: [`CloseEvent`].
21	Close(CloseEvent),
22	/// See: [`CreateEvent`].
23	Create(CreateEvent),
24	/// See: [`ReparentEvent`].
25	Reparent(ReparentEvent),
26	/// See: [`DesktopCreateEvent`].
27	DesktopCreate(DesktopCreateEvent),
28	/// See: [`DesktopDestroyEvent`].
29	DesktopDestroy(DesktopDestroyEvent),
30	/// See: [`DestroyEvent`].
31	Destroy(DestroyEvent),
32	/// See: [`ActivateEvent`].
33	Activate(ActivateEvent),
34	/// See: [`DeactivateEvent`].
35	Deactivate(DeactivateEvent),
36	/// See: [`RaiseEvent`].
37	Raise(RaiseEvent),
38	/// See: [`LowerEvent`].
39	Lower(LowerEvent),
40	/// See: [`MoveEvent`].
41	Move(MoveEvent),
42	/// See: [`ResizeEvent`].
43	Resize(ResizeEvent),
44	/// See: [`ShadeEvent`].
45	Shade(ShadeEvent),
46	/// See: [`UUshadeEvent`].
47	UUshade(UUshadeEvent),
48	/// See: [`RestyleEvent`].
49	Restyle(RestyleEvent),
50}
51
52impl EventTypeProperties for WindowEvents {
53	fn member(&self) -> &'static str {
54		match self {
55			Self::PropertyChange(inner) => inner.member(),
56			Self::Minimize(inner) => inner.member(),
57			Self::Maximize(inner) => inner.member(),
58			Self::Restore(inner) => inner.member(),
59			Self::Close(inner) => inner.member(),
60			Self::Create(inner) => inner.member(),
61			Self::Reparent(inner) => inner.member(),
62			Self::DesktopCreate(inner) => inner.member(),
63			Self::DesktopDestroy(inner) => inner.member(),
64			Self::Destroy(inner) => inner.member(),
65			Self::Activate(inner) => inner.member(),
66			Self::Deactivate(inner) => inner.member(),
67			Self::Raise(inner) => inner.member(),
68			Self::Lower(inner) => inner.member(),
69			Self::Move(inner) => inner.member(),
70			Self::Resize(inner) => inner.member(),
71			Self::Shade(inner) => inner.member(),
72			Self::UUshade(inner) => inner.member(),
73			Self::Restyle(inner) => inner.member(),
74		}
75	}
76	fn interface(&self) -> &'static str {
77		match self {
78			Self::PropertyChange(inner) => inner.interface(),
79			Self::Minimize(inner) => inner.interface(),
80			Self::Maximize(inner) => inner.interface(),
81			Self::Restore(inner) => inner.interface(),
82			Self::Close(inner) => inner.interface(),
83			Self::Create(inner) => inner.interface(),
84			Self::Reparent(inner) => inner.interface(),
85			Self::DesktopCreate(inner) => inner.interface(),
86			Self::DesktopDestroy(inner) => inner.interface(),
87			Self::Destroy(inner) => inner.interface(),
88			Self::Activate(inner) => inner.interface(),
89			Self::Deactivate(inner) => inner.interface(),
90			Self::Raise(inner) => inner.interface(),
91			Self::Lower(inner) => inner.interface(),
92			Self::Move(inner) => inner.interface(),
93			Self::Resize(inner) => inner.interface(),
94			Self::Shade(inner) => inner.interface(),
95			Self::UUshade(inner) => inner.interface(),
96			Self::Restyle(inner) => inner.interface(),
97		}
98	}
99	fn match_rule(&self) -> &'static str {
100		match self {
101			Self::PropertyChange(inner) => inner.match_rule(),
102			Self::Minimize(inner) => inner.match_rule(),
103			Self::Maximize(inner) => inner.match_rule(),
104			Self::Restore(inner) => inner.match_rule(),
105			Self::Close(inner) => inner.match_rule(),
106			Self::Create(inner) => inner.match_rule(),
107			Self::Reparent(inner) => inner.match_rule(),
108			Self::DesktopCreate(inner) => inner.match_rule(),
109			Self::DesktopDestroy(inner) => inner.match_rule(),
110			Self::Destroy(inner) => inner.match_rule(),
111			Self::Activate(inner) => inner.match_rule(),
112			Self::Deactivate(inner) => inner.match_rule(),
113			Self::Raise(inner) => inner.match_rule(),
114			Self::Lower(inner) => inner.match_rule(),
115			Self::Move(inner) => inner.match_rule(),
116			Self::Resize(inner) => inner.match_rule(),
117			Self::Shade(inner) => inner.match_rule(),
118			Self::UUshade(inner) => inner.match_rule(),
119			Self::Restyle(inner) => inner.match_rule(),
120		}
121	}
122	fn registry_string(&self) -> &'static str {
123		match self {
124			Self::PropertyChange(inner) => inner.registry_string(),
125			Self::Minimize(inner) => inner.registry_string(),
126			Self::Maximize(inner) => inner.registry_string(),
127			Self::Restore(inner) => inner.registry_string(),
128			Self::Close(inner) => inner.registry_string(),
129			Self::Create(inner) => inner.registry_string(),
130			Self::Reparent(inner) => inner.registry_string(),
131			Self::DesktopCreate(inner) => inner.registry_string(),
132			Self::DesktopDestroy(inner) => inner.registry_string(),
133			Self::Destroy(inner) => inner.registry_string(),
134			Self::Activate(inner) => inner.registry_string(),
135			Self::Deactivate(inner) => inner.registry_string(),
136			Self::Raise(inner) => inner.registry_string(),
137			Self::Lower(inner) => inner.registry_string(),
138			Self::Move(inner) => inner.registry_string(),
139			Self::Resize(inner) => inner.registry_string(),
140			Self::Shade(inner) => inner.registry_string(),
141			Self::UUshade(inner) => inner.registry_string(),
142			Self::Restyle(inner) => inner.registry_string(),
143		}
144	}
145}
146
147impl EventProperties for WindowEvents {
148	fn path(&self) -> ObjectPath<'_> {
149		match self {
150			Self::PropertyChange(inner) => inner.path(),
151			Self::Minimize(inner) => inner.path(),
152			Self::Maximize(inner) => inner.path(),
153			Self::Restore(inner) => inner.path(),
154			Self::Close(inner) => inner.path(),
155			Self::Create(inner) => inner.path(),
156			Self::Reparent(inner) => inner.path(),
157			Self::DesktopCreate(inner) => inner.path(),
158			Self::DesktopDestroy(inner) => inner.path(),
159			Self::Destroy(inner) => inner.path(),
160			Self::Activate(inner) => inner.path(),
161			Self::Deactivate(inner) => inner.path(),
162			Self::Raise(inner) => inner.path(),
163			Self::Lower(inner) => inner.path(),
164			Self::Move(inner) => inner.path(),
165			Self::Resize(inner) => inner.path(),
166			Self::Shade(inner) => inner.path(),
167			Self::UUshade(inner) => inner.path(),
168			Self::Restyle(inner) => inner.path(),
169		}
170	}
171	fn sender(&self) -> UniqueName<'_> {
172		match self {
173			Self::PropertyChange(inner) => inner.sender(),
174			Self::Minimize(inner) => inner.sender(),
175			Self::Maximize(inner) => inner.sender(),
176			Self::Restore(inner) => inner.sender(),
177			Self::Close(inner) => inner.sender(),
178			Self::Create(inner) => inner.sender(),
179			Self::Reparent(inner) => inner.sender(),
180			Self::DesktopCreate(inner) => inner.sender(),
181			Self::DesktopDestroy(inner) => inner.sender(),
182			Self::Destroy(inner) => inner.sender(),
183			Self::Activate(inner) => inner.sender(),
184			Self::Deactivate(inner) => inner.sender(),
185			Self::Raise(inner) => inner.sender(),
186			Self::Lower(inner) => inner.sender(),
187			Self::Move(inner) => inner.sender(),
188			Self::Resize(inner) => inner.sender(),
189			Self::Shade(inner) => inner.sender(),
190			Self::UUshade(inner) => inner.sender(),
191			Self::Restyle(inner) => inner.sender(),
192		}
193	}
194}
195
196impl_from_interface_event_enum_for_event!(WindowEvents, Event::Window);
197impl_try_from_event_for_user_facing_event_type!(WindowEvents, Event::Window);
198
199event_wrapper_test_cases!(WindowEvents, MoveEvent);
200
201impl HasMatchRule for WindowEvents {
202	const MATCH_RULE_STRING: &'static str = "type='signal',interface='org.a11y.atspi.Event.Window'";
203}
204
205#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
206pub struct PropertyChangeEvent {
207	/// The [`ObjectRef`] which the event applies to.
208	pub item: crate::events::ObjectRef,
209	pub property: String,
210}
211
212/// The window has been minimized.
213#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
214pub struct MinimizeEvent {
215	/// The application which has been minimized.
216	pub item: crate::events::ObjectRef,
217}
218
219/// The window has been maximized.
220#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
221pub struct MaximizeEvent {
222	/// The application which has been maximized.
223	pub item: crate::events::ObjectRef,
224}
225
226#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
227pub struct RestoreEvent {
228	/// The [`ObjectRef`] which the event applies to.
229	pub item: crate::events::ObjectRef,
230}
231
232/// A window has been closed.
233#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
234pub struct CloseEvent {
235	/// The application which has been closed.
236	pub item: crate::events::ObjectRef,
237}
238
239/// A new window has been created.
240#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
241pub struct CreateEvent {
242	/// An application to query for additional events from.
243	pub item: crate::events::ObjectRef,
244}
245
246#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
247pub struct ReparentEvent {
248	/// The [`ObjectRef`] which the event applies to.
249	pub item: crate::events::ObjectRef,
250}
251
252/// A new virtual desktop has been created.
253#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
254pub struct DesktopCreateEvent {
255	/// A reference to a new desktop
256	pub item: crate::events::ObjectRef,
257}
258
259/// A virtual desktop has been deleted.
260#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
261pub struct DesktopDestroyEvent {
262	/// A reference to the destroyed desktop.
263	pub item: crate::events::ObjectRef,
264}
265
266#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
267pub struct DestroyEvent {
268	/// The [`ObjectRef`] which the event applies to.
269	pub item: crate::events::ObjectRef,
270}
271
272#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
273pub struct ActivateEvent {
274	/// The [`ObjectRef`] which the event applies to.
275	pub item: crate::events::ObjectRef,
276}
277
278#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
279pub struct DeactivateEvent {
280	/// The [`ObjectRef`] which the event applies to.
281	pub item: crate::events::ObjectRef,
282}
283
284#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
285pub struct RaiseEvent {
286	/// The [`ObjectRef`] which the event applies to.
287	pub item: crate::events::ObjectRef,
288}
289
290#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
291pub struct LowerEvent {
292	/// The [`ObjectRef`] which the event applies to.
293	pub item: crate::events::ObjectRef,
294}
295
296#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
297pub struct MoveEvent {
298	/// The [`ObjectRef`] which the event applies to.
299	pub item: crate::events::ObjectRef,
300}
301
302/// A window has been resized.
303#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
304pub struct ResizeEvent {
305	/// The application which has been resized.
306	pub item: crate::events::ObjectRef,
307}
308
309#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
310pub struct ShadeEvent {
311	/// The [`ObjectRef`] which the event applies to.
312	pub item: crate::events::ObjectRef,
313}
314
315#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
316pub struct UUshadeEvent {
317	/// The [`ObjectRef`] which the event applies to.
318	pub item: crate::events::ObjectRef,
319}
320
321#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
322pub struct RestyleEvent {
323	/// The [`ObjectRef`] which the event applies to.
324	pub item: crate::events::ObjectRef,
325}
326
327impl BusProperties for PropertyChangeEvent {
328	const DBUS_MEMBER: &'static str = "PropertyChange";
329	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
330	const MATCH_RULE_STRING: &'static str =
331		"type='signal',interface='org.a11y.atspi.Event.Window',member='PropertyChange'";
332	const REGISTRY_EVENT_STRING: &'static str = "Window:";
333
334	type Body = EventBodyOwned;
335
336	fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
337		Ok(Self { item, property: body.kind })
338	}
339	fn body(&self) -> Self::Body {
340		let copy = self.clone();
341		copy.into()
342	}
343}
344
345impl BusProperties for MinimizeEvent {
346	const DBUS_MEMBER: &'static str = "Minimize";
347	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
348	const MATCH_RULE_STRING: &'static str =
349		"type='signal',interface='org.a11y.atspi.Event.Window',member='Minimize'";
350	const REGISTRY_EVENT_STRING: &'static str = "Window:";
351
352	type Body = EventBodyOwned;
353
354	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
355		Ok(Self { item })
356	}
357	fn body(&self) -> Self::Body {
358		let copy = self.clone();
359		copy.into()
360	}
361}
362
363impl BusProperties for MaximizeEvent {
364	const DBUS_MEMBER: &'static str = "Maximize";
365	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
366	const MATCH_RULE_STRING: &'static str =
367		"type='signal',interface='org.a11y.atspi.Event.Window',member='Maximize'";
368	const REGISTRY_EVENT_STRING: &'static str = "Window:";
369
370	type Body = EventBodyOwned;
371
372	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
373		Ok(Self { item })
374	}
375	fn body(&self) -> Self::Body {
376		let copy = self.clone();
377		copy.into()
378	}
379}
380
381impl BusProperties for RestoreEvent {
382	const DBUS_MEMBER: &'static str = "Restore";
383	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
384	const MATCH_RULE_STRING: &'static str =
385		"type='signal',interface='org.a11y.atspi.Event.Window',member='Restore'";
386	const REGISTRY_EVENT_STRING: &'static str = "Window:";
387
388	type Body = EventBodyOwned;
389
390	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
391		Ok(Self { item })
392	}
393	fn body(&self) -> Self::Body {
394		let copy = self.clone();
395		copy.into()
396	}
397}
398
399impl BusProperties for CloseEvent {
400	const DBUS_MEMBER: &'static str = "Close";
401	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
402	const MATCH_RULE_STRING: &'static str =
403		"type='signal',interface='org.a11y.atspi.Event.Window',member='Close'";
404	const REGISTRY_EVENT_STRING: &'static str = "Window:";
405
406	type Body = EventBodyOwned;
407
408	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
409		Ok(Self { item })
410	}
411	fn body(&self) -> Self::Body {
412		let copy = self.clone();
413		copy.into()
414	}
415}
416
417impl BusProperties for CreateEvent {
418	const DBUS_MEMBER: &'static str = "Create";
419	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
420	const MATCH_RULE_STRING: &'static str =
421		"type='signal',interface='org.a11y.atspi.Event.Window',member='Create'";
422	const REGISTRY_EVENT_STRING: &'static str = "Window:";
423
424	type Body = EventBodyOwned;
425
426	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
427		Ok(Self { item })
428	}
429	fn body(&self) -> Self::Body {
430		let copy = self.clone();
431		copy.into()
432	}
433}
434
435impl BusProperties for ReparentEvent {
436	const DBUS_MEMBER: &'static str = "Reparent";
437	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
438	const MATCH_RULE_STRING: &'static str =
439		"type='signal',interface='org.a11y.atspi.Event.Window',member='Reparent'";
440	const REGISTRY_EVENT_STRING: &'static str = "Window:";
441
442	type Body = EventBodyOwned;
443
444	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
445		Ok(Self { item })
446	}
447	fn body(&self) -> Self::Body {
448		let copy = self.clone();
449		copy.into()
450	}
451}
452
453impl BusProperties for DesktopCreateEvent {
454	const DBUS_MEMBER: &'static str = "DesktopCreate";
455	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
456	const MATCH_RULE_STRING: &'static str =
457		"type='signal',interface='org.a11y.atspi.Event.Window',member='DesktopCreate'";
458	const REGISTRY_EVENT_STRING: &'static str = "Window:";
459
460	type Body = EventBodyOwned;
461
462	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
463		Ok(Self { item })
464	}
465	fn body(&self) -> Self::Body {
466		let copy = self.clone();
467		copy.into()
468	}
469}
470
471impl BusProperties for DesktopDestroyEvent {
472	const DBUS_MEMBER: &'static str = "DesktopDestroy";
473	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
474	const MATCH_RULE_STRING: &'static str =
475		"type='signal',interface='org.a11y.atspi.Event.Window',member='DesktopDestroy'";
476	const REGISTRY_EVENT_STRING: &'static str = "Window:";
477
478	type Body = EventBodyOwned;
479
480	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
481		Ok(Self { item })
482	}
483	fn body(&self) -> Self::Body {
484		let copy = self.clone();
485		copy.into()
486	}
487}
488
489impl BusProperties for DestroyEvent {
490	const DBUS_MEMBER: &'static str = "Destroy";
491	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
492	const MATCH_RULE_STRING: &'static str =
493		"type='signal',interface='org.a11y.atspi.Event.Window',member='Destroy'";
494	const REGISTRY_EVENT_STRING: &'static str = "Window:";
495
496	type Body = EventBodyOwned;
497
498	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
499		Ok(Self { item })
500	}
501	fn body(&self) -> Self::Body {
502		let copy = self.clone();
503		copy.into()
504	}
505}
506
507impl BusProperties for ActivateEvent {
508	const DBUS_MEMBER: &'static str = "Activate";
509	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
510	const MATCH_RULE_STRING: &'static str =
511		"type='signal',interface='org.a11y.atspi.Event.Window',member='Activate'";
512	const REGISTRY_EVENT_STRING: &'static str = "Window:";
513
514	type Body = EventBodyOwned;
515
516	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
517		Ok(Self { item })
518	}
519	fn body(&self) -> Self::Body {
520		let copy = self.clone();
521		copy.into()
522	}
523}
524
525impl BusProperties for DeactivateEvent {
526	const DBUS_MEMBER: &'static str = "Deactivate";
527	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
528	const MATCH_RULE_STRING: &'static str =
529		"type='signal',interface='org.a11y.atspi.Event.Window',member='Deactivate'";
530	const REGISTRY_EVENT_STRING: &'static str = "Window:";
531
532	type Body = EventBodyOwned;
533
534	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
535		Ok(Self { item })
536	}
537	fn body(&self) -> Self::Body {
538		let copy = self.clone();
539		copy.into()
540	}
541}
542
543impl BusProperties for RaiseEvent {
544	const DBUS_MEMBER: &'static str = "Raise";
545	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
546	const MATCH_RULE_STRING: &'static str =
547		"type='signal',interface='org.a11y.atspi.Event.Window',member='Raise'";
548	const REGISTRY_EVENT_STRING: &'static str = "Window:";
549
550	type Body = EventBodyOwned;
551
552	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
553		Ok(Self { item })
554	}
555	fn body(&self) -> Self::Body {
556		let copy = self.clone();
557		copy.into()
558	}
559}
560
561impl BusProperties for LowerEvent {
562	const DBUS_MEMBER: &'static str = "Lower";
563	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
564	const MATCH_RULE_STRING: &'static str =
565		"type='signal',interface='org.a11y.atspi.Event.Window',member='Lower'";
566	const REGISTRY_EVENT_STRING: &'static str = "Window:";
567
568	type Body = EventBodyOwned;
569
570	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
571		Ok(Self { item })
572	}
573	fn body(&self) -> Self::Body {
574		let copy = self.clone();
575		copy.into()
576	}
577}
578
579impl BusProperties for MoveEvent {
580	const DBUS_MEMBER: &'static str = "Move";
581	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
582	const MATCH_RULE_STRING: &'static str =
583		"type='signal',interface='org.a11y.atspi.Event.Window',member='Move'";
584	const REGISTRY_EVENT_STRING: &'static str = "Window:";
585
586	type Body = EventBodyOwned;
587
588	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
589		Ok(Self { item })
590	}
591	fn body(&self) -> Self::Body {
592		let copy = self.clone();
593		copy.into()
594	}
595}
596
597impl BusProperties for ResizeEvent {
598	const DBUS_MEMBER: &'static str = "Resize";
599	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
600	const MATCH_RULE_STRING: &'static str =
601		"type='signal',interface='org.a11y.atspi.Event.Window',member='Resize'";
602	const REGISTRY_EVENT_STRING: &'static str = "Window:";
603
604	type Body = EventBodyOwned;
605
606	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
607		Ok(Self { item })
608	}
609	fn body(&self) -> Self::Body {
610		let copy = self.clone();
611		copy.into()
612	}
613}
614
615impl BusProperties for ShadeEvent {
616	const DBUS_MEMBER: &'static str = "Shade";
617	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
618	const MATCH_RULE_STRING: &'static str =
619		"type='signal',interface='org.a11y.atspi.Event.Window',member='Shade'";
620	const REGISTRY_EVENT_STRING: &'static str = "Window:";
621
622	type Body = EventBodyOwned;
623
624	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
625		Ok(Self { item })
626	}
627	fn body(&self) -> Self::Body {
628		let copy = self.clone();
629		copy.into()
630	}
631}
632
633impl BusProperties for UUshadeEvent {
634	const DBUS_MEMBER: &'static str = "uUshade";
635	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
636	const MATCH_RULE_STRING: &'static str =
637		"type='signal',interface='org.a11y.atspi.Event.Window',member='uUshade'";
638	const REGISTRY_EVENT_STRING: &'static str = "Window:";
639
640	type Body = EventBodyOwned;
641
642	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
643		Ok(Self { item })
644	}
645	fn body(&self) -> Self::Body {
646		let copy = self.clone();
647		copy.into()
648	}
649}
650
651impl BusProperties for RestyleEvent {
652	const DBUS_MEMBER: &'static str = "Restyle";
653	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window";
654	const MATCH_RULE_STRING: &'static str =
655		"type='signal',interface='org.a11y.atspi.Event.Window',member='Restyle'";
656	const REGISTRY_EVENT_STRING: &'static str = "Window:";
657
658	type Body = EventBodyOwned;
659
660	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
661		Ok(Self { item })
662	}
663	fn body(&self) -> Self::Body {
664		let copy = self.clone();
665		copy.into()
666	}
667}
668
669#[cfg(feature = "zbus")]
670impl TryFrom<&zbus::Message> for WindowEvents {
671	type Error = AtspiError;
672	fn try_from(ev: &zbus::Message) -> Result<Self, Self::Error> {
673		let header = ev.header();
674		let member = header
675			.member()
676			.ok_or(AtspiError::MemberMatch("Event without member".into()))?;
677		match member.as_str() {
678			"PropertyChange" => Ok(WindowEvents::PropertyChange(ev.try_into()?)),
679			"Minimize" => Ok(WindowEvents::Minimize(ev.try_into()?)),
680			"Maximize" => Ok(WindowEvents::Maximize(ev.try_into()?)),
681			"Restore" => Ok(WindowEvents::Restore(ev.try_into()?)),
682			"Close" => Ok(WindowEvents::Close(ev.try_into()?)),
683			"Create" => Ok(WindowEvents::Create(ev.try_into()?)),
684			"Reparent" => Ok(WindowEvents::Reparent(ev.try_into()?)),
685			"DesktopCreate" => Ok(WindowEvents::DesktopCreate(ev.try_into()?)),
686			"DesktopDestroy" => Ok(WindowEvents::DesktopDestroy(ev.try_into()?)),
687			"Destroy" => Ok(WindowEvents::Destroy(ev.try_into()?)),
688			"Activate" => Ok(WindowEvents::Activate(ev.try_into()?)),
689			"Deactivate" => Ok(WindowEvents::Deactivate(ev.try_into()?)),
690			"Raise" => Ok(WindowEvents::Raise(ev.try_into()?)),
691			"Lower" => Ok(WindowEvents::Lower(ev.try_into()?)),
692			"Move" => Ok(WindowEvents::Move(ev.try_into()?)),
693			"Resize" => Ok(WindowEvents::Resize(ev.try_into()?)),
694			"Shade" => Ok(WindowEvents::Shade(ev.try_into()?)),
695			"uUshade" => Ok(WindowEvents::UUshade(ev.try_into()?)),
696			"Restyle" => Ok(WindowEvents::Restyle(ev.try_into()?)),
697			_ => Err(AtspiError::MemberMatch("No matching member for Window".into())),
698		}
699	}
700}
701
702impl_from_user_facing_event_for_interface_event_enum!(
703	PropertyChangeEvent,
704	WindowEvents,
705	WindowEvents::PropertyChange
706);
707impl_from_user_facing_type_for_event_enum!(PropertyChangeEvent, Event::Window);
708impl_try_from_event_for_user_facing_type!(
709	PropertyChangeEvent,
710	WindowEvents::PropertyChange,
711	Event::Window
712);
713event_test_cases!(PropertyChangeEvent);
714impl_to_dbus_message!(PropertyChangeEvent);
715impl_from_dbus_message!(PropertyChangeEvent);
716impl_event_properties!(PropertyChangeEvent);
717impl From<PropertyChangeEvent> for EventBodyOwned {
718	fn from(event: PropertyChangeEvent) -> Self {
719		EventBodyOwned {
720			properties: std::collections::HashMap::new(),
721			kind: event.property,
722			detail1: i32::default(),
723			detail2: i32::default(),
724			any_data: u8::default().into(),
725		}
726	}
727}
728
729impl_from_user_facing_event_for_interface_event_enum!(
730	MinimizeEvent,
731	WindowEvents,
732	WindowEvents::Minimize
733);
734impl_from_user_facing_type_for_event_enum!(MinimizeEvent, Event::Window);
735impl_try_from_event_for_user_facing_type!(MinimizeEvent, WindowEvents::Minimize, Event::Window);
736event_test_cases!(MinimizeEvent);
737impl_to_dbus_message!(MinimizeEvent);
738impl_from_dbus_message!(MinimizeEvent);
739impl_event_properties!(MinimizeEvent);
740impl From<MinimizeEvent> for EventBodyOwned {
741	fn from(_event: MinimizeEvent) -> Self {
742		EventBodyOwned {
743			properties: std::collections::HashMap::new(),
744			kind: String::default(),
745			detail1: i32::default(),
746			detail2: i32::default(),
747			any_data: u8::default().into(),
748		}
749	}
750}
751
752impl_from_user_facing_event_for_interface_event_enum!(
753	MaximizeEvent,
754	WindowEvents,
755	WindowEvents::Maximize
756);
757impl_from_user_facing_type_for_event_enum!(MaximizeEvent, Event::Window);
758impl_try_from_event_for_user_facing_type!(MaximizeEvent, WindowEvents::Maximize, Event::Window);
759event_test_cases!(MaximizeEvent);
760impl_to_dbus_message!(MaximizeEvent);
761impl_from_dbus_message!(MaximizeEvent);
762impl_event_properties!(MaximizeEvent);
763impl From<MaximizeEvent> for EventBodyOwned {
764	fn from(_event: MaximizeEvent) -> Self {
765		EventBodyOwned {
766			properties: std::collections::HashMap::new(),
767			kind: String::default(),
768			detail1: i32::default(),
769			detail2: i32::default(),
770			any_data: u8::default().into(),
771		}
772	}
773}
774
775impl_from_user_facing_event_for_interface_event_enum!(
776	RestoreEvent,
777	WindowEvents,
778	WindowEvents::Restore
779);
780impl_from_user_facing_type_for_event_enum!(RestoreEvent, Event::Window);
781impl_try_from_event_for_user_facing_type!(RestoreEvent, WindowEvents::Restore, Event::Window);
782event_test_cases!(RestoreEvent);
783impl_to_dbus_message!(RestoreEvent);
784impl_from_dbus_message!(RestoreEvent);
785impl_event_properties!(RestoreEvent);
786impl From<RestoreEvent> for EventBodyOwned {
787	fn from(_event: RestoreEvent) -> Self {
788		EventBodyOwned {
789			properties: std::collections::HashMap::new(),
790			kind: String::default(),
791			detail1: i32::default(),
792			detail2: i32::default(),
793			any_data: u8::default().into(),
794		}
795	}
796}
797
798impl_from_user_facing_event_for_interface_event_enum!(
799	CloseEvent,
800	WindowEvents,
801	WindowEvents::Close
802);
803impl_from_user_facing_type_for_event_enum!(CloseEvent, Event::Window);
804impl_try_from_event_for_user_facing_type!(CloseEvent, WindowEvents::Close, Event::Window);
805event_test_cases!(CloseEvent);
806impl_to_dbus_message!(CloseEvent);
807impl_from_dbus_message!(CloseEvent);
808impl_event_properties!(CloseEvent);
809impl From<CloseEvent> for EventBodyOwned {
810	fn from(_event: CloseEvent) -> Self {
811		EventBodyOwned {
812			properties: std::collections::HashMap::new(),
813			kind: String::default(),
814			detail1: i32::default(),
815			detail2: i32::default(),
816			any_data: u8::default().into(),
817		}
818	}
819}
820
821impl_from_user_facing_event_for_interface_event_enum!(
822	CreateEvent,
823	WindowEvents,
824	WindowEvents::Create
825);
826impl_from_user_facing_type_for_event_enum!(CreateEvent, Event::Window);
827impl_try_from_event_for_user_facing_type!(CreateEvent, WindowEvents::Create, Event::Window);
828event_test_cases!(CreateEvent);
829impl_to_dbus_message!(CreateEvent);
830impl_from_dbus_message!(CreateEvent);
831impl_event_properties!(CreateEvent);
832impl From<CreateEvent> for EventBodyOwned {
833	fn from(_event: CreateEvent) -> Self {
834		EventBodyOwned {
835			properties: std::collections::HashMap::new(),
836			kind: String::default(),
837			detail1: i32::default(),
838			detail2: i32::default(),
839			any_data: u8::default().into(),
840		}
841	}
842}
843
844impl_from_user_facing_event_for_interface_event_enum!(
845	ReparentEvent,
846	WindowEvents,
847	WindowEvents::Reparent
848);
849impl_from_user_facing_type_for_event_enum!(ReparentEvent, Event::Window);
850impl_try_from_event_for_user_facing_type!(ReparentEvent, WindowEvents::Reparent, Event::Window);
851event_test_cases!(ReparentEvent);
852impl_to_dbus_message!(ReparentEvent);
853impl_from_dbus_message!(ReparentEvent);
854impl_event_properties!(ReparentEvent);
855impl From<ReparentEvent> for EventBodyOwned {
856	fn from(_event: ReparentEvent) -> Self {
857		EventBodyOwned {
858			properties: std::collections::HashMap::new(),
859			kind: String::default(),
860			detail1: i32::default(),
861			detail2: i32::default(),
862			any_data: u8::default().into(),
863		}
864	}
865}
866
867impl_from_user_facing_event_for_interface_event_enum!(
868	DesktopCreateEvent,
869	WindowEvents,
870	WindowEvents::DesktopCreate
871);
872impl_from_user_facing_type_for_event_enum!(DesktopCreateEvent, Event::Window);
873impl_try_from_event_for_user_facing_type!(
874	DesktopCreateEvent,
875	WindowEvents::DesktopCreate,
876	Event::Window
877);
878event_test_cases!(DesktopCreateEvent);
879impl_to_dbus_message!(DesktopCreateEvent);
880impl_from_dbus_message!(DesktopCreateEvent);
881impl_event_properties!(DesktopCreateEvent);
882impl From<DesktopCreateEvent> for EventBodyOwned {
883	fn from(_event: DesktopCreateEvent) -> Self {
884		EventBodyOwned {
885			properties: std::collections::HashMap::new(),
886			kind: String::default(),
887			detail1: i32::default(),
888			detail2: i32::default(),
889			any_data: u8::default().into(),
890		}
891	}
892}
893
894impl_from_user_facing_event_for_interface_event_enum!(
895	DesktopDestroyEvent,
896	WindowEvents,
897	WindowEvents::DesktopDestroy
898);
899impl_from_user_facing_type_for_event_enum!(DesktopDestroyEvent, Event::Window);
900impl_try_from_event_for_user_facing_type!(
901	DesktopDestroyEvent,
902	WindowEvents::DesktopDestroy,
903	Event::Window
904);
905event_test_cases!(DesktopDestroyEvent);
906impl_to_dbus_message!(DesktopDestroyEvent);
907impl_from_dbus_message!(DesktopDestroyEvent);
908impl_event_properties!(DesktopDestroyEvent);
909impl From<DesktopDestroyEvent> for EventBodyOwned {
910	fn from(_event: DesktopDestroyEvent) -> Self {
911		EventBodyOwned {
912			properties: std::collections::HashMap::new(),
913			kind: String::default(),
914			detail1: i32::default(),
915			detail2: i32::default(),
916			any_data: u8::default().into(),
917		}
918	}
919}
920
921impl_from_user_facing_event_for_interface_event_enum!(
922	DestroyEvent,
923	WindowEvents,
924	WindowEvents::Destroy
925);
926impl_from_user_facing_type_for_event_enum!(DestroyEvent, Event::Window);
927impl_try_from_event_for_user_facing_type!(DestroyEvent, WindowEvents::Destroy, Event::Window);
928event_test_cases!(DestroyEvent);
929impl_to_dbus_message!(DestroyEvent);
930impl_from_dbus_message!(DestroyEvent);
931impl_event_properties!(DestroyEvent);
932impl From<DestroyEvent> for EventBodyOwned {
933	fn from(_event: DestroyEvent) -> Self {
934		EventBodyOwned {
935			properties: std::collections::HashMap::new(),
936			kind: String::default(),
937			detail1: i32::default(),
938			detail2: i32::default(),
939			any_data: u8::default().into(),
940		}
941	}
942}
943
944impl_from_user_facing_event_for_interface_event_enum!(
945	ActivateEvent,
946	WindowEvents,
947	WindowEvents::Activate
948);
949impl_from_user_facing_type_for_event_enum!(ActivateEvent, Event::Window);
950impl_try_from_event_for_user_facing_type!(ActivateEvent, WindowEvents::Activate, Event::Window);
951event_test_cases!(ActivateEvent);
952impl_to_dbus_message!(ActivateEvent);
953impl_from_dbus_message!(ActivateEvent);
954impl_event_properties!(ActivateEvent);
955impl From<ActivateEvent> for EventBodyOwned {
956	fn from(_event: ActivateEvent) -> Self {
957		EventBodyOwned {
958			properties: std::collections::HashMap::new(),
959			kind: String::default(),
960			detail1: i32::default(),
961			detail2: i32::default(),
962			any_data: u8::default().into(),
963		}
964	}
965}
966
967impl_from_user_facing_event_for_interface_event_enum!(
968	DeactivateEvent,
969	WindowEvents,
970	WindowEvents::Deactivate
971);
972impl_from_user_facing_type_for_event_enum!(DeactivateEvent, Event::Window);
973impl_try_from_event_for_user_facing_type!(DeactivateEvent, WindowEvents::Deactivate, Event::Window);
974event_test_cases!(DeactivateEvent);
975impl_to_dbus_message!(DeactivateEvent);
976impl_from_dbus_message!(DeactivateEvent);
977impl_event_properties!(DeactivateEvent);
978impl From<DeactivateEvent> for EventBodyOwned {
979	fn from(_event: DeactivateEvent) -> Self {
980		EventBodyOwned {
981			properties: std::collections::HashMap::new(),
982			kind: String::default(),
983			detail1: i32::default(),
984			detail2: i32::default(),
985			any_data: u8::default().into(),
986		}
987	}
988}
989
990impl_from_user_facing_event_for_interface_event_enum!(
991	RaiseEvent,
992	WindowEvents,
993	WindowEvents::Raise
994);
995impl_from_user_facing_type_for_event_enum!(RaiseEvent, Event::Window);
996impl_try_from_event_for_user_facing_type!(RaiseEvent, WindowEvents::Raise, Event::Window);
997event_test_cases!(RaiseEvent);
998impl_to_dbus_message!(RaiseEvent);
999impl_from_dbus_message!(RaiseEvent);
1000impl_event_properties!(RaiseEvent);
1001impl From<RaiseEvent> for EventBodyOwned {
1002	fn from(_event: RaiseEvent) -> Self {
1003		EventBodyOwned {
1004			properties: std::collections::HashMap::new(),
1005			kind: String::default(),
1006			detail1: i32::default(),
1007			detail2: i32::default(),
1008			any_data: u8::default().into(),
1009		}
1010	}
1011}
1012
1013impl_from_user_facing_event_for_interface_event_enum!(
1014	LowerEvent,
1015	WindowEvents,
1016	WindowEvents::Lower
1017);
1018impl_from_user_facing_type_for_event_enum!(LowerEvent, Event::Window);
1019impl_try_from_event_for_user_facing_type!(LowerEvent, WindowEvents::Lower, Event::Window);
1020event_test_cases!(LowerEvent);
1021impl_to_dbus_message!(LowerEvent);
1022impl_from_dbus_message!(LowerEvent);
1023impl_event_properties!(LowerEvent);
1024impl From<LowerEvent> for EventBodyOwned {
1025	fn from(_event: LowerEvent) -> Self {
1026		EventBodyOwned {
1027			properties: std::collections::HashMap::new(),
1028			kind: String::default(),
1029			detail1: i32::default(),
1030			detail2: i32::default(),
1031			any_data: u8::default().into(),
1032		}
1033	}
1034}
1035
1036impl_from_user_facing_event_for_interface_event_enum!(MoveEvent, WindowEvents, WindowEvents::Move);
1037impl_from_user_facing_type_for_event_enum!(MoveEvent, Event::Window);
1038impl_try_from_event_for_user_facing_type!(MoveEvent, WindowEvents::Move, Event::Window);
1039event_test_cases!(MoveEvent);
1040impl_to_dbus_message!(MoveEvent);
1041impl_from_dbus_message!(MoveEvent);
1042impl_event_properties!(MoveEvent);
1043impl From<MoveEvent> for EventBodyOwned {
1044	fn from(_event: MoveEvent) -> Self {
1045		EventBodyOwned {
1046			properties: std::collections::HashMap::new(),
1047			kind: String::default(),
1048			detail1: i32::default(),
1049			detail2: i32::default(),
1050			any_data: u8::default().into(),
1051		}
1052	}
1053}
1054
1055impl_from_user_facing_event_for_interface_event_enum!(
1056	ResizeEvent,
1057	WindowEvents,
1058	WindowEvents::Resize
1059);
1060impl_from_user_facing_type_for_event_enum!(ResizeEvent, Event::Window);
1061impl_try_from_event_for_user_facing_type!(ResizeEvent, WindowEvents::Resize, Event::Window);
1062event_test_cases!(ResizeEvent);
1063impl_to_dbus_message!(ResizeEvent);
1064impl_from_dbus_message!(ResizeEvent);
1065impl_event_properties!(ResizeEvent);
1066impl From<ResizeEvent> for EventBodyOwned {
1067	fn from(_event: ResizeEvent) -> Self {
1068		EventBodyOwned {
1069			properties: std::collections::HashMap::new(),
1070			kind: String::default(),
1071			detail1: i32::default(),
1072			detail2: i32::default(),
1073			any_data: u8::default().into(),
1074		}
1075	}
1076}
1077
1078impl_from_user_facing_event_for_interface_event_enum!(
1079	ShadeEvent,
1080	WindowEvents,
1081	WindowEvents::Shade
1082);
1083impl_from_user_facing_type_for_event_enum!(ShadeEvent, Event::Window);
1084impl_try_from_event_for_user_facing_type!(ShadeEvent, WindowEvents::Shade, Event::Window);
1085event_test_cases!(ShadeEvent);
1086impl_to_dbus_message!(ShadeEvent);
1087impl_from_dbus_message!(ShadeEvent);
1088impl_event_properties!(ShadeEvent);
1089impl From<ShadeEvent> for EventBodyOwned {
1090	fn from(_event: ShadeEvent) -> Self {
1091		EventBodyOwned {
1092			properties: std::collections::HashMap::new(),
1093			kind: String::default(),
1094			detail1: i32::default(),
1095			detail2: i32::default(),
1096			any_data: zvariant::Value::U8(0).try_into().unwrap(),
1097		}
1098	}
1099}
1100
1101impl_from_user_facing_event_for_interface_event_enum!(
1102	UUshadeEvent,
1103	WindowEvents,
1104	WindowEvents::UUshade
1105);
1106impl_from_user_facing_type_for_event_enum!(UUshadeEvent, Event::Window);
1107impl_try_from_event_for_user_facing_type!(UUshadeEvent, WindowEvents::UUshade, Event::Window);
1108event_test_cases!(UUshadeEvent);
1109impl_to_dbus_message!(UUshadeEvent);
1110impl_from_dbus_message!(UUshadeEvent);
1111impl_event_properties!(UUshadeEvent);
1112impl From<UUshadeEvent> for EventBodyOwned {
1113	fn from(_event: UUshadeEvent) -> Self {
1114		EventBodyOwned {
1115			properties: std::collections::HashMap::new(),
1116			kind: String::default(),
1117			detail1: i32::default(),
1118			detail2: i32::default(),
1119			any_data: zvariant::Value::U8(0).try_into().unwrap(),
1120		}
1121	}
1122}
1123
1124impl_from_user_facing_event_for_interface_event_enum!(
1125	RestyleEvent,
1126	WindowEvents,
1127	WindowEvents::Restyle
1128);
1129impl_from_user_facing_type_for_event_enum!(RestyleEvent, Event::Window);
1130impl_try_from_event_for_user_facing_type!(RestyleEvent, WindowEvents::Restyle, Event::Window);
1131event_test_cases!(RestyleEvent);
1132impl_to_dbus_message!(RestyleEvent);
1133impl_from_dbus_message!(RestyleEvent);
1134impl_event_properties!(RestyleEvent);
1135impl From<RestyleEvent> for EventBodyOwned {
1136	fn from(_event: RestyleEvent) -> Self {
1137		EventBodyOwned {
1138			properties: std::collections::HashMap::new(),
1139			kind: String::default(),
1140			detail1: i32::default(),
1141			detail2: i32::default(),
1142			any_data: u8::default().into(),
1143		}
1144	}
1145}
1146
1147impl HasRegistryEventString for WindowEvents {
1148	const REGISTRY_EVENT_STRING: &'static str = "Window:";
1149}