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).



SVN revision: 69032
This commit is contained in:
Christopher Michael 2012-03-07 21:46:52 +00:00
parent 804a3332bf
commit 3e9fe228aa
2 changed files with 59 additions and 16 deletions

View File

@ -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);

View File

@ -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;
}
/* 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");
/* _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);
}