atspi: reduce DBus signal 'BoundsChanged' 74/256974/5
authorShinwoo Kim <cinoo.kim@samsung.com>
Fri, 16 Apr 2021 00:41:28 +0000 (09:41 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Wed, 28 Apr 2021 02:03:45 +0000 (11:03 +0900)
No AT-client listens the BoundsChanged event,
but there are a large number of 'BoundsChanged' events.
This patch is reducing unnecessary DBus use.

Change-Id: If3aff4b38221156e149b80f35d75e86a037a9c9d

dali/internal/accessibility/bridge/accessibility-common.h
dali/internal/accessibility/bridge/bridge-base.cpp
dali/internal/accessibility/bridge/bridge-base.h
dali/internal/accessibility/bridge/bridge-object.cpp

index cdb92e1..d9165f6 100644 (file)
@@ -34,6 +34,8 @@
 #define A11yDbusPath "/org/a11y/bus"
 #define A11yDbusStatusInterface "org.a11y.Status"
 #define AtspiDbusNameRegistry "org.a11y.atspi.Registry"
+#define AtspiDbusPathRegistry "/org/a11y/atspi/registry"
+#define AtspiDbusInterfaceRegistry "org.a11y.atspi.Registry"
 #define AtspiDbusPathRoot "/org/a11y/atspi/accessible/root"
 #define AtspiDbusInterfaceSocket "org.a11y.atspi.Socket"
 #define AtspiPath "/org/a11y/atspi/accessible"
index 9f1da75..dcca27b 100644 (file)
@@ -88,6 +88,29 @@ bool BridgeBase::tickFilteredEvents()
   return !filteredEvents.empty();
 }
 
+void BridgeBase::RegisteredEventsUpdate()
+{
+  using ReturnType = std::vector<std::tuple<std::string, std::string>>;
+  registry.method<DBus::ValueOrError<ReturnType>()>( "GetRegisteredEvents" ).asyncCall([this](DBus::ValueOrError<ReturnType> msg) {
+    if(!msg)
+    {
+      LOG() << "Get registered events failed";
+      return;
+    }
+
+    allowObjectBoundsChangedEvent = false;
+
+    ReturnType values = std::get<ReturnType>(msg.getValues());
+    for(long unsigned int i = 0; i < values.size(); i++)
+    {
+      if (!std::get<1>(values[i]).compare("Object:BoundsChanged"))
+      {
+        allowObjectBoundsChangedEvent = true;
+      }
+    }
+  });
+}
+
 BridgeBase::ForceUpResult BridgeBase::ForceUp()
 {
   if(Bridge::ForceUp() == ForceUpResult::ALREADY_UP)
@@ -117,12 +140,25 @@ BridgeBase::ForceUpResult BridgeBase::ForceUp()
     dbusServer.addInterface(AtspiPath, desc);
   }
 
+  registry = {AtspiDbusNameRegistry, AtspiDbusPathRegistry, AtspiDbusInterfaceRegistry, con};
+
+  RegisteredEventsUpdate();
+
+  registry.addSignal<void(void)>("EventListenerRegistered", [this](void) {
+    RegisteredEventsUpdate();
+  });
+
+  registry.addSignal<void(void)>("EventListenerDeregistered", [this](void) {
+    RegisteredEventsUpdate();
+  });
+
   return ForceUpResult::JUST_STARTED;
 }
 
 void BridgeBase::ForceDown()
 {
   Bridge::ForceDown();
+  registry   = {};
   dbusServer = {};
   con        = {};
 }
index e14f864..5088ec6 100644 (file)
@@ -275,6 +275,7 @@ protected:
 private:
   void IdSet(int id);
   int  IdGet();
+  void RegisteredEventsUpdate();
 
   using CacheElementType = std::tuple<
     Dali::Accessibility::Address,
@@ -299,6 +300,8 @@ protected:
   DBus::DBusServer           dbusServer;
   DBusWrapper::ConnectionPtr con;
   int                        id = 0;
+  DBus::DBusClient           registry;
+  bool                       allowObjectBoundsChangedEvent;
 };
 
 #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_BASE_H
index e91f2e8..06bb80d 100644 (file)
@@ -496,6 +496,8 @@ void BridgeObject::EmitStateChanged(Accessible* obj, State state, int newValue1,
 
 void BridgeObject::EmitBoundsChanged(Accessible* obj, Dali::Rect<> rect)
 {
+  if(!allowObjectBoundsChangedEvent) return;
+
   auto        addr       = obj->GetAddress();
   const auto  prefixPath = "/org/a11y/atspi/accessible/";
   const auto  nullPath   = "/org/a11y/atspi/null";