summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-05-19 18:46:30 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-05-19 18:51:03 +0100
commit048470f888153408d650e45364b96d3d0703b7f8 (patch)
treec240a8fe4fc6f4ae89e1e5e4b727806923a758da /src
parentf84d23ffd25a0e669087cf068d8fab355d5d824d (diff)
xkb - optimize handling of keymaps to only change them a few times
also listen to all xkb events properly.. @fix
Diffstat (limited to 'src')
-rw-r--r--src/bin/e_xkb.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/bin/e_xkb.c b/src/bin/e_xkb.c
index e33b17606..82b08a354 100644
--- a/src/bin/e_xkb.c
+++ b/src/bin/e_xkb.c
@@ -6,13 +6,15 @@ static void _e_xkb_type_reconfig(E_Pixmap_Type comp_type);
6static void _e_xkb_type_update(E_Pixmap_Type comp_type, int cur_group); 6static void _e_xkb_type_update(E_Pixmap_Type comp_type, int cur_group);
7 7
8static int _e_xkb_cur_group = -1; 8static int _e_xkb_cur_group = -1;
9static Ecore_Event_Handler *xkb_state_handler = NULL, *xkb_new_keyboard_handler = NULL;
10 9
11static Ecore_Exe *cur_exe; 10static Ecore_Exe *cur_exe;
12 11
13#ifndef HAVE_WAYLAND_ONLY 12#ifndef HAVE_WAYLAND_ONLY
13static Ecore_Event_Handler *xkb_state_handler = NULL;
14static Ecore_Event_Handler *xkb_new_keyboard_handler = NULL;
15static Ecore_Event_Handler *xkb_keymap_handler = NULL;
14static int skip_new_keyboard = 0; 16static int skip_new_keyboard = 0;
15static Ecore_Timer *save_group; 17static Ecore_Timer *save_group = NULL;
16#endif 18#endif
17 19
18E_API int E_EVENT_XKB_CHANGED = 0; 20E_API int E_EVENT_XKB_CHANGED = 0;
@@ -41,6 +43,7 @@ _eval_cur_group(void)
41 e_config->xkb.cur_group = 0; 43 e_config->xkb.cur_group = 0;
42} 44}
43 45
46#ifndef HAVE_WAYLAND_ONLY
44static Eina_Bool 47static Eina_Bool
45_e_xkb_init_timer(void *data EINA_UNUSED) 48_e_xkb_init_timer(void *data EINA_UNUSED)
46{ 49{
@@ -49,9 +52,10 @@ _e_xkb_init_timer(void *data EINA_UNUSED)
49 _eval_cur_group(); 52 _eval_cur_group();
50 53
51 e_xkb_update(e_config->xkb.cur_group); 54 e_xkb_update(e_config->xkb.cur_group);
52 55 ecore_x_xkb_track_state();
53 return EINA_FALSE; 56 return EINA_FALSE;
54} 57}
58#endif
55 59
56#ifndef HAVE_WAYLAND_ONLY 60#ifndef HAVE_WAYLAND_ONLY
57 61
@@ -64,12 +68,9 @@ _e_xkb_save_group(void *data)
64 { 68 {
65 e_config->xkb.cur_group = group; 69 e_config->xkb.cur_group = group;
66 e_config_save_queue(); 70 e_config_save_queue();
67
68 e_xkb_update(e_config->xkb.cur_group); 71 e_xkb_update(e_config->xkb.cur_group);
69 } 72 }
70
71 save_group = NULL; 73 save_group = NULL;
72
73 return EINA_FALSE; 74 return EINA_FALSE;
74} 75}
75 76
@@ -94,10 +95,15 @@ _xkb_new_state(void* data EINA_UNUSED, int type EINA_UNUSED, void *event)
94{ 95{
95 Ecore_X_Event_Xkb *ev = event; 96 Ecore_X_Event_Xkb *ev = event;
96 97
97 ecore_timer_del(save_group); 98 if (save_group) ecore_timer_del(save_group);
99 save_group = ecore_timer_loop_add(0.5, _e_xkb_save_group, (void *)(intptr_t)ev->group);
98 100
99 save_group = ecore_timer_loop_add(0.5, _e_xkb_save_group, (void*)(intptr_t)ev->group); 101 return ECORE_CALLBACK_PASS_ON;
102}
100 103
104static Eina_Bool
105_xkb_keymap(void* data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
106{
101 return ECORE_CALLBACK_PASS_ON; 107 return ECORE_CALLBACK_PASS_ON;
102} 108}
103#endif 109#endif
@@ -124,15 +130,19 @@ e_xkb_init(E_Pixmap_Type comp_type)
124 { 130 {
125 xkb_state_handler = ecore_event_handler_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, _xkb_new_state, NULL); 131 xkb_state_handler = ecore_event_handler_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, _xkb_new_state, NULL);
126 xkb_new_keyboard_handler = ecore_event_handler_add(ECORE_X_EVENT_XKB_NEWKBD_NOTIFY, _xkb_new_keyboard, NULL); 132 xkb_new_keyboard_handler = ecore_event_handler_add(ECORE_X_EVENT_XKB_NEWKBD_NOTIFY, _xkb_new_keyboard, NULL);
133 xkb_keymap_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_KEYMAP, _xkb_keymap, NULL);
127 } 134 }
128#endif 135#endif
129 if (e_config->xkb.dont_touch_my_damn_keyboard) return 1; 136 if (e_config->xkb.dont_touch_my_damn_keyboard) return 1;
130 137
131 _e_xkb_type_reconfig(comp_type); 138 _e_xkb_type_reconfig(comp_type);
132 139
140#ifndef HAVE_WAYLAND_ONLY
133 if (comp_type == E_PIXMAP_TYPE_X) 141 if (comp_type == E_PIXMAP_TYPE_X)
134 ecore_timer_loop_add(1.5, _e_xkb_init_timer, NULL); 142 ecore_timer_loop_add(1.5, _e_xkb_init_timer, NULL);
135 else if (comp_type == E_PIXMAP_TYPE_WL) 143 else
144#endif
145 if (comp_type == E_PIXMAP_TYPE_WL)
136 { 146 {
137 _eval_cur_group(); 147 _eval_cur_group();
138 _e_xkb_type_update(comp_type, e_config->xkb.cur_group); 148 _e_xkb_type_update(comp_type, e_config->xkb.cur_group);
@@ -144,9 +154,10 @@ e_xkb_init(E_Pixmap_Type comp_type)
144E_API int 154E_API int
145e_xkb_shutdown(void) 155e_xkb_shutdown(void)
146{ 156{
157#ifndef HAVE_WAYLAND_ONLY
158 E_FREE_FUNC(xkb_keymap_handler, ecore_event_handler_del);
147 E_FREE_FUNC(xkb_state_handler, ecore_event_handler_del); 159 E_FREE_FUNC(xkb_state_handler, ecore_event_handler_del);
148 E_FREE_FUNC(xkb_new_keyboard_handler, ecore_event_handler_del); 160 E_FREE_FUNC(xkb_new_keyboard_handler, ecore_event_handler_del);
149#ifndef HAVE_WAYLAND_ONLY
150 ecore_timer_del(save_group); 161 ecore_timer_del(save_group);
151 save_group = NULL; 162 save_group = NULL;
152#endif 163#endif
@@ -247,12 +258,16 @@ _e_x_xkb_update(int cur_group)
247 if (e_config->xkb.dont_touch_my_damn_keyboard) return; 258 if (e_config->xkb.dont_touch_my_damn_keyboard) return;
248 if ((!e_config->xkb.used_layouts) && (!e_config->xkb.used_options) && (!e_config->xkb.default_model)) return; 259 if ((!e_config->xkb.used_layouts) && (!e_config->xkb.used_options) && (!e_config->xkb.default_model)) return;
249 if (!getenv("DISPLAY")) return; 260 if (!getenv("DISPLAY")) return;
250 if (cur_group != -1) 261 if (cur_group != _e_xkb_cur_group)
251 { 262 {
252 _e_xkb_cur_group = cur_group; 263 _e_xkb_cur_group = cur_group;
253#ifndef HAVE_WAYLAND_ONLY 264#ifndef HAVE_WAYLAND_ONLY
254 if (e_comp->root) 265 if (e_comp->root)
255 ecore_x_xkb_select_group(cur_group); 266 {
267 e_comp_canvas_keys_ungrab();
268 ecore_x_xkb_select_group(cur_group);
269 e_comp_canvas_keys_grab();
270 }
256#endif 271#endif
257 e_deskenv_xmodmap_run(); 272 e_deskenv_xmodmap_run();
258 _e_xkb_update_event(cur_group); 273 _e_xkb_update_event(cur_group);