summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2013-09-10 15:58:46 +0100
committerChris Michael <cp.michael@samsung.com>2013-09-10 15:59:40 +0100
commit164299e689b6e08aa64024209710831e9bd63a29 (patch)
tree2f36ea3d21cefc8a1490f0a81929a0dd1dcf8f98
parent77cf31d322231d0459eefecad51b6f15a236c498 (diff)
Rework keyboard repeat to use an ecore_timer (not a timerfd).
NB: This fixes keyboard repeat in terminology (under wayland) to be sane again :) Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/lib/ecore_wayland/Ecore_Wayland.h3
-rw-r--r--src/lib/ecore_wayland/ecore_wl_input.c66
2 files changed, 16 insertions, 53 deletions
diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h
index f21aad2fca..c43ae49ea3 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -192,8 +192,7 @@ struct _Ecore_Wl_Input
192 192
193 struct 193 struct
194 { 194 {
195 Ecore_Fd_Handler *hdlr; 195 Ecore_Timer *tmr;
196 int timerfd;
197 unsigned int sym, key, time; 196 unsigned int sym, key, time;
198 } repeat; 197 } repeat;
199}; 198};
diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c
index 0ece81b2d8..6f56e9f666 100644
--- a/src/lib/ecore_wayland/ecore_wl_input.c
+++ b/src/lib/ecore_wayland/ecore_wl_input.c
@@ -19,7 +19,6 @@
19 19
20#include "ecore_wl_private.h" 20#include "ecore_wl_private.h"
21#include <sys/mman.h> 21#include <sys/mman.h>
22#include <sys/timerfd.h>
23#include <ctype.h> 22#include <ctype.h>
24 23
25/* FIXME: This gives BTN_LEFT/RIGHT/MIDDLE for linux systems ... 24/* FIXME: This gives BTN_LEFT/RIGHT/MIDDLE for linux systems ...
@@ -69,7 +68,7 @@ static void _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_keyboard *ke
69static 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);
70static 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);
71static 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);
72static Eina_Bool _ecore_wl_input_cb_keyboard_repeat(void *data, Ecore_Fd_Handler *handler EINA_UNUSED); 71static Eina_Bool _ecore_wl_input_cb_keyboard_repeat(void *data);
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); 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);
74static void _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch, unsigned int serial, unsigned int timestamp, int id EINA_UNUSED); 73static void _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch, unsigned int serial, unsigned int timestamp, int id EINA_UNUSED);
75static 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); 74static 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);
@@ -320,14 +319,6 @@ _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id)
320 input->cursor_surface = 319 input->cursor_surface =
321 wl_compositor_create_surface(_ecore_wl_disp->wl.compositor); 320 wl_compositor_create_surface(_ecore_wl_disp->wl.compositor);
322 321
323 input->repeat.timerfd =
324 timerfd_create(CLOCK_MONOTONIC, (TFD_CLOEXEC | TFD_NONBLOCK));
325
326 input->repeat.hdlr =
327 ecore_main_fd_handler_add(input->repeat.timerfd, ECORE_FD_READ,
328 _ecore_wl_input_cb_keyboard_repeat, input,
329 NULL, NULL);
330
331 ewd->input = input; 322 ewd->input = input;
332} 323}
333 324
@@ -382,11 +373,8 @@ _ecore_wl_input_del(Ecore_Wl_Input *input)
382 wl_list_remove(&input->link); 373 wl_list_remove(&input->link);
383 if (input->seat) wl_seat_destroy(input->seat); 374 if (input->seat) wl_seat_destroy(input->seat);
384 375
385 if (input->repeat.hdlr) ecore_main_fd_handler_del(input->repeat.hdlr); 376 if (input->repeat.tmr) ecore_timer_del(input->repeat.tmr);
386 input->repeat.hdlr = NULL; 377 input->repeat.tmr = NULL;
387
388 if (input->repeat.timerfd) close(input->repeat.timerfd);
389 input->repeat.timerfd = 0;
390 378
391 free(input); 379 free(input);
392} 380}
@@ -638,7 +626,6 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
638 xkb_keysym_t sym = XKB_KEY_NoSymbol; 626 xkb_keysym_t sym = XKB_KEY_NoSymbol;
639 char key[32], keyname[32], compose[32]; 627 char key[32], keyname[32], compose[32];
640 Ecore_Event_Key *e; 628 Ecore_Event_Key *e;
641 struct itimerspec ts;
642 629
643 LOGFN(__FILE__, __LINE__, __FUNCTION__); 630 LOGFN(__FILE__, __LINE__, __FUNCTION__);
644 631
@@ -707,30 +694,21 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
707 input->repeat.key = 0; 694 input->repeat.key = 0;
708 input->repeat.time = 0; 695 input->repeat.time = 0;
709 696
710 ts.it_interval.tv_sec = 0; 697 if (input->repeat.tmr) ecore_timer_del(input->repeat.tmr);
711 ts.it_interval.tv_nsec = 0; 698 input->repeat.tmr = NULL;
712 ts.it_value.tv_sec = 0;
713 ts.it_value.tv_nsec = 0;
714
715 timerfd_settime(input->repeat.timerfd, 0, &ts, NULL);
716 } 699 }
717 else if ((state)) //&& 700 else if (state)
718 /* ((!input->repeat.key) || */
719 /* ((keycode) && (keycode != input->repeat.key)))) */
720 { 701 {
721 input->repeat.sym = sym; 702 input->repeat.sym = sym;
722 input->repeat.key = keycode; 703 input->repeat.key = keycode;
723 input->repeat.time = timestamp; 704 input->repeat.time = timestamp;
724 705
725 /* interval after expires */ 706 if (!input->repeat.tmr)
726 ts.it_interval.tv_sec = 0; 707 {
727 ts.it_interval.tv_nsec = 35 * 1000 * 1000; 708 input->repeat.tmr =
728 709 ecore_timer_add(0.025, _ecore_wl_input_cb_keyboard_repeat, input);
729 /* initial expiration */ 710 ecore_timer_delay(input->repeat.tmr, 0.4);
730 ts.it_value.tv_sec = 0; 711 }
731 ts.it_value.tv_nsec = 500 * 1000 * 1000;
732
733 timerfd_settime(input->repeat.timerfd, 0, &ts, NULL);
734 } 712 }
735} 713}
736 714
@@ -762,20 +740,15 @@ _ecore_wl_input_cb_keyboard_modifiers(void *data, struct wl_keyboard *keyboard E
762} 740}
763 741
764static Eina_Bool 742static Eina_Bool
765_ecore_wl_input_cb_keyboard_repeat(void *data, Ecore_Fd_Handler *handler EINA_UNUSED) 743_ecore_wl_input_cb_keyboard_repeat(void *data)
766{ 744{
767 Ecore_Wl_Input *input; 745 Ecore_Wl_Input *input;
768 Ecore_Wl_Window *win = NULL; 746 Ecore_Wl_Window *win = NULL;
769 unsigned long long int xp;
770 747
771 LOGFN(__FILE__, __LINE__, __FUNCTION__); 748 LOGFN(__FILE__, __LINE__, __FUNCTION__);
772 749
773 if (!(input = data)) return ECORE_CALLBACK_RENEW; 750 if (!(input = data)) return ECORE_CALLBACK_RENEW;
774 751
775 /* Trap for EAGAIN */
776 if (read(input->repeat.timerfd, &xp, sizeof(xp)) != sizeof(xp))
777 return ECORE_CALLBACK_RENEW;
778
779 if ((win = input->keyboard_focus)) 752 if ((win = input->keyboard_focus))
780 _ecore_wl_input_cb_keyboard_key(input, NULL, input->display->serial, 753 _ecore_wl_input_cb_keyboard_key(input, NULL, input->display->serial,
781 input->repeat.time, 754 input->repeat.time,
@@ -937,17 +910,8 @@ _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_keyboard *keyboard EINA_
937 if (!surface) return; 910 if (!surface) return;
938 if (!(input = data)) return; 911 if (!(input = data)) return;
939 912
940 if (input->repeat.timerfd) 913 if (input->repeat.tmr) ecore_timer_del(input->repeat.tmr);
941 { 914 input->repeat.tmr = NULL;
942 struct itimerspec ts;
943
944 ts.it_interval.tv_sec = 0;
945 ts.it_interval.tv_nsec = 0;
946 ts.it_value.tv_sec = 0;
947 ts.it_value.tv_nsec = 0;
948
949 timerfd_settime(input->repeat.timerfd, 0, &ts, NULL);
950 }
951 915
952 if (!input->timestamp) 916 if (!input->timestamp)
953 { 917 {