billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=b7fff38636a9315b041be749fd2b6c60550ee9d4

commit b7fff38636a9315b041be749fd2b6c60550ee9d4
Author: Boris Faure <bill...@gmail.com>
Date:   Sun Jun 30 16:20:40 2019 +0200

    win: hide mouse cursor when idle after timer
---
 src/bin/options_behavior.c |  2 --
 src/bin/win.c              | 54 +++++++++++++++++++++++++++++++++++++++-------
 src/bin/win.h              |  1 -
 3 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/src/bin/options_behavior.c b/src/bin/options_behavior.c
index 1318c94..5e30a9b 100644
--- a/src/bin/options_behavior.c
+++ b/src/bin/options_behavior.c
@@ -224,7 +224,6 @@ _cb_op_hide_cursor_changed(void *data,
         config->hide_cursor = INFINITY;
         elm_object_disabled_set(ctx->sld_hide_cursor, EINA_TRUE);
      }
-   main_hide_cursor_update(config);
    config_save(config, NULL);
 }
 
@@ -241,7 +240,6 @@ _cb_hide_cursor_slider_chg(void *data,
        return;
 
    config->hide_cursor = value;
-   main_hide_cursor_update(config);
    config_save(config, NULL);
 }
 
diff --git a/src/bin/win.c b/src/bin/win.c
index 44bcaf6..19b429f 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -170,6 +170,7 @@ struct _Win
    Evas_Object *cmdbox;
    Ecore_Timer *cmdbox_del_timer;
    Ecore_Timer *cmdbox_focus_timer;
+   Ecore_Timer *hide_cursor_timer;
    unsigned char focused : 1;
    unsigned char cmdbox_up : 1;
    unsigned char group_input : 1;
@@ -679,12 +680,6 @@ _win_trans(Win *wn, Term *term, Eina_Bool trans)
      }
 }
 
-void
-main_hide_cursor_update(const Config *config)
-{
-   /* TODO */
-}
-
 void
 main_trans_update(const Config *config)
 {
@@ -1546,6 +1541,34 @@ _cb_win_mouse_down(void *data,
    tc_child->focus(tc_child, tc);
 }
 
+static Eina_Bool
+_set_cursor(Term *term, void *data)
+{
+   char *cursor = data;
+
+   if (cursor)
+     {
+        elm_object_cursor_set(term->base, cursor);
+     }
+   else
+     {
+        elm_object_cursor_unset(term->base);
+     }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+
+static Eina_Bool
+_hide_cursor(void *data)
+{
+   Win *wn = data;
+
+   wn->hide_cursor_timer = NULL;
+   for_each_term_do(wn, &_set_cursor, (void*)"blank");
+   return ECORE_CALLBACK_CANCEL;
+}
+
 static void
 _cb_win_mouse_move(void *data,
                    Evas *_e EINA_UNUSED,
@@ -1558,10 +1581,25 @@ _cb_win_mouse_move(void *data,
    Term_Container *tc = (Term_Container*) wn;
    Term_Container *tc_child = NULL;
 
-   if (wn->on_popover || wn->group_input || !tc->is_focused)
+   if (wn->on_popover)
      return;
 
-   if (!wn->config->mouse_over_focus)
+   if (!isnan(wn->config->hide_cursor))
+     {
+        if (wn->hide_cursor_timer)
+          {
+             ecore_timer_interval_set(wn->hide_cursor_timer,
+                                      wn->config->hide_cursor);
+          }
+        else
+          {
+             for_each_term_do(wn, &_set_cursor, NULL);
+             wn->hide_cursor_timer = ecore_timer_add(
+                wn->config->hide_cursor, _hide_cursor, wn);
+          }
+     }
+
+   if (wn->group_input || !tc->is_focused || !wn->config->mouse_over_focus)
      return;
 
    term_mouse = tc->find_term_at_coords(tc,
diff --git a/src/bin/win.h b/src/bin/win.h
index defa217..af4bf16 100644
--- a/src/bin/win.h
+++ b/src/bin/win.h
@@ -90,6 +90,5 @@ term_apply_shine(Term *term, int shine);
 void background_set_shine(Config *config, Evas_Object *bg);
 
 void main_trans_update(const Config *config);
-void main_hide_cursor_update(const Config *config);
 
 #endif

-- 


Reply via email to