diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2017-11-14 18:15:26 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2017-11-14 18:15:26 +0900 |
commit | 9fe734318072b4ec86be07d9006f5c36a7556c64 (patch) | |
tree | 38ca0d73e5b82073717a74edb8975eda26fa7e76 | |
parent | db9e70708a809c3b29eb5bbbbe5d36f89db6a216 (diff) | |
download | enlightenment-9fe734318072b4ec86be07d9006f5c36a7556c64.tar.gz |
fix mouse hangs after unblank
this fixes T5883
-rw-r--r-- | src/bin/e_comp_x.c | 28 | ||||
-rw-r--r-- | src/bin/e_pointer.c | 28 | ||||
-rw-r--r-- | src/bin/e_pointer.h | 4 |
3 files changed, 41 insertions, 19 deletions
diff --git a/src/bin/e_comp_x.c b/src/bin/e_comp_x.c index 47403a3401..5c8106fc7e 100644 --- a/src/bin/e_comp_x.c +++ b/src/bin/e_comp_x.c @@ -5122,13 +5122,11 @@ _e_comp_x_cb_ping(void *data EINA_UNUSED, int ev_type EINA_UNUSED, Ecore_X_Event static void _e_comp_pointer_grab(void) { - fprintf(stderr, "E_COMP_X: 06 create grab win and grab pointer\n"); if (_e_comp_x_suspend_grabbed) ecore_x_window_free(_e_comp_x_suspend_grabbed); _e_comp_x_suspend_grabbed = ecore_x_window_input_new(e_comp->root, 0, 0, 1, 1); ecore_x_window_show(_e_comp_x_suspend_grabbed); if (!e_grabinput_get(_e_comp_x_suspend_grabbed, 0, 0)) { - fprintf(stderr, "E_COMP_X: 07 grab failed\n"); ecore_x_window_free(_e_comp_x_suspend_grabbed); _e_comp_x_suspend_grabbed = 0; } @@ -5138,7 +5136,6 @@ static void _e_comp_pointer_ungrab(void) { if (!_e_comp_x_suspend_grabbed) return; - fprintf(stderr, "E_COMP_X: 6 really ungrab input and free window\n"); e_grabinput_release(_e_comp_x_suspend_grabbed, 0); ecore_x_window_free(_e_comp_x_suspend_grabbed); _e_comp_x_suspend_grabbed = 0; @@ -5147,17 +5144,20 @@ _e_comp_pointer_ungrab(void) static void _e_comp_cb_pointer_suspend_resume_done(void *data, Evas_Object *obj, const char *emission, const char *source) { - fprintf(stderr, "E_COMP_X: 5 cursor suspend/resume done\n"); edje_object_signal_callback_del(obj, emission, source, _e_comp_cb_pointer_suspend_resume_done); - if (!data) _e_comp_pointer_ungrab(); + if (!data) + { + _e_comp_pointer_ungrab(); + e_pointer_grab_set(e_comp->pointer, EINA_FALSE); + } } EINTERN Eina_Bool _e_comp_x_screensaver_on() { const char *s; - fprintf(stderr, "E_COMP_X: 01 screensaver on\n"); + if ((!e_comp->pointer) || (!e_comp->pointer->o_ptr)) return ECORE_CALLBACK_RENEW; s = edje_object_data_get(e_comp->pointer->o_ptr, "can_suspend"); @@ -5165,13 +5165,12 @@ _e_comp_x_screensaver_on() { if (!e_desklock_state_get()) { - fprintf(stderr, "E_COMP_X: 02 ungrab then grab pointer\n"); _e_comp_pointer_ungrab(); + e_pointer_grab_set(e_comp->pointer, EINA_FALSE); + e_pointer_grab_set(e_comp->pointer, EINA_TRUE); _e_comp_pointer_grab(); - fprintf(stderr, "E_COMP_X: 03 no desklock but abort pointer suspend\n"); if (!_e_comp_x_suspend_grabbed) return ECORE_CALLBACK_RENEW; } - fprintf(stderr, "E_COMP_X: 04 emit suspend signals to pointer\n"); edje_object_signal_callback_del(e_comp->pointer->o_ptr, "e,state,mouse,suspend,done", "e", _e_comp_cb_pointer_suspend_resume_done); @@ -5194,8 +5193,8 @@ _e_comp_x_screensaver_off() { const char *s; - fprintf(stderr, "E_COMP_X: 1 screensaver off\n"); _e_comp_pointer_ungrab(); + e_pointer_grab_set(e_comp->pointer, EINA_FALSE); if ((!e_comp->pointer) || (!e_comp->pointer->o_ptr)) return ECORE_CALLBACK_RENEW; s = edje_object_data_get(e_comp->pointer->o_ptr, "can_suspend"); @@ -5203,15 +5202,10 @@ _e_comp_x_screensaver_off() { if (!e_desklock_state_get()) { - fprintf(stderr, "E_COMP_X: 2 re-grab pointer because desklock not on\n"); + e_pointer_grab_set(e_comp->pointer, EINA_TRUE); _e_comp_pointer_grab(); - if (!_e_comp_x_suspend_grabbed) - { - fprintf(stderr, "E_COMP_X: 3 no desklock but abort pointer unsuspend\n"); - return ECORE_CALLBACK_RENEW; - } + if (!_e_comp_x_suspend_grabbed) return ECORE_CALLBACK_RENEW; } - fprintf(stderr, "E_COMP_X: 4 emit resume signals to pointer\n"); edje_object_signal_callback_del(e_comp->pointer->o_ptr, "e,state,mouse,suspend,done", "e", _e_comp_cb_pointer_suspend_resume_done); diff --git a/src/bin/e_pointer.c b/src/bin/e_pointer.c index 4f3648bc81..4387ede266 100644 --- a/src/bin/e_pointer.c +++ b/src/bin/e_pointer.c @@ -354,6 +354,7 @@ _e_pointer_cb_free(E_Pointer *ptr) E_FREE_LIST(ptr->stack, _e_pointer_stack_free); eina_stringshare_del(ptr->type); + eina_stringshare_del(ptr->deferred_type); E_FREE_FUNC(ptr->idle_tmr, ecore_timer_del); E_FREE_FUNC(ptr->idle_poll, ecore_poller_del); @@ -431,6 +432,11 @@ _e_pointer_type_set(E_Pointer *ptr, const char *type) /* check if pointer type is already set */ if (!e_util_strcmp(ptr->type, type)) return; + if (ptr->grabcount > 0) + { + eina_stringshare_replace(&(ptr->deferred_type), type); + return; + } eina_stringshare_replace(&ptr->type, type); /* don't show cursor if in hidden mode */ @@ -462,7 +468,6 @@ _e_pointer_type_set(E_Pointer *ptr, const char *type) e_pointer_object_set(ptr, NULL, 0, 0); else evas_object_show(ptr->o_ptr); - } else _e_pointer_x11_setup(ptr, NULL); @@ -641,7 +646,7 @@ e_pointer_type_pop(E_Pointer *ptr, void *obj, const char *type) _e_pointer_type_set(ptr, stack->type); - eina_stringshare_refplace(&ptr->type, stack->type); + eina_stringshare_replace(&ptr->type, stack->type); } E_API void @@ -820,6 +825,25 @@ e_pointer_window_add(E_Pointer *ptr, Ecore_Window win) _e_pointer_x11_setup(ptr, "default"); } +E_API void +e_pointer_grab_set(E_Pointer *ptr, Eina_Bool grab) +{ + if (grab) ptr->grabcount++; + else + { + if (ptr->grabcount > 0) + { + ptr->grabcount--; + if ((ptr->grabcount == 0) && (ptr->deferred_type)) + { + _e_pointer_type_set(ptr, ptr->deferred_type); + eina_stringshare_del(ptr->deferred_type); + ptr->deferred_type = NULL; + } + } + } +} + EINTERN void e_pointers_freeze_set(Eina_Bool set) { diff --git a/src/bin/e_pointer.h b/src/bin/e_pointer.h index 55f9a2a842..de3c666c27 100644 --- a/src/bin/e_pointer.h +++ b/src/bin/e_pointer.h @@ -45,6 +45,7 @@ struct _E_Pointer int *pixels; int x, y, w, h; const char *type; + const char *deferred_type; struct { @@ -57,6 +58,8 @@ struct _E_Pointer Eina_List *stack; + unsigned short grabcount; + Eina_Bool e_cursor E_BITFIELD; Eina_Bool color E_BITFIELD; Eina_Bool idle E_BITFIELD; @@ -80,5 +83,6 @@ E_API void e_pointer_mode_pop(void *obj, E_Pointer_Mode mode); E_API void e_pointer_idler_before(void); E_API void e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y); E_API void e_pointer_window_add(E_Pointer *ptr, Ecore_Window win); +E_API void e_pointer_grab_set(E_Pointer *ptr, Eina_Bool grab); # endif #endif |