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.
v-0.4.0
Carsten Haitzler 5 years ago
parent d82c1877ec
commit 62bbf25fd2
  1. 14
      src/bin/browser.c
  2. 9
      src/bin/win.c
  3. 3
      src/bin/win.h

@ -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

@ -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);
@ -639,6 +640,14 @@ win_add(void)
return win;
}
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)
{

@ -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);

Loading…
Cancel
Save