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"
|
|
|
|
|
1999-09-21 19:13:51 -07:00
|
|
|
static void ReverseTimeout(int val, void *data);
|
|
|
|
static void AutoraiseTimeout(int val, void *data);
|
|
|
|
|
2003-06-11 13:05:59 -07:00
|
|
|
static int new_desk_focus_nesting = 0;
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
/* Mostly stolen from the temporary 'ToolTipTimeout' */
|
1999-09-21 19:13:51 -07:00
|
|
|
static void
|
1999-08-17 15:56:46 -07:00
|
|
|
AutoraiseTimeout(int val, void *data)
|
|
|
|
{
|
|
|
|
EWin *found_ewin;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.mode == FOCUS_CLICK)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
|
|
|
found_ewin = FindItem("", val, LIST_FINDBY_ID, LIST_TYPE_EWIN);
|
|
|
|
if (found_ewin)
|
|
|
|
RaiseEwin(found_ewin);
|
|
|
|
data = NULL;
|
|
|
|
}
|
|
|
|
|
1999-09-21 19:13:51 -07:00
|
|
|
static void
|
1999-08-17 15:56:46 -07:00
|
|
|
ReverseTimeout(int val, void *data)
|
|
|
|
{
|
|
|
|
EWin *ewin;
|
|
|
|
|
|
|
|
ewin = RemoveItem("EWIN", val, LIST_FINDBY_ID, LIST_TYPE_EWIN);
|
|
|
|
if (ewin)
|
|
|
|
AddItem(ewin, "EWIN", ewin->client.win, LIST_TYPE_EWIN);
|
|
|
|
val = 0;
|
|
|
|
data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetNextFocusEwin(void)
|
|
|
|
{
|
|
|
|
EWin **lst0, **lst, *ewin;
|
|
|
|
int i, num0, num, ax, ay;
|
|
|
|
|
|
|
|
EDBUG(5, "GetNextFocusEwin");
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.warplist.enable)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
WarpFocus(1);
|
|
|
|
EDBUG_RETURN_;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
lst0 = (EWin **) ListItemType(&num0, LIST_TYPE_EWIN);
|
|
|
|
num = 0;
|
|
|
|
lst = NULL;
|
|
|
|
GetCurrentArea(&ax, &ay);
|
|
|
|
if (lst0)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num0; i++)
|
|
|
|
{
|
|
|
|
ewin = lst0[i];
|
|
|
|
if (((ewin->sticky) || (ewin->desktop == desks.current)) && ((ewin->area_x == ax) && (ewin->area_y == ay)) && (!ewin->skipfocus) && (!ewin->neverfocus) && (!ewin->iconified) && (!ewin->menu) && (!ewin->pager) && (!ewin->ibox) && (!ewin->iconified) /*&& (ewin->client.mwm_decor_title) &&
|
|
|
|
* * * * (ewin->client.mwm_decor_border) */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
num++;
|
|
|
|
lst = Erealloc(lst, sizeof(EWin *) * num);
|
|
|
|
lst[num - 1] = lst0[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(lst0);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
ewin = NULL;
|
|
|
|
if (lst)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (mode.focuswin == lst[i])
|
|
|
|
{
|
|
|
|
if (i < num - 1)
|
|
|
|
ewin = lst[i + 1];
|
|
|
|
else
|
|
|
|
ewin = lst[0];
|
|
|
|
Efree(lst);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.raise_on_next_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
RaiseEwin(ewin);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.warp_on_next_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0,
|
|
|
|
ewin->w / 2, ewin->h / 2);
|
|
|
|
FocusToEWin(ewin);
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ewin = lst[0];
|
|
|
|
Efree(lst);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.raise_on_next_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
RaiseEwin(ewin);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.warp_on_next_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0, ewin->w / 2,
|
|
|
|
ewin->h / 2);
|
|
|
|
FocusToEWin(ewin);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetPrevFocusEwin(void)
|
|
|
|
{
|
|
|
|
EWin **lst0, **lst, *ewin;
|
|
|
|
int i, num0, num, ax, ay;
|
|
|
|
|
|
|
|
EDBUG(5, "GetPrevFocusEwin");
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.warplist.enable)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
WarpFocus(-1);
|
|
|
|
EDBUG_RETURN_;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
RemoveTimerEvent("REVERSE_FOCUS_TIMEOUT");
|
|
|
|
DoIn("REVERSE_FOCUS_TIMEOUT", 1.0, ReverseTimeout, 0, NULL);
|
|
|
|
lst0 = (EWin **) ListItemType(&num0, LIST_TYPE_EWIN);
|
|
|
|
num = 0;
|
|
|
|
lst = NULL;
|
|
|
|
GetCurrentArea(&ax, &ay);
|
|
|
|
if (lst0)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num0; i++)
|
|
|
|
{
|
|
|
|
ewin = lst0[i];
|
|
|
|
DetermineEwinArea(ewin);
|
|
|
|
if (((ewin->sticky) || (ewin->desktop == desks.current))
|
|
|
|
&& ((ewin->area_x == ax) && (ewin->area_y == ay))
|
|
|
|
&& (!ewin->skipfocus) && (!ewin->neverfocus) && (!ewin->shaded)
|
|
|
|
&& (!ewin->menu) && (!ewin->pager) && (!ewin->ibox)
|
|
|
|
&& (!ewin->iconified)
|
|
|
|
/* && (ewin->client.mwm_decor_title) &&
|
|
|
|
* (ewin->client.mwm_decor_border) */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
num++;
|
|
|
|
lst = Erealloc(lst, sizeof(EWin *) * num);
|
|
|
|
lst[num - 1] = lst0[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(lst0);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
ewin = NULL;
|
|
|
|
if (lst)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (mode.focuswin == lst[i])
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
ewin = lst[num - 1];
|
|
|
|
else
|
|
|
|
ewin = lst[i - 1];
|
|
|
|
Efree(lst);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.raise_on_next_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
RaiseEwin(ewin);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.warp_on_next_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0,
|
|
|
|
ewin->w / 2, ewin->h / 2);
|
|
|
|
FocusToEWin(ewin);
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ewin = lst[0];
|
|
|
|
Efree(lst);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.raise_on_next_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
RaiseEwin(ewin);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.warp_on_next_focus)
|
2003-05-22 12:15:03 -07:00
|
|
|
XWarpPointer(disp, None, ewin->win, 0, 0, 0, 0, ewin->w / 2,
|
|
|
|
ewin->h / 2);
|
|
|
|
FocusToEWin(ewin);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FixFocus(void)
|
|
|
|
{
|
|
|
|
EWin **lst, *ewin;
|
|
|
|
int i, num;
|
|
|
|
|
|
|
|
EDBUG(5, "FixFocus");
|
|
|
|
num = 0;
|
|
|
|
lst = (EWin **) ListItemType(&num, LIST_TYPE_EWIN);
|
|
|
|
if (lst)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
ewin = lst[i];
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.mode == FOCUS_CLICK)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
|
|
|
if (!(ewin->active))
|
|
|
|
XGrabButton(disp, AnyButton, AnyModifier,
|
|
|
|
ewin->win_container, False, ButtonPressMask,
|
|
|
|
GrabModeSync, GrabModeAsync, None, None);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XUngrabButton(disp, AnyButton, AnyModifier,
|
|
|
|
ewin->win_container);
|
|
|
|
GrabButtonGrabs(ewin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(lst);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FocusToEWin(EWin * ewin)
|
|
|
|
{
|
|
|
|
int ax, ay;
|
|
|
|
|
|
|
|
EDBUG(4, "FocusToEWin");
|
1999-10-03 09:02:09 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
if (mode.slideout)
|
|
|
|
EDBUG_RETURN_;
|
1999-10-03 09:02:09 -07:00
|
|
|
|
|
|
|
if (clickmenu)
|
1999-10-03 09:53:11 -07:00
|
|
|
EDBUG_RETURN_;
|
1999-10-03 09:02:09 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
ICCCM_Cmap(ewin);
|
2004-01-12 12:43:18 -08:00
|
|
|
if ((!ewin) && (conf.focus.mode != FOCUS_POINTER))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
ewin = FindItem("", 0, LIST_FINDBY_NONE, LIST_TYPE_EWIN);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.mode == FOCUS_CLICK)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
|
|
|
if ((mode.focuswin) && (ewin))
|
|
|
|
{
|
|
|
|
if (!
|
|
|
|
(((ewin->desktop
|
|
|
|
== mode.focuswin->desktop) || (ewin->sticky))
|
|
|
|
&& (ewin->area_x == mode.focuswin->area_x)
|
|
|
|
&& (ewin->area_y == mode.focuswin->area_y)))
|
|
|
|
ewin = NULL;
|
|
|
|
}
|
|
|
|
else if (!mode.focuswin)
|
|
|
|
ewin = NULL;
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
if (ewin == mode.focuswin)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if (!mode.cur_menu_mode)
|
|
|
|
mode.context_ewin = ewin;
|
|
|
|
EDBUG_RETURN_;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
/* Never focus a window that's not on the current desktop. That's just dumb. -- mej */
|
|
|
|
if ((ewin) && (ewin->desktop != desks.current && !(ewin->sticky)))
|
|
|
|
ewin = NULL;
|
2000-02-27 07:02:10 -08:00
|
|
|
if ((ewin) && (ewin->neverfocus))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
EDBUG_RETURN_;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
if ((ewin) && (!ewin->client.need_input))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if (mode.windowdestroy == 1)
|
|
|
|
{
|
|
|
|
mode.focuswin = NULL;
|
|
|
|
mode.realfocuswin = NULL;
|
|
|
|
mode.windowdestroy = 0;
|
|
|
|
}
|
|
|
|
if (!mode.cur_menu_mode)
|
|
|
|
mode.context_ewin = ewin;
|
|
|
|
EDBUG_RETURN_;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
mode.windowdestroy = 0;
|
|
|
|
if (mode.focuswin)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.autoraise)
|
2003-05-22 12:15:03 -07:00
|
|
|
RemoveTimerEvent("AUTORAISE_TIMEOUT");
|
|
|
|
mode.focuswin->active = 0;
|
|
|
|
/* losing the focus may cause the titlebar to be resized */
|
|
|
|
CalcEwinSizes(mode.focuswin);
|
|
|
|
DrawEwin(mode.focuswin);
|
2004-01-12 12:43:18 -08:00
|
|
|
if ((conf.focus.clickraises) || (conf.focus.mode == FOCUS_CLICK))
|
2003-05-22 12:15:03 -07:00
|
|
|
XGrabButton(disp, AnyButton, AnyModifier,
|
|
|
|
mode.focuswin->win_container, False, ButtonPressMask,
|
|
|
|
GrabModeSync, GrabModeAsync, None, None);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
if (!ewin)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
mode.focuswin = NULL;
|
|
|
|
mode.realfocuswin = NULL;
|
|
|
|
mode.context_ewin = NULL;
|
|
|
|
ICCCM_Focus(NULL);
|
|
|
|
EDBUG_RETURN_;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else if (!ewin->menu)
|
|
|
|
mode.realfocuswin = ewin;
|
|
|
|
if (ewin)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if (!mode.cur_menu_mode)
|
|
|
|
mode.context_ewin = ewin;
|
|
|
|
mode.focuswin = ewin;
|
|
|
|
mode.focuswin->active = 1;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
/* gaining the focus may cause the titlebar to be resized */
|
2004-01-12 12:43:18 -08:00
|
|
|
if ((conf.focus.mode == FOCUS_CLICK) && (mode.focuswin))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
XUngrabButton(disp, AnyButton, AnyModifier,
|
|
|
|
mode.focuswin->win_container);
|
|
|
|
GrabButtonGrabs(mode.focuswin);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
if (mode.focuswin)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
CalcEwinSizes(mode.focuswin);
|
|
|
|
DrawEwin(mode.focuswin);
|
2004-01-03 04:29:58 -08:00
|
|
|
SoundPlay("SOUND_FOCUS_SET");
|
2003-05-22 12:15:03 -07:00
|
|
|
ICCCM_Focus(mode.focuswin);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-10-05 11:21:40 -07:00
|
|
|
/* ReZoom(mode.focuswin); */
|
2004-01-12 12:43:18 -08:00
|
|
|
if ((conf.autoraise) && (mode.focuswin) && (!mode.focuswin->menu)
|
|
|
|
&& (conf.focus.mode != FOCUS_CLICK))
|
|
|
|
DoIn("AUTORAISE_TIMEOUT", conf.autoraisetime, AutoraiseTimeout,
|
2003-05-22 12:15:03 -07:00
|
|
|
mode.focuswin->client.win, NULL);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.mode == FOCUS_CLICK)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if (ewin)
|
|
|
|
{
|
|
|
|
if (!ewin->sticky)
|
|
|
|
{
|
|
|
|
if ((ewin->desktop != desks.current) && (!ewin->iconified))
|
|
|
|
GotoDesktop(ewin->desktop);
|
|
|
|
}
|
|
|
|
if ((!ewin->fixedpos) && (!ewin->sticky))
|
|
|
|
{
|
|
|
|
GetCurrentArea(&ax, &ay);
|
|
|
|
if ((ax != ewin->area_x) || (ay != ewin->area_y))
|
|
|
|
{
|
|
|
|
if ((ewin->x >= root.w) || (ewin->y >= root.h)
|
|
|
|
|| ((ewin->x + ewin->w) < 0)
|
|
|
|
|| ((ewin->y + ewin->h) < 0))
|
|
|
|
SetCurrentArea(ewin->area_x, ewin->area_y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
RemoveTimerEvent("REVERSE_FOCUS_TIMEOUT");
|
|
|
|
if (mode.focuswin)
|
|
|
|
DoIn("REVERSE_FOCUS_TIMEOUT", 0.5, ReverseTimeout,
|
2003-05-22 12:15:03 -07:00
|
|
|
mode.focuswin->client.win, NULL);
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BeginNewDeskFocus(void)
|
|
|
|
{
|
|
|
|
EWin *ewin, **lst;
|
|
|
|
int i, j, num;
|
|
|
|
|
2003-06-11 13:05:59 -07:00
|
|
|
if (new_desk_focus_nesting++)
|
|
|
|
return;
|
|
|
|
|
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 */
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
lst = (EWin **) ListItemType(&num, LIST_TYPE_EWIN);
|
|
|
|
if (lst)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
ewin = lst[i];
|
|
|
|
XSelectInput(disp, ewin->win,
|
|
|
|
FocusChangeMask | SubstructureNotifyMask |
|
|
|
|
SubstructureRedirectMask | PropertyChangeMask |
|
|
|
|
ResizeRedirectMask);
|
|
|
|
if (ewin->pager)
|
2003-11-30 07:35:43 -08:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
XSelectInput(disp, ewin->client.win,
|
|
|
|
PropertyChangeMask | FocusChangeMask |
|
|
|
|
ResizeRedirectMask | StructureNotifyMask |
|
|
|
|
ColormapChangeMask | ButtonPressMask |
|
|
|
|
ButtonReleaseMask | PointerMotionMask);
|
|
|
|
#endif
|
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
else if (ewin->dialog)
|
|
|
|
XSelectInput(disp, ewin->client.win,
|
|
|
|
PropertyChangeMask | FocusChangeMask |
|
|
|
|
ResizeRedirectMask | StructureNotifyMask |
|
|
|
|
ColormapChangeMask | ExposureMask | KeyPressMask);
|
|
|
|
else
|
|
|
|
XSelectInput(disp, ewin->client.win,
|
|
|
|
PropertyChangeMask | FocusChangeMask |
|
|
|
|
ResizeRedirectMask | StructureNotifyMask |
|
|
|
|
ColormapChangeMask);
|
|
|
|
for (j = 0; j < ewin->border->num_winparts; j++)
|
|
|
|
{
|
|
|
|
if (ewin->border->part[j].flags & FLAG_TITLE)
|
|
|
|
XSelectInput(disp, ewin->bits[j].win,
|
|
|
|
ExposureMask | ButtonPressMask |
|
|
|
|
ButtonReleaseMask);
|
|
|
|
else
|
|
|
|
XSelectInput(disp, ewin->bits[j].win,
|
|
|
|
ButtonPressMask | ButtonReleaseMask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(lst);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-06-11 13:05:59 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
|
|
|
|
XSelectInput(disp, desks.desk[i].win,
|
2003-05-22 12:15:03 -07:00
|
|
|
PropertyChangeMask | SubstructureRedirectMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NewDeskFocus(void)
|
|
|
|
{
|
|
|
|
EWin *ewin, **lst;
|
|
|
|
int i, j, num;
|
|
|
|
|
|
|
|
EDBUG(4, "NewDeskFocus");
|
|
|
|
|
2003-06-11 13:05:59 -07:00
|
|
|
if (--new_desk_focus_nesting)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* we flipped - re-enable enter and leave events */
|
1999-08-17 15:56:46 -07:00
|
|
|
lst = (EWin **) ListItemType(&num, LIST_TYPE_EWIN);
|
|
|
|
if (lst)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
ewin = lst[i];
|
|
|
|
XSelectInput(disp, ewin->win,
|
|
|
|
FocusChangeMask | SubstructureNotifyMask |
|
|
|
|
SubstructureRedirectMask | EnterWindowMask |
|
|
|
|
LeaveWindowMask | PointerMotionMask |
|
|
|
|
PropertyChangeMask | ResizeRedirectMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask);
|
|
|
|
if (ewin->pager)
|
|
|
|
XSelectInput(disp, ewin->client.win,
|
|
|
|
PropertyChangeMask | EnterWindowMask |
|
|
|
|
LeaveWindowMask | FocusChangeMask |
|
|
|
|
ResizeRedirectMask | StructureNotifyMask |
|
|
|
|
ColormapChangeMask | ButtonPressMask |
|
|
|
|
ButtonReleaseMask | PointerMotionMask);
|
|
|
|
else if (ewin->dialog)
|
|
|
|
XSelectInput(disp, ewin->client.win,
|
|
|
|
PropertyChangeMask | EnterWindowMask |
|
|
|
|
LeaveWindowMask | FocusChangeMask |
|
|
|
|
ResizeRedirectMask | StructureNotifyMask |
|
|
|
|
ColormapChangeMask | ExposureMask | KeyPressMask);
|
|
|
|
else
|
|
|
|
XSelectInput(disp, ewin->client.win,
|
|
|
|
PropertyChangeMask | EnterWindowMask |
|
|
|
|
LeaveWindowMask | FocusChangeMask |
|
|
|
|
ResizeRedirectMask | StructureNotifyMask |
|
|
|
|
ColormapChangeMask);
|
|
|
|
for (j = 0; j < ewin->border->num_winparts; j++)
|
|
|
|
{
|
|
|
|
if (ewin->border->part[j].flags & FLAG_TITLE)
|
|
|
|
XSelectInput(disp, ewin->bits[j].win,
|
|
|
|
ExposureMask | KeyPressMask | KeyReleaseMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask |
|
|
|
|
PointerMotionMask);
|
|
|
|
else
|
|
|
|
XSelectInput(disp, ewin->bits[j].win,
|
|
|
|
KeyPressMask | KeyReleaseMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask |
|
|
|
|
PointerMotionMask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(lst);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-06-11 13:05:59 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
for (i = 0; i < ENLIGHTENMENT_CONF_NUM_DESKTOPS; i++)
|
|
|
|
XSelectInput(disp, desks.desk[i].win,
|
2003-05-22 12:15:03 -07:00
|
|
|
SubstructureNotifyMask | ButtonPressMask |
|
|
|
|
ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
|
|
|
|
ButtonMotionMask | PropertyChangeMask |
|
|
|
|
SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
|
|
|
|
PointerMotionMask);
|
2003-06-11 13:05:59 -07:00
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if ((conf.focus.mode == FOCUS_POINTER) || (conf.focus.mode == FOCUS_SLOPPY))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
ewin = GetEwinPointerInClient();
|
|
|
|
if (ewin)
|
|
|
|
ICCCM_Focus(ewin);
|
|
|
|
else
|
|
|
|
ICCCM_Focus(NULL);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
lst = (EWin **) ListItemType(&num, LIST_TYPE_EWIN);
|
|
|
|
if (lst)
|
|
|
|
{
|
|
|
|
int ax, ay;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
GetCurrentArea(&ax, &ay);
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
ewin = lst[i];
|
|
|
|
if ((ewin->sticky)
|
|
|
|
||
|
|
|
|
((((ewin->area_x
|
|
|
|
== ax) && (ewin->area_y == ay)) || (ewin->fixedpos))
|
|
|
|
&& (ewin->desktop == desks.current)))
|
|
|
|
{
|
|
|
|
ICCCM_Focus(ewin);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(lst);
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-06-11 13:05:59 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
#if 0 /* Clean up if OK -- Remove FocusToNone */
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
|
|
|
FocusToNone(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
EDBUG(4, "FocusToNone");
|
|
|
|
|
|
|
|
if ((mode.focuswin) && (mode.focuswin->floating))
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
ICCCM_Cmap(NULL);
|
|
|
|
if (mode.focuswin)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.autoraise)
|
2003-05-22 12:15:03 -07:00
|
|
|
RemoveTimerEvent("AUTORAISE_TIMEOUT");
|
|
|
|
mode.focuswin->active = 0;
|
|
|
|
/* losing the focus may cause the titlebar to be resized */
|
|
|
|
CalcEwinSizes(mode.focuswin);
|
|
|
|
DrawEwin(mode.focuswin);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.focus.mode == FOCUS_CLICK)
|
2003-05-22 12:15:03 -07:00
|
|
|
XGrabButton(disp, AnyButton, AnyModifier,
|
|
|
|
mode.focuswin->win_container, False, ButtonPressMask,
|
|
|
|
GrabModeSync, GrabModeAsync, None, None);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
XSetInputFocus(disp, root.win, RevertToPointerRoot, CurrentTime);
|
|
|
|
mode.focuswin = NULL;
|
|
|
|
mode.realfocuswin = NULL;
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
2003-05-04 03:27:21 -07:00
|
|
|
#endif
|