From 7c488fc09b0604e2463681c64df31fb8eede52f2 Mon Sep 17 00:00:00 2001 From: devilhorns Date: Wed, 7 Mar 2012 21:46:52 +0000 Subject: [PATCH] Ecore_Wayland: Don't need to init egl here (just yet). Add an event (interfaces_bound) to be raised when ecore_wayland has everything it needs to function properly. (Used in the e17 wayland only code). git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@69032 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_wayland/Ecore_Wayland.h | 9 +++++ src/lib/ecore_wayland/ecore_wl.c | 68 ++++++++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h index 22608fd..7dab37c 100644 --- a/src/lib/ecore_wayland/Ecore_Wayland.h +++ b/src/lib/ecore_wayland/Ecore_Wayland.h @@ -44,6 +44,7 @@ typedef struct _Ecore_Wl_Event_Dnd_Enter Ecore_Wl_Event_Dnd_Enter; typedef struct _Ecore_Wl_Event_Dnd_Position Ecore_Wl_Event_Dnd_Position; typedef struct _Ecore_Wl_Event_Dnd_Leave Ecore_Wl_Event_Dnd_Leave; typedef struct _Ecore_Wl_Event_Dnd_Drop Ecore_Wl_Event_Dnd_Drop; +typedef struct _Ecore_Wl_Event_Interfaces_Bound Ecore_Wl_Event_Interfaces_Bound; enum _Ecore_Wl_Window_Type { @@ -244,6 +245,13 @@ struct _Ecore_Wl_Event_Dnd_Drop } position; }; +struct _Ecore_Wl_Event_Interfaces_Bound +{ + Eina_Bool compositor : 1; + Eina_Bool shm : 1; + Eina_Bool shell : 1; +}; + /** * @file * @brief Ecore functions for dealing with the Wayland window system @@ -267,6 +275,7 @@ EAPI extern int ECORE_WL_EVENT_DND_ENTER; EAPI extern int ECORE_WL_EVENT_DND_POSITION; EAPI extern int ECORE_WL_EVENT_DND_LEAVE; EAPI extern int ECORE_WL_EVENT_DND_DROP; +EAPI extern int ECORE_WL_EVENT_INTERFACES_BOUND; EAPI int ecore_wl_init(const char *name); EAPI int ecore_wl_shutdown(void); diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c index 724b453..a6d9072 100644 --- a/src/lib/ecore_wayland/ecore_wl.c +++ b/src/lib/ecore_wayland/ecore_wl.c @@ -33,6 +33,7 @@ static Eina_Bool _ecore_wl_egl_init(Ecore_Wl_Display *ewd); static Eina_Bool _ecore_wl_egl_shutdown(Ecore_Wl_Display *ewd); static Eina_Bool _ecore_wl_xkb_init(Ecore_Wl_Display *ewd); static Eina_Bool _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd); +static void _ecore_wl_cb_interfaces_bound_free(void *data __UNUSED__, void *event); /* local variables */ static int _ecore_wl_init_count = 0; @@ -50,6 +51,7 @@ EAPI int ECORE_WL_EVENT_DND_ENTER = 0; EAPI int ECORE_WL_EVENT_DND_POSITION = 0; EAPI int ECORE_WL_EVENT_DND_LEAVE = 0; EAPI int ECORE_WL_EVENT_DND_DROP = 0; +EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0; /** * @defgroup Ecore_Wl_Init_Group Wayland Library Init and Shutdown Functions @@ -115,6 +117,7 @@ ecore_wl_init(const char *name) ECORE_WL_EVENT_DND_POSITION = ecore_event_type_new(); ECORE_WL_EVENT_DND_LEAVE = ecore_event_type_new(); ECORE_WL_EVENT_DND_DROP = ecore_event_type_new(); + ECORE_WL_EVENT_INTERFACES_BOUND = ecore_event_type_new(); } if (!(_ecore_wl_disp = malloc(sizeof(Ecore_Wl_Display)))) @@ -159,22 +162,22 @@ ecore_wl_init(const char *name) /* FIXME: Process connection events ?? */ /* wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE); */ - if (!_ecore_wl_egl_init(_ecore_wl_disp)) - { - ERR("Could not initialize EGL"); - free(_ecore_wl_disp); - eina_log_domain_unregister(_ecore_wl_log_dom); - _ecore_wl_log_dom = -1; - ecore_event_shutdown(); - ecore_shutdown(); - eina_shutdown(); - return --_ecore_wl_init_count; - } - - _ecore_wl_disp->create_image = - (void *)eglGetProcAddress("eglCreateImageKHR"); - _ecore_wl_disp->destroy_image = - (void *)eglGetProcAddress("eglDestroyImageKHR"); + /* if (!_ecore_wl_egl_init(_ecore_wl_disp)) */ + /* { */ + /* ERR("Could not initialize EGL"); */ + /* free(_ecore_wl_disp); */ + /* eina_log_domain_unregister(_ecore_wl_log_dom); */ + /* _ecore_wl_log_dom = -1; */ + /* ecore_event_shutdown(); */ + /* ecore_shutdown(); */ + /* eina_shutdown(); */ + /* return --_ecore_wl_init_count; */ + /* } */ + + /* _ecore_wl_disp->create_image = */ + /* (void *)eglGetProcAddress("eglCreateImageKHR"); */ + /* _ecore_wl_disp->destroy_image = */ + /* (void *)eglGetProcAddress("eglDestroyImageKHR"); */ /* TODO: create pointer surfaces */ @@ -342,7 +345,7 @@ _ecore_wl_shutdown(Eina_Bool close) _ecore_wl_input_del(in); _ecore_wl_xkb_shutdown(_ecore_wl_disp); - _ecore_wl_egl_shutdown(_ecore_wl_disp); + /* _ecore_wl_egl_shutdown(_ecore_wl_disp); */ if (_ecore_wl_disp->wl.shell) wl_shell_destroy(_ecore_wl_disp->wl.shell); @@ -400,7 +403,13 @@ _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char LOGFN(__FILE__, __LINE__, __FUNCTION__); + if ((!strcmp(interface, "wl_display")) || + (!strcmp(interface, "wl_drm")) || + (!strcmp(interface, "desktop_shell"))) + return; + ewd = data; + if (!strcmp(interface, "wl_compositor")) ewd->wl.compositor = wl_display_bind(disp, id, &wl_compositor_interface); else if (!strcmp(interface, "wl_output")) @@ -416,6 +425,21 @@ _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char ewd->wl.data_device_manager = wl_display_bind(disp, id, &wl_data_device_manager_interface); } + + if ((ewd->wl.compositor) && (ewd->wl.shm) && (ewd->wl.shell)) + { + Ecore_Wl_Event_Interfaces_Bound *ev; + + if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Interfaces_Bound)))) + return; + + ev->compositor = (ewd->wl.compositor != NULL); + ev->shm = (ewd->wl.shm != NULL); + ev->shell = (ewd->wl.shell != NULL); + + ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, + _ecore_wl_cb_interfaces_bound_free, NULL); + } } static Eina_Bool @@ -527,3 +551,13 @@ _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd) if (ewd->xkb) xkb_free_keymap(ewd->xkb); return EINA_TRUE; } + +static void +_ecore_wl_cb_interfaces_bound_free(void *data __UNUSED__, void *event) +{ + Ecore_Wl_Event_Interfaces_Bound *ev; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + + if ((ev = event)) free(ev); +} -- 2.7.4