From: devilhorns Date: Tue, 15 May 2012 11:58:21 +0000 (+0000) Subject: Ecore_Wayland: Update ecore_wayland to work with recent wayland git: X-Git-Tag: 2.0_alpha~25^2~114 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4718497d0deaa36fab5a0c0dbc062b0d0a2dc3d1;p=framework%2Fuifw%2Fecore.git Ecore_Wayland: Update ecore_wayland to work with recent wayland git: This commit also includes patch(s) from Robert Bradford for Supporting vertical/horizontal scrolling, and updates to wayland fixed point for input events. Fix ecore_wl_input to use new libxkbcommon api. Add new surface_enter/leave listener for ecore_wl_window. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@71107 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h index 1bc1705..2d4ac51 100644 --- a/src/lib/ecore_wayland/Ecore_Wayland.h +++ b/src/lib/ecore_wayland/Ecore_Wayland.h @@ -9,6 +9,7 @@ # include # include +# include # ifdef EAPI # undef EAPI @@ -49,6 +50,7 @@ typedef struct _Ecore_Wl_Event_Interfaces_Bound Ecore_Wl_Event_Interfaces_Bound; enum _Ecore_Wl_Window_Type { + ECORE_WL_WINDOW_TYPE_NONE, ECORE_WL_WINDOW_TYPE_TOPLEVEL, ECORE_WL_WINDOW_TYPE_FULLSCREEN, ECORE_WL_WINDOW_TYPE_MAXIMIZED, @@ -84,7 +86,16 @@ struct _Ecore_Wl_Display struct wl_list inputs; struct wl_list outputs; - struct xkb_desc *xkb; + struct + { + struct xkb_rule_names names; + struct xkb_context *context; + struct xkb_keymap *keymap; + struct xkb_state *state; + xkb_mod_mask_t control_mask; + xkb_mod_mask_t alt_mask; + xkb_mod_mask_t shift_mask; + } xkb; Ecore_Wl_Output *output; Ecore_Wl_Input *input; diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c index 9339bec..33d69e2 100644 --- a/src/lib/ecore_wayland/ecore_wl.c +++ b/src/lib/ecore_wayland/ecore_wl.c @@ -3,21 +3,6 @@ #endif #include - -/* FIXME: This gives BTN_LEFT/RIGHT/MIDDLE for linux systems ... - * What about other OSs ?? */ -#ifdef __linux__ -# include -#else -# define BTN_LEFT 0x110 -# define BTN_RIGHT 0x111 -# define BTN_MIDDLE 0x112 -# define BTN_SIDE 0x113 -# define BTN_EXTRA 0x114 -# define BTN_FORWARD 0x115 -# define BTN_BACK 0x116 -#endif - #include "ecore_wl_private.h" /* local function prototypes */ @@ -458,17 +443,29 @@ _ecore_wl_xkb_init(Ecore_Wl_Display *ewd) LOGFN(__FILE__, __LINE__, __FUNCTION__); - names.rules = "evdev"; - names.model = "evdev"; - names.layout = "us"; - names.variant = ""; - names.options = ""; + if (!(ewd->xkb.context = xkb_context_new(0))) + return EINA_FALSE; - if (!(ewd->xkb = xkb_compile_keymap_from_rules(&names))) - { - ERR("Failed to compile keymap"); - return EINA_FALSE; - } + memset(&names, 0, sizeof(names)); + + ewd->xkb.names = names; + ewd->xkb.names.rules = strdup("evdev"); + ewd->xkb.names.model = strdup("pc105"); + ewd->xkb.names.layout = strdup("us"); + + ewd->xkb.keymap = + xkb_map_new_from_names(ewd->xkb.context, &ewd->xkb.names, 0); + if (!ewd->xkb.keymap) return EINA_FALSE; + + if (!(ewd->xkb.state = xkb_state_new(ewd->xkb.keymap))) + return EINA_FALSE; + + ewd->xkb.control_mask = + 1 << xkb_map_mod_get_index(ewd->xkb.keymap, "Control"); + ewd->xkb.alt_mask = + 1 << xkb_map_mod_get_index(ewd->xkb.keymap, "Mod1"); + ewd->xkb.shift_mask = + 1 << xkb_map_mod_get_index(ewd->xkb.keymap, "Shift"); return EINA_TRUE; } @@ -478,6 +475,15 @@ _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - if (ewd->xkb) xkb_free_keymap(ewd->xkb); + xkb_state_unref(ewd->xkb.state); + xkb_map_unref(ewd->xkb.keymap); + xkb_context_unref(ewd->xkb.context); + + free((char *)ewd->xkb.names.rules); + free((char *)ewd->xkb.names.model); + free((char *)ewd->xkb.names.layout); + free((char *)ewd->xkb.names.variant); + free((char *)ewd->xkb.names.options); + return EINA_TRUE; } diff --git a/src/lib/ecore_wayland/ecore_wl_dnd.c b/src/lib/ecore_wayland/ecore_wl_dnd.c index ced46c1..39e4f1c 100644 --- a/src/lib/ecore_wayland/ecore_wl_dnd.c +++ b/src/lib/ecore_wayland/ecore_wl_dnd.c @@ -34,7 +34,7 @@ _ecore_wl_dnd_add(Ecore_Wl_Input *input, struct wl_data_device *data_device, uns } void -_ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer) +_ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *offer) { Ecore_Wl_Event_Dnd_Enter *event; Ecore_Wl_Input *input; @@ -57,8 +57,8 @@ _ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device __UNUSED__, u event->win = win->id; event->source = input->drag_source->input->keyboard_focus->id; - event->position.x = x; - event->position.y = y; + event->position.x = wl_fixed_to_int(x); + event->position.y = wl_fixed_to_int(y); event->num_types = input->drag_source->types.size; event->types = input->drag_source->types.data; @@ -81,7 +81,7 @@ _ecore_wl_dnd_leave(void *data, struct wl_data_device *data_device __UNUSED__) } void -_ecore_wl_dnd_motion(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, int x, int y) +_ecore_wl_dnd_motion(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, wl_fixed_t x, wl_fixed_t y) { Ecore_Wl_Event_Dnd_Position *event; Ecore_Wl_Input *input; @@ -90,15 +90,15 @@ _ecore_wl_dnd_motion(void *data, struct wl_data_device *data_device __UNUSED__, if (!(input = data)) return; - input->sx = x; - input->sy = y; + input->sx = wl_fixed_to_int(x); + input->sy = wl_fixed_to_int(y); if (!(event = calloc(1, sizeof(Ecore_Wl_Event_Dnd_Position)))) return; event->win = input->drag_source->input->pointer_focus->id; event->source = input->drag_source->input->keyboard_focus->id; - event->position.x = x; - event->position.y = y; + event->position.x = input->sx; + event->position.y = input->sy; ecore_event_add(ECORE_WL_EVENT_DND_POSITION, event, NULL, NULL); } diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c index 1a17d48..1627bc1 100644 --- a/src/lib/ecore_wayland/ecore_wl_input.c +++ b/src/lib/ecore_wayland/ecore_wl_input.c @@ -34,26 +34,30 @@ #endif /* Required for keysym names - in the future available in libxkbcommon */ -#include +//#include + +#define MOD_SHIFT_MASK 0x01 +#define MOD_ALT_MASK 0x02 +#define MOD_CONTROL_MASK 0x04 /* local function prototypes */ -static void _ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int sx, int sy); +static void _ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, wl_fixed_t sx, wl_fixed_t sy); static void _ecore_wl_input_cb_button(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state); static void _ecore_wl_input_cb_axis(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, unsigned int axis, int value); static void _ecore_wl_input_cb_key(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, unsigned int key, unsigned int state); -static void _ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, int sx, int sy); +static void _ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy); static void _ecore_wl_input_cb_pointer_leave(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface); -static void _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, struct wl_array *keys); +static void _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, struct wl_array *keys __UNUSED__); static void _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface); -static void _ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, int x, int y); +static void _ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, wl_fixed_t x, wl_fixed_t y); static void _ecore_wl_input_cb_touch_up(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, int id __UNUSED__); -static void _ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, int x, int y); +static void _ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, wl_fixed_t x, wl_fixed_t y); static void _ecore_wl_input_cb_touch_frame(void *data __UNUSED__, struct wl_input_device *input_device __UNUSED__); static void _ecore_wl_input_cb_touch_cancel(void *data __UNUSED__, struct wl_input_device *input_device __UNUSED__); static void _ecore_wl_input_cb_data_offer(void *data, struct wl_data_device *data_device, unsigned int id); -static void _ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer); +static void _ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *offer); static void _ecore_wl_input_cb_data_leave(void *data, struct wl_data_device *data_device); -static void _ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, int x, int y); +static void _ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, wl_fixed_t x, wl_fixed_t y); static void _ecore_wl_input_cb_data_drop(void *data, struct wl_data_device *data_device); static void _ecore_wl_input_cb_data_selection(void *data, struct wl_data_device *data_device, struct wl_data_offer *offer); @@ -66,7 +70,7 @@ static void _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, Ecore_Wl_Wind static void _ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int timestamp); static void _ecore_wl_input_mouse_wheel_send(Ecore_Wl_Input *input, unsigned int axis, int value, unsigned int timestamp); -static int _ecore_wl_input_keysym_to_string(unsigned int symbol, char *buffer, int len); +/* static int _ecore_wl_input_keysym_to_string(unsigned int symbol, char *buffer, int len); */ /* wayland interfaces */ static const struct wl_input_device_listener _ecore_wl_input_listener = @@ -173,7 +177,7 @@ _ecore_wl_input_pointer_xy_get(int *x, int *y) /* local functions */ static void -_ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int sx, int sy) +_ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, wl_fixed_t sx, wl_fixed_t sy) { Ecore_Wl_Input *input; @@ -184,8 +188,8 @@ _ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNU _pointer_x = sx; _pointer_y = sy; - input->sx = sx; - input->sy = sy; + input->sx = wl_fixed_to_int(sx); + input->sy = wl_fixed_to_int(sy); input->timestamp = timestamp; @@ -257,81 +261,87 @@ _ecore_wl_input_cb_axis(void *data, struct wl_input_device *input_device __UNUSE * Copyright 1985, 1987, 1998 The Open Group * */ -static int -_ecore_wl_input_keysym_to_string(unsigned int symbol, char *buffer, int len) -{ - unsigned long high_bytes; - unsigned char c; - - high_bytes = symbol >> 8; - if (!(len && - ((high_bytes == 0) || - ((high_bytes == 0xFF) && - (((symbol >= XK_BackSpace) && - (symbol <= XK_Clear)) || - (symbol == XK_Return) || - (symbol == XK_Escape) || - (symbol == XK_KP_Space) || - (symbol == XK_KP_Tab) || - (symbol == XK_KP_Enter) || - ((symbol >= XK_KP_Multiply) && - (symbol <= XK_KP_9)) || - (symbol == XK_KP_Equal) || - (symbol == XK_Delete)))))) - return 0; - - /* if X keysym, convert to ascii by grabbing low 7 bits */ - if (symbol == XK_KP_Space) - c = XK_space & 0x7F; /* patch encoding botch */ - else if (high_bytes == 0xFF) - c = symbol & 0x7F; - else - c = symbol & 0xFF; - - buffer[0] = c; - return 1; -} +/* static int */ +/* _ecore_wl_input_keysym_to_string(unsigned int symbol, char *buffer, int len) */ +/* { */ +/* unsigned long high_bytes; */ +/* unsigned char c; */ + +/* high_bytes = symbol >> 8; */ +/* if (!(len && */ +/* ((high_bytes == 0) || */ +/* ((high_bytes == 0xFF) && */ +/* (((symbol >= XK_BackSpace) && */ +/* (symbol <= XK_Clear)) || */ +/* (symbol == XK_Return) || */ +/* (symbol == XK_Escape) || */ +/* (symbol == XK_KP_Space) || */ +/* (symbol == XK_KP_Tab) || */ +/* (symbol == XK_KP_Enter) || */ +/* ((symbol >= XK_KP_Multiply) && */ +/* (symbol <= XK_KP_9)) || */ +/* (symbol == XK_KP_Equal) || */ +/* (symbol == XK_Delete)))))) */ +/* return 0; */ + +/* if (symbol == XK_KP_Space) */ +/* else if (high_bytes == 0xFF) */ +/* c = symbol & 0x7F; */ +/* else */ +/* c = symbol & 0xFF; */ + +/* buffer[0] = c; */ +/* return 1; */ +/* } */ static void _ecore_wl_input_cb_key(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state) { Ecore_Wl_Input *input; Ecore_Wl_Window *win; - unsigned int keysym, modified_keysym, level = 0; - char key[8], keyname[8], string[8]; + unsigned int code, num; + const xkb_keysym_t *syms; + xkb_keysym_t sym; + xkb_mod_mask_t mask; + char string[8], key[8], keyname[8]; Ecore_Event_Key *e; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!(input = data)) return; - - input->timestamp = timestamp; input->display->serial = serial; - win = input->keyboard_focus; + code = keycode + 8; + win = input->keyboard_focus; if ((!win) || (win->keyboard_device != input)) return; - /* FIXME: NB: I believe this should be min_key_code rather than 8, - * but weston code has it like this */ - keycode += 8; + num = xkb_key_get_syms(input->display->xkb.state, code, &syms); + xkb_state_update_key(input->display->xkb.state, code, + (state ? XKB_KEY_DOWN : XKB_KEY_UP)); + mask = xkb_state_serialize_mods(input->display->xkb.state, + (XKB_STATE_DEPRESSED | XKB_STATE_LATCHED)); + input->modifiers = 0; + if (mask & input->display->xkb.control_mask) + input->modifiers |= MOD_CONTROL_MASK; + if (mask & input->display->xkb.alt_mask) + input->modifiers |= MOD_ALT_MASK; + if (mask & input->display->xkb.shift_mask) + input->modifiers |= MOD_SHIFT_MASK; - if ((input->modifiers & XKB_COMMON_SHIFT_MASK) && - (XkbKeyGroupWidth(_ecore_wl_disp->xkb, keycode, 0) > 1)) - level = 1; + if (num == 1) sym = syms[0]; + else sym = XKB_KEY_NoSymbol; memset(key, 0, sizeof(key)); memset(keyname, 0, sizeof(keyname)); memset(string, 0, sizeof(string)); - modified_keysym = XkbKeySymEntry(_ecore_wl_disp->xkb, keycode, level, 0); - xkb_keysym_to_string(modified_keysym, key, sizeof(key)); - - keysym = XkbKeySymEntry(_ecore_wl_disp->xkb, keycode, 0, 0); - xkb_keysym_to_string(keysym, keyname, sizeof(keyname)); - /* TODO: Switch over to the libxkbcommon API when it is available */ - if (!_ecore_wl_input_keysym_to_string(modified_keysym, string, sizeof(string))) - string[0] = '\0'; + /* if (!_ecore_wl_input_keysym_to_string(sym, string, sizeof(string))) */ + /* string[0] = '\0'; */ + + xkb_keysym_get_name(sym, key, sizeof(key)); + xkb_keysym_get_name(sym, keyname, sizeof(keyname)); + xkb_keysym_get_name(sym, string, sizeof(string)); e = malloc(sizeof(Ecore_Event_Key) + strlen(keyname) + strlen(key) + strlen(string) + 3); @@ -342,6 +352,7 @@ _ecore_wl_input_cb_key(void *data, struct wl_input_device *input_device __UNUSED e->compose = e->string; strcpy((char *)e->keyname, keyname); + strcpy((char *)e->key, key); if (strlen (string)) strcpy((char *)e->string, string); @@ -351,27 +362,21 @@ _ecore_wl_input_cb_key(void *data, struct wl_input_device *input_device __UNUSED e->timestamp = timestamp; /* The Ecore_Event_Modifiers don't quite match the X mask bits */ - e->modifiers = 0; - if (input->modifiers & XKB_COMMON_SHIFT_MASK) - e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT; - if (input->modifiers & XKB_COMMON_CONTROL_MASK) - e->modifiers |= ECORE_EVENT_MODIFIER_CTRL; - if (input->modifiers & XKB_COMMON_MOD1_MASK) - e->modifiers |= ECORE_EVENT_MODIFIER_ALT; + e->modifiers = input->modifiers; if (state) ecore_event_add(ECORE_EVENT_KEY_DOWN, e, NULL, NULL); else ecore_event_add(ECORE_EVENT_KEY_UP, e, NULL, NULL); - if (state) - input->modifiers |= _ecore_wl_disp->xkb->map->modmap[keycode]; - else - input->modifiers &= ~_ecore_wl_disp->xkb->map->modmap[keycode]; + /* if (state) */ + /* input->modifiers |= _ecore_wl_disp->xkb->map->modmap[keycode]; */ + /* else */ + /* input->modifiers &= ~_ecore_wl_disp->xkb->map->modmap[keycode]; */ } static void -_ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, int sx, int sy) +_ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy) { Ecore_Wl_Input *input; Ecore_Wl_Window *win = NULL; @@ -388,8 +393,8 @@ _ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_devic input->timestamp = (tv.tv_sec * 1000 + tv.tv_usec / 1000); } - input->sx = sx; - input->sy = sy; + input->sx = wl_fixed_to_int(sx); + input->sy = wl_fixed_to_int(sy); input->display->serial = serial; input->pointer_enter_serial = serial; @@ -465,11 +470,10 @@ _ecore_wl_input_cb_pointer_leave(void *data, struct wl_input_device *input_devic } static void -_ecore_wl_input_cb_keyboard_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, struct wl_array *keys) +_ecore_wl_input_cb_keyboard_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, struct wl_surface *surface, struct wl_array *keys __UNUSED__) { Ecore_Wl_Input *input; Ecore_Wl_Window *win = NULL; - unsigned int *k, *end; LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -483,11 +487,6 @@ _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_input_device *input_devi input->timestamp = (tv.tv_sec * 1000 + tv.tv_usec / 1000); } - end = keys->data + keys->size; - input->modifiers = 0; - for (k = keys->data; k < end; k++) - input->modifiers |= _ecore_wl_disp->xkb->map->modmap[*k]; - input->display->serial = serial; if (!(win = wl_surface_get_user_data(surface))) return; @@ -529,7 +528,7 @@ _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_input_device *input_devi } static void -_ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, int x, int y) +_ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int serial, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, wl_fixed_t x, wl_fixed_t y) { Ecore_Wl_Input *input; @@ -542,8 +541,8 @@ _ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device _ /* input->timestamp = timestamp; */ input->display->serial = serial; input->button = 0; - input->sx = x; - input->sy = y; + input->sx = wl_fixed_to_int(x); + input->sy = wl_fixed_to_int(y); _ecore_wl_input_mouse_down_send(input, input->pointer_focus, timestamp); } @@ -565,7 +564,7 @@ _ecore_wl_input_cb_touch_up(void *data, struct wl_input_device *input_device __U } static void -_ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, int x, int y) +_ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, wl_fixed_t x, wl_fixed_t y) { Ecore_Wl_Input *input; @@ -576,8 +575,8 @@ _ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device /* FIXME: NB: Not sure yet if input->timestamp should be set here. * This needs to be tested with an actual touch device */ /* input->timestamp = timestamp; */ - input->sx = x; - input->sy = y; + input->sx = wl_fixed_to_int(x); + input->sy = wl_fixed_to_int(y); _ecore_wl_input_mouse_move_send(input, input->pointer_focus, timestamp); } @@ -603,7 +602,7 @@ _ecore_wl_input_cb_data_offer(void *data, struct wl_data_device *data_device, un } static void -_ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer) +_ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *offer) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -619,7 +618,7 @@ _ecore_wl_input_cb_data_leave(void *data, struct wl_data_device *data_device) } static void -_ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, int x, int y) +_ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, wl_fixed_t x, wl_fixed_t y) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -765,6 +764,7 @@ _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, uns ev->y = input->sy; /* ev->root.x = input->sx; */ /* ev->root.y = input->sy; */ + printf("Input Modifiers: %d\n", input->modifiers); ev->modifiers = input->modifiers; /* FIXME: Need to get these from wayland somehow */ @@ -848,12 +848,13 @@ _ecore_wl_input_mouse_wheel_send(Ecore_Wl_Input *input, unsigned int axis, int v if (axis == WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL) { - ev->direction = value; - ev->z = 1; + ev->direction = 0; + ev->z = -value; } else if (axis == WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL) { - /* TODO: handle horizontal scroll */ + ev->direction = 1; + ev->z = -value; } if (input->grab) diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h index 75b562c..c8da8a1 100644 --- a/src/lib/ecore_wayland/ecore_wl_private.h +++ b/src/lib/ecore_wayland/ecore_wl_private.h @@ -2,13 +2,12 @@ # define _ECORE_WAYLAND_PRIVATE_H # include -# include # include "Ecore.h" # include "Ecore_Input.h" # include "Ecore_Wayland.h" -//# define LOGFNS 1 +# define LOGFNS 1 # ifdef LOGFNS # include diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c index d949334..70e6ee6 100644 --- a/src/lib/ecore_wayland/ecore_wl_window.c +++ b/src/lib/ecore_wayland/ecore_wl_window.c @@ -8,12 +8,20 @@ static void _ecore_wl_window_cb_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, unsigned int serial); static void _ecore_wl_window_cb_configure(void *data, struct wl_shell_surface *shell_surface __UNUSED__, unsigned int edges, int w, int h); static void _ecore_wl_window_cb_popup_done(void *data, struct wl_shell_surface *shell_surface __UNUSED__); +static void _ecore_wl_window_cb_surface_enter(void *data, struct wl_surface *surface, struct wl_output *output); +static void _ecore_wl_window_cb_surface_leave(void *data, struct wl_surface *surface, struct wl_output *output); static void _ecore_wl_window_configure_send(Ecore_Wl_Window *win, int w, int h, unsigned int timestamp); /* local variables */ static Eina_Hash *_windows = NULL; /* wayland listeners */ +static const struct wl_surface_listener _ecore_wl_surface_listener = +{ + _ecore_wl_window_cb_surface_enter, + _ecore_wl_window_cb_surface_leave +}; + static const struct wl_shell_surface_listener _ecore_wl_shell_surface_listener = { _ecore_wl_window_cb_ping, @@ -81,7 +89,7 @@ ecore_wl_window_new(Ecore_Wl_Window *parent, int x, int y, int w, int h, int buf win->allocation.h = h; win->saved_allocation = win->allocation; win->transparent = EINA_FALSE; - win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL; + win->type = ECORE_WL_WINDOW_TYPE_NONE; win->buffer_type = buffer_type; win->id = _win_id++; @@ -261,6 +269,9 @@ ecore_wl_window_buffer_attach(Ecore_Wl_Window *win, struct wl_buffer *buffer, in if (buffer) wl_surface_attach(win->surface, buffer, x, y); + wl_surface_damage(win->surface, 0, 0, + win->allocation.w, win->allocation.h); + win->server_allocation = win->allocation; } break; @@ -268,10 +279,6 @@ ecore_wl_window_buffer_attach(Ecore_Wl_Window *win, struct wl_buffer *buffer, in return; } - if (win->surface) - wl_surface_damage(win->surface, 0, 0, - win->allocation.w, win->allocation.h); - if (win->region.input) { wl_surface_set_input_region(win->surface, win->region.input); @@ -307,6 +314,7 @@ ecore_wl_window_show(Ecore_Wl_Window *win) win->surface = wl_compositor_create_surface(_ecore_wl_disp->wl.compositor); wl_surface_set_user_data(win->surface, win); + /* wl_surface_add_listener(win->surface, &_ecore_wl_surface_listener, win); */ win->shell_surface = wl_shell_get_shell_surface(_ecore_wl_disp->wl.shell, win->surface); @@ -331,12 +339,15 @@ ecore_wl_window_show(Ecore_Wl_Window *win) case ECORE_WL_WINDOW_TYPE_MENU: wl_shell_surface_set_popup(win->shell_surface, _ecore_wl_disp->input->input_device, - _ecore_wl_disp->input->timestamp, + _ecore_wl_disp->serial, /* win->parent->pointer_device->input_device, */ /* win->parent->pointer_device->timestamp, */ win->parent->shell_surface, win->allocation.x, win->allocation.y, 0); break; + case ECORE_WL_WINDOW_TYPE_NONE: + win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL; + /* fallthrough */ case ECORE_WL_WINDOW_TYPE_TOPLEVEL: wl_shell_surface_set_toplevel(win->shell_surface); break; @@ -595,6 +606,26 @@ _ecore_wl_window_cb_popup_done(void *data, struct wl_shell_surface *shell_surfac } static void +_ecore_wl_window_cb_surface_enter(void *data, struct wl_surface *surface, struct wl_output *output) +{ + Ecore_Wl_Window *win; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + + if (!(win = data)) return; +} + +static void +_ecore_wl_window_cb_surface_leave(void *data, struct wl_surface *surface, struct wl_output *output) +{ + Ecore_Wl_Window *win; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + + if (!(win = data)) return; +} + +static void _ecore_wl_window_configure_send(Ecore_Wl_Window *win, int w, int h, unsigned int timestamp) { Ecore_Wl_Event_Window_Configure *ev;