enlightenment/src/bin/e_focus.c

178 lines
5.0 KiB
C
Raw Normal View History

#include "e.h"
/* local subsystem functions */
2012-08-03 07:02:14 -07:00
static Eina_Bool _e_focus_raise_timer(void *data);
/* local subsystem globals */
/* externally accessible functions */
EINTERN int
e_focus_init(void)
{
return 1;
}
EINTERN int
e_focus_shutdown(void)
{
return 1;
}
2006-01-07 02:39:46 -08:00
EAPI void
e_focus_idler_before(void)
{
return;
}
2006-01-07 02:39:46 -08:00
EAPI void
2012-08-03 07:02:14 -07:00
e_focus_event_mouse_in(E_Border *bd)
{
if ((bd->focus_policy == E_FOCUS_MOUSE) ||
(bd->focus_policy == E_FOCUS_SLOPPY))
{
2012-08-03 07:02:14 -07:00
e_border_focus_set(bd, 1, 1);
}
if (bd->raise_timer) ecore_timer_del(bd->raise_timer);
bd->raise_timer = NULL;
if (e_config->use_auto_raise)
{
2012-08-03 07:02:14 -07:00
if (e_config->auto_raise_delay == 0.0)
{
if (!bd->lock_user_stacking)
remove "border_raise_on_focus" config option buckle up. for the first time in history, a config option is getting removed instead of added. the reasons for this removal are many, but let's go way back to the beginning and see why it was added: oh wait, we can't because the commit message (from 2006) is >> patches that i said were in - commit. (see my reply emails) >> also finish off a TODO item or 2 reading through the TODO items which were also crossed off in that commit, I'm assuming that this was the "option to NOT raise on focus in click to focus" item. == REASON 1 == the problem here is that there's another, BETTER option called "click raises window" (always_click_to_raise) which does the same thing, except it doesn't totally fuck you when you get a random X focus event, which happens more often than you might think. this means that, to avoid broken behavior which might cause your windows to spastically raise for a few frames in common cases (using winlist...) with click-to-focus, you have to know that this is the default-enabled option that's fucking you, and you have to remember to manually disable it every time. if you DON'T know that this is the option that's fucking you, and you just see windows randomly raising on their own, you'll probably either ignore it or file a bug, when this is supposed to be a "feature" that actually worked in reverse, since it was intended only for disabling. == REASON 2 == there's also auto-raise, which can be set to 0.0s, which is effectively the same thing since it also triggers on focus but can be configured not to fuck your window stack == REASON 3 == aaand finally, this option makes any sort of pointer focus model impossible to use, since your windows will constantly be raising all over as you move the mouse tl;dr: I'm removing it, e-dealwithit.gif
2013-10-06 22:49:33 -07:00
e_border_raise(bd);
2012-08-03 07:02:14 -07:00
}
else
bd->raise_timer = ecore_timer_add(e_config->auto_raise_delay, _e_focus_raise_timer, bd);
}
}
2006-01-07 02:39:46 -08:00
EAPI void
2012-08-03 07:02:14 -07:00
e_focus_event_mouse_out(E_Border *bd)
{
if (bd->focus_policy == E_FOCUS_MOUSE)
{
2013-05-22 03:06:31 -07:00
if (!bd->lock_focus_in)
2012-08-03 07:02:14 -07:00
{
2013-05-22 03:06:31 -07:00
if (bd->focused)
e_border_focus_set(bd, 0, 1);
2012-08-03 07:02:14 -07:00
}
}
2013-05-22 03:06:31 -07:00
E_FREE_FUNC(bd->raise_timer, ecore_timer_del);
}
2006-01-07 02:39:46 -08:00
EAPI void
2012-08-03 07:02:14 -07:00
e_focus_event_mouse_down(E_Border *bd)
{
if (!bd->focused)
{
if (bd->focus_policy == E_FOCUS_CLICK)
e_border_focus_set(bd, 1, 1);
else if (e_config->always_click_to_focus)
e_border_focus_set(bd, 1, 1);
}
if (e_config->always_click_to_raise)
{
2012-08-03 07:02:14 -07:00
if (!bd->lock_user_stacking)
2013-09-05 05:42:18 -07:00
e_border_raise(bd);
}
}
2006-01-07 02:39:46 -08:00
EAPI void
2012-08-03 07:02:14 -07:00
e_focus_event_mouse_up(E_Border *bd __UNUSED__)
{
}
2006-01-07 02:39:46 -08:00
EAPI void
e_focus_event_focus_in(E_Border *bd)
{
if ((bd->focus_policy == E_FOCUS_CLICK) &&
(!e_config->always_click_to_raise) &&
(!e_config->always_click_to_focus))
2004-12-23 23:45:21 -08:00
{
2012-08-03 07:02:14 -07:00
if (!bd->button_grabbed) return;
e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
ecore_x_window_button_ungrab(bd->win, 1, 0, 1);
ecore_x_window_button_ungrab(bd->win, 2, 0, 1);
ecore_x_window_button_ungrab(bd->win, 3, 0, 1);
e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
bd->button_grabbed = 0;
2004-12-23 23:45:21 -08:00
}
}
2006-01-07 02:39:46 -08:00
EAPI void
e_focus_event_focus_out(E_Border *bd)
{
if ((bd->focus_policy == E_FOCUS_CLICK) &&
(!e_config->always_click_to_raise) &&
(!e_config->always_click_to_focus))
2004-12-23 23:45:21 -08:00
{
2012-08-03 07:02:14 -07:00
if (bd->button_grabbed) return;
ecore_x_window_button_grab(bd->win, 1,
ECORE_X_EVENT_MASK_MOUSE_DOWN |
ECORE_X_EVENT_MASK_MOUSE_UP |
ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
ecore_x_window_button_grab(bd->win, 2,
ECORE_X_EVENT_MASK_MOUSE_DOWN |
ECORE_X_EVENT_MASK_MOUSE_UP |
ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
ecore_x_window_button_grab(bd->win, 3,
ECORE_X_EVENT_MASK_MOUSE_DOWN |
ECORE_X_EVENT_MASK_MOUSE_UP |
ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
bd->button_grabbed = 1;
2004-12-23 23:45:21 -08:00
}
}
2006-01-07 02:39:46 -08:00
EAPI void
e_focus_setup(E_Border *bd)
{
if ((bd->focus_policy == E_FOCUS_CLICK) ||
(e_config->always_click_to_raise) ||
(e_config->always_click_to_focus))
2004-12-23 23:45:21 -08:00
{
2012-08-03 07:02:14 -07:00
if (bd->button_grabbed) return;
ecore_x_window_button_grab(bd->win, 1,
ECORE_X_EVENT_MASK_MOUSE_DOWN |
ECORE_X_EVENT_MASK_MOUSE_UP |
ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
ecore_x_window_button_grab(bd->win, 2,
ECORE_X_EVENT_MASK_MOUSE_DOWN |
ECORE_X_EVENT_MASK_MOUSE_UP |
ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
ecore_x_window_button_grab(bd->win, 3,
ECORE_X_EVENT_MASK_MOUSE_DOWN |
ECORE_X_EVENT_MASK_MOUSE_UP |
ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
bd->button_grabbed = 1;
2004-12-23 23:45:21 -08:00
}
}
2006-01-07 02:39:46 -08:00
EAPI void
e_focus_setdown(E_Border *bd)
{
if (!bd->button_grabbed) return;
e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
ecore_x_window_button_ungrab(bd->win, 1, 0, 1);
ecore_x_window_button_ungrab(bd->win, 2, 0, 1);
ecore_x_window_button_ungrab(bd->win, 3, 0, 1);
e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
bd->button_grabbed = 0;
}
/* local subsystem functions */
static Eina_Bool
2012-08-03 07:02:14 -07:00
_e_focus_raise_timer(void *data)
{
E_Border *bd;
bd = data;
if (!bd->lock_user_stacking) e_border_raise(bd);
bd->raise_timer = NULL;
return ECORE_CALLBACK_CANCEL;
}
2012-08-03 07:02:14 -07:00