From 2603f3d7a1b1ef4a08159851fbe4555651e0dafd Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Mon, 12 Nov 2012 14:41:30 +0000 Subject: [PATCH] Kick the Wayland support for E Compositor back into build shape. NB: Builds again now, but does not Yet render wayland clients...soon ;) Signed-off-by: Christopher Michael SVN revision: 79164 --- src/modules/comp/e_mod_comp.c | 16 +- src/modules/comp/e_mod_comp_wl.c | 98 ++++++------ src/modules/comp/e_mod_comp_wl.h | 6 +- src/modules/comp/e_mod_comp_wl_comp.c | 196 ++++++++++++----------- src/modules/comp/e_mod_comp_wl_comp.h | 2 +- src/modules/comp/e_mod_comp_wl_input.c | 167 ++++++++++++++++--- src/modules/comp/e_mod_comp_wl_surface.c | 48 +++++- src/modules/comp/e_mod_comp_wl_surface.h | 1 + 8 files changed, 356 insertions(+), 178 deletions(-) diff --git a/src/modules/comp/e_mod_comp.c b/src/modules/comp/e_mod_comp.c index fdd8f2a2e..c4a9cbb68 100644 --- a/src/modules/comp/e_mod_comp.c +++ b/src/modules/comp/e_mod_comp.c @@ -585,10 +585,10 @@ _e_mod_comp_win_update(E_Comp_Win *cw) { Ecore_X_Pixmap pm = 0; -#ifdef HAVE_WAYLAND_CLIENTS - if ((cw->bd) && (cw->bd->borderless)) - pm = e_mod_comp_wl_pixmap_get(cw->win); -#endif +/* #ifdef HAVE_WAYLAND_CLIENTS */ +/* if ((cw->bd) && (cw->bd->borderless)) */ +/* pm = e_mod_comp_wl_pixmap_get(cw->win); */ +/* #endif */ if (!pm) pm = ecore_x_composite_name_window_pixmap_get(cw->win); if (pm) { @@ -2238,10 +2238,10 @@ _e_mod_comp_win_show(E_Comp_Win *cw) { // we redirect all subwindows anyway // ecore_x_composite_redirect_window(cw->win, ECORE_X_COMPOSITE_UPDATE_MANUAL); -#ifdef HAVE_WAYLAND_CLIENTS - if ((cw->bd) && (cw->bd->borderless)) - cw->pixmap = e_mod_comp_wl_pixmap_get(cw->win); -#endif +/* #ifdef HAVE_WAYLAND_CLIENTS */ +/* if ((cw->bd) && (cw->bd->borderless)) */ +/* cw->pixmap = e_mod_comp_wl_pixmap_get(cw->win); */ +/* #endif */ if (!cw->pixmap) cw->pixmap = ecore_x_composite_name_window_pixmap_get(cw->win); if (cw->pixmap) diff --git a/src/modules/comp/e_mod_comp_wl.c b/src/modules/comp/e_mod_comp_wl.c index d0516eb7e..6e6609195 100644 --- a/src/modules/comp/e_mod_comp_wl.c +++ b/src/modules/comp/e_mod_comp_wl.c @@ -10,7 +10,7 @@ #endif /* local function prototypes */ -static Eina_Bool _e_mod_comp_wl_fd_handle(void *data, Ecore_Fd_Handler *hdl __UNUSED__); +static Eina_Bool _e_mod_comp_wl_fd_handle(void *data, Ecore_Fd_Handler *hdl); /* private variables */ static Ecore_Fd_Handler *_wl_fd_handler = NULL; @@ -82,7 +82,7 @@ e_mod_comp_wl_init(void) fd = wl_event_loop_get_fd(loop); _wl_fd_handler = - ecore_main_fd_handler_add(fd, ECORE_FD_READ, + ecore_main_fd_handler_add(fd, ECORE_FD_READ,// | ECORE_FD_WRITE, _e_mod_comp_wl_fd_handle, NULL, NULL, NULL); wl_event_loop_dispatch(loop, 0); @@ -120,73 +120,73 @@ e_mod_comp_wl_time_get(void) Ecore_X_Pixmap e_mod_comp_wl_pixmap_get(Ecore_X_Window win) { - Wayland_Compositor *comp; - Wayland_Surface *ws; -// struct wl_list *list; + /* Wayland_Compositor *comp; */ + /* Wayland_Surface *ws; */ Ecore_X_Pixmap pmap = 0; - LOGFN(__FILE__, __LINE__, __FUNCTION__); + /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */ - comp = e_mod_comp_wl_comp_get(); - if (wl_list_empty(&comp->surfaces)) return 0; + /* comp = e_mod_comp_wl_comp_get(); */ + /* if (wl_list_empty(&comp->surfaces)) return 0; */ -// list = &comp->surfaces; - wl_list_for_each(ws, &comp->surfaces, link) - { - if (!ws->buffer) continue; - if (((ws->win) && (ws->win->border)) - && (ws->win->border->win == win)) - { - Ecore_X_Connection *conn; - Ecore_X_GC gc; - uint8_t *pix = 0; - int depth; + /* wl_list_for_each(ws, &comp->surfaces, link) */ + /* { */ + /* if (!ws->buffer) continue; */ + /* if (((ws->win) && (ws->win->border)) */ + /* && (ws->win->border->win == win)) */ + /* { */ + /* Ecore_X_Connection *conn; */ + /* xcb_gc_t gc; */ + /* uint8_t *pix = 0; */ + /* int depth; */ - if (ws->buffer) - { - if (wl_buffer_is_shm(ws->buffer)) - pix = (uint8_t *)wl_shm_buffer_get_data(ws->buffer); - else - { - if (ws->texture) pix = (uint8_t *)ws->texture; - else if (ws->saved_texture) - pix = (uint8_t *)ws->saved_texture; - } - } - else if (ws->image) - { - if (ws->texture) pix = (uint8_t *)ws->texture; - else if (ws->saved_texture) - pix = (uint8_t *)ws->saved_texture; - } + /* if (ws->buffer) */ + /* { */ + /* if (wl_buffer_is_shm(ws->buffer)) */ + /* pix = (uint8_t *)wl_shm_buffer_get_data(ws->buffer); */ + /* else */ + /* { */ + /* if (ws->texture) pix = (uint8_t *)ws->texture; */ + /* else if (ws->saved_texture) */ + /* pix = (uint8_t *)ws->saved_texture; */ + /* } */ + /* } */ + /* else if (ws->image) */ + /* { */ + /* if (ws->texture) pix = (uint8_t *)ws->texture; */ + /* else if (ws->saved_texture) */ + /* pix = (uint8_t *)ws->saved_texture; */ + /* } */ - if (!pix) return 0; + /* if (!pix) return 0; */ - depth = ecore_x_window_depth_get(win); - conn = ecore_x_connection_get(); + /* depth = ecore_x_window_depth_get(win); */ + /* conn = ecore_x_connection_get(); */ - pmap = xcb_generate_id(conn); - xcb_create_pixmap(conn, depth, pmap, win, ws->w, ws->h); + /* pmap = xcb_generate_id(conn); */ + /* xcb_create_pixmap(conn, depth, pmap, win, ws->w, ws->h); */ - gc = ecore_x_gc_new(pmap, 0, NULL); - xcb_put_image(conn, 2, pmap, gc, ws->w, ws->h, - 0, 0, 0, depth, - (ws->w * ws->h * sizeof(int)), pix); - ecore_x_gc_free(gc); - } - } + /* gc = xcb_generate_id(conn); */ + /* xcb_put_image(conn, 2, pmap, gc, ws->w, ws->h, */ + /* 0, 0, 0, depth, */ + /* (ws->w * ws->h * sizeof(int)), pix); */ + /* xcb_free_gc(conn, gc); */ + /* xcb_free_pixmap(conn, pmap); */ + /* } */ + /* } */ return pmap; } /* local functions */ static Eina_Bool -_e_mod_comp_wl_fd_handle(void *data __UNUSED__, Ecore_Fd_Handler *hdl __UNUSED__) +_e_mod_comp_wl_fd_handle(void *data __UNUSED__, Ecore_Fd_Handler *hdl) { struct wl_event_loop *loop; loop = wl_display_get_event_loop(_wl_disp); wl_event_loop_dispatch(loop, 0); + return ECORE_CALLBACK_RENEW; } diff --git a/src/modules/comp/e_mod_comp_wl.h b/src/modules/comp/e_mod_comp_wl.h index 7444705fc..98cd0b729 100644 --- a/src/modules/comp/e_mod_comp_wl.h +++ b/src/modules/comp/e_mod_comp_wl.h @@ -19,6 +19,10 @@ # define LOGFN(fl, ln, fn) # endif +#define container_of(ptr, type, member) ({ \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + typedef enum _Wayland_Visual Wayland_Visual; typedef enum _Wayland_Shell_Surface_Type Wayland_Shell_Surface_Type; typedef struct _Wayland_Frame_Callback Wayland_Frame_Callback; @@ -151,7 +155,7 @@ struct _Wayland_Output struct _Wayland_Input { - struct wl_input_device input_device; + struct wl_seat seat; int32_t hotspot_x, hotspot_y; struct wl_list link; uint32_t modifier_state; diff --git a/src/modules/comp/e_mod_comp_wl_comp.c b/src/modules/comp/e_mod_comp_wl_comp.c index c5fa3d3d4..b1be19fb2 100644 --- a/src/modules/comp/e_mod_comp_wl_comp.c +++ b/src/modules/comp/e_mod_comp_wl_comp.c @@ -33,7 +33,7 @@ static void _e_mod_comp_wl_comp_surface_create(struct wl_client *cli static void _e_mod_comp_wl_comp_region_create(struct wl_client *client, struct wl_resource *resource, unsigned int id); static void _e_mod_comp_wl_comp_region_destroy(struct wl_resource *resource); static Eina_Bool _e_mod_comp_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event); -static Eina_Bool _e_mod_comp_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event); +static Eina_Bool _e_mod_comp_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__); static Eina_Bool _e_mod_comp_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event); static Eina_Bool _e_mod_comp_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event); static Eina_Bool _e_mod_comp_wl_cb_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event); @@ -58,7 +58,8 @@ static const struct wl_surface_interface _wl_surface_interface = e_mod_comp_wl_surface_damage, e_mod_comp_wl_surface_frame, e_mod_comp_wl_surface_set_opaque_region, - e_mod_comp_wl_surface_set_input_region + e_mod_comp_wl_surface_set_input_region, + e_mod_comp_wl_surface_commit }; static const struct wl_region_interface _wl_region_interface = { @@ -191,28 +192,31 @@ e_mod_comp_wl_comp_get(void) } void -e_mod_comp_wl_comp_repick(struct wl_input_device *device, uint32_t timestamp __UNUSED__) +e_mod_comp_wl_comp_repick(struct wl_seat *seat, uint32_t timestamp __UNUSED__) { Wayland_Surface *ws, *focus; + struct wl_pointer *pointer; + + if (!(pointer = seat->pointer)) return; ws = - _e_mod_comp_wl_comp_pick_surface(device->x, device->y, - &device->current_x, &device->current_y); + _e_mod_comp_wl_comp_pick_surface(pointer->x, pointer->y, + &pointer->current_x, &pointer->current_y); if (!ws) return; - if (&ws->surface != device->current) + if (&ws->surface != pointer->current) { const struct wl_pointer_grab_interface *interface; - interface = device->pointer_grab->interface; - interface->focus(device->pointer_grab, &ws->surface, - device->current_x, device->current_y); - device->current = &ws->surface; + interface = pointer->grab->interface; + pointer->current = &ws->surface; + interface->focus(pointer->grab, &ws->surface, + pointer->current_x, pointer->current_y); } - if ((focus = (Wayland_Surface *)device->pointer_grab->focus)) + if ((focus = (Wayland_Surface *)pointer->grab->focus)) { - device->pointer_grab->x = device->x - focus->x; - device->pointer_grab->y = device->y - focus->y; + pointer->grab->x = pointer->x - focus->x; + pointer->grab->y = pointer->y - focus->y; } } @@ -388,7 +392,6 @@ _e_mod_comp_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *eve Wayland_Input *input; Wayland_Surface *ws; Ecore_X_Event_Window_Focus_In *ev; - uint32_t timestamp; // LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -401,10 +404,8 @@ _e_mod_comp_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *eve if (((ws->win) && (ws->win->border)) && (ws->win->border->win == ev->win)) { - timestamp = e_mod_comp_wl_time_get(); - wl_input_device_set_keyboard_focus(&input->input_device, - &ws->surface); - wl_data_device_set_keyboard_focus(&input->input_device); + wl_keyboard_set_focus(input->seat.keyboard, &ws->surface); + wl_data_device_set_keyboard_focus(&input->seat); break; } } @@ -413,19 +414,17 @@ _e_mod_comp_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *eve } static Eina_Bool -_e_mod_comp_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event) +_e_mod_comp_wl_cb_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) { Wayland_Input *input; - Ecore_X_Event_Window_Focus_Out *ev; - uint32_t timestamp; + /* Ecore_X_Event_Window_Focus_Out *ev; */ // LOGFN(__FILE__, __LINE__, __FUNCTION__); - ev = event; + /* ev = event; */ input = e_mod_comp_wl_input_get(); - timestamp = e_mod_comp_wl_time_get(); - wl_input_device_set_keyboard_focus(&input->input_device, NULL); - wl_data_device_set_keyboard_focus(&input->input_device); + wl_keyboard_set_focus(input->seat.keyboard, NULL); + wl_data_device_set_keyboard_focus(&input->seat); return ECORE_CALLBACK_PASS_ON; } @@ -436,17 +435,20 @@ _e_mod_comp_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *eve Wayland_Input *input; Ecore_X_Event_Mouse_In *ev; uint32_t timestamp; + struct wl_pointer *ptr; // LOGFN(__FILE__, __LINE__, __FUNCTION__); ev = event; if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON; input = e_mod_comp_wl_input_get(); - input->input_device.x = ev->x; - input->input_device.y = ev->y; + + ptr = input->seat.pointer; + ptr->x = ev->x; + ptr->y = ev->y; timestamp = e_mod_comp_wl_time_get(); - e_mod_comp_wl_comp_repick(&input->input_device, timestamp); + e_mod_comp_wl_comp_repick(&input->seat, timestamp); return ECORE_CALLBACK_PASS_ON; } @@ -465,7 +467,7 @@ _e_mod_comp_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *ev input = e_mod_comp_wl_input_get(); timestamp = e_mod_comp_wl_time_get(); - e_mod_comp_wl_comp_repick(&input->input_device, timestamp); + e_mod_comp_wl_comp_repick(&input->seat, timestamp); return ECORE_CALLBACK_PASS_ON; } @@ -475,9 +477,9 @@ _e_mod_comp_wl_cb_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *e { Wayland_Input *input; Ecore_Event_Mouse_Move *ev; - struct wl_input_device *device; const struct wl_pointer_grab_interface *interface; uint32_t timestamp; + struct wl_pointer *ptr; // LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -485,16 +487,18 @@ _e_mod_comp_wl_cb_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *e if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON; input = e_mod_comp_wl_input_get(); - device = &input->input_device; - device->x = ev->x; - device->y = ev->y; + + ptr = input->seat.pointer; + ptr->x = ev->x; + ptr->y = ev->y; timestamp = e_mod_comp_wl_time_get(); - e_mod_comp_wl_comp_repick(device, timestamp); + e_mod_comp_wl_comp_repick(&input->seat, timestamp); - interface = device->pointer_grab->interface; - interface->motion(device->pointer_grab, timestamp, - device->pointer_grab->x, device->pointer_grab->y); + interface = ptr->grab->interface; + interface->motion(ptr->grab, timestamp, ptr->grab->x, ptr->grab->y); + + /* TODO: handle sprite */ return ECORE_CALLBACK_PASS_ON; } @@ -504,7 +508,7 @@ _e_mod_comp_wl_cb_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *e { Wayland_Input *input; Ecore_Event_Mouse_Button *ev; - struct wl_input_device *device; + struct wl_pointer *ptr; int btn = 0; uint32_t timestamp; @@ -529,21 +533,24 @@ _e_mod_comp_wl_cb_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *e } input = e_mod_comp_wl_input_get(); - device = &input->input_device; + ptr = input->seat.pointer; timestamp = e_mod_comp_wl_time_get(); - if (device->button_count == 0) + if (ptr->button_count == 0) { - device->grab_button = btn; - device->grab_time = timestamp; - device->grab_x = device->x; - device->grab_y = device->y; + ptr->grab_button = btn; + ptr->grab_time = timestamp; + ptr->grab_x = ptr->x; + ptr->grab_y = ptr->y; } - device->button_count++; + ptr->button_count++; /* TODO: Run binding ?? */ - device->pointer_grab->interface->button(device->pointer_grab, - timestamp, btn, 1); + + ptr->grab->interface->button(ptr->grab, timestamp, btn, 1); + + if (ptr->button_count == 1) + ptr->grab_serial = wl_display_get_serial(_wl_disp); return ECORE_CALLBACK_PASS_ON; } @@ -553,7 +560,7 @@ _e_mod_comp_wl_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *eve { Wayland_Input *input; Ecore_Event_Mouse_Button *ev; - struct wl_input_device *device; + struct wl_pointer *ptr; int btn = 0; uint32_t timestamp; @@ -578,14 +585,15 @@ _e_mod_comp_wl_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *eve } input = e_mod_comp_wl_input_get(); - device = &input->input_device; - - device->button_count--; + ptr = input->seat.pointer; + ptr->button_count--; /* TODO: Run binding ?? */ timestamp = e_mod_comp_wl_time_get(); - device->pointer_grab->interface->button(device->pointer_grab, - timestamp, btn, 0); + ptr->grab->interface->button(ptr->grab, timestamp, btn, 0); + + if (ptr->button_count == 1) + ptr->grab_serial = wl_display_get_serial(_wl_disp); return ECORE_CALLBACK_PASS_ON; } @@ -593,37 +601,37 @@ _e_mod_comp_wl_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *eve static Eina_Bool _e_mod_comp_wl_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) { - Wayland_Input *input; - Ecore_Event_Key *ev; - struct wl_input_device *device; - uint32_t *k, *end, key = 0; - uint32_t timestamp; + /* Wayland_Input *input; */ + /* Ecore_Event_Key *ev; */ + /* struct wl_keyboard *kbd; */ + /* uint32_t *k, *end, key = 0; */ + /* uint32_t timestamp; */ // LOGFN(__FILE__, __LINE__, __FUNCTION__); - ev = event; - if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON; + /* ev = event; */ + /* if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON; */ - input = e_mod_comp_wl_input_get(); - device = &input->input_device; - timestamp = e_mod_comp_wl_time_get(); + /* input = e_mod_comp_wl_input_get(); */ + /* kbd = input->seat.keyboard; */ + /* timestamp = e_mod_comp_wl_time_get(); */ - key = ecore_x_keysym_keycode_get(ev->key); + /* key = ecore_x_keysym_keycode_get(ev->key); */ - input->modifier_state = 0; - _e_mod_comp_wl_comp_update_modifier(input, key, 1); + /* input->modifier_state = 0; */ + /* _e_mod_comp_wl_comp_update_modifier(input, key, 1); */ - end = device->keys.data + device->keys.size; - for (k = device->keys.data; k < end; k++) - if (*k == key) *k = *--end; - device->keys.size = (void *)end - device->keys.data; + /* end = kbd->keys.data + kbd->keys.size; */ + /* for (k = kbd->keys.data; k < end; k++) */ + /* if (*k == key) *k = *--end; */ + /* kbd->keys.size = (void *)end - kbd->keys.data; */ - k = wl_array_add(&device->keys, sizeof(*k)); - *k = key; + /* k = wl_array_add(&kbd->keys, sizeof(*k)); */ + /* *k = key; */ - if (device->keyboard_focus_resource) - wl_resource_post_event(device->keyboard_focus_resource, - WL_INPUT_DEVICE_KEY, timestamp, key, 1); + /* if (kbd->keyboard_focus_resource) */ + /* wl_resource_post_event(device->keyboard_focus_resource, */ + /* WL_INPUT_DEVICE_KEY, timestamp, key, 1); */ return ECORE_CALLBACK_PASS_ON; } @@ -631,36 +639,36 @@ _e_mod_comp_wl_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *eve static Eina_Bool _e_mod_comp_wl_cb_key_up(void *data __UNUSED__, int type __UNUSED__, void *event) { - Wayland_Input *input; - Ecore_Event_Key *ev; - struct wl_input_device *device; - uint32_t *k, *end, key = 0; - uint32_t timestamp; + /* Wayland_Input *input; */ + /* Ecore_Event_Key *ev; */ + /* struct wl_input_device *device; */ + /* uint32_t *k, *end, key = 0; */ + /* uint32_t timestamp; */ // LOGFN(__FILE__, __LINE__, __FUNCTION__); - ev = event; - if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON; + /* ev = event; */ + /* if (wl_list_empty(&_wl_comp->surfaces)) return ECORE_CALLBACK_PASS_ON; */ - input = e_mod_comp_wl_input_get(); - device = &input->input_device; - timestamp = e_mod_comp_wl_time_get(); + /* input = e_mod_comp_wl_input_get(); */ + /* device = &input->input_device; */ + /* timestamp = e_mod_comp_wl_time_get(); */ - key = ecore_x_keysym_keycode_get(ev->key); + /* key = ecore_x_keysym_keycode_get(ev->key); */ - _e_mod_comp_wl_comp_update_modifier(input, key, 0); + /* _e_mod_comp_wl_comp_update_modifier(input, key, 0); */ - end = device->keys.data + device->keys.size; - for (k = device->keys.data; k < end; k++) - if (*k == key) *k = *--end; - device->keys.size = (void *)end - device->keys.data; + /* end = device->keys.data + device->keys.size; */ + /* for (k = device->keys.data; k < end; k++) */ + /* if (*k == key) *k = *--end; */ + /* device->keys.size = (void *)end - device->keys.data; */ /* k = wl_array_add(&device->keys, sizeof(*k)); */ /* *k = ev->key; */ - if (device->keyboard_focus_resource) - wl_resource_post_event(device->keyboard_focus_resource, - WL_INPUT_DEVICE_KEY, timestamp, key, 0); + /* if (device->keyboard_focus_resource) */ + /* wl_resource_post_event(device->keyboard_focus_resource, */ + /* WL_INPUT_DEVICE_KEY, timestamp, key, 0); */ return ECORE_CALLBACK_PASS_ON; } diff --git a/src/modules/comp/e_mod_comp_wl_comp.h b/src/modules/comp/e_mod_comp_wl_comp.h index 6fa41a803..769511648 100644 --- a/src/modules/comp/e_mod_comp_wl_comp.h +++ b/src/modules/comp/e_mod_comp_wl_comp.h @@ -6,7 +6,7 @@ Eina_Bool e_mod_comp_wl_comp_init(void); void e_mod_comp_wl_comp_shutdown(void); Wayland_Compositor *e_mod_comp_wl_comp_get(void); -void e_mod_comp_wl_comp_repick(struct wl_input_device *device, uint32_t timestamp); +void e_mod_comp_wl_comp_repick(struct wl_seat *seat, uint32_t timestamp); # endif #endif diff --git a/src/modules/comp/e_mod_comp_wl_input.c b/src/modules/comp/e_mod_comp_wl_input.c index 1afd60e39..cfd27007c 100644 --- a/src/modules/comp/e_mod_comp_wl_input.c +++ b/src/modules/comp/e_mod_comp_wl_input.c @@ -8,12 +8,22 @@ /* local function prototypes */ static void _e_mod_comp_wl_input_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id); static void _e_mod_comp_wl_input_unbind(struct wl_resource *resource); -static void _e_mod_comp_wl_input_attach(struct wl_client *client, struct wl_resource *resource, uint32_t serial, struct wl_resource *buffer_resource __UNUSED__, int32_t x, int32_t y); +static void _e_mod_comp_wl_input_pointer_get(struct wl_client *client, struct wl_resource *resource, unsigned int id); +static void _e_mod_comp_wl_input_keyboard_get(struct wl_client *client, struct wl_resource *resource, unsigned int id); +static void _e_mod_comp_wl_input_touch_get(struct wl_client *client, struct wl_resource *resource, unsigned int id); +static void _e_mod_comp_wl_input_pointer_cursor_set(struct wl_client *client, struct wl_resource *resource, unsigned int serial, struct wl_resource *surface_resource, int x, int y); /* wayland interfaces */ -static const struct wl_input_device_interface _wl_input_interface = +static const struct wl_seat_interface _wl_seat_interface = { - _e_mod_comp_wl_input_attach, + _e_mod_comp_wl_input_pointer_get, + _e_mod_comp_wl_input_keyboard_get, + _e_mod_comp_wl_input_touch_get +}; + +static const struct wl_pointer_interface _wl_pointer_interface = +{ + _e_mod_comp_wl_input_pointer_cursor_set }; /* private variables */ @@ -32,8 +42,8 @@ e_mod_comp_wl_input_init(void) memset(_wl_input, 0, sizeof(*_wl_input)); - wl_input_device_init(&_wl_input->input_device); - if (!wl_display_add_global(_wl_disp, &wl_input_device_interface, _wl_input, + wl_seat_init(&_wl_input->seat); + if (!wl_display_add_global(_wl_disp, &wl_seat_interface, _wl_input, _e_mod_comp_wl_input_bind)) { EINA_LOG_ERR("Failed to add input to wayland\n"); @@ -53,7 +63,7 @@ e_mod_comp_wl_input_shutdown(void) LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!_wl_input) return; - wl_input_device_release(&_wl_input->input_device); + wl_seat_release(&_wl_input->seat); free(_wl_input); } @@ -67,17 +77,27 @@ e_mod_comp_wl_input_get(void) static void _e_mod_comp_wl_input_bind(struct wl_client *client, void *data, uint32_t version __UNUSED__, uint32_t id) { - struct wl_input_device *device; + Wayland_Input *input; + struct wl_seat *device; struct wl_resource *resource; + enum wl_seat_capability caps = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); - device = data; + input = data; + device = &input->seat; + resource = - wl_client_add_object(client, &wl_input_device_interface, - &_wl_input_interface, id, data); - wl_list_insert(&device->resource_list, &resource->link); + wl_client_add_object(client, &wl_seat_interface, + &_wl_seat_interface, id, data); + wl_list_insert(&device->base_resource_list, &resource->link); resource->destroy = _e_mod_comp_wl_input_unbind; + + if (device->pointer) caps |= WL_SEAT_CAPABILITY_POINTER; + if (device->keyboard) caps |= WL_SEAT_CAPABILITY_KEYBOARD; + if (device->touch) caps |= WL_SEAT_CAPABILITY_TOUCH; + + wl_seat_send_capabilities(resource, caps); } static void @@ -89,18 +109,127 @@ _e_mod_comp_wl_input_unbind(struct wl_resource *resource) free(resource); } -static void -_e_mod_comp_wl_input_attach(struct wl_client *client, struct wl_resource *resource, uint32_t serial, struct wl_resource *buffer_resource __UNUSED__, int32_t x, int32_t y) +static void +_e_mod_comp_wl_input_pointer_get(struct wl_client *client, struct wl_resource *resource, unsigned int id) { Wayland_Input *wi; + struct wl_resource *res; LOGFN(__FILE__, __LINE__, __FUNCTION__); - wi = resource->data; - if (serial < wi->input_device.pointer_focus_serial) return; - if (!wi->input_device.pointer_focus) return; - if (wi->input_device.pointer_focus->resource.client != client) return; - wi->hotspot_x = x; - wi->hotspot_y = y; + if (!(wi = resource->data)) return; + if (!wi->seat.pointer) return; + + res = wl_client_add_object(client, &wl_pointer_interface, + &_wl_pointer_interface, id, wi); + wl_list_insert(&wi->seat.pointer->resource_list, &res->link); + res->destroy = _e_mod_comp_wl_input_unbind; + + if ((wi->seat.pointer->focus) && + (wi->seat.pointer->focus->resource.client == client)) + { + /* TODO: surface_from_global_fixed ?? */ + + wl_pointer_set_focus(wi->seat.pointer, wi->seat.pointer->focus, + wi->seat.pointer->x, + wi->seat.pointer->y); + } } +static void +_e_mod_comp_wl_input_keyboard_get(struct wl_client *client, struct wl_resource *resource, unsigned int id) +{ + Wayland_Input *wi; + struct wl_resource *res; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + + if (!(wi = resource->data)) return; + if (!wi->seat.keyboard) return; + + res = wl_client_add_object(client, &wl_keyboard_interface, NULL, id, wi); + wl_list_insert(&wi->seat.keyboard->resource_list, &res->link); + res->destroy = _e_mod_comp_wl_input_unbind; + + /* TODO: wl_keyboard_send_keymap ?? */ + + if ((wi->seat.keyboard->focus) && + (wi->seat.keyboard->focus->resource.client == client)) + { + wl_keyboard_set_focus(wi->seat.keyboard, wi->seat.keyboard->focus); + } +} + +static void +_e_mod_comp_wl_input_touch_get(struct wl_client *client, struct wl_resource *resource, unsigned int id) +{ + Wayland_Input *wi; + struct wl_resource *res; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + + if (!(wi = resource->data)) return; + if (!wi->seat.touch) return; + + res = wl_client_add_object(client, &wl_touch_interface, NULL, id, wi); + wl_list_insert(&wi->seat.touch->resource_list, &res->link); + res->destroy = _e_mod_comp_wl_input_unbind; +} + +static void +_e_mod_comp_wl_input_pointer_cursor_set(struct wl_client *client, struct wl_resource *resource, unsigned int serial, struct wl_resource *surface_resource, int x, int y) +{ + /* Wayland_Input *wi; */ + /* Wayland_Surface *ws; */ + + /* if (!(wi = resource->data)) return; */ + /* if (!wi->seat.pointer->focus) return; */ + /* if (wi->seat.pointer->focus->resource.client != client) return; */ + + /* if (surface_resource) ws = surface_resource->data; */ + + /* if ((ws) && (ws != wi->sprite)) */ + /* { */ + /* if (ws->configure) */ + /* { */ + /* wl_resource_post_error(&ws->surface.resource, */ + /* WL_DISPLAY_ERROR_INVALID_OBJECT, */ + /* "Surface configure already set"); */ + /* return; */ + /* } */ + /* } */ + + /* TODO: Unmap sprite ? */ + + /* if (!ws) return; */ + + /* wl_signal_add(&ws->surface.resource.destroy_signal, */ + /* &wi->sprite_destroy_listener); */ + + /* ws->configure = ; */ + /* ws->private = seat; */ + /* wi->sprite = ws; */ + /* wi->hotspot_x = x; */ + /* wi->hotspot_y = y; */ + + /* if (ws->buffer) */ + /* { */ + /* TODO: cursor surface configure */ + /* } */ +} + +/* static void */ +/* _e_mod_comp_wl_input_attach(struct wl_client *client, struct wl_resource *resource, uint32_t serial, struct wl_resource *buffer_resource __UNUSED__, int32_t x, int32_t y) */ +/* { */ +/* Wayland_Input *wi; */ + +/* LOGFN(__FILE__, __LINE__, __FUNCTION__); */ + +/* wi = resource->data; */ +/* if (serial < wi->input_device.pointer_focus_serial) return; */ +/* if (!wi->input_device.pointer_focus) return; */ +/* if (wi->input_device.pointer_focus->resource.client != client) return; */ +/* wi->hotspot_x = x; */ +/* wi->hotspot_y = y; */ +/* } */ + diff --git a/src/modules/comp/e_mod_comp_wl_surface.c b/src/modules/comp/e_mod_comp_wl_surface.c index f6a7aaebd..d6ebd6039 100644 --- a/src/modules/comp/e_mod_comp_wl_surface.c +++ b/src/modules/comp/e_mod_comp_wl_surface.c @@ -181,7 +181,38 @@ e_mod_comp_wl_surface_set_input_region(struct wl_client *client __UNUSED__, stru pixman_region32_init_rect(&ws->input, 0, 0, ws->w, ws->h); input = e_mod_comp_wl_input_get(); - e_mod_comp_wl_comp_repick(&input->input_device, e_mod_comp_wl_time_get()); + e_mod_comp_wl_comp_repick(&input->seat, e_mod_comp_wl_time_get()); +} + +void +e_mod_comp_wl_surface_commit(struct wl_client *client, struct wl_resource *resource) +{ + Wayland_Surface *ws; + pixman_region32_t opaque; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + + if (!(ws = resource->data)) return; + + /* TODO: handle 'pending' ?? */ + + e_mod_comp_wl_surface_configure(ws, ws->x, ws->y, ws->w, ws->h); + e_mod_comp_wl_surface_damage_surface(ws); + + pixman_region32_init_rect(&opaque, 0, 0, ws->w, ws->h); + pixman_region32_intersect(&opaque, &opaque, &ws->opaque); + if (!pixman_region32_equal(&opaque, &ws->opaque)) + { + pixman_region32_copy(&ws->opaque, &opaque); + /* TODO: set dirty */ + } + pixman_region32_fini(&opaque); + + pixman_region32_fini(&ws->input); + pixman_region32_init_rect(&ws->input, 0, 0, ws->w, ws->h); + pixman_region32_intersect(&ws->input, &ws->input, &ws->input); + + wl_list_init(&ws->frame_callbacks); } void @@ -203,7 +234,7 @@ e_mod_comp_wl_surface_destroy_surface(struct wl_resource *resource) e_object_del(E_OBJECT(ws->win)); wl_list_remove(&ws->link); - e_mod_comp_wl_comp_repick(&input->input_device, e_mod_comp_wl_time_get()); + e_mod_comp_wl_comp_repick(&input->seat, e_mod_comp_wl_time_get()); if (ws->texture) glDeleteTextures(1, &ws->texture); @@ -274,8 +305,14 @@ e_mod_comp_wl_surface_activate(Wayland_Surface *ws, Wayland_Input *wi, uint32_t } _e_mod_comp_wl_surface_raise(ws); - wl_input_device_set_keyboard_focus(&wi->input_device, &ws->surface); - wl_data_device_set_keyboard_focus(&wi->input_device); + + if (wi->seat.keyboard) + { + wl_keyboard_set_focus(wi->seat.keyboard, &ws->surface); + wl_data_device_set_keyboard_focus(&wi->seat); + } + + /* TODO: emit activate signal ?? */ } void @@ -311,7 +348,7 @@ _e_mod_comp_wl_surface_raise(Wayland_Surface *ws) wl_list_remove(&ws->link); wl_list_insert(&comp->surfaces, &ws->link); - e_mod_comp_wl_comp_repick(&input->input_device, e_mod_comp_wl_time_get()); + e_mod_comp_wl_comp_repick(&input->seat, e_mod_comp_wl_time_get()); e_mod_comp_wl_surface_damage_surface(ws); } @@ -335,4 +372,3 @@ _e_mod_comp_wl_surface_frame_destroy_callback(struct wl_resource *resource) wl_list_remove(&cb->link); free(cb); } - diff --git a/src/modules/comp/e_mod_comp_wl_surface.h b/src/modules/comp/e_mod_comp_wl_surface.h index 208879be4..59084a91b 100644 --- a/src/modules/comp/e_mod_comp_wl_surface.h +++ b/src/modules/comp/e_mod_comp_wl_surface.h @@ -10,6 +10,7 @@ void e_mod_comp_wl_surface_damage(struct wl_client *client __UNUSED__, struct wl void e_mod_comp_wl_surface_frame(struct wl_client *client, struct wl_resource *resource, uint32_t callback); void e_mod_comp_wl_surface_set_opaque_region(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *region_resource); void e_mod_comp_wl_surface_set_input_region(struct wl_client *client __UNUSED__, struct wl_resource *resource, struct wl_resource *region_resource); +void e_mod_comp_wl_surface_commit(struct wl_client *client, struct wl_resource *resource); void e_mod_comp_wl_surface_destroy_surface(struct wl_resource *resource); void e_mod_comp_wl_surface_configure(Wayland_Surface *ws, int32_t x, int32_t y, int32_t width, int32_t height); void e_mod_comp_wl_surface_activate(Wayland_Surface *ws, Wayland_Input *wi, uint32_t timestamp);