From 203507fa226d03edf74270d7c551751b137cbcb7 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 12 May 2017 12:09:18 -0400 Subject: [PATCH] add desklock interface handler for key press key presses during desklock should only be received by the lock implementation and not by any other handler. this ensures that nothing unexpected can happen with focus and simplifies overall key handling --- src/bin/e_comp_canvas.c | 6 ++++++ src/bin/e_desklock.c | 6 ++++++ src/bin/e_desklock.h | 4 ++++ src/modules/lokker/e_mod_main.c | 3 ++- src/modules/lokker/e_mod_main.h | 1 + src/modules/lokker/lokker.c | 7 ++----- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/bin/e_comp_canvas.c b/src/bin/e_comp_canvas.c index 91aa21d3b..654aa9851 100644 --- a/src/bin/e_comp_canvas.c +++ b/src/bin/e_comp_canvas.c @@ -106,6 +106,12 @@ static Eina_Bool _key_down(int ctx, Ecore_Event_Key *ev) { e_screensaver_notidle(); + if (e_desklock_state_get() && (ctx == E_BINDING_CONTEXT_MANAGER)) + { + E_Desklock_Interface *iface = e_desklock_interface_current_get(); + if (iface && iface->key_down) + return iface->key_down(ev); + } if ((e_comp->comp_type == E_PIXMAP_TYPE_X) && (ev->event_window != e_comp->root)) { E_Client *ec; diff --git a/src/bin/e_desklock.c b/src/bin/e_desklock.c index fc5a92a0d..07da1b669 100644 --- a/src/bin/e_desklock.c +++ b/src/bin/e_desklock.c @@ -147,6 +147,12 @@ e_desklock_interface_append(E_Desklock_Interface *iface) } } +EINTERN E_Desklock_Interface * +e_desklock_interface_current_get(void) +{ + return current_iface; +} + E_API void e_desklock_interface_remove(E_Desklock_Interface *iface) { diff --git a/src/bin/e_desklock.h b/src/bin/e_desklock.h index 6bc694e91..a25f9a50c 100644 --- a/src/bin/e_desklock.h +++ b/src/bin/e_desklock.h @@ -25,11 +25,14 @@ typedef struct E_Desklock_Interface E_Desklock_Interface; #ifndef E_DESKLOCK_H #define E_DESKLOCK_H +typedef Eina_Bool (*E_Desklock_Key_Cb)(Ecore_Event_Key*); + struct E_Desklock_Interface { const char *name; E_Desklock_Show_Cb show; E_Desklock_Hide_Cb hide; + E_Desklock_Key_Cb key_down; Eina_Bool active : 1; //interface is currently being used for locking }; @@ -50,6 +53,7 @@ E_API Eina_Bool e_desklock_state_get(void); E_API void e_desklock_interface_append(E_Desklock_Interface *iface); E_API void e_desklock_interface_remove(E_Desklock_Interface *iface); +EINTERN E_Desklock_Interface *e_desklock_interface_current_get(void); E_API Eina_Stringshare *e_desklock_user_wallpaper_get(E_Zone *zone); E_API void e_desklock_show_hook_add(E_Desklock_Show_Cb cb); E_API void e_desklock_show_hook_del(E_Desklock_Show_Cb cb); diff --git a/src/modules/lokker/e_mod_main.c b/src/modules/lokker/e_mod_main.c index 25064d76c..18fc250ce 100644 --- a/src/modules/lokker/e_mod_main.c +++ b/src/modules/lokker/e_mod_main.c @@ -7,7 +7,8 @@ static E_Desklock_Interface lokker_desklock_iface = { .name = "lokker", .show = lokker_lock, - .hide = lokker_unlock + .hide = lokker_unlock, + .key_down = lokker_key_down, }; E_API void * diff --git a/src/modules/lokker/e_mod_main.h b/src/modules/lokker/e_mod_main.h index 09c8e2be2..0ce0619f4 100644 --- a/src/modules/lokker/e_mod_main.h +++ b/src/modules/lokker/e_mod_main.h @@ -27,4 +27,5 @@ typedef enum EINTERN Eina_Bool lokker_lock(void); EINTERN void lokker_unlock(void); E_API E_Config_Dialog *e_int_config_lokker(Evas_Object *parent, const char *params EINA_UNUSED); +EINTERN Eina_Bool lokker_key_down(Ecore_Event_Key*); #endif diff --git a/src/modules/lokker/lokker.c b/src/modules/lokker/lokker.c index e7e34331e..b009093fd 100644 --- a/src/modules/lokker/lokker.c +++ b/src/modules/lokker/lokker.c @@ -722,11 +722,9 @@ _lokker_check_auth(void) return 0; } -static Eina_Bool -_lokker_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +EINTERN Eina_Bool +lokker_key_down(Ecore_Event_Key *ev) { - Ecore_Event_Key *ev = event; - if (!strcmp(ev->key, "Caps_Lock")) { if(ev->modifiers & ECORE_EVENT_LOCK_CAPS) @@ -829,7 +827,6 @@ lokker_lock(void) total_zone_num = eina_list_count(e_comp->zones); /* handlers */ - E_LIST_HANDLER_APPEND(edd->handlers, ECORE_EVENT_KEY_DOWN, _lokker_cb_key_down, NULL); E_LIST_HANDLER_APPEND(edd->handlers, E_EVENT_ZONE_ADD, _lokker_cb_zone_add, NULL); E_LIST_HANDLER_APPEND(edd->handlers, E_EVENT_ZONE_DEL, _lokker_cb_zone_del, NULL); E_LIST_HANDLER_APPEND(edd->handlers, E_EVENT_ZONE_MOVE_RESIZE, _lokker_cb_zone_move_resize, NULL);