2012-02-28 13:55:51 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2012-12-28 11:36:01 -08:00
|
|
|
/*
|
2012-04-24 09:59:35 -07:00
|
|
|
* NB: Events that receive a 'serial' instead of timestamp
|
|
|
|
*
|
|
|
|
* input_device_attach (for pointer image)
|
|
|
|
* input_device_button_event (button press/release)
|
|
|
|
* input_device_key_press
|
|
|
|
* input_device_pointer_enter
|
|
|
|
* input_device_pointer_leave
|
|
|
|
* input_device_keyboard_enter
|
|
|
|
* input_device_keyboard_leave
|
|
|
|
* input_device_touch_down
|
|
|
|
* input_device_touch_up
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
#include "ecore_wl_private.h"
|
2012-06-06 01:18:58 -07:00
|
|
|
#include <sys/mman.h>
|
2012-08-09 02:57:47 -07:00
|
|
|
#include <sys/timerfd.h>
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
/* FIXME: This gives BTN_LEFT/RIGHT/MIDDLE for linux systems ...
|
|
|
|
* What about other OSs ?? */
|
|
|
|
#ifdef __linux__
|
|
|
|
# include <linux/input.h>
|
|
|
|
#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
|
|
|
|
|
2013-04-10 10:45:12 -07:00
|
|
|
typedef struct _Ecore_Wl_Mouse_Down_Info
|
|
|
|
{
|
|
|
|
EINA_INLIST;
|
2013-05-07 12:18:06 -07:00
|
|
|
int dev;
|
2013-04-10 10:45:12 -07:00
|
|
|
int last_win;
|
|
|
|
int last_last_win;
|
|
|
|
int last_event_win;
|
|
|
|
int last_last_event_win;
|
|
|
|
unsigned int last_time;
|
|
|
|
unsigned int last_last_time;
|
2013-04-10 22:33:30 -07:00
|
|
|
Eina_Bool did_double : 1;
|
|
|
|
Eina_Bool did_triple : 1;
|
2013-04-10 10:45:12 -07:00
|
|
|
} Ecore_Wl_Mouse_Down_Info;
|
|
|
|
|
2012-08-28 23:35:02 -07:00
|
|
|
Ecore_Wl_Dnd *glb_dnd = NULL;
|
|
|
|
|
2013-04-10 10:45:12 -07:00
|
|
|
/* FIXME: This should be a global setting, used by wayland and X */
|
|
|
|
static double _ecore_wl_double_click_time = 0.25;
|
|
|
|
static Eina_Inlist *_ecore_wl_mouse_down_info_list = NULL;
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
/* local function prototypes */
|
2012-05-22 01:17:30 -07:00
|
|
|
static void _ecore_wl_input_seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps);
|
|
|
|
|
2012-11-25 01:55:32 -08:00
|
|
|
static void _ecore_wl_input_cb_pointer_enter(void *data, struct wl_pointer *pointer EINA_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_pointer *pointer EINA_UNUSED, unsigned int serial, struct wl_surface *surface);
|
|
|
|
static void _ecore_wl_input_cb_pointer_motion(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int timestamp, wl_fixed_t sx, wl_fixed_t sy);
|
2013-05-07 12:18:06 -07:00
|
|
|
static void _ecore_wl_input_cb_pointer_button(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state);
|
2012-11-25 01:55:32 -08:00
|
|
|
static void _ecore_wl_input_cb_pointer_axis(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int timestamp, unsigned int axis, wl_fixed_t value);
|
|
|
|
static void _ecore_wl_input_cb_pointer_frame(void *data, struct wl_callback *callback, unsigned int timestamp EINA_UNUSED);
|
|
|
|
static void _ecore_wl_input_cb_keyboard_keymap(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int format, int fd, unsigned int size);
|
|
|
|
static void _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface, struct wl_array *keys EINA_UNUSED);
|
|
|
|
static void _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface);
|
|
|
|
static void _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, unsigned int timestamp, unsigned int key, unsigned int state);
|
|
|
|
static void _ecore_wl_input_cb_keyboard_modifiers(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial EINA_UNUSED, unsigned int depressed, unsigned int latched, unsigned int locked, unsigned int group);
|
|
|
|
static Eina_Bool _ecore_wl_input_cb_keyboard_repeat(void *data, Ecore_Fd_Handler *handler EINA_UNUSED);
|
2013-04-10 10:45:12 -07:00
|
|
|
static void _ecore_wl_input_cb_touch_down(void *data, struct wl_touch *touch, unsigned int serial, unsigned int timestamp, struct wl_surface *surface EINA_UNUSED, int id EINA_UNUSED, wl_fixed_t x, wl_fixed_t y);
|
|
|
|
static void _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch, unsigned int serial, unsigned int timestamp, int id EINA_UNUSED);
|
2013-05-07 12:18:06 -07:00
|
|
|
static void _ecore_wl_input_cb_touch_motion(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int timestamp, int id, wl_fixed_t x, wl_fixed_t y);
|
2012-11-25 01:55:32 -08:00
|
|
|
static void _ecore_wl_input_cb_touch_frame(void *data EINA_UNUSED, struct wl_touch *touch EINA_UNUSED);
|
|
|
|
static void _ecore_wl_input_cb_touch_cancel(void *data EINA_UNUSED, struct wl_touch *touch EINA_UNUSED);
|
2012-07-04 00:16:29 -07:00
|
|
|
static void _ecore_wl_input_cb_data_offer(void *data, struct wl_data_device *data_device, struct wl_data_offer *offer);
|
2012-05-15 04:58:21 -07:00
|
|
|
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);
|
2012-02-28 13:55:51 -08:00
|
|
|
static void _ecore_wl_input_cb_data_leave(void *data, struct wl_data_device *data_device);
|
2012-05-15 04:58:21 -07:00
|
|
|
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);
|
2012-02-28 13:55:51 -08:00
|
|
|
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);
|
|
|
|
|
2013-05-07 12:18:06 -07:00
|
|
|
static void _ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int timestamp, int device);
|
2012-04-17 14:55:25 -07:00
|
|
|
static void _ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int timestamp);
|
|
|
|
static void _ecore_wl_input_mouse_out_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int timestamp);
|
2012-11-25 01:55:32 -08:00
|
|
|
static void _ecore_wl_input_focus_in_send(Ecore_Wl_Input *input EINA_UNUSED, Ecore_Wl_Window *win, unsigned int timestamp);
|
|
|
|
static void _ecore_wl_input_focus_out_send(Ecore_Wl_Input *input EINA_UNUSED, Ecore_Wl_Window *win, unsigned int timestamp);
|
2013-05-07 12:18:06 -07:00
|
|
|
static void _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int device, unsigned int button, unsigned int timestamp);
|
|
|
|
static void _ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int device, unsigned int button, unsigned int timestamp);
|
2012-03-27 10:50:40 -07:00
|
|
|
static void _ecore_wl_input_mouse_wheel_send(Ecore_Wl_Input *input, unsigned int axis, int value, unsigned int timestamp);
|
2013-05-07 12:18:06 -07:00
|
|
|
static Ecore_Wl_Mouse_Down_Info *_ecore_wl_mouse_down_info_get(int dev);
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2012-05-15 04:58:21 -07:00
|
|
|
/* static int _ecore_wl_input_keysym_to_string(unsigned int symbol, char *buffer, int len); */
|
2012-05-02 11:04:40 -07:00
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
/* wayland interfaces */
|
2012-05-22 01:17:30 -07:00
|
|
|
static const struct wl_pointer_listener pointer_listener =
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
2012-03-08 18:36:00 -08:00
|
|
|
_ecore_wl_input_cb_pointer_enter,
|
|
|
|
_ecore_wl_input_cb_pointer_leave,
|
2012-05-22 01:17:30 -07:00
|
|
|
_ecore_wl_input_cb_pointer_motion,
|
|
|
|
_ecore_wl_input_cb_pointer_button,
|
2012-06-06 01:18:58 -07:00
|
|
|
_ecore_wl_input_cb_pointer_axis,
|
2012-05-22 01:17:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct wl_keyboard_listener keyboard_listener =
|
|
|
|
{
|
2012-06-06 01:18:58 -07:00
|
|
|
_ecore_wl_input_cb_keyboard_keymap,
|
2012-03-08 18:36:00 -08:00
|
|
|
_ecore_wl_input_cb_keyboard_enter,
|
|
|
|
_ecore_wl_input_cb_keyboard_leave,
|
2012-06-06 01:18:58 -07:00
|
|
|
_ecore_wl_input_cb_keyboard_key,
|
|
|
|
_ecore_wl_input_cb_keyboard_modifiers,
|
2012-05-22 01:17:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct wl_touch_listener touch_listener =
|
|
|
|
{
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_input_cb_touch_down,
|
|
|
|
_ecore_wl_input_cb_touch_up,
|
|
|
|
_ecore_wl_input_cb_touch_motion,
|
|
|
|
_ecore_wl_input_cb_touch_frame,
|
|
|
|
_ecore_wl_input_cb_touch_cancel
|
|
|
|
};
|
|
|
|
|
2012-05-22 01:17:30 -07:00
|
|
|
static const struct wl_seat_listener _ecore_wl_seat_listener =
|
|
|
|
{
|
|
|
|
_ecore_wl_input_seat_handle_capabilities,
|
|
|
|
};
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
static const struct wl_data_device_listener _ecore_wl_data_listener =
|
|
|
|
{
|
|
|
|
_ecore_wl_input_cb_data_offer,
|
|
|
|
_ecore_wl_input_cb_data_enter,
|
|
|
|
_ecore_wl_input_cb_data_leave,
|
|
|
|
_ecore_wl_input_cb_data_motion,
|
|
|
|
_ecore_wl_input_cb_data_drop,
|
|
|
|
_ecore_wl_input_cb_data_selection
|
|
|
|
};
|
|
|
|
|
2012-07-04 00:16:29 -07:00
|
|
|
static const struct wl_callback_listener _ecore_wl_pointer_surface_listener =
|
|
|
|
{
|
|
|
|
_ecore_wl_input_cb_pointer_frame
|
|
|
|
};
|
|
|
|
|
2012-03-05 08:50:20 -08:00
|
|
|
/* local variables */
|
|
|
|
static int _pointer_x, _pointer_y;
|
|
|
|
|
2012-03-26 19:13:34 -07:00
|
|
|
EAPI void
|
|
|
|
ecore_wl_input_grab(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int button)
|
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
if (!input) return;
|
2012-03-26 19:13:34 -07:00
|
|
|
input->grab = win;
|
|
|
|
input->grab_button = button;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2012-04-24 09:59:35 -07:00
|
|
|
ecore_wl_input_ungrab(Ecore_Wl_Input *input)
|
2012-03-26 19:13:34 -07:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
if (!input) return;
|
2012-03-26 19:13:34 -07:00
|
|
|
input->grab = NULL;
|
2012-04-10 10:00:56 -07:00
|
|
|
input->grab_button = 0;
|
2012-03-26 19:13:34 -07:00
|
|
|
}
|
|
|
|
|
2013-04-22 09:35:54 -07:00
|
|
|
static void
|
|
|
|
_pointer_update_stop(Ecore_Wl_Input *input)
|
|
|
|
{
|
|
|
|
if (!input->cursor_timer) return;
|
|
|
|
|
|
|
|
ecore_timer_del(input->cursor_timer);
|
|
|
|
input->cursor_timer = NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
EAPI void
|
2012-06-18 03:48:29 -07:00
|
|
|
ecore_wl_input_pointer_set(Ecore_Wl_Input *input, struct wl_surface *surface, int hot_x, int hot_y)
|
2012-06-06 01:18:58 -07:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2013-04-22 09:35:54 -07:00
|
|
|
if (!input) return;
|
|
|
|
|
|
|
|
_pointer_update_stop(input);
|
|
|
|
wl_pointer_set_cursor(input->pointer, input->pointer_enter_serial,
|
|
|
|
surface, hot_x, hot_y);
|
2012-06-06 01:18:58 -07:00
|
|
|
}
|
|
|
|
|
2013-04-22 09:35:54 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_ecore_wl_input_cursor_update(void *data)
|
2012-06-06 01:18:58 -07:00
|
|
|
{
|
|
|
|
struct wl_cursor_image *cursor_image;
|
|
|
|
struct wl_buffer *buffer;
|
2013-04-22 09:35:54 -07:00
|
|
|
Ecore_Wl_Input *input = data;
|
|
|
|
unsigned int delay;
|
|
|
|
|
|
|
|
cursor_image = input->cursor->images[input->cursor_current_index];
|
|
|
|
if ((buffer = wl_cursor_image_get_buffer(cursor_image)))
|
|
|
|
{
|
|
|
|
ecore_wl_input_pointer_set(input, input->cursor_surface,
|
|
|
|
cursor_image->hotspot_x,
|
|
|
|
cursor_image->hotspot_y);
|
|
|
|
wl_surface_attach(input->cursor_surface, buffer, 0, 0);
|
|
|
|
wl_surface_damage(input->cursor_surface, 0, 0,
|
|
|
|
cursor_image->width, cursor_image->height);
|
|
|
|
wl_surface_commit(input->cursor_surface);
|
|
|
|
|
|
|
|
if (!input->cursor_frame_cb)
|
|
|
|
_ecore_wl_input_cb_pointer_frame(input, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (input->cursor->image_count <= 1)
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
|
|
|
|
delay = cursor_image->delay;
|
|
|
|
input->cursor_current_index =
|
|
|
|
(input->cursor_current_index + 1) % input->cursor->image_count;
|
|
|
|
|
|
|
|
if (!input->cursor_timer)
|
|
|
|
input->cursor_timer =
|
|
|
|
ecore_timer_loop_add(delay / 1000.0,
|
|
|
|
_ecore_wl_input_cursor_update, input);
|
|
|
|
else
|
|
|
|
ecore_timer_interval_set(input->cursor_timer, delay / 1000.0);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl_input_cursor_from_name_set(Ecore_Wl_Input *input, const char *cursor_name)
|
|
|
|
{
|
2012-06-06 01:18:58 -07:00
|
|
|
struct wl_cursor *cursor;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!input) return;
|
|
|
|
|
2013-04-22 09:35:54 -07:00
|
|
|
_pointer_update_stop(input);
|
|
|
|
|
2012-08-16 02:37:52 -07:00
|
|
|
eina_stringshare_replace(&input->cursor_name, cursor_name);
|
|
|
|
|
2012-08-16 02:53:05 -07:00
|
|
|
/* No cursor. Set to default Left Pointer */
|
|
|
|
if (!cursor_name)
|
|
|
|
eina_stringshare_replace(&input->cursor_name, "left_ptr");
|
2012-06-06 01:18:58 -07:00
|
|
|
|
2012-08-16 02:53:05 -07:00
|
|
|
/* try to get this cursor from the theme */
|
|
|
|
if (!(cursor = ecore_wl_cursor_get(input->cursor_name)))
|
2012-08-16 02:37:52 -07:00
|
|
|
{
|
2012-08-16 02:53:05 -07:00
|
|
|
/* if the theme does not have this cursor, default to left pointer */
|
|
|
|
if (!(cursor = ecore_wl_cursor_get("left_ptr")))
|
2012-10-16 04:57:25 -07:00
|
|
|
return;
|
2012-08-16 02:37:52 -07:00
|
|
|
}
|
2012-06-06 01:18:58 -07:00
|
|
|
|
2013-04-22 09:35:54 -07:00
|
|
|
input->cursor = cursor;
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
if ((!cursor->images) || (!cursor->images[0]))
|
2012-08-16 02:37:52 -07:00
|
|
|
{
|
|
|
|
ecore_wl_input_pointer_set(input, NULL, 0, 0);
|
|
|
|
return;
|
|
|
|
}
|
2012-06-06 01:18:58 -07:00
|
|
|
|
2013-04-22 09:35:54 -07:00
|
|
|
input->cursor_current_index = 0;
|
2012-07-04 00:16:29 -07:00
|
|
|
|
2013-04-22 09:35:54 -07:00
|
|
|
_ecore_wl_input_cursor_update(input);
|
2012-06-06 01:18:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_wl_input_cursor_default_restore(Ecore_Wl_Input *input)
|
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!input) return;
|
|
|
|
|
|
|
|
/* Restore to default wayland cursor */
|
|
|
|
ecore_wl_input_cursor_from_name_set(input, "left_ptr");
|
|
|
|
}
|
|
|
|
|
2012-08-09 02:57:47 -07:00
|
|
|
/* local functions */
|
2012-02-28 13:55:51 -08:00
|
|
|
void
|
|
|
|
_ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id)
|
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = malloc(sizeof(Ecore_Wl_Input)))) return;
|
|
|
|
|
|
|
|
memset(input, 0, sizeof(Ecore_Wl_Input));
|
|
|
|
|
|
|
|
input->display = ewd;
|
|
|
|
input->pointer_focus = NULL;
|
|
|
|
input->keyboard_focus = NULL;
|
|
|
|
|
2012-05-22 01:17:30 -07:00
|
|
|
input->seat =
|
2012-10-16 04:57:19 -07:00
|
|
|
wl_registry_bind(ewd->wl.registry, id, &wl_seat_interface, 1);
|
2012-02-28 13:55:51 -08:00
|
|
|
wl_list_insert(ewd->inputs.prev, &input->link);
|
2012-10-16 04:57:19 -07:00
|
|
|
|
2012-05-22 01:17:30 -07:00
|
|
|
wl_seat_add_listener(input->seat,
|
|
|
|
&_ecore_wl_seat_listener, input);
|
|
|
|
wl_seat_set_user_data(input->seat, input);
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
input->data_device =
|
|
|
|
wl_data_device_manager_get_data_device(ewd->wl.data_device_manager,
|
2012-05-22 01:17:30 -07:00
|
|
|
input->seat);
|
2012-02-28 13:55:51 -08:00
|
|
|
wl_data_device_add_listener(input->data_device,
|
|
|
|
&_ecore_wl_data_listener, input);
|
2012-06-18 03:48:29 -07:00
|
|
|
input->cursor_surface =
|
|
|
|
wl_compositor_create_surface(_ecore_wl_disp->wl.compositor);
|
|
|
|
|
2012-08-09 02:57:47 -07:00
|
|
|
input->repeat.timerfd =
|
|
|
|
timerfd_create(CLOCK_MONOTONIC, (TFD_CLOEXEC | TFD_NONBLOCK));
|
|
|
|
|
|
|
|
input->repeat.hdlr =
|
|
|
|
ecore_main_fd_handler_add(input->repeat.timerfd, ECORE_FD_READ,
|
|
|
|
_ecore_wl_input_cb_keyboard_repeat, input,
|
|
|
|
NULL, NULL);
|
|
|
|
|
2012-03-26 19:13:34 -07:00
|
|
|
ewd->input = input;
|
2012-08-28 23:35:02 -07:00
|
|
|
|
|
|
|
/* create Ecore_Wl_Dnd */
|
|
|
|
if (!glb_dnd)
|
|
|
|
if (!(glb_dnd = calloc(1, sizeof(Ecore_Wl_Dnd)))) return;
|
|
|
|
glb_dnd->ewd = ewd;
|
|
|
|
glb_dnd->input = input;
|
|
|
|
input->dnd = glb_dnd;
|
|
|
|
wl_array_init(&glb_dnd->types_offered);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_ecore_wl_input_del(Ecore_Wl_Input *input)
|
|
|
|
{
|
|
|
|
if (!input) return;
|
|
|
|
|
2013-04-22 09:35:54 -07:00
|
|
|
_pointer_update_stop(input);
|
|
|
|
|
2012-08-16 02:37:52 -07:00
|
|
|
if (input->cursor_name) eina_stringshare_del(input->cursor_name);
|
|
|
|
input->cursor_name = NULL;
|
|
|
|
|
2012-08-09 02:57:47 -07:00
|
|
|
if (input->keyboard_focus)
|
|
|
|
{
|
|
|
|
Ecore_Wl_Window *win = NULL;
|
|
|
|
|
|
|
|
if ((win = input->keyboard_focus))
|
|
|
|
win->keyboard_device = NULL;
|
|
|
|
|
|
|
|
input->keyboard_focus = NULL;
|
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
if (input->drag_source) _ecore_wl_dnd_del(input->drag_source);
|
|
|
|
input->drag_source = NULL;
|
|
|
|
|
|
|
|
if (input->selection_source) _ecore_wl_dnd_del(input->selection_source);
|
|
|
|
input->selection_source = NULL;
|
|
|
|
|
|
|
|
if (input->data_device) wl_data_device_destroy(input->data_device);
|
2012-07-23 07:04:17 -07:00
|
|
|
|
2012-06-11 10:11:38 -07:00
|
|
|
if (input->xkb.state)
|
|
|
|
xkb_state_unref(input->xkb.state);
|
|
|
|
if (input->xkb.keymap)
|
|
|
|
xkb_map_unref(input->xkb.keymap);
|
2012-07-04 00:16:29 -07:00
|
|
|
|
2012-06-18 03:48:29 -07:00
|
|
|
if (input->cursor_surface)
|
|
|
|
wl_surface_destroy(input->cursor_surface);
|
|
|
|
|
2012-07-04 00:16:29 -07:00
|
|
|
wl_list_remove(&input->link);
|
|
|
|
if (input->seat) wl_seat_destroy(input->seat);
|
|
|
|
|
2012-08-09 02:57:47 -07:00
|
|
|
if (input->repeat.hdlr) ecore_main_fd_handler_del(input->repeat.hdlr);
|
|
|
|
input->repeat.hdlr = NULL;
|
|
|
|
|
|
|
|
if (input->repeat.timerfd) close(input->repeat.timerfd);
|
|
|
|
input->repeat.timerfd = 0;
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
free(input);
|
|
|
|
}
|
|
|
|
|
2012-03-05 08:50:20 -08:00
|
|
|
void
|
|
|
|
_ecore_wl_input_pointer_xy_get(int *x, int *y)
|
|
|
|
{
|
|
|
|
if (x) *x = _pointer_x;
|
|
|
|
if (y) *y = _pointer_y;
|
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
static void
|
2012-05-22 01:17:30 -07:00
|
|
|
_ecore_wl_input_seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps)
|
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
|
|
|
if (!(input = data)) return;
|
2012-10-16 04:57:25 -07:00
|
|
|
|
2012-05-22 01:17:30 -07:00
|
|
|
if ((caps & WL_SEAT_CAPABILITY_POINTER) && (!input->pointer))
|
|
|
|
{
|
|
|
|
input->pointer = wl_seat_get_pointer(seat);
|
|
|
|
wl_pointer_set_user_data(input->pointer, input);
|
|
|
|
wl_pointer_add_listener(input->pointer, &pointer_listener, input);
|
|
|
|
}
|
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && (input->pointer))
|
|
|
|
{
|
|
|
|
wl_pointer_destroy(input->pointer);
|
|
|
|
input->pointer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && (!input->keyboard))
|
|
|
|
{
|
|
|
|
input->keyboard = wl_seat_get_keyboard(seat);
|
|
|
|
wl_keyboard_set_user_data(input->keyboard, input);
|
|
|
|
wl_keyboard_add_listener(input->keyboard, &keyboard_listener, input);
|
|
|
|
}
|
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && (input->keyboard))
|
|
|
|
{
|
|
|
|
wl_keyboard_destroy(input->keyboard);
|
|
|
|
input->keyboard = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((caps & WL_SEAT_CAPABILITY_TOUCH) && (!input->touch))
|
|
|
|
{
|
|
|
|
input->touch = wl_seat_get_touch(seat);
|
|
|
|
wl_touch_set_user_data(input->touch, input);
|
|
|
|
wl_touch_add_listener(input->touch, &touch_listener, input);
|
|
|
|
}
|
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && (input->touch))
|
|
|
|
{
|
|
|
|
wl_touch_destroy(input->touch);
|
|
|
|
input->touch = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_pointer_motion(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int timestamp, wl_fixed_t sx, wl_fixed_t sy)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
/* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
if (!(input = data)) return;
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
_pointer_x = input->sx = wl_fixed_to_int(sx);
|
|
|
|
_pointer_y = input->sy = wl_fixed_to_int(sy);
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2012-04-17 14:55:25 -07:00
|
|
|
input->timestamp = timestamp;
|
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
if (input->pointer_focus)
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_mouse_move_send(input, input->pointer_focus, timestamp, 0);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_cb_pointer_button(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = data)) return;
|
|
|
|
|
|
|
|
input->timestamp = timestamp;
|
2012-04-17 12:06:23 -07:00
|
|
|
input->display->serial = serial;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
// _ecore_wl_input_mouse_move_send(input, input->pointer_focus, timestamp);
|
2012-04-17 14:55:25 -07:00
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
if (state)
|
|
|
|
{
|
|
|
|
if ((input->pointer_focus) && (!input->grab) && (state))
|
|
|
|
ecore_wl_input_grab(input, input->pointer_focus, button);
|
2012-03-26 19:13:34 -07:00
|
|
|
|
2013-04-10 10:45:12 -07:00
|
|
|
_ecore_wl_input_mouse_down_send(input, input->pointer_focus,
|
2013-05-07 12:18:06 -07:00
|
|
|
0, button, timestamp);
|
2012-04-24 09:59:35 -07:00
|
|
|
}
|
|
|
|
else
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
2013-04-10 10:45:12 -07:00
|
|
|
_ecore_wl_input_mouse_up_send(input, input->pointer_focus,
|
2013-05-07 12:18:06 -07:00
|
|
|
0, button, timestamp);
|
2012-04-24 09:59:35 -07:00
|
|
|
if ((input->grab) && (input->grab_button == button) && (!state))
|
|
|
|
ecore_wl_input_ungrab(input);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
2012-04-10 10:00:56 -07:00
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
// _ecore_wl_input_mouse_move_send(input, timestamp);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
2012-03-27 10:50:40 -07:00
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_pointer_axis(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int timestamp, unsigned int axis, wl_fixed_t value)
|
2012-03-27 10:50:40 -07:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = data)) return;
|
2012-06-06 07:10:43 -07:00
|
|
|
_ecore_wl_input_mouse_wheel_send(input, axis, wl_fixed_to_int(value),
|
|
|
|
timestamp);
|
2012-03-27 10:50:40 -07:00
|
|
|
}
|
|
|
|
|
2012-07-04 00:16:29 -07:00
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_pointer_frame(void *data, struct wl_callback *callback, unsigned int timestamp EINA_UNUSED)
|
2012-07-04 00:16:29 -07:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = data)) return;
|
|
|
|
|
|
|
|
if (callback)
|
|
|
|
{
|
|
|
|
if (callback != input->cursor_frame_cb) return;
|
|
|
|
wl_callback_destroy(callback);
|
|
|
|
input->cursor_frame_cb = NULL;
|
|
|
|
}
|
|
|
|
|
2012-08-16 02:37:52 -07:00
|
|
|
if (!input->cursor_name)
|
|
|
|
{
|
|
|
|
ecore_wl_input_pointer_set(input, NULL, 0, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-04 00:16:29 -07:00
|
|
|
if (!input->cursor_frame_cb)
|
|
|
|
{
|
|
|
|
input->cursor_frame_cb = wl_surface_frame(input->cursor_surface);
|
|
|
|
wl_callback_add_listener(input->cursor_frame_cb,
|
|
|
|
&_ecore_wl_pointer_surface_listener, input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_keyboard_keymap(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int format, int fd, unsigned int size)
|
2012-06-06 01:18:58 -07:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
char *map = NULL;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = data))
|
|
|
|
{
|
|
|
|
close(fd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
|
|
|
|
{
|
|
|
|
close(fd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
|
|
|
if (map == MAP_FAILED)
|
|
|
|
{
|
|
|
|
close(fd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-06 06:20:02 -07:00
|
|
|
input->xkb.keymap =
|
2012-06-06 01:18:58 -07:00
|
|
|
xkb_map_new_from_string(input->display->xkb.context, map,
|
|
|
|
XKB_KEYMAP_FORMAT_TEXT_V1, 0);
|
|
|
|
|
|
|
|
munmap(map, size);
|
|
|
|
close(fd);
|
|
|
|
|
2012-06-06 06:20:02 -07:00
|
|
|
if (!(input->xkb.keymap)) return;
|
|
|
|
if (!(input->xkb.state = xkb_state_new(input->xkb.keymap)))
|
2012-06-06 01:18:58 -07:00
|
|
|
{
|
2012-06-06 06:20:02 -07:00
|
|
|
xkb_map_unref(input->xkb.keymap);
|
|
|
|
input->xkb.keymap = NULL;
|
2012-06-06 01:18:58 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-06 06:20:02 -07:00
|
|
|
input->xkb.control_mask =
|
|
|
|
1 << xkb_map_mod_get_index(input->xkb.keymap, "Control");
|
|
|
|
input->xkb.alt_mask =
|
|
|
|
1 << xkb_map_mod_get_index(input->xkb.keymap, "Mod1");
|
|
|
|
input->xkb.shift_mask =
|
|
|
|
1 << xkb_map_mod_get_index(input->xkb.keymap, "Shift");
|
2012-06-06 01:18:58 -07:00
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
Ecore_Wl_Window *win;
|
2012-05-15 04:58:21 -07:00
|
|
|
unsigned int code, num;
|
|
|
|
const xkb_keysym_t *syms;
|
2012-08-23 04:25:45 -07:00
|
|
|
xkb_keysym_t sym = XKB_KEY_NoSymbol;
|
|
|
|
xkb_mod_mask_t mask;
|
|
|
|
char string[32], key[32], keyname[32];// compose[32];
|
2012-05-02 11:04:40 -07:00
|
|
|
Ecore_Event_Key *e;
|
2012-08-09 02:57:47 -07:00
|
|
|
struct itimerspec ts;
|
2012-08-23 04:25:45 -07:00
|
|
|
int len = 0;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = data)) return;
|
2012-04-17 12:06:23 -07:00
|
|
|
input->display->serial = serial;
|
2012-08-23 04:25:45 -07:00
|
|
|
|
|
|
|
/* xkb rules reflect X broken keycodes, so offset by 8 */
|
2012-05-15 04:58:21 -07:00
|
|
|
code = keycode + 8;
|
2012-05-02 11:04:40 -07:00
|
|
|
|
2012-05-15 04:58:21 -07:00
|
|
|
win = input->keyboard_focus;
|
2012-08-09 02:57:47 -07:00
|
|
|
if ((!win) || (win->keyboard_device != input) || (!input->xkb.state))
|
|
|
|
return;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2012-08-23 04:25:45 -07:00
|
|
|
mask = xkb_state_serialize_mods(input->xkb.state,
|
|
|
|
XKB_STATE_DEPRESSED | XKB_STATE_LATCHED);
|
2012-06-06 05:55:53 -07:00
|
|
|
|
2012-08-23 04:25:45 -07:00
|
|
|
input->modifiers = 0;
|
|
|
|
|
|
|
|
/* The Ecore_Event_Modifiers don't quite match the X mask bits */
|
|
|
|
if (mask & input->xkb.control_mask)
|
2012-10-06 08:58:27 -07:00
|
|
|
input->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
|
2012-08-23 04:25:45 -07:00
|
|
|
if (mask & input->xkb.alt_mask)
|
2012-10-06 08:58:27 -07:00
|
|
|
input->modifiers |= ECORE_EVENT_MODIFIER_ALT;
|
2012-08-23 04:25:45 -07:00
|
|
|
if (mask & input->xkb.shift_mask)
|
2012-10-06 08:58:27 -07:00
|
|
|
input->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
|
2012-06-06 05:55:53 -07:00
|
|
|
|
2012-08-23 04:25:45 -07:00
|
|
|
num = xkb_key_get_syms(input->xkb.state, code, &syms);
|
2012-05-15 04:58:21 -07:00
|
|
|
if (num == 1) sym = syms[0];
|
2012-05-02 11:04:40 -07:00
|
|
|
|
|
|
|
memset(key, 0, sizeof(key));
|
2012-08-23 04:25:45 -07:00
|
|
|
xkb_keysym_get_name(sym, key, sizeof(key));
|
|
|
|
|
2012-05-02 11:04:40 -07:00
|
|
|
memset(keyname, 0, sizeof(keyname));
|
2012-08-23 04:25:45 -07:00
|
|
|
xkb_keysym_get_name(sym, keyname, sizeof(keyname));
|
|
|
|
if (keyname[0] == '\0')
|
2013-04-13 12:59:30 -07:00
|
|
|
snprintf(keyname, sizeof(keyname), "Keycode-%u", code);
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2012-08-23 04:25:45 -07:00
|
|
|
memset(string, 0, sizeof(string));
|
2012-08-01 23:43:20 -07:00
|
|
|
if (xkb_keysym_to_utf8(sym, string, 32) <= 0)
|
2012-08-23 04:25:45 -07:00
|
|
|
{
|
|
|
|
/* FIXME: NB: We may need to add more checks here for other
|
|
|
|
* non-printable characters */
|
|
|
|
if ((sym == XKB_KEY_Tab) || (sym == XKB_KEY_ISO_Left_Tab))
|
|
|
|
string[len++] = '\t';
|
|
|
|
}
|
2012-05-15 04:58:21 -07:00
|
|
|
|
2012-08-23 04:25:45 -07:00
|
|
|
/* FIXME: NB: Start hacking on compose key support */
|
|
|
|
/* memset(compose, 0, sizeof(compose)); */
|
|
|
|
/* if (sym == XKB_KEY_Multi_key) */
|
|
|
|
/* { */
|
|
|
|
/* if (xkb_keysym_to_utf8(sym, compose, 32) <= 0) */
|
|
|
|
/* compose[0] = '\0'; */
|
|
|
|
/* } */
|
2012-05-02 11:04:40 -07:00
|
|
|
|
2012-08-23 04:25:45 -07:00
|
|
|
e = malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
|
|
|
|
((string[0] != '\0') ? strlen(string) : 0) + 3);
|
|
|
|
if (!e) return;
|
2012-05-02 11:04:40 -07:00
|
|
|
|
|
|
|
e->keyname = (char *)(e + 1);
|
|
|
|
e->key = e->keyname + strlen(keyname) + 1;
|
|
|
|
e->string = strlen(string) ? e->key + strlen(key) + 1 : NULL;
|
|
|
|
e->compose = e->string;
|
|
|
|
|
|
|
|
strcpy((char *)e->keyname, keyname);
|
|
|
|
strcpy((char *)e->key, key);
|
2012-08-23 04:25:45 -07:00
|
|
|
if (strlen(string)) strcpy((char *)e->string, string);
|
2012-05-02 11:04:40 -07:00
|
|
|
|
|
|
|
e->window = win->id;
|
|
|
|
e->event_window = win->id;
|
|
|
|
e->timestamp = timestamp;
|
2012-10-06 08:58:27 -07:00
|
|
|
e->modifiers = input->modifiers;
|
2012-05-02 11:04:40 -07:00
|
|
|
|
|
|
|
if (state)
|
|
|
|
ecore_event_add(ECORE_EVENT_KEY_DOWN, e, NULL, NULL);
|
|
|
|
else
|
|
|
|
ecore_event_add(ECORE_EVENT_KEY_UP, e, NULL, NULL);
|
2012-08-09 02:57:47 -07:00
|
|
|
|
|
|
|
if ((!state) && (keycode == input->repeat.key))
|
|
|
|
{
|
|
|
|
input->repeat.sym = 0;
|
|
|
|
input->repeat.key = 0;
|
|
|
|
input->repeat.time = 0;
|
|
|
|
|
|
|
|
ts.it_interval.tv_sec = 0;
|
|
|
|
ts.it_interval.tv_nsec = 0;
|
|
|
|
ts.it_value.tv_sec = 0;
|
|
|
|
ts.it_value.tv_nsec = 0;
|
|
|
|
|
|
|
|
timerfd_settime(input->repeat.timerfd, 0, &ts, NULL);
|
|
|
|
}
|
|
|
|
else if ((state) &&
|
|
|
|
((!input->repeat.key) ||
|
|
|
|
((keycode) && (keycode != input->repeat.key))))
|
|
|
|
{
|
|
|
|
input->repeat.sym = sym;
|
|
|
|
input->repeat.key = keycode;
|
|
|
|
input->repeat.time = timestamp;
|
|
|
|
|
|
|
|
/* interval after expires */
|
|
|
|
ts.it_interval.tv_sec = 0;
|
|
|
|
ts.it_interval.tv_nsec = 35 * 1000 * 1000;
|
|
|
|
|
|
|
|
/* initial expiration */
|
|
|
|
ts.it_value.tv_sec = 0;
|
|
|
|
ts.it_value.tv_nsec = 500 * 1000 * 1000;
|
|
|
|
|
|
|
|
timerfd_settime(input->repeat.timerfd, 0, &ts, NULL);
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_keyboard_modifiers(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial EINA_UNUSED, unsigned int depressed, unsigned int latched, unsigned int locked, unsigned int group)
|
2012-06-06 01:18:58 -07:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = data)) return;
|
2012-08-23 04:25:45 -07:00
|
|
|
xkb_state_update_mask(input->xkb.state, depressed, latched,
|
|
|
|
locked, 0, 0, group);
|
2012-06-06 01:18:58 -07:00
|
|
|
}
|
|
|
|
|
2012-08-09 02:57:47 -07:00
|
|
|
static Eina_Bool
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_keyboard_repeat(void *data, Ecore_Fd_Handler *handler EINA_UNUSED)
|
2012-08-09 02:57:47 -07:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
Ecore_Wl_Window *win = NULL;
|
|
|
|
unsigned long long int xp;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = data)) return ECORE_CALLBACK_RENEW;
|
|
|
|
|
|
|
|
/* Trap for EAGAIN */
|
|
|
|
if (read(input->repeat.timerfd, &xp, sizeof(xp)) != sizeof(xp))
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
|
|
|
|
if ((win = input->keyboard_focus))
|
|
|
|
_ecore_wl_input_cb_keyboard_key(input, NULL, input->display->serial,
|
|
|
|
input->repeat.time,
|
|
|
|
input->repeat.key, EINA_TRUE);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
static void
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_cb_pointer_enter(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
Ecore_Wl_Window *win = NULL;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-07-26 00:23:32 -07:00
|
|
|
if (!surface) return;
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!(input = data)) return;
|
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
if (!input->timestamp)
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
2012-04-17 12:06:23 -07:00
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
input->timestamp = (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2012-07-04 00:16:29 -07:00
|
|
|
input->sx = wl_fixed_to_double(sx);
|
|
|
|
input->sy = wl_fixed_to_double(sy);
|
2012-04-24 09:59:35 -07:00
|
|
|
input->display->serial = serial;
|
|
|
|
input->pointer_enter_serial = serial;
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
/* The cursor on the surface is undefined until we set it */
|
2012-08-16 02:37:52 -07:00
|
|
|
ecore_wl_input_cursor_from_name_set(input, "left_ptr");
|
2012-06-06 01:18:58 -07:00
|
|
|
|
2012-10-16 04:57:19 -07:00
|
|
|
if ((win = wl_surface_get_user_data(surface)))
|
|
|
|
{
|
|
|
|
win->pointer_device = input;
|
|
|
|
input->pointer_focus = win;
|
|
|
|
|
|
|
|
_ecore_wl_input_mouse_in_send(input, win, input->timestamp);
|
|
|
|
}
|
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
/* NB: This whole 'if' below is a major HACK due to wayland's stupidness
|
|
|
|
* of not sending a mouse_up (or any notification at all for that matter)
|
|
|
|
* when a move or resize grab is finished */
|
|
|
|
if (input->grab)
|
|
|
|
{
|
|
|
|
/* NB: This COULD mean a move has finished, or it could mean that
|
|
|
|
* a 'drag' is being done to a different surface */
|
|
|
|
|
|
|
|
if ((input->grab == win) && (win->moving))
|
|
|
|
{
|
|
|
|
/* NB: 'Fake' a mouse_up for move finished */
|
|
|
|
win->moving = EINA_FALSE;
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_mouse_up_send(input, win, 0,
|
2013-04-10 10:45:12 -07:00
|
|
|
BTN_LEFT, input->timestamp);
|
2012-04-24 09:59:35 -07:00
|
|
|
|
|
|
|
if ((input->grab) && (input->grab_button == BTN_LEFT))
|
|
|
|
ecore_wl_input_ungrab(input);
|
|
|
|
}
|
|
|
|
else if ((input->grab == win) && (win->resizing))
|
|
|
|
{
|
|
|
|
/* NB: 'Fake' a mouse_up for resize finished */
|
|
|
|
win->resizing = EINA_FALSE;
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_mouse_up_send(input, win, 0,
|
2013-04-10 10:45:12 -07:00
|
|
|
BTN_LEFT, input->timestamp);
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
if ((input->grab) && (input->grab_button == BTN_LEFT))
|
|
|
|
ecore_wl_input_ungrab(input);
|
|
|
|
}
|
|
|
|
/* FIXME: Test d-n-d and potentially add needed case here */
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_pointer_leave(void *data, struct wl_pointer *pointer EINA_UNUSED, unsigned int serial, struct wl_surface *surface)
|
2012-03-08 18:36:00 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
2012-04-24 09:59:35 -07:00
|
|
|
Ecore_Wl_Window *win;
|
2012-03-08 18:36:00 -08:00
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-08-03 06:27:05 -07:00
|
|
|
if (!surface) return;
|
2012-03-08 18:36:00 -08:00
|
|
|
if (!(input = data)) return;
|
2012-04-17 14:55:25 -07:00
|
|
|
|
2012-04-17 12:06:23 -07:00
|
|
|
input->display->serial = serial;
|
2012-04-17 14:55:25 -07:00
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
if (!surface) return;
|
|
|
|
if (!(win = wl_surface_get_user_data(surface))) return;
|
|
|
|
|
|
|
|
win->pointer_device = NULL;
|
|
|
|
input->pointer_focus = NULL;
|
|
|
|
|
2012-06-06 01:18:58 -07:00
|
|
|
/* _ecore_wl_input_mouse_move_send(input, win, input->timestamp); */
|
2012-04-24 09:59:35 -07:00
|
|
|
_ecore_wl_input_mouse_out_send(input, win, input->timestamp);
|
|
|
|
|
|
|
|
if (input->grab)
|
|
|
|
{
|
|
|
|
/* move or resize started */
|
|
|
|
|
|
|
|
/* printf("Pointer Leave WITH a Grab\n"); */
|
|
|
|
}
|
2012-03-08 18:36:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_keyboard_enter(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface, struct wl_array *keys EINA_UNUSED)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
Ecore_Wl_Window *win = NULL;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-08-03 06:27:05 -07:00
|
|
|
if (!surface) return;
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!(input = data)) return;
|
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
if (!input->timestamp)
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
input->timestamp = (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
|
|
|
}
|
2012-04-10 10:00:56 -07:00
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
input->display->serial = serial;
|
|
|
|
|
|
|
|
if (!(win = wl_surface_get_user_data(surface))) return;
|
|
|
|
|
2012-04-10 10:00:56 -07:00
|
|
|
win->keyboard_device = input;
|
2012-04-24 09:59:35 -07:00
|
|
|
input->keyboard_focus = win;
|
2012-04-10 10:00:56 -07:00
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
_ecore_wl_input_focus_in_send(input, win, input->timestamp);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
2012-03-08 18:36:00 -08:00
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_keyboard_leave(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface)
|
2012-03-08 18:36:00 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
2012-04-24 09:59:35 -07:00
|
|
|
Ecore_Wl_Window *win;
|
2012-03-08 18:36:00 -08:00
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-08-03 06:27:05 -07:00
|
|
|
if (!surface) return;
|
2012-03-08 18:36:00 -08:00
|
|
|
if (!(input = data)) return;
|
2012-04-24 09:59:35 -07:00
|
|
|
|
2012-08-09 02:57:47 -07:00
|
|
|
if (input->repeat.timerfd)
|
|
|
|
{
|
|
|
|
struct itimerspec ts;
|
|
|
|
|
|
|
|
ts.it_interval.tv_sec = 0;
|
|
|
|
ts.it_interval.tv_nsec = 0;
|
|
|
|
ts.it_value.tv_sec = 0;
|
|
|
|
ts.it_value.tv_nsec = 0;
|
|
|
|
|
|
|
|
timerfd_settime(input->repeat.timerfd, 0, &ts, NULL);
|
|
|
|
}
|
|
|
|
|
2012-04-24 09:59:35 -07:00
|
|
|
if (!input->timestamp)
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
input->timestamp = (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
|
|
|
}
|
|
|
|
|
2012-04-17 12:06:23 -07:00
|
|
|
input->display->serial = serial;
|
2012-04-24 09:59:35 -07:00
|
|
|
|
|
|
|
if (!surface) return;
|
|
|
|
if (!(win = wl_surface_get_user_data(surface))) return;
|
|
|
|
|
|
|
|
win->keyboard_device = NULL;
|
|
|
|
_ecore_wl_input_focus_out_send(input, win, input->timestamp);
|
2012-08-09 02:57:47 -07:00
|
|
|
|
|
|
|
input->keyboard_focus = NULL;
|
2012-03-08 18:36:00 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
static void
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_cb_touch_down(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int serial, unsigned int timestamp, struct wl_surface *surface EINA_UNUSED, int id, wl_fixed_t x, wl_fixed_t y)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-08-03 06:27:05 -07:00
|
|
|
if (!surface) return;
|
2012-02-28 13:55:51 -08:00
|
|
|
if (!(input = data)) return;
|
|
|
|
|
|
|
|
/* 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; */
|
2012-04-17 12:06:23 -07:00
|
|
|
input->display->serial = serial;
|
2012-05-15 04:58:21 -07:00
|
|
|
input->sx = wl_fixed_to_int(x);
|
|
|
|
input->sy = wl_fixed_to_int(y);
|
2012-08-22 08:53:29 -07:00
|
|
|
_ecore_wl_input_cb_pointer_enter(data, NULL, serial, surface, x, y);
|
2013-04-10 10:45:12 -07:00
|
|
|
_ecore_wl_input_mouse_down_send(input, input->pointer_focus,
|
2013-05-07 12:18:06 -07:00
|
|
|
id, BTN_LEFT, timestamp);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int serial, unsigned int timestamp, int id)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = data)) return;
|
|
|
|
|
|
|
|
/* 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; */
|
2012-04-17 12:06:23 -07:00
|
|
|
input->display->serial = serial;
|
2013-04-10 10:45:12 -07:00
|
|
|
_ecore_wl_input_mouse_up_send(input, input->pointer_focus,
|
2013-05-07 12:18:06 -07:00
|
|
|
id, BTN_LEFT, timestamp);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_cb_touch_motion(void *data, struct wl_touch *touch EINA_UNUSED, unsigned int timestamp, int id, wl_fixed_t x, wl_fixed_t y)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Input *input;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(input = data)) return;
|
|
|
|
|
|
|
|
/* 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; */
|
2012-05-15 04:58:21 -07:00
|
|
|
input->sx = wl_fixed_to_int(x);
|
|
|
|
input->sy = wl_fixed_to_int(y);
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_mouse_move_send(input, input->pointer_focus, timestamp, id);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_touch_frame(void *data EINA_UNUSED, struct wl_touch *touch EINA_UNUSED)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_cb_touch_cancel(void *data EINA_UNUSED, struct wl_touch *touch EINA_UNUSED)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-04 00:16:29 -07:00
|
|
|
_ecore_wl_input_cb_data_offer(void *data, struct wl_data_device *data_device, struct wl_data_offer *offer)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-07-04 00:16:29 -07:00
|
|
|
_ecore_wl_dnd_add(data, data_device, offer);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-15 04:58:21 -07:00
|
|
|
_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)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
2012-08-03 06:27:05 -07:00
|
|
|
if (!surface) return;
|
|
|
|
|
2012-02-28 13:55:51 -08:00
|
|
|
_ecore_wl_dnd_enter(data, data_device, timestamp, surface, x, y, offer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_wl_input_cb_data_leave(void *data, struct wl_data_device *data_device)
|
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
_ecore_wl_dnd_leave(data, data_device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-15 04:58:21 -07:00
|
|
|
_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)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
_ecore_wl_dnd_motion(data, data_device, timestamp, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_wl_input_cb_data_drop(void *data, struct wl_data_device *data_device)
|
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
_ecore_wl_dnd_drop(data, data_device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_wl_input_cb_data_selection(void *data, struct wl_data_device *data_device, struct wl_data_offer *offer)
|
|
|
|
{
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
_ecore_wl_dnd_selection(data, data_device, offer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int timestamp, int device)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Event_Mouse_Move *ev;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Move)))) return;
|
|
|
|
|
|
|
|
ev->timestamp = timestamp;
|
|
|
|
ev->x = input->sx;
|
|
|
|
ev->y = input->sy;
|
2012-04-24 09:59:35 -07:00
|
|
|
/* ev->root.x = input->sx; */
|
|
|
|
/* ev->root.y = input->sy; */
|
2012-10-06 08:58:27 -07:00
|
|
|
ev->modifiers = input->modifiers;
|
2013-05-07 12:18:06 -07:00
|
|
|
ev->multi.device = device;
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->multi.radius = 1;
|
|
|
|
ev->multi.radius_x = 1;
|
|
|
|
ev->multi.radius_y = 1;
|
|
|
|
ev->multi.pressure = 1.0;
|
|
|
|
ev->multi.angle = 0.0;
|
|
|
|
ev->multi.x = input->sx;
|
|
|
|
ev->multi.y = input->sy;
|
|
|
|
|
2012-08-17 01:52:35 -07:00
|
|
|
if (win)
|
|
|
|
{
|
|
|
|
ev->window = win->id;
|
|
|
|
ev->event_window = win->id;
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2012-03-26 19:13:34 -07:00
|
|
|
ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-17 14:55:25 -07:00
|
|
|
_ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int timestamp)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Event_Mouse_In *ev;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Mouse_In)))) return;
|
|
|
|
|
|
|
|
ev->x = input->sx;
|
|
|
|
ev->y = input->sy;
|
2012-04-24 09:59:35 -07:00
|
|
|
/* ev->root.x = input->sx; */
|
|
|
|
/* ev->root.y = input->sy; */
|
2012-10-06 08:58:27 -07:00
|
|
|
ev->modifiers = input->modifiers;
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->timestamp = timestamp;
|
|
|
|
|
2012-08-17 01:52:35 -07:00
|
|
|
if (win)
|
|
|
|
{
|
|
|
|
ev->window = win->id;
|
|
|
|
ev->event_window = win->id;
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
|
2012-03-26 19:13:34 -07:00
|
|
|
ecore_event_add(ECORE_WL_EVENT_MOUSE_IN, ev, NULL, NULL);
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-17 14:55:25 -07:00
|
|
|
_ecore_wl_input_mouse_out_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int timestamp)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Event_Mouse_Out *ev;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Mouse_Out)))) return;
|
|
|
|
|
|
|
|
ev->x = input->sx;
|
|
|
|
ev->y = input->sy;
|
2012-04-24 09:59:35 -07:00
|
|
|
/* ev->root.x = input->sx; */
|
|
|
|
/* ev->root.y = input->sy; */
|
2012-10-06 08:58:27 -07:00
|
|
|
ev->modifiers = input->modifiers;
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->timestamp = timestamp;
|
|
|
|
|
2012-08-17 01:52:35 -07:00
|
|
|
if (win)
|
|
|
|
{
|
|
|
|
ev->window = win->id;
|
|
|
|
ev->event_window = win->id;
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
ecore_event_add(ECORE_WL_EVENT_MOUSE_OUT, ev, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_focus_in_send(Ecore_Wl_Input *input EINA_UNUSED, Ecore_Wl_Window *win, unsigned int timestamp)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Event_Focus_In *ev;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Focus_In)))) return;
|
|
|
|
ev->timestamp = timestamp;
|
2012-08-17 01:52:35 -07:00
|
|
|
if (win) ev->win = win->id;
|
2012-02-28 13:55:51 -08:00
|
|
|
ecore_event_add(ECORE_WL_EVENT_FOCUS_IN, ev, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_wl_input_focus_out_send(Ecore_Wl_Input *input EINA_UNUSED, Ecore_Wl_Window *win, unsigned int timestamp)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Wl_Event_Focus_Out *ev;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Focus_Out)))) return;
|
|
|
|
ev->timestamp = timestamp;
|
2012-08-17 01:52:35 -07:00
|
|
|
if (win) ev->win = win->id;
|
2012-02-28 13:55:51 -08:00
|
|
|
ecore_event_add(ECORE_WL_EVENT_FOCUS_OUT, ev, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int device, unsigned int button, unsigned int timestamp)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Event_Mouse_Button *ev;
|
2013-04-10 22:33:30 -07:00
|
|
|
Ecore_Wl_Mouse_Down_Info *down_info;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return;
|
|
|
|
|
2013-02-05 10:21:33 -08:00
|
|
|
if (button == BTN_LEFT)
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->buttons = 1;
|
2013-02-05 10:21:33 -08:00
|
|
|
else if (button == BTN_MIDDLE)
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->buttons = 2;
|
2013-02-05 10:21:33 -08:00
|
|
|
else if (button == BTN_RIGHT)
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->buttons = 3;
|
|
|
|
else
|
2013-02-05 10:21:33 -08:00
|
|
|
ev->buttons = button;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
ev->timestamp = timestamp;
|
|
|
|
ev->x = input->sx;
|
|
|
|
ev->y = input->sy;
|
2012-04-24 09:59:35 -07:00
|
|
|
/* ev->root.x = input->sx; */
|
|
|
|
/* ev->root.y = input->sy; */
|
2012-10-06 08:58:27 -07:00
|
|
|
ev->modifiers = input->modifiers;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
ev->double_click = 0;
|
|
|
|
ev->triple_click = 0;
|
|
|
|
|
2013-04-10 10:45:12 -07:00
|
|
|
/* handling double and triple click, taking into account multiple input
|
|
|
|
* devices */
|
2013-04-10 22:33:30 -07:00
|
|
|
if ((down_info = _ecore_wl_mouse_down_info_get(device)))
|
2013-04-10 10:45:12 -07:00
|
|
|
{
|
|
|
|
if (down_info->did_triple)
|
|
|
|
{
|
|
|
|
down_info->last_win = 0;
|
|
|
|
down_info->last_last_win = 0;
|
|
|
|
down_info->last_event_win = 0;
|
|
|
|
down_info->last_last_event_win = 0;
|
|
|
|
down_info->last_time = 0;
|
|
|
|
down_info->last_last_time = 0;
|
|
|
|
}
|
|
|
|
//Check Double Clicked
|
|
|
|
if (((int)(timestamp - down_info->last_time) <=
|
|
|
|
(int)(1000 * _ecore_wl_double_click_time)) &&
|
|
|
|
(win->id == down_info->last_win) &&
|
|
|
|
(win->id == down_info->last_event_win))
|
|
|
|
{
|
|
|
|
ev->double_click = 1;
|
|
|
|
down_info->did_double = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
down_info->did_double = EINA_FALSE;
|
|
|
|
down_info->did_triple = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Check Triple Clicked
|
|
|
|
if (((int)(timestamp - down_info->last_last_time) <=
|
|
|
|
(int)(2 * 1000 * _ecore_wl_double_click_time)) &&
|
|
|
|
(win->id == down_info->last_win) &&
|
|
|
|
(win->id == down_info->last_last_win) &&
|
|
|
|
(win->id == down_info->last_event_win) &&
|
|
|
|
(win->id == down_info->last_last_event_win)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ev->triple_click = 1;
|
|
|
|
down_info->did_triple = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
down_info->did_triple = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-07 12:18:06 -07:00
|
|
|
ev->multi.device = device;
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->multi.radius = 1;
|
|
|
|
ev->multi.radius_x = 1;
|
|
|
|
ev->multi.radius_y = 1;
|
|
|
|
ev->multi.pressure = 1.0;
|
|
|
|
ev->multi.angle = 0.0;
|
|
|
|
ev->multi.x = input->sx;
|
|
|
|
ev->multi.y = input->sy;
|
|
|
|
|
2012-08-17 01:52:35 -07:00
|
|
|
if (win)
|
|
|
|
{
|
|
|
|
ev->window = win->id;
|
|
|
|
ev->event_window = win->id;
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
|
2013-04-10 10:45:12 -07:00
|
|
|
|
|
|
|
if ((down_info) &&
|
|
|
|
(!down_info->did_triple))
|
|
|
|
{
|
|
|
|
down_info->last_last_win = down_info->last_win;
|
|
|
|
down_info->last_win = win->id;
|
|
|
|
down_info->last_last_event_win = down_info->last_event_win;
|
|
|
|
down_info->last_event_win = win->id;
|
|
|
|
down_info->last_last_time = down_info->last_time;
|
|
|
|
down_info->last_time = timestamp;
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int device, unsigned int button, unsigned int timestamp)
|
2012-02-28 13:55:51 -08:00
|
|
|
{
|
|
|
|
Ecore_Event_Mouse_Button *ev;
|
2013-04-10 22:33:30 -07:00
|
|
|
Ecore_Wl_Mouse_Down_Info *down_info;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return;
|
|
|
|
|
2013-02-05 10:21:33 -08:00
|
|
|
if (button == BTN_LEFT)
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->buttons = 1;
|
2013-02-05 10:21:33 -08:00
|
|
|
else if (button == BTN_MIDDLE)
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->buttons = 2;
|
2013-02-05 10:21:33 -08:00
|
|
|
else if (button == BTN_RIGHT)
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->buttons = 3;
|
|
|
|
else
|
2013-02-05 10:21:33 -08:00
|
|
|
ev->buttons = button;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
ev->timestamp = timestamp;
|
|
|
|
ev->x = input->sx;
|
|
|
|
ev->y = input->sy;
|
2012-04-24 09:59:35 -07:00
|
|
|
/* ev->root.x = input->sx; */
|
|
|
|
/* ev->root.y = input->sy; */
|
2012-10-06 08:58:27 -07:00
|
|
|
ev->modifiers = input->modifiers;
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
ev->double_click = 0;
|
|
|
|
ev->triple_click = 0;
|
|
|
|
|
2013-04-10 22:33:30 -07:00
|
|
|
if ((down_info = _ecore_wl_mouse_down_info_get(device)))
|
2013-04-10 10:45:12 -07:00
|
|
|
{
|
|
|
|
if (down_info->did_double)
|
|
|
|
ev->double_click = 1;
|
|
|
|
if (down_info->did_triple)
|
|
|
|
ev->triple_click = 1;
|
|
|
|
}
|
|
|
|
|
2013-05-07 12:18:06 -07:00
|
|
|
ev->multi.device = device;
|
2012-02-28 13:55:51 -08:00
|
|
|
ev->multi.radius = 1;
|
|
|
|
ev->multi.radius_x = 1;
|
|
|
|
ev->multi.radius_y = 1;
|
|
|
|
ev->multi.pressure = 1.0;
|
|
|
|
ev->multi.angle = 0.0;
|
|
|
|
ev->multi.x = input->sx;
|
|
|
|
ev->multi.y = input->sy;
|
|
|
|
|
2012-08-17 01:52:35 -07:00
|
|
|
if (win)
|
|
|
|
{
|
|
|
|
ev->window = win->id;
|
|
|
|
ev->event_window = win->id;
|
|
|
|
}
|
2012-02-28 13:55:51 -08:00
|
|
|
|
|
|
|
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
|
|
|
|
}
|
2012-03-27 10:50:40 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_wl_input_mouse_wheel_send(Ecore_Wl_Input *input, unsigned int axis, int value, unsigned int timestamp)
|
|
|
|
{
|
|
|
|
Ecore_Event_Mouse_Wheel *ev;
|
|
|
|
|
|
|
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Wheel)))) return;
|
|
|
|
|
|
|
|
ev->timestamp = timestamp;
|
2012-10-06 08:58:27 -07:00
|
|
|
ev->modifiers = input->modifiers;
|
2012-03-27 10:50:40 -07:00
|
|
|
ev->x = input->sx;
|
|
|
|
ev->y = input->sy;
|
2012-04-24 09:59:35 -07:00
|
|
|
/* ev->root.x = input->sx; */
|
|
|
|
/* ev->root.y = input->sy; */
|
2012-03-27 10:50:40 -07:00
|
|
|
|
2012-05-22 01:17:30 -07:00
|
|
|
if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
2012-03-27 10:50:40 -07:00
|
|
|
{
|
2012-05-15 04:58:21 -07:00
|
|
|
ev->direction = 0;
|
2012-10-17 14:50:31 -07:00
|
|
|
ev->z = value;
|
2012-03-27 10:50:40 -07:00
|
|
|
}
|
2012-05-22 01:17:30 -07:00
|
|
|
else if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
|
2012-03-27 10:50:40 -07:00
|
|
|
{
|
2012-05-15 04:58:21 -07:00
|
|
|
ev->direction = 1;
|
2012-10-17 14:50:31 -07:00
|
|
|
ev->z = value;
|
2012-03-27 10:50:40 -07:00
|
|
|
}
|
|
|
|
|
2012-04-10 10:00:56 -07:00
|
|
|
if (input->grab)
|
|
|
|
{
|
|
|
|
ev->window = input->grab->id;
|
|
|
|
ev->event_window = input->grab->id;
|
|
|
|
}
|
|
|
|
else if (input->pointer_focus)
|
2012-03-27 10:50:40 -07:00
|
|
|
{
|
|
|
|
ev->window = input->pointer_focus->id;
|
|
|
|
ev->event_window = input->pointer_focus->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
|
|
|
|
}
|
2012-08-28 23:35:02 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
_ecore_wl_input_set_selection(Ecore_Wl_Input *input, struct wl_data_source *source)
|
|
|
|
{
|
|
|
|
wl_data_device_set_selection(input->data_device, source, input->display->serial);
|
|
|
|
}
|
2012-10-05 06:46:35 -07:00
|
|
|
|
2013-04-10 10:45:12 -07:00
|
|
|
static void
|
|
|
|
_ecore_wl_mouse_down_info_clear(void)
|
|
|
|
{
|
2013-04-10 22:33:30 -07:00
|
|
|
Eina_Inlist *l;
|
2013-04-10 10:45:12 -07:00
|
|
|
Ecore_Wl_Mouse_Down_Info *info = NULL;
|
2013-04-10 22:33:30 -07:00
|
|
|
|
|
|
|
l = _ecore_wl_mouse_down_info_list;
|
2013-04-10 10:45:12 -07:00
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
info = EINA_INLIST_CONTAINER_GET(l, Ecore_Wl_Mouse_Down_Info);
|
|
|
|
l = eina_inlist_remove(l, l);
|
|
|
|
free(info);
|
|
|
|
}
|
|
|
|
_ecore_wl_mouse_down_info_list = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Ecore_Wl_Mouse_Down_Info *
|
2013-05-07 12:18:06 -07:00
|
|
|
_ecore_wl_mouse_down_info_get(int dev)
|
2013-04-10 10:45:12 -07:00
|
|
|
{
|
2013-04-10 22:33:30 -07:00
|
|
|
Eina_Inlist *l = NULL;
|
2013-04-10 10:45:12 -07:00
|
|
|
Ecore_Wl_Mouse_Down_Info *info = NULL;
|
|
|
|
|
|
|
|
//Return the exist info
|
2013-04-10 22:33:30 -07:00
|
|
|
l = _ecore_wl_mouse_down_info_list;
|
2013-04-10 10:45:12 -07:00
|
|
|
EINA_INLIST_FOREACH(l, info)
|
|
|
|
if (info->dev == dev) return info;
|
|
|
|
|
|
|
|
//New Device. Add it.
|
|
|
|
info = calloc(1, sizeof(Ecore_Wl_Mouse_Down_Info));
|
|
|
|
if (!info) return NULL;
|
|
|
|
|
|
|
|
info->dev = dev;
|
|
|
|
l = eina_inlist_append(l, (Eina_Inlist *)info);
|
|
|
|
_ecore_wl_mouse_down_info_list = l;
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_ecore_wl_events_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_ecore_wl_events_shutdown(void)
|
|
|
|
{
|
|
|
|
_ecore_wl_mouse_down_info_clear();
|
|
|
|
}
|