try and address some focus issues...

SVN revision: 72751
This commit is contained in:
Carsten Haitzler 2012-06-24 04:18:01 +00:00
parent e0df3ac375
commit b2fec5b8dc
4 changed files with 51 additions and 12 deletions

View File

@ -2148,7 +2148,7 @@ e_border_focus_set(E_Border *bd,
if ((set) && (!focus_next) && (!focusing))
{
e_grabinput_focus(bd->zone->container->bg_win,
e_grabinput_focus(bd->zone->container->manager->root,
E_FOCUS_METHOD_PASSIVE);
}
}
@ -4505,11 +4505,15 @@ _e_border_free(E_Border *bd)
if (focusing == bd)
focusing = NULL;
if (focused == bd)
focus_next = eina_list_remove(focus_next, bd);
if ((focused == bd) ||
(e_grabinput_last_focus_win_get() == bd->client.win))
{
if ((!focus_next) && (!focusing))
{
e_grabinput_focus(bd->zone->container->bg_win, E_FOCUS_METHOD_PASSIVE);
e_grabinput_focus(bd->zone->container->manager->root,
E_FOCUS_METHOD_PASSIVE);
e_hints_active_window_set(bd->zone->container->manager, NULL);
}

View File

@ -119,7 +119,7 @@ typedef struct _E_Event_Border_Desk_Set E_Event_Border_Desk_Set;
typedef struct _E_Event_Border_Stack E_Event_Border_Stack;
typedef struct _E_Event_Border_Simple E_Event_Border_Icon_Change;
typedef struct _E_Event_Border_Simple E_Event_Border_Urgent_Change;
typedef struct _E_Event_Border_Simple E_Event_Border_Focus_In;
typedef struct _E_Event_Border_Simple E_Event_Border_Focus_In;
typedef struct _E_Event_Border_Simple E_Event_Border_Focus_Out;
typedef struct _E_Event_Border_Simple E_Event_Border_Property;
typedef struct _E_Event_Border_Simple E_Event_Border_Fullscreen;

View File

@ -1,6 +1,8 @@
#include "e.h"
/* local subsystem functions */
static Eina_Bool _e_grabinput_focus_check(void *data);
static void _e_grabinput_focus_do(Ecore_X_Window win, E_Focus_Method method);
static void _e_grabinput_focus(Ecore_X_Window win, E_Focus_Method method);
/* local subsystem globals */
@ -10,6 +12,10 @@ static Ecore_X_Window focus_win = 0;
static E_Focus_Method focus_method = E_FOCUS_METHOD_NO_INPUT;
static double last_focus_time = 0.0;
static Ecore_X_Window focus_fix_win = 0;
static Ecore_Timer *focus_fix_timer = NULL;
static E_Focus_Method focus_fix_method = E_FOCUS_METHOD_NO_INPUT;
/* externally accessible functions */
EINTERN int
e_grabinput_init(void)
@ -20,6 +26,11 @@ e_grabinput_init(void)
EINTERN int
e_grabinput_shutdown(void)
{
if (focus_fix_timer)
{
ecore_timer_del(focus_fix_timer);
focus_fix_timer = NULL;
}
return 1;
}
@ -108,29 +119,52 @@ e_grabinput_last_focus_time_get(void)
return last_focus_time;
}
EAPI Ecore_X_Window
e_grabinput_last_focus_win_get(void)
{
return focus_fix_win;
}
static Eina_Bool
_e_grabinput_focus_check(void *data __UNUSED__)
{
if (ecore_x_window_focus_get() != focus_fix_win)
{
_e_grabinput_focus_do(focus_fix_win, focus_fix_method);
}
focus_fix_timer = NULL;
return EINA_FALSE;
}
static void
_e_grabinput_focus(Ecore_X_Window win, E_Focus_Method method)
_e_grabinput_focus_do(Ecore_X_Window win, E_Focus_Method method)
{
switch (method)
{
case E_FOCUS_METHOD_NO_INPUT:
break;
case E_FOCUS_METHOD_LOCALLY_ACTIVE:
ecore_x_window_focus_at_time(win, ecore_x_current_time_get());
ecore_x_icccm_take_focus_send(win, ecore_x_current_time_get());
break;
case E_FOCUS_METHOD_GLOBALLY_ACTIVE:
ecore_x_icccm_take_focus_send(win, ecore_x_current_time_get());
break;
case E_FOCUS_METHOD_PASSIVE:
ecore_x_window_focus_at_time(win, ecore_x_current_time_get());
break;
default:
break;
}
last_focus_time = ecore_loop_time_get();
}
static void
_e_grabinput_focus(Ecore_X_Window win, E_Focus_Method method)
{
focus_fix_win = win;
focus_fix_method = method;
_e_grabinput_focus_do(win, method);
last_focus_time = ecore_loop_time_get();
if (focus_fix_timer) ecore_timer_del(focus_fix_timer);
focus_fix_timer = ecore_timer_add(0.2, _e_grabinput_focus_check, NULL);
}

View File

@ -12,12 +12,13 @@ typedef enum _E_Focus_Method
#ifndef E_GRABINPUT_H
#define E_GRABINPUT_H
EINTERN int e_grabinput_init(void);
EINTERN int e_grabinput_shutdown(void);
EINTERN int e_grabinput_init(void);
EINTERN int e_grabinput_shutdown(void);
EAPI int e_grabinput_get(Ecore_X_Window mouse_win, int confine_mouse, Ecore_X_Window key_win);
EAPI void e_grabinput_release(Ecore_X_Window mouse_win, Ecore_X_Window key_win);
EAPI void e_grabinput_focus(Ecore_X_Window win, E_Focus_Method method);
EAPI double e_grabinput_last_focus_time_get(void);
EAPI Ecore_X_Window e_grabinput_last_focus_win_get(void);
#endif
#endif