2004-11-24 19:37:45 -08:00
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
/* local subsystem functions */
|
2012-08-03 07:02:14 -07:00
|
|
|
static Eina_Bool _e_focus_raise_timer(void *data);
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
/* local subsystem globals */
|
|
|
|
|
|
|
|
/* externally accessible functions */
|
2010-11-22 07:21:32 -08:00
|
|
|
EINTERN int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_focus_init(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-11-22 07:21:32 -08:00
|
|
|
EINTERN int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_focus_shutdown(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2004-11-24 19:37:45 -08:00
|
|
|
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)
|
2005-05-20 00:32:42 -07:00
|
|
|
{
|
2013-11-21 04:24:46 -08:00
|
|
|
if ((bd->focus_policy == E_FOCUS_MOUSE) ||
|
|
|
|
(bd->focus_policy == E_FOCUS_SLOPPY))
|
2005-07-04 03:24:22 -07:00
|
|
|
{
|
2012-08-03 07:02:14 -07:00
|
|
|
e_border_focus_set(bd, 1, 1);
|
2005-07-04 03:24:22 -07:00
|
|
|
}
|
2005-09-28 12:44:58 -07:00
|
|
|
if (bd->raise_timer) ecore_timer_del(bd->raise_timer);
|
2005-05-20 00:32:42 -07:00
|
|
|
bd->raise_timer = NULL;
|
2005-05-20 02:27:06 -07:00
|
|
|
if (e_config->use_auto_raise)
|
2005-05-20 00:32:42 -07:00
|
|
|
{
|
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);
|
2005-05-20 00:32:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
2005-05-20 00:32:42 -07:00
|
|
|
{
|
2013-11-21 04:24:46 -08:00
|
|
|
if (bd->focus_policy == E_FOCUS_MOUSE)
|
2005-07-04 03:24:22 -07:00
|
|
|
{
|
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
|
|
|
}
|
2005-07-04 03:24:22 -07:00
|
|
|
}
|
2013-05-22 03:06:31 -07:00
|
|
|
E_FREE_FUNC(bd->raise_timer, ecore_timer_del);
|
2005-05-20 00:32:42 -07:00
|
|
|
}
|
|
|
|
|
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)
|
2005-05-20 00:32:42 -07:00
|
|
|
{
|
2013-11-20 10:17:42 -08:00
|
|
|
if (!bd->focused)
|
|
|
|
{
|
2013-11-21 04:24:46 -08:00
|
|
|
if (bd->focus_policy == E_FOCUS_CLICK)
|
2013-11-20 10:17:42 -08:00
|
|
|
e_border_focus_set(bd, 1, 1);
|
|
|
|
else if (e_config->always_click_to_focus)
|
|
|
|
e_border_focus_set(bd, 1, 1);
|
|
|
|
}
|
2013-09-25 00:24:50 -07:00
|
|
|
if (e_config->always_click_to_raise)
|
2005-05-20 03:14:51 -07:00
|
|
|
{
|
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);
|
2005-05-20 03:14:51 -07:00
|
|
|
}
|
2005-05-20 00:32:42 -07:00
|
|
|
}
|
|
|
|
|
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__)
|
2005-05-20 00:32:42 -07:00
|
|
|
{
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-05-20 02:27:06 -07:00
|
|
|
e_focus_event_focus_in(E_Border *bd)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2013-11-21 04:24:46 -08:00
|
|
|
if ((bd->focus_policy == E_FOCUS_CLICK) &&
|
2005-09-27 09:36:14 -07:00
|
|
|
(!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
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-05-20 02:27:06 -07:00
|
|
|
e_focus_event_focus_out(E_Border *bd)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2013-11-21 04:24:46 -08:00
|
|
|
if ((bd->focus_policy == E_FOCUS_CLICK) &&
|
2005-09-27 09:36:14 -07:00
|
|
|
(!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
|
|
|
}
|
2005-05-20 02:27:06 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-05-20 02:27:06 -07:00
|
|
|
e_focus_setup(E_Border *bd)
|
|
|
|
{
|
2013-11-21 04:24:46 -08:00
|
|
|
if ((bd->focus_policy == E_FOCUS_CLICK) ||
|
2005-09-27 09:36:14 -07:00
|
|
|
(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
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-05-20 00:32:42 -07:00
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-05-20 02:27:06 -07:00
|
|
|
e_focus_setdown(E_Border *bd)
|
2005-05-20 00:32:42 -07:00
|
|
|
{
|
2005-05-20 02:27:06 -07:00
|
|
|
if (!bd->button_grabbed) return;
|
2012-06-08 03:10:16 -07:00
|
|
|
e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
|
|
|
|
e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
|
2005-05-20 02:27:06 -07:00
|
|
|
ecore_x_window_button_ungrab(bd->win, 1, 0, 1);
|
2005-05-22 23:09:52 -07:00
|
|
|
ecore_x_window_button_ungrab(bd->win, 2, 0, 1);
|
|
|
|
ecore_x_window_button_ungrab(bd->win, 3, 0, 1);
|
2012-06-08 03:10:16 -07:00
|
|
|
e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
|
|
|
|
e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
|
2005-05-20 02:27:06 -07:00
|
|
|
bd->button_grabbed = 0;
|
|
|
|
}
|
2005-05-20 00:32:42 -07:00
|
|
|
|
2005-05-20 02:27:06 -07:00
|
|
|
/* local subsystem functions */
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool
|
2012-08-03 07:02:14 -07:00
|
|
|
_e_focus_raise_timer(void *data)
|
2005-05-20 00:32:42 -07:00
|
|
|
{
|
2005-07-04 03:24:22 -07:00
|
|
|
E_Border *bd;
|
2010-06-24 09:19:12 -07:00
|
|
|
|
2005-07-04 03:24:22 -07:00
|
|
|
bd = data;
|
2006-06-07 16:30:15 -07:00
|
|
|
if (!bd->lock_user_stacking) e_border_raise(bd);
|
2005-07-04 03:24:22 -07:00
|
|
|
bd->raise_timer = NULL;
|
2010-06-24 09:19:12 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2005-05-20 00:32:42 -07:00
|
|
|
}
|
2012-08-03 07:02:14 -07:00
|
|
|
|