2014-10-14 10:52:26 -07:00
|
|
|
#define E_COMP_WL
|
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
#define COMPOSITOR_VERSION 3
|
|
|
|
|
|
|
|
#define E_COMP_WL_PIXMAP_CHECK \
|
|
|
|
if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) return
|
|
|
|
|
2014-10-14 11:03:15 -07:00
|
|
|
/* local functions */
|
2014-10-14 11:07:38 -07:00
|
|
|
static void
|
|
|
|
_e_comp_wl_log_cb_print(const char *format, va_list args)
|
|
|
|
{
|
|
|
|
INF("WL: ", format, args);
|
|
|
|
}
|
|
|
|
|
2014-10-14 11:03:15 -07:00
|
|
|
static void
|
|
|
|
_e_comp_wl_cb_del(E_Comp *comp)
|
|
|
|
{
|
|
|
|
E_Comp_Data *cdata;
|
|
|
|
|
|
|
|
/* get existing compositor data */
|
|
|
|
if (!(cdata = comp->wl_comp_data)) return;
|
|
|
|
|
|
|
|
/* free allocated data structure */
|
|
|
|
free(cdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_e_comp_wl_compositor_create(void)
|
|
|
|
{
|
|
|
|
E_Comp *comp;
|
2014-10-14 11:12:32 -07:00
|
|
|
const char *name;
|
2014-10-14 11:03:15 -07:00
|
|
|
|
|
|
|
/* check for existing compositor. create if needed */
|
|
|
|
if (!(comp = e_comp_get(NULL)))
|
|
|
|
{
|
|
|
|
comp = e_comp_new();
|
|
|
|
comp->comp_type = E_PIXMAP_TYPE_WL;
|
|
|
|
E_OBJECT_DEL_SET(comp, _e_comp_wl_cb_del);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create new compositor data */
|
|
|
|
cdata = E_NEW(E_Comp_Data, 1);
|
|
|
|
|
2014-10-14 11:07:38 -07:00
|
|
|
/* set wayland log handler */
|
|
|
|
wl_log_set_handler_server(_e_comp_wl_log_cb_print);
|
|
|
|
|
2014-10-14 11:09:58 -07:00
|
|
|
/* try to create a wayland display */
|
|
|
|
if (!(cdata->wl.disp = wl_display_create()))
|
|
|
|
{
|
|
|
|
ERR("Could not create a Wayland display: %m");
|
|
|
|
goto disp_err;
|
|
|
|
}
|
|
|
|
|
2014-10-14 11:12:32 -07:00
|
|
|
/* try to setup wayland socket */
|
|
|
|
if (!(name = wl_display_add_socket_auto(cdata->wl.disp)))
|
|
|
|
{
|
|
|
|
ERR("Could not create Wayland display socket: %m");
|
|
|
|
goto sock_err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set wayland display environment variable */
|
|
|
|
e_env_set("WAYLAND_DISPLAY", name);
|
|
|
|
|
2014-10-14 11:03:15 -07:00
|
|
|
return EINA_TRUE;
|
2014-10-14 11:09:58 -07:00
|
|
|
|
2014-10-14 11:12:32 -07:00
|
|
|
sock_err:
|
|
|
|
wl_display_destroy(cdata->wl.disp);
|
2014-10-14 11:09:58 -07:00
|
|
|
disp_err:
|
|
|
|
free(cdata);
|
|
|
|
return EINA_FALSE;
|
2014-10-14 11:03:15 -07:00
|
|
|
}
|
|
|
|
|
2014-10-14 10:52:26 -07:00
|
|
|
/* public functions */
|
|
|
|
EAPI Eina_Bool
|
|
|
|
e_comp_wl_init(void)
|
|
|
|
{
|
2014-10-14 10:53:25 -07:00
|
|
|
/* set gl available if we have ecore_evas support */
|
|
|
|
if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_WAYLAND_EGL) ||
|
|
|
|
ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_OPENGL_DRM))
|
|
|
|
e_comp_gl_set(EINA_TRUE);
|
|
|
|
|
2014-10-14 11:03:15 -07:00
|
|
|
/* try to create a wayland compositor */
|
|
|
|
if (!_e_comp_wl_compositor_create())
|
|
|
|
{
|
|
|
|
e_error_message_show(_("Enlightenment cannot create a Wayland Compositor!\n"));
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2014-10-14 10:52:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI struct wl_signal
|
|
|
|
e_comp_wl_surface_create_signal_get(E_Comp *comp)
|
|
|
|
{
|
|
|
|
return comp->wl_comp_data->signals.surface.create;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* internal functions */
|
|
|
|
EINTERN void
|
|
|
|
e_comp_wl_shutdown(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EINTERN struct wl_resource *
|
|
|
|
e_comp_wl_surface_create(struct wl_client *client, int version, uint32_t id)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|