summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-07-22 11:39:12 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-07-22 11:39:12 +0200
commit29aa5a35b84f18490d2b94acd91abe3c8c78e0c8 (patch)
treeb411b6d00b0fe6f5975f082129f89007e772f275
parentbfb50d06ea87f0c5fb9aa88b7dc571a3a2a67d05 (diff)
mod: make the timer better
repeated keypresses are now staying on the screen, instead of flickering arround.
-rw-r--r--src/e_mod_main.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/e_mod_main.c b/src/e_mod_main.c
index e56dd2d..0447642 100644
--- a/src/e_mod_main.c
+++ b/src/e_mod_main.c
@@ -20,6 +20,17 @@ typedef struct {
20 Ecore_Timer *timer; 20 Ecore_Timer *timer;
21} Entry; 21} Entry;
22 22
23static void _del_key(const char *name);
24
25static Eina_Bool
26_timed_del(void *data)
27{
28 Entry *e = data;
29 _del_key(e->name);
30 e->timer = NULL;
31 return 0;
32}
33
23static void 34static void
24_del_key(const char *name) 35_del_key(const char *name)
25{ 36{
@@ -34,6 +45,13 @@ _del_key(const char *name)
34 45
35 //deref the entry 46 //deref the entry
36 e->ref --; 47 e->ref --;
48
49 if (e->ref == 1)
50 {
51 if (e->timer) ecore_timer_del(e->timer);
52 e->timer = ecore_timer_add(0.5, _timed_del, e);
53 }
54
37 //free if null 55 //free if null
38 if (e->ref == 0) 56 if (e->ref == 0)
39 { 57 {
@@ -47,15 +65,6 @@ _del_key(const char *name)
47 } 65 }
48} 66}
49 67
50static Eina_Bool
51_timed_del(void *data)
52{
53 Entry *e = data;
54 _del_key(e->name);
55
56 return 0;
57}
58
59static void 68static void
60_add_key(const char *name) 69_add_key(const char *name)
61{ 70{
@@ -68,7 +77,7 @@ _add_key(const char *name)
68 if (e) 77 if (e)
69 { 78 {
70 e->ref ++; 79 e->ref ++;
71 ecore_timer_reset(e->timer); 80 E_FREE_FUNC(e->timer, ecore_timer_del);
72 return; 81 return;
73 } 82 }
74 83
@@ -93,7 +102,6 @@ _add_key(const char *name)
93 e->name = strdup(name); 102 e->name = strdup(name);
94 entry_counter ++; 103 entry_counter ++;
95 eina_hash_add(string_hash, name, e); 104 eina_hash_add(string_hash, name, e);
96 e->timer = ecore_timer_add(0.5, _timed_del, e);
97} 105}
98 106
99static void 107static void