summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2017-02-28 12:17:02 -0500
committerChris Michael <cp.michael@samsung.com>2017-02-28 12:17:02 -0500
commitdfb2af6974799ef3b2dcace5e2d30fd69b50edd1 (patch)
tree3926e3f7d971e4ab0b5539e75c4168e629ce323b /src
parent3d81843a3b254c03ecf6e5f40085573f4558403a (diff)
ecore-wl2: Ensure we only bind one wayland shell
This patch adds prioritizing to our wayland shell binding code so that we only bind One shell that the compositor advertises. During the global_add callback, the shells get added to the 'globals' hash, and when sync is done, we will search for shells to bind based on priority so that we can ensure we always bind to the latest supported shell. ref T5226 Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_display.c122
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_private.h1
2 files changed, 93 insertions, 30 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c
index cade757c77..4c6efe3953 100644
--- a/src/lib/ecore_wl2/ecore_wl2_display.c
+++ b/src/lib/ecore_wl2/ecore_wl2_display.c
@@ -152,36 +152,6 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
152 ewd->wl.data_device_manager = 152 ewd->wl.data_device_manager =
153 wl_registry_bind(registry, id, &wl_data_device_manager_interface, ewd->wl.data_device_manager_version); 153 wl_registry_bind(registry, id, &wl_data_device_manager_interface, ewd->wl.data_device_manager_version);
154 } 154 }
155 else if (!strcmp(interface, "wl_shell"))
156 {
157 ewd->wl.wl_shell =
158 wl_registry_bind(registry, id, &wl_shell_interface, 1);
159 }
160 else if ((!strcmp(interface, "xdg_shell")) &&
161 (!getenv("EFL_WAYLAND_DONT_USE_XDG_SHELL")))
162 {
163 Ecore_Wl2_Window *window;
164
165 ewd->wl.xdg_shell =
166 wl_registry_bind(registry, id, &xdg_shell_interface, 1);
167 xdg_shell_use_unstable_version(ewd->wl.xdg_shell,
168 XDG_V5_UNSTABLE_VERSION);
169 xdg_shell_add_listener(ewd->wl.xdg_shell, &_xdg_shell_listener, NULL);
170
171 EINA_INLIST_FOREACH(ewd->windows, window)
172 if ((window->type != ECORE_WL2_WINDOW_TYPE_DND) &&
173 (window->type != ECORE_WL2_WINDOW_TYPE_NONE))
174 _ecore_wl2_window_shell_surface_init(window);
175 else
176 window->pending.configure = EINA_FALSE;
177 }
178 else if (!strcmp(interface, "zxdg_shell_v6"))
179 {
180 ewd->wl.zxdg_shell =
181 wl_registry_bind(registry, id, &zxdg_shell_v6_interface, 1);
182 zxdg_shell_v6_add_listener(ewd->wl.zxdg_shell,
183 &_zxdg_shell_listener, NULL);
184 }
185 else if ((eina_streq(interface, "www")) && 155 else if ((eina_streq(interface, "www")) &&
186 (getenv("EFL_WAYLAND_ENABLE_WWW"))) 156 (getenv("EFL_WAYLAND_ENABLE_WWW")))
187 { 157 {
@@ -431,6 +401,96 @@ err:
431 return ECORE_CALLBACK_RENEW; 401 return ECORE_CALLBACK_RENEW;
432} 402}
433 403
404static Ecore_Wl2_Global *
405_ecore_wl2_global_find(Ecore_Wl2_Display *ewd, const char *interface)
406{
407 Eina_Iterator *itr;
408 Ecore_Wl2_Global *global = NULL;
409 void *data;
410
411 itr = eina_hash_iterator_data_new(ewd->globals);
412 if (!itr) return NULL;
413
414 while (eina_iterator_next(itr, &data))
415 {
416 Ecore_Wl2_Global *g = NULL;
417
418 g = (Ecore_Wl2_Global *)data;
419 if (!g) continue;
420
421 if (!strcmp(g->interface, interface))
422 {
423 global = data;
424 break;
425 }
426 }
427
428 eina_iterator_free(itr);
429 return global;
430}
431
432static void
433_ecore_wl2_shell_bind(Ecore_Wl2_Display *ewd)
434{
435 Ecore_Wl2_Global *global = NULL;
436 const char **itr;
437 const char *shells[] =
438 {
439 "zxdg_shell_v6",
440 "xdg_shell",
441 "wl_shell",
442 NULL
443 };
444
445 if (ewd->shell_done) return;
446
447 for (itr = shells; *itr != NULL; itr++)
448 {
449 global = _ecore_wl2_global_find(ewd, *itr);
450 if (!global) continue;
451 break;
452 }
453
454 if (!global) return;
455
456 else if (!strcmp(global->interface, "wl_shell"))
457 {
458 ewd->wl.wl_shell =
459 wl_registry_bind(ewd->wl.registry, global->id,
460 &wl_shell_interface, 1);
461 ewd->shell_done = EINA_TRUE;
462 }
463 else if ((!strcmp(global->interface, "xdg_shell")) &&
464 (!getenv("EFL_WAYLAND_DONT_USE_XDG_SHELL")))
465 {
466 Ecore_Wl2_Window *window;
467
468 ewd->wl.xdg_shell =
469 wl_registry_bind(ewd->wl.registry, global->id,
470 &xdg_shell_interface, 1);
471 xdg_shell_use_unstable_version(ewd->wl.xdg_shell,
472 XDG_V5_UNSTABLE_VERSION);
473 xdg_shell_add_listener(ewd->wl.xdg_shell, &_xdg_shell_listener, NULL);
474 ewd->shell_done = EINA_TRUE;
475
476 EINA_INLIST_FOREACH(ewd->windows, window)
477 if ((window->type != ECORE_WL2_WINDOW_TYPE_DND) &&
478 (window->type != ECORE_WL2_WINDOW_TYPE_NONE))
479 _ecore_wl2_window_shell_surface_init(window);
480 else
481 window->pending.configure = EINA_FALSE;
482 }
483 else if (!strcmp(global->interface, "zxdg_shell_v6"))
484 {
485 ewd->wl.zxdg_shell =
486 wl_registry_bind(ewd->wl.registry, global->id,
487 &zxdg_shell_v6_interface, 1);
488 zxdg_shell_v6_add_listener(ewd->wl.zxdg_shell,
489 &_zxdg_shell_listener, NULL);
490 ewd->shell_done = EINA_TRUE;
491 }
492}
493
434static void 494static void
435_cb_sync_done(void *data, struct wl_callback *cb, uint32_t serial EINA_UNUSED) 495_cb_sync_done(void *data, struct wl_callback *cb, uint32_t serial EINA_UNUSED)
436{ 496{
@@ -440,6 +500,8 @@ _cb_sync_done(void *data, struct wl_callback *cb, uint32_t serial EINA_UNUSED)
440 ewd = data; 500 ewd = data;
441 ewd->sync_done = EINA_TRUE; 501 ewd->sync_done = EINA_TRUE;
442 502
503 _ecore_wl2_shell_bind(ewd);
504
443 wl_callback_destroy(cb); 505 wl_callback_destroy(cb);
444 506
445 ev = calloc(1, sizeof(Ecore_Wl2_Event_Sync_Done)); 507 ev = calloc(1, sizeof(Ecore_Wl2_Event_Sync_Done));
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h
index c44420ad14..05d42543ee 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -113,6 +113,7 @@ struct _Ecore_Wl2_Display
113 Eina_Inlist *seats; 113 Eina_Inlist *seats;
114 114
115 Eina_Bool sync_done : 1; 115 Eina_Bool sync_done : 1;
116 Eina_Bool shell_done : 1;
116}; 117};
117 118
118struct _Ecore_Wl2_Subsurface 119struct _Ecore_Wl2_Subsurface