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"
|
2013-11-22 04:39:03 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The subsurface protocol was moved into Wayland Core
|
|
|
|
* around v1.3.90 (i.e. v1.4.0).
|
|
|
|
* Test if subsurface protocol is part of wayland-client.h.
|
|
|
|
* If not, we include our own copy of the protocol header.
|
|
|
|
*/
|
|
|
|
#include <wayland-client.h>
|
|
|
|
#ifndef WL_SUBSURFACE_ERROR_ENUM
|
|
|
|
# include <subsurface-client-protocol.h>
|
|
|
|
#endif
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2014-08-13 07:44:11 -07:00
|
|
|
#include "xdg-shell-client-protocol.h"
|
2015-06-08 07:56:10 -07:00
|
|
|
#define XDG_VERSION 5
|
2014-08-13 07:44:11 -07:00
|
|
|
|
2015-03-20 06:13:59 -07:00
|
|
|
#include "session-recovery-client-protocol.h"
|
|
|
|
|
2011-12-26 15:27:20 -08:00
|
|
|
/* local function prototypes */
|
2014-10-23 07:40:39 -07:00
|
|
|
static int _ecore_wl_shutdown(Eina_Bool close);
|
2012-12-19 05:58:48 -08:00
|
|
|
static Eina_Bool _ecore_wl_cb_idle_enterer(void *data);
|
2012-10-16 04:57:06 -07:00
|
|
|
static Eina_Bool _ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl);
|
2012-11-25 01:55:32 -08:00
|
|
|
static void _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version EINA_UNUSED);
|
2013-06-26 03:52:58 -07:00
|
|
|
static void _ecore_wl_cb_handle_global_remove(void *data, struct wl_registry *registry EINA_UNUSED, unsigned int id);
|
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);
|
2013-04-05 12:31:43 -07:00
|
|
|
static void _ecore_wl_sync_wait(Ecore_Wl_Display *ewd);
|
|
|
|
static void _ecore_wl_sync_callback(void *data, struct wl_callback *callback, uint32_t serial);
|
2013-06-07 07:31:41 -07:00
|
|
|
static void _ecore_wl_animator_tick_cb_begin(void *data EINA_UNUSED);
|
|
|
|
static void _ecore_wl_animator_tick_cb_end(void *data EINA_UNUSED);
|
|
|
|
static void _ecore_wl_animator_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED);
|
|
|
|
static Eina_Bool _ecore_wl_animator_window_add(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED);
|
2013-06-26 03:52:58 -07:00
|
|
|
static void _ecore_wl_signal_exit(void);
|
|
|
|
static void _ecore_wl_signal_exit_free(void *data EINA_UNUSED, void *event);
|
2013-10-28 09:07:25 -07:00
|
|
|
static void _ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
|
|
|
/* local variables */
|
|
|
|
static int _ecore_wl_init_count = 0;
|
2013-06-07 07:31:41 -07:00
|
|
|
static Eina_Bool _ecore_wl_animator_busy = EINA_FALSE;
|
2013-06-26 03:52:58 -07:00
|
|
|
static Eina_Bool _ecore_wl_fatal_error = EINA_FALSE;
|
2015-10-05 13:40:05 -07:00
|
|
|
Eina_Bool _ecore_wl_server_mode = EINA_FALSE;
|
2013-06-07 07:31:41 -07:00
|
|
|
|
2012-12-02 23:37:17 -08:00
|
|
|
static const struct wl_registry_listener _ecore_wl_registry_listener =
|
2012-10-16 04:57:06 -07:00
|
|
|
{
|
|
|
|
_ecore_wl_cb_handle_global,
|
2013-06-26 03:52:58 -07:00
|
|
|
_ecore_wl_cb_handle_global_remove
|
2012-10-16 04:57:06 -07:00
|
|
|
};
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2013-04-05 12:31:43 -07:00
|
|
|
static const struct wl_callback_listener _ecore_wl_sync_listener =
|
|
|
|
{
|
|
|
|
_ecore_wl_sync_callback
|
|
|
|
};
|
|
|
|
|
2013-10-28 09:07:25 -07:00
|
|
|
static const struct wl_callback_listener _ecore_wl_init_sync_listener =
|
|
|
|
{
|
|
|
|
_ecore_wl_init_callback
|
|
|
|
};
|
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
static const struct wl_callback_listener _ecore_wl_anim_listener =
|
2013-06-07 07:31:41 -07:00
|
|
|
{
|
|
|
|
_ecore_wl_animator_callback
|
|
|
|
};
|
|
|
|
|
2015-03-13 18:40:59 -07:00
|
|
|
static void
|
2014-08-13 07:58:56 -07:00
|
|
|
xdg_shell_ping(void *data EINA_UNUSED, struct xdg_shell *shell, uint32_t serial)
|
2014-08-13 07:44:11 -07:00
|
|
|
{
|
|
|
|
xdg_shell_pong(shell, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct xdg_shell_listener xdg_shell_listener =
|
|
|
|
{
|
|
|
|
xdg_shell_ping,
|
|
|
|
};
|
|
|
|
|
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;
|
2013-05-28 03:42:37 -07:00
|
|
|
EAPI int ECORE_WL_EVENT_DND_OFFER = 0;
|
|
|
|
EAPI int ECORE_WL_EVENT_DND_END = 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
|
|
|
|
2013-10-28 09:07:25 -07:00
|
|
|
static void
|
|
|
|
_ecore_wl_init_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ecore_Wl_Display *ewd = data;
|
|
|
|
|
|
|
|
wl_callback_destroy(callback);
|
|
|
|
ewd->init_done = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_wl_init_wait(void)
|
|
|
|
{
|
2015-09-23 06:22:29 -07:00
|
|
|
int ret;
|
2013-10-28 09:07:25 -07:00
|
|
|
while (!_ecore_wl_disp->init_done)
|
2015-09-23 06:22:29 -07:00
|
|
|
{
|
|
|
|
ret = wl_display_dispatch(_ecore_wl_disp->wl.display);
|
|
|
|
if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
|
|
|
|
{
|
|
|
|
/* raise exit signal */
|
|
|
|
ERR("Wayland socket error: %s", strerror(errno));
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-10-28 09:07:25 -07:00
|
|
|
}
|
|
|
|
|
2012-12-02 23:37:17 -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
|
|
|
{
|
2013-10-28 09:07:25 -07:00
|
|
|
struct wl_callback *callback;
|
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;
|
|
|
|
|
2012-12-02 23:37:17 -08:00
|
|
|
_ecore_wl_log_dom =
|
2011-12-26 15:27:20 -08:00
|
|
|
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");
|
2014-09-18 08:03:26 -07:00
|
|
|
goto exit_eina;
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
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");
|
2014-09-18 08:03:26 -07:00
|
|
|
goto exit_ecore;
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
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");
|
2014-09-18 08:03:26 -07:00
|
|
|
goto exit_ecore_event;
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
2017-12-18 18:14:37 -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();
|
|
|
|
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();
|
|
|
|
ECORE_WL_EVENT_DND_OFFER = ecore_event_type_new();
|
|
|
|
ECORE_WL_EVENT_DND_END = ecore_event_type_new();
|
|
|
|
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();
|
|
|
|
ECORE_WL_EVENT_INTERFACES_BOUND = ecore_event_type_new();
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2015-03-17 17:30:32 -07:00
|
|
|
if (!(_ecore_wl_disp = calloc(1, 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");
|
2014-09-18 08:03:26 -07:00
|
|
|
goto exit_ecore_disp;
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
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");
|
2014-09-18 08:03:26 -07:00
|
|
|
goto exit_ecore_disp_connect;
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
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-12-02 23:37:17 -08:00
|
|
|
_ecore_wl_disp->fd_hdl =
|
2015-03-13 18:40:59 -07:00
|
|
|
ecore_main_fd_handler_add(_ecore_wl_disp->fd,
|
2014-08-13 07:49:35 -07:00
|
|
|
ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
|
2012-12-02 23:37:17 -08:00
|
|
|
_ecore_wl_cb_handle_data, _ecore_wl_disp,
|
2012-02-28 13:55:51 -08:00
|
|
|
NULL, NULL);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-12-19 05:58:48 -08:00
|
|
|
_ecore_wl_disp->idle_enterer =
|
|
|
|
ecore_idle_enterer_add(_ecore_wl_cb_idle_enterer, _ecore_wl_disp);
|
|
|
|
|
2012-12-02 23:37:17 -08:00
|
|
|
_ecore_wl_disp->wl.registry =
|
2012-10-16 04:57:06 -07:00
|
|
|
wl_display_get_registry(_ecore_wl_disp->wl.display);
|
2012-12-02 23:37:17 -08:00
|
|
|
wl_registry_add_listener(_ecore_wl_disp->wl.registry,
|
2012-10-16 04:57:06 -07:00
|
|
|
&_ecore_wl_registry_listener, _ecore_wl_disp);
|
2012-04-24 09:59:35 -07:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!_ecore_wl_xkb_init(_ecore_wl_disp))
|
|
|
|
{
|
|
|
|
ERR("Could not initialize XKB");
|
2014-09-18 08:03:26 -07:00
|
|
|
goto exit_ecore_disp_connect;
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_window_init();
|
2013-04-10 10:45:12 -07:00
|
|
|
_ecore_wl_events_init();
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2014-03-18 00:39:44 -07:00
|
|
|
_ecore_wl_disp->init_done = EINA_TRUE;
|
|
|
|
if (!_ecore_wl_server_mode)
|
|
|
|
{
|
|
|
|
_ecore_wl_disp->init_done = EINA_FALSE;
|
|
|
|
callback = wl_display_sync(_ecore_wl_disp->wl.display);
|
|
|
|
wl_callback_add_listener(callback, &_ecore_wl_init_sync_listener,
|
|
|
|
_ecore_wl_disp);
|
|
|
|
}
|
2013-10-28 09:07:25 -07:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
return _ecore_wl_init_count;
|
2014-09-18 08:03:26 -07:00
|
|
|
|
|
|
|
exit_ecore_disp_connect:
|
|
|
|
free(_ecore_wl_disp);
|
|
|
|
|
|
|
|
exit_ecore_disp:
|
|
|
|
ecore_event_shutdown();
|
|
|
|
|
|
|
|
exit_ecore_event:
|
|
|
|
ecore_shutdown();
|
|
|
|
|
|
|
|
exit_ecore:
|
|
|
|
eina_log_domain_unregister(_ecore_wl_log_dom);
|
|
|
|
_ecore_wl_log_dom = -1;
|
|
|
|
|
|
|
|
exit_eina:
|
|
|
|
eina_shutdown();
|
|
|
|
return --_ecore_wl_init_count;
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
2012-12-02 23:37:17 -08:00
|
|
|
EAPI int
|
2012-02-28 13:55:51 -08:00
|
|
|
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-12-02 23:37:17 -08:00
|
|
|
EAPI void
|
2012-02-28 13:55:51 -08:00
|
|
|
ecore_wl_flush(void)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2013-07-23 23:15:44 -07:00
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) return;
|
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-12-02 23:37:17 -08:00
|
|
|
EAPI void
|
2012-02-28 13:55:51 -08:00
|
|
|
ecore_wl_sync(void)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2015-09-23 06:22:29 -07:00
|
|
|
int ret;
|
2013-07-23 23:15:44 -07:00
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) return;
|
2013-04-05 12:31:43 -07:00
|
|
|
_ecore_wl_sync_wait(_ecore_wl_disp);
|
|
|
|
while (_ecore_wl_disp->sync_ref_count > 0)
|
2015-09-23 06:22:29 -07:00
|
|
|
{
|
|
|
|
ret = wl_display_dispatch(_ecore_wl_disp->wl.display);
|
|
|
|
if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
|
|
|
|
{
|
|
|
|
/* raise exit signal */
|
|
|
|
ERR("Wayland socket error: %s", strerror(errno));
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-03 12:37:30 -08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2013-07-23 23:15:44 -07:00
|
|
|
if (!_ecore_wl_disp) return NULL;
|
2013-10-28 09:07:25 -07:00
|
|
|
|
|
|
|
_ecore_wl_init_wait();
|
|
|
|
|
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 13:55:51 -08:00
|
|
|
EAPI struct wl_display *
|
|
|
|
ecore_wl_display_get(void)
|
2012-01-13 01:33:33 -08:00
|
|
|
{
|
2013-11-22 04:39:03 -08:00
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
|
2013-07-23 23:15:44 -07:00
|
|
|
return NULL;
|
2012-02-28 13:55:51 -08:00
|
|
|
return _ecore_wl_disp->wl.display;
|
2012-01-13 01:33:33 -08:00
|
|
|
}
|
|
|
|
|
2013-11-04 07:48:57 -08:00
|
|
|
EAPI Eina_Inlist *
|
2013-02-05 08:53:31 -08:00
|
|
|
ecore_wl_globals_get(void)
|
|
|
|
{
|
2013-11-22 04:39:03 -08:00
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
|
2013-07-23 23:15:44 -07:00
|
|
|
return NULL;
|
2013-10-28 09:07:25 -07:00
|
|
|
|
|
|
|
_ecore_wl_init_wait();
|
|
|
|
|
2013-11-04 07:48:57 -08:00
|
|
|
return _ecore_wl_disp->globals;
|
2013-02-05 08:53:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI struct wl_registry *
|
|
|
|
ecore_wl_registry_get(void)
|
|
|
|
{
|
2013-11-22 04:39:03 -08:00
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
|
2013-07-23 23:15:44 -07:00
|
|
|
return NULL;
|
2013-02-05 08:53:31 -08:00
|
|
|
return _ecore_wl_disp->wl.registry;
|
|
|
|
}
|
|
|
|
|
2013-10-29 13:40:33 -07:00
|
|
|
struct wl_compositor *
|
2013-10-29 14:32:00 -07:00
|
|
|
_ecore_wl_compositor_get(void)
|
2013-10-29 13:40:33 -07:00
|
|
|
{
|
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
_ecore_wl_init_wait();
|
|
|
|
|
|
|
|
return _ecore_wl_disp->wl.compositor;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wl_subcompositor *
|
2013-10-29 14:32:00 -07:00
|
|
|
_ecore_wl_subcompositor_get(void)
|
2013-10-29 13:40:33 -07:00
|
|
|
{
|
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
_ecore_wl_init_wait();
|
|
|
|
|
|
|
|
return _ecore_wl_disp->wl.subcompositor;
|
|
|
|
}
|
|
|
|
|
2012-12-02 23:37:17 -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
|
|
|
{
|
2014-08-26 08:08:38 -07:00
|
|
|
Ecore_Wl_Output *out;
|
|
|
|
Eina_Inlist *tmp;
|
|
|
|
int ow = 0, oh = 0;
|
|
|
|
|
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;
|
|
|
|
|
2013-07-23 23:15:44 -07:00
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) return;
|
|
|
|
|
2013-10-28 09:07:25 -07:00
|
|
|
_ecore_wl_init_wait();
|
2013-04-05 13:26:00 -07:00
|
|
|
|
2014-08-26 03:26:19 -07:00
|
|
|
// the first sync is in case registry replies are not back yet
|
|
|
|
if (!_ecore_wl_disp->output)
|
|
|
|
{
|
|
|
|
// second sync is in case bound object replies in registry are not back
|
|
|
|
ecore_wl_sync();
|
|
|
|
if (!_ecore_wl_disp->output) ecore_wl_sync();
|
|
|
|
}
|
|
|
|
|
2014-08-26 08:08:38 -07:00
|
|
|
EINA_INLIST_FOREACH_SAFE(_ecore_wl_disp->outputs, tmp, out)
|
2013-04-02 13:11:10 -07:00
|
|
|
{
|
2014-08-26 08:08:38 -07:00
|
|
|
switch (out->transform)
|
|
|
|
{
|
|
|
|
case WL_OUTPUT_TRANSFORM_90:
|
|
|
|
case WL_OUTPUT_TRANSFORM_270:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
|
|
|
/* Swap width and height */
|
|
|
|
ow += out->allocation.h;
|
|
|
|
oh += out->allocation.w;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ow += out->allocation.w;
|
|
|
|
oh += out->allocation.h;
|
|
|
|
}
|
2013-04-02 13:11:10 -07:00
|
|
|
}
|
2014-08-26 08:08:38 -07:00
|
|
|
|
|
|
|
if (w) *w = ow;
|
|
|
|
if (h) *h = oh;
|
2012-01-13 01:33:33 -08:00
|
|
|
}
|
|
|
|
|
2012-03-01 05:43:41 -08:00
|
|
|
/* @since 1.2 */
|
2012-12-02 23:37:17 -08:00
|
|
|
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-12-02 23:37:17 -08:00
|
|
|
EAPI int
|
2012-03-26 19:13:34 -07:00
|
|
|
ecore_wl_dpi_get(void)
|
|
|
|
{
|
|
|
|
int w, mw;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2013-07-23 23:15:44 -07:00
|
|
|
if (!_ecore_wl_disp) return 0;
|
2015-05-11 06:27:13 -07:00
|
|
|
|
|
|
|
_ecore_wl_init_wait();
|
|
|
|
|
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-12-02 23:37:17 -08:00
|
|
|
/* FIXME: NB: Hrrrmmm, need to verify this. xorg code is using a different
|
2012-07-05 07:06:20 -07:00
|
|
|
* formula to calc this */
|
2012-03-26 19:13:34 -07:00
|
|
|
return (((w * 254) / mw) + 5) / 10;
|
|
|
|
}
|
|
|
|
|
2012-12-02 23:37:17 -08:00
|
|
|
EAPI void
|
2012-03-28 18:26:30 -07:00
|
|
|
ecore_wl_display_iterate(void)
|
|
|
|
{
|
2015-09-23 06:22:29 -07:00
|
|
|
int ret;
|
2013-07-23 23:15:44 -07:00
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->wl.display)) return;
|
2013-07-18 03:03:53 -07:00
|
|
|
if (!_ecore_wl_server_mode)
|
2015-09-23 06:22:29 -07:00
|
|
|
{
|
|
|
|
ret = wl_display_dispatch(_ecore_wl_disp->wl.display);
|
|
|
|
if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
|
|
|
|
{
|
|
|
|
/* raise exit signal */
|
|
|
|
ERR("Wayland socket error: %s", strerror(errno));
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
2012-03-28 18:26:30 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 07:31:41 -07:00
|
|
|
/* @since 1.8 */
|
2013-11-22 04:39:03 -08:00
|
|
|
EAPI Eina_Bool
|
2013-06-07 07:31:41 -07:00
|
|
|
ecore_wl_animator_source_set(Ecore_Animator_Source source)
|
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2015-10-05 13:11:52 -07:00
|
|
|
if (_ecore_wl_server_mode) return EINA_FALSE;
|
|
|
|
|
2013-06-07 07:31:41 -07:00
|
|
|
/* FIXME: check existing source. If custom, disable anim_callbacks */
|
|
|
|
|
|
|
|
/* based on the animator source we are using, setup or destroy callbacks */
|
|
|
|
switch (source)
|
|
|
|
{
|
|
|
|
case ECORE_ANIMATOR_SOURCE_CUSTOM:
|
|
|
|
ecore_animator_custom_source_tick_begin_callback_set
|
|
|
|
(_ecore_wl_animator_tick_cb_begin, NULL);
|
|
|
|
ecore_animator_custom_source_tick_end_callback_set
|
|
|
|
(_ecore_wl_animator_tick_cb_end, NULL);
|
|
|
|
break;
|
|
|
|
case ECORE_ANIMATOR_SOURCE_TIMER:
|
|
|
|
ecore_animator_custom_source_tick_begin_callback_set(NULL, NULL);
|
|
|
|
ecore_animator_custom_source_tick_end_callback_set(NULL, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the source of the animator */
|
|
|
|
ecore_animator_source_set(source);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
EAPI struct wl_cursor *
|
|
|
|
ecore_wl_cursor_get(const char *cursor_name)
|
|
|
|
{
|
2012-12-02 23:37:17 -08:00
|
|
|
if ((!_ecore_wl_disp) || (!_ecore_wl_disp->cursor_theme))
|
2012-06-06 01:18:58 -07:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return wl_cursor_theme_get_cursor(_ecore_wl_disp->cursor_theme,
|
|
|
|
cursor_name);
|
|
|
|
}
|
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
EAPI void
|
2013-07-18 03:03:53 -07:00
|
|
|
ecore_wl_server_mode_set(Eina_Bool on)
|
|
|
|
{
|
|
|
|
_ecore_wl_server_mode = on;
|
|
|
|
}
|
|
|
|
|
2011-12-26 15:27:20 -08:00
|
|
|
/* local functions */
|
2014-10-23 07:40:39 -07:00
|
|
|
static int
|
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__);
|
|
|
|
|
2014-10-23 07:33:40 -07:00
|
|
|
if (_ecore_wl_init_count < 1)
|
|
|
|
{
|
|
|
|
ERR("Ecore_Wayland Shutdown called without Ecore_Wayland Init");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2017-03-09 16:13:56 -08:00
|
|
|
ecore_event_type_flush(ECORE_WL_EVENT_MOUSE_IN,
|
|
|
|
ECORE_WL_EVENT_MOUSE_OUT,
|
|
|
|
ECORE_WL_EVENT_FOCUS_IN,
|
|
|
|
ECORE_WL_EVENT_FOCUS_OUT,
|
|
|
|
ECORE_WL_EVENT_WINDOW_CONFIGURE,
|
|
|
|
ECORE_WL_EVENT_DND_ENTER,
|
|
|
|
ECORE_WL_EVENT_DND_POSITION,
|
|
|
|
ECORE_WL_EVENT_DND_LEAVE,
|
|
|
|
ECORE_WL_EVENT_DND_DROP,
|
|
|
|
ECORE_WL_EVENT_DND_OFFER,
|
|
|
|
ECORE_WL_EVENT_DND_END,
|
|
|
|
ECORE_WL_EVENT_DATA_SOURCE_TARGET,
|
|
|
|
ECORE_WL_EVENT_DATA_SOURCE_SEND,
|
|
|
|
ECORE_WL_EVENT_SELECTION_DATA_READY,
|
|
|
|
ECORE_WL_EVENT_DATA_SOURCE_CANCELLED,
|
|
|
|
ECORE_WL_EVENT_INTERFACES_BOUND);
|
|
|
|
|
2013-04-10 10:45:12 -07:00
|
|
|
_ecore_wl_events_shutdown();
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_window_shutdown();
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-12-02 23:37:17 -08:00
|
|
|
if (_ecore_wl_disp->fd_hdl)
|
2012-02-28 13:55:51 -08:00
|
|
|
ecore_main_fd_handler_del(_ecore_wl_disp->fd_hdl);
|
2012-12-19 05:58:48 -08:00
|
|
|
if (_ecore_wl_disp->idle_enterer)
|
|
|
|
ecore_idle_enterer_del(_ecore_wl_disp->idle_enterer);
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2013-06-26 03:52:58 -07:00
|
|
|
if ((close) && (!_ecore_wl_fatal_error))
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2013-11-04 08:18:39 -08:00
|
|
|
Ecore_Wl_Output *out;
|
2013-11-04 08:24:59 -08:00
|
|
|
Ecore_Wl_Input *in;
|
2013-11-04 07:48:57 -08:00
|
|
|
Ecore_Wl_Global *global;
|
|
|
|
Eina_Inlist *tmp;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2013-11-04 08:18:39 -08:00
|
|
|
EINA_INLIST_FOREACH_SAFE(_ecore_wl_disp->outputs, tmp, out)
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_output_del(out);
|
|
|
|
|
2013-11-04 08:24:59 -08:00
|
|
|
EINA_INLIST_FOREACH_SAFE(_ecore_wl_disp->inputs, tmp, in)
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_input_del(in);
|
|
|
|
|
2013-11-04 07:48:57 -08:00
|
|
|
EINA_INLIST_FOREACH_SAFE(_ecore_wl_disp->globals, tmp, global)
|
2014-08-26 08:01:22 -07:00
|
|
|
{
|
2015-03-13 18:40:59 -07:00
|
|
|
_ecore_wl_disp->globals =
|
|
|
|
eina_inlist_remove(_ecore_wl_disp->globals,
|
2014-08-13 07:49:35 -07:00
|
|
|
EINA_INLIST_GET(global));
|
2014-08-26 08:01:22 -07:00
|
|
|
free(global->interface);
|
|
|
|
free(global);
|
|
|
|
}
|
2013-01-24 14:03:22 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_xkb_shutdown(_ecore_wl_disp);
|
|
|
|
|
2015-08-25 05:31:09 -07:00
|
|
|
if (_ecore_wl_disp->wl.session_recovery)
|
2015-12-18 05:51:04 -08:00
|
|
|
zwp_e_session_recovery_destroy(_ecore_wl_disp->wl.session_recovery);
|
2014-08-25 05:44:10 -07:00
|
|
|
#ifdef USE_IVI_SHELL
|
|
|
|
if (_ecore_wl_disp->wl.ivi_application)
|
|
|
|
ivi_application_destroy(_ecore_wl_disp->wl.ivi_application);
|
|
|
|
#endif
|
2014-08-13 07:44:11 -07:00
|
|
|
if (_ecore_wl_disp->wl.xdg_shell)
|
|
|
|
xdg_shell_destroy(_ecore_wl_disp->wl.xdg_shell);
|
2012-12-02 23:37:17 -08:00
|
|
|
if (_ecore_wl_disp->wl.shell)
|
2012-02-28 13:55:51 -08:00
|
|
|
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);
|
2013-10-11 01:41:22 -07:00
|
|
|
if (_ecore_wl_disp->wl.subcompositor)
|
|
|
|
wl_subcompositor_destroy(_ecore_wl_disp->wl.subcompositor);
|
2015-10-20 14:51:22 -07:00
|
|
|
if (_ecore_wl_disp->cursor_theme)
|
|
|
|
wl_cursor_theme_destroy(_ecore_wl_disp->cursor_theme);
|
2012-02-28 13:55:51 -08:00
|
|
|
if (_ecore_wl_disp->wl.display)
|
2012-01-12 22:34:40 -08:00
|
|
|
{
|
2012-11-23 10:44:00 -08:00
|
|
|
wl_registry_destroy(_ecore_wl_disp->wl.registry);
|
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;
|
|
|
|
}
|
|
|
|
|
2012-12-19 05:58:48 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_ecore_wl_cb_idle_enterer(void *data)
|
|
|
|
{
|
|
|
|
Ecore_Wl_Display *ewd;
|
2013-06-26 03:52:58 -07:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (_ecore_wl_fatal_error) return ECORE_CALLBACK_CANCEL;
|
2012-12-19 05:58:48 -08:00
|
|
|
|
|
|
|
if (!(ewd = data)) return ECORE_CALLBACK_RENEW;
|
|
|
|
|
2013-06-26 03:52:58 -07:00
|
|
|
ret = wl_display_get_error(ewd->wl.display);
|
|
|
|
if (ret < 0) goto err;
|
|
|
|
|
2015-06-23 08:00:07 -07:00
|
|
|
ret = wl_display_dispatch_pending(ewd->wl.display);
|
|
|
|
if (ret < 0) goto err;
|
|
|
|
|
2012-12-19 05:58:48 -08:00
|
|
|
ret = wl_display_flush(ewd->wl.display);
|
2012-12-19 05:58:52 -08:00
|
|
|
if ((ret < 0) && (errno == EAGAIN))
|
2013-11-22 04:39:03 -08:00
|
|
|
ecore_main_fd_handler_active_set(ewd->fd_hdl,
|
2013-03-05 03:53:23 -08:00
|
|
|
(ECORE_FD_READ | ECORE_FD_WRITE));
|
2013-06-26 03:52:58 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
|
|
|
|
err:
|
|
|
|
if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
|
2012-12-19 05:58:48 -08:00
|
|
|
{
|
2013-06-26 03:52:58 -07:00
|
|
|
_ecore_wl_fatal_error = EINA_TRUE;
|
|
|
|
|
|
|
|
/* raise exit signal */
|
2015-03-12 11:33:45 -07:00
|
|
|
ERR("Wayland socket error: %s", strerror(errno));
|
2013-06-26 03:52:58 -07:00
|
|
|
_ecore_wl_signal_exit();
|
2013-07-09 03:11:14 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2012-12-19 05:58:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2012-12-02 23:37:17 -08:00
|
|
|
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;
|
2013-06-26 03:52:58 -07:00
|
|
|
int ret = 0;
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2013-06-17 15:19:41 -07:00
|
|
|
/* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2013-06-26 03:52:58 -07:00
|
|
|
if (_ecore_wl_fatal_error) return ECORE_CALLBACK_CANCEL;
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!(ewd = data)) return ECORE_CALLBACK_RENEW;
|
2012-10-16 04:57:06 -07:00
|
|
|
|
2014-04-17 07:16:57 -07:00
|
|
|
if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_ERROR))
|
|
|
|
{
|
|
|
|
ERR("Received error on wayland display fd");
|
|
|
|
_ecore_wl_fatal_error = EINA_TRUE;
|
|
|
|
_ecore_wl_signal_exit();
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
2012-10-16 04:57:06 -07:00
|
|
|
|
2012-10-16 04:57:22 -07:00
|
|
|
/* wl_display_dispatch_pending(ewd->wl.display); */
|
|
|
|
|
2012-10-16 04:57:06 -07:00
|
|
|
if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_READ))
|
2013-06-26 03:52:58 -07:00
|
|
|
ret = wl_display_dispatch(ewd->wl.display);
|
2012-10-16 04:57:06 -07:00
|
|
|
else if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_WRITE))
|
2012-12-19 05:58:48 -08:00
|
|
|
{
|
|
|
|
ret = wl_display_flush(ewd->wl.display);
|
|
|
|
if (ret == 0)
|
|
|
|
ecore_main_fd_handler_active_set(hdl, ECORE_FD_READ);
|
2013-06-26 03:52:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
|
|
|
|
{
|
|
|
|
_ecore_wl_fatal_error = EINA_TRUE;
|
|
|
|
|
|
|
|
/* raise exit signal */
|
|
|
|
_ecore_wl_signal_exit();
|
2013-07-09 03:11:14 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2012-12-19 05:58:48 -08:00
|
|
|
}
|
2012-10-16 04:57:06 -07:00
|
|
|
|
2011-12-26 15:27:20 -08:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2012-12-02 23:37:17 -08:00
|
|
|
static void
|
2015-07-08 08:01:13 -07:00
|
|
|
_ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version)
|
2011-12-26 15:27:20 -08:00
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
Ecore_Wl_Display *ewd;
|
2013-01-24 14:03:22 -08:00
|
|
|
Ecore_Wl_Global *global;
|
2011-12-26 15:27:20 -08:00
|
|
|
|
2012-10-16 04:57:22 -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
|
|
|
|
2014-08-13 07:50:04 -07:00
|
|
|
if (!(global = calloc(1, sizeof(Ecore_Wl_Global)))) return;
|
2013-02-05 08:53:31 -08:00
|
|
|
|
2013-01-24 14:03:22 -08:00
|
|
|
global->id = id;
|
|
|
|
global->interface = strdup(interface);
|
|
|
|
global->version = version;
|
2013-11-04 07:48:57 -08:00
|
|
|
ewd->globals = eina_inlist_append(ewd->globals, EINA_INLIST_GET(global));
|
2013-01-24 14:03:22 -08:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!strcmp(interface, "wl_compositor"))
|
2012-10-16 04:57:06 -07:00
|
|
|
{
|
2012-12-02 23:37:17 -08:00
|
|
|
ewd->wl.compositor =
|
2013-08-06 03:18:11 -07:00
|
|
|
wl_registry_bind(registry, id, &wl_compositor_interface, 3);
|
2012-10-16 04:57:06 -07:00
|
|
|
}
|
2013-10-11 01:41:22 -07:00
|
|
|
else if (!strcmp(interface, "wl_subcompositor"))
|
|
|
|
{
|
|
|
|
ewd->wl.subcompositor =
|
|
|
|
wl_registry_bind(registry, id, &wl_subcompositor_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);
|
2015-12-18 05:51:04 -08:00
|
|
|
else if (!strcmp(interface, "zwp_e_session_recovery") && getenv("EFL_WAYLAND_SESSION_RECOVERY"))
|
2015-08-25 05:31:09 -07:00
|
|
|
{
|
|
|
|
ewd->wl.session_recovery =
|
2015-12-18 05:51:04 -08:00
|
|
|
wl_registry_bind(registry, id, &zwp_e_session_recovery_interface, 1);
|
2015-08-25 05:31:09 -07:00
|
|
|
}
|
2014-08-25 05:44:10 -07:00
|
|
|
#ifdef USE_IVI_SHELL
|
|
|
|
else if (!strcmp(interface, "ivi_application"))
|
|
|
|
{
|
|
|
|
ewd->wl.ivi_application =
|
|
|
|
wl_registry_bind(registry, id, &ivi_application_interface, 1);
|
|
|
|
}
|
|
|
|
#endif
|
2014-12-05 11:02:16 -08:00
|
|
|
else if (!strcmp(interface, "xdg_shell") && !getenv("EFL_WAYLAND_DONT_USE_XDG_SHELL"))
|
2014-08-13 07:44:11 -07:00
|
|
|
{
|
2015-10-19 13:13:50 -07:00
|
|
|
Eina_Hash *h;
|
|
|
|
Eina_Iterator *it;
|
|
|
|
Ecore_Wl_Window *win;
|
|
|
|
|
2015-03-13 18:40:59 -07:00
|
|
|
ewd->wl.xdg_shell =
|
2014-08-13 07:49:35 -07:00
|
|
|
wl_registry_bind(registry, id, &xdg_shell_interface, 1);
|
2014-08-13 07:44:11 -07:00
|
|
|
xdg_shell_use_unstable_version(ewd->wl.xdg_shell, XDG_VERSION);
|
|
|
|
xdg_shell_add_listener(ewd->wl.xdg_shell, &xdg_shell_listener,
|
|
|
|
ewd->wl.display);
|
2015-10-19 13:13:50 -07:00
|
|
|
h = _ecore_wl_window_hash_get();
|
|
|
|
it = eina_hash_iterator_data_new(h);
|
|
|
|
EINA_ITERATOR_FOREACH(it, win)
|
2015-10-19 13:20:45 -07:00
|
|
|
if (win->surface)
|
|
|
|
_ecore_wl_window_shell_surface_init(win);
|
2014-08-13 07:44:11 -07:00
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
else if (!strcmp(interface, "wl_shell"))
|
2012-10-16 04:57:06 -07:00
|
|
|
{
|
2012-12-02 23:37:17 -08:00
|
|
|
ewd->wl.shell =
|
2012-10-16 04:57:06 -07:00
|
|
|
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
|
|
|
|
2014-09-17 06:11:46 -07:00
|
|
|
if (ewd->input)
|
2015-03-12 12:49:03 -07:00
|
|
|
_ecore_wl_input_setup(ewd->input);
|
2015-10-20 14:51:22 -07:00
|
|
|
else if (!ewd->cursor_theme)
|
2014-09-17 06:17:03 -07:00
|
|
|
{
|
2015-03-13 18:40:59 -07:00
|
|
|
ewd->cursor_theme =
|
|
|
|
wl_cursor_theme_load(NULL, ECORE_WL_DEFAULT_CURSOR_SIZE,
|
2014-09-17 06:17:03 -07:00
|
|
|
ewd->wl.shm);
|
|
|
|
}
|
2012-06-06 01:18:58 -07:00
|
|
|
}
|
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-12-02 23:37:17 -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
|
|
|
}
|
2013-10-28 09:46:40 -07:00
|
|
|
|
2015-03-13 18:40:59 -07:00
|
|
|
if ((ewd->wl.compositor) && (ewd->wl.shm) &&
|
2014-08-21 10:14:20 -07:00
|
|
|
((ewd->wl.shell) || (ewd->wl.xdg_shell)))
|
2013-10-28 09:46:40 -07:00
|
|
|
{
|
|
|
|
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);
|
2014-08-21 10:14:20 -07:00
|
|
|
ev->shell = ((ewd->wl.shell != NULL) || (ewd->wl.xdg_shell != NULL));
|
2013-10-28 09:12:27 -07:00
|
|
|
ev->output = (ewd->output != NULL);
|
|
|
|
ev->seat = (ewd->input != NULL);
|
|
|
|
ev->data_device_manager = (ewd->wl.data_device_manager != NULL);
|
|
|
|
ev->subcompositor = (ewd->wl.subcompositor != NULL);
|
2013-10-28 09:46:40 -07:00
|
|
|
|
|
|
|
ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL);
|
|
|
|
}
|
2011-12-26 15:27:20 -08:00
|
|
|
}
|
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
static void
|
2013-06-26 03:52:58 -07:00
|
|
|
_ecore_wl_cb_handle_global_remove(void *data, struct wl_registry *registry EINA_UNUSED, unsigned int id)
|
|
|
|
{
|
|
|
|
Ecore_Wl_Display *ewd;
|
2013-11-04 07:48:57 -08:00
|
|
|
Ecore_Wl_Global *global;
|
|
|
|
Eina_Inlist *tmp;
|
2013-06-26 03:52:58 -07:00
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
ewd = data;
|
|
|
|
|
2013-11-04 07:48:57 -08:00
|
|
|
EINA_INLIST_FOREACH_SAFE(ewd->globals, tmp, global)
|
2013-06-26 03:52:58 -07:00
|
|
|
{
|
|
|
|
if (global->id != id) continue;
|
2015-03-13 18:40:59 -07:00
|
|
|
ewd->globals =
|
2014-08-13 07:49:35 -07:00
|
|
|
eina_inlist_remove(ewd->globals, EINA_INLIST_GET(global));
|
2013-06-26 03:52:58 -07:00
|
|
|
free(global->interface);
|
|
|
|
free(global);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-02 23:37:17 -08:00
|
|
|
static Eina_Bool
|
2012-02-28 13:55:51 -08:00
|
|
|
_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-12-02 23:37:17 -08:00
|
|
|
static Eina_Bool
|
2012-02-28 13:55:51 -08:00
|
|
|
_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
|
|
|
|
2013-04-05 12:31:43 -07:00
|
|
|
static void
|
|
|
|
_ecore_wl_sync_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ecore_Wl_Display *ewd = data;
|
|
|
|
|
|
|
|
ewd->sync_ref_count--;
|
|
|
|
wl_callback_destroy(callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_wl_sync_wait(Ecore_Wl_Display *ewd)
|
|
|
|
{
|
|
|
|
struct wl_callback *callback;
|
|
|
|
|
|
|
|
ewd->sync_ref_count++;
|
|
|
|
callback = wl_display_sync(ewd->wl.display);
|
|
|
|
wl_callback_add_listener(callback, &_ecore_wl_sync_listener, ewd);
|
|
|
|
}
|
2013-06-07 07:31:41 -07:00
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
static void
|
2013-06-07 07:31:41 -07:00
|
|
|
_ecore_wl_animator_tick_cb_begin(void *data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eina_Hash *windows;
|
|
|
|
|
|
|
|
_ecore_wl_animator_busy = EINA_TRUE;
|
|
|
|
|
|
|
|
windows = _ecore_wl_window_hash_get();
|
|
|
|
eina_hash_foreach(windows, _ecore_wl_animator_window_add, NULL);
|
|
|
|
}
|
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
static void
|
2013-06-07 07:31:41 -07:00
|
|
|
_ecore_wl_animator_tick_cb_end(void *data EINA_UNUSED)
|
|
|
|
{
|
|
|
|
_ecore_wl_animator_busy = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
static void
|
2013-06-07 07:31:41 -07:00
|
|
|
_ecore_wl_animator_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ecore_Wl_Window *win;
|
|
|
|
|
|
|
|
if (!(win = data)) return;
|
|
|
|
|
|
|
|
ecore_animator_custom_tick();
|
|
|
|
|
|
|
|
wl_callback_destroy(callback);
|
|
|
|
win->anim_callback = NULL;
|
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
if (_ecore_wl_animator_busy)
|
2013-06-07 07:31:41 -07:00
|
|
|
{
|
|
|
|
win->anim_callback = wl_surface_frame(win->surface);
|
2013-11-22 04:39:03 -08:00
|
|
|
wl_callback_add_listener(win->anim_callback,
|
2013-06-07 07:31:41 -07:00
|
|
|
&_ecore_wl_anim_listener, win);
|
|
|
|
ecore_wl_window_commit(win);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
static Eina_Bool
|
2013-06-07 07:31:41 -07:00
|
|
|
_ecore_wl_animator_window_add(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ecore_Wl_Window *win;
|
|
|
|
|
|
|
|
if (!(win = data)) return EINA_TRUE;
|
|
|
|
if (!win->surface) return EINA_TRUE;
|
|
|
|
if (win->anim_callback) return EINA_TRUE;
|
|
|
|
|
|
|
|
win->anim_callback = wl_surface_frame(win->surface);
|
|
|
|
wl_callback_add_listener(win->anim_callback, &_ecore_wl_anim_listener, win);
|
|
|
|
ecore_wl_window_commit(win);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2013-06-26 03:52:58 -07:00
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
static void
|
2013-06-26 03:52:58 -07:00
|
|
|
_ecore_wl_signal_exit(void)
|
|
|
|
{
|
|
|
|
Ecore_Event_Signal_Exit *ev;
|
|
|
|
|
|
|
|
if (!(ev = calloc(1, sizeof(Ecore_Event_Signal_Exit))))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ev->quit = 1;
|
2013-11-22 04:39:03 -08:00
|
|
|
ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, ev,
|
2013-06-26 03:52:58 -07:00
|
|
|
_ecore_wl_signal_exit_free, NULL);
|
|
|
|
}
|
|
|
|
|
2013-11-22 04:39:03 -08:00
|
|
|
static void
|
2013-06-26 03:52:58 -07:00
|
|
|
_ecore_wl_signal_exit_free(void *data EINA_UNUSED, void *event)
|
|
|
|
{
|
|
|
|
free(event);
|
|
|
|
}
|