summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wayland
diff options
context:
space:
mode:
authorRafael Antognolli <rafael.antognolli@intel.com>2013-10-28 14:07:25 -0200
committerRafael Antognolli <rafael.antognolli@intel.com>2013-10-28 14:07:25 -0200
commitb87afd1b943b260c92f8493647b7d9cae327656e (patch)
tree9fc02d32a68a31d1d0beb346b93aae649f643a9b /src/lib/ecore_wayland
parente35c7b19fbc98215edf606ce59ceb7f0964cbd36 (diff)
change init done bindings.
Diffstat (limited to 'src/lib/ecore_wayland')
-rw-r--r--src/lib/ecore_wayland/Ecore_Wayland.h6
-rw-r--r--src/lib/ecore_wayland/ecore_wl.c65
2 files changed, 55 insertions, 16 deletions
diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h
index 30545b7343..15c59405e9 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -120,6 +120,8 @@ struct _Ecore_Wl_Display
120 struct wl_list outputs; 120 struct wl_list outputs;
121 struct wl_list globals; /** @since 1.7.6 */ 121 struct wl_list globals; /** @since 1.7.6 */
122 122
123 Eina_Bool init_done;
124
123 struct 125 struct
124 { 126 {
125 struct xkb_context *context; 127 struct xkb_context *context;
@@ -366,6 +368,10 @@ struct _Ecore_Wl_Event_Interfaces_Bound
366 Eina_Bool compositor : 1; 368 Eina_Bool compositor : 1;
367 Eina_Bool shm : 1; 369 Eina_Bool shm : 1;
368 Eina_Bool shell : 1; 370 Eina_Bool shell : 1;
371 Eina_Bool output : 1;
372 Eina_Bool seat : 1;
373 Eina_Bool data_device_manager : 1;
374 Eina_Bool subcompositor : 1;
369}; 375};
370 376
371/** 377/**
diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index ee614e0e4b..8766834e7e 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -22,6 +22,7 @@ static void _ecore_wl_animator_callback(void *data, struct wl_callback *callback
22static Eina_Bool _ecore_wl_animator_window_add(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED); 22static Eina_Bool _ecore_wl_animator_window_add(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED);
23static void _ecore_wl_signal_exit(void); 23static void _ecore_wl_signal_exit(void);
24static void _ecore_wl_signal_exit_free(void *data EINA_UNUSED, void *event); 24static void _ecore_wl_signal_exit_free(void *data EINA_UNUSED, void *event);
25static void _ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED);
25 26
26/* local variables */ 27/* local variables */
27static int _ecore_wl_init_count = 0; 28static int _ecore_wl_init_count = 0;
@@ -40,6 +41,11 @@ static const struct wl_callback_listener _ecore_wl_sync_listener =
40 _ecore_wl_sync_callback 41 _ecore_wl_sync_callback
41}; 42};
42 43
44static const struct wl_callback_listener _ecore_wl_init_sync_listener =
45{
46 _ecore_wl_init_callback
47};
48
43static const struct wl_callback_listener _ecore_wl_anim_listener = 49static const struct wl_callback_listener _ecore_wl_anim_listener =
44{ 50{
45 _ecore_wl_animator_callback 51 _ecore_wl_animator_callback
@@ -66,9 +72,40 @@ EAPI int ECORE_WL_EVENT_SELECTION_DATA_READY = 0;
66EAPI int ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = 0; 72EAPI int ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = 0;
67EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0; 73EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0;
68 74
75static void
76_ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED)
77{
78 Ecore_Wl_Display *ewd = data;
79 Ecore_Wl_Event_Interfaces_Bound *ev;
80
81 wl_callback_destroy(callback);
82 ewd->init_done = EINA_TRUE;
83
84 if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Interfaces_Bound))))
85 return;
86
87 ev->compositor = (ewd->wl.compositor != NULL);
88 ev->shm = (ewd->wl.shm != NULL);
89 ev->shell = (ewd->wl.shell != NULL);
90 ev->output = (ewd->output != NULL);
91 ev->seat = (ewd->input != NULL);
92 ev->data_device_manager = (ewd->wl.data_device_manager != NULL);
93 ev->subcompositor = (ewd->wl.subcompositor != NULL);
94
95 ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL);
96}
97
98static void
99_ecore_wl_init_wait(void)
100{
101 while (!_ecore_wl_disp->init_done)
102 wl_display_dispatch(_ecore_wl_disp->wl.display);
103}
104
69EAPI int 105EAPI int
70ecore_wl_init(const char *name) 106ecore_wl_init(const char *name)
71{ 107{
108 struct wl_callback *callback;
72 LOGFN(__FILE__, __LINE__, __FUNCTION__); 109 LOGFN(__FILE__, __LINE__, __FUNCTION__);
73 110
74 if (++_ecore_wl_init_count != 1) return _ecore_wl_init_count; 111 if (++_ecore_wl_init_count != 1) return _ecore_wl_init_count;
@@ -181,6 +218,10 @@ ecore_wl_init(const char *name)
181 _ecore_wl_window_init(); 218 _ecore_wl_window_init();
182 _ecore_wl_events_init(); 219 _ecore_wl_events_init();
183 220
221 callback = wl_display_sync(_ecore_wl_disp->wl.display);
222 wl_callback_add_listener(callback, &_ecore_wl_init_sync_listener,
223 _ecore_wl_disp);
224
184 return _ecore_wl_init_count; 225 return _ecore_wl_init_count;
185} 226}
186 227
@@ -212,6 +253,9 @@ EAPI struct wl_shm *
212ecore_wl_shm_get(void) 253ecore_wl_shm_get(void)
213{ 254{
214 if (!_ecore_wl_disp) return NULL; 255 if (!_ecore_wl_disp) return NULL;
256
257 _ecore_wl_init_wait();
258
215 return _ecore_wl_disp->wl.shm; 259 return _ecore_wl_disp->wl.shm;
216} 260}
217 261
@@ -228,6 +272,9 @@ ecore_wl_globals_get(void)
228{ 272{
229 if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) 273 if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
230 return NULL; 274 return NULL;
275
276 _ecore_wl_init_wait();
277
231 return &(_ecore_wl_disp->globals); 278 return &(_ecore_wl_disp->globals);
232} 279}
233 280
@@ -236,6 +283,7 @@ ecore_wl_registry_get(void)
236{ 283{
237 if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) 284 if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
238 return NULL; 285 return NULL;
286
239 return _ecore_wl_disp->wl.registry; 287 return _ecore_wl_disp->wl.registry;
240} 288}
241 289
@@ -249,8 +297,7 @@ ecore_wl_screen_size_get(int *w, int *h)
249 297
250 if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) return; 298 if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) return;
251 299
252 if (!_ecore_wl_disp->output) 300 _ecore_wl_init_wait();
253 ecore_wl_sync();
254 301
255 if (!_ecore_wl_disp->output) return; 302 if (!_ecore_wl_disp->output) return;
256 303
@@ -545,20 +592,6 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned in
545 ewd->wl.data_device_manager = 592 ewd->wl.data_device_manager =
546 wl_registry_bind(registry, id, &wl_data_device_manager_interface, 1); 593 wl_registry_bind(registry, id, &wl_data_device_manager_interface, 1);
547 } 594 }
548
549 if ((ewd->wl.compositor) && (ewd->wl.shm) && (ewd->wl.shell))
550 {
551 Ecore_Wl_Event_Interfaces_Bound *ev;
552
553 if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Interfaces_Bound))))
554 return;
555
556 ev->compositor = (ewd->wl.compositor != NULL);
557 ev->shm = (ewd->wl.shm != NULL);
558 ev->shell = (ewd->wl.shell != NULL);
559
560 ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL);
561 }
562} 595}
563 596
564static void 597static void