summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-07-15 10:06:20 -0400
committerChris Michael <cp.michael@samsung.com>2015-08-04 09:28:01 -0400
commit667d7b15c9b7779e3cf5815ee062e47109077256 (patch)
tree28f574baf2133d429d7f1b37eb2fc19c56efe108
parent377bf414b1ebc78c8f852d0a1dc5f38d2a06e2d2 (diff)
ecore-wl: Support wl_keyboard_send_repeat_info for adjusting keyboard repeat rate and delay
Summary: This adds support for allowing a client/compositor to adjust the keyboard repeat rate and delay via a call to wl_keyboard_send_repeat_info. @feature Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/lib/ecore_wayland/ecore_wl_input.c34
-rw-r--r--src/lib/ecore_wayland/ecore_wl_private.h2
2 files changed, 34 insertions, 2 deletions
diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c
index ea33346638..9bdd93283e 100644
--- a/src/lib/ecore_wayland/ecore_wl_input.c
+++ b/src/lib/ecore_wayland/ecore_wl_input.c
@@ -68,6 +68,7 @@ static void _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_keyboard *ke
68static void _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface); 68static void _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, struct wl_surface *surface);
69static 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); 69static 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);
70static 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); 70static 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);
71static void _ecore_wl_input_cb_keyboard_repeat_setup(void *data, struct wl_keyboard *keyboard EINA_UNUSED, int32_t rate, int32_t delay);
71static Eina_Bool _ecore_wl_input_cb_keyboard_repeat(void *data); 72static Eina_Bool _ecore_wl_input_cb_keyboard_repeat(void *data);
72static 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); 73static 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);
73static void _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch, unsigned int serial, unsigned int timestamp, int id EINA_UNUSED); 74static void _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch, unsigned int serial, unsigned int timestamp, int id EINA_UNUSED);
@@ -110,6 +111,7 @@ static const struct wl_keyboard_listener keyboard_listener =
110 _ecore_wl_input_cb_keyboard_leave, 111 _ecore_wl_input_cb_keyboard_leave,
111 _ecore_wl_input_cb_keyboard_key, 112 _ecore_wl_input_cb_keyboard_key,
112 _ecore_wl_input_cb_keyboard_modifiers, 113 _ecore_wl_input_cb_keyboard_modifiers,
114 _ecore_wl_input_cb_keyboard_repeat_setup,
113}; 115};
114 116
115static const struct wl_touch_listener touch_listener = 117static const struct wl_touch_listener touch_listener =
@@ -390,6 +392,10 @@ _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id)
390 input->keyboard_focus = NULL; 392 input->keyboard_focus = NULL;
391 input->touch_focus = NULL; 393 input->touch_focus = NULL;
392 394
395 input->repeat.enabled = EINA_TRUE;
396 input->repeat.rate = 0.025;
397 input->repeat.delay = 0.4;
398
393 if (ewd->wl.shm) 399 if (ewd->wl.shm)
394 _ecore_wl_input_setup(input); 400 _ecore_wl_input_setup(input);
395 input->seat = 401 input->seat =
@@ -846,6 +852,8 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
846 } 852 }
847 else if ((state) && (keycode != input->repeat.key)) 853 else if ((state) && (keycode != input->repeat.key))
848 { 854 {
855 if (!input->repeat.enabled) return;
856
849 input->repeat.sym = sym; 857 input->repeat.sym = sym;
850 input->repeat.key = keycode; 858 input->repeat.key = keycode;
851 input->repeat.time = timestamp; 859 input->repeat.time = timestamp;
@@ -853,9 +861,10 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
853 if (!input->repeat.tmr) 861 if (!input->repeat.tmr)
854 { 862 {
855 input->repeat.tmr = 863 input->repeat.tmr =
856 ecore_timer_add(0.025, _ecore_wl_input_cb_keyboard_repeat, input); 864 ecore_timer_add(input->repeat.rate,
865 _ecore_wl_input_cb_keyboard_repeat, input);
857 } 866 }
858 ecore_timer_delay(input->repeat.tmr, 0.4); 867 ecore_timer_delay(input->repeat.tmr, input->repeat.delay);
859 } 868 }
860} 869}
861 870
@@ -896,6 +905,27 @@ _ecore_wl_input_cb_keyboard_modifiers(void *data, struct wl_keyboard *keyboard E
896 input->modifiers |= ECORE_EVENT_MODIFIER_ALTGR; 905 input->modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
897} 906}
898 907
908static void
909_ecore_wl_input_cb_keyboard_repeat_setup(void *data, struct wl_keyboard *keyboard EINA_UNUSED, int32_t rate, int32_t delay)
910{
911 Ecore_Wl_Input *input;
912
913 LOGFN(__FILE__, __LINE__, __FUNCTION__);
914
915 if (!(input = data)) return;
916
917 if (rate == 0)
918 {
919 input->repeat.enabled = EINA_FALSE;
920 return;
921 }
922 else
923 input->repeat.enabled = EINA_TRUE;
924
925 input->repeat.rate = (rate / 1000);
926 input->repeat.delay = (delay / 100);
927}
928
899static Eina_Bool 929static Eina_Bool
900_ecore_wl_input_cb_keyboard_repeat(void *data) 930_ecore_wl_input_cb_keyboard_repeat(void *data)
901{ 931{
diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h
index 21daf65492..349347203f 100644
--- a/src/lib/ecore_wayland/ecore_wl_private.h
+++ b/src/lib/ecore_wayland/ecore_wl_private.h
@@ -237,6 +237,8 @@ struct _Ecore_Wl_Input
237 { 237 {
238 Ecore_Timer *tmr; 238 Ecore_Timer *tmr;
239 unsigned int sym, key, time; 239 unsigned int sym, key, time;
240 double rate, delay;
241 Eina_Bool enabled : 1;
240 } repeat; 242 } repeat;
241}; 243};
242 244