From 7ffc08f294494eb34c3fb8f430627e4a64925408 Mon Sep 17 00:00:00 2001 From: Duna Oh Date: Fri, 11 Dec 2015 17:25:06 +0900 Subject: [PATCH] e_comp_wl: add config for cursor_timer hiding the cursor after some interval Signed-off-by: Duna Oh Change-Id: Ia9c506241e55643ce1082896678ca251c6ded9e1 --- src/bin/e_comp_wl.c | 128 +++++++++++++++++++++++++++++++++++++++- src/bin/e_comp_wl.h | 3 + src/bin/e_comp_wl_input.c | 12 ---- src/bin/e_config.c | 5 ++ src/bin/e_config.h | 3 + src/bin/e_pointer.c | 7 ++- src/modules/wl_drm/e_mod_main.c | 5 +- 7 files changed, 147 insertions(+), 16 deletions(-) diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index e3e2829..178aed9 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -20,6 +20,9 @@ static void _e_comp_wl_subsurface_parent_commit(E_Client *ec, Eina_Bool parent_synchronized); static void _e_comp_wl_subsurface_restack(E_Client *ec); +static Eina_Bool _e_comp_wl_cursor_timer(void *data); +static void _e_comp_wl_cursor_reload(E_Client *ec); + /* local variables */ typedef struct _E_Comp_Wl_Transform_Context { @@ -662,6 +665,24 @@ _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj return; } + if (e_config->use_cursor_timer) + { + if (ec->comp->wl_comp_data->ptr.hidden == EINA_TRUE) + { + Evas_Object *o = NULL; + + ecore_evas_cursor_get(ec->comp->pointer->ee, &o, NULL, NULL, NULL); + if (o) + ec->comp->wl_comp_data->ptr.ec = e_comp_object_client_get(o); + return; + } + else + { + E_FREE_FUNC(ec->comp->wl_comp_data->ptr.hide_tmr, ecore_timer_del); + ec->comp->wl_comp_data->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec); + } + } + wc = wl_resource_get_client(ec->comp_data->surface); serial = wl_display_next_serial(ec->comp->wl_comp_data->wl.disp); EINA_LIST_FOREACH(ec->comp->wl_comp_data->ptr.resources, l, res) @@ -699,7 +720,12 @@ _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob ecore_evas_cursor_get(e_comp->ee, &o, NULL, NULL, NULL); if ((e_comp->pointer->o_ptr != o) && (e_comp->wl_comp_data->ptr.enabled)) - e_pointer_object_set(e_comp->pointer, NULL, 0, 0); + { + if ((e_config->use_cursor_timer) && (e_comp->wl_comp_data->ptr.hidden)) + e_comp->wl_comp_data->ptr.ec = NULL; + else + e_pointer_object_set(e_comp->pointer, NULL, 0, 0); + } } if (e_object_is_del(E_OBJECT(ec))) return; @@ -744,6 +770,87 @@ _e_comp_wl_evas_handle_mouse_move_to_touch(E_Client *ec, uint32_t timestamp, int } static void +_e_comp_wl_cursor_reload(E_Client *ec) +{ + E_Client *ec_cursor; + struct wl_resource *res; + struct wl_client *wc; + Eina_List *l; + uint32_t serial; + int cx, cy; + + if (e_object_is_del(E_OBJECT(ec))) return; + if (!ec->comp_data) return; + + if ((ec_cursor = ec->comp->wl_comp_data->ptr.ec)) + { + ec_cursor->visible = 1; + ecore_evas_object_cursor_set(ec->comp->pointer->ee, ec_cursor->frame, EVAS_LAYER_MAX, ec_cursor->x, ec_cursor->y); + } + + ec->comp->wl_comp_data->ptr.hidden = EINA_FALSE; + + cx = wl_fixed_to_int(e_comp->wl_comp_data->ptr.x) - ec->client.x; + cy = wl_fixed_to_int(e_comp->wl_comp_data->ptr.y) - ec->client.y; + + if (!ec->comp_data->surface) return; + wc = wl_resource_get_client(ec->comp_data->surface); + serial = wl_display_next_serial(ec->comp->wl_comp_data->wl.disp); + EINA_LIST_FOREACH(ec->comp->wl_comp_data->ptr.resources, l, res) + { + if (!e_comp_wl_input_pointer_check(res)) continue; + if (wl_resource_get_client(res) != wc) continue; + wl_pointer_send_enter(res, serial, ec->comp_data->surface, + wl_fixed_from_int(cx), wl_fixed_from_int(cy)); + } +} + +static Eina_Bool +_e_comp_wl_cursor_timer(void *data) +{ + E_Client *ec = NULL; + E_Client *ec_cursor = NULL; + Evas_Object *o; + struct wl_resource *res; + struct wl_client *wc; + Eina_List *l; + uint32_t serial; + + if (!(ec = data)) return EINA_FALSE; + if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE; + if (!ec->comp_data) return EINA_FALSE; + + ecore_evas_cursor_get(ec->comp->pointer->ee, &o, NULL, NULL, NULL); + if (o) + { + ec_cursor = ec->comp->wl_comp_data->ptr.ec = e_comp_object_client_get(o); + if (ec_cursor) + { + ec_cursor->hidden = 1; + ec_cursor->x = ec->comp->pointer->hot.x; + ec_cursor->y = ec->comp->pointer->hot.y; + } + } + + ecore_evas_cursor_unset(ec->comp->pointer->ee); + + ec->comp->wl_comp_data->ptr.hidden = EINA_TRUE; + ec->comp->wl_comp_data->ptr.hide_tmr = NULL; + + if (!ec->comp_data->surface) return EINA_FALSE; + wc = wl_resource_get_client(ec->comp_data->surface); + serial = wl_display_next_serial(ec->comp->wl_comp_data->wl.disp); + EINA_LIST_FOREACH(ec->comp->wl_comp_data->ptr.resources, l, res) + { + if (!e_comp_wl_input_pointer_check(res)) continue; + if (wl_resource_get_client(res) != wc) continue; + wl_pointer_send_leave(res, serial, ec->comp_data->surface); + } + + return ECORE_CALLBACK_CANCEL; +} + +static void _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event) { E_Client *ec; @@ -788,6 +895,14 @@ _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *o wl_fixed_from_int(ev->cur.canvas.y - ec->client.y)); } } + if (e_config->use_cursor_timer) + { + if (ec->comp->wl_comp_data->ptr.hidden == EINA_TRUE) + _e_comp_wl_cursor_reload(ec); + + E_FREE_FUNC(ec->comp->wl_comp_data->ptr.hide_tmr, ecore_timer_del); + ec->comp->wl_comp_data->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec); + } } static Eina_Bool @@ -892,6 +1007,15 @@ _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *o else _e_comp_wl_evas_handle_mouse_button(ec, ev->timestamp, ev->button, WL_POINTER_BUTTON_STATE_PRESSED); + + if (e_config->use_cursor_timer) + { + if (ec->comp->wl_comp_data->ptr.hidden == EINA_TRUE) + _e_comp_wl_cursor_reload(ec); + + E_FREE_FUNC(ec->comp->wl_comp_data->ptr.hide_tmr, ecore_timer_del); + ec->comp->wl_comp_data->ptr.hide_tmr = ecore_timer_add(e_config->cursor_timer_interval, _e_comp_wl_cursor_timer, ec); + } } static void @@ -2627,6 +2751,8 @@ _e_comp_wl_compositor_cb_del(E_Comp *comp) /* delete fd handler */ if (cdata->fd_hdlr) ecore_main_fd_handler_del(cdata->fd_hdlr); + E_FREE_FUNC(cdata->ptr.hide_tmr, ecore_timer_del); + /* free allocated data structure */ free(cdata); } diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h index 66f274c..6a6dc9c 100644 --- a/src/bin/e_comp_wl.h +++ b/src/bin/e_comp_wl.h @@ -194,6 +194,9 @@ struct _E_Comp_Wl_Data wl_fixed_t x, y; wl_fixed_t grab_x, grab_y; uint32_t button; + Ecore_Timer *hide_tmr; + E_Client *ec; + Eina_Bool hidden :1; unsigned int num_devices; } ptr; diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c index 2bf5797..513b64c 100644 --- a/src/bin/e_comp_wl_input.c +++ b/src/bin/e_comp_wl_input.c @@ -168,18 +168,6 @@ _e_comp_wl_input_cb_pointer_get(struct wl_client *client, struct wl_resource *re cdata->ptr.resources = eina_list_append(cdata->ptr.resources, res); wl_resource_set_implementation(res, &_e_pointer_interface, cdata, _e_comp_wl_input_cb_pointer_unbind); - - if (!(ec = e_client_focused_get())) return; - if (e_object_is_del(E_OBJECT(ec))) return; - if (!ec->comp_data->surface) return; - if (client != wl_resource_get_client(ec->comp_data->surface)) return; - - cx = wl_fixed_to_int(e_comp->wl_comp_data->ptr.x) - ec->client.x; - cy = wl_fixed_to_int(e_comp->wl_comp_data->ptr.y) - ec->client.y; - - serial = wl_display_next_serial(e_comp->wl_comp_data->wl.disp); - wl_pointer_send_enter(res, serial, ec->comp_data->surface, - wl_fixed_from_int(cx), wl_fixed_from_int(cy)); } static void diff --git a/src/bin/e_config.c b/src/bin/e_config.c index c6ba0cb..a97bfd4 100644 --- a/src/bin/e_config.c +++ b/src/bin/e_config.c @@ -787,6 +787,8 @@ _e_config_edd_init(Eina_Bool old) #ifdef _F_ZONE_WINDOW_ROTATION_ E_CONFIG_VAL(D, T, wm_win_rotation, UCHAR); #endif + E_CONFIG_VAL(D, T, use_cursor_timer, INT); + E_CONFIG_VAL(D, T, cursor_timer_interval, INT); E_CONFIG_LIST(D, T, client_types, _e_config_client_type_edd); } @@ -1552,6 +1554,9 @@ e_config_load(void) E_CONFIG_LIMIT(e_config->xkb.delay_held_key_input_to_focus, 0,5000); // 5000(ms) == 5(s) + E_CONFIG_LIMIT(e_config->use_cursor_timer, 0, 1); + E_CONFIG_LIMIT(e_config->cursor_timer_interval, 0.0, 9.9); + if (!e_config->icon_theme) e_config->icon_theme = eina_stringshare_add("hicolor"); // FDO default diff --git a/src/bin/e_config.h b/src/bin/e_config.h index e461d8b..31aa28b 100644 --- a/src/bin/e_config.h +++ b/src/bin/e_config.h @@ -452,6 +452,9 @@ struct _E_Config #ifdef _F_ZONE_WINDOW_ROTATION_ unsigned char wm_win_rotation; #endif + int use_cursor_timer; + int cursor_timer_interval; + Eina_List *client_types; }; diff --git a/src/bin/e_pointer.c b/src/bin/e_pointer.c index 99cae1a..25afa09 100644 --- a/src/bin/e_pointer.c +++ b/src/bin/e_pointer.c @@ -781,7 +781,11 @@ e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y) ecore_evas_cursor_get(ptr->ee, &o, NULL, NULL, NULL); if (o) { - if (o == obj) return; + if (o == obj) + { + ecore_evas_object_cursor_set(ptr->ee, obj, EVAS_LAYER_MAX, x, y); + return; + } ec = e_comp_object_client_get(o); if (ec) ec->hidden = 1; @@ -798,6 +802,5 @@ e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y) else if (ptr->o_ptr) { ecore_evas_object_cursor_set(ptr->ee, ptr->o_ptr, EVAS_LAYER_MAX, ptr->hot.x, ptr->hot.y); - evas_object_show(ptr->o_ptr); } } diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c index dd3985f..94c087d 100644 --- a/src/modules/wl_drm/e_mod_main.c +++ b/src/modules/wl_drm/e_mod_main.c @@ -90,7 +90,10 @@ _e_mod_drm_cb_input_device_add(void *data, int type, void *event) { if (comp->wl_comp_data->ptr.num_devices == 0) { - e_pointer_object_set(comp->pointer, NULL, 0, 0); + if (e_config->use_cursor_timer) + comp->wl_comp_data->ptr.hidden = EINA_TRUE; + else + e_pointer_object_set(comp->pointer, NULL, 0, 0); e_comp_wl_input_pointer_enabled_set(EINA_TRUE); } comp->wl_comp_data->ptr.num_devices++; -- 2.7.4