1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2004-01-19 14:30:35 -08:00
|
|
|
* Copyright (C) 2000-2004 Carsten Haitzler, Geoff Harrison and various contributors
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
|
|
|
|
2003-06-11 13:05:59 -07:00
|
|
|
static int new_desk_focus_nesting = 0;
|
|
|
|
|
2004-02-24 15:19:03 -08:00
|
|
|
/*
|
|
|
|
* Return !0 if it is OK to focus ewin.
|
2004-07-17 01:55:34 -07:00
|
|
|
* on_screen: Require window to be on-screen now
|
2004-02-24 15:19:03 -08:00
|
|
|
*/
|
|
|
|
static int
|
2004-07-17 01:55:34 -07:00
|
|
|
FocusEwinValid(EWin * ewin, int on_screen)
|
2004-02-24 15:19:03 -08:00
|
|
|
{
|
2004-07-17 01:55:34 -07:00
|
|
|
if (!ewin)
|
|
|
|
return 0;
|
|
|
|
|
2004-07-17 03:11:31 -07:00
|
|
|
if (ewin->neverfocus || ewin->iconified)
|
2004-07-17 01:55:34 -07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!ewin->client.need_input)
|
2004-02-24 15:19:03 -08:00
|
|
|
return 0;
|
|
|
|
|
2004-07-15 16:31:02 -07:00
|
|
|
if (!EwinIsMapped(ewin))
|
2004-02-26 11:33:21 -08:00
|
|
|
return 0;
|
|
|
|
|
2004-07-17 01:55:34 -07:00
|
|
|
return !on_screen || EwinIsOnScreen(ewin);
|
2004-02-24 15:19:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2004-02-26 11:33:21 -08:00
|
|
|
* Return the ewin to focus after entering area or losing focused window.
|
2004-02-24 15:19:03 -08:00
|
|
|
*/
|
|
|
|
static EWin *
|
|
|
|
FocusEwinSelect(void)
|
|
|
|
{
|
2004-04-01 14:41:22 -08:00
|
|
|
EWin *const *lst, *ewin = NULL;
|
2004-02-24 15:19:03 -08:00
|
|
|
int num, i;
|
|
|
|
|
2004-03-20 07:49:05 -08:00
|
|
|
switch (Conf.focus.mode)
|
2004-02-24 15:19:03 -08:00
|
|
|
{
|
2004-02-26 11:33:21 -08:00
|
|
|
default:
|
|
|
|
case MODE_FOCUS_POINTER:
|
|
|
|
ewin = GetEwinPointerInClient();
|
|
|
|
break;
|
2004-07-17 01:55:34 -07:00
|
|
|
case MODE_FOCUS_SLOPPY:
|
|
|
|
ewin = GetEwinPointerInClient();
|
|
|
|
if (ewin)
|
|
|
|
break;
|
|
|
|
/* If pointer not in window - fall thru and select other */
|
2004-02-26 11:33:21 -08:00
|
|
|
case MODE_FOCUS_CLICK:
|
2004-04-01 14:41:22 -08:00
|
|
|
lst = EwinListGetFocus(&num);
|
2004-02-26 11:33:21 -08:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
2004-07-17 07:58:16 -07:00
|
|
|
if (!FocusEwinValid(lst[i], 1) || lst[i]->skipfocus)
|
2004-02-26 11:33:21 -08:00
|
|
|
continue;
|
|
|
|
ewin = lst[i];
|
|
|
|
break;
|
|
|
|
}
|
2004-02-24 15:19:03 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ewin;
|
|
|
|
}
|
|
|
|
|
1999-09-21 19:13:51 -07:00
|
|
|
static void
|
2004-04-01 14:41:22 -08:00
|
|
|
AutoraiseTimeout(int val, void *data __UNUSED__)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-01-28 12:09:07 -08:00
|
|
|
EWin *ewin;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-03-20 07:49:05 -08:00
|
|
|
if (Conf.focus.mode == MODE_FOCUS_CLICK)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2004-01-28 12:09:07 -08:00
|
|
|
|
|
|
|
ewin = FindItem("", val, LIST_FINDBY_ID, LIST_TYPE_EWIN);
|
|
|
|
if (ewin)
|
|
|
|
RaiseEwin(ewin);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
1999-09-21 19:13:51 -07:00
|
|
|
static void
|
2004-04-01 14:41:22 -08:00
|
|
|
ReverseTimeout(int val, void *data __UNUSED__)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EWin *ewin;
|
|
|
|
|
2004-04-01 14:41:22 -08:00
|
|
|
ewin = FindItem("", val, LIST_FINDBY_ID, LIST_TYPE_EWIN);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (ewin)
|
2004-04-01 14:41:22 -08:00
|
|
|
EwinListRaise(&EwinListFocus, ewin, 0);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-07-23 13:05:50 -07:00
|
|
|
void
|
|
|
|
FocusGetNextEwin(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-07-23 13:05:50 -07:00
|
|
|
EWin *const *lst;
|
|
|
|
EWin *ewin;
|
|
|
|
int i, num;
|
2004-01-21 15:32:45 -08:00
|
|
|
|
2004-07-23 13:05:50 -07:00
|
|
|
lst = EwinListGetFocus(&num);
|
|
|
|
if (num <= 1)
|
|
|
|
return;
|
2004-01-21 15:32:45 -08:00
|
|
|
|
2004-07-23 13:05:50 -07:00
|
|
|
ewin = NULL;
|
|
|
|
for (i = num - 1; i >= 0; i--)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-07-23 13:05:50 -07:00
|
|
|
if (lst[i]->skipfocus || !FocusEwinValid(lst[i], 1))
|
|
|
|
continue;
|
|
|
|
ewin = lst[i];
|
|
|
|
break;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-01-21 15:32:45 -08:00
|
|
|
|
2004-07-23 13:05:50 -07:00
|
|
|
if (ewin)
|
|
|
|
FocusToEWin(ewin, FOCUS_NEXT);
|
2004-01-21 15:32:45 -08:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-01-21 15:32:45 -08:00
|
|
|
void
|
|
|
|
FocusGetPrevEwin(void)
|
|
|
|
{
|
2004-07-23 13:05:50 -07:00
|
|
|
EWin *const *lst;
|
|
|
|
EWin *ewin;
|
|
|
|
int i, num;
|
|
|
|
|
|
|
|
lst = EwinListGetFocus(&num);
|
|
|
|
if (num <= 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ewin = NULL;
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (lst[i]->skipfocus || !FocusEwinValid(lst[i], 1))
|
|
|
|
continue;
|
|
|
|
ewin = lst[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ewin)
|
|
|
|
FocusToEWin(ewin, FOCUS_PREV);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
void
|
|
|
|
FocusEwinSetGrabs(EWin * ewin)
|
|
|
|
{
|
2004-03-20 07:49:05 -08:00
|
|
|
if ((Conf.focus.mode != MODE_FOCUS_CLICK &&
|
|
|
|
ewin->active && Conf.focus.clickraises) ||
|
|
|
|
(Conf.focus.mode == MODE_FOCUS_CLICK && !ewin->active))
|
2004-02-01 03:28:06 -08:00
|
|
|
{
|
2004-08-14 08:06:26 -07:00
|
|
|
GrabButtonSet(AnyButton, AnyModifier, ewin->win_container,
|
|
|
|
ButtonPressMask, ECSR_PGRAB, 1);
|
2004-08-13 17:47:17 -07:00
|
|
|
#if 0
|
|
|
|
Eprintf("FocusEwinSetGrabs: %#lx grab %s\n", ewin->client.win,
|
|
|
|
EwinGetTitle(ewin));
|
|
|
|
#endif
|
2004-02-01 03:28:06 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-08-14 08:06:26 -07:00
|
|
|
GrabButtonRelease(AnyButton, AnyModifier, ewin->win_container);
|
2004-08-13 17:47:17 -07:00
|
|
|
#if 0
|
|
|
|
Eprintf("FocusEwinSetGrabs: %#lx ungrab %s\n", ewin->client.win,
|
|
|
|
EwinGetTitle(ewin));
|
|
|
|
#endif
|
2004-02-01 03:28:06 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-01 14:41:22 -08:00
|
|
|
static void
|
|
|
|
FocusEwinSetActive(EWin * ewin, int active)
|
|
|
|
{
|
|
|
|
ewin->active = active;
|
2004-06-07 09:46:08 -07:00
|
|
|
EwinBorderUpdateState(ewin);
|
2004-04-01 14:41:22 -08:00
|
|
|
|
|
|
|
FocusEwinSetGrabs(ewin);
|
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
2004-01-21 15:32:45 -08:00
|
|
|
FocusFix(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-03-26 13:21:47 -08:00
|
|
|
EWin *const *lst, *ewin;
|
1999-08-17 15:56:46 -07:00
|
|
|
int i, num;
|
|
|
|
|
2004-01-21 15:32:45 -08:00
|
|
|
EDBUG(5, "FocusFix");
|
2004-02-01 03:28:06 -08:00
|
|
|
|
2004-04-01 14:41:22 -08:00
|
|
|
lst = EwinListGetAll(&num);
|
2004-02-01 03:28:06 -08:00
|
|
|
for (i = 0; i < num; i++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-02-01 03:28:06 -08:00
|
|
|
ewin = lst[i];
|
2004-08-14 08:06:26 -07:00
|
|
|
GrabButtonRelease(AnyButton, AnyModifier, ewin->win_container);
|
2004-02-01 03:28:06 -08:00
|
|
|
FocusEwinSetGrabs(ewin);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-02-01 03:28:06 -08:00
|
|
|
|
|
|
|
EDBUG_RETURN_;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-01-21 15:32:45 -08:00
|
|
|
FocusToEWin(EWin * ewin, int why)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-02-08 14:51:50 -08:00
|
|
|
int do_follow = 0;
|
2004-07-23 13:05:50 -07:00
|
|
|
int do_raise = 0, do_warp = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
EDBUG(4, "FocusToEWin");
|
2004-02-17 15:15:54 -08:00
|
|
|
|
2004-03-22 08:36:03 -08:00
|
|
|
if (EventDebug(EDBUG_TYPE_FOCUS))
|
2004-02-17 15:15:54 -08:00
|
|
|
{
|
|
|
|
if (ewin)
|
2004-04-08 05:54:46 -07:00
|
|
|
Eprintf("FocusToEWin %#lx %s why=%d\n", ewin->client.win,
|
2004-07-12 16:24:36 -07:00
|
|
|
EwinGetTitle(ewin), why);
|
2004-02-17 15:15:54 -08:00
|
|
|
else
|
2004-04-08 05:54:46 -07:00
|
|
|
Eprintf("FocusToEWin None why=%d\n", why);
|
2004-02-17 15:15:54 -08:00
|
|
|
}
|
1999-10-03 09:02:09 -07:00
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
switch (why)
|
|
|
|
{
|
2004-07-23 13:05:50 -07:00
|
|
|
case FOCUS_NEXT:
|
|
|
|
case FOCUS_PREV:
|
|
|
|
if (Conf.focus.raise_on_next)
|
|
|
|
do_raise = 1;
|
|
|
|
if (Conf.focus.warp_on_next)
|
|
|
|
do_warp = 1;
|
|
|
|
/* Fall thru */
|
2004-02-01 03:28:06 -08:00
|
|
|
default:
|
2004-07-17 01:55:34 -07:00
|
|
|
case FOCUS_SET:
|
|
|
|
case FOCUS_ENTER:
|
|
|
|
case FOCUS_LEAVE: /* Unused */
|
|
|
|
case FOCUS_CLICK:
|
|
|
|
if (ewin == Mode.focuswin)
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
if (ewin == NULL) /* Unfocus */
|
|
|
|
break;
|
|
|
|
if (!FocusEwinValid(ewin, 1))
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FOCUS_DESK_ENTER:
|
|
|
|
ewin = FocusEwinSelect();
|
|
|
|
if (!ewin)
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FOCUS_NONE:
|
|
|
|
case FOCUS_DESK_LEAVE:
|
|
|
|
ewin = NULL;
|
2004-03-20 07:49:05 -08:00
|
|
|
if (ewin == Mode.focuswin)
|
2004-02-01 03:28:06 -08:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
break;
|
1999-10-03 09:02:09 -07:00
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
case FOCUS_EWIN_GONE:
|
2004-03-20 07:49:05 -08:00
|
|
|
if (ewin != Mode.focuswin)
|
2004-02-01 03:28:06 -08:00
|
|
|
EDBUG_RETURN_;
|
2004-07-17 01:55:34 -07:00
|
|
|
ewin = FocusEwinSelect();
|
|
|
|
if (ewin == Mode.focuswin)
|
2004-04-08 08:51:26 -07:00
|
|
|
ewin = NULL;
|
2004-02-26 11:33:21 -08:00
|
|
|
break;
|
1999-10-03 09:02:09 -07:00
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
case FOCUS_EWIN_NEW:
|
2004-07-12 16:24:36 -07:00
|
|
|
/* Don't chase around after the windows at startup */
|
|
|
|
if (Mode.wm.startup)
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
|
2004-03-20 07:49:05 -08:00
|
|
|
if (Conf.focus.all_new_windows_get_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-02-08 14:51:50 -08:00
|
|
|
do_follow = 2;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2004-03-20 07:49:05 -08:00
|
|
|
else if (Conf.focus.new_transients_get_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-02-01 03:28:06 -08:00
|
|
|
if (ewin->client.transient)
|
2004-02-08 14:51:50 -08:00
|
|
|
do_follow = 2;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2004-03-20 07:49:05 -08:00
|
|
|
else if (Conf.focus.new_transients_get_focus_if_group_focused)
|
2004-02-01 03:28:06 -08:00
|
|
|
{
|
|
|
|
EWin *ewin2;
|
|
|
|
|
|
|
|
ewin2 = FindItem(NULL, ewin->client.transient_for,
|
|
|
|
LIST_FINDBY_ID, LIST_TYPE_EWIN);
|
2004-03-20 07:49:05 -08:00
|
|
|
if ((ewin2) && (Mode.focuswin == ewin2))
|
2004-02-08 14:51:50 -08:00
|
|
|
do_follow = 2;
|
2004-02-01 03:28:06 -08:00
|
|
|
}
|
2004-03-20 07:49:05 -08:00
|
|
|
else if (Mode.place)
|
2004-02-01 03:28:06 -08:00
|
|
|
{
|
2004-02-08 14:51:50 -08:00
|
|
|
do_follow = 1;
|
2004-02-01 03:28:06 -08:00
|
|
|
}
|
|
|
|
|
2004-02-08 14:51:50 -08:00
|
|
|
if (!do_follow)
|
2004-02-01 03:28:06 -08:00
|
|
|
EDBUG_RETURN_;
|
2004-07-17 01:55:34 -07:00
|
|
|
if (ewin == Mode.focuswin)
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
if (!FocusEwinValid(ewin, 0))
|
|
|
|
EDBUG_RETURN_;
|
2004-02-01 03:28:06 -08:00
|
|
|
break;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-02-01 03:28:06 -08:00
|
|
|
|
2004-07-17 01:55:34 -07:00
|
|
|
if (ewin == Mode.focuswin)
|
2004-07-15 16:31:02 -07:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
|
2004-07-17 01:55:34 -07:00
|
|
|
/* Check if ewin is a valid focus window target */
|
2004-02-01 03:28:06 -08:00
|
|
|
|
2004-07-17 01:55:34 -07:00
|
|
|
if (!ewin)
|
|
|
|
goto done;
|
2004-02-01 03:28:06 -08:00
|
|
|
|
2004-07-17 01:55:34 -07:00
|
|
|
/* NB! ewin != NULL */
|
2004-02-01 03:28:06 -08:00
|
|
|
|
2004-04-28 15:31:37 -07:00
|
|
|
if (do_follow)
|
2004-02-08 14:51:50 -08:00
|
|
|
GotoDesktopByEwin(ewin);
|
|
|
|
|
2004-03-20 07:49:05 -08:00
|
|
|
if (Conf.autoraise.enable)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-02-01 03:28:06 -08:00
|
|
|
RemoveTimerEvent("AUTORAISE_TIMEOUT");
|
|
|
|
|
2004-03-20 07:49:05 -08:00
|
|
|
if (Conf.focus.mode != MODE_FOCUS_CLICK)
|
|
|
|
DoIn("AUTORAISE_TIMEOUT", Conf.autoraise.delay, AutoraiseTimeout,
|
2004-02-01 03:28:06 -08:00
|
|
|
ewin->client.win, NULL);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-02-01 03:28:06 -08:00
|
|
|
|
2004-07-23 13:05:50 -07:00
|
|
|
if (do_raise)
|
2004-02-01 03:28:06 -08:00
|
|
|
RaiseEwin(ewin);
|
|
|
|
|
2004-07-23 13:05:50 -07:00
|
|
|
if (do_warp && ewin != Mode.mouse_over_ewin)
|
|
|
|
XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0, ewin->w / 2, ewin->h / 2);
|
2004-02-01 03:28:06 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
RemoveTimerEvent("REVERSE_FOCUS_TIMEOUT");
|
2004-07-23 13:05:50 -07:00
|
|
|
switch (why)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case FOCUS_PREV:
|
|
|
|
DoIn("REVERSE_FOCUS_TIMEOUT", 0.5, ReverseTimeout, ewin->client.win,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
case FOCUS_DESK_ENTER:
|
|
|
|
break;
|
|
|
|
case FOCUS_NEXT:
|
|
|
|
EwinListRaise(&EwinListFocus, ewin, 0);
|
|
|
|
break;
|
|
|
|
}
|
2004-02-01 03:28:06 -08:00
|
|
|
|
|
|
|
SoundPlay("SOUND_FOCUS_SET");
|
2004-03-20 07:49:05 -08:00
|
|
|
done:
|
2004-04-01 14:41:22 -08:00
|
|
|
/* Unset old focus window (if any) highlighting */
|
|
|
|
if (Mode.focuswin)
|
|
|
|
FocusEwinSetActive(Mode.focuswin, 0);
|
2004-02-01 03:28:06 -08:00
|
|
|
ICCCM_Cmap(ewin);
|
2004-03-20 07:49:05 -08:00
|
|
|
Mode.focuswin = ewin;
|
2004-04-01 14:41:22 -08:00
|
|
|
/* Set new focus window (if any) highlighting */
|
|
|
|
if (Mode.focuswin)
|
|
|
|
FocusEwinSetActive(Mode.focuswin, 1);
|
2004-07-15 16:31:02 -07:00
|
|
|
ICCCM_Focus(ewin);
|
2004-02-01 03:28:06 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-01-21 15:32:45 -08:00
|
|
|
FocusNewDeskBegin(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2003-06-11 13:05:59 -07:00
|
|
|
if (new_desk_focus_nesting++)
|
|
|
|
return;
|
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
FocusToEWin(NULL, FOCUS_DESK_LEAVE);
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
/* we are about to flip desktops or areas - disable enter and leave events
|
2003-06-11 13:05:59 -07:00
|
|
|
* temporarily */
|
2004-04-12 06:57:43 -07:00
|
|
|
EwinsEventsConfigure(1);
|
|
|
|
DesktopsEventsConfigure(1);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-01-21 15:32:45 -08:00
|
|
|
FocusNewDesk(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-04-12 06:57:43 -07:00
|
|
|
EWin *ewin;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-01-21 15:32:45 -08:00
|
|
|
EDBUG(4, "FocusNewDesk");
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-06-11 13:05:59 -07:00
|
|
|
if (--new_desk_focus_nesting)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* we flipped - re-enable enter and leave events */
|
2004-04-12 06:57:43 -07:00
|
|
|
EwinsEventsConfigure(0);
|
|
|
|
DesktopsEventsConfigure(0);
|
2003-06-11 13:05:59 -07:00
|
|
|
|
2004-04-04 14:32:37 -07:00
|
|
|
/* Set the mouse-over window */
|
|
|
|
ewin = GetEwinByCurrentPointer();
|
2004-06-28 16:37:55 -07:00
|
|
|
Mode.mouse_over_ewin = ewin;
|
2004-04-04 14:32:37 -07:00
|
|
|
|
2004-07-17 01:55:34 -07:00
|
|
|
FocusToEWin(NULL, FOCUS_DESK_ENTER);
|
2003-06-11 13:05:59 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
/*
|
|
|
|
* Focus event handlers
|
|
|
|
*/
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
2004-02-01 03:28:06 -08:00
|
|
|
FocusHandleEnter(XEvent * ev)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-04-01 14:41:22 -08:00
|
|
|
Window win = ev->xcrossing.window;
|
2004-02-01 03:28:06 -08:00
|
|
|
EWin *ewin;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
EDBUG(5, "FocusHandleEnter");
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-04-01 14:41:22 -08:00
|
|
|
/* Entering root may mean entering this screen */
|
2004-05-04 12:04:42 -07:00
|
|
|
if (win == VRoot.win &&
|
2004-04-01 14:41:22 -08:00
|
|
|
(ev->xcrossing.mode == NotifyNormal &&
|
|
|
|
ev->xcrossing.detail != NotifyInferior))
|
|
|
|
{
|
2004-07-17 01:55:34 -07:00
|
|
|
FocusToEWin(NULL, FOCUS_DESK_ENTER);
|
2004-04-01 14:41:22 -08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
ewin = GetEwinByCurrentPointer();
|
2004-06-28 16:37:55 -07:00
|
|
|
Mode.mouse_over_ewin = ewin;
|
2004-01-28 12:09:07 -08:00
|
|
|
|
2004-03-20 07:49:05 -08:00
|
|
|
switch (Conf.focus.mode)
|
2004-01-28 12:09:07 -08:00
|
|
|
{
|
2004-02-01 03:28:06 -08:00
|
|
|
default:
|
|
|
|
case MODE_FOCUS_CLICK:
|
|
|
|
break;
|
|
|
|
case MODE_FOCUS_SLOPPY:
|
|
|
|
if (!ewin || ewin->focusclick)
|
|
|
|
break;
|
|
|
|
FocusToEWin(ewin, FOCUS_ENTER);
|
|
|
|
break;
|
|
|
|
case MODE_FOCUS_POINTER:
|
|
|
|
if (ewin && ewin->focusclick)
|
|
|
|
break;
|
|
|
|
FocusToEWin(ewin, FOCUS_ENTER);
|
|
|
|
break;
|
2004-01-28 12:09:07 -08:00
|
|
|
}
|
2004-02-01 03:28:06 -08:00
|
|
|
|
2004-04-01 14:41:22 -08:00
|
|
|
done:
|
2004-01-28 12:09:07 -08:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-02-01 03:28:06 -08:00
|
|
|
FocusHandleLeave(XEvent * ev)
|
2004-01-28 12:09:07 -08:00
|
|
|
{
|
2004-02-06 16:30:23 -08:00
|
|
|
Window win = ev->xcrossing.window;
|
|
|
|
|
2004-02-16 14:58:21 -08:00
|
|
|
/* Leaving root may mean entering other screen */
|
2004-05-04 12:04:42 -07:00
|
|
|
if (win == VRoot.win &&
|
2004-02-16 14:58:21 -08:00
|
|
|
(ev->xcrossing.mode == NotifyNormal &&
|
|
|
|
ev->xcrossing.detail != NotifyInferior))
|
2004-02-06 16:30:23 -08:00
|
|
|
FocusToEWin(NULL, FOCUS_SET);
|
2004-01-28 12:09:07 -08:00
|
|
|
}
|
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
void
|
|
|
|
FocusHandleClick(Window win)
|
|
|
|
{
|
|
|
|
EWin *ewin;
|
|
|
|
|
2004-08-14 11:50:27 -07:00
|
|
|
ewin = FindEwinByChildren(win);
|
|
|
|
if (!ewin)
|
|
|
|
ewin = FindEwinByBase(win);
|
2004-02-01 03:28:06 -08:00
|
|
|
if (!ewin)
|
|
|
|
return;
|
|
|
|
|
2004-03-20 07:49:05 -08:00
|
|
|
if ((Conf.focus.clickraises) || (Conf.focus.mode == MODE_FOCUS_CLICK))
|
2004-02-01 03:28:06 -08:00
|
|
|
{
|
|
|
|
RaiseEwin(ewin);
|
|
|
|
FocusToEWin(ewin, FOCUS_CLICK);
|
|
|
|
|
|
|
|
/* allow click to pass thorugh */
|
2004-11-27 05:29:39 -08:00
|
|
|
if (EventDebug(EDBUG_TYPE_GRABS))
|
|
|
|
Eprintf("FocusHandleClick %#lx %#lx\n", win, ewin->win_container);
|
2004-02-01 03:28:06 -08:00
|
|
|
if (win == ewin->win_container)
|
|
|
|
{
|
|
|
|
XSync(disp, False);
|
|
|
|
XAllowEvents(disp, ReplayPointer, CurrentTime);
|
|
|
|
XSync(disp, False);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ewin->focusclick)
|
|
|
|
{
|
|
|
|
FocusToEWin(ewin, FOCUS_CLICK);
|
|
|
|
}
|
|
|
|
}
|