e_comp_wl: add config for cursor_timer hiding the cursor after some interval 86/54086/10
authorDuna Oh <duna.oh@samsung.com>
Fri, 11 Dec 2015 08:25:06 +0000 (17:25 +0900)
committerDuna Oh <duna.oh@samsung.com>
Fri, 18 Dec 2015 07:10:24 +0000 (23:10 -0800)
Signed-off-by: Duna Oh <duna.oh@samsung.com>
Change-Id: Ia9c506241e55643ce1082896678ca251c6ded9e1

src/bin/e_comp_wl.c
src/bin/e_comp_wl.h
src/bin/e_comp_wl_input.c
src/bin/e_config.c
src/bin/e_config.h
src/bin/e_pointer.c
src/modules/wl_drm/e_mod_main.c

index e3e282996f50242b30044076d54e9e3fcaf155b5..178aed9fba55b7ee6f83586dc6df379f9611177d 100644 (file)
@@ -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;
 
@@ -743,6 +769,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)
 {
@@ -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);
 }
index 66f274c8428461a5ba88cd7c88d73f5e90f735aa..6a6dc9c470a24cff30d226be5c3db20e83e0d613 100644 (file)
@@ -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;
 
index 2bf579775eee94c51d03a5a73215003bffeee244..513b64c8cb358a6e0d7f5a5bbbc874b1cf30492a 100644 (file)
@@ -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
index c6ba0cb93756d89c548836f4cbbcad975d7fcdad..a97bfd495ac8ca90893a906ac954b8e0a99094b7 100644 (file)
@@ -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
 
index e461d8ba072f176d9c407989ceaaba904f08deee..31aa28bcb40e36858cea02c84790f89f6369242e 100644 (file)
@@ -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;
 };
 
index 99cae1a25c79a0d0a6d71125b4802aebe8cf61bc..25afa092876f7859d0fc5ad4120d704ec847d371 100644 (file)
@@ -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);
      }
 }
index dd3985fab28cd4ffc32dfedc3b6d1d50b2245be0..94c087ded019d313836463d37142bf7c1b862500 100644 (file)
@@ -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++;