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.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
FocusEwinValid(EWin * ewin)
|
|
|
|
{
|
|
|
|
if (ewin->skipfocus || ewin->neverfocus || ewin->shaded || ewin->iconified)
|
|
|
|
return 0;
|
|
|
|
|
2004-04-21 13:51:57 -07:00
|
|
|
if (ewin->state != EWIN_STATE_MAPPED)
|
2004-02-26 11:33:21 -08:00
|
|
|
return 0;
|
|
|
|
|
2004-02-24 15:19:03 -08:00
|
|
|
return EwinIsOnScreen(ewin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
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:
|
|
|
|
case MODE_FOCUS_SLOPPY:
|
|
|
|
ewin = GetEwinPointerInClient();
|
|
|
|
break;
|
|
|
|
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++)
|
|
|
|
{
|
|
|
|
if (!FocusEwinValid(lst[i]))
|
|
|
|
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-01-21 15:32:45 -08:00
|
|
|
static void
|
|
|
|
FocusCycle(int inc)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-04-01 14:41:22 -08:00
|
|
|
EWin *const *lst0;
|
|
|
|
EWin **lst, *ewin;
|
1999-08-17 15:56:46 -07:00
|
|
|
int i, num0, num, ax, ay;
|
|
|
|
|
2004-01-21 15:32:45 -08:00
|
|
|
EDBUG(5, "FocusCycle");
|
|
|
|
|
|
|
|
/* On previous only ? */
|
|
|
|
RemoveTimerEvent("REVERSE_FOCUS_TIMEOUT");
|
|
|
|
DoIn("REVERSE_FOCUS_TIMEOUT", 1.0, ReverseTimeout, 0, NULL);
|
|
|
|
|
|
|
|
GetCurrentArea(&ax, &ay);
|
|
|
|
|
2004-04-01 14:41:22 -08:00
|
|
|
lst0 = EwinListGetFocus(&num0);
|
2004-01-21 15:32:45 -08:00
|
|
|
if (lst0 == NULL)
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
num = 0;
|
|
|
|
lst = NULL;
|
2004-01-21 15:32:45 -08:00
|
|
|
for (i = 0; i < num0; i++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-01-21 15:32:45 -08:00
|
|
|
ewin = lst0[i];
|
2004-02-24 15:19:03 -08:00
|
|
|
if (FocusEwinValid(ewin))
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-01-21 15:32:45 -08:00
|
|
|
num++;
|
|
|
|
lst = Erealloc(lst, sizeof(EWin *) * num);
|
2004-02-24 15:19:03 -08:00
|
|
|
lst[num - 1] = ewin;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-01-21 15:32:45 -08:00
|
|
|
|
|
|
|
if (lst == NULL)
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
|
|
|
|
for (i = 0; i < num; i++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-03-20 07:49:05 -08:00
|
|
|
if (Mode.focuswin == lst[i])
|
2004-01-21 15:32:45 -08:00
|
|
|
break;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-01-21 15:32:45 -08:00
|
|
|
i += inc + num;
|
|
|
|
i %= num;
|
|
|
|
ewin = lst[i];
|
|
|
|
Efree(lst);
|
|
|
|
|
2004-02-02 11:42:35 -08:00
|
|
|
FocusToEWin(ewin, FOCUS_NEXT);
|
2004-01-21 15:32:45 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-01-21 15:32:45 -08:00
|
|
|
FocusGetNextEwin(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-01-21 15:32:45 -08:00
|
|
|
FocusCycle(1);
|
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-01-21 15:32:45 -08:00
|
|
|
void
|
|
|
|
FocusGetPrevEwin(void)
|
|
|
|
{
|
|
|
|
FocusCycle(-1);
|
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
|
|
|
{
|
|
|
|
XGrabButton(disp, AnyButton, AnyModifier, ewin->win_container,
|
|
|
|
False, ButtonPressMask, GrabModeSync, GrabModeAsync,
|
|
|
|
None, None);
|
2004-04-08 05:54:46 -07:00
|
|
|
/* Eprintf("FocusEwinSetGrabs: %#lx grab\n", ewin->client.win); */
|
2004-02-01 03:28:06 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XUngrabButton(disp, AnyButton, AnyModifier, ewin->win_container);
|
2004-04-08 05:54:46 -07:00
|
|
|
/* Eprintf("FocusEwinSetGrabs: %#lx ungrab\n", ewin->client.win); */
|
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-02-16 14:58:21 -08:00
|
|
|
XUngrabButton(disp, 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;
|
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)
|
|
|
|
{
|
|
|
|
default:
|
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-04-10 00:22:45 -07:00
|
|
|
Mode.focuswin = NULL;
|
2004-04-08 08:51:26 -07:00
|
|
|
if (Conf.focus.mode == MODE_FOCUS_CLICK)
|
|
|
|
ewin = FocusEwinSelect();
|
|
|
|
else
|
|
|
|
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_;
|
|
|
|
break;
|
|
|
|
|
2004-02-02 11:42:35 -08:00
|
|
|
case FOCUS_WARP_NEXT:
|
|
|
|
why = FOCUS_NEXT;
|
|
|
|
break;
|
|
|
|
|
2004-02-01 03:28:06 -08:00
|
|
|
case FOCUS_WARP_DONE:
|
|
|
|
break;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-02-01 03:28:06 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
if (!ewin)
|
2004-03-20 07:49:05 -08:00
|
|
|
goto done;
|
2004-02-01 03:28:06 -08:00
|
|
|
|
|
|
|
/* NB! ewin != NULL */
|
|
|
|
|
|
|
|
if (ewin->iconified || ewin->neverfocus)
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
|
|
|
|
if (!ewin->client.need_input)
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
|
|
|
|
/* Don't focus menus (use client.need_input?) */
|
|
|
|
if (ewin->menu)
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
|
2004-04-28 15:31:37 -07:00
|
|
|
if (do_follow)
|
2004-02-08 14:51:50 -08:00
|
|
|
GotoDesktopByEwin(ewin);
|
|
|
|
|
|
|
|
if (!EwinIsOnScreen(ewin))
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
|
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-03-20 07:49:05 -08:00
|
|
|
if ((Conf.focus.raise_on_next_focus && (why == FOCUS_NEXT)) ||
|
|
|
|
(Conf.focus.raise_after_next_focus && (why == FOCUS_WARP_DONE)))
|
2004-02-01 03:28:06 -08:00
|
|
|
RaiseEwin(ewin);
|
|
|
|
|
2004-03-20 07:49:05 -08:00
|
|
|
if ((Conf.focus.warp_on_next_focus && (why == FOCUS_NEXT)) ||
|
|
|
|
(Conf.focus.warp_after_next_focus && (why == FOCUS_WARP_DONE)))
|
2004-02-01 03:28:06 -08:00
|
|
|
{
|
2004-06-28 16:37:55 -07:00
|
|
|
if (ewin != Mode.mouse_over_ewin)
|
2004-02-01 03:28:06 -08:00
|
|
|
XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0, ewin->w / 2,
|
|
|
|
ewin->h / 2);
|
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
RemoveTimerEvent("REVERSE_FOCUS_TIMEOUT");
|
2004-02-24 15:19:03 -08:00
|
|
|
if (why != FOCUS_DESK_ENTER)
|
|
|
|
DoIn("REVERSE_FOCUS_TIMEOUT", 0.5, ReverseTimeout, ewin->client.win,
|
|
|
|
NULL);
|
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);
|
|
|
|
ICCCM_Focus(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-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-02-26 11:33:21 -08:00
|
|
|
ewin = FocusEwinSelect();
|
|
|
|
if (ewin)
|
|
|
|
FocusToEWin(ewin, 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))
|
|
|
|
{
|
|
|
|
ewin = FocusEwinSelect();
|
|
|
|
if (ewin)
|
|
|
|
FocusToEWin(ewin, FOCUS_DESK_ENTER);
|
|
|
|
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-03-14 01:03:26 -08:00
|
|
|
#if 0 /* Remove old code */
|
2004-01-28 12:09:07 -08:00
|
|
|
void
|
|
|
|
FocusHandleEnter(XEvent * ev)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* multi screen handling -- root windows receive
|
|
|
|
* enter / leave notify
|
|
|
|
*/
|
2004-05-04 12:04:42 -07:00
|
|
|
if (ev->xany.window == VRoot.win)
|
2004-01-28 12:09:07 -08:00
|
|
|
{
|
2004-03-20 07:49:05 -08:00
|
|
|
if (!Mode.focuswin || Conf.focus.mode == MODE_FOCUS_POINTER)
|
2004-01-28 12:09:07 -08:00
|
|
|
HandleFocusWindow(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HandleFocusWindow(ev->xcrossing.window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FocusHandleLeave(XEvent * ev)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If we are leaving the root window, we are switching
|
|
|
|
* screens on a multi screen system - need to unfocus
|
|
|
|
* to allow other desk to grab focus...
|
|
|
|
*/
|
2004-05-04 12:04:42 -07:00
|
|
|
if (ev->xcrossing.window == VRoot.win)
|
2004-01-28 12:09:07 -08:00
|
|
|
{
|
|
|
|
if (ev->xcrossing.mode == NotifyNormal
|
2004-03-20 07:49:05 -08:00
|
|
|
&& ev->xcrossing.detail != NotifyInferior && Mode.focuswin)
|
2004-01-28 12:09:07 -08:00
|
|
|
HandleFocusWindow(0);
|
|
|
|
else
|
|
|
|
HandleFocusWindow(ev->xcrossing.window);
|
|
|
|
}
|
|
|
|
/* THIS caused the "emacs focus bug" ? */
|
|
|
|
/* else */
|
|
|
|
/* HandleFocusWindow(ev->xcrossing.window); */
|
|
|
|
}
|
2004-02-01 03:28:06 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
FocusHandleClick(Window win)
|
|
|
|
{
|
|
|
|
EWin *ewin;
|
|
|
|
|
|
|
|
ewin = GetEwinByCurrentPointer();
|
|
|
|
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 */
|
|
|
|
if (win == ewin->win_container)
|
|
|
|
{
|
|
|
|
XSync(disp, False);
|
|
|
|
XAllowEvents(disp, ReplayPointer, CurrentTime);
|
|
|
|
XSync(disp, False);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ewin->focusclick)
|
|
|
|
{
|
|
|
|
FocusToEWin(ewin, FOCUS_CLICK);
|
|
|
|
}
|
|
|
|
}
|