}
}
+//TIZEN_ONLY(20211206) Provide GetActiveWindow
+static void
+handle_activate_window (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+ SpiRegistry *reg = SPI_REGISTRY (user_data);
+
+ const char *sender = dbus_message_get_sender (message);
+ const char *path = dbus_message_get_path (message);
+
+ if (!sender || !path)
+ return;
+
+ char *detail = NULL;
+ dbus_int32_t detail1;
+ DBusMessageIter iter;
+ dbus_message_iter_init (message, &iter);
+ dbus_message_iter_get_basic (&iter, &detail);
+ dbus_message_iter_next (&iter);
+ dbus_message_iter_get_basic (&iter, &detail1);
+
+ if (detail1 & ACCESSIBLE_WINDOW_ACTIVATE_INFO_KEYBOARD)
+ return;
+
+ if (reg->active_window_name)
+ g_free (reg->active_window_name);
+ if (reg->active_window_path)
+ g_free (reg->active_window_path);
+
+ reg->active_window_name = g_strdup(sender);
+ reg->active_window_path = g_strdup(path);
+}
+
+static void
+handle_deactivate_window (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+ SpiRegistry *reg = SPI_REGISTRY (user_data);
+
+ if (!reg->active_window_name || !reg->active_window_path)
+ return;
+
+ const char *sender = dbus_message_get_sender (message);
+ const char *path = dbus_message_get_path (message);
+
+ if (!sender || !path)
+ return;
+
+ if (!g_strcmp0(reg->active_window_name, sender) &&
+ !g_strcmp0(reg->active_window_path, path))
+ {
+ g_free (reg->active_window_name);
+ g_free (reg->active_window_path);
+ reg->active_window_name = NULL;
+ reg->active_window_path = NULL;
+ }
+}
+//
+
/*
* Converts names of the form "active-descendant-changed" to
*" ActiveDescendantChanged"
if (!g_strcmp0(iface, DBUS_INTERFACE_DBUS) &&
!g_strcmp0(member, "NameOwnerChanged"))
handle_disconnection (bus, message, user_data);
+ //TIZEN_ONLY(20211206) Provide GetActiveWindow
+ else if (!g_strcmp0(iface, "org.a11y.atspi.Event.Window"))
+ {
+ if (!g_strcmp0(member, "Activate"))
+ handle_activate_window (bus, message, user_data);
+ else if (!g_strcmp0(member, "Deactivate"))
+ handle_deactivate_window (bus, message, user_data);
+ }
+ //
else
res = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
return reply;
}
+//TIZEN_ONLY(20211206) Provide GetActiveWindow
+static DBusMessage *
+impl_GetActiveWindow (DBusConnection * bus,
+ DBusMessage * message, void *user_data)
+{
+ SpiRegistry *reg = SPI_REGISTRY (user_data);
+ DBusMessage *reply;
+ DBusMessageIter iter;
+
+ reply = dbus_message_new_method_return (message);
+ dbus_message_iter_init_append (reply, &iter);
+
+ if (!reg->active_window_name || !reg->active_window_path)
+ append_reference (&iter, SPI_DBUS_NAME_REGISTRY, SPI_DBUS_PATH_NULL);
+ else
+ append_reference (&iter, reg->active_window_name, reg->active_window_path);
+
+ return reply;
+}
+//
+
static DBusMessage *
impl_GetItems (DBusConnection * bus, DBusMessage * message, void *user_data)
{
dbus_message_iter_init_append (reply, &iter);
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(ss)", &iter_array);
+
+ //TIZEN_ONLY(20211206) Provide GetActiveWindow
+ //we need this part because EFL sends only registered event
+ const char *registry_bus_name = SPI_DBUS_NAME_REGISTRY;
+ const char *window_activate_event = "Window:Activate:";
+ const char *window_deactivate_event = "Window:Deactivate:";
+
+ dbus_message_iter_open_container (&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, ®istry_bus_name);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &window_activate_event);
+ dbus_message_iter_close_container (&iter_array, &iter_struct);
+
+ dbus_message_iter_open_container (&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, ®istry_bus_name);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &window_deactivate_event);
+ dbus_message_iter_close_container (&iter_array, &iter_struct);
+ //
+
for (list = registry->events; list; list = list->next)
{
gchar *str;
reply = impl_Embed (bus, message, user_data);
else if (!strcmp (member, "Unembed"))
reply = impl_Unembed (bus, message, user_data);
+ //TIZEN_ONLY(20211206) Provide GetActiveWindow
+ else if (!strcmp (member, "GetActiveWindow"))
+ reply = impl_GetActiveWindow (bus, message, user_data);
+ //
else
result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
static gchar *app_sig_match_name_owner =
"type='signal', interface='org.freedesktop.DBus', member='NameOwnerChanged'";
+//TIZEN_ONLY(20211206) Provide GetActivateWindow
+static gchar *app_sig_match_window_activate =
+ "type='signal',interface='org.a11y.atspi.Event.Window',member='Activate'";
+static gchar *app_sig_match_window_deactivate =
+ "type='signal',interface='org.a11y.atspi.Event.Window',member='Deactivate'";
+//
+
SpiRegistry *
spi_registry_new (DBusConnection *bus)
{
dbus_bus_add_match (bus, app_sig_match_name_owner, NULL);
dbus_connection_add_filter (bus, signal_filter, reg, NULL);
+ //TIZEN_ONLY(20211206) Provide GetActiveWindow
+ reg->active_window_name = NULL;
+ reg->active_window_path = NULL;
+ dbus_bus_add_match (reg->bus, app_sig_match_window_activate, NULL);
+ dbus_bus_add_match (reg->bus, app_sig_match_window_deactivate, NULL);
+ //
+
dbus_connection_register_object_path (bus, SPI_DBUS_PATH_ROOT, &root_vtable, reg);
dbus_connection_register_object_path (bus, SPI_DBUS_PATH_CACHE, &cache_vtable, reg);
return reg;
}
+//
/*END------------------------------------------------------------------------*/