return g_strdup(ret);
}
+static void clear(gpointer d)
+{
+ AtspiAccessible **data = d;
+ AtspiAccessible *obj = *data;
+ g_object_unref(obj);
+}
+
static bool is_active_window_object(AtspiAccessible *accessible)
{
- AtspiAccessible *window = atspi_get_active_window();
- if (!window)
+ AtspiAccessible *active_window = atspi_get_active_window();
+ if (!active_window)
return false;
gchar *accessible_bus_name = atspi_accessible_get_bus_name(accessible, NULL);
- gchar *window_bus_name = atspi_accessible_get_bus_name(window, NULL);
-
- bool result = is_same_str(accessible_bus_name, window_bus_name);
-
- g_free(window_bus_name);
+ gchar *active_window_bus_name = atspi_accessible_get_bus_name(active_window, NULL);
+
+ bool result = is_same_str(accessible_bus_name, active_window_bus_name);
+
+ if (!result) {
+ GHashTable *attributes = g_hash_table_new(g_str_hash, g_str_equal);
+ g_hash_table_insert(attributes, "child_bus", accessible_bus_name);
+
+ AtspiMatchRule *rule = atspi_match_rule_new(
+ NULL,
+ ATSPI_Collection_MATCH_INVALID,
+ attributes,
+ ATSPI_Collection_MATCH_ANY,
+ NULL,
+ ATSPI_Collection_MATCH_INVALID,
+ NULL,
+ ATSPI_Collection_MATCH_INVALID,
+ FALSE);
+ AtspiCollection *col_iface = atspi_accessible_get_collection_iface(active_window);
+ GArray *query_result = atspi_collection_get_matches(
+ col_iface,
+ rule,
+ ATSPI_Collection_SORT_ORDER_CANONICAL,
+ 0,
+ TRUE,
+ NULL);
+ g_hash_table_destroy(attributes);
+ g_object_unref(col_iface);
+
+ if (query_result) {
+ result = query_result->len > 0;
+ g_array_set_clear_func(query_result, clear);
+ g_array_free(query_result, TRUE);
+ }
+ g_object_unref(rule);
+ }
+ g_free(active_window_bus_name);
g_free(accessible_bus_name);
- g_object_unref(window);
+ g_object_unref(active_window);
return result;
}