2011-12-26 15:27:20 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2012-02-28 13:55:51 -08:00
|
|
|
# include <config.h>
|
2011-12-26 15:27:20 -08:00
|
|
|
#endif
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include "ecore_wl_private.h"
|
2011-12-26 15:27:20 -08:00
|
|
|
|
|
|
|
/* local function prototypes */
|
2012-02-28 13:55:51 -08:00
|
|
|
static Eina_Bool _ecore_wl_shutdown(Eina_Bool close);
|
2012-10-16 04:57:06 -07:00
|
|
|
static Eina_Bool _ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl);
|
|
|
|
static void _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__);
|
2012-02-28 13:55:51 -08:00
|
|
|
static Eina_Bool _ecore_wl_xkb_init(Ecore_Wl_Display *ewd);
|
|
|
|
static Eina_Bool _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
|
|
|
/* local variables */
|
|
|
|
static int _ecore_wl_init_count = 0;
|
2012-10-16 04:57:06 -07:00
|
|
|
static const struct wl_registry_listener _ecore_wl_registry_listener =
|
|
|
|
{
|
|
|
|
_ecore_wl_cb_handle_global,
|
|
|
|
NULL // handle_global_remove
|
|
|
|
};
|
2011-12-26 15:27:20 -08:00
|
|
|
|
|
|
|
/* external variables */
|
|
|
|
int _ecore_wl_log_dom = -1;
|
2012-02-28 13:55:51 -08:00
|
|
|
Ecore_Wl_Display *_ecore_wl_disp = NULL;
|
|
|
|
|
2011-12-26 15:27:20 -08:00
|
|
|
EAPI int ECORE_WL_EVENT_MOUSE_IN = 0;
|
|
|
|
EAPI int ECORE_WL_EVENT_MOUSE_OUT = 0;
|
|
|
|
EAPI int ECORE_WL_EVENT_FOCUS_IN = 0;
|
|
|
|
EAPI int ECORE_WL_EVENT_FOCUS_OUT = 0;
|
2012-02-28 13:55:51 -08:00
|
|
|
EAPI int ECORE_WL_EVENT_WINDOW_CONFIGURE = 0;
|
|
|
|
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;
|
2012-08-28 23:35:02 -07:00
|
|
|
EAPI int ECORE_WL_EVENT_DATA_SOURCE_TARGET = 0;
|
|
|
|
EAPI int ECORE_WL_EVENT_DATA_SOURCE_SEND = 0;
|
|
|
|
EAPI int ECORE_WL_EVENT_SELECTION_DATA_READY = 0;
|
|
|
|
EAPI int ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = 0;
|
2012-03-07 13:46:52 -08:00
|
|
|
EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup Ecore_Wl_Init_Group Wayland Library Init and Shutdown Functions
|
|
|
|
*
|
|
|
|
* Functions that start and shutdown the Ecore Wayland Library.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the Wayland display connection to the given display.
|
|
|
|
*
|
|
|
|
* @param name Display target name. if @c NULL, the default display is
|
|
|
|
* assumed.
|
|
|
|
* @return The number of times the library has been initialized without being
|
|
|
|
* shut down. 0 is returned if an error occurs.
|
|
|
|
*
|
|
|
|
* @ingroup Ecore_Wl_Init_Group
|
|
|
|
*/
|
2011-12-26 15:27:20 -08:00
|
|
|
EAPI int
|
2012-02-28 13:55:51 -08:00
|
|
|
ecore_wl_init(const char *name)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (++_ecore_wl_init_count != 1) return _ecore_wl_init_count;
|
|
|
|
|
2011-12-26 15:27:20 -08:00
|
|
|
if (!eina_init()) return --_ecore_wl_init_count;
|
|
|
|
|
|
|
|
_ecore_wl_log_dom =
|
|
|
|
eina_log_domain_register("ecore_wl", ECORE_WL_DEFAULT_LOG_COLOR);
|
2012-02-28 13:55:51 -08:00
|
|
|
if (_ecore_wl_log_dom < 0)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
EINA_LOG_ERR("Cannot create a log domain for Ecore Wayland");
|
2011-12-26 15:27:20 -08:00
|
|
|
eina_shutdown();
|
|
|
|
return --_ecore_wl_init_count;
|
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!ecore_init())
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
ERR("Could not initialize ecore");
|
2011-12-26 15:27:20 -08:00
|
|
|
eina_log_domain_unregister(_ecore_wl_log_dom);
|
|
|
|
_ecore_wl_log_dom = -1;
|
|
|
|
eina_shutdown();
|
|
|
|
return --_ecore_wl_init_count;
|
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!ecore_event_init())
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
ERR("Could not initialize ecore_event");
|
2011-12-26 15:27:20 -08:00
|
|
|
eina_log_domain_unregister(_ecore_wl_log_dom);
|
|
|
|
_ecore_wl_log_dom = -1;
|
|
|
|
ecore_shutdown();
|
|
|
|
eina_shutdown();
|
|
|
|
return --_ecore_wl_init_count;
|
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!ECORE_WL_EVENT_MOUSE_IN)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
|
|
|
ECORE_WL_EVENT_MOUSE_IN = ecore_event_type_new();
|
|
|
|
ECORE_WL_EVENT_MOUSE_OUT = ecore_event_type_new();
|
|
|
|
ECORE_WL_EVENT_FOCUS_IN = ecore_event_type_new();
|
|
|
|
ECORE_WL_EVENT_FOCUS_OUT = ecore_event_type_new();
|
2012-02-28 13:55:51 -08:00
|
|
|
ECORE_WL_EVENT_WINDOW_CONFIGURE = ecore_event_type_new();
|
|
|
|
ECORE_WL_EVENT_DND_ENTER = ecore_event_type_new();
|
|
|
|
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();
|
2012-08-28 23:35:02 -07:00
|
|
|
ECORE_WL_EVENT_DATA_SOURCE_TARGET = ecore_event_type_new();
|
|
|
|
ECORE_WL_EVENT_DATA_SOURCE_SEND = ecore_event_type_new();
|
|
|
|
ECORE_WL_EVENT_SELECTION_DATA_READY = ecore_event_type_new();
|
|
|
|
ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = ecore_event_type_new();
|
2012-03-07 13:46:52 -08:00
|
|
|
ECORE_WL_EVENT_INTERFACES_BOUND = ecore_event_type_new();
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!(_ecore_wl_disp = malloc(sizeof(Ecore_Wl_Display))))
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
ERR("Could not allocate memory for Ecore_Wl_Display structure");
|
2011-12-26 15:27:20 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
memset(_ecore_wl_disp, 0, sizeof(Ecore_Wl_Display));
|
|
|
|
|
|
|
|
if (!(_ecore_wl_disp->wl.display = wl_display_connect(name)))
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
ERR("Could not connect to Wayland display");
|
2011-12-26 15:27:20 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-10-16 04:57:06 -07:00
|
|
|
_ecore_wl_disp->fd = wl_display_get_fd(_ecore_wl_disp->wl.display);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_disp->fd_hdl =
|
2012-10-16 04:57:06 -07:00
|
|
|
ecore_main_fd_handler_add(_ecore_wl_disp->fd,
|
|
|
|
ECORE_FD_READ | ECORE_FD_WRITE,
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_cb_handle_data, _ecore_wl_disp,
|
|
|
|
NULL, NULL);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
wl_list_init(&_ecore_wl_disp->inputs);
|
|
|
|
wl_list_init(&_ecore_wl_disp->outputs);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-10-16 04:57:06 -07:00
|
|
|
_ecore_wl_disp->wl.registry =
|
|
|
|
wl_display_get_registry(_ecore_wl_disp->wl.display);
|
|
|
|
wl_registry_add_listener(_ecore_wl_disp->wl.registry,
|
|
|
|
&_ecore_wl_registry_listener, _ecore_wl_disp);
|
2012-04-24 09:59:35 -07:00
|
|
|
|
2012-10-16 04:57:06 -07:00
|
|
|
wl_display_dispatch(_ecore_wl_disp->wl.display);
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
/* TODO: create pointer surfaces */
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!_ecore_wl_xkb_init(_ecore_wl_disp))
|
|
|
|
{
|
|
|
|
ERR("Could not initialize XKB");
|
|
|
|
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;
|
|
|
|
}
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_window_init();
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
return _ecore_wl_init_count;
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
/**
|
|
|
|
* Shuts down the Ecore Wayland Library
|
|
|
|
*
|
|
|
|
* In shutting down the library, the Wayland display connection is terminated
|
|
|
|
* and any event handlers for it are removed.
|
|
|
|
*
|
|
|
|
* @return The number of times the library has been initialized without
|
|
|
|
* being shut down.
|
|
|
|
*
|
|
|
|
* @ingroup Ecore_Wl_Init_Group
|
|
|
|
*/
|
|
|
|
EAPI int
|
|
|
|
ecore_wl_shutdown(void)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
return _ecore_wl_shutdown(EINA_TRUE);
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 14:31:27 -08:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_Wl_Flush_Group Wayland Synchronization Functions
|
|
|
|
*
|
|
|
|
* Functions that ensure that all commands which have been issued by the
|
|
|
|
* Ecore Wayland library have been sent to the server.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends all Wayland commands to the Wayland Display.
|
|
|
|
*
|
|
|
|
* @ingroup Ecore_Wl_Flush_Group
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
2011-12-26 15:27:20 -08:00
|
|
|
EAPI void
|
2012-02-28 13:55:51 -08:00
|
|
|
ecore_wl_flush(void)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-03-26 19:13:34 -07:00
|
|
|
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-10-16 04:57:06 -07:00
|
|
|
wl_display_flush(_ecore_wl_disp->wl.display);
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 14:31:27 -08:00
|
|
|
/**
|
|
|
|
* Flushes the command buffer and waits until all requests have been
|
|
|
|
* processed by the server.
|
|
|
|
*
|
|
|
|
* @ingroup Ecore_Wl_Flush_Group
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
2011-12-26 15:27:20 -08:00
|
|
|
EAPI void
|
2012-02-28 13:55:51 -08:00
|
|
|
ecore_wl_sync(void)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-03-28 18:26:30 -07:00
|
|
|
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-03-26 19:13:34 -07:00
|
|
|
wl_display_sync(_ecore_wl_disp->wl.display);
|
2012-01-03 12:37:30 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 14:31:27 -08:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_Wl_Display_Group Wayland Display Functions
|
|
|
|
*
|
|
|
|
* Functions that set and retrieve various information about the Wayland Display.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the Wayland Shm Interface used for the current Wayland connection.
|
|
|
|
*
|
|
|
|
* @return The current wayland shm interface
|
|
|
|
*
|
|
|
|
* @ingroup Ecore_Wl_Display_Group
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
2012-02-28 13:55:51 -08:00
|
|
|
EAPI struct wl_shm *
|
|
|
|
ecore_wl_shm_get(void)
|
2012-01-13 01:33:33 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
return _ecore_wl_disp->wl.shm;
|
2012-01-13 01:33:33 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 14:31:27 -08:00
|
|
|
/**
|
|
|
|
* Retrieves the Wayland Display Interface used for the current Wayland connection.
|
|
|
|
*
|
|
|
|
* @return The current wayland display interface
|
|
|
|
*
|
|
|
|
* @ingroup Ecore_Wl_Display_Group
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
2012-02-28 13:55:51 -08:00
|
|
|
EAPI struct wl_display *
|
|
|
|
ecore_wl_display_get(void)
|
2012-01-13 01:33:33 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
return _ecore_wl_disp->wl.display;
|
2012-01-13 01:33:33 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 14:31:27 -08:00
|
|
|
/**
|
|
|
|
* Retrieves the size of the current screen.
|
|
|
|
*
|
|
|
|
* @param w where to return the width. May be NULL. Returns 0 on error.
|
|
|
|
* @param h where to return the height. May be NULL. Returns 0 on error.
|
|
|
|
*
|
|
|
|
* @ingroup Ecore_Wl_Display_Group
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
2012-01-13 01:33:33 -08:00
|
|
|
EAPI void
|
2012-02-28 13:55:51 -08:00
|
|
|
ecore_wl_screen_size_get(int *w, int *h)
|
2012-01-13 01:33:33 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2012-01-13 01:33:33 -08:00
|
|
|
|
2012-04-17 14:55:25 -07:00
|
|
|
if (w) *w = 0;
|
|
|
|
if (h) *h = 0;
|
|
|
|
|
|
|
|
if (!_ecore_wl_disp->output) return;
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (w) *w = _ecore_wl_disp->output->allocation.w;
|
|
|
|
if (h) *h = _ecore_wl_disp->output->allocation.h;
|
2012-01-13 01:33:33 -08:00
|
|
|
}
|
|
|
|
|
2012-03-01 05:43:41 -08:00
|
|
|
/* @since 1.2 */
|
|
|
|
EAPI void
|
2012-03-05 08:50:20 -08:00
|
|
|
ecore_wl_pointer_xy_get(int *x, int *y)
|
2012-03-01 05:43:41 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-03-05 08:50:20 -08:00
|
|
|
_ecore_wl_input_pointer_xy_get(x, y);
|
2012-03-01 05:43:41 -08:00
|
|
|
}
|
|
|
|
|
2012-03-27 08:15:21 -07:00
|
|
|
/**
|
|
|
|
* Return the screen DPI
|
|
|
|
*
|
|
|
|
* This is a simplistic call to get DPI. It does not account for differing
|
2012-07-05 07:06:20 -07:00
|
|
|
* DPI in the x and y axes nor does it account for multihead or xinerama and
|
|
|
|
* xrandr where different parts of the screen may have different DPI etc.
|
2012-03-27 08:15:21 -07:00
|
|
|
*
|
|
|
|
* @return the general screen DPI (dots/pixels per inch).
|
|
|
|
*
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
2012-03-26 19:13:34 -07:00
|
|
|
EAPI int
|
|
|
|
ecore_wl_dpi_get(void)
|
|
|
|
{
|
|
|
|
int w, mw;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-04-17 14:55:25 -07:00
|
|
|
if (!_ecore_wl_disp->output) return 75;
|
|
|
|
|
2012-03-26 19:13:34 -07:00
|
|
|
mw = _ecore_wl_disp->output->mw;
|
|
|
|
if (mw <= 0) return 75;
|
|
|
|
|
|
|
|
w = _ecore_wl_disp->output->allocation.w;
|
2012-07-05 07:06:20 -07:00
|
|
|
/* FIXME: NB: Hrrrmmm, need to verify this. xorg code is using a different
|
|
|
|
* formula to calc this */
|
2012-03-26 19:13:34 -07:00
|
|
|
return (((w * 254) / mw) + 5) / 10;
|
|
|
|
}
|
|
|
|
|
2012-03-28 18:26:30 -07:00
|
|
|
EAPI void
|
|
|
|
ecore_wl_display_iterate(void)
|
|
|
|
{
|
2012-10-16 04:57:06 -07:00
|
|
|
wl_display_dispatch(_ecore_wl_disp->wl.display);
|
2012-03-28 18:26:30 -07:00
|
|
|
}
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
/**
|
|
|
|
* Retrieves the requested cursor from the cursor theme
|
|
|
|
*
|
|
|
|
* @param cursor_name The desired cursor name to be looked up in the theme
|
|
|
|
* @return the cursor or NULL if the cursor cannot be found
|
|
|
|
*
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
|
|
|
EAPI struct wl_cursor *
|
|
|
|
ecore_wl_cursor_get(const char *cursor_name)
|
|
|
|
{
|
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->cursor_theme))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return wl_cursor_theme_get_cursor(_ecore_wl_disp->cursor_theme,
|
|
|
|
cursor_name);
|
|
|
|
}
|
|
|
|
|
2011-12-26 15:27:20 -08:00
|
|
|
/* local functions */
|
|
|
|
static Eina_Bool
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_shutdown(Eina_Bool close)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (--_ecore_wl_init_count != 0) return _ecore_wl_init_count;
|
2011-12-26 15:27:20 -08:00
|
|
|
if (!_ecore_wl_disp) return _ecore_wl_init_count;
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_window_shutdown();
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (_ecore_wl_disp->fd_hdl)
|
|
|
|
ecore_main_fd_handler_del(_ecore_wl_disp->fd_hdl);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (close)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
Ecore_Wl_Output *out, *tout;
|
|
|
|
Ecore_Wl_Input *in, *tin;
|
|
|
|
|
|
|
|
wl_list_for_each_safe(out, tout, &_ecore_wl_disp->outputs, link)
|
|
|
|
_ecore_wl_output_del(out);
|
|
|
|
|
|
|
|
wl_list_for_each_safe(in, tin, &_ecore_wl_disp->inputs, link)
|
|
|
|
_ecore_wl_input_del(in);
|
|
|
|
|
|
|
|
_ecore_wl_xkb_shutdown(_ecore_wl_disp);
|
|
|
|
|
|
|
|
if (_ecore_wl_disp->wl.shell)
|
|
|
|
wl_shell_destroy(_ecore_wl_disp->wl.shell);
|
|
|
|
if (_ecore_wl_disp->wl.shm) wl_shm_destroy(_ecore_wl_disp->wl.shm);
|
|
|
|
if (_ecore_wl_disp->wl.data_device_manager)
|
|
|
|
wl_data_device_manager_destroy(_ecore_wl_disp->wl.data_device_manager);
|
|
|
|
if (_ecore_wl_disp->wl.compositor)
|
|
|
|
wl_compositor_destroy(_ecore_wl_disp->wl.compositor);
|
|
|
|
if (_ecore_wl_disp->wl.display)
|
2012-01-12 22:34:40 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
wl_display_flush(_ecore_wl_disp->wl.display);
|
2012-03-08 18:36:00 -08:00
|
|
|
wl_display_disconnect(_ecore_wl_disp->wl.display);
|
2012-01-12 22:34:40 -08:00
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
free(_ecore_wl_disp);
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
ecore_event_shutdown();
|
|
|
|
ecore_shutdown();
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
eina_log_domain_unregister(_ecore_wl_log_dom);
|
|
|
|
_ecore_wl_log_dom = -1;
|
2011-12-26 15:27:20 -08:00
|
|
|
eina_shutdown();
|
|
|
|
|
|
|
|
return _ecore_wl_init_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2012-10-16 04:57:06 -07:00
|
|
|
_ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
Ecore_Wl_Display *ewd;
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
/* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!(ewd = data)) return ECORE_CALLBACK_RENEW;
|
2012-10-16 04:57:06 -07:00
|
|
|
|
|
|
|
/* FIXME: This should also catch ECORE_FD_ERROR and exit */
|
|
|
|
|
|
|
|
if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_READ))
|
|
|
|
wl_display_dispatch(ewd->wl.display);
|
|
|
|
else if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_WRITE))
|
|
|
|
wl_display_flush(ewd->wl.display);
|
|
|
|
|
2011-12-26 15:27:20 -08:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-16 04:57:06 -07:00
|
|
|
_ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
Ecore_Wl_Display *ewd;
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-03-26 19:13:34 -07:00
|
|
|
// LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
2012-03-07 13:46:52 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
ewd = data;
|
2012-03-07 13:46:52 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!strcmp(interface, "wl_compositor"))
|
2012-10-16 04:57:06 -07:00
|
|
|
{
|
|
|
|
ewd->wl.compositor =
|
|
|
|
wl_registry_bind(registry, id, &wl_compositor_interface, 1);
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
else if (!strcmp(interface, "wl_output"))
|
|
|
|
_ecore_wl_output_add(ewd, id);
|
2012-05-23 01:01:15 -07:00
|
|
|
else if (!strcmp(interface, "wl_seat"))
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_input_add(ewd, id);
|
|
|
|
else if (!strcmp(interface, "wl_shell"))
|
2012-10-16 04:57:06 -07:00
|
|
|
{
|
|
|
|
ewd->wl.shell =
|
|
|
|
wl_registry_bind(registry, id, &wl_shell_interface, 1);
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
else if (!strcmp(interface, "wl_shm"))
|
2012-06-06 01:18:58 -07:00
|
|
|
{
|
2012-10-16 04:57:06 -07:00
|
|
|
ewd->wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
2012-08-16 02:46:26 -07:00
|
|
|
|
|
|
|
/* FIXME: We should not hard-code a cursor size here, and we should
|
|
|
|
* also import the theme name from a config or env variable */
|
2012-06-06 01:18:58 -07:00
|
|
|
ewd->cursor_theme = wl_cursor_theme_load(NULL, 32, ewd->wl.shm);
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
else if (!strcmp(interface, "wl_data_device_manager"))
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
ewd->wl.data_device_manager =
|
2012-10-16 04:57:06 -07:00
|
|
|
wl_registry_bind(registry, id, &wl_data_device_manager_interface, 1);
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
2012-03-07 13:46:52 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2012-03-08 07:54:21 -08:00
|
|
|
ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL);
|
2012-03-07 13:46:52 -08:00
|
|
|
}
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_ecore_wl_xkb_init(Ecore_Wl_Display *ewd)
|
2012-01-08 03:29:04 -08:00
|
|
|
{
|
2012-02-09 00:15:10 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-05-15 04:58:21 -07:00
|
|
|
if (!(ewd->xkb.context = xkb_context_new(0)))
|
|
|
|
return EINA_FALSE;
|
2012-01-08 03:29:04 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
return EINA_TRUE;
|
2012-01-08 03:29:04 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd)
|
2012-01-08 03:29:04 -08:00
|
|
|
{
|
2012-02-09 00:15:10 -08:00
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-05-15 04:58:21 -07:00
|
|
|
xkb_context_unref(ewd->xkb.context);
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
return EINA_TRUE;
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
2012-08-28 23:35:02 -07:00
|
|
|
|
|
|
|
struct wl_data_source *
|
|
|
|
_ecore_wl_create_data_source(Ecore_Wl_Display *ewd)
|
|
|
|
{
|
|
|
|
return wl_data_device_manager_create_data_source(ewd->wl.data_device_manager);
|
|
|
|
}
|