diff --git a/atspi-common/src/events/document.rs b/atspi-common/src/events/document.rs index a94d30ec..627bf8d5 100644 --- a/atspi-common/src/events/document.rs +++ b/atspi-common/src/events/document.rs @@ -149,6 +149,7 @@ impl BusProperties for LoadCompleteEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -168,6 +169,7 @@ impl BusProperties for ReloadEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -187,6 +189,7 @@ impl BusProperties for LoadStoppedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -206,6 +209,7 @@ impl BusProperties for ContentChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -225,6 +229,7 @@ impl BusProperties for AttributesChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -244,6 +249,7 @@ impl BusProperties for PageChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } diff --git a/atspi-common/src/events/focus.rs b/atspi-common/src/events/focus.rs index 01c70b9e..06e724d6 100644 --- a/atspi-common/src/events/focus.rs +++ b/atspi-common/src/events/focus.rs @@ -63,6 +63,7 @@ pub struct FocusEvent { pub item: crate::events::ObjectRef, } +#[cfg(feature = "zbus")] impl BusProperties for FocusEvent { const DBUS_MEMBER: &'static str = "Focus"; const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Focus"; @@ -72,6 +73,7 @@ impl BusProperties for FocusEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } diff --git a/atspi-common/src/events/keyboard.rs b/atspi-common/src/events/keyboard.rs index 3c397182..5b0637dc 100644 --- a/atspi-common/src/events/keyboard.rs +++ b/atspi-common/src/events/keyboard.rs @@ -1,7 +1,10 @@ use crate::{ error::AtspiError, - events::{BusProperties, EventBodyOwned, HasMatchRule, HasRegistryEventString, ObjectRef}, - Event, EventProperties, EventTypeProperties, + events::{ + BusProperties, EventBodyOwned, EventProperties, HasMatchRule, HasRegistryEventString, + ObjectRef, + }, + Event, EventTypeProperties, }; use zbus_names::BusName; use zvariant::{ObjectPath, OwnedValue}; @@ -66,6 +69,7 @@ pub struct ModifiersEvent { pub current_modifiers: i32, } +#[cfg(feature = "zbus")] impl BusProperties for ModifiersEvent { const DBUS_MEMBER: &'static str = "Modifiers"; const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Keyboard"; @@ -75,6 +79,7 @@ impl BusProperties for ModifiersEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body: EventBodyOwned = msg.try_into()?; diff --git a/atspi-common/src/events/mod.rs b/atspi-common/src/events/mod.rs index 2c8b1566..75670816 100644 --- a/atspi-common/src/events/mod.rs +++ b/atspi-common/src/events/mod.rs @@ -431,6 +431,7 @@ impl BusProperties for LegacyAddAccessibleEvent { type Body = LegacyCacheItem; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let body = msg.body(); let node_added: Self::Body = body.deserialize::()?; @@ -472,6 +473,7 @@ impl BusProperties for AddAccessibleEvent { type Body = CacheItem; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let body = msg.body(); let node_added: Self::Body = body.deserialize::()?; @@ -512,6 +514,7 @@ impl_from_user_facing_event_for_interface_event_enum!( impl_from_user_facing_type_for_event_enum!(RemoveAccessibleEvent, Event::Cache); impl_try_from_event_for_user_facing_type!(RemoveAccessibleEvent, CacheEvents::Remove, Event::Cache); event_test_cases!(RemoveAccessibleEvent); + impl BusProperties for RemoveAccessibleEvent { const REGISTRY_EVENT_STRING: &'static str = "Cache:Remove"; const MATCH_RULE_STRING: &'static str = @@ -521,6 +524,7 @@ impl BusProperties for RemoveAccessibleEvent { type Body = ObjectRef; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let body = msg.body(); let node_removed: Self::Body = body.deserialize::()?; @@ -723,6 +727,7 @@ impl BusProperties for EventListenerDeregisteredEvent { type Body = EventListeners; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = msg.try_into()?; let body: Self::Body = msg.body().deserialize::()?; @@ -759,6 +764,7 @@ impl_try_from_event_for_user_facing_type!( Event::Listener ); event_test_cases!(EventListenerRegisteredEvent); + impl BusProperties for EventListenerRegisteredEvent { const REGISTRY_EVENT_STRING: &'static str = "Registry:EventListenerRegistered"; const MATCH_RULE_STRING: &'static str = @@ -768,6 +774,7 @@ impl BusProperties for EventListenerRegisteredEvent { type Body = EventListeners; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = msg.try_into()?; let body: Self::Body = msg.body().deserialize::()?; @@ -805,6 +812,7 @@ impl TryFrom for AvailableEvent { } } event_test_cases!(AvailableEvent); + impl BusProperties for AvailableEvent { const REGISTRY_EVENT_STRING: &'static str = "Socket:Available"; const MATCH_RULE_STRING: &'static str = @@ -814,6 +822,7 @@ impl BusProperties for AvailableEvent { type Body = ObjectRef; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = msg.try_into()?; let body = msg.body(); @@ -997,6 +1006,7 @@ pub trait BusProperties { /// /// When the body type, which is what the raw message looks like over `DBus`, does not match the type that is expected for the given event. /// It is not possible for this to error on most events, but on events whose raw message [`Self::Body`] type contains a [`enum@zvariant::Value`], you may get errors when constructing the structure. + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> std::result::Result where Self: Sized; diff --git a/atspi-common/src/events/mouse.rs b/atspi-common/src/events/mouse.rs index d451bca4..8cc08122 100644 --- a/atspi-common/src/events/mouse.rs +++ b/atspi-common/src/events/mouse.rs @@ -107,6 +107,7 @@ impl BusProperties for AbsEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; @@ -128,6 +129,7 @@ impl BusProperties for RelEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; @@ -149,6 +151,7 @@ impl BusProperties for ButtonEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; diff --git a/atspi-common/src/events/object.rs b/atspi-common/src/events/object.rs index a60090ef..02506a88 100644 --- a/atspi-common/src/events/object.rs +++ b/atspi-common/src/events/object.rs @@ -587,6 +587,7 @@ impl BusProperties for PropertyChangeEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; @@ -609,6 +610,7 @@ impl BusProperties for BoundsChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -628,6 +630,7 @@ impl BusProperties for LinkSelectedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -647,6 +650,7 @@ impl BusProperties for StateChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; @@ -668,6 +672,7 @@ impl BusProperties for ChildrenChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; @@ -695,6 +700,7 @@ impl BusProperties for VisibleDataChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -714,6 +720,7 @@ impl BusProperties for SelectionChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -733,6 +740,7 @@ impl BusProperties for ModelChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -752,6 +760,7 @@ impl BusProperties for ActiveDescendantChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; @@ -773,6 +782,7 @@ impl BusProperties for AnnouncementEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; @@ -798,6 +808,7 @@ impl BusProperties for AttributesChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -816,6 +827,7 @@ impl BusProperties for RowInsertedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -834,6 +846,7 @@ impl BusProperties for RowReorderedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -852,6 +865,7 @@ impl BusProperties for RowDeletedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -870,6 +884,7 @@ impl BusProperties for ColumnInsertedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -888,6 +903,7 @@ impl BusProperties for ColumnReorderedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -906,6 +922,7 @@ impl BusProperties for ColumnDeletedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -925,6 +942,7 @@ impl BusProperties for TextBoundsChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -944,6 +962,7 @@ impl BusProperties for TextSelectionChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -963,6 +982,7 @@ impl BusProperties for TextChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; @@ -990,6 +1010,7 @@ impl BusProperties for TextAttributesChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -1009,6 +1030,7 @@ impl BusProperties for TextCaretMovedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; diff --git a/atspi-common/src/events/terminal.rs b/atspi-common/src/events/terminal.rs index 35e97f34..d7ade031 100644 --- a/atspi-common/src/events/terminal.rs +++ b/atspi-common/src/events/terminal.rs @@ -137,6 +137,7 @@ impl BusProperties for LineChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -155,6 +156,7 @@ impl BusProperties for ColumnCountChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -173,6 +175,7 @@ impl BusProperties for LineCountChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -191,6 +194,7 @@ impl BusProperties for ApplicationChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -209,6 +213,7 @@ impl BusProperties for CharWidthChangedEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } diff --git a/atspi-common/src/events/window.rs b/atspi-common/src/events/window.rs index acd7294d..84685fcd 100644 --- a/atspi-common/src/events/window.rs +++ b/atspi-common/src/events/window.rs @@ -333,6 +333,7 @@ impl BusProperties for PropertyChangeEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { let item = ObjectRef::try_from(msg)?; let body = EventBodyOwned::try_from(msg)?; @@ -354,6 +355,7 @@ impl BusProperties for MinimizeEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -372,6 +374,7 @@ impl BusProperties for MaximizeEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -390,6 +393,7 @@ impl BusProperties for RestoreEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -408,6 +412,7 @@ impl BusProperties for CloseEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -426,6 +431,7 @@ impl BusProperties for CreateEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -444,6 +450,7 @@ impl BusProperties for ReparentEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -462,6 +469,7 @@ impl BusProperties for DesktopCreateEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -480,6 +488,7 @@ impl BusProperties for DesktopDestroyEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -498,6 +507,7 @@ impl BusProperties for DestroyEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -516,6 +526,7 @@ impl BusProperties for ActivateEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -534,6 +545,7 @@ impl BusProperties for DeactivateEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -552,6 +564,7 @@ impl BusProperties for RaiseEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -570,6 +583,7 @@ impl BusProperties for LowerEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -588,6 +602,7 @@ impl BusProperties for MoveEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -606,6 +621,7 @@ impl BusProperties for ResizeEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -624,6 +640,7 @@ impl BusProperties for ShadeEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -642,6 +659,7 @@ impl BusProperties for UUshadeEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } @@ -660,6 +678,7 @@ impl BusProperties for RestyleEvent { type Body = EventBodyOwned; + #[cfg(feature = "zbus")] fn try_from_message(msg: &zbus::Message) -> Result { Ok(Self { item: msg.try_into()? }) } diff --git a/atspi-common/src/lib.rs b/atspi-common/src/lib.rs index 1372a338..72400a59 100644 --- a/atspi-common/src/lib.rs +++ b/atspi-common/src/lib.rs @@ -232,6 +232,7 @@ impl TryFrom for Live { } } +#[cfg(feature = "zbus")] pub trait MessageExt { /// Check if the message matches the event. /// @@ -242,6 +243,7 @@ pub trait MessageExt { fn matches_event(&self) -> crate::Result; } +#[cfg(feature = "zbus")] impl MessageExt for zbus::Message { fn matches_event(&self) -> crate::Result { let event_signature = ::Body::signature(); diff --git a/atspi-common/src/macros.rs b/atspi-common/src/macros.rs index c5fb3015..383760ad 100644 --- a/atspi-common/src/macros.rs +++ b/atspi-common/src/macros.rs @@ -296,6 +296,7 @@ macro_rules! impl_from_dbus_message { #[cfg(test)] macro_rules! generic_event_test_case { ($type:ty) => { + #[cfg(feature = "zbus")] #[test] fn generic_event_uses() { let struct_event = <$type>::default(); @@ -542,6 +543,7 @@ macro_rules! event_wrapper_test_cases { #[rename_item::rename(name($type), prefix = "events_tests_", case = "snake")] mod foo { use super::{$any_subtype, $type, Event, BusProperties}; + #[cfg(feature = "zbus")] #[test] fn into_and_try_from_event() { // Create a default event struct from its type's `Default::default()` impl.