1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2007-01-13 11:14:29 -08:00
|
|
|
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
|
|
|
* Copyright (C) 2004-2007 Kim Woelders
|
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
|
|
|
/*
|
|
|
|
* Author: Merlin Hughes
|
|
|
|
* - merlin@merlin.org
|
|
|
|
*
|
|
|
|
* This code is free software.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
#include "E.h"
|
2007-03-05 19:33:31 -08:00
|
|
|
#include "desktops.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "emodule.h"
|
|
|
|
#include "ewins.h"
|
2006-11-19 13:55:52 -08:00
|
|
|
#include "focus.h"
|
|
|
|
#include "grabs.h"
|
2005-09-26 10:32:10 -07:00
|
|
|
#include "iclass.h"
|
2005-05-25 14:42:59 -07:00
|
|
|
#include "icons.h"
|
2006-04-22 15:00:02 -07:00
|
|
|
#include "screen.h"
|
2005-09-26 10:32:10 -07:00
|
|
|
#include "tclass.h"
|
2005-08-20 06:55:51 -07:00
|
|
|
#include "tooltips.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "xwin.h"
|
2004-12-28 15:46:49 -08:00
|
|
|
#include <X11/keysym.h>
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-04-18 12:26:32 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
EWin *ewin;
|
2006-04-29 12:39:21 -07:00
|
|
|
Win win;
|
2004-04-18 12:26:32 -07:00
|
|
|
char *txt;
|
|
|
|
} WarplistItem;
|
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
EObj o;
|
|
|
|
TextClass *tc;
|
|
|
|
ImageClass *ic;
|
|
|
|
int mw, mh, tw, th;
|
|
|
|
} WarpFocusWin;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
static void WarpFocusHandleEvent(Win win, XEvent * ev, void *prm);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
static WarpFocusWin *warpFocusWindow = NULL;
|
2005-04-17 06:58:09 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
static int warpFocusIndex = 0;
|
2004-03-18 16:27:16 -08:00
|
|
|
static unsigned int warpFocusKey = 0;
|
2004-04-18 12:26:32 -07:00
|
|
|
static int warplist_num = 0;
|
|
|
|
static WarplistItem *warplist;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-02-09 11:29:16 -08:00
|
|
|
#define ICON_PAD 2
|
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
static WarpFocusWin *
|
|
|
|
WarpFocusWinCreate(void)
|
|
|
|
{
|
|
|
|
WarpFocusWin *fw;
|
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
fw = ECALLOC(WarpFocusWin, 1);
|
2005-10-15 13:37:25 -07:00
|
|
|
if (!fw)
|
|
|
|
return fw;
|
|
|
|
|
2005-10-16 02:33:49 -07:00
|
|
|
EoInit(fw, EOBJ_TYPE_MISC, None, 0, 0, 1, 1, 1, "Warp");
|
2005-10-15 13:37:25 -07:00
|
|
|
EoSetFloating(fw, 1);
|
|
|
|
EoSetLayer(fw, 20);
|
|
|
|
|
|
|
|
EventCallbackRegister(EoGetWin(fw), 0, WarpFocusHandleEvent, NULL);
|
|
|
|
ESelectInput(EoGetWin(fw), ButtonReleaseMask);
|
|
|
|
|
|
|
|
fw->tc = TextclassFind("WARPFOCUS", 0);
|
|
|
|
if (!fw->tc)
|
|
|
|
fw->tc = TextclassFind("COORDS", 1);
|
|
|
|
|
|
|
|
fw->ic = ImageclassFind("WARPFOCUS", 0);
|
|
|
|
if (!fw->ic)
|
|
|
|
fw->ic = ImageclassFind("COORDS", 1);
|
|
|
|
|
|
|
|
return fw;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2003-08-10 08:44:47 -07:00
|
|
|
static void
|
2005-10-15 13:37:25 -07:00
|
|
|
WarpFocusWinDestroy(WarpFocusWin * fw)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2005-10-15 13:37:25 -07:00
|
|
|
EventCallbackUnregister(EoGetWin(fw), 0, WarpFocusHandleEvent, NULL);
|
2005-10-16 02:33:49 -07:00
|
|
|
EoFini(fw);
|
2005-10-15 13:37:25 -07:00
|
|
|
Efree(fw);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
WarpFocusWinShow(WarpFocusWin * fw)
|
|
|
|
{
|
|
|
|
WarplistItem *wi;
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageBorder *pad;
|
2007-03-05 19:33:31 -08:00
|
|
|
EWin *ewin;
|
2005-06-30 05:03:38 -07:00
|
|
|
int i, x, y, w, h, ww, hh;
|
2007-03-05 19:33:31 -08:00
|
|
|
char s[1024], ss[32];
|
2005-06-30 05:03:38 -07:00
|
|
|
const char *fmt;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
w = 0;
|
|
|
|
h = 0;
|
|
|
|
pad = ImageclassGetPadding(fw->ic);
|
2005-06-30 05:03:38 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
for (i = 0; i < warplist_num; i++)
|
|
|
|
{
|
|
|
|
wi = warplist + i;
|
|
|
|
wi->win = ECreateWindow(EoGetWin(fw), 0, 0, 1, 1, 0);
|
|
|
|
EMapWindow(wi->win);
|
2007-03-05 19:33:31 -08:00
|
|
|
|
|
|
|
ewin = wi->ewin;
|
|
|
|
if (ewin->state.iconified)
|
|
|
|
fmt = "%s[%s]";
|
|
|
|
else if (ewin->state.shaded)
|
|
|
|
fmt = "%s=%s=";
|
2005-10-15 13:37:25 -07:00
|
|
|
else
|
2007-03-05 19:33:31 -08:00
|
|
|
fmt = "%s%s";
|
|
|
|
ss[0] = '\0';
|
|
|
|
if (Conf.warplist.showalldesks)
|
|
|
|
{
|
|
|
|
if (EoIsSticky(ewin) || ewin->state.iconified)
|
|
|
|
strcpy(ss, "[-] ");
|
|
|
|
else
|
|
|
|
Esnprintf(ss, sizeof(ss), "[%d] ", EoGetDeskNum(ewin));
|
|
|
|
}
|
|
|
|
Esnprintf(s, sizeof(s), fmt, ss, EwinGetTitle(ewin));
|
2005-10-15 13:37:25 -07:00
|
|
|
wi->txt = strdup(s);
|
|
|
|
TextSize(fw->tc, 0, 0, 0, wi->txt, &ww, &hh, 17);
|
|
|
|
if (ww > w)
|
|
|
|
w = ww;
|
|
|
|
if (hh > h)
|
|
|
|
h = hh;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
fw->tw = w; /* Text size */
|
|
|
|
fw->th = h;
|
|
|
|
w += pad->left + pad->right;
|
|
|
|
h += pad->top + pad->bottom;
|
|
|
|
if (Conf.warplist.icon_mode != 0)
|
|
|
|
w += h;
|
|
|
|
fw->mw = w; /* Focus list item size */
|
|
|
|
fw->mh = h;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
/* Reset shape */
|
|
|
|
EShapeCombineMask(EoGetWin(fw), ShapeBounding, 0, 0, None, ShapeSet);
|
2003-08-10 08:44:47 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
GetPointerScreenAvailableArea(&x, &y, &ww, &hh);
|
|
|
|
x += (ww - w) / 2;
|
|
|
|
y += (hh - h * warplist_num) / 2;
|
|
|
|
EoMoveResize(fw, x, y, w, h * warplist_num);
|
2005-09-26 10:32:10 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
for (i = 0; i < warplist_num; i++)
|
|
|
|
EMoveResizeWindow(warplist[i].win, 0, (h * i), fw->mw, fw->mh);
|
2005-04-17 06:58:09 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
EoMap(fw, 0);
|
2005-04-17 06:58:09 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
/*
|
|
|
|
* Grab the keyboard. The grab is automatically released when
|
|
|
|
* WarpFocusHide unmaps warpFocusWindow.
|
|
|
|
*/
|
2006-04-29 12:39:21 -07:00
|
|
|
GrabKeyboardSet(EoGetWin(fw));
|
|
|
|
GrabPointerSet(EoGetWin(fw), None, 0);
|
2005-04-17 06:58:09 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
TooltipsEnable(0);
|
|
|
|
}
|
2005-04-17 06:58:09 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
static void
|
|
|
|
WarpFocusWinHide(WarpFocusWin * fw)
|
|
|
|
{
|
|
|
|
int i;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
EoUnmap(fw);
|
|
|
|
for (i = 0; i < warplist_num; i++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2005-10-15 13:37:25 -07:00
|
|
|
EDestroyWindow(warplist[i].win);
|
|
|
|
Efree(warplist[i].txt);
|
|
|
|
}
|
|
|
|
#if 0 /* We might as well keep it around */
|
|
|
|
WarpFocusWinDestroy(fw);
|
|
|
|
warpFocusWindow = NULL;
|
|
|
|
#endif
|
2005-02-09 11:29:16 -08:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
TooltipsEnable(1);
|
|
|
|
}
|
2003-08-10 08:44:47 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
static void
|
|
|
|
WarpFocusWinPaint(WarpFocusWin * fw)
|
|
|
|
{
|
2006-04-22 06:24:51 -07:00
|
|
|
int i, state, iw;
|
2005-10-15 13:37:25 -07:00
|
|
|
WarplistItem *wi;
|
2006-04-22 06:24:51 -07:00
|
|
|
EImageBorder *pad;
|
|
|
|
|
|
|
|
pad = ImageclassGetPadding(fw->ic);
|
2003-08-10 08:44:47 -07:00
|
|
|
|
2004-04-18 12:26:32 -07:00
|
|
|
for (i = 0; i < warplist_num; i++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2005-10-15 13:37:25 -07:00
|
|
|
wi = warplist + i;
|
2005-05-25 14:42:59 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
if (!EwinFindByPtr(wi->ewin))
|
|
|
|
wi->ewin = NULL;
|
|
|
|
if (!wi->ewin)
|
|
|
|
continue;
|
2004-04-18 12:26:32 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
state = (i == warpFocusIndex) ? STATE_CLICKED : STATE_NORMAL;
|
2004-02-28 17:30:18 -08:00
|
|
|
|
2007-09-10 13:26:53 -07:00
|
|
|
ImageclassApply(fw->ic, wi->win, 0, 0, state, ST_WARPLIST);
|
2005-02-09 05:45:30 -08:00
|
|
|
|
2006-04-22 06:24:51 -07:00
|
|
|
iw = 0;
|
2005-10-15 13:37:25 -07:00
|
|
|
if (Conf.warplist.icon_mode != 0)
|
|
|
|
{
|
|
|
|
int icon_size = fw->mh - 2 * ICON_PAD;
|
2006-03-29 11:13:17 -08:00
|
|
|
EImage *im;
|
2005-10-15 13:37:25 -07:00
|
|
|
|
|
|
|
im = EwinIconImageGet(wi->ewin, icon_size,
|
|
|
|
Conf.warplist.icon_mode);
|
2006-04-22 06:24:51 -07:00
|
|
|
if (im)
|
|
|
|
{
|
2007-04-07 09:18:53 -07:00
|
|
|
EImageRenderOnDrawable(im, wi->win, None,
|
|
|
|
EIMAGE_BLEND | EIMAGE_ANTI_ALIAS,
|
2006-05-13 06:25:30 -07:00
|
|
|
pad->left + ICON_PAD, ICON_PAD,
|
2007-04-06 15:20:07 -07:00
|
|
|
icon_size, icon_size);
|
2006-04-22 06:24:51 -07:00
|
|
|
EImageFree(im);
|
|
|
|
}
|
|
|
|
iw = fw->mh;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2006-04-22 06:24:51 -07:00
|
|
|
|
2006-05-08 09:26:22 -07:00
|
|
|
TextDraw(fw->tc, wi->win, None, 0, 0, state, wi->txt,
|
2006-04-22 06:24:51 -07:00
|
|
|
pad->left + iw, pad->top, fw->tw, fw->th, 0, 0);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-08-10 08:44:47 -07:00
|
|
|
|
2005-07-13 12:39:22 -07:00
|
|
|
/* FIXME - Check shape */
|
2006-01-22 10:25:41 -08:00
|
|
|
EoShapeUpdate(fw, 1);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2003-08-10 08:44:47 -07:00
|
|
|
static void
|
2005-10-15 13:37:25 -07:00
|
|
|
WarpFocusShow(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2005-10-15 13:37:25 -07:00
|
|
|
WarpFocusWin *fw = warpFocusWindow;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
if (!warplist)
|
|
|
|
return;
|
2005-04-17 06:58:09 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
if (!fw)
|
|
|
|
{
|
|
|
|
warpFocusWindow = fw = WarpFocusWinCreate();
|
|
|
|
if (!fw)
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-08-10 08:44:47 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
if (!EoIsShown(fw))
|
|
|
|
WarpFocusWinShow(fw);
|
|
|
|
|
|
|
|
WarpFocusWinPaint(fw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
WarpFocusHide(void)
|
|
|
|
{
|
|
|
|
WarpFocusWin *fw = warpFocusWindow;
|
|
|
|
|
|
|
|
if (fw && EoIsShown(fw))
|
|
|
|
WarpFocusWinHide(fw);
|
|
|
|
|
2004-04-18 12:26:32 -07:00
|
|
|
if (warplist)
|
|
|
|
Efree(warplist);
|
|
|
|
warplist = NULL;
|
|
|
|
warplist_num = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
WarpFocus(int delta)
|
|
|
|
{
|
2005-10-15 13:37:25 -07:00
|
|
|
WarpFocusWin *fw = warpFocusWindow;
|
2005-06-30 05:03:38 -07:00
|
|
|
EWin *const *lst;
|
|
|
|
EWin *ewin;
|
|
|
|
int i, num;
|
|
|
|
WarplistItem *wl;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* Remember invoking keycode (ugly hack) */
|
2005-10-15 13:37:25 -07:00
|
|
|
if (!fw || !EoIsShown(fw))
|
2005-08-15 09:57:13 -07:00
|
|
|
warpFocusKey = Mode.events.last_keycode;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-06-30 05:03:38 -07:00
|
|
|
if (!warplist)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-06-30 05:03:38 -07:00
|
|
|
lst = EwinListFocusGet(&num);
|
|
|
|
for (i = 0; i < num; i++)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-06-30 05:03:38 -07:00
|
|
|
ewin = lst[i];
|
2004-12-28 15:46:49 -08:00
|
|
|
if ( /* Either visible or iconified */
|
2007-03-05 19:33:31 -08:00
|
|
|
((EwinIsOnScreen(ewin)) || (ewin->state.iconified) ||
|
|
|
|
(Conf.warplist.showalldesks)) &&
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Exclude windows that explicitely say so */
|
2005-07-08 09:48:19 -07:00
|
|
|
(!ewin->props.skip_focuslist) &&
|
2005-09-10 18:50:10 -07:00
|
|
|
(!ewin->props.skip_ext_task) &&
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Keep shaded windows if conf say so */
|
2005-07-08 09:48:19 -07:00
|
|
|
((!ewin->state.shaded) || (Conf.warplist.showshaded)) &&
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Keep sticky windows if conf say so */
|
|
|
|
((!EoIsSticky(ewin)) || (Conf.warplist.showsticky)) &&
|
|
|
|
/* Keep iconified windows if conf say so */
|
2005-07-08 09:48:19 -07:00
|
|
|
((!ewin->state.iconified) || (Conf.warplist.showiconified)))
|
2005-06-30 05:03:38 -07:00
|
|
|
{
|
|
|
|
warplist_num++;
|
2007-01-16 17:10:44 -08:00
|
|
|
warplist = EREALLOC(WarplistItem, warplist, warplist_num);
|
2005-06-30 05:03:38 -07:00
|
|
|
wl = warplist + warplist_num - 1;
|
|
|
|
wl->ewin = ewin;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2005-06-30 05:03:38 -07:00
|
|
|
/* Hmmm. Hack... */
|
|
|
|
if (warplist_num >= 2 && warplist[1].ewin == GetFocusEwin())
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-06-30 05:03:38 -07:00
|
|
|
warplist[1].ewin = warplist[0].ewin;
|
|
|
|
warplist[0].ewin = GetFocusEwin();
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2005-06-30 05:03:38 -07:00
|
|
|
|
|
|
|
warpFocusIndex = 0;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2005-06-30 05:03:38 -07:00
|
|
|
|
|
|
|
if (!warplist)
|
|
|
|
return;
|
|
|
|
|
|
|
|
warpFocusIndex = (warpFocusIndex + warplist_num + delta) % warplist_num;
|
|
|
|
ewin = warplist[warpFocusIndex].ewin;
|
2005-06-30 05:50:47 -07:00
|
|
|
if (!EwinFindByPtr(ewin))
|
2005-06-30 05:03:38 -07:00
|
|
|
ewin = NULL;
|
|
|
|
if (!ewin)
|
|
|
|
return;
|
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
WarpFocusShow();
|
2005-07-09 15:55:56 -07:00
|
|
|
|
2007-03-05 19:33:31 -08:00
|
|
|
if (!EwinIsOnScreen(ewin))
|
|
|
|
return;
|
|
|
|
|
2005-06-30 05:03:38 -07:00
|
|
|
if (Conf.focus.raise_on_next)
|
2006-05-03 13:52:15 -07:00
|
|
|
EwinRaise(ewin);
|
2005-06-30 05:03:38 -07:00
|
|
|
if (Conf.focus.warp_on_next)
|
2005-07-08 09:48:19 -07:00
|
|
|
if (ewin != Mode.mouse_over_ewin && !ewin->state.iconified)
|
2005-07-09 15:55:56 -07:00
|
|
|
{
|
2006-04-23 16:18:23 -07:00
|
|
|
EXWarpPointer(EoGetXwin(ewin), EoGetW(ewin) / 2, EoGetH(ewin) / 2);
|
2005-07-09 15:55:56 -07:00
|
|
|
Mode.mouse_over_ewin = ewin;
|
|
|
|
}
|
2005-06-30 05:03:38 -07:00
|
|
|
if (Conf.warplist.warpfocused)
|
|
|
|
FocusToEWin(ewin, FOCUS_SET);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-06-30 05:03:38 -07:00
|
|
|
WarpFocusClick(int ix)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-06-30 05:03:38 -07:00
|
|
|
EWin *ewin;
|
|
|
|
|
|
|
|
if (!warplist)
|
|
|
|
return;
|
2007-01-28 21:27:47 -08:00
|
|
|
if (ix < 0 || ix >= warplist_num)
|
|
|
|
return;
|
|
|
|
if (ix == warpFocusIndex)
|
|
|
|
return;
|
|
|
|
|
|
|
|
warpFocusIndex = ix;
|
|
|
|
WarpFocusShow();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-06-30 05:03:38 -07:00
|
|
|
ewin = warplist[ix].ewin;
|
2005-06-30 05:50:47 -07:00
|
|
|
if (!EwinFindByPtr(ewin))
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-03-05 19:33:31 -08:00
|
|
|
if (Conf.focus.raise_on_next)
|
|
|
|
EwinRaise(ewin);
|
2007-01-28 21:27:47 -08:00
|
|
|
|
2005-06-30 05:03:38 -07:00
|
|
|
FocusToEWin(ewin, FOCUS_SET);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
WarpFocusFinish(void)
|
|
|
|
{
|
|
|
|
EWin *ewin;
|
|
|
|
|
|
|
|
ewin = warplist[warpFocusIndex].ewin;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-04-17 06:58:09 -07:00
|
|
|
WarpFocusHide();
|
2005-06-30 05:03:38 -07:00
|
|
|
|
2005-07-09 03:27:39 -07:00
|
|
|
if (!EwinFindByPtr(ewin))
|
2005-06-30 05:03:38 -07:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-03-05 19:33:31 -08:00
|
|
|
EwinOpActivate(ewin, OPSRC_USER, Conf.warplist.raise_on_select);
|
2005-06-30 05:03:38 -07:00
|
|
|
if (Conf.warplist.warp_on_select)
|
|
|
|
if (ewin != Mode.mouse_over_ewin)
|
2005-07-09 15:55:56 -07:00
|
|
|
{
|
2006-04-23 16:18:23 -07:00
|
|
|
EXWarpPointer(EoGetXwin(ewin), EoGetW(ewin) / 2, EoGetH(ewin) / 2);
|
2005-07-09 15:55:56 -07:00
|
|
|
Mode.mouse_over_ewin = ewin;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-04-29 12:39:21 -07:00
|
|
|
WarpFocusHandleEvent(Win win __UNUSED__, XEvent * ev, void *prm __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-10-15 13:37:25 -07:00
|
|
|
WarpFocusWin *fw = warpFocusWindow;
|
2005-07-13 12:39:22 -07:00
|
|
|
KeySym key;
|
2007-01-31 18:35:16 -08:00
|
|
|
unsigned int mask;
|
2005-07-13 12:39:22 -07:00
|
|
|
|
2005-10-15 13:37:25 -07:00
|
|
|
if (!EoIsShown(fw))
|
2005-10-13 11:34:52 -07:00
|
|
|
return;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
switch (ev->type)
|
|
|
|
{
|
|
|
|
case KeyPress:
|
2005-10-13 11:34:52 -07:00
|
|
|
if (ev->xkey.keycode == warpFocusKey)
|
2007-01-31 18:35:16 -08:00
|
|
|
key = 0x80000000;
|
2005-10-13 11:34:52 -07:00
|
|
|
else
|
|
|
|
key = XLookupKeysym(&ev->xkey, 0);
|
|
|
|
switch (key)
|
2005-09-10 18:50:10 -07:00
|
|
|
{
|
2005-10-13 11:34:52 -07:00
|
|
|
default:
|
|
|
|
break;
|
2007-01-31 18:35:16 -08:00
|
|
|
case 0x80000000:
|
2005-10-13 11:34:52 -07:00
|
|
|
case XK_Down:
|
|
|
|
WarpFocus(1);
|
|
|
|
break;
|
|
|
|
case XK_Up:
|
|
|
|
WarpFocus(-1);
|
2005-09-10 18:50:10 -07:00
|
|
|
break;
|
|
|
|
}
|
2005-10-13 11:34:52 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KeyRelease:
|
2007-01-31 18:35:16 -08:00
|
|
|
mask = 0;
|
|
|
|
EQueryPointer(NULL, NULL, NULL, NULL, &mask);
|
|
|
|
if ((mask & Mode.masks.mod_key_mask) == 0)
|
|
|
|
{
|
|
|
|
WarpFocusFinish();
|
|
|
|
break;
|
|
|
|
}
|
2005-09-10 18:50:10 -07:00
|
|
|
if (ev->xkey.keycode == warpFocusKey)
|
2007-01-31 18:35:16 -08:00
|
|
|
key = 0x80000000;
|
2005-09-10 18:50:10 -07:00
|
|
|
else
|
|
|
|
key = XLookupKeysym(&ev->xkey, 0);
|
2005-07-13 12:39:22 -07:00
|
|
|
switch (key)
|
|
|
|
{
|
2005-10-13 11:34:52 -07:00
|
|
|
case XK_Escape:
|
|
|
|
WarpFocusHide();
|
|
|
|
break;
|
2007-01-31 18:35:16 -08:00
|
|
|
default:
|
|
|
|
case 0x80000000:
|
2005-07-13 12:39:22 -07:00
|
|
|
case XK_Down:
|
|
|
|
case XK_Up:
|
|
|
|
break;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
2005-06-30 05:03:38 -07:00
|
|
|
|
|
|
|
case ButtonRelease:
|
2005-10-15 13:37:25 -07:00
|
|
|
WarpFocusClick((ev->xbutton.y * warplist_num) / EoGetH(fw));
|
2005-06-30 05:03:38 -07:00
|
|
|
break;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Warplist module
|
|
|
|
*/
|
|
|
|
|
2005-04-23 06:30:03 -07:00
|
|
|
static void
|
|
|
|
WarplistCfgValidate(void)
|
|
|
|
{
|
|
|
|
if (Conf.warplist.icon_mode < 0 || Conf.warplist.icon_mode > 3)
|
|
|
|
Conf.warplist.icon_mode = 3;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
WarplistSighan(int sig, void *prm __UNUSED__)
|
|
|
|
{
|
|
|
|
switch (sig)
|
|
|
|
{
|
|
|
|
case ESIGNAL_INIT:
|
2005-04-23 06:30:03 -07:00
|
|
|
WarplistCfgValidate();
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const CfgItem WarplistCfgItems[] = {
|
|
|
|
CFG_ITEM_BOOL(Conf.warplist, enable, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf.warplist, showsticky, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf.warplist, showshaded, 1),
|
2007-03-05 19:33:31 -08:00
|
|
|
CFG_ITEM_BOOL(Conf.warplist, showiconified, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf.warplist, showalldesks, 0),
|
2004-12-28 15:46:49 -08:00
|
|
|
CFG_ITEM_BOOL(Conf.warplist, warpfocused, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf.warplist, raise_on_select, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf.warplist, warp_on_select, 0),
|
2006-09-25 11:19:20 -07:00
|
|
|
CFG_ITEM_INT(Conf.warplist, icon_mode, 3),
|
2004-12-28 15:46:49 -08:00
|
|
|
};
|
|
|
|
#define N_CFG_ITEMS (sizeof(WarplistCfgItems)/sizeof(CfgItem))
|
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
extern const EModule ModWarplist;
|
2006-04-21 15:52:59 -07:00
|
|
|
const EModule ModWarplist = {
|
2004-12-28 15:46:49 -08:00
|
|
|
"warplist", "warp",
|
|
|
|
WarplistSighan,
|
|
|
|
{0, NULL},
|
|
|
|
{N_CFG_ITEMS, WarplistCfgItems}
|
|
|
|
};
|