atspi: add atspi bridge ready event 67/259367/2
authorShinwoo Kim <cinoo.kim@samsung.com>
Fri, 4 Jun 2021 11:20:00 +0000 (20:20 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Mon, 7 Jun 2021 04:27:56 +0000 (04:27 +0000)
Summary:
calling elm_init does not guarantee of readiness of atspi bridge
even though elm_init is calling _elm_atspi_bridge_init.
widget or user could want to know when the atspi bridge is ready.

Reviewers: Hermet, jsuya, herb

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12283

Change-Id: I75f1f45851ec51af07d3f9ba68d69019160ed721

src/lib/elementary/elm_atspi_bridge.c
src/lib/elementary/elm_general.h
src/lib/elementary/elm_main.c

index 3ddae2b..0573cd8 100644 (file)
@@ -172,6 +172,8 @@ static int _init_count = 0;
 static const char *_a11y_socket_address;
 //
 
+EAPI int ELM_EVENT_ATSPI_BRIDGE_STATE_CHANGED = -1;
+
 // Object Event handlers
 static void _state_changed_signal_send(void *data, const Efl_Event *event);
 static void _bounds_changed_signal_send(void *data, const Efl_Event *event);
@@ -6106,6 +6108,7 @@ end:
 static void
 _registered_listeners_get(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
 {
+   Elm_Event_Atspi_Bridge_State_Changed *e;
    const char *event, *bus;
    ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN(data, pd);
    pd->pending_requests = eina_list_remove(pd->pending_requests, pending);
@@ -6156,6 +6159,13 @@ _registered_listeners_get(void *data, const Eldbus_Message *msg, Eldbus_Pending
            _plug_connect(pd->a11y_bus, pr);
 
         pd->socket_queue = pd->plug_queue = NULL;
+
+        e = calloc(1, sizeof(Elm_Event_Atspi_Bridge_State_Changed));
+        if (e)
+          {
+             e->state = ELM_ATSPI_BRIDGE_CONNECTED;
+             ecore_event_add(ELM_EVENT_ATSPI_BRIDGE_STATE_CHANGED, e, NULL, NULL);
+          }
      }
    //
 }
@@ -6847,6 +6857,7 @@ _interfaces_unregister(Eo *bridge)
 static void
 _a11y_connection_shutdown(Eo *bridge)
 {
+   Elm_Event_Atspi_Bridge_State_Changed *e;
    ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN(bridge, pd);
 
    // TIZEN_ONLY(20171109) : fix for invalid proxy object, when at-spi has been restarted
@@ -6901,6 +6912,13 @@ _a11y_connection_shutdown(Eo *bridge)
    pd->event_hdlr = NULL;
 
    efl_event_callback_legacy_call(bridge, ELM_ATSPI_BRIDGE_EVENT_DISCONNECTED, NULL);
+   e = calloc(1, sizeof(Elm_Event_Atspi_Bridge_State_Changed));
+   if (e)
+     {
+        e->state = ELM_ATSPI_BRIDGE_DISCONNECTED;
+        ecore_event_add(ELM_EVENT_ATSPI_BRIDGE_STATE_CHANGED, e, NULL, NULL);
+     }
+
    pd->connected = EINA_FALSE;
 }
 
index 93eed1e..36cbe11 100644 (file)
@@ -491,6 +491,28 @@ typedef enum
   ELM_FOCUS_REGION_SHOW_ITEM /**< As an item. */
 } Elm_Focus_Region_Show_Mode;
 
+/** Possible values for the atspi bridge state.
+ *
+ * @since 1.26
+ *
+ * @ingroup Elm_Atspi_Bridge
+ */
+typedef enum
+{
+  ELM_ATSPI_BRIDGE_CONNECTED = 0, /**< when atspi bridge is ready */
+  ELM_ATSPI_BRIDGE_DISCONNECTED, /**< when atspi bridge is shutdown */
+} Elm_Atspi_Bridge_State;
+
+/** Data on event when atspi bridge state is changed
+ *
+ * @since 1.26
+ *
+ * @ingroup Elm_Atspi_Bridge
+ */
+typedef struct _Elm_Event_Atspi_Bridge_State_Changed
+{
+  Elm_Atspi_Bridge_State state;
+} Elm_Event_Atspi_Bridge_State_Changed;
 
 /**************************************************************************/
 EAPI extern int ELM_ECORE_EVENT_ETHUMB_CONNECT;
@@ -520,6 +542,12 @@ EAPI extern int ELM_EVENT_PROCESS_BACKGROUND;
  */
 EAPI extern int ELM_EVENT_PROCESS_FOREGROUND;
 
+/**
+ * Emitted when atspi bridge state is changed.
+ * @since 1.26
+ */
+EAPI extern int ELM_EVENT_ATSPI_BRIDGE_STATE_CHANGED;
+
 typedef Eina_Bool             (*Elm_Event_Cb)(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info); /**< Function prototype definition for callbacks on input events happening on Elementary widgets. @a data will receive the user data pointer passed to elm_object_event_callback_add(). @a src will be a pointer to the widget on which the input event took place. @a type will get the type of this event and @a event_info, the struct with details on this event. */
 
 EAPI extern double _elm_startup_time;
index 258ffd9..d41cc68 100644 (file)
@@ -454,6 +454,7 @@ elm_init(int argc, char **argv)
    //
 
    ELM_CNP_EVENT_SELECTION_CHANGED = ecore_event_type_new();
+   ELM_EVENT_ATSPI_BRIDGE_STATE_CHANGED = ecore_event_type_new();
 
    //TIZEN_ONLY(20210423): move atspi init to elm_run
    /*