raster pushed a commit to branch master.

http://git.enlightenment.org/apps/rage.git/commit/?id=62bbf25fd232fb97df43574ceb40dd2aaef84e5f

commit 62bbf25fd232fb97df43574ceb40dd2aaef84e5f
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Mon Oct 16 08:40:11 2017 +0900

    browser - work around focus restore errors by explicitly focusing win
    
    browser hides and rage relied on elm auto-focusing what was left after
    hiding/deletion of the browser input button... but this broke ... work
    around it and be explicit in focusing win content again.
---
 src/bin/browser.c | 14 +++++++++++++-
 src/bin/win.c     |  9 +++++++++
 src/bin/win.h     |  3 ++-
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/bin/browser.c b/src/bin/browser.c
index e3bc6ba..fc7b943 100644
--- a/src/bin/browser.c
+++ b/src/bin/browser.c
@@ -56,6 +56,7 @@ static Evas_Object *sc, *bt;
 static Ecore_Thread *fill_thread = NULL;
 static Entry *dir_entry = NULL;
 static Eina_List *entries = NULL;
+static Ecore_Timer *_browser_hide_focus_restore_timer = NULL;
 static Eina_Semaphore step_sema;
 
 static void _sel_go(Evas_Object *win EINA_UNUSED, Entry *base_entry, int x, 
int y);
@@ -893,7 +894,6 @@ _cb_key_down(void *data, Evas *evas EINA_UNUSED, 
Evas_Object *obj EINA_UNUSED, v
    Evas_Event_Key_Down *ev = event_info;
    Evas_Object *win = data;
 
-   printf("brow %s\n", ev->key);
    if ((!strcmp(ev->key, "Left")) ||
        (!strcmp(ev->key, "bracketleft")))
      {
@@ -963,6 +963,8 @@ browser_show(Evas_Object *win)
 {
    Inf *inf = evas_object_data_get(win, "inf");
 
+   if (_browser_hide_focus_restore_timer) 
ecore_timer_del(_browser_hide_focus_restore_timer);
+   _browser_hide_focus_restore_timer = NULL;
    if (!bx)
      {
         bx = elm_box_add(win);
@@ -1020,6 +1022,14 @@ _cb_hidden(void *data, Evas_Object *obj, const char *sig 
EINA_UNUSED, const char
    elm_object_focus_next(data, ELM_FOCUS_PREVIOUS);
 }
 
+static Eina_Bool
+_browser_hide_focus_restore_cb(void *data)
+{
+   win_focus(data);
+   _browser_hide_focus_restore_timer = NULL;
+   return EINA_FALSE;
+}
+
 void
 browser_hide(Evas_Object *win)
 {
@@ -1031,6 +1041,8 @@ browser_hide(Evas_Object *win)
    elm_layout_signal_callback_add(inf->lay, "browser,state,hidden,finished", 
"rage",
                                   _cb_hidden, win);
    elm_layout_signal_emit(inf->lay, "browser,state,hidden", "rage");
+   if (_browser_hide_focus_restore_timer) 
ecore_timer_del(_browser_hide_focus_restore_timer);
+   _browser_hide_focus_restore_timer = ecore_timer_add(0.2, 
_browser_hide_focus_restore_cb, win);
 }
 
 void
diff --git a/src/bin/win.c b/src/bin/win.c
index 71780ce..1264a13 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -628,6 +628,7 @@ win_add(void)
 
    // a dummy button to collect key events and have focus
    o = elm_button_add(win);
+   inf->focus = o;
    elm_object_focus_highlight_style_set(o, "blank");
    evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(win, o);
@@ -640,6 +641,14 @@ win_add(void)
 }
 
 void
+win_focus(Evas_Object *win)
+{
+   Inf *inf = evas_object_data_get(win, "inf");
+
+   elm_object_focus_set(inf->focus, EINA_TRUE);
+}
+
+void
 win_title_update(Evas_Object *win)
 {
    Inf *inf = evas_object_data_get(win, "inf");
diff --git a/src/bin/win.h b/src/bin/win.h
index 6c60ef2..1a83e6a 100644
--- a/src/bin/win.h
+++ b/src/bin/win.h
@@ -5,7 +5,7 @@ typedef struct _Inf Inf;
 
 struct _Inf
 {
-   Evas_Object *vid, *lay, *event, *event2, *glayer, *vidthumb, *artimg;
+   Evas_Object *vid, *lay, *event, *event2, *glayer, *vidthumb, *artimg, 
*focus;
    Eina_List *file_list, *file_cur;
    Ecore_Job *next_job;
    Ecore_Timer *show_timeout;
@@ -46,6 +46,7 @@ void win_video_delete(Evas_Object *win);
 Eina_Bool win_video_have_next(Evas_Object *win);
 Eina_Bool win_video_have_prev(Evas_Object *win);
 Evas_Object *win_add(void);
+void win_focus(Evas_Object *win);
 void win_title_update(Evas_Object *win);
 void win_show(Evas_Object *win, int w, int h);
 void win_art(Evas_Object *win, const char *path);

-- 


Reply via email to