remove E_Comp_Data typedef, use backend-specific typedefs unconditionally

this turned into a bit of a charlie-foxtrot due to constant pointer aliasing
in the wl compositor codebase

no functional changes
This commit is contained in:
Mike Blumenkrantz 2015-06-25 19:16:27 -04:00
parent 6f46020e5d
commit eec5cf6a67
6 changed files with 193 additions and 277 deletions

View File

@ -3,16 +3,15 @@ typedef struct _E_Comp E_Comp;
#ifdef E_COMP_WL #ifdef E_COMP_WL
typedef struct _E_Comp_Wl_Client_Data E_Comp_Client_Data; typedef struct _E_Comp_Wl_Client_Data E_Comp_Client_Data;
typedef struct _E_Comp_Wl_Data E_Comp_Data;
#endif #endif
typedef struct _E_Comp_Wl_Data E_Comp_Wl_Data;
#ifdef E_COMP_X #ifdef E_COMP_X
typedef struct _E_Comp_X_Client_Data E_Comp_Client_Data; typedef struct _E_Comp_X_Client_Data E_Comp_Client_Data;
typedef struct _E_Comp_X_Data E_Comp_Data;
#endif #endif
typedef struct _E_Comp_X_Data E_Comp_X_Data;
#if !defined(E_COMP_WL) && !defined(E_COMP_X) #if !defined(E_COMP_WL) && !defined(E_COMP_X)
typedef struct _E_Comp_Data E_Comp_Data;
typedef struct _E_Comp_Client_Data E_Comp_Client_Data; typedef struct _E_Comp_Client_Data E_Comp_Client_Data;
#endif #endif
@ -88,8 +87,8 @@ struct _E_Comp
Eina_List *clients; Eina_List *clients;
unsigned int new_clients; unsigned int new_clients;
E_Comp_Data *x_comp_data; E_Comp_X_Data *x_comp_data;
E_Comp_Data *wl_comp_data; E_Comp_Wl_Data *wl_comp_data;
E_Pixmap_Type comp_type; //for determining X/Wayland/ E_Pixmap_Type comp_type; //for determining X/Wayland/

View File

@ -510,7 +510,7 @@ static void
_e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{ {
E_Client *ec; E_Client *ec;
E_Comp_Data *cdata; E_Comp_Wl_Data *cdata;
struct wl_resource *res; struct wl_resource *res;
struct wl_client *wc; struct wl_client *wc;
uint32_t serial, *k; uint32_t serial, *k;
@ -846,7 +846,7 @@ _e_comp_wl_cb_comp_object_add(void *data EINA_UNUSED, int type EINA_UNUSED, E_Ev
static void static void
_e_comp_wl_cb_key_down(void *event) _e_comp_wl_cb_key_down(void *event)
{ {
E_Comp_Data *cdata; E_Comp_Wl_Data *cdata;
E_Client *ec; E_Client *ec;
Ecore_Event_Key *ev; Ecore_Event_Key *ev;
uint32_t serial, *end, *k, keycode; uint32_t serial, *end, *k, keycode;
@ -917,7 +917,7 @@ static void
_e_comp_wl_cb_key_up(void *event) _e_comp_wl_cb_key_up(void *event)
{ {
E_Client *ec; E_Client *ec;
E_Comp_Data *cdata; E_Comp_Wl_Data *cdata;
Ecore_Event_Key *ev; Ecore_Event_Key *ev;
uint32_t serial, *end, *k, keycode; uint32_t serial, *end, *k, keycode;
@ -966,7 +966,7 @@ _e_comp_wl_cb_key_up(void *event)
static void static void
_e_comp_wl_cb_mouse_move(void *event) _e_comp_wl_cb_mouse_move(void *event)
{ {
E_Comp_Data *cdata; E_Comp_Wl_Data *cdata;
Ecore_Event_Mouse_Move *ev; Ecore_Event_Mouse_Move *ev;
if (!(cdata = e_comp->wl_comp_data)) return; if (!(cdata = e_comp->wl_comp_data)) return;
@ -1621,7 +1621,7 @@ _e_comp_wl_compositor_cb_bind(struct wl_client *client, void *data EINA_UNUSED,
static void static void
_e_comp_wl_compositor_cb_del(void *data EINA_UNUSED) _e_comp_wl_compositor_cb_del(void *data EINA_UNUSED)
{ {
E_Comp_Data *cdata; E_Comp_Wl_Data *cdata;
E_Comp_Wl_Output *output; E_Comp_Wl_Output *output;
cdata = e_comp->wl_comp_data; cdata = e_comp->wl_comp_data;
@ -2402,7 +2402,7 @@ _e_comp_wl_cb_output_bind(struct wl_client *client, void *data, uint32_t version
static Eina_Bool static Eina_Bool
_e_comp_wl_compositor_create(void) _e_comp_wl_compositor_create(void)
{ {
E_Comp_Data *cdata; E_Comp_Wl_Data *cdata;
const char *name; const char *name;
int fd = 0; int fd = 0;
@ -2411,7 +2411,7 @@ _e_comp_wl_compositor_create(void)
E_OBJECT_DEL_SET(e_comp, _e_comp_wl_compositor_cb_del); E_OBJECT_DEL_SET(e_comp, _e_comp_wl_compositor_cb_del);
/* create new compositor data */ /* create new compositor data */
if (!(cdata = E_NEW(E_Comp_Data, 1))) if (!(cdata = E_NEW(E_Comp_Wl_Data, 1)))
{ {
ERR("Could not create compositor data: %m"); ERR("Could not create compositor data: %m");
return EINA_FALSE; return EINA_FALSE;
@ -2879,7 +2879,7 @@ e_comp_wl_output_init(const char *id, const char *make, const char *model,
unsigned int refresh, unsigned int subpixel, unsigned int refresh, unsigned int subpixel,
unsigned int transform) unsigned int transform)
{ {
E_Comp_Data *cdata; E_Comp_Wl_Data *cdata;
E_Comp_Wl_Output *output; E_Comp_Wl_Output *output;
Eina_List *l2; Eina_List *l2;
struct wl_resource *resource; struct wl_resource *resource;
@ -2947,7 +2947,7 @@ e_comp_wl_output_init(const char *id, const char *make, const char *model,
E_API void E_API void
e_comp_wl_output_remove(const char *id) e_comp_wl_output_remove(const char *id)
{ {
E_Comp_Data *cdata; E_Comp_Wl_Data *cdata;
E_Comp_Wl_Output *output; E_Comp_Wl_Output *output;
if (!(cdata = e_comp->wl_comp_data)) return; if (!(cdata = e_comp->wl_comp_data)) return;

View File

@ -159,30 +159,28 @@ static const struct wl_data_source_interface _e_data_source_interface =
static void static void
_e_comp_wl_data_device_destroy_selection_data_source(struct wl_listener *listener EINA_UNUSED, void *data) _e_comp_wl_data_device_destroy_selection_data_source(struct wl_listener *listener EINA_UNUSED, void *data)
{ {
E_Comp_Data *cdata;
E_Comp_Wl_Data_Source *source; E_Comp_Wl_Data_Source *source;
struct wl_resource *data_device_res, *focus = NULL; struct wl_resource *data_device_res, *focus = NULL;
if (!(source = (E_Comp_Wl_Data_Source*)data)) if (!(source = (E_Comp_Wl_Data_Source*)data))
return; return;
cdata = e_comp->wl_comp_data; e_comp->wl_comp_data->selection.data_source = NULL;
cdata->selection.data_source = NULL;
if (cdata->kbd.enabled) if (e_comp->wl_comp_data->kbd.enabled)
focus = cdata->kbd.focus; focus = e_comp->wl_comp_data->kbd.focus;
if (focus) if (focus)
{ {
data_device_res = data_device_res =
_e_comp_wl_data_find_for_client(cdata->mgr.data_resources, _e_comp_wl_data_find_for_client(e_comp->wl_comp_data->mgr.data_resources,
wl_resource_get_client(source->resource)); wl_resource_get_client(source->resource));
if (data_device_res) if (data_device_res)
wl_data_device_send_selection(data_device_res, NULL); wl_data_device_send_selection(data_device_res, NULL);
} }
wl_signal_emit(&cdata->selection.signal, cdata); wl_signal_emit(&e_comp->wl_comp_data->selection.signal, e_comp->wl_comp_data);
} }
static struct wl_resource* static struct wl_resource*
@ -226,21 +224,19 @@ static void
_e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Source *source, uint32_t serial) _e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Source *source, uint32_t serial)
{ {
E_Comp_Wl_Data_Source *sel_source; E_Comp_Wl_Data_Source *sel_source;
E_Comp_Data *cdata;
struct wl_resource *offer_res, *data_device_res, *focus = NULL; struct wl_resource *offer_res, *data_device_res, *focus = NULL;
cdata = e_comp->wl_comp_data; sel_source = (E_Comp_Wl_Data_Source*)e_comp->wl_comp_data->selection.data_source;
sel_source = (E_Comp_Wl_Data_Source*)cdata->selection.data_source;
if ((sel_source) && if ((sel_source) &&
(cdata->selection.serial - serial < UINT32_MAX / 2)) (e_comp->wl_comp_data->selection.serial - serial < UINT32_MAX / 2))
{ {
/* TODO: elm_entry is sending too many request on now, /* TODO: elm_entry is sending too many request on now,
* for those requests, selection.signal is being emitted also a lot. * for those requests, selection.signal is being emitted also a lot.
* when it completes to optimize the entry, it should be checked more. * when it completes to optimize the entry, it should be checked more.
*/ */
if (cdata->clipboard.source) if (e_comp->wl_comp_data->clipboard.source)
wl_signal_emit(&cdata->selection.signal, cdata); wl_signal_emit(&e_comp->wl_comp_data->selection.signal, e_comp->wl_comp_data);
return; return;
} }
@ -249,20 +245,20 @@ _e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Sour
{ {
if (sel_source->cancelled) if (sel_source->cancelled)
sel_source->cancelled(sel_source); sel_source->cancelled(sel_source);
wl_list_remove(&cdata->selection.data_source_listener.link); wl_list_remove(&e_comp->wl_comp_data->selection.data_source_listener.link);
cdata->selection.data_source = NULL; e_comp->wl_comp_data->selection.data_source = NULL;
} }
cdata->selection.data_source = sel_source = source; e_comp->wl_comp_data->selection.data_source = sel_source = source;
cdata->selection.serial = serial; e_comp->wl_comp_data->selection.serial = serial;
if (cdata->kbd.enabled) if (e_comp->wl_comp_data->kbd.enabled)
focus = cdata->kbd.focus; focus = e_comp->wl_comp_data->kbd.focus;
if (focus) if (focus)
{ {
data_device_res = data_device_res =
_e_comp_wl_data_find_for_client(cdata->mgr.data_resources, _e_comp_wl_data_find_for_client(e_comp->wl_comp_data->mgr.data_resources,
wl_resource_get_client(focus)); wl_resource_get_client(focus));
if ((data_device_res) && (source)) if ((data_device_res) && (source))
{ {
@ -276,29 +272,27 @@ _e_comp_wl_data_device_selection_set(void *data EINA_UNUSED, E_Comp_Wl_Data_Sour
wl_data_device_send_selection(data_device_res, NULL); wl_data_device_send_selection(data_device_res, NULL);
} }
wl_signal_emit(&cdata->selection.signal, cdata); wl_signal_emit(&e_comp->wl_comp_data->selection.signal, e_comp->wl_comp_data);
if (source) if (source)
{ {
cdata->selection.data_source_listener.notify = e_comp->wl_comp_data->selection.data_source_listener.notify =
_e_comp_wl_data_device_destroy_selection_data_source; _e_comp_wl_data_device_destroy_selection_data_source;
wl_signal_add(&source->destroy_signal, wl_signal_add(&source->destroy_signal,
&cdata->selection.data_source_listener); &e_comp->wl_comp_data->selection.data_source_listener);
} }
} }
static void static void
_e_comp_wl_data_device_cb_drag_start(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, struct wl_resource *source_resource, struct wl_resource *origin_resource, struct wl_resource *icon_resource, uint32_t serial) _e_comp_wl_data_device_cb_drag_start(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, struct wl_resource *source_resource, struct wl_resource *origin_resource, struct wl_resource *icon_resource, uint32_t serial)
{ {
E_Comp_Data *cdata;
E_Comp_Wl_Data_Source *source; E_Comp_Wl_Data_Source *source;
Eina_List *l; Eina_List *l;
struct wl_resource *res; struct wl_resource *res;
DBG("Data Device Drag Start"); DBG("Data Device Drag Start");
cdata = e_comp->wl_comp_data; if ((e_comp->wl_comp_data->kbd.focus) && (e_comp->wl_comp_data->kbd.focus != origin_resource)) return;
if ((cdata->kbd.focus) && (cdata->kbd.focus != origin_resource)) return;
if (!(source = wl_resource_get_user_data(source_resource))) return; if (!(source = wl_resource_get_user_data(source_resource))) return;
@ -311,11 +305,11 @@ _e_comp_wl_data_device_cb_drag_start(struct wl_client *client, struct wl_resourc
cp = wl_resource_get_user_data(icon_resource); cp = wl_resource_get_user_data(icon_resource);
} }
EINA_LIST_FOREACH(cdata->ptr.resources, l, res) EINA_LIST_FOREACH(e_comp->wl_comp_data->ptr.resources, l, res)
{ {
if (!e_comp_wl_input_pointer_check(res)) continue; if (!e_comp_wl_input_pointer_check(res)) continue;
if (wl_resource_get_client(res) != client) continue; if (wl_resource_get_client(res) != client) continue;
wl_pointer_send_leave(res, serial, cdata->kbd.focus); wl_pointer_send_leave(res, serial, e_comp->wl_comp_data->kbd.focus);
} }
/* TODO: pointer start drag */ /* TODO: pointer start drag */
@ -389,12 +383,10 @@ _e_comp_wl_data_manager_cb_source_create(struct wl_client *client EINA_UNUSED, s
static void static void
_e_comp_wl_data_manager_cb_device_get(struct wl_client *client, struct wl_resource *manager_resource, uint32_t id, struct wl_resource *seat_resource EINA_UNUSED) _e_comp_wl_data_manager_cb_device_get(struct wl_client *client, struct wl_resource *manager_resource, uint32_t id, struct wl_resource *seat_resource EINA_UNUSED)
{ {
E_Comp_Data *cdata;
struct wl_resource *res; struct wl_resource *res;
/* DBG("Data Manager Device Get"); */ /* DBG("Data Manager Device Get"); */
cdata = e_comp->wl_comp_data;
/* try to create the data device resource */ /* try to create the data device resource */
res = wl_resource_create(client, &wl_data_device_interface, 1, id); res = wl_resource_create(client, &wl_data_device_interface, 1, id);
@ -405,9 +397,9 @@ _e_comp_wl_data_manager_cb_device_get(struct wl_client *client, struct wl_resour
return; return;
} }
cdata->mgr.data_resources = e_comp->wl_comp_data->mgr.data_resources =
eina_list_append(cdata->mgr.data_resources, res); eina_list_append(e_comp->wl_comp_data->mgr.data_resources, res);
wl_resource_set_implementation(res, &_e_data_device_interface, cdata, wl_resource_set_implementation(res, &_e_data_device_interface, e_comp->wl_comp_data,
_e_comp_wl_data_device_cb_unbind); _e_comp_wl_data_device_cb_unbind);
} }
@ -420,13 +412,13 @@ static const struct wl_data_device_manager_interface _e_manager_interface =
/* static void */ /* static void */
/* _e_comp_wl_data_cb_unbind_manager(struct wl_resource *resource) */ /* _e_comp_wl_data_cb_unbind_manager(struct wl_resource *resource) */
/* { */ /* { */
/* E_Comp_Data *cdata; */ /* E_Comp_Data *e_comp->wl_comp_data; */
/* DBG("Comp_Wl_Data: Unbind Manager"); */ /* DBG("Comp_Wl_Data: Unbind Manager"); */
/* if (!(cdata = wl_resource_get_user_data(resource))) return; */ /* if (!(e_comp->wl_comp_data = wl_resource_get_user_data(resource))) return; */
/* cdata->mgr.resource = NULL; */ /* e_comp->wl_comp_data->mgr.resource = NULL; */
/* } */ /* } */
static void static void
@ -518,14 +510,12 @@ _e_comp_wl_clipboard_offer_create(E_Comp_Wl_Clipboard_Source* source, int fd)
static Eina_Bool static Eina_Bool
_e_comp_wl_clipboard_source_save(void *data EINA_UNUSED, Ecore_Fd_Handler *handler) _e_comp_wl_clipboard_source_save(void *data EINA_UNUSED, Ecore_Fd_Handler *handler)
{ {
E_Comp_Data *cdata;
E_Comp_Wl_Clipboard_Source *source; E_Comp_Wl_Clipboard_Source *source;
char *p; char *p;
int len, size; int len, size;
cdata = e_comp->wl_comp_data;
if (!(source = (E_Comp_Wl_Clipboard_Source*)cdata->clipboard.source)) if (!(source = (E_Comp_Wl_Clipboard_Source*)e_comp->wl_comp_data->clipboard.source))
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
/* extend contents buffer */ /* extend contents buffer */
@ -548,7 +538,7 @@ _e_comp_wl_clipboard_source_save(void *data EINA_UNUSED, Ecore_Fd_Handler *handl
else if (len < 0) else if (len < 0)
{ {
_e_comp_wl_clipboard_source_unref(source); _e_comp_wl_clipboard_source_unref(source);
cdata->clipboard.source = NULL; e_comp->wl_comp_data->clipboard.source = NULL;
} }
else else
{ {
@ -585,7 +575,7 @@ _e_comp_wl_clipboard_source_cancelled_send(E_Comp_Wl_Data_Source *source EINA_UN
} }
static E_Comp_Wl_Clipboard_Source* static E_Comp_Wl_Clipboard_Source*
_e_comp_wl_clipboard_source_create(E_Comp_Data *cdata, const char *mime_type, uint32_t serial, int fd) _e_comp_wl_clipboard_source_create(const char *mime_type, uint32_t serial, int fd)
{ {
E_Comp_Wl_Clipboard_Source *source; E_Comp_Wl_Clipboard_Source *source;
@ -610,7 +600,7 @@ _e_comp_wl_clipboard_source_create(E_Comp_Data *cdata, const char *mime_type, ui
source->fd_handler = source->fd_handler =
ecore_main_fd_handler_add(fd, ECORE_FD_READ, ecore_main_fd_handler_add(fd, ECORE_FD_READ,
_e_comp_wl_clipboard_source_save, _e_comp_wl_clipboard_source_save,
cdata, NULL, NULL); e_comp->wl_comp_data, NULL, NULL);
if (!source->fd_handler) return NULL; if (!source->fd_handler) return NULL;
source->fd = fd; source->fd = fd;
@ -621,20 +611,18 @@ _e_comp_wl_clipboard_source_create(E_Comp_Data *cdata, const char *mime_type, ui
static void static void
_e_comp_wl_clipboard_selection_set(struct wl_listener *listener EINA_UNUSED, void *data EINA_UNUSED) _e_comp_wl_clipboard_selection_set(struct wl_listener *listener EINA_UNUSED, void *data EINA_UNUSED)
{ {
E_Comp_Data *cdata;
E_Comp_Wl_Data_Source *sel_source; E_Comp_Wl_Data_Source *sel_source;
E_Comp_Wl_Clipboard_Source *clip_source; E_Comp_Wl_Clipboard_Source *clip_source;
int p[2]; int p[2];
char *mime_type; char *mime_type;
cdata = e_comp->wl_comp_data; sel_source = (E_Comp_Wl_Data_Source*) e_comp->wl_comp_data->selection.data_source;
sel_source = (E_Comp_Wl_Data_Source*) cdata->selection.data_source; clip_source = (E_Comp_Wl_Clipboard_Source*) e_comp->wl_comp_data->clipboard.source;
clip_source = (E_Comp_Wl_Clipboard_Source*) cdata->clipboard.source;
if (!sel_source) if (!sel_source)
{ {
if (clip_source) if (clip_source)
_e_comp_wl_data_device_selection_set(cdata, _e_comp_wl_data_device_selection_set(e_comp->wl_comp_data,
&clip_source->data_source, &clip_source->data_source,
clip_source->serial); clip_source->serial);
return; return;
@ -645,7 +633,7 @@ _e_comp_wl_clipboard_selection_set(struct wl_listener *listener EINA_UNUSED, voi
if (clip_source) if (clip_source)
_e_comp_wl_clipboard_source_unref(clip_source); _e_comp_wl_clipboard_source_unref(clip_source);
cdata->clipboard.source = NULL; e_comp->wl_comp_data->clipboard.source = NULL;
mime_type = eina_list_nth(sel_source->mime_types, 0); mime_type = eina_list_nth(sel_source->mime_types, 0);
if (pipe2(p, O_CLOEXEC) == -1) if (pipe2(p, O_CLOEXEC) == -1)
@ -653,67 +641,56 @@ _e_comp_wl_clipboard_selection_set(struct wl_listener *listener EINA_UNUSED, voi
sel_source->send(sel_source, mime_type, p[1]); sel_source->send(sel_source, mime_type, p[1]);
cdata->clipboard.source = e_comp->wl_comp_data->clipboard.source =
_e_comp_wl_clipboard_source_create(cdata, mime_type, _e_comp_wl_clipboard_source_create(mime_type,
cdata->selection.serial, p[0]); e_comp->wl_comp_data->selection.serial, p[0]);
if (!cdata->clipboard.source) if (!e_comp->wl_comp_data->clipboard.source)
close(p[0]); close(p[0]);
} }
static void
_e_comp_wl_clipboard_destroy(E_Comp_Data *cdata)
{
wl_list_remove(&cdata->clipboard.listener.link);
}
static void static void
_e_comp_wl_clipboard_create(void) _e_comp_wl_clipboard_create(void)
{ {
E_Comp_Data *cdata; e_comp->wl_comp_data->clipboard.listener.notify = _e_comp_wl_clipboard_selection_set;
wl_signal_add(&e_comp->wl_comp_data->selection.signal, &e_comp->wl_comp_data->clipboard.listener);
cdata = e_comp->wl_comp_data;
cdata->clipboard.listener.notify = _e_comp_wl_clipboard_selection_set;
wl_signal_add(&cdata->selection.signal, &cdata->clipboard.listener);
} }
EINTERN void EINTERN void
e_comp_wl_data_device_keyboard_focus_set(void) e_comp_wl_data_device_keyboard_focus_set(void)
{ {
E_Comp_Data *cdata;
struct wl_resource *data_device_res, *offer_res, *focus; struct wl_resource *data_device_res, *offer_res, *focus;
E_Comp_Wl_Data_Source *source; E_Comp_Wl_Data_Source *source;
cdata = e_comp->wl_comp_data;
if (!cdata->kbd.enabled) if (!e_comp->wl_comp_data->kbd.enabled)
{ {
ERR("Keyboard not enabled"); ERR("Keyboard not enabled");
return; return;
} }
if (!(focus = cdata->kbd.focus)) if (!(focus = e_comp->wl_comp_data->kbd.focus))
{ {
ERR("No focused resource"); ERR("No focused resource");
return; return;
} }
data_device_res = data_device_res =
_e_comp_wl_data_find_for_client(cdata->mgr.data_resources, _e_comp_wl_data_find_for_client(e_comp->wl_comp_data->mgr.data_resources,
wl_resource_get_client(focus)); wl_resource_get_client(focus));
if (!data_device_res) return; if (!data_device_res) return;
source = (E_Comp_Wl_Data_Source*)cdata->selection.data_source; source = (E_Comp_Wl_Data_Source*)e_comp->wl_comp_data->selection.data_source;
if (source) if (source)
{ {
uint32_t serial; uint32_t serial;
serial = wl_display_next_serial(cdata->wl.disp); serial = wl_display_next_serial(e_comp->wl_comp_data->wl.disp);
offer_res = _e_comp_wl_data_device_data_offer_create(source, offer_res = _e_comp_wl_data_device_data_offer_create(source,
data_device_res); data_device_res);
wl_data_device_send_enter(data_device_res, serial, focus, wl_data_device_send_enter(data_device_res, serial, focus,
cdata->ptr.x, cdata->ptr.y, offer_res); e_comp->wl_comp_data->ptr.x, e_comp->wl_comp_data->ptr.y, offer_res);
wl_data_device_send_selection(data_device_res, offer_res); wl_data_device_send_selection(data_device_res, offer_res);
} }
} }
@ -721,21 +698,17 @@ e_comp_wl_data_device_keyboard_focus_set(void)
EINTERN Eina_Bool EINTERN Eina_Bool
e_comp_wl_data_manager_init(void) e_comp_wl_data_manager_init(void)
{ {
E_Comp_Data *cdata;
cdata = e_comp->wl_comp_data;
/* try to create global data manager */ /* try to create global data manager */
cdata->mgr.global = e_comp->wl_comp_data->mgr.global =
wl_global_create(cdata->wl.disp, &wl_data_device_manager_interface, 1, wl_global_create(e_comp->wl_comp_data->wl.disp, &wl_data_device_manager_interface, 1,
cdata, _e_comp_wl_data_cb_bind_manager); e_comp->wl_comp_data, _e_comp_wl_data_cb_bind_manager);
if (!cdata->mgr.global) if (!e_comp->wl_comp_data->mgr.global)
{ {
ERR("Could not create global for data device manager: %m"); ERR("Could not create global for data device manager: %m");
return EINA_FALSE; return EINA_FALSE;
} }
wl_signal_init(&cdata->selection.signal); wl_signal_init(&e_comp->wl_comp_data->selection.signal);
/* create clipboard */ /* create clipboard */
_e_comp_wl_clipboard_create(); _e_comp_wl_clipboard_create();
@ -747,7 +720,7 @@ EINTERN void
e_comp_wl_data_manager_shutdown(void) e_comp_wl_data_manager_shutdown(void)
{ {
/* destroy the global manager resource */ /* destroy the global manager resource */
/* if (cdata->mgr.global) wl_global_destroy(cdata->mgr.global); */ /* if (e_comp->wl_comp_data->mgr.global) wl_global_destroy(e_comp->wl_comp_data->mgr.global); */
_e_comp_wl_clipboard_destroy(e_comp->wl_comp_data); wl_list_remove(&e_comp->wl_comp_data->clipboard.listener.link);
} }

View File

@ -6,21 +6,18 @@
static void static void
_e_comp_wl_input_update_seat_caps(void) _e_comp_wl_input_update_seat_caps(void)
{ {
E_Comp_Data *cdata;
Eina_List *l; Eina_List *l;
struct wl_resource *res; struct wl_resource *res;
enum wl_seat_capability caps = 0; enum wl_seat_capability caps = 0;
cdata = e_comp->wl_comp_data; if (e_comp->wl_comp_data->ptr.enabled)
if (cdata->ptr.enabled)
caps |= WL_SEAT_CAPABILITY_POINTER; caps |= WL_SEAT_CAPABILITY_POINTER;
if (cdata->kbd.enabled) if (e_comp->wl_comp_data->kbd.enabled)
caps |= WL_SEAT_CAPABILITY_KEYBOARD; caps |= WL_SEAT_CAPABILITY_KEYBOARD;
if (cdata->touch.enabled) if (e_comp->wl_comp_data->touch.enabled)
caps |= WL_SEAT_CAPABILITY_TOUCH; caps |= WL_SEAT_CAPABILITY_TOUCH;
EINA_LIST_FOREACH(cdata->seat.resources, l, res) EINA_LIST_FOREACH(e_comp->wl_comp_data->seat.resources, l, res)
wl_seat_send_capabilities(res, caps); wl_seat_send_capabilities(res, caps);
} }
@ -38,6 +35,7 @@ _e_comp_wl_input_pointer_cb_cursor_set(struct wl_client *client, struct wl_resou
E_CLIENT_FOREACH(ec) E_CLIENT_FOREACH(ec)
{ {
if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) continue;
if (!ec->comp_data->surface) continue; if (!ec->comp_data->surface) continue;
if (client != wl_resource_get_client(ec->comp_data->surface)) continue; if (client != wl_resource_get_client(ec->comp_data->surface)) continue;
if (ec->mouse.in) if (ec->mouse.in)
@ -90,42 +88,33 @@ static const struct wl_touch_interface _e_touch_interface =
static void static void
_e_comp_wl_input_cb_pointer_unbind(struct wl_resource *resource) _e_comp_wl_input_cb_pointer_unbind(struct wl_resource *resource)
{ {
E_Comp_Data *cdata; e_comp->wl_comp_data->ptr.resources = eina_list_remove(e_comp->wl_comp_data->ptr.resources, resource);
cdata = e_comp->wl_comp_data;
cdata->ptr.resources = eina_list_remove(cdata->ptr.resources, resource);
} }
static void static void
_e_comp_wl_input_cb_pointer_get(struct wl_client *client, struct wl_resource *resource, uint32_t id) _e_comp_wl_input_cb_pointer_get(struct wl_client *client, struct wl_resource *resource, uint32_t id)
{ {
E_Comp_Data *cdata;
struct wl_resource *res; struct wl_resource *res;
cdata = e_comp->wl_comp_data;
/* try to create pointer resource */ /* try to create pointer resource */
res = wl_resource_create(client, &wl_pointer_interface, res = wl_resource_create(client, &wl_pointer_interface,
wl_resource_get_version(resource), id); wl_resource_get_version(resource), id);
if (!res) if (!res)
{ {
ERR("Could not create pointer on seat %s: %m", cdata->seat.name); ERR("Could not create pointer on seat %s: %m", e_comp->wl_comp_data->seat.name);
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
} }
cdata->ptr.resources = eina_list_append(cdata->ptr.resources, res); e_comp->wl_comp_data->ptr.resources = eina_list_append(e_comp->wl_comp_data->ptr.resources, res);
wl_resource_set_implementation(res, &_e_pointer_interface, cdata, wl_resource_set_implementation(res, &_e_pointer_interface, e_comp->wl_comp_data,
_e_comp_wl_input_cb_pointer_unbind); _e_comp_wl_input_cb_pointer_unbind);
} }
static void static void
_e_comp_wl_input_cb_keyboard_unbind(struct wl_resource *resource) _e_comp_wl_input_cb_keyboard_unbind(struct wl_resource *resource)
{ {
E_Comp_Data *cdata; e_comp->wl_comp_data->kbd.resources = eina_list_remove(e_comp->wl_comp_data->kbd.resources, resource);
cdata = e_comp->wl_comp_data;
cdata->kbd.resources = eina_list_remove(cdata->kbd.resources, resource);
} }
void void
@ -162,28 +151,25 @@ static void
_e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *resource, uint32_t id) _e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *resource, uint32_t id)
{ {
E_Client *focused; E_Client *focused;
E_Comp_Data *cdata;
struct wl_resource *res; struct wl_resource *res;
cdata = e_comp->wl_comp_data;
/* try to create keyboard resource */ /* try to create keyboard resource */
res = wl_resource_create(client, &wl_keyboard_interface, res = wl_resource_create(client, &wl_keyboard_interface,
wl_resource_get_version(resource), id); wl_resource_get_version(resource), id);
if (!res) if (!res)
{ {
ERR("Could not create keyboard on seat %s: %m", cdata->seat.name); ERR("Could not create keyboard on seat %s: %m", e_comp->wl_comp_data->seat.name);
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
} }
cdata->kbd.resources = eina_list_append(cdata->kbd.resources, res); e_comp->wl_comp_data->kbd.resources = eina_list_append(e_comp->wl_comp_data->kbd.resources, res);
wl_resource_set_implementation(res, &_e_keyboard_interface, cdata, wl_resource_set_implementation(res, &_e_keyboard_interface, e_comp->wl_comp_data,
_e_comp_wl_input_cb_keyboard_unbind); _e_comp_wl_input_cb_keyboard_unbind);
/* send current keymap */ /* send current keymap */
wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
cdata->xkb.fd, cdata->xkb.size); e_comp->wl_comp_data->xkb.fd, e_comp->wl_comp_data->xkb.size);
/* if the client owns the focused surface, we need to send an enter */ /* if the client owns the focused surface, we need to send an enter */
focused = e_client_focused_get(); focused = e_client_focused_get();
@ -196,32 +182,26 @@ _e_comp_wl_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *r
static void static void
_e_comp_wl_input_cb_touch_unbind(struct wl_resource *resource) _e_comp_wl_input_cb_touch_unbind(struct wl_resource *resource)
{ {
E_Comp_Data *cdata; e_comp->wl_comp_data->touch.resources = eina_list_remove(e_comp->wl_comp_data->touch.resources, resource);
cdata = e_comp->wl_comp_data;
cdata->touch.resources = eina_list_remove(cdata->touch.resources, resource);
} }
static void static void
_e_comp_wl_input_cb_touch_get(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t id EINA_UNUSED) _e_comp_wl_input_cb_touch_get(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t id EINA_UNUSED)
{ {
E_Comp_Data *cdata;
struct wl_resource *res; struct wl_resource *res;
cdata = e_comp->wl_comp_data;
/* try to create pointer resource */ /* try to create pointer resource */
res = wl_resource_create(client, &wl_touch_interface, res = wl_resource_create(client, &wl_touch_interface,
wl_resource_get_version(resource), id); wl_resource_get_version(resource), id);
if (!res) if (!res)
{ {
ERR("Could not create touch on seat %s: %m", cdata->seat.name); ERR("Could not create touch on seat %s: %m", e_comp->wl_comp_data->seat.name);
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
} }
cdata->touch.resources = eina_list_append(cdata->touch.resources, res); e_comp->wl_comp_data->touch.resources = eina_list_append(e_comp->wl_comp_data->touch.resources, res);
wl_resource_set_implementation(res, &_e_touch_interface, cdata, wl_resource_set_implementation(res, &_e_touch_interface, e_comp->wl_comp_data,
_e_comp_wl_input_cb_touch_unbind); _e_comp_wl_input_cb_touch_unbind);
} }
@ -235,19 +215,14 @@ static const struct wl_seat_interface _e_seat_interface =
static void static void
_e_comp_wl_input_cb_unbind_seat(struct wl_resource *resource) _e_comp_wl_input_cb_unbind_seat(struct wl_resource *resource)
{ {
E_Comp_Data *cdata; e_comp->wl_comp_data->seat.resources = eina_list_remove(e_comp->wl_comp_data->seat.resources, resource);
cdata = e_comp->wl_comp_data;
cdata->seat.resources = eina_list_remove(cdata->seat.resources, resource);
} }
static void static void
_e_comp_wl_input_cb_bind_seat(struct wl_client *client, void *data EINA_UNUSED, uint32_t version, uint32_t id) _e_comp_wl_input_cb_bind_seat(struct wl_client *client, void *data EINA_UNUSED, uint32_t version, uint32_t id)
{ {
E_Comp_Data *cdata;
struct wl_resource *res; struct wl_resource *res;
cdata = e_comp->wl_comp_data;
res = wl_resource_create(client, &wl_seat_interface, MIN(version, 4), id); res = wl_resource_create(client, &wl_seat_interface, MIN(version, 4), id);
if (!res) if (!res)
{ {
@ -256,15 +231,15 @@ _e_comp_wl_input_cb_bind_seat(struct wl_client *client, void *data EINA_UNUSED,
} }
/* store version of seat interface for reuse in updating capabilities */ /* store version of seat interface for reuse in updating capabilities */
cdata->seat.version = version; e_comp->wl_comp_data->seat.version = version;
cdata->seat.resources = eina_list_append(cdata->seat.resources, res); e_comp->wl_comp_data->seat.resources = eina_list_append(e_comp->wl_comp_data->seat.resources, res);
wl_resource_set_implementation(res, &_e_seat_interface, cdata, wl_resource_set_implementation(res, &_e_seat_interface, e_comp->wl_comp_data,
_e_comp_wl_input_cb_unbind_seat); _e_comp_wl_input_cb_unbind_seat);
_e_comp_wl_input_update_seat_caps(); _e_comp_wl_input_update_seat_caps();
if (cdata->seat.version >= WL_SEAT_NAME_SINCE_VERSION) if (e_comp->wl_comp_data->seat.version >= WL_SEAT_NAME_SINCE_VERSION)
wl_seat_send_name(res, cdata->seat.name); wl_seat_send_name(res, e_comp->wl_comp_data->seat.name);
} }
static int static int
@ -322,44 +297,42 @@ _e_comp_wl_input_keymap_update(struct xkb_keymap *keymap)
struct wl_resource *res; struct wl_resource *res;
Eina_List *l; Eina_List *l;
uint32_t serial; uint32_t serial;
E_Comp_Data *cdata;
cdata = e_comp->wl_comp_data;
/* unreference any existing keymap */ /* unreference any existing keymap */
if (cdata->xkb.keymap) xkb_map_unref(cdata->xkb.keymap); if (e_comp->wl_comp_data->xkb.keymap) xkb_map_unref(e_comp->wl_comp_data->xkb.keymap);
/* unmap any existing keyboard area */ /* unmap any existing keyboard area */
if (cdata->xkb.area) munmap(cdata->xkb.area, cdata->xkb.size); if (e_comp->wl_comp_data->xkb.area) munmap(e_comp->wl_comp_data->xkb.area, e_comp->wl_comp_data->xkb.size);
if (cdata->xkb.fd >= 0) close(cdata->xkb.fd); if (e_comp->wl_comp_data->xkb.fd >= 0) close(e_comp->wl_comp_data->xkb.fd);
/* unreference any existing keyboard state */ /* unreference any existing keyboard state */
if (cdata->xkb.state) if (e_comp->wl_comp_data->xkb.state)
{ {
latched = latched =
xkb_state_serialize_mods(cdata->xkb.state, XKB_STATE_MODS_LATCHED); xkb_state_serialize_mods(e_comp->wl_comp_data->xkb.state, XKB_STATE_MODS_LATCHED);
locked = locked =
xkb_state_serialize_mods(cdata->xkb.state, XKB_STATE_MODS_LOCKED); xkb_state_serialize_mods(e_comp->wl_comp_data->xkb.state, XKB_STATE_MODS_LOCKED);
group = group =
xkb_state_serialize_layout(cdata->xkb.state, xkb_state_serialize_layout(e_comp->wl_comp_data->xkb.state,
XKB_STATE_LAYOUT_EFFECTIVE); XKB_STATE_LAYOUT_EFFECTIVE);
xkb_state_unref(cdata->xkb.state); xkb_state_unref(e_comp->wl_comp_data->xkb.state);
} }
/* create a new xkb state */ /* create a new xkb state */
cdata->xkb.state = xkb_state_new(keymap); e_comp->wl_comp_data->xkb.state = xkb_state_new(keymap);
if ((latched) || (locked) || (group)) if ((latched) || (locked) || (group))
xkb_state_update_mask(cdata->xkb.state, 0, latched, locked, 0, 0, group); xkb_state_update_mask(e_comp->wl_comp_data->xkb.state, 0, latched, locked, 0, 0, group);
/* increment keymap reference */ /* increment keymap reference */
cdata->xkb.keymap = xkb_map_ref(keymap); e_comp->wl_comp_data->xkb.keymap = xkb_map_ref(keymap);
/* fetch updated modifiers */ /* fetch updated modifiers */
cdata->kbd.mod_shift = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_SHIFT); e_comp->wl_comp_data->kbd.mod_shift = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_SHIFT);
cdata->kbd.mod_caps = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_CAPS); e_comp->wl_comp_data->kbd.mod_caps = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_CAPS);
cdata->kbd.mod_ctrl = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_CTRL); e_comp->wl_comp_data->kbd.mod_ctrl = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_CTRL);
cdata->kbd.mod_alt = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_ALT); e_comp->wl_comp_data->kbd.mod_alt = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_ALT);
cdata->kbd.mod_super = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_LOGO); e_comp->wl_comp_data->kbd.mod_super = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_LOGO);
if (!(tmp = xkb_map_get_as_string(keymap))) if (!(tmp = xkb_map_get_as_string(keymap)))
{ {
@ -367,32 +340,32 @@ _e_comp_wl_input_keymap_update(struct xkb_keymap *keymap)
return; return;
} }
cdata->xkb.size = strlen(tmp) + 1; e_comp->wl_comp_data->xkb.size = strlen(tmp) + 1;
cdata->xkb.fd = _e_comp_wl_input_keymap_fd_get(cdata->xkb.size); e_comp->wl_comp_data->xkb.fd = _e_comp_wl_input_keymap_fd_get(e_comp->wl_comp_data->xkb.size);
if (cdata->xkb.fd < 0) if (e_comp->wl_comp_data->xkb.fd < 0)
{ {
ERR("Could not create keymap file"); ERR("Could not create keymap file");
free(tmp); free(tmp);
return; return;
} }
cdata->xkb.area = e_comp->wl_comp_data->xkb.area =
mmap(NULL, cdata->xkb.size, (PROT_READ | PROT_WRITE), mmap(NULL, e_comp->wl_comp_data->xkb.size, (PROT_READ | PROT_WRITE),
MAP_SHARED, cdata->xkb.fd, 0); MAP_SHARED, e_comp->wl_comp_data->xkb.fd, 0);
if (cdata->xkb.area == MAP_FAILED) if (e_comp->wl_comp_data->xkb.area == MAP_FAILED)
{ {
ERR("Failed to mmap keymap area: %m"); ERR("Failed to mmap keymap area: %m");
free(tmp); free(tmp);
return; return;
} }
strcpy(cdata->xkb.area, tmp); strcpy(e_comp->wl_comp_data->xkb.area, tmp);
free(tmp); free(tmp);
/* send updated keymap */ /* send updated keymap */
EINA_LIST_FOREACH(cdata->kbd.resources, l, res) EINA_LIST_FOREACH(e_comp->wl_comp_data->kbd.resources, l, res)
wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
cdata->xkb.fd, cdata->xkb.size); e_comp->wl_comp_data->xkb.fd, e_comp->wl_comp_data->xkb.size);
/* update modifiers */ /* update modifiers */
e_comp_wl_input_keyboard_modifiers_update(); e_comp_wl_input_keyboard_modifiers_update();
@ -400,36 +373,32 @@ _e_comp_wl_input_keymap_update(struct xkb_keymap *keymap)
if ((!latched) && (!locked)) return; if ((!latched) && (!locked)) return;
/* send modifiers */ /* send modifiers */
serial = wl_display_get_serial(cdata->wl.disp); serial = wl_display_get_serial(e_comp->wl_comp_data->wl.disp);
EINA_LIST_FOREACH(cdata->kbd.resources, l, res) EINA_LIST_FOREACH(e_comp->wl_comp_data->kbd.resources, l, res)
wl_keyboard_send_modifiers(res, serial, cdata->kbd.mod_depressed, wl_keyboard_send_modifiers(res, serial, e_comp->wl_comp_data->kbd.mod_depressed,
cdata->kbd.mod_latched, cdata->kbd.mod_locked, e_comp->wl_comp_data->kbd.mod_latched, e_comp->wl_comp_data->kbd.mod_locked,
cdata->kbd.mod_group); e_comp->wl_comp_data->kbd.mod_group);
} }
EINTERN Eina_Bool EINTERN Eina_Bool
e_comp_wl_input_init(void) e_comp_wl_input_init(void)
{ {
E_Comp_Data *cdata;
cdata = e_comp->wl_comp_data;
/* set default seat name */ /* set default seat name */
if (!cdata->seat.name) cdata->seat.name = "default"; if (!e_comp->wl_comp_data->seat.name) e_comp->wl_comp_data->seat.name = "default";
cdata->xkb.fd = -1; e_comp->wl_comp_data->xkb.fd = -1;
/* create the global resource for input seat */ /* create the global resource for input seat */
cdata->seat.global = e_comp->wl_comp_data->seat.global =
wl_global_create(cdata->wl.disp, &wl_seat_interface, 4, wl_global_create(e_comp->wl_comp_data->wl.disp, &wl_seat_interface, 4,
cdata, _e_comp_wl_input_cb_bind_seat); e_comp->wl_comp_data, _e_comp_wl_input_cb_bind_seat);
if (!cdata->seat.global) if (!e_comp->wl_comp_data->seat.global)
{ {
ERR("Could not create global for seat: %m"); ERR("Could not create global for seat: %m");
return EINA_FALSE; return EINA_FALSE;
} }
wl_array_init(&cdata->kbd.keys); wl_array_init(&e_comp->wl_comp_data->kbd.keys);
return EINA_TRUE; return EINA_TRUE;
} }
@ -438,41 +407,38 @@ EINTERN void
e_comp_wl_input_shutdown(void) e_comp_wl_input_shutdown(void)
{ {
struct wl_resource *res; struct wl_resource *res;
E_Comp_Data *cdata;
cdata = e_comp->wl_comp_data;
/* destroy pointer resources */ /* destroy pointer resources */
EINA_LIST_FREE(cdata->ptr.resources, res) EINA_LIST_FREE(e_comp->wl_comp_data->ptr.resources, res)
wl_resource_destroy(res); wl_resource_destroy(res);
/* destroy keyboard resources */ /* destroy keyboard resources */
EINA_LIST_FREE(cdata->kbd.resources, res) EINA_LIST_FREE(e_comp->wl_comp_data->kbd.resources, res)
wl_resource_destroy(res); wl_resource_destroy(res);
/* destroy touch resources */ /* destroy touch resources */
EINA_LIST_FREE(cdata->touch.resources, res) EINA_LIST_FREE(e_comp->wl_comp_data->touch.resources, res)
wl_resource_destroy(res); wl_resource_destroy(res);
/* destroy cdata->kbd.keys array */ /* destroy e_comp->wl_comp_data->kbd.keys array */
wl_array_release(&cdata->kbd.keys); wl_array_release(&e_comp->wl_comp_data->kbd.keys);
/* unreference any existing keymap */ /* unreference any existing keymap */
if (cdata->xkb.keymap) xkb_map_unref(cdata->xkb.keymap); if (e_comp->wl_comp_data->xkb.keymap) xkb_map_unref(e_comp->wl_comp_data->xkb.keymap);
/* unmap any existing keyboard area */ /* unmap any existing keyboard area */
if (cdata->xkb.area) munmap(cdata->xkb.area, cdata->xkb.size); if (e_comp->wl_comp_data->xkb.area) munmap(e_comp->wl_comp_data->xkb.area, e_comp->wl_comp_data->xkb.size);
if (cdata->xkb.fd >= 0) close(cdata->xkb.fd); if (e_comp->wl_comp_data->xkb.fd >= 0) close(e_comp->wl_comp_data->xkb.fd);
/* unreference any existing keyboard state */ /* unreference any existing keyboard state */
if (cdata->xkb.state) xkb_state_unref(cdata->xkb.state); if (e_comp->wl_comp_data->xkb.state) xkb_state_unref(e_comp->wl_comp_data->xkb.state);
/* unreference any existing context */ /* unreference any existing context */
if (cdata->xkb.context) xkb_context_unref(cdata->xkb.context); if (e_comp->wl_comp_data->xkb.context) xkb_context_unref(e_comp->wl_comp_data->xkb.context);
/* destroy the global seat resource */ /* destroy the global seat resource */
if (cdata->seat.global) wl_global_destroy(cdata->seat.global); if (e_comp->wl_comp_data->seat.global) wl_global_destroy(e_comp->wl_comp_data->seat.global);
cdata->seat.global = NULL; e_comp->wl_comp_data->seat.global = NULL;
} }
EINTERN Eina_Bool EINTERN Eina_Bool
@ -492,18 +458,14 @@ e_comp_wl_input_keyboard_check(struct wl_resource *res)
EINTERN void EINTERN void
e_comp_wl_input_keyboard_modifiers_serialize(void) e_comp_wl_input_keyboard_modifiers_serialize(void)
{ {
E_Comp_Data *cdata; e_comp->wl_comp_data->kbd.mod_depressed =
xkb_state_serialize_mods(e_comp->wl_comp_data->xkb.state, XKB_STATE_DEPRESSED);
cdata = e_comp->wl_comp_data; e_comp->wl_comp_data->kbd.mod_latched =
xkb_state_serialize_mods(e_comp->wl_comp_data->xkb.state, XKB_STATE_MODS_LATCHED);
cdata->kbd.mod_depressed = e_comp->wl_comp_data->kbd.mod_locked =
xkb_state_serialize_mods(cdata->xkb.state, XKB_STATE_DEPRESSED); xkb_state_serialize_mods(e_comp->wl_comp_data->xkb.state, XKB_STATE_MODS_LOCKED);
cdata->kbd.mod_latched = e_comp->wl_comp_data->kbd.mod_group =
xkb_state_serialize_mods(cdata->xkb.state, XKB_STATE_MODS_LATCHED); xkb_state_serialize_layout(e_comp->wl_comp_data->xkb.state, XKB_STATE_LAYOUT_EFFECTIVE);
cdata->kbd.mod_locked =
xkb_state_serialize_mods(cdata->xkb.state, XKB_STATE_MODS_LOCKED);
cdata->kbd.mod_group =
xkb_state_serialize_layout(cdata->xkb.state, XKB_STATE_LAYOUT_EFFECTIVE);
} }
EINTERN void EINTERN void
@ -512,36 +474,32 @@ e_comp_wl_input_keyboard_modifiers_update(void)
uint32_t serial; uint32_t serial;
struct wl_resource *res; struct wl_resource *res;
Eina_List *l; Eina_List *l;
E_Comp_Data *cdata;
cdata = e_comp->wl_comp_data;
e_comp_wl_input_keyboard_modifiers_serialize(); e_comp_wl_input_keyboard_modifiers_serialize();
if (!eina_list_count(cdata->kbd.resources)) return; if (!eina_list_count(e_comp->wl_comp_data->kbd.resources)) return;
serial = wl_display_next_serial(cdata->wl.disp); serial = wl_display_next_serial(e_comp->wl_comp_data->wl.disp);
EINA_LIST_FOREACH(cdata->kbd.resources, l, res) EINA_LIST_FOREACH(e_comp->wl_comp_data->kbd.resources, l, res)
wl_keyboard_send_modifiers(res, serial, wl_keyboard_send_modifiers(res, serial,
cdata->kbd.mod_depressed, e_comp->wl_comp_data->kbd.mod_depressed,
cdata->kbd.mod_latched, e_comp->wl_comp_data->kbd.mod_latched,
cdata->kbd.mod_locked, e_comp->wl_comp_data->kbd.mod_locked,
cdata->kbd.mod_group); e_comp->wl_comp_data->kbd.mod_group);
} }
EINTERN void EINTERN void
e_comp_wl_input_keyboard_state_update(uint32_t keycode, Eina_Bool pressed) e_comp_wl_input_keyboard_state_update(uint32_t keycode, Eina_Bool pressed)
{ {
enum xkb_key_direction dir; enum xkb_key_direction dir;
E_Comp_Data *cdata;
cdata = e_comp->wl_comp_data; if (!e_comp->wl_comp_data->xkb.state) return;
if (!cdata->xkb.state) return;
if (pressed) dir = XKB_KEY_DOWN; if (pressed) dir = XKB_KEY_DOWN;
else dir = XKB_KEY_UP; else dir = XKB_KEY_UP;
cdata->kbd.mod_changed = e_comp->wl_comp_data->kbd.mod_changed =
xkb_state_update_key(cdata->xkb.state, keycode + 8, dir); xkb_state_update_key(e_comp->wl_comp_data->xkb.state, keycode + 8, dir);
} }
E_API void E_API void
@ -577,9 +535,6 @@ e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *lay
{ {
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
struct xkb_rule_names names; struct xkb_rule_names names;
E_Comp_Data *cdata;
cdata = e_comp->wl_comp_data;
/* DBG("COMP_WL: Keymap Set: %s %s %s", rules, model, layout); */ /* DBG("COMP_WL: Keymap Set: %s %s %s", rules, model, layout); */
@ -590,13 +545,13 @@ e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *lay
if (layout) names.layout = strdup(layout); if (layout) names.layout = strdup(layout);
/* unreference any existing context */ /* unreference any existing context */
if (cdata->xkb.context) xkb_context_unref(cdata->xkb.context); if (e_comp->wl_comp_data->xkb.context) xkb_context_unref(e_comp->wl_comp_data->xkb.context);
/* create a new xkb context */ /* create a new xkb context */
cdata->xkb.context = xkb_context_new(0); e_comp->wl_comp_data->xkb.context = xkb_context_new(0);
/* fetch new keymap based on names */ /* fetch new keymap based on names */
keymap = xkb_map_new_from_names(cdata->xkb.context, &names, 0); keymap = xkb_map_new_from_names(e_comp->wl_comp_data->xkb.context, &names, 0);
/* update compositor keymap */ /* update compositor keymap */
_e_comp_wl_input_keymap_update(keymap); _e_comp_wl_input_keymap_update(keymap);

View File

@ -4871,7 +4871,7 @@ _e_comp_x_setup(Ecore_X_Window root, int w, int h)
if (!ecore_x_window_manage(root)) return EINA_FALSE; if (!ecore_x_window_manage(root)) return EINA_FALSE;
E_OBJECT_DEL_SET(e_comp, _e_comp_x_del); E_OBJECT_DEL_SET(e_comp, _e_comp_x_del);
e_comp->x_comp_data = E_NEW(E_Comp_Data, 1); e_comp->x_comp_data = E_NEW(E_Comp_X_Data, 1);
ecore_x_e_window_profile_supported_set(root, e_config->use_desktop_window_profile); ecore_x_e_window_profile_supported_set(root, e_config->use_desktop_window_profile);
e_comp->cm_selection = ecore_x_window_input_new(root, 0, 0, 1, 1); e_comp->cm_selection = ecore_x_window_input_new(root, 0, 0, 1, 1);
if (!e_comp->cm_selection) return EINA_FALSE; if (!e_comp->cm_selection) return EINA_FALSE;

View File

@ -143,7 +143,6 @@ static void
_e_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED) _e_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED)
{ {
E_Client *ec; E_Client *ec;
E_Comp_Data *cdata;
E_Binding_Event_Mouse_Button ev; E_Binding_Event_Mouse_Button ev;
/* get the client for this resource */ /* get the client for this resource */
@ -157,8 +156,7 @@ _e_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_resourc
if ((ec->maximized) || (ec->fullscreen)) return; if ((ec->maximized) || (ec->fullscreen)) return;
cdata = e_comp->wl_comp_data; switch (e_comp->wl_comp_data->ptr.button)
switch (cdata->ptr.button)
{ {
case BTN_LEFT: case BTN_LEFT:
ev.button = 1; ev.button = 1;
@ -170,13 +168,13 @@ _e_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_resourc
ev.button = 3; ev.button = 3;
break; break;
default: default:
ev.button = cdata->ptr.button; ev.button = e_comp->wl_comp_data->ptr.button;
break; break;
} }
e_comp_object_frame_xy_unadjust(ec->frame, e_comp_object_frame_xy_unadjust(ec->frame,
wl_fixed_to_int(cdata->ptr.x), wl_fixed_to_int(e_comp->wl_comp_data->ptr.x),
wl_fixed_to_int(cdata->ptr.y), wl_fixed_to_int(e_comp->wl_comp_data->ptr.y),
&ev.canvas.x, &ev.canvas.y); &ev.canvas.x, &ev.canvas.y);
_e_shell_surface_mouse_down_helper(ec, &ev, EINA_TRUE); _e_shell_surface_mouse_down_helper(ec, &ev, EINA_TRUE);
@ -186,7 +184,6 @@ static void
_e_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, uint32_t edges) _e_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, uint32_t edges)
{ {
E_Client *ec; E_Client *ec;
E_Comp_Data *cdata;
E_Binding_Event_Mouse_Button ev; E_Binding_Event_Mouse_Button ev;
/* get the client for this resource */ /* get the client for this resource */
@ -203,16 +200,14 @@ _e_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_resou
if ((ec->maximized) || (ec->fullscreen)) return; if ((ec->maximized) || (ec->fullscreen)) return;
cdata = e_comp->wl_comp_data;
DBG("Comp Resize Edges Set: %d", edges); DBG("Comp Resize Edges Set: %d", edges);
cdata->resize.resource = resource; e_comp->wl_comp_data->resize.resource = resource;
cdata->resize.edges = edges; e_comp->wl_comp_data->resize.edges = edges;
cdata->ptr.grab_x = cdata->ptr.x - wl_fixed_from_int(ec->client.x); e_comp->wl_comp_data->ptr.grab_x = e_comp->wl_comp_data->ptr.x - wl_fixed_from_int(ec->client.x);
cdata->ptr.grab_y = cdata->ptr.y - wl_fixed_from_int(ec->client.y); e_comp->wl_comp_data->ptr.grab_y = e_comp->wl_comp_data->ptr.y - wl_fixed_from_int(ec->client.y);
switch (cdata->ptr.button) switch (e_comp->wl_comp_data->ptr.button)
{ {
case BTN_LEFT: case BTN_LEFT:
ev.button = 1; ev.button = 1;
@ -224,13 +219,13 @@ _e_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_resou
ev.button = 3; ev.button = 3;
break; break;
default: default:
ev.button = cdata->ptr.button; ev.button = e_comp->wl_comp_data->ptr.button;
break; break;
} }
e_comp_object_frame_xy_unadjust(ec->frame, e_comp_object_frame_xy_unadjust(ec->frame,
wl_fixed_to_int(cdata->ptr.x), wl_fixed_to_int(e_comp->wl_comp_data->ptr.x),
wl_fixed_to_int(cdata->ptr.y), wl_fixed_to_int(e_comp->wl_comp_data->ptr.y),
&ev.canvas.x, &ev.canvas.y); &ev.canvas.x, &ev.canvas.y);
_e_shell_surface_mouse_down_helper(ec, &ev, EINA_FALSE); _e_shell_surface_mouse_down_helper(ec, &ev, EINA_FALSE);
@ -724,7 +719,6 @@ static void
_e_xdg_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED) _e_xdg_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED)
{ {
E_Client *ec; E_Client *ec;
E_Comp_Data *cdata;
E_Binding_Event_Mouse_Button ev; E_Binding_Event_Mouse_Button ev;
/* get the client for this resource */ /* get the client for this resource */
@ -738,8 +732,7 @@ _e_xdg_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_res
if ((ec->maximized) || (ec->fullscreen)) return; if ((ec->maximized) || (ec->fullscreen)) return;
cdata = e_comp->wl_comp_data; switch (e_comp->wl_comp_data->ptr.button)
switch (cdata->ptr.button)
{ {
case BTN_LEFT: case BTN_LEFT:
ev.button = 1; ev.button = 1;
@ -751,13 +744,13 @@ _e_xdg_shell_surface_cb_move(struct wl_client *client EINA_UNUSED, struct wl_res
ev.button = 3; ev.button = 3;
break; break;
default: default:
ev.button = cdata->ptr.button; ev.button = e_comp->wl_comp_data->ptr.button;
break; break;
} }
e_comp_object_frame_xy_unadjust(ec->frame, e_comp_object_frame_xy_unadjust(ec->frame,
wl_fixed_to_int(cdata->ptr.x), wl_fixed_to_int(e_comp->wl_comp_data->ptr.x),
wl_fixed_to_int(cdata->ptr.y), wl_fixed_to_int(e_comp->wl_comp_data->ptr.y),
&ev.canvas.x, &ev.canvas.y); &ev.canvas.x, &ev.canvas.y);
_e_shell_surface_mouse_down_helper(ec, &ev, EINA_TRUE); _e_shell_surface_mouse_down_helper(ec, &ev, EINA_TRUE);
@ -767,7 +760,6 @@ static void
_e_xdg_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, uint32_t edges) _e_xdg_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, uint32_t edges)
{ {
E_Client *ec; E_Client *ec;
E_Comp_Data *cdata;
E_Binding_Event_Mouse_Button ev; E_Binding_Event_Mouse_Button ev;
/* DBG("XDG_SHELL: Surface Resize: %d\tEdges: %d", */ /* DBG("XDG_SHELL: Surface Resize: %d\tEdges: %d", */
@ -787,13 +779,12 @@ _e_xdg_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_r
if ((ec->maximized) || (ec->fullscreen)) return; if ((ec->maximized) || (ec->fullscreen)) return;
cdata = e_comp->wl_comp_data; e_comp->wl_comp_data->resize.resource = resource;
cdata->resize.resource = resource; e_comp->wl_comp_data->resize.edges = edges;
cdata->resize.edges = edges; e_comp->wl_comp_data->ptr.grab_x = e_comp->wl_comp_data->ptr.x - wl_fixed_from_int(ec->client.x);
cdata->ptr.grab_x = cdata->ptr.x - wl_fixed_from_int(ec->client.x); e_comp->wl_comp_data->ptr.grab_y = e_comp->wl_comp_data->ptr.y - wl_fixed_from_int(ec->client.y);
cdata->ptr.grab_y = cdata->ptr.y - wl_fixed_from_int(ec->client.y);
switch (cdata->ptr.button) switch (e_comp->wl_comp_data->ptr.button)
{ {
case BTN_LEFT: case BTN_LEFT:
ev.button = 1; ev.button = 1;
@ -805,13 +796,13 @@ _e_xdg_shell_surface_cb_resize(struct wl_client *client EINA_UNUSED, struct wl_r
ev.button = 3; ev.button = 3;
break; break;
default: default:
ev.button = cdata->ptr.button; ev.button = e_comp->wl_comp_data->ptr.button;
break; break;
} }
e_comp_object_frame_xy_unadjust(ec->frame, e_comp_object_frame_xy_unadjust(ec->frame,
wl_fixed_to_int(cdata->ptr.x), wl_fixed_to_int(e_comp->wl_comp_data->ptr.x),
wl_fixed_to_int(cdata->ptr.y), wl_fixed_to_int(e_comp->wl_comp_data->ptr.y),
&ev.canvas.x, &ev.canvas.y); &ev.canvas.x, &ev.canvas.y);
_e_shell_surface_mouse_down_helper(ec, &ev, EINA_FALSE); _e_shell_surface_mouse_down_helper(ec, &ev, EINA_FALSE);
@ -1364,8 +1355,6 @@ E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Desktop_Shell" };
E_API void * E_API void *
e_modapi_init(E_Module *m) e_modapi_init(E_Module *m)
{ {
E_Comp_Data *cdata;
/* try to get the current compositor */ /* try to get the current compositor */
if (!e_comp) return NULL; if (!e_comp) return NULL;
@ -1373,19 +1362,19 @@ e_modapi_init(E_Module *m)
/* if (e_comp->comp_type != E_PIXMAP_TYPE_WL) return NULL; */ /* if (e_comp->comp_type != E_PIXMAP_TYPE_WL) return NULL; */
/* try to get the compositor data */ /* try to get the compositor data */
if (!(cdata = e_comp->wl_comp_data)) return NULL; if (!e_comp->wl_comp_data) return NULL;
/* try to create global shell interface */ /* try to create global shell interface */
if (!wl_global_create(cdata->wl.disp, &wl_shell_interface, 1, if (!wl_global_create(e_comp->wl_comp_data->wl.disp, &wl_shell_interface, 1,
cdata, _e_shell_cb_bind)) e_comp->wl_comp_data, _e_shell_cb_bind))
{ {
ERR("Could not create shell global: %m"); ERR("Could not create shell global: %m");
return NULL; return NULL;
} }
/* try to create global xdg_shell interface */ /* try to create global xdg_shell interface */
if (!wl_global_create(cdata->wl.disp, &xdg_shell_interface, 1, if (!wl_global_create(e_comp->wl_comp_data->wl.disp, &xdg_shell_interface, 1,
cdata, _e_xdg_shell_cb_bind)) e_comp->wl_comp_data, _e_xdg_shell_cb_bind))
{ {
ERR("Could not create xdg_shell global: %m"); ERR("Could not create xdg_shell global: %m");
return NULL; return NULL;