diff --git a/src/bin/e_border.c b/src/bin/e_border.c index 407f821ea..691db404c 100644 --- a/src/bin/e_border.c +++ b/src/bin/e_border.c @@ -206,6 +206,8 @@ static Eina_List *handlers = NULL; static Eina_List *borders = NULL; static Eina_Hash *borders_hash = NULL; static E_Border *focused = NULL; +static Eina_List *focus_next = NULL; +static Ecore_X_Time focus_time = 0; static E_Border *resize = NULL; static E_Border *move = NULL; @@ -1902,29 +1904,10 @@ e_border_focus_set(E_Border *bd, { E_Event_Border_Focus_In *ev; - if ((bd->visible) && (bd->changes.visible)) - { - bd->want_focus = 1; - bd->changed = 1; - return; - } if (set) - { - if ((bd->client.icccm.take_focus) && - (bd->client.icccm.accepts_focus)) - { - e_grabinput_focus(bd->client.win, E_FOCUS_METHOD_LOCALLY_ACTIVE); - return; - } - else if (!bd->client.icccm.accepts_focus) - { - e_grabinput_focus(bd->client.win, E_FOCUS_METHOD_GLOBALLY_ACTIVE); - return; - } - else if (!bd->client.icccm.take_focus) - { - e_grabinput_focus(bd->client.win, E_FOCUS_METHOD_PASSIVE); - } + { + focus_next = eina_list_prepend(focus_next, bd); + return; } if (focused) @@ -1932,6 +1915,7 @@ e_border_focus_set(E_Border *bd, bd->focused = 1; focused = bd; + e_focus_event_focus_in(bd); e_border_focus_latest_set(bd); e_hints_active_window_set(bd->zone->container->manager, bd); @@ -2957,6 +2941,36 @@ e_border_idler_before(void) e_container_border_list_free(bl); } } + + if (focus_next) + { + E_Border *bd = NULL, *bd2; + + EINA_LIST_FREE(focus_next, bd2) + if ((!bd) && (bd2->visible)) bd = bd2; + + if (!bd) + { + /* TODO revert focus when lost here ? */ + return; + } + + focus_time = ecore_x_current_time_get(); + + if ((bd->client.icccm.take_focus) && + (bd->client.icccm.accepts_focus)) + { + e_grabinput_focus(bd->client.win, E_FOCUS_METHOD_LOCALLY_ACTIVE); + } + else if (!bd->client.icccm.accepts_focus) + { + e_grabinput_focus(bd->client.win, E_FOCUS_METHOD_GLOBALLY_ACTIVE); + } + else if (!bd->client.icccm.take_focus) + { + e_grabinput_focus(bd->client.win, E_FOCUS_METHOD_PASSIVE); + } + } } EAPI Eina_List * @@ -4163,6 +4177,11 @@ _e_border_del(E_Border *bd) E_Event_Border_Remove *ev; E_Border *child; + if (bd == focused) + focused = NULL; + + focus_next = eina_list_remove(focus_next, bd); + if (bd->fullscreen) bd->desk->fullscreen_borders--; if ((drag_border) && (drag_border->data == bd)) @@ -5001,7 +5020,8 @@ _e_border_cb_window_focus_in(void *data __UNUSED__, { if (e->detail == ECORE_X_EVENT_DETAIL_POINTER) return ECORE_CALLBACK_PASS_ON; } - e_border_focus_set(bd, 1, 0); + if (e->time >= focus_time) + e_border_focus_set(bd, 1, 0); return ECORE_CALLBACK_PASS_ON; } diff --git a/src/bin/e_grabinput.c b/src/bin/e_grabinput.c index 3bd75e138..517d26871 100644 --- a/src/bin/e_grabinput.c +++ b/src/bin/e_grabinput.c @@ -1,7 +1,6 @@ #include "e.h" /* local subsystem functions */ -static void _e_grabinput_focus_job(void *data); static void _e_grabinput_focus(Ecore_X_Window win, E_Focus_Method method); /* local subsystem globals */ @@ -9,9 +8,6 @@ static Ecore_X_Window grab_mouse_win = 0; static Ecore_X_Window grab_key_win = 0; static Ecore_X_Window focus_win = 0; static E_Focus_Method focus_method = E_FOCUS_METHOD_NO_INPUT; -static Ecore_X_Window do_focus_win = 0; -static E_Focus_Method do_focus_method = E_FOCUS_METHOD_NO_INPUT; -static Ecore_Job *focus_job = NULL; static double last_focus_time = 0.0; /* externally accessible functions */ @@ -101,12 +97,8 @@ e_grabinput_focus(Ecore_X_Window win, E_Focus_Method method) focus_method = method; } else - { - do_focus_win = win; - do_focus_method = method; - if (!focus_job) - focus_job = ecore_job_add(_e_grabinput_focus_job, NULL); - //_e_grabinput_focus(win, method); + { + _e_grabinput_focus(win, method); } } @@ -116,15 +108,6 @@ e_grabinput_last_focus_time_get(void) return last_focus_time; } -/* local subsystem functions */ -static void -_e_grabinput_focus_job(void *data __UNUSED__) -{ - focus_job = NULL; - _e_grabinput_focus(do_focus_win, do_focus_method); - do_focus_win = 0; -} - static void _e_grabinput_focus(Ecore_X_Window win, E_Focus_Method method) { @@ -134,17 +117,13 @@ _e_grabinput_focus(Ecore_X_Window win, E_Focus_Method method) break; case E_FOCUS_METHOD_LOCALLY_ACTIVE: ecore_x_window_focus(win); - ecore_x_sync(); // let x actually get the x focus request ecore_x_icccm_take_focus_send(win, ecore_x_current_time_get()); - ecore_x_sync(); // let x actually get the x focus request break; case E_FOCUS_METHOD_GLOBALLY_ACTIVE: ecore_x_icccm_take_focus_send(win, ecore_x_current_time_get()); - ecore_x_sync(); // let x actually get the x focus request break; case E_FOCUS_METHOD_PASSIVE: ecore_x_window_focus(win); - ecore_x_sync(); // let x actually get the x focus request break; default: break;