Package: at-spi2-atk / 2.22.0-2

main_context Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
Index: at-spi2-atk/atk-adaptor/accessible-cache.c
===================================================================
--- at-spi2-atk.orig/atk-adaptor/accessible-cache.c
+++ at-spi2-atk/atk-adaptor/accessible-cache.c
@@ -314,6 +314,9 @@ add_pending_items (gpointer data)
 
 /*---------------------------------------------------------------------------*/
 
+guint
+spi_idle_add(GSourceFunc    function, gpointer       data);
+
 static gboolean
 child_added_listener (GSignalInvocationHint * signal_hint,
                       guint n_param_values,
@@ -358,7 +361,7 @@ child_added_listener (GSignalInvocationH
           g_queue_push_tail (cache->add_traversal, child);
 
           if (cache->add_pending_idle == 0)
-            cache->add_pending_idle = g_idle_add (add_pending_items, cache);
+            cache->add_pending_idle = spi_idle_add (add_pending_items, cache);
         }
 #ifdef SPI_ATK_DEBUG
       recursion_check_unset ();
@@ -400,7 +403,7 @@ toplevel_added_listener (AtkObject * acc
       g_queue_push_tail (cache->add_traversal, child);
 
       if (cache->add_pending_idle == 0)
-        cache->add_pending_idle = g_idle_add (add_pending_items, cache);
+        cache->add_pending_idle = spi_idle_add (add_pending_items, cache);
 #ifdef SPI_ATK_DEBUG
       recursion_check_unset ();
 #endif
Index: at-spi2-atk/atk-adaptor/event.c
===================================================================
--- at-spi2-atk.orig/atk-adaptor/event.c
+++ at-spi2-atk/atk-adaptor/event.c
@@ -42,6 +42,8 @@ static GArray *listener_ids = NULL;
 static gint atk_bridge_key_event_listener_id;
 static gint atk_bridge_focus_tracker_id;
 
+GMainContext *spi_context = NULL;
+
 /*---------------------------------------------------------------------------*/
 
 #define ITF_EVENT_OBJECT   "org.a11y.atspi.Event.Object"
@@ -72,6 +74,34 @@ switch_main_context (GMainContext *cnx)
     atspi_dbus_connection_setup_with_g_main (list->data, cnx);
 }
 
+guint
+spi_idle_add(GSourceFunc    function, gpointer       data)
+{
+  GSource *source;
+  guint id;
+
+  source = g_idle_source_new ();
+  g_source_set_callback (source, function, data, NULL);
+  id = g_source_attach (source, spi_context);
+  g_source_unref (source);
+
+  return id;
+}
+
+guint
+spi_timeout_add_seconds (gint interval, GSourceFunc function, gpointer    data)
+{
+  GSource *source;
+  guint id;
+
+  source = g_timeout_source_new_seconds (interval);
+  g_source_set_callback (source, function, data, NULL);
+  id = g_source_attach (source, spi_context);
+  g_source_unref (source);
+
+  return id;
+}
+
 static void
 set_reply (DBusPendingCall * pending, void *user_data)
 {
@@ -79,7 +109,7 @@ set_reply (DBusPendingCall * pending, vo
 
   closure->reply = dbus_pending_call_steal_reply (pending);
   dbus_pending_call_unref (pending);
-  switch_main_context (NULL);
+  switch_main_context (spi_context);
   g_main_loop_quit (closure->loop);
 }
 
@@ -88,7 +118,7 @@ timeout_reply (void *data)
 {
   SpiReentrantCallClosure *closure = data;
 
-  switch_main_context (NULL);
+  switch_main_context (spi_context);
   g_main_loop_quit (closure->loop);
   closure->timeout = -1;
   return FALSE;
@@ -108,7 +138,7 @@ send_and_allow_reentry (DBusConnection *
 
   if (!dbus_connection_send_with_reply (bus, message, &pending, 9000) || !pending)
     {
-      switch_main_context (NULL);
+      switch_main_context (spi_context);
       return NULL;
     }
   dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
@@ -126,6 +156,13 @@ send_and_allow_reentry (DBusConnection *
   return closure.reply;
 }
 
+void
+atk_bridge_set_event_context(GMainContext *cnx)
+{
+  spi_context = cnx;
+  switch_main_context(spi_context);
+}
+
 /*---------------------------------------------------------------------------*/
 
 /*
Index: at-spi2-atk/atk-adaptor/accessible-leasing.c
===================================================================
--- at-spi2-atk.orig/atk-adaptor/accessible-leasing.c
+++ at-spi2-atk/atk-adaptor/accessible-leasing.c
@@ -25,6 +25,7 @@
 #include <string.h>
 
 #include "accessible-leasing.h"
+#include "event.h"
 
 #ifdef SPI_ATK_DEBUG
 #include "accessible-cache.h"
@@ -161,8 +162,8 @@ add_expiry_timeout (SpiLeasing * leasing
   /* The current time is implicitly rounded down here by ignoring the us */
   g_get_current_time (&t);
   next_expiry = elem->expiry_s - t.tv_sec;
-  leasing->expiry_func_id = g_timeout_add_seconds (next_expiry,
-                                                   expiry_func, leasing);
+  leasing->expiry_func_id = spi_timeout_add_seconds (next_expiry,
+                                                     expiry_func, leasing);
 }
 
 /*---------------------------------------------------------------------------*/
Index: at-spi2-atk/atk-adaptor/event.h
===================================================================
--- at-spi2-atk.orig/atk-adaptor/event.h
+++ at-spi2-atk/atk-adaptor/event.h
@@ -30,4 +30,8 @@ void spi_atk_deregister_event_listeners
 void spi_atk_tidy_windows (void);
 
 gboolean spi_event_is_subtype (gchar **needle, gchar **haystack);
+
+extern GMainContext *spi_context;
+guint spi_idle_add(GSourceFunc    function, gpointer       data);
+guint spi_timeout_add_seconds (gint interval, GSourceFunc function, gpointer    data);
 #endif /* EVENT_H */
Index: at-spi2-atk/atk-adaptor/atkbridge.symbols
===================================================================
--- at-spi2-atk.orig/atk-adaptor/atkbridge.symbols
+++ at-spi2-atk/atk-adaptor/atkbridge.symbols
@@ -1,2 +1,3 @@
 atk_bridge_adaptor_init
 atk_bridge_adaptor_cleanup
+atk_bridge_set_event_context
Index: at-spi2-atk/atk-adaptor/bridge.c
===================================================================
--- at-spi2-atk.orig/atk-adaptor/bridge.c
+++ at-spi2-atk/atk-adaptor/bridge.c
@@ -673,7 +673,7 @@ new_connection_cb (DBusServer *server, D
 {
   dbus_connection_set_unix_user_function (con, user_check, NULL, NULL);
   dbus_connection_ref(con);
-  atspi_dbus_connection_setup_with_g_main(con, NULL);
+  atspi_dbus_connection_setup_with_g_main(con, spi_context);
   droute_intercept_dbus (con);
   droute_context_register (spi_global_app_data->droute, con);
 
@@ -909,7 +909,7 @@ spi_atk_create_socket (SpiBridge *app)
     return -1;
   }
 
-  atspi_dbus_server_setup_with_g_main(server, NULL);
+  atspi_dbus_server_setup_with_g_main(server, spi_context);
   dbus_server_set_new_connection_function(server, new_connection_cb, NULL, NULL);
 
   spi_global_app_data->server = server;
Index: at-spi2-atk/atk-adaptor/atk-bridge.h
===================================================================
--- at-spi2-atk.orig/atk-adaptor/atk-bridge.h
+++ at-spi2-atk/atk-adaptor/atk-bridge.h
@@ -31,6 +31,7 @@ G_BEGIN_DECLS
 
 int atk_bridge_adaptor_init (int * argc, char ** argv[]);
 void atk_bridge_adaptor_cleanup (void);
+void atk_bridge_set_event_context(GMainContext *cnx);
 
 G_END_DECLS