atspi_common/events/
object.rs

1use std::hash::Hash;
2
3use crate::{
4	error::AtspiError,
5	events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef},
6	Event, EventProperties, EventTypeProperties, State,
7};
8use zbus_names::UniqueName;
9use zvariant::{ObjectPath, OwnedValue, Value};
10
11#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)]
12pub enum ObjectEvents {
13	/// See: [`PropertyChangeEvent`].
14	PropertyChange(PropertyChangeEvent),
15	/// See: [`BoundsChangedEvent`].
16	BoundsChanged(BoundsChangedEvent),
17	/// See: [`LinkSelectedEvent`].
18	LinkSelected(LinkSelectedEvent),
19	/// See: [`StateChangedEvent`].
20	StateChanged(StateChangedEvent),
21	/// See: [`ChildrenChangedEvent`].
22	ChildrenChanged(ChildrenChangedEvent),
23	/// See: [`VisibleDataChangedEvent`].
24	VisibleDataChanged(VisibleDataChangedEvent),
25	/// See: [`SelectionChangedEvent`].
26	SelectionChanged(SelectionChangedEvent),
27	/// See: [`ModelChangedEvent`].
28	ModelChanged(ModelChangedEvent),
29	/// See: [`ActiveDescendantChangedEvent`].
30	ActiveDescendantChanged(ActiveDescendantChangedEvent),
31	/// See: [`AnnouncementEvent`].
32	Announcement(AnnouncementEvent),
33	/// See: [`AttributesChangedEvent`].
34	AttributesChanged(AttributesChangedEvent),
35	/// See: [`RowInsertedEvent`].
36	RowInserted(RowInsertedEvent),
37	/// See: [`RowReorderedEvent`].
38	RowReordered(RowReorderedEvent),
39	/// See: [`RowDeletedEvent`].
40	RowDeleted(RowDeletedEvent),
41	/// See: [`ColumnInsertedEvent`].
42	ColumnInserted(ColumnInsertedEvent),
43	/// See: [`ColumnReorderedEvent`].
44	ColumnReordered(ColumnReorderedEvent),
45	/// See: [`ColumnDeletedEvent`].
46	ColumnDeleted(ColumnDeletedEvent),
47	/// See: [`TextBoundsChangedEvent`].
48	TextBoundsChanged(TextBoundsChangedEvent),
49	/// See: [`TextSelectionChangedEvent`].
50	TextSelectionChanged(TextSelectionChangedEvent),
51	/// See: [`TextChangedEvent`].
52	TextChanged(TextChangedEvent),
53	/// See: [`TextAttributesChangedEvent`].
54	TextAttributesChanged(TextAttributesChangedEvent),
55	/// See: [`TextCaretMovedEvent`].
56	TextCaretMoved(TextCaretMovedEvent),
57}
58
59impl EventTypeProperties for ObjectEvents {
60	fn member(&self) -> &'static str {
61		match self {
62			Self::PropertyChange(inner) => inner.member(),
63			Self::BoundsChanged(inner) => inner.member(),
64			Self::LinkSelected(inner) => inner.member(),
65			Self::StateChanged(inner) => inner.member(),
66			Self::ChildrenChanged(inner) => inner.member(),
67			Self::VisibleDataChanged(inner) => inner.member(),
68			Self::SelectionChanged(inner) => inner.member(),
69			Self::ModelChanged(inner) => inner.member(),
70			Self::ActiveDescendantChanged(inner) => inner.member(),
71			Self::Announcement(inner) => inner.member(),
72			Self::AttributesChanged(inner) => inner.member(),
73			Self::RowInserted(inner) => inner.member(),
74			Self::RowReordered(inner) => inner.member(),
75			Self::RowDeleted(inner) => inner.member(),
76			Self::ColumnInserted(inner) => inner.member(),
77			Self::ColumnReordered(inner) => inner.member(),
78			Self::ColumnDeleted(inner) => inner.member(),
79			Self::TextBoundsChanged(inner) => inner.member(),
80			Self::TextSelectionChanged(inner) => inner.member(),
81			Self::TextChanged(inner) => inner.member(),
82			Self::TextAttributesChanged(inner) => inner.member(),
83			Self::TextCaretMoved(inner) => inner.member(),
84		}
85	}
86	fn interface(&self) -> &'static str {
87		match self {
88			Self::PropertyChange(inner) => inner.interface(),
89			Self::BoundsChanged(inner) => inner.interface(),
90			Self::LinkSelected(inner) => inner.interface(),
91			Self::StateChanged(inner) => inner.interface(),
92			Self::ChildrenChanged(inner) => inner.interface(),
93			Self::VisibleDataChanged(inner) => inner.interface(),
94			Self::SelectionChanged(inner) => inner.interface(),
95			Self::ModelChanged(inner) => inner.interface(),
96			Self::ActiveDescendantChanged(inner) => inner.interface(),
97			Self::Announcement(inner) => inner.interface(),
98			Self::AttributesChanged(inner) => inner.interface(),
99			Self::RowInserted(inner) => inner.interface(),
100			Self::RowReordered(inner) => inner.interface(),
101			Self::RowDeleted(inner) => inner.interface(),
102			Self::ColumnInserted(inner) => inner.interface(),
103			Self::ColumnReordered(inner) => inner.interface(),
104			Self::ColumnDeleted(inner) => inner.interface(),
105			Self::TextBoundsChanged(inner) => inner.interface(),
106			Self::TextSelectionChanged(inner) => inner.interface(),
107			Self::TextChanged(inner) => inner.interface(),
108			Self::TextAttributesChanged(inner) => inner.interface(),
109			Self::TextCaretMoved(inner) => inner.interface(),
110		}
111	}
112	fn match_rule(&self) -> &'static str {
113		match self {
114			Self::PropertyChange(inner) => inner.match_rule(),
115			Self::BoundsChanged(inner) => inner.match_rule(),
116			Self::LinkSelected(inner) => inner.match_rule(),
117			Self::StateChanged(inner) => inner.match_rule(),
118			Self::ChildrenChanged(inner) => inner.match_rule(),
119			Self::VisibleDataChanged(inner) => inner.match_rule(),
120			Self::SelectionChanged(inner) => inner.match_rule(),
121			Self::ModelChanged(inner) => inner.match_rule(),
122			Self::ActiveDescendantChanged(inner) => inner.match_rule(),
123			Self::Announcement(inner) => inner.match_rule(),
124			Self::AttributesChanged(inner) => inner.match_rule(),
125			Self::RowInserted(inner) => inner.match_rule(),
126			Self::RowReordered(inner) => inner.match_rule(),
127			Self::RowDeleted(inner) => inner.match_rule(),
128			Self::ColumnInserted(inner) => inner.match_rule(),
129			Self::ColumnReordered(inner) => inner.match_rule(),
130			Self::ColumnDeleted(inner) => inner.match_rule(),
131			Self::TextBoundsChanged(inner) => inner.match_rule(),
132			Self::TextSelectionChanged(inner) => inner.match_rule(),
133			Self::TextChanged(inner) => inner.match_rule(),
134			Self::TextAttributesChanged(inner) => inner.match_rule(),
135			Self::TextCaretMoved(inner) => inner.match_rule(),
136		}
137	}
138	fn registry_string(&self) -> &'static str {
139		match self {
140			Self::PropertyChange(inner) => inner.registry_string(),
141			Self::BoundsChanged(inner) => inner.registry_string(),
142			Self::LinkSelected(inner) => inner.registry_string(),
143			Self::StateChanged(inner) => inner.registry_string(),
144			Self::ChildrenChanged(inner) => inner.registry_string(),
145			Self::VisibleDataChanged(inner) => inner.registry_string(),
146			Self::SelectionChanged(inner) => inner.registry_string(),
147			Self::ModelChanged(inner) => inner.registry_string(),
148			Self::ActiveDescendantChanged(inner) => inner.registry_string(),
149			Self::Announcement(inner) => inner.registry_string(),
150			Self::AttributesChanged(inner) => inner.registry_string(),
151			Self::RowInserted(inner) => inner.registry_string(),
152			Self::RowReordered(inner) => inner.registry_string(),
153			Self::RowDeleted(inner) => inner.registry_string(),
154			Self::ColumnInserted(inner) => inner.registry_string(),
155			Self::ColumnReordered(inner) => inner.registry_string(),
156			Self::ColumnDeleted(inner) => inner.registry_string(),
157			Self::TextBoundsChanged(inner) => inner.registry_string(),
158			Self::TextSelectionChanged(inner) => inner.registry_string(),
159			Self::TextChanged(inner) => inner.registry_string(),
160			Self::TextAttributesChanged(inner) => inner.registry_string(),
161			Self::TextCaretMoved(inner) => inner.registry_string(),
162		}
163	}
164}
165
166impl EventProperties for ObjectEvents {
167	fn path(&self) -> ObjectPath<'_> {
168		match self {
169			Self::PropertyChange(inner) => inner.path(),
170			Self::BoundsChanged(inner) => inner.path(),
171			Self::LinkSelected(inner) => inner.path(),
172			Self::StateChanged(inner) => inner.path(),
173			Self::ChildrenChanged(inner) => inner.path(),
174			Self::VisibleDataChanged(inner) => inner.path(),
175			Self::SelectionChanged(inner) => inner.path(),
176			Self::ModelChanged(inner) => inner.path(),
177			Self::ActiveDescendantChanged(inner) => inner.path(),
178			Self::Announcement(inner) => inner.path(),
179			Self::AttributesChanged(inner) => inner.path(),
180			Self::RowInserted(inner) => inner.path(),
181			Self::RowReordered(inner) => inner.path(),
182			Self::RowDeleted(inner) => inner.path(),
183			Self::ColumnInserted(inner) => inner.path(),
184			Self::ColumnReordered(inner) => inner.path(),
185			Self::ColumnDeleted(inner) => inner.path(),
186			Self::TextBoundsChanged(inner) => inner.path(),
187			Self::TextSelectionChanged(inner) => inner.path(),
188			Self::TextChanged(inner) => inner.path(),
189			Self::TextAttributesChanged(inner) => inner.path(),
190			Self::TextCaretMoved(inner) => inner.path(),
191		}
192	}
193	fn sender(&self) -> UniqueName<'_> {
194		match self {
195			Self::PropertyChange(inner) => inner.sender(),
196			Self::BoundsChanged(inner) => inner.sender(),
197			Self::LinkSelected(inner) => inner.sender(),
198			Self::StateChanged(inner) => inner.sender(),
199			Self::ChildrenChanged(inner) => inner.sender(),
200			Self::VisibleDataChanged(inner) => inner.sender(),
201			Self::SelectionChanged(inner) => inner.sender(),
202			Self::ModelChanged(inner) => inner.sender(),
203			Self::ActiveDescendantChanged(inner) => inner.sender(),
204			Self::Announcement(inner) => inner.sender(),
205			Self::AttributesChanged(inner) => inner.sender(),
206			Self::RowInserted(inner) => inner.sender(),
207			Self::RowReordered(inner) => inner.sender(),
208			Self::RowDeleted(inner) => inner.sender(),
209			Self::ColumnInserted(inner) => inner.sender(),
210			Self::ColumnReordered(inner) => inner.sender(),
211			Self::ColumnDeleted(inner) => inner.sender(),
212			Self::TextBoundsChanged(inner) => inner.sender(),
213			Self::TextSelectionChanged(inner) => inner.sender(),
214			Self::TextChanged(inner) => inner.sender(),
215			Self::TextAttributesChanged(inner) => inner.sender(),
216			Self::TextCaretMoved(inner) => inner.sender(),
217		}
218	}
219}
220
221impl_from_interface_event_enum_for_event!(ObjectEvents, Event::Object);
222impl_try_from_event_for_user_facing_event_type!(ObjectEvents, Event::Object);
223
224event_wrapper_test_cases!(ObjectEvents, PropertyChangeEvent);
225
226impl HasMatchRule for ObjectEvents {
227	const MATCH_RULE_STRING: &'static str = "type='signal',interface='org.a11y.atspi.Event.Object'";
228}
229
230/// The `org.a11y.atspi.Event.Object:PropertyChange` event.
231#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
232pub struct PropertyChangeEvent {
233	/// The [`ObjectRef`] which the event applies to.
234	pub item: crate::events::ObjectRef,
235	pub property: String,
236	pub value: Property,
237}
238
239impl Hash for PropertyChangeEvent {
240	fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
241		self.item.hash(state);
242		self.property.hash(state);
243	}
244}
245
246// Do not derive Eq if not all fields implement Eq
247impl Eq for PropertyChangeEvent {}
248
249// Looks like a false positive Clippy lint
250#[allow(clippy::derivable_impls)]
251impl Default for PropertyChangeEvent {
252	fn default() -> Self {
253		Self { item: ObjectRef::default(), property: String::default(), value: Property::default() }
254	}
255}
256
257#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize)]
258#[non_exhaustive]
259pub enum Property {
260	Name(String),
261	Description(String),
262	Role(crate::Role),
263	Parent(ObjectRef),
264	TableCaption(String),
265	TableColumnDescription(String),
266	TableColumnHeader(String),
267	TableRowDescription(String),
268	TableRowHeader(String),
269	TableSummary(String),
270	Other((String, OwnedValue)),
271}
272
273impl Clone for Property {
274	fn clone(&self) -> Self {
275		match self {
276			Property::Name(name) => Self::Name(name.clone()),
277			Property::Description(description) => Self::Description(description.clone()),
278			Property::Role(role) => Self::Role(*role),
279			Property::Parent(parent) => Self::Parent(parent.clone()),
280			Property::TableCaption(table_caption) => Self::TableCaption(table_caption.clone()),
281			Property::TableColumnDescription(table_column_description) => {
282				Self::TableColumnDescription(table_column_description.clone())
283			}
284			Property::TableColumnHeader(table_column_header) => {
285				Self::TableColumnHeader(table_column_header.clone())
286			}
287			Property::TableRowDescription(table_row_description) => {
288				Self::TableRowDescription(table_row_description.clone())
289			}
290			Property::TableRowHeader(table_row_header) => {
291				Self::TableRowHeader(table_row_header.clone())
292			}
293			Property::TableSummary(table_summary) => Self::TableSummary(table_summary.clone()),
294			Property::Other((property, value)) => Self::Other((
295				property.clone(),
296				value
297					.try_clone()
298					.expect("Could not clone 'value'.  Since properties are not known to carry files, we do not expect to exceed open file limit."),
299			)),
300		}
301	}
302}
303
304impl Default for Property {
305	fn default() -> Self {
306		Self::Other((String::default(), u64::default().into()))
307	}
308}
309
310impl TryFrom<EventBodyOwned> for Property {
311	type Error = AtspiError;
312
313	fn try_from(body: EventBodyOwned) -> Result<Self, Self::Error> {
314		let property = body.kind;
315
316		match property.as_str() {
317			"accessible-name" => Ok(Self::Name(
318				body.any_data
319					.try_into()
320					.map_err(|_| AtspiError::ParseError("accessible-name"))?,
321			)),
322			"accessible-description" => Ok(Self::Description(
323				body.any_data
324					.try_into()
325					.map_err(|_| AtspiError::ParseError("accessible-description"))?,
326			)),
327			"accessible-role" => Ok(Self::Role({
328				let role_int: u32 = body
329					.any_data
330					.try_into()
331					.map_err(|_| AtspiError::ParseError("accessible-role"))?;
332				let role: crate::Role = crate::Role::try_from(role_int)
333					.map_err(|_| AtspiError::ParseError("accessible-role"))?;
334				role
335			})),
336			"accessible-parent" => Ok(Self::Parent(
337				body.any_data
338					.try_into()
339					.map_err(|_| AtspiError::ParseError("accessible-parent"))?,
340			)),
341			"accessible-table-caption" => Ok(Self::TableCaption(
342				body.any_data
343					.try_into()
344					.map_err(|_| AtspiError::ParseError("accessible-table-caption"))?,
345			)),
346			"table-column-description" => Ok(Self::TableColumnDescription(
347				body.any_data
348					.try_into()
349					.map_err(|_| AtspiError::ParseError("table-column-description"))?,
350			)),
351			"table-column-header" => Ok(Self::TableColumnHeader(
352				body.any_data
353					.try_into()
354					.map_err(|_| AtspiError::ParseError("table-column-header"))?,
355			)),
356			"table-row-description" => Ok(Self::TableRowDescription(
357				body.any_data
358					.try_into()
359					.map_err(|_| AtspiError::ParseError("table-row-description"))?,
360			)),
361			"table-row-header" => Ok(Self::TableRowHeader(
362				body.any_data
363					.try_into()
364					.map_err(|_| AtspiError::ParseError("table-row-header"))?,
365			)),
366			"table-summary" => Ok(Self::TableSummary(
367				body.any_data
368					.try_into()
369					.map_err(|_| AtspiError::ParseError("table-summary"))?,
370			)),
371			_ => Ok(Self::Other((property, body.any_data))),
372		}
373	}
374}
375
376impl From<Property> for OwnedValue {
377	fn from(property: Property) -> Self {
378		let value = match property {
379			Property::Name(name) => Value::from(name),
380			Property::Description(description) => Value::from(description),
381			Property::Role(role) => Value::from(role as u32),
382			Property::Parent(parent) => Value::from(parent),
383			Property::TableCaption(table_caption) => Value::from(table_caption),
384			Property::TableColumnDescription(table_column_description) => {
385				Value::from(table_column_description)
386			}
387			Property::TableColumnHeader(table_column_header) => Value::from(table_column_header),
388			Property::TableRowDescription(table_row_description) => {
389				Value::from(table_row_description)
390			}
391			Property::TableRowHeader(table_row_header) => Value::from(table_row_header),
392			Property::TableSummary(table_summary) => Value::from(table_summary),
393			Property::Other((_, value)) => value.into(),
394		};
395		value.try_into().expect("Should succeed as there are no borrowed file descriptors involved that could, potentially, exceed the open file limit when converted to OwnedValue")
396	}
397}
398
399#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
400pub struct BoundsChangedEvent {
401	/// The [`ObjectRef`] which the event applies to.
402	pub item: crate::events::ObjectRef,
403}
404
405#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
406pub struct LinkSelectedEvent {
407	/// The [`ObjectRef`] which the event applies to.
408	pub item: crate::events::ObjectRef,
409}
410
411/// A state of an object has been modified.
412/// A [`State`] can be added or removed from any [`ObjectRef`].
413#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
414pub struct StateChangedEvent {
415	/// The [`ObjectRef`] which the event applies to.
416	pub item: crate::events::ObjectRef,
417	/// The state to be enabled/disabled.
418	pub state: State,
419	/// Enabled or disabled the state.
420	///
421	/// 1 == enabled
422	///
423	/// 0 == disabled
424	pub enabled: i32,
425}
426
427/// A child of an [`ObjectRef`] has been added or removed.
428#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
429pub struct ChildrenChangedEvent {
430	/// The [`ObjectRef`] which the event applies to.
431	pub item: crate::events::ObjectRef,
432	/// Operation, which may be one of:
433	///
434	/// * "insert/system"
435	/// * "insert"
436	/// * "delete/system"
437	/// * "delete"
438	///
439	/// The operation is the same whether it contains the "/system" suffix or not.
440	/// TODO: This should be an enum.
441	pub operation: String,
442	/// Index to remove from/add to.
443	pub index_in_parent: i32,
444	/// A reference to the new child.
445	pub child: ObjectRef,
446}
447
448#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
449pub struct VisibleDataChangedEvent {
450	/// The [`ObjectRef`] which the event applies to.
451	pub item: crate::events::ObjectRef,
452}
453
454#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
455pub struct SelectionChangedEvent {
456	/// The [`ObjectRef`] which the event applies to.
457	pub item: crate::events::ObjectRef,
458}
459
460#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
461pub struct ModelChangedEvent {
462	/// The [`ObjectRef`] which the event applies to.
463	pub item: crate::events::ObjectRef,
464}
465
466#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
467pub struct ActiveDescendantChangedEvent {
468	/// The [`ObjectRef`] which the event applies to.
469	pub item: crate::events::ObjectRef,
470	pub child: ObjectRef,
471}
472
473#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
474pub struct AnnouncementEvent {
475	/// The [`ObjectRef`] which the event applies to.
476	pub item: crate::events::ObjectRef,
477	/// Text of the announcement.
478	pub text: String,
479	/// Politeness level.
480	pub live: crate::Live,
481}
482
483#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
484pub struct AttributesChangedEvent {
485	/// The [`ObjectRef`] which the event applies to.
486	pub item: crate::events::ObjectRef,
487}
488
489/// A row has been added to a table.
490#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
491pub struct RowInsertedEvent {
492	/// The table which has had a row inserted.
493	pub item: crate::events::ObjectRef,
494}
495
496/// A row has been moved within a table.
497#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
498pub struct RowReorderedEvent {
499	/// The table which has had a row re-ordered.
500	pub item: crate::events::ObjectRef,
501}
502
503/// A row has been deleted from a table.
504#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
505pub struct RowDeletedEvent {
506	/// The table which has had a row removed.
507	pub item: crate::events::ObjectRef,
508}
509
510/// A column has been added to a table.
511#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
512pub struct ColumnInsertedEvent {
513	/// The table which has had a column inserted.
514	pub item: crate::events::ObjectRef,
515}
516
517/// A column has been re-ordered within a table.
518#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
519pub struct ColumnReorderedEvent {
520	/// The table which has had a column re-ordered.
521	pub item: crate::events::ObjectRef,
522}
523
524/// A column has been removed from a table.
525#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
526pub struct ColumnDeletedEvent {
527	/// The table which has had a column removed.
528	pub item: crate::events::ObjectRef,
529}
530
531#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
532pub struct TextBoundsChangedEvent {
533	/// The [`ObjectRef`] which the event applies to.
534	pub item: crate::events::ObjectRef,
535}
536
537#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
538pub struct TextSelectionChangedEvent {
539	/// The [`ObjectRef`] which the event applies to.
540	pub item: crate::events::ObjectRef,
541}
542
543/// Text has changed within an [`ObjectRef`].
544#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
545pub struct TextChangedEvent {
546	/// The [`ObjectRef`] which the event applies to.
547	pub item: crate::events::ObjectRef,
548	/// Operation, which may be one of:
549	///
550	/// * "insert/system"
551	/// * "insert"
552	/// * "delete/system"
553	/// * "delete"
554	///
555	/// The operation is the same whether it contains the "/system" suffix or not.
556	/// TODO: This should be an enum.
557	pub operation: String,
558	/// starting index of the insertion/deletion
559	pub start_pos: i32,
560	/// length of the insertion/deletion
561	pub length: i32,
562	/// the text being inserted/deleted
563	pub text: String,
564}
565
566#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
567pub struct TextAttributesChangedEvent {
568	/// The [`ObjectRef`] which the event applies to.
569	pub item: crate::events::ObjectRef,
570}
571
572/// The caret of the user also known as a cursor (not to be confused with mouse pointer) has changed position.
573#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
574pub struct TextCaretMovedEvent {
575	/// The object on which the caret has been moved on.
576	pub item: crate::events::ObjectRef,
577	/// New position of the caret.
578	pub position: i32,
579}
580
581impl BusProperties for PropertyChangeEvent {
582	const DBUS_MEMBER: &'static str = "PropertyChange";
583	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
584	const MATCH_RULE_STRING: &'static str =
585		"type='signal',interface='org.a11y.atspi.Event.Object',member='PropertyChange'";
586	const REGISTRY_EVENT_STRING: &'static str = "Object:";
587
588	type Body = EventBodyOwned;
589
590	fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
591		let property = body.kind.clone();
592		let value: Property = body.try_into()?;
593		Ok(Self { item, property, value })
594	}
595	fn body(&self) -> Self::Body {
596		let copy = self.clone();
597		copy.into()
598	}
599}
600
601impl BusProperties for BoundsChangedEvent {
602	const DBUS_MEMBER: &'static str = "BoundsChanged";
603	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
604	const MATCH_RULE_STRING: &'static str =
605		"type='signal',interface='org.a11y.atspi.Event.Object',member='BoundsChanged'";
606	const REGISTRY_EVENT_STRING: &'static str = "Object:";
607
608	type Body = EventBodyOwned;
609
610	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
611		Ok(Self { item })
612	}
613	fn body(&self) -> Self::Body {
614		let copy = self.clone();
615		copy.into()
616	}
617}
618
619impl BusProperties for LinkSelectedEvent {
620	const DBUS_MEMBER: &'static str = "LinkSelected";
621	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
622	const MATCH_RULE_STRING: &'static str =
623		"type='signal',interface='org.a11y.atspi.Event.Object',member='LinkSelected'";
624	const REGISTRY_EVENT_STRING: &'static str = "Object:";
625
626	type Body = EventBodyOwned;
627
628	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
629		Ok(Self { item })
630	}
631	fn body(&self) -> Self::Body {
632		let copy = self.clone();
633		copy.into()
634	}
635}
636
637impl BusProperties for StateChangedEvent {
638	const DBUS_MEMBER: &'static str = "StateChanged";
639	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
640	const MATCH_RULE_STRING: &'static str =
641		"type='signal',interface='org.a11y.atspi.Event.Object',member='StateChanged'";
642	const REGISTRY_EVENT_STRING: &'static str = "Object:";
643
644	type Body = EventBodyOwned;
645
646	fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
647		Ok(Self { item, state: body.kind.into(), enabled: body.detail1 })
648	}
649	fn body(&self) -> Self::Body {
650		let copy = self.clone();
651		copy.into()
652	}
653}
654
655impl BusProperties for ChildrenChangedEvent {
656	const DBUS_MEMBER: &'static str = "ChildrenChanged";
657	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
658	const MATCH_RULE_STRING: &'static str =
659		"type='signal',interface='org.a11y.atspi.Event.Object',member='ChildrenChanged'";
660	const REGISTRY_EVENT_STRING: &'static str = "Object:";
661
662	type Body = EventBodyOwned;
663
664	fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
665		Ok(Self {
666			item,
667			operation: body.kind,
668			index_in_parent: body.detail1,
669			child: body.any_data.try_into()?,
670		})
671	}
672	fn body(&self) -> Self::Body {
673		let copy = self.clone();
674		copy.into()
675	}
676}
677
678impl BusProperties for VisibleDataChangedEvent {
679	const DBUS_MEMBER: &'static str = "VisibleDataChanged";
680	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
681	const MATCH_RULE_STRING: &'static str =
682		"type='signal',interface='org.a11y.atspi.Event.Object',member='VisibleDataChanged'";
683	const REGISTRY_EVENT_STRING: &'static str = "Object:";
684
685	type Body = EventBodyOwned;
686
687	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
688		Ok(Self { item })
689	}
690	fn body(&self) -> Self::Body {
691		let copy = self.clone();
692		copy.into()
693	}
694}
695
696impl BusProperties for SelectionChangedEvent {
697	const DBUS_MEMBER: &'static str = "SelectionChanged";
698	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
699	const MATCH_RULE_STRING: &'static str =
700		"type='signal',interface='org.a11y.atspi.Event.Object',member='SelectionChanged'";
701	const REGISTRY_EVENT_STRING: &'static str = "Object:";
702
703	type Body = EventBodyOwned;
704
705	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
706		Ok(Self { item })
707	}
708	fn body(&self) -> Self::Body {
709		let copy = self.clone();
710		copy.into()
711	}
712}
713
714impl BusProperties for ModelChangedEvent {
715	const DBUS_MEMBER: &'static str = "ModelChanged";
716	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
717	const MATCH_RULE_STRING: &'static str =
718		"type='signal',interface='org.a11y.atspi.Event.Object',member='ModelChanged'";
719	const REGISTRY_EVENT_STRING: &'static str = "Object:";
720
721	type Body = EventBodyOwned;
722
723	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
724		Ok(Self { item })
725	}
726	fn body(&self) -> Self::Body {
727		let copy = self.clone();
728		copy.into()
729	}
730}
731
732impl BusProperties for ActiveDescendantChangedEvent {
733	const DBUS_MEMBER: &'static str = "ActiveDescendantChanged";
734	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
735	const MATCH_RULE_STRING: &'static str =
736		"type='signal',interface='org.a11y.atspi.Event.Object',member='ActiveDescendantChanged'";
737	const REGISTRY_EVENT_STRING: &'static str = "Object:";
738
739	type Body = EventBodyOwned;
740
741	fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
742		Ok(Self { item, child: body.any_data.try_into()? })
743	}
744	fn body(&self) -> Self::Body {
745		let copy = self.clone();
746		copy.into()
747	}
748}
749
750impl BusProperties for AnnouncementEvent {
751	const DBUS_MEMBER: &'static str = "Announcement";
752	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
753	const MATCH_RULE_STRING: &'static str =
754		"type='signal',interface='org.a11y.atspi.Event.Object',member='Announcement'";
755	const REGISTRY_EVENT_STRING: &'static str = "Object:";
756
757	type Body = EventBodyOwned;
758
759	fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
760		Ok(Self {
761			item,
762			text: body.any_data.try_into().map_err(|_| AtspiError::Conversion("text"))?,
763			live: body.detail1.try_into()?,
764		})
765	}
766	fn body(&self) -> Self::Body {
767		let copy = self.clone();
768		copy.into()
769	}
770}
771
772impl BusProperties for AttributesChangedEvent {
773	const DBUS_MEMBER: &'static str = "AttributesChanged";
774	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
775	const MATCH_RULE_STRING: &'static str =
776		"type='signal',interface='org.a11y.atspi.Event.Object',member='AttributesChanged'";
777	const REGISTRY_EVENT_STRING: &'static str = "Object:";
778
779	type Body = EventBodyOwned;
780
781	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
782		Ok(Self { item })
783	}
784	fn body(&self) -> Self::Body {
785		let copy = self.clone();
786		copy.into()
787	}
788}
789
790impl BusProperties for RowInsertedEvent {
791	const DBUS_MEMBER: &'static str = "RowInserted";
792	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
793	const MATCH_RULE_STRING: &'static str =
794		"type='signal',interface='org.a11y.atspi.Event.Object',member='RowInserted'";
795	const REGISTRY_EVENT_STRING: &'static str = "Object:";
796
797	type Body = EventBodyOwned;
798
799	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
800		Ok(Self { item })
801	}
802	fn body(&self) -> Self::Body {
803		let copy = self.clone();
804		copy.into()
805	}
806}
807
808impl BusProperties for RowReorderedEvent {
809	const DBUS_MEMBER: &'static str = "RowReordered";
810	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
811	const MATCH_RULE_STRING: &'static str =
812		"type='signal',interface='org.a11y.atspi.Event.Object',member='RowReordered'";
813	const REGISTRY_EVENT_STRING: &'static str = "Object:";
814
815	type Body = EventBodyOwned;
816
817	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
818		Ok(Self { item })
819	}
820	fn body(&self) -> Self::Body {
821		let copy = self.clone();
822		copy.into()
823	}
824}
825
826impl BusProperties for RowDeletedEvent {
827	const DBUS_MEMBER: &'static str = "RowDeleted";
828	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
829	const MATCH_RULE_STRING: &'static str =
830		"type='signal',interface='org.a11y.atspi.Event.Object',member='RowDeleted'";
831	const REGISTRY_EVENT_STRING: &'static str = "Object:";
832
833	type Body = EventBodyOwned;
834
835	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
836		Ok(Self { item })
837	}
838	fn body(&self) -> Self::Body {
839		let copy = self.clone();
840		copy.into()
841	}
842}
843
844impl BusProperties for ColumnInsertedEvent {
845	const DBUS_MEMBER: &'static str = "ColumnInserted";
846	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
847	const MATCH_RULE_STRING: &'static str =
848		"type='signal',interface='org.a11y.atspi.Event.Object',member='ColumnInserted'";
849	const REGISTRY_EVENT_STRING: &'static str = "Object:";
850
851	type Body = EventBodyOwned;
852
853	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
854		Ok(Self { item })
855	}
856	fn body(&self) -> Self::Body {
857		let copy = self.clone();
858		copy.into()
859	}
860}
861
862impl BusProperties for ColumnReorderedEvent {
863	const DBUS_MEMBER: &'static str = "ColumnReordered";
864	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
865	const MATCH_RULE_STRING: &'static str =
866		"type='signal',interface='org.a11y.atspi.Event.Object',member='ColumnReordered'";
867	const REGISTRY_EVENT_STRING: &'static str = "Object:";
868
869	type Body = EventBodyOwned;
870
871	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
872		Ok(Self { item })
873	}
874	fn body(&self) -> Self::Body {
875		let copy = self.clone();
876		copy.into()
877	}
878}
879
880impl BusProperties for ColumnDeletedEvent {
881	const DBUS_MEMBER: &'static str = "ColumnDeleted";
882	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
883	const MATCH_RULE_STRING: &'static str =
884		"type='signal',interface='org.a11y.atspi.Event.Object',member='ColumnDeleted'";
885	const REGISTRY_EVENT_STRING: &'static str = "Object:";
886
887	type Body = EventBodyOwned;
888
889	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
890		Ok(Self { item })
891	}
892	fn body(&self) -> Self::Body {
893		let copy = self.clone();
894		copy.into()
895	}
896}
897
898impl BusProperties for TextBoundsChangedEvent {
899	const DBUS_MEMBER: &'static str = "TextBoundsChanged";
900	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
901	const MATCH_RULE_STRING: &'static str =
902		"type='signal',interface='org.a11y.atspi.Event.Object',member='TextBoundsChanged'";
903	const REGISTRY_EVENT_STRING: &'static str = "Object:";
904
905	type Body = EventBodyOwned;
906
907	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
908		Ok(Self { item })
909	}
910	fn body(&self) -> Self::Body {
911		let copy = self.clone();
912		copy.into()
913	}
914}
915
916impl BusProperties for TextSelectionChangedEvent {
917	const DBUS_MEMBER: &'static str = "TextSelectionChanged";
918	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
919	const MATCH_RULE_STRING: &'static str =
920		"type='signal',interface='org.a11y.atspi.Event.Object',member='TextSelectionChanged'";
921	const REGISTRY_EVENT_STRING: &'static str = "Object:";
922
923	type Body = EventBodyOwned;
924
925	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
926		Ok(Self { item })
927	}
928	fn body(&self) -> Self::Body {
929		let copy = self.clone();
930		copy.into()
931	}
932}
933
934impl BusProperties for TextChangedEvent {
935	const DBUS_MEMBER: &'static str = "TextChanged";
936	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
937	const MATCH_RULE_STRING: &'static str =
938		"type='signal',interface='org.a11y.atspi.Event.Object',member='TextChanged'";
939	const REGISTRY_EVENT_STRING: &'static str = "Object:";
940
941	type Body = EventBodyOwned;
942
943	fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
944		Ok(Self {
945			item,
946			operation: body.kind,
947			start_pos: body.detail1,
948			length: body.detail2,
949			text: body.any_data.try_into()?,
950		})
951	}
952	fn body(&self) -> Self::Body {
953		let copy = self.clone();
954		copy.into()
955	}
956}
957
958impl BusProperties for TextAttributesChangedEvent {
959	const DBUS_MEMBER: &'static str = "TextAttributesChanged";
960	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
961	const MATCH_RULE_STRING: &'static str =
962		"type='signal',interface='org.a11y.atspi.Event.Object',member='TextAttributesChanged'";
963	const REGISTRY_EVENT_STRING: &'static str = "Object:";
964
965	type Body = EventBodyOwned;
966
967	fn from_message_parts(item: ObjectRef, _body: Self::Body) -> Result<Self, AtspiError> {
968		Ok(Self { item })
969	}
970	fn body(&self) -> Self::Body {
971		let copy = self.clone();
972		copy.into()
973	}
974}
975
976impl BusProperties for TextCaretMovedEvent {
977	const DBUS_MEMBER: &'static str = "TextCaretMoved";
978	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object";
979	const MATCH_RULE_STRING: &'static str =
980		"type='signal',interface='org.a11y.atspi.Event.Object',member='TextCaretMoved'";
981	const REGISTRY_EVENT_STRING: &'static str = "Object:";
982
983	type Body = EventBodyOwned;
984
985	fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
986		Ok(Self { item, position: body.detail1 })
987	}
988	fn body(&self) -> Self::Body {
989		let copy = self.clone();
990		copy.into()
991	}
992}
993
994#[cfg(feature = "zbus")]
995impl TryFrom<&zbus::Message> for ObjectEvents {
996	type Error = AtspiError;
997	fn try_from(ev: &zbus::Message) -> Result<Self, Self::Error> {
998		let header = ev.header();
999		let member = header
1000			.member()
1001			.ok_or(AtspiError::MemberMatch("Event without member".into()))?;
1002		match member.as_str() {
1003			"PropertyChange" => Ok(ObjectEvents::PropertyChange(ev.try_into()?)),
1004			"BoundsChanged" => Ok(ObjectEvents::BoundsChanged(ev.try_into()?)),
1005			"LinkSelected" => Ok(ObjectEvents::LinkSelected(ev.try_into()?)),
1006			"StateChanged" => Ok(ObjectEvents::StateChanged(ev.try_into()?)),
1007			"ChildrenChanged" => Ok(ObjectEvents::ChildrenChanged(ev.try_into()?)),
1008			"VisibleDataChanged" => Ok(ObjectEvents::VisibleDataChanged(ev.try_into()?)),
1009			"SelectionChanged" => Ok(ObjectEvents::SelectionChanged(ev.try_into()?)),
1010			"ModelChanged" => Ok(ObjectEvents::ModelChanged(ev.try_into()?)),
1011			"ActiveDescendantChanged" => Ok(ObjectEvents::ActiveDescendantChanged(ev.try_into()?)),
1012			"Announcement" => Ok(ObjectEvents::Announcement(ev.try_into()?)),
1013			"AttributesChanged" => Ok(ObjectEvents::AttributesChanged(ev.try_into()?)),
1014			"RowInserted" => Ok(ObjectEvents::RowInserted(ev.try_into()?)),
1015			"RowReordered" => Ok(ObjectEvents::RowReordered(ev.try_into()?)),
1016			"RowDeleted" => Ok(ObjectEvents::RowDeleted(ev.try_into()?)),
1017			"ColumnInserted" => Ok(ObjectEvents::ColumnInserted(ev.try_into()?)),
1018			"ColumnReordered" => Ok(ObjectEvents::ColumnReordered(ev.try_into()?)),
1019			"ColumnDeleted" => Ok(ObjectEvents::ColumnDeleted(ev.try_into()?)),
1020			"TextBoundsChanged" => Ok(ObjectEvents::TextBoundsChanged(ev.try_into()?)),
1021			"TextSelectionChanged" => Ok(ObjectEvents::TextSelectionChanged(ev.try_into()?)),
1022			"TextChanged" => Ok(ObjectEvents::TextChanged(ev.try_into()?)),
1023			"TextAttributesChanged" => Ok(ObjectEvents::TextAttributesChanged(ev.try_into()?)),
1024			"TextCaretMoved" => Ok(ObjectEvents::TextCaretMoved(ev.try_into()?)),
1025			_ => Err(AtspiError::MemberMatch("No matching member for Object".into())),
1026		}
1027	}
1028}
1029
1030impl_from_user_facing_event_for_interface_event_enum!(
1031	PropertyChangeEvent,
1032	ObjectEvents,
1033	ObjectEvents::PropertyChange
1034);
1035impl_from_user_facing_type_for_event_enum!(PropertyChangeEvent, Event::Object);
1036impl_try_from_event_for_user_facing_type!(
1037	PropertyChangeEvent,
1038	ObjectEvents::PropertyChange,
1039	Event::Object
1040);
1041
1042event_test_cases!(PropertyChangeEvent);
1043impl_to_dbus_message!(PropertyChangeEvent);
1044impl_from_dbus_message!(PropertyChangeEvent);
1045impl_event_properties!(PropertyChangeEvent);
1046
1047impl From<PropertyChangeEvent> for EventBodyOwned {
1048	fn from(event: PropertyChangeEvent) -> Self {
1049		EventBodyOwned {
1050			properties: std::collections::HashMap::new(),
1051			kind: event.property,
1052			detail1: i32::default(),
1053			detail2: i32::default(),
1054			any_data: event.value.into(),
1055		}
1056	}
1057}
1058
1059impl_from_user_facing_event_for_interface_event_enum!(
1060	BoundsChangedEvent,
1061	ObjectEvents,
1062	ObjectEvents::BoundsChanged
1063);
1064impl_from_user_facing_type_for_event_enum!(BoundsChangedEvent, Event::Object);
1065impl_try_from_event_for_user_facing_type!(
1066	BoundsChangedEvent,
1067	ObjectEvents::BoundsChanged,
1068	Event::Object
1069);
1070event_test_cases!(BoundsChangedEvent);
1071impl_to_dbus_message!(BoundsChangedEvent);
1072impl_from_dbus_message!(BoundsChangedEvent);
1073impl_event_properties!(BoundsChangedEvent);
1074impl From<BoundsChangedEvent> for EventBodyOwned {
1075	fn from(_event: BoundsChangedEvent) -> Self {
1076		EventBodyOwned {
1077			properties: std::collections::HashMap::new(),
1078			kind: String::default(),
1079			detail1: i32::default(),
1080			detail2: i32::default(),
1081			any_data: u8::default().into(),
1082		}
1083	}
1084}
1085
1086impl_from_user_facing_event_for_interface_event_enum!(
1087	LinkSelectedEvent,
1088	ObjectEvents,
1089	ObjectEvents::LinkSelected
1090);
1091impl_from_user_facing_type_for_event_enum!(LinkSelectedEvent, Event::Object);
1092impl_try_from_event_for_user_facing_type!(
1093	LinkSelectedEvent,
1094	ObjectEvents::LinkSelected,
1095	Event::Object
1096);
1097event_test_cases!(LinkSelectedEvent);
1098impl_to_dbus_message!(LinkSelectedEvent);
1099impl_from_dbus_message!(LinkSelectedEvent);
1100impl_event_properties!(LinkSelectedEvent);
1101impl From<LinkSelectedEvent> for EventBodyOwned {
1102	fn from(_event: LinkSelectedEvent) -> Self {
1103		EventBodyOwned {
1104			properties: std::collections::HashMap::new(),
1105			kind: String::default(),
1106			detail1: i32::default(),
1107			detail2: i32::default(),
1108			any_data: u8::default().into(),
1109		}
1110	}
1111}
1112
1113impl_from_user_facing_event_for_interface_event_enum!(
1114	StateChangedEvent,
1115	ObjectEvents,
1116	ObjectEvents::StateChanged
1117);
1118impl_from_user_facing_type_for_event_enum!(StateChangedEvent, Event::Object);
1119impl_try_from_event_for_user_facing_type!(
1120	StateChangedEvent,
1121	ObjectEvents::StateChanged,
1122	Event::Object
1123);
1124event_test_cases!(StateChangedEvent);
1125impl_to_dbus_message!(StateChangedEvent);
1126impl_from_dbus_message!(StateChangedEvent);
1127impl_event_properties!(StateChangedEvent);
1128impl From<StateChangedEvent> for EventBodyOwned {
1129	fn from(event: StateChangedEvent) -> Self {
1130		EventBodyOwned {
1131			properties: std::collections::HashMap::new(),
1132			kind: event.state.into(),
1133			detail1: event.enabled,
1134			detail2: i32::default(),
1135			any_data: u8::default().into(),
1136		}
1137	}
1138}
1139
1140impl_from_user_facing_event_for_interface_event_enum!(
1141	ChildrenChangedEvent,
1142	ObjectEvents,
1143	ObjectEvents::ChildrenChanged
1144);
1145impl_from_user_facing_type_for_event_enum!(ChildrenChangedEvent, Event::Object);
1146impl_try_from_event_for_user_facing_type!(
1147	ChildrenChangedEvent,
1148	ObjectEvents::ChildrenChanged,
1149	Event::Object
1150);
1151event_test_cases!(ChildrenChangedEvent);
1152impl_to_dbus_message!(ChildrenChangedEvent);
1153impl_from_dbus_message!(ChildrenChangedEvent);
1154impl_event_properties!(ChildrenChangedEvent);
1155impl From<ChildrenChangedEvent> for EventBodyOwned {
1156	fn from(event: ChildrenChangedEvent) -> Self {
1157		EventBodyOwned {
1158			properties: std::collections::HashMap::new(),
1159			kind: event.operation,
1160			detail1: event.index_in_parent,
1161			detail2: i32::default(),
1162			// `OwnedValue` is constructed from the `ObjectRef`
1163			// Only path to fail is to convert a Fd into an `OwnedValue`.
1164			// Therefore, this is safe.
1165			any_data: Value::from(event.child)
1166				.try_into()
1167				.expect("Failed to convert child to OwnedValue"),
1168		}
1169	}
1170}
1171
1172impl_from_user_facing_event_for_interface_event_enum!(
1173	VisibleDataChangedEvent,
1174	ObjectEvents,
1175	ObjectEvents::VisibleDataChanged
1176);
1177impl_from_user_facing_type_for_event_enum!(VisibleDataChangedEvent, Event::Object);
1178impl_try_from_event_for_user_facing_type!(
1179	VisibleDataChangedEvent,
1180	ObjectEvents::VisibleDataChanged,
1181	Event::Object
1182);
1183event_test_cases!(VisibleDataChangedEvent);
1184impl_to_dbus_message!(VisibleDataChangedEvent);
1185impl_from_dbus_message!(VisibleDataChangedEvent);
1186impl_event_properties!(VisibleDataChangedEvent);
1187impl From<VisibleDataChangedEvent> for EventBodyOwned {
1188	fn from(_event: VisibleDataChangedEvent) -> Self {
1189		EventBodyOwned {
1190			properties: std::collections::HashMap::new(),
1191			kind: String::default(),
1192			detail1: i32::default(),
1193			detail2: i32::default(),
1194			any_data: u8::default().into(),
1195		}
1196	}
1197}
1198
1199impl_from_user_facing_event_for_interface_event_enum!(
1200	SelectionChangedEvent,
1201	ObjectEvents,
1202	ObjectEvents::SelectionChanged
1203);
1204impl_from_user_facing_type_for_event_enum!(SelectionChangedEvent, Event::Object);
1205impl_try_from_event_for_user_facing_type!(
1206	SelectionChangedEvent,
1207	ObjectEvents::SelectionChanged,
1208	Event::Object
1209);
1210event_test_cases!(SelectionChangedEvent);
1211impl_to_dbus_message!(SelectionChangedEvent);
1212impl_from_dbus_message!(SelectionChangedEvent);
1213impl_event_properties!(SelectionChangedEvent);
1214impl From<SelectionChangedEvent> for EventBodyOwned {
1215	fn from(_event: SelectionChangedEvent) -> Self {
1216		EventBodyOwned {
1217			properties: std::collections::HashMap::new(),
1218			kind: String::default(),
1219			detail1: i32::default(),
1220			detail2: i32::default(),
1221			any_data: u8::default().into(),
1222		}
1223	}
1224}
1225
1226impl_from_user_facing_event_for_interface_event_enum!(
1227	ModelChangedEvent,
1228	ObjectEvents,
1229	ObjectEvents::ModelChanged
1230);
1231impl_from_user_facing_type_for_event_enum!(ModelChangedEvent, Event::Object);
1232impl_try_from_event_for_user_facing_type!(
1233	ModelChangedEvent,
1234	ObjectEvents::ModelChanged,
1235	Event::Object
1236);
1237event_test_cases!(ModelChangedEvent);
1238impl_to_dbus_message!(ModelChangedEvent);
1239impl_from_dbus_message!(ModelChangedEvent);
1240impl_event_properties!(ModelChangedEvent);
1241impl From<ModelChangedEvent> for EventBodyOwned {
1242	fn from(_event: ModelChangedEvent) -> Self {
1243		EventBodyOwned {
1244			properties: std::collections::HashMap::new(),
1245			kind: String::default(),
1246			detail1: i32::default(),
1247			detail2: i32::default(),
1248			any_data: u8::default().into(),
1249		}
1250	}
1251}
1252
1253impl_from_user_facing_event_for_interface_event_enum!(
1254	ActiveDescendantChangedEvent,
1255	ObjectEvents,
1256	ObjectEvents::ActiveDescendantChanged
1257);
1258impl_from_user_facing_type_for_event_enum!(ActiveDescendantChangedEvent, Event::Object);
1259impl_try_from_event_for_user_facing_type!(
1260	ActiveDescendantChangedEvent,
1261	ObjectEvents::ActiveDescendantChanged,
1262	Event::Object
1263);
1264event_test_cases!(ActiveDescendantChangedEvent);
1265impl_to_dbus_message!(ActiveDescendantChangedEvent);
1266impl_from_dbus_message!(ActiveDescendantChangedEvent);
1267impl_event_properties!(ActiveDescendantChangedEvent);
1268impl From<ActiveDescendantChangedEvent> for EventBodyOwned {
1269	fn from(event: ActiveDescendantChangedEvent) -> Self {
1270		EventBodyOwned {
1271			properties: std::collections::HashMap::new(),
1272			kind: String::default(),
1273			detail1: i32::default(),
1274			detail2: i32::default(),
1275			// `OwnedValue` is constructed from the `ObjectRef`
1276			// Only path to fail is to convert a Fd into an `OwnedValue`.
1277			// Therefore, this is safe.
1278			any_data: Value::from(event.child)
1279				.try_to_owned()
1280				.expect("Failed to convert child to OwnedValue"),
1281		}
1282	}
1283}
1284
1285impl_from_user_facing_event_for_interface_event_enum!(
1286	AnnouncementEvent,
1287	ObjectEvents,
1288	ObjectEvents::Announcement
1289);
1290impl_from_user_facing_type_for_event_enum!(AnnouncementEvent, Event::Object);
1291impl_try_from_event_for_user_facing_type!(
1292	AnnouncementEvent,
1293	ObjectEvents::Announcement,
1294	Event::Object
1295);
1296event_test_cases!(AnnouncementEvent);
1297impl_to_dbus_message!(AnnouncementEvent);
1298impl_from_dbus_message!(AnnouncementEvent);
1299impl_event_properties!(AnnouncementEvent);
1300impl From<AnnouncementEvent> for EventBodyOwned {
1301	fn from(event: AnnouncementEvent) -> Self {
1302		EventBodyOwned {
1303			detail1: event.live as i32,
1304			// `OwnedValue` is constructed from `String`
1305			// Therefore, this is safe.
1306			any_data: Value::from(event.text)
1307				.try_to_owned()
1308				.expect("Failed to convert text to OwnedValue"),
1309			..Default::default()
1310		}
1311	}
1312}
1313
1314impl_from_user_facing_event_for_interface_event_enum!(
1315	AttributesChangedEvent,
1316	ObjectEvents,
1317	ObjectEvents::AttributesChanged
1318);
1319impl_from_user_facing_type_for_event_enum!(AttributesChangedEvent, Event::Object);
1320impl_try_from_event_for_user_facing_type!(
1321	AttributesChangedEvent,
1322	ObjectEvents::AttributesChanged,
1323	Event::Object
1324);
1325event_test_cases!(AttributesChangedEvent);
1326impl_to_dbus_message!(AttributesChangedEvent);
1327impl_from_dbus_message!(AttributesChangedEvent);
1328impl_event_properties!(AttributesChangedEvent);
1329impl From<AttributesChangedEvent> for EventBodyOwned {
1330	fn from(_event: AttributesChangedEvent) -> Self {
1331		EventBodyOwned {
1332			properties: std::collections::HashMap::new(),
1333			kind: String::default(),
1334			detail1: i32::default(),
1335			detail2: i32::default(),
1336			any_data: u8::default().into(),
1337		}
1338	}
1339}
1340
1341impl_from_user_facing_event_for_interface_event_enum!(
1342	RowInsertedEvent,
1343	ObjectEvents,
1344	ObjectEvents::RowInserted
1345);
1346impl_from_user_facing_type_for_event_enum!(RowInsertedEvent, Event::Object);
1347impl_try_from_event_for_user_facing_type!(
1348	RowInsertedEvent,
1349	ObjectEvents::RowInserted,
1350	Event::Object
1351);
1352event_test_cases!(RowInsertedEvent);
1353impl_to_dbus_message!(RowInsertedEvent);
1354impl_from_dbus_message!(RowInsertedEvent);
1355impl_event_properties!(RowInsertedEvent);
1356impl From<RowInsertedEvent> for EventBodyOwned {
1357	fn from(_event: RowInsertedEvent) -> Self {
1358		EventBodyOwned {
1359			properties: std::collections::HashMap::new(),
1360			kind: String::default(),
1361			detail1: i32::default(),
1362			detail2: i32::default(),
1363			any_data: u8::default().into(),
1364		}
1365	}
1366}
1367
1368impl_from_user_facing_event_for_interface_event_enum!(
1369	RowReorderedEvent,
1370	ObjectEvents,
1371	ObjectEvents::RowReordered
1372);
1373impl_from_user_facing_type_for_event_enum!(RowReorderedEvent, Event::Object);
1374impl_try_from_event_for_user_facing_type!(
1375	RowReorderedEvent,
1376	ObjectEvents::RowReordered,
1377	Event::Object
1378);
1379event_test_cases!(RowReorderedEvent);
1380impl_to_dbus_message!(RowReorderedEvent);
1381impl_from_dbus_message!(RowReorderedEvent);
1382impl_event_properties!(RowReorderedEvent);
1383impl From<RowReorderedEvent> for EventBodyOwned {
1384	fn from(_event: RowReorderedEvent) -> Self {
1385		EventBodyOwned {
1386			properties: std::collections::HashMap::new(),
1387			kind: String::default(),
1388			detail1: i32::default(),
1389			detail2: i32::default(),
1390			any_data: u8::default().into(),
1391		}
1392	}
1393}
1394
1395impl_from_user_facing_event_for_interface_event_enum!(
1396	RowDeletedEvent,
1397	ObjectEvents,
1398	ObjectEvents::RowDeleted
1399);
1400impl_from_user_facing_type_for_event_enum!(RowDeletedEvent, Event::Object);
1401impl_try_from_event_for_user_facing_type!(RowDeletedEvent, ObjectEvents::RowDeleted, Event::Object);
1402event_test_cases!(RowDeletedEvent);
1403impl_to_dbus_message!(RowDeletedEvent);
1404impl_from_dbus_message!(RowDeletedEvent);
1405impl_event_properties!(RowDeletedEvent);
1406impl From<RowDeletedEvent> for EventBodyOwned {
1407	fn from(_event: RowDeletedEvent) -> Self {
1408		EventBodyOwned {
1409			properties: std::collections::HashMap::new(),
1410			kind: String::default(),
1411			detail1: i32::default(),
1412			detail2: i32::default(),
1413			any_data: u8::default().into(),
1414		}
1415	}
1416}
1417
1418impl_from_user_facing_event_for_interface_event_enum!(
1419	ColumnInsertedEvent,
1420	ObjectEvents,
1421	ObjectEvents::ColumnInserted
1422);
1423impl_from_user_facing_type_for_event_enum!(ColumnInsertedEvent, Event::Object);
1424impl_try_from_event_for_user_facing_type!(
1425	ColumnInsertedEvent,
1426	ObjectEvents::ColumnInserted,
1427	Event::Object
1428);
1429event_test_cases!(ColumnInsertedEvent);
1430impl_to_dbus_message!(ColumnInsertedEvent);
1431impl_from_dbus_message!(ColumnInsertedEvent);
1432impl_event_properties!(ColumnInsertedEvent);
1433impl From<ColumnInsertedEvent> for EventBodyOwned {
1434	fn from(_event: ColumnInsertedEvent) -> Self {
1435		EventBodyOwned {
1436			properties: std::collections::HashMap::new(),
1437			kind: String::default(),
1438			detail1: i32::default(),
1439			detail2: i32::default(),
1440			any_data: u8::default().into(),
1441		}
1442	}
1443}
1444
1445impl_from_user_facing_event_for_interface_event_enum!(
1446	ColumnReorderedEvent,
1447	ObjectEvents,
1448	ObjectEvents::ColumnReordered
1449);
1450impl_from_user_facing_type_for_event_enum!(ColumnReorderedEvent, Event::Object);
1451impl_try_from_event_for_user_facing_type!(
1452	ColumnReorderedEvent,
1453	ObjectEvents::ColumnReordered,
1454	Event::Object
1455);
1456event_test_cases!(ColumnReorderedEvent);
1457impl_to_dbus_message!(ColumnReorderedEvent);
1458impl_from_dbus_message!(ColumnReorderedEvent);
1459impl_event_properties!(ColumnReorderedEvent);
1460impl From<ColumnReorderedEvent> for EventBodyOwned {
1461	fn from(_event: ColumnReorderedEvent) -> Self {
1462		EventBodyOwned {
1463			properties: std::collections::HashMap::new(),
1464			kind: String::default(),
1465			detail1: i32::default(),
1466			detail2: i32::default(),
1467			any_data: u8::default().into(),
1468		}
1469	}
1470}
1471
1472impl_from_user_facing_event_for_interface_event_enum!(
1473	ColumnDeletedEvent,
1474	ObjectEvents,
1475	ObjectEvents::ColumnDeleted
1476);
1477impl_from_user_facing_type_for_event_enum!(ColumnDeletedEvent, Event::Object);
1478impl_try_from_event_for_user_facing_type!(
1479	ColumnDeletedEvent,
1480	ObjectEvents::ColumnDeleted,
1481	Event::Object
1482);
1483event_test_cases!(ColumnDeletedEvent);
1484impl_to_dbus_message!(ColumnDeletedEvent);
1485impl_from_dbus_message!(ColumnDeletedEvent);
1486impl_event_properties!(ColumnDeletedEvent);
1487impl From<ColumnDeletedEvent> for EventBodyOwned {
1488	fn from(_event: ColumnDeletedEvent) -> Self {
1489		EventBodyOwned {
1490			properties: std::collections::HashMap::new(),
1491			kind: String::default(),
1492			detail1: i32::default(),
1493			detail2: i32::default(),
1494			any_data: u8::default().into(),
1495		}
1496	}
1497}
1498
1499impl_from_user_facing_event_for_interface_event_enum!(
1500	TextBoundsChangedEvent,
1501	ObjectEvents,
1502	ObjectEvents::TextBoundsChanged
1503);
1504impl_from_user_facing_type_for_event_enum!(TextBoundsChangedEvent, Event::Object);
1505impl_try_from_event_for_user_facing_type!(
1506	TextBoundsChangedEvent,
1507	ObjectEvents::TextBoundsChanged,
1508	Event::Object
1509);
1510event_test_cases!(TextBoundsChangedEvent);
1511impl_to_dbus_message!(TextBoundsChangedEvent);
1512impl_from_dbus_message!(TextBoundsChangedEvent);
1513impl_event_properties!(TextBoundsChangedEvent);
1514impl From<TextBoundsChangedEvent> for EventBodyOwned {
1515	fn from(_event: TextBoundsChangedEvent) -> Self {
1516		EventBodyOwned {
1517			properties: std::collections::HashMap::new(),
1518			kind: String::default(),
1519			detail1: i32::default(),
1520			detail2: i32::default(),
1521			any_data: u8::default().into(),
1522		}
1523	}
1524}
1525
1526impl_from_user_facing_event_for_interface_event_enum!(
1527	TextSelectionChangedEvent,
1528	ObjectEvents,
1529	ObjectEvents::TextSelectionChanged
1530);
1531impl_from_user_facing_type_for_event_enum!(TextSelectionChangedEvent, Event::Object);
1532impl_try_from_event_for_user_facing_type!(
1533	TextSelectionChangedEvent,
1534	ObjectEvents::TextSelectionChanged,
1535	Event::Object
1536);
1537event_test_cases!(TextSelectionChangedEvent);
1538impl_to_dbus_message!(TextSelectionChangedEvent);
1539impl_from_dbus_message!(TextSelectionChangedEvent);
1540impl_event_properties!(TextSelectionChangedEvent);
1541impl From<TextSelectionChangedEvent> for EventBodyOwned {
1542	fn from(_event: TextSelectionChangedEvent) -> Self {
1543		EventBodyOwned {
1544			properties: std::collections::HashMap::new(),
1545			kind: String::default(),
1546			detail1: i32::default(),
1547			detail2: i32::default(),
1548			any_data: u8::default().into(),
1549		}
1550	}
1551}
1552
1553impl_from_user_facing_event_for_interface_event_enum!(
1554	TextChangedEvent,
1555	ObjectEvents,
1556	ObjectEvents::TextChanged
1557);
1558impl_from_user_facing_type_for_event_enum!(TextChangedEvent, Event::Object);
1559impl_try_from_event_for_user_facing_type!(
1560	TextChangedEvent,
1561	ObjectEvents::TextChanged,
1562	Event::Object
1563);
1564event_test_cases!(TextChangedEvent);
1565impl_to_dbus_message!(TextChangedEvent);
1566impl_from_dbus_message!(TextChangedEvent);
1567impl_event_properties!(TextChangedEvent);
1568impl From<TextChangedEvent> for EventBodyOwned {
1569	fn from(event: TextChangedEvent) -> Self {
1570		EventBodyOwned {
1571			properties: std::collections::HashMap::new(),
1572			kind: event.operation,
1573			detail1: event.start_pos,
1574			detail2: event.length,
1575
1576			// `OwnedValue` is constructed from a `String`
1577			// Therefore, this is safe.
1578			any_data: Value::from(event.text)
1579				.try_to_owned()
1580				.expect("Failed to convert child to OwnedValue"),
1581		}
1582	}
1583}
1584
1585impl_from_user_facing_event_for_interface_event_enum!(
1586	TextAttributesChangedEvent,
1587	ObjectEvents,
1588	ObjectEvents::TextAttributesChanged
1589);
1590impl_from_user_facing_type_for_event_enum!(TextAttributesChangedEvent, Event::Object);
1591impl_try_from_event_for_user_facing_type!(
1592	TextAttributesChangedEvent,
1593	ObjectEvents::TextAttributesChanged,
1594	Event::Object
1595);
1596event_test_cases!(TextAttributesChangedEvent);
1597impl_to_dbus_message!(TextAttributesChangedEvent);
1598impl_from_dbus_message!(TextAttributesChangedEvent);
1599impl_event_properties!(TextAttributesChangedEvent);
1600impl From<TextAttributesChangedEvent> for EventBodyOwned {
1601	fn from(_event: TextAttributesChangedEvent) -> Self {
1602		EventBodyOwned {
1603			properties: std::collections::HashMap::new(),
1604			kind: String::default(),
1605			detail1: i32::default(),
1606			detail2: i32::default(),
1607			any_data: u8::default().into(),
1608		}
1609	}
1610}
1611
1612impl_from_user_facing_event_for_interface_event_enum!(
1613	TextCaretMovedEvent,
1614	ObjectEvents,
1615	ObjectEvents::TextCaretMoved
1616);
1617impl_from_user_facing_type_for_event_enum!(TextCaretMovedEvent, Event::Object);
1618impl_try_from_event_for_user_facing_type!(
1619	TextCaretMovedEvent,
1620	ObjectEvents::TextCaretMoved,
1621	Event::Object
1622);
1623event_test_cases!(TextCaretMovedEvent);
1624impl_to_dbus_message!(TextCaretMovedEvent);
1625impl_from_dbus_message!(TextCaretMovedEvent);
1626impl_event_properties!(TextCaretMovedEvent);
1627impl From<TextCaretMovedEvent> for EventBodyOwned {
1628	fn from(event: TextCaretMovedEvent) -> Self {
1629		EventBodyOwned {
1630			properties: std::collections::HashMap::new(),
1631			kind: String::default(),
1632			detail1: event.position,
1633			detail2: i32::default(),
1634			any_data: u8::default().into(),
1635		}
1636	}
1637}
1638
1639impl HasRegistryEventString for ObjectEvents {
1640	const REGISTRY_EVENT_STRING: &'static str = "Object:";
1641}