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.
|
|
|
|
*/
|
2003-11-08 15:57:49 -08:00
|
|
|
#define DECLARE_STRUCT_PAGER
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
#define PAGER_EVENT_MOUSE_OUT -1
|
|
|
|
#define PAGER_EVENT_MOTION 0
|
|
|
|
#define PAGER_EVENT_MOUSE_IN 1
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
static void PagerUpdateTimeout(int val, void *data);
|
2003-11-30 07:35:43 -08:00
|
|
|
static void PagerEwinUpdateMini(Pager * p, EWin * ewin);
|
|
|
|
static void PagerEwinUpdateFromPager(Pager * p, EWin * ewin);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
#define HIQ conf.pagers.hiq
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
PagerUpdateTimeout(int val, void *data)
|
|
|
|
{
|
|
|
|
Pager *p;
|
|
|
|
char s[4096];
|
1999-10-09 11:25:04 -07:00
|
|
|
static double last_time = 0.0;
|
|
|
|
double cur_time, in;
|
|
|
|
static int calls = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
int y, y2, phase, ax, ay, cx, cy, ww, hh, xx, yy;
|
2000-06-04 12:45:55 -07:00
|
|
|
static int offsets[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
p = (Pager *) data;
|
2003-12-09 12:25:17 -08:00
|
|
|
Esnprintf(s, sizeof(s), "__.%x", (unsigned)p->win);
|
1999-10-09 11:25:04 -07:00
|
|
|
/* prevent runaway pager timeouts - dont knwo how it happens - but hack */
|
|
|
|
/* around to stop it */
|
|
|
|
cur_time = GetTime();
|
|
|
|
if ((cur_time - last_time) < 0.05)
|
|
|
|
calls++;
|
|
|
|
last_time = cur_time;
|
2004-01-12 12:43:18 -08:00
|
|
|
in = 1 / ((double)conf.pagers.scanspeed);
|
1999-10-09 11:25:04 -07:00
|
|
|
if (calls > 50)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
calls = 0;
|
|
|
|
in = 0.25;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.pagers.scanspeed > 0)
|
1999-10-09 11:25:04 -07:00
|
|
|
DoIn(s, in, PagerUpdateTimeout, 0, p);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.snap)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
|
|
|
if (!p->visible)
|
|
|
|
return;
|
|
|
|
if (p->desktop != desks.current)
|
|
|
|
return;
|
|
|
|
if (mode.mode != MODE_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
GetCurrentArea(&cx, &cy);
|
|
|
|
ww = p->w / ax;
|
|
|
|
hh = p->h / ay;
|
|
|
|
xx = cx * ww;
|
|
|
|
yy = cy * hh;
|
|
|
|
phase = p->update_phase;
|
|
|
|
y = ((phase & 0xfffffff8) + offsets[phase % 8]) % hh;
|
|
|
|
y2 = (y * root.h) / hh;
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
ScaleLine(p->pmap, root.win, xx, yy + y, root.w, ww, y2, (root.h / hh));
|
1999-08-17 15:56:46 -07:00
|
|
|
XClearArea(disp, p->win, xx, yy + y, ww, 1, False);
|
|
|
|
|
|
|
|
p->update_phase++;
|
|
|
|
if (p->update_phase >= p->h)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
int i;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < desks.desk[p->desktop].num; i++)
|
|
|
|
PagerEwinUpdateFromPager(p, desks.desk[p->desktop].list[i]);
|
|
|
|
p->update_phase = 0;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Pager *
|
2003-11-30 07:35:43 -08:00
|
|
|
PagerCreate(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
Pager *p;
|
|
|
|
int ax, ay;
|
|
|
|
char pq;
|
|
|
|
ImageClass *ic;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
static char did_dialog = 0;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return NULL;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if ((!did_dialog) && (conf.pagers.snap))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-11-15 14:27:17 -08:00
|
|
|
#if !USE_IMLIB2
|
|
|
|
if (pImlib_Context->x.shm)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-11-15 14:27:17 -08:00
|
|
|
if (!pImlib_Context->x.shmp)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
|
|
|
if (XShmPixmapFormat(disp) != ZPixmap)
|
|
|
|
{
|
|
|
|
SettingsPager();
|
2004-01-10 05:40:59 -08:00
|
|
|
DialogOK(_("Warning!"),
|
|
|
|
_("\n"
|
|
|
|
"You seem to have an X Server capable of Shared Memory\n"
|
|
|
|
"but it is incapable of doing ZPixmap Shared pixmaps\n"
|
|
|
|
"(The server does not claim to be able to do them).\n"
|
|
|
|
"\n"
|
|
|
|
"The pager in Enlightenment will run slowly in snapshot\n"
|
|
|
|
"mode if you continue to use that mode of the pager\n"
|
|
|
|
"under these conditions.\n" "\n"
|
|
|
|
"It is suggested you change the settings on your pager to\n"
|
|
|
|
"disable snapshots to improve performance.\n"
|
|
|
|
"\n"));
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
else
|
2004-01-10 05:40:59 -08:00
|
|
|
DialogOK(_("Warning!"),
|
|
|
|
_("\n"
|
|
|
|
"Your X Server is capable of doing Shared Memory but you do\n"
|
|
|
|
"not have Shared Pixmaps enabled in your Imlib configuration.\n"
|
|
|
|
"\n"
|
|
|
|
"Please enable Shared Pixmaps in your Imlib configuration\n"
|
|
|
|
"then restart Enlightenment to gain better performance for\n"
|
|
|
|
"the pagers when snapshot mode is enabled.\n"
|
|
|
|
"\n"));
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SettingsPager();
|
2004-01-10 05:40:59 -08:00
|
|
|
DialogOK(_("Warning!"),
|
|
|
|
_("\n"
|
|
|
|
"You seem to be running Enlightenment over a network Connection\n"
|
|
|
|
"or on an X Server that does not support Shared Memory, or you\n"
|
|
|
|
"have disabled MIT-SHM Shared memory in your Imlib configuration.\n"
|
|
|
|
"This means the Enlightenment Pager will perform slowly and use\n"
|
|
|
|
"more system resources than it would when Shared Memory is\n"
|
|
|
|
"available.\n" "\n"
|
|
|
|
"To improve performance please either enable MIT-SHM Shared Memory\n"
|
|
|
|
"in your Imlib config, if you disabled it, or disable Pager\n"
|
|
|
|
"snapshots.\n" "\n"));
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-11-15 14:27:17 -08:00
|
|
|
#endif
|
2003-05-22 12:15:03 -07:00
|
|
|
did_dialog = 1;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
p = Emalloc(sizeof(Pager));
|
|
|
|
p->name = NULL;
|
|
|
|
attr.colormap = root.cmap;
|
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
1999-09-21 19:13:51 -07:00
|
|
|
p->w = ((48 * root.w) / root.h) * ax;
|
|
|
|
p->h = 48 * ay;
|
1999-10-01 08:37:41 -07:00
|
|
|
p->dw = ((48 * root.w) / root.h);
|
1999-09-21 19:13:51 -07:00
|
|
|
p->dh = 48;
|
|
|
|
p->win = ECreateWindow(root.win, 0, 0, p->w, p->h, 0);
|
2003-11-15 14:27:17 -08:00
|
|
|
p->pmap = ECreatePixmap(disp, p->win, p->w, p->h, root.depth);
|
|
|
|
p->bgpmap = ECreatePixmap(disp, p->win, p->w / ax, p->h / ay, root.depth);
|
1999-08-17 15:56:46 -07:00
|
|
|
ESetWindowBackgroundPixmap(disp, p->win, p->pmap);
|
2000-06-04 12:45:55 -07:00
|
|
|
XSelectInput(disp, p->win,
|
2003-05-22 12:15:03 -07:00
|
|
|
ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
|
1999-08-17 15:56:46 -07:00
|
|
|
p->hi_win = ECreateWindow(root.win, 0, 0, 3, 3, 0);
|
|
|
|
p->hi_visible = 0;
|
|
|
|
p->hi_ewin = NULL;
|
2000-06-04 12:45:55 -07:00
|
|
|
XSelectInput(disp, p->hi_win,
|
2003-11-30 07:35:43 -08:00
|
|
|
ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask);
|
1999-08-17 15:56:46 -07:00
|
|
|
p->desktop = 0;
|
|
|
|
p->visible = 0;
|
|
|
|
p->update_phase = 0;
|
|
|
|
p->ewin = NULL;
|
|
|
|
p->border_name = NULL;
|
1999-09-21 19:13:51 -07:00
|
|
|
p->sel_win = ECreateWindow(p->win, 0, 0, p->w / ax, p->h / ay, 0);
|
1999-08-17 15:56:46 -07:00
|
|
|
pq = queue_up;
|
|
|
|
queue_up = 0;
|
|
|
|
ic = FindItem("PAGER_SEL", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS);
|
|
|
|
if (ic)
|
1999-10-01 08:37:41 -07:00
|
|
|
IclassApply(ic, p->sel_win, p->w / ax, p->h / ay, 0, 0, STATE_NORMAL, 0);
|
1999-08-17 15:56:46 -07:00
|
|
|
queue_up = pq;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerResize(Pager * p, int w, int h)
|
|
|
|
{
|
1999-08-27 21:46:04 -07:00
|
|
|
int ax, ay, i, cx, cy;
|
1999-08-17 15:56:46 -07:00
|
|
|
char pq;
|
|
|
|
ImageClass *ic;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
|
|
|
if ((w == p->w) && (h == p->h))
|
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
EFreePixmap(disp, p->pmap);
|
|
|
|
EFreePixmap(disp, p->bgpmap);
|
|
|
|
EResizeWindow(disp, p->win, w, h);
|
|
|
|
p->w = w;
|
|
|
|
p->h = h;
|
|
|
|
p->dw = w / ax;
|
|
|
|
p->dh = h / ay;
|
2003-11-15 14:27:17 -08:00
|
|
|
p->pmap = ECreatePixmap(disp, p->win, p->w, p->h, root.depth);
|
|
|
|
p->bgpmap = ECreatePixmap(disp, p->win, p->w / ax, p->h / ay, root.depth);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (p->visible)
|
|
|
|
PagerRedraw(p, 1);
|
|
|
|
ESetWindowBackgroundPixmap(disp, p->win, p->pmap);
|
|
|
|
XClearWindow(disp, p->win);
|
|
|
|
if (p->ewin)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
double aspect;
|
2000-07-26 11:00:47 -07:00
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
aspect = ((double)root.w) / ((double)root.h);
|
|
|
|
p->ewin->client.w_inc = ax * 4;
|
|
|
|
p->ewin->client.h_inc = ay * 8;
|
|
|
|
p->ewin->client.aspect_min = aspect * ((double)ax / (double)ay);
|
|
|
|
p->ewin->client.aspect_max = aspect * ((double)ax / (double)ay);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
pq = queue_up;
|
|
|
|
queue_up = 0;
|
|
|
|
ic = FindItem("PAGER_SEL", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS);
|
|
|
|
if (ic)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
|
|
|
EMoveResizeWindow(disp, p->sel_win, cx * p->dw, cy * p->dh, p->dw,
|
|
|
|
p->dh);
|
|
|
|
IclassApply(ic, p->sel_win, p->dw, p->dh, 0, 0, STATE_NORMAL, 0);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
queue_up = pq;
|
2003-11-30 07:35:43 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
for (i = 0; i < desks.desk[p->desktop].num; i++)
|
|
|
|
PagerEwinUpdateMini(p, desks.desk[p->desktop].list[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerShow(Pager * p)
|
|
|
|
{
|
|
|
|
EWin *ewin = NULL;
|
|
|
|
XClassHint *xch;
|
|
|
|
char s[64];
|
1999-09-16 11:26:02 -07:00
|
|
|
char pq;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
if (p->ewin)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
ShowEwin(p->ewin);
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
Esnprintf(s, sizeof(s), "%i", p->desktop);
|
|
|
|
xch = XAllocClassHint();
|
|
|
|
xch->res_name = s;
|
|
|
|
xch->res_class = "Enlightenment_Pager";
|
|
|
|
XSetClassHint(disp, p->win, xch);
|
|
|
|
XFree(xch);
|
1999-09-16 11:26:02 -07:00
|
|
|
pq = queue_up;
|
|
|
|
queue_up = 0;
|
1999-09-21 19:13:51 -07:00
|
|
|
MatchToSnapInfoPager(p);
|
2003-12-04 08:57:48 -08:00
|
|
|
ewin = AddInternalToFamily(p->win, 1,
|
|
|
|
(p->border_name) ? p->border_name : "PAGER",
|
|
|
|
EWIN_TYPE_PAGER, p);
|
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
|
|
|
char s[4096];
|
2003-12-21 04:08:01 -08:00
|
|
|
int ax, ay;
|
2003-05-22 12:15:03 -07:00
|
|
|
Snapshot *sn;
|
|
|
|
double aspect;
|
|
|
|
|
|
|
|
aspect = ((double)root.w) / ((double)root.h);
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
ewin->client.aspect_min = aspect * ((double)ax / (double)ay);
|
|
|
|
ewin->client.aspect_max = aspect * ((double)ax / (double)ay);
|
|
|
|
ewin->client.w_inc = ax * 4;
|
|
|
|
ewin->client.h_inc = ay * 8;
|
|
|
|
ewin->client.width.min = 10 * ax;
|
|
|
|
ewin->client.height.min = 8 * ay;
|
|
|
|
ewin->client.width.max = 320 * ax;
|
|
|
|
ewin->client.height.max = 240 * ay;
|
|
|
|
ewin->pager = p;
|
|
|
|
p->ewin = ewin;
|
|
|
|
p->visible = 1;
|
|
|
|
sn = FindSnapshot(ewin);
|
|
|
|
/* get the size right damnit! */
|
|
|
|
if (sn)
|
|
|
|
{
|
2003-12-21 04:08:01 -08:00
|
|
|
ResizeEwin(ewin, ewin->client.w, ewin->client.h);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-12-21 04:08:01 -08:00
|
|
|
/* no snapshots ? first time ? make a row on the bottom left up */
|
2003-12-21 04:28:10 -08:00
|
|
|
MoveResizeEwin(ewin, 0,
|
2004-01-12 12:43:18 -08:00
|
|
|
root.h - (conf.desks.numdesktops -
|
|
|
|
p->desktop) * ewin->h, ewin->client.w,
|
|
|
|
ewin->client.h);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-21 04:08:01 -08:00
|
|
|
PagerRedraw(p, 1);
|
2003-05-22 12:15:03 -07:00
|
|
|
/* show the pager ewin */
|
|
|
|
ShowEwin(ewin);
|
|
|
|
if (((sn) && (sn->use_sticky) && (sn->sticky)) || (!sn))
|
|
|
|
MakeWindowSticky(ewin);
|
|
|
|
RememberImportantInfoForEwin(ewin);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.pagers.snap)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-09 12:25:17 -08:00
|
|
|
Esnprintf(s, sizeof(s), "__.%x", (unsigned)p->win);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.pagers.scanspeed > 0)
|
|
|
|
DoIn(s, 1 / ((double)conf.pagers.scanspeed), PagerUpdateTimeout,
|
2003-05-22 12:15:03 -07:00
|
|
|
0, p);
|
|
|
|
}
|
|
|
|
AddItem(p, "PAGER", p->win, LIST_TYPE_PAGER);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-09-28 12:21:34 -07:00
|
|
|
|
|
|
|
queue_up = pq;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-11-30 07:35:43 -08:00
|
|
|
PagerDestroy(Pager * p)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
char s[4096];
|
|
|
|
|
|
|
|
RemoveItem("PAGER", p->win, LIST_FINDBY_ID, LIST_TYPE_PAGER);
|
2003-12-09 12:25:17 -08:00
|
|
|
Esnprintf(s, sizeof(s), "__.%x", (unsigned)p->win);
|
1999-08-17 15:56:46 -07:00
|
|
|
RemoveTimerEvent(s);
|
|
|
|
if (p->name)
|
|
|
|
Efree(p->name);
|
|
|
|
EDestroyWindow(disp, p->win);
|
|
|
|
if (p->hi_win)
|
|
|
|
EDestroyWindow(disp, p->hi_win);
|
1999-08-27 21:46:04 -07:00
|
|
|
if (p->pmap)
|
|
|
|
EFreePixmap(disp, p->pmap);
|
|
|
|
if (p->bgpmap)
|
|
|
|
EFreePixmap(disp, p->bgpmap);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (p->border_name)
|
|
|
|
Efree(p->border_name);
|
|
|
|
Efree(p);
|
|
|
|
}
|
|
|
|
|
2004-01-18 02:24:06 -08:00
|
|
|
void
|
|
|
|
PagerOnUnmap(Pager * p)
|
|
|
|
{
|
|
|
|
PagerHideHi(p);
|
|
|
|
if (p == mode.context_pager)
|
|
|
|
{
|
|
|
|
mode.context_pager = NULL;
|
|
|
|
mode.mode = MODE_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
Pager **
|
|
|
|
PagersForDesktop(int d, int *num)
|
|
|
|
{
|
|
|
|
Pager **pp = NULL;
|
|
|
|
Pager **pl = NULL;
|
|
|
|
int i, pnum;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return NULL;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
*num = 0;
|
|
|
|
pl = (Pager **) ListItemType(&pnum, LIST_TYPE_PAGER);
|
|
|
|
if (pl)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < pnum; i++)
|
|
|
|
{
|
|
|
|
if (pl[i]->desktop == d)
|
|
|
|
{
|
|
|
|
(*num)++;
|
|
|
|
pp = Erealloc(pp, sizeof(Pager *) * (*num));
|
|
|
|
pp[(*num) - 1] = pl[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(pl);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
return pp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RedrawPagersForDesktop(int d, char newbg)
|
|
|
|
{
|
|
|
|
Pager **pl;
|
|
|
|
int i, num;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
pl = PagersForDesktop(d, &num);
|
|
|
|
if (pl)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
PagerRedraw(pl[i], newbg);
|
|
|
|
Efree(pl);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ForceUpdatePagersForDesktop(int d)
|
|
|
|
{
|
|
|
|
Pager **pl;
|
|
|
|
int i, num;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
pl = PagersForDesktop(d, &num);
|
|
|
|
if (pl)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
PagerForceUpdate(pl[i]);
|
|
|
|
Efree(pl);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
static void
|
|
|
|
PagerUpdateHiWin(Pager * p, EWin * ewin)
|
|
|
|
{
|
|
|
|
Imlib_Image *im;
|
|
|
|
|
|
|
|
if (!p->hi_visible || !ewin->mini_pmm.pmap)
|
|
|
|
return;
|
|
|
|
|
|
|
|
imlib_context_set_drawable(ewin->mini_pmm.pmap);
|
|
|
|
im = imlib_create_image_from_drawable(0, 0, 0,
|
|
|
|
ewin->mini_w, ewin->mini_h, 0);
|
|
|
|
imlib_context_set_image(im);
|
|
|
|
imlib_context_set_drawable(p->hi_win);
|
|
|
|
imlib_render_image_on_drawable_at_size(0, 0, p->hi_win_w, p->hi_win_h);
|
|
|
|
imlib_free_image_and_decache();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-08-17 15:56:46 -07:00
|
|
|
PagerEwinUpdateMini(Pager * p, EWin * ewin)
|
|
|
|
{
|
|
|
|
int w, h, ax, ay, cx, cy;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
|
|
|
|
|
|
|
w = ((ewin->w) * (p->w / ax)) / root.w;
|
|
|
|
h = ((ewin->h) * (p->h / ay)) / root.h;
|
|
|
|
|
|
|
|
if (w < 1)
|
|
|
|
w = 1;
|
|
|
|
if (h < 1)
|
|
|
|
h = 1;
|
|
|
|
if ((ewin->mini_w != w) || (ewin->mini_h != h))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-11-15 14:27:17 -08:00
|
|
|
FreePmapMask(&ewin->mini_pmm);
|
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
ewin->mini_w = w;
|
|
|
|
ewin->mini_h = h;
|
|
|
|
|
|
|
|
if ((ewin->desktop != desks.current) || (ewin->area_x != cx)
|
2004-01-12 12:43:18 -08:00
|
|
|
|| (ewin->area_y != cy) || (!conf.pagers.snap))
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
|
|
|
ImageClass *ic = NULL;
|
|
|
|
|
|
|
|
ic = FindItem("PAGER_WIN", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS);
|
|
|
|
if (ic)
|
|
|
|
IclassApplyCopy(ic, ewin->win, w, h, 0, 0, STATE_NORMAL,
|
2003-11-15 14:27:17 -08:00
|
|
|
&ewin->mini_pmm, 1);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-15 14:27:17 -08:00
|
|
|
ewin->mini_pmm.type = 0;
|
|
|
|
ewin->mini_pmm.pmap =
|
|
|
|
ECreatePixmap(disp, p->win, w, h, root.depth);
|
2003-11-30 07:35:43 -08:00
|
|
|
ScaleRect(ewin->mini_pmm.pmap, ewin->win, 0, 0, 0, 0, ewin->w,
|
|
|
|
ewin->h, w, h);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-15 14:27:17 -08:00
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
if (ewin == p->hi_ewin)
|
|
|
|
PagerUpdateHiWin(p, ewin);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
static void
|
1999-08-17 15:56:46 -07:00
|
|
|
PagerEwinUpdateFromPager(Pager * p, EWin * ewin)
|
|
|
|
{
|
|
|
|
int x, y, w, h, ax, ay, cx, cy;
|
|
|
|
static GC gc = 0;
|
|
|
|
XGCValues gcv;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.snap)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
PagerEwinUpdateMini(p, ewin);
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
|
|
|
x = ((ewin->x + (cx * root.w)) * (p->w / ax)) / root.w;
|
|
|
|
y = ((ewin->y + (cy * root.h)) * (p->h / ay)) / root.h;
|
|
|
|
w = ((ewin->w) * (p->w / ax)) / root.w;
|
|
|
|
h = ((ewin->h) * (p->h / ay)) / root.h;
|
|
|
|
if (!gc)
|
|
|
|
gc = XCreateGC(disp, p->pmap, 0, &gcv);
|
2003-11-15 14:27:17 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
if ((ewin->mini_w != w) || (ewin->mini_h != h))
|
2003-11-15 14:27:17 -08:00
|
|
|
FreePmapMask(&ewin->mini_pmm);
|
|
|
|
|
|
|
|
if (!ewin->mini_pmm.pmap)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
ewin->mini_w = w;
|
|
|
|
ewin->mini_h = h;
|
2003-11-15 14:27:17 -08:00
|
|
|
ewin->mini_pmm.type = 0;
|
|
|
|
ewin->mini_pmm.pmap = ECreatePixmap(disp, p->win, w, h, root.depth);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-15 14:27:17 -08:00
|
|
|
XCopyArea(disp, p->pmap, ewin->mini_pmm.pmap, gc, x, y, w, h, 0, 0);
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
if (ewin == p->hi_ewin)
|
|
|
|
PagerUpdateHiWin(p, ewin);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerRedraw(Pager * p, char newbg)
|
|
|
|
{
|
|
|
|
int i, x, y, ax, ay, cx, cy;
|
1999-08-27 21:46:04 -07:00
|
|
|
GC gc;
|
1999-08-17 15:56:46 -07:00
|
|
|
XGCValues gcv;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable || mode.mode == MODE_DESKSWITCH)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-09-28 12:21:34 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
if (queue_up)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
DrawQueue *dq;
|
|
|
|
|
|
|
|
dq = Emalloc(sizeof(DrawQueue));
|
|
|
|
dq->win = p->win;
|
|
|
|
dq->iclass = NULL;
|
|
|
|
dq->w = p->w;
|
|
|
|
dq->h = p->h;
|
|
|
|
dq->active = 0;
|
|
|
|
dq->sticky = 0;
|
|
|
|
dq->state = 0;
|
|
|
|
dq->expose = 0;
|
|
|
|
dq->tclass = NULL;
|
|
|
|
dq->text = NULL;
|
|
|
|
dq->shape_propagate = 0;
|
|
|
|
dq->pager = NULL;
|
|
|
|
dq->redraw_pager = p;
|
|
|
|
dq->newbg = newbg;
|
|
|
|
dq->d = NULL;
|
|
|
|
dq->di = NULL;
|
|
|
|
dq->x = 0;
|
|
|
|
dq->y = 0;
|
|
|
|
AddItem(dq, "DRAW", dq->win, LIST_TYPE_DRAW);
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
p->update_phase = 0;
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
1999-08-27 21:46:04 -07:00
|
|
|
gc = XCreateGC(disp, p->pmap, 0, &gcv);
|
1999-11-08 10:36:09 -08:00
|
|
|
if (gc)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if ((newbg > 0) && (newbg < 3))
|
|
|
|
{
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.snap)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
|
|
|
ImageClass *ic = NULL;
|
2003-11-15 14:27:17 -08:00
|
|
|
PmapMask pmm;
|
2003-05-22 12:15:03 -07:00
|
|
|
|
|
|
|
EFreePixmap(disp, p->bgpmap);
|
|
|
|
ic = FindItem("PAGER_BACKGROUND", 0, LIST_FINDBY_NAME,
|
|
|
|
LIST_TYPE_ICLASS);
|
|
|
|
if (ic)
|
|
|
|
IclassApplyCopy(ic, p->win, p->w / ax, p->h / ay, 0, 0,
|
2003-11-15 14:27:17 -08:00
|
|
|
STATE_NORMAL, &pmm, 0);
|
|
|
|
p->bgpmap = pmm.pmap;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (desks.desk[p->desktop].bg)
|
|
|
|
{
|
|
|
|
char s[4096];
|
|
|
|
char *uniq;
|
2003-11-15 14:27:17 -08:00
|
|
|
Imlib_Image *im;
|
|
|
|
Pixmap mask;
|
2003-05-22 12:15:03 -07:00
|
|
|
|
|
|
|
uniq = GetUniqueBGString(desks.desk[p->desktop].bg);
|
|
|
|
Esnprintf(s, sizeof(s), "%s/cached/pager/%s.%i.%i.%s",
|
|
|
|
UserCacheDir(),
|
|
|
|
desks.desk[p->desktop].bg->name, (p->w / ax),
|
|
|
|
(p->h / ay), uniq);
|
|
|
|
Efree(uniq);
|
|
|
|
|
2003-11-15 14:27:17 -08:00
|
|
|
im = imlib_load_image(s);
|
2003-05-22 12:15:03 -07:00
|
|
|
if (im)
|
|
|
|
{
|
|
|
|
EFreePixmap(disp, p->bgpmap);
|
2003-11-15 14:27:17 -08:00
|
|
|
imlib_context_set_image(im);
|
|
|
|
imlib_render_pixmaps_for_whole_image_at_size(&p->
|
|
|
|
bgpmap,
|
|
|
|
&mask,
|
|
|
|
(p->w /
|
|
|
|
ax),
|
|
|
|
(p->h /
|
|
|
|
ay));
|
|
|
|
imlib_free_image();
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-15 14:27:17 -08:00
|
|
|
SetBackgroundTo(p->bgpmap,
|
2003-05-22 12:15:03 -07:00
|
|
|
desks.desk[p->desktop].bg, 0);
|
2003-11-15 14:27:17 -08:00
|
|
|
imlib_context_set_drawable(p->bgpmap);
|
2003-07-12 08:04:32 -07:00
|
|
|
im =
|
2003-11-15 14:27:17 -08:00
|
|
|
imlib_create_image_from_drawable(0, 0, 0,
|
|
|
|
(p->w / ax),
|
|
|
|
(p->h / ay), 0);
|
|
|
|
imlib_context_set_image(im);
|
|
|
|
imlib_image_set_format("ppm");
|
|
|
|
imlib_save_image(s);
|
|
|
|
imlib_free_image_and_decache();
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-15 14:27:17 -08:00
|
|
|
XSetForeground(disp, gc, BlackPixel(disp, root.scr));
|
2003-05-22 12:15:03 -07:00
|
|
|
XDrawRectangle(disp, p->bgpmap, gc, 0, 0, p->dw, p->dh);
|
2003-11-15 14:27:17 -08:00
|
|
|
XSetForeground(disp, gc, WhitePixel(disp, root.scr));
|
2003-05-22 12:15:03 -07:00
|
|
|
XFillRectangle(disp, p->bgpmap, gc, 1, 1, p->dw - 2,
|
|
|
|
p->dh - 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
for (y = 0; y < ay; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < ax; x++)
|
|
|
|
XCopyArea(disp, p->bgpmap, p->pmap, gc, 0, 0, p->w / ax,
|
|
|
|
p->h / ay, x * (p->w / ax), y * (p->h / ay));
|
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = desks.desk[p->desktop].num - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
EWin *ewin;
|
|
|
|
int wx, wy, ww, wh;
|
|
|
|
|
|
|
|
ewin = desks.desk[p->desktop].list[i];
|
2003-12-14 09:24:34 -08:00
|
|
|
if (!ewin->iconified && ewin->visible)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
|
|
|
wx = ((ewin->x + (cx * root.w)) * (p->w / ax)) / root.w;
|
|
|
|
wy = ((ewin->y + (cy * root.h)) * (p->h / ay)) / root.h;
|
|
|
|
ww = ((ewin->w) * (p->w / ax)) / root.w;
|
|
|
|
wh = ((ewin->h) * (p->h / ay)) / root.h;
|
|
|
|
PagerEwinUpdateMini(p, ewin);
|
2003-11-15 14:27:17 -08:00
|
|
|
if (ewin->mini_pmm.pmap)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-11-15 14:27:17 -08:00
|
|
|
if (ewin->mini_pmm.mask)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-11-15 14:27:17 -08:00
|
|
|
XSetClipMask(disp, gc, ewin->mini_pmm.mask);
|
2003-05-22 12:15:03 -07:00
|
|
|
XSetClipOrigin(disp, gc, wx, wy);
|
|
|
|
}
|
2003-11-15 14:27:17 -08:00
|
|
|
XCopyArea(disp, ewin->mini_pmm.pmap, p->pmap, gc, 0, 0,
|
|
|
|
ww, wh, wx, wy);
|
|
|
|
if (ewin->mini_pmm.mask)
|
2003-05-22 12:15:03 -07:00
|
|
|
XSetClipMask(disp, gc, None);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-15 14:27:17 -08:00
|
|
|
XSetForeground(disp, gc, BlackPixel(disp, root.scr));
|
2003-05-22 12:15:03 -07:00
|
|
|
XDrawRectangle(disp, p->pmap, gc, wx - 1, wy - 1, ww + 1,
|
|
|
|
wh + 1);
|
2003-11-15 14:27:17 -08:00
|
|
|
XSetForeground(disp, gc, WhitePixel(disp, root.scr));
|
2003-05-22 12:15:03 -07:00
|
|
|
XFillRectangle(disp, p->pmap, gc, wx, wy, ww, wh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
if (newbg < 2)
|
|
|
|
{
|
|
|
|
ESetWindowBackgroundPixmap(disp, p->win, p->pmap);
|
|
|
|
XClearWindow(disp, p->win);
|
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
XFreeGC(disp, gc);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerForceUpdate(Pager * p)
|
|
|
|
{
|
|
|
|
int ww, hh, xx, yy, ax, ay, cx, cy, i;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable || mode.mode == MODE_DESKSWITCH)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-09-28 12:21:34 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
if (queue_up)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
DrawQueue *dq;
|
|
|
|
|
|
|
|
dq = Emalloc(sizeof(DrawQueue));
|
|
|
|
dq->win = p->win;
|
|
|
|
dq->iclass = NULL;
|
|
|
|
dq->w = p->w;
|
|
|
|
dq->h = p->h;
|
|
|
|
dq->active = 0;
|
|
|
|
dq->sticky = 0;
|
|
|
|
dq->state = 0;
|
|
|
|
dq->expose = 0;
|
|
|
|
dq->tclass = NULL;
|
|
|
|
dq->text = NULL;
|
|
|
|
dq->shape_propagate = 0;
|
|
|
|
dq->pager = p;
|
|
|
|
dq->redraw_pager = NULL;
|
|
|
|
dq->d = NULL;
|
|
|
|
dq->di = NULL;
|
|
|
|
dq->x = 0;
|
|
|
|
dq->y = 0;
|
|
|
|
AddItem(dq, "DRAW", dq->win, LIST_TYPE_DRAW);
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if ((p->desktop != desks.current) || (!conf.pagers.snap))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
PagerRedraw(p, 0);
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
p->update_phase = 0;
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
|
|
|
ww = p->w / ax;
|
|
|
|
hh = p->h / ay;
|
|
|
|
xx = cx * ww;
|
|
|
|
yy = cy * hh;
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
ScaleRect(p->pmap, root.win, 0, 0, xx, yy, root.w, root.h, ww, hh);
|
1999-08-17 15:56:46 -07:00
|
|
|
XClearWindow(disp, p->win);
|
|
|
|
|
|
|
|
for (i = 0; i < desks.desk[p->desktop].num; i++)
|
|
|
|
PagerEwinUpdateFromPager(p, desks.desk[p->desktop].list[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerReArea(void)
|
|
|
|
{
|
|
|
|
Pager **pl = NULL;
|
|
|
|
int i, pnum, w, h, ax, ay;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
pl = (Pager **) ListItemType(&pnum, LIST_TYPE_PAGER);
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
if (pl)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < pnum; i++)
|
|
|
|
{
|
|
|
|
w = pl[i]->dw * ax;
|
|
|
|
h = pl[i]->dh * ay;
|
|
|
|
if (pl[i]->ewin)
|
|
|
|
{
|
|
|
|
double aspect;
|
|
|
|
|
|
|
|
aspect = ((double)root.w) / ((double)root.h);
|
|
|
|
pl[i]->ewin->client.w_inc = ax * 4;
|
|
|
|
pl[i]->ewin->client.h_inc = ay * 8;
|
|
|
|
pl[i]->ewin->client.aspect_min =
|
|
|
|
aspect * ((double)ax / (double)ay);
|
|
|
|
pl[i]->ewin->client.aspect_max =
|
|
|
|
aspect * ((double)ax / (double)ay);
|
|
|
|
MoveResizeEwin(pl[i]->ewin, pl[i]->ewin->x, pl[i]->ewin->y, w,
|
|
|
|
h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(pl);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerEwinOutsideAreaUpdate(EWin * ewin)
|
|
|
|
{
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
if (ewin->sticky)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
int i;
|
2000-07-26 11:00:47 -07:00
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
for (i = 0; i < conf.desks.numdesktops; i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
RedrawPagersForDesktop(i, 0);
|
|
|
|
ForceUpdatePagersForDesktop(ewin->desktop);
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else if (ewin->desktop != desks.current)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
RedrawPagersForDesktop(ewin->desktop, 0);
|
|
|
|
ForceUpdatePagersForDesktop(ewin->desktop);
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2000-06-04 12:45:55 -07:00
|
|
|
if ((ewin->x < 0) || (ewin->y < 0) || ((ewin->x + ewin->w) > root.w)
|
|
|
|
|| ((ewin->y + ewin->h) > root.h))
|
1999-08-17 15:56:46 -07:00
|
|
|
RedrawPagersForDesktop(ewin->desktop, 3);
|
|
|
|
ForceUpdatePagersForDesktop(ewin->desktop);
|
|
|
|
}
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
static EWin *
|
1999-08-17 15:56:46 -07:00
|
|
|
EwinInPagerAt(Pager * p, int x, int y)
|
|
|
|
{
|
|
|
|
int i, wx, wy, ww, wh, ax, ay, cx, cy;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return NULL;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
|
|
|
for (i = 0; i < desks.desk[p->desktop].num; i++)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
EWin *ewin;
|
|
|
|
|
|
|
|
ewin = desks.desk[p->desktop].list[i];
|
|
|
|
if ((ewin->visible) && (!ewin->iconified))
|
|
|
|
{
|
|
|
|
wx = ((ewin->x + (cx * root.w)) * (p->w / ax)) / root.w;
|
|
|
|
wy = ((ewin->y + (cy * root.h)) * (p->h / ay)) / root.h;
|
|
|
|
ww = ((ewin->w) * (p->w / ax)) / root.w;
|
|
|
|
wh = ((ewin->h) * (p->h / ay)) / root.h;
|
|
|
|
if ((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh)))
|
|
|
|
return ewin;
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
static void
|
1999-08-17 15:56:46 -07:00
|
|
|
PagerAreaAt(Pager * p, int x, int y, int *ax, int *ay)
|
|
|
|
{
|
|
|
|
int asx, asy;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
GetAreaSize(&asx, &asy);
|
|
|
|
*ax = x / (p->w / asx);
|
|
|
|
*ay = y / (p->h / asy);
|
|
|
|
}
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
static void
|
2003-12-14 09:24:34 -08:00
|
|
|
PagerMenuShow(Pager * p, int x, int y)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
static Menu *p_menu = NULL, *pw_menu = NULL;
|
|
|
|
MenuItem *mi;
|
|
|
|
EWin *ewin;
|
|
|
|
int ax, ay;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
ewin = EwinInPagerAt(p, x, y);
|
|
|
|
if (ewin)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if (pw_menu)
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuDestroy(pw_menu);
|
2004-01-21 14:14:11 -08:00
|
|
|
|
|
|
|
SetContextEwin(ewin);
|
|
|
|
|
2003-12-14 09:24:34 -08:00
|
|
|
pw_menu = MenuCreate("__DESK_WIN_MENU");
|
|
|
|
MenuAddTitle(pw_menu, _("Window Options"));
|
|
|
|
MenuAddStyle(pw_menu, "DEFAULT");
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2004-01-21 14:14:11 -08:00
|
|
|
mi = MenuItemCreate(_("Iconify"), NULL, ACTION_ICONIFY, NULL, NULL);
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuAddItem(pw_menu, mi);
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2004-01-21 14:14:11 -08:00
|
|
|
mi = MenuItemCreate(_("Close"), NULL, ACTION_KILL, NULL, NULL);
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuAddItem(pw_menu, mi);
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2004-01-21 14:14:11 -08:00
|
|
|
mi =
|
|
|
|
MenuItemCreate(_("Annihilate"), NULL, ACTION_KILL_NASTY, NULL, NULL);
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuAddItem(pw_menu, mi);
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2004-01-21 14:14:11 -08:00
|
|
|
mi =
|
|
|
|
MenuItemCreate(_("Stick / Unstick"), NULL, ACTION_STICK, NULL, NULL);
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuAddItem(pw_menu, mi);
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2004-01-18 02:24:06 -08:00
|
|
|
ActionsCall(ACTION_SHOW_MENU, NULL, "named __DESK_WIN_MENU");
|
2003-05-22 12:15:03 -07:00
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
PagerAreaAt(p, x, y, &ax, &ay);
|
|
|
|
if (p_menu)
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuDestroy(p_menu);
|
|
|
|
p_menu = MenuCreate("__DESK_MENU");
|
|
|
|
MenuAddTitle(p_menu, _("Desktop Options"));
|
|
|
|
MenuAddStyle(p_menu, "DEFAULT");
|
|
|
|
|
|
|
|
mi = MenuItemCreate(_("Pager Settings..."), NULL, ACTION_CONFIG, "pager",
|
2003-05-22 12:15:03 -07:00
|
|
|
NULL);
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuAddItem(p_menu, mi);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-12-14 09:24:34 -08:00
|
|
|
mi = MenuItemCreate(_("Snapshotting On"), NULL, ACTION_SET_PAGER_SNAP, "1",
|
2003-05-22 12:15:03 -07:00
|
|
|
NULL);
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuAddItem(p_menu, mi);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-12-14 09:24:34 -08:00
|
|
|
mi = MenuItemCreate(_("Snapshotting Off"), NULL, ACTION_SET_PAGER_SNAP, "0",
|
2003-05-22 12:15:03 -07:00
|
|
|
NULL);
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuAddItem(p_menu, mi);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.pagers.snap)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-12-14 09:24:34 -08:00
|
|
|
mi = MenuItemCreate(_("High Quality On"), NULL, ACTION_SET_PAGER_HIQ,
|
2003-05-22 12:15:03 -07:00
|
|
|
"1", NULL);
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuAddItem(p_menu, mi);
|
2003-03-27 21:16:21 -08:00
|
|
|
|
2003-12-14 09:24:34 -08:00
|
|
|
mi = MenuItemCreate(_("High Quality Off"), NULL, ACTION_SET_PAGER_HIQ,
|
2003-05-22 12:15:03 -07:00
|
|
|
"0", NULL);
|
2003-12-14 09:24:34 -08:00
|
|
|
MenuAddItem(p_menu, mi);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-12-14 09:24:34 -08:00
|
|
|
|
2004-01-18 02:24:06 -08:00
|
|
|
ActionsCall(ACTION_SHOW_MENU, NULL, "named __DESK_MENU");
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerHide(Pager * p)
|
|
|
|
{
|
|
|
|
if (p->ewin)
|
|
|
|
HideEwin(p->ewin);
|
|
|
|
}
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
static void
|
1999-08-17 15:56:46 -07:00
|
|
|
PagerTitle(Pager * p, char *title)
|
|
|
|
{
|
|
|
|
XTextProperty xtp;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
xtp.encoding = XA_STRING;
|
|
|
|
xtp.format = 8;
|
|
|
|
xtp.value = (unsigned char *)(title);
|
|
|
|
xtp.nitems = strlen((char *)(xtp.value));
|
|
|
|
XSetWMName(disp, p->win, &xtp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UpdatePagerSel(void)
|
|
|
|
{
|
|
|
|
Pager **pl;
|
|
|
|
Pager *p;
|
|
|
|
int i, pnum, cx, cy;
|
1999-10-01 08:37:41 -07:00
|
|
|
ImageClass *ic;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
pl = (Pager **) ListItemType(&pnum, LIST_TYPE_PAGER);
|
|
|
|
if (pl)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < pnum; i++)
|
|
|
|
{
|
|
|
|
p = pl[i];
|
|
|
|
if (p->desktop != desks.current)
|
|
|
|
EUnmapWindow(disp, p->sel_win);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
|
|
|
EMoveWindow(disp, p->sel_win, cx * p->dw, cy * p->dh);
|
|
|
|
EMapWindow(disp, p->sel_win);
|
|
|
|
ic = FindItem("PAGER_SEL", 0, LIST_FINDBY_NAME,
|
|
|
|
LIST_TYPE_ICLASS);
|
|
|
|
if (ic)
|
|
|
|
IclassApply(ic, p->sel_win, p->dw, p->dh, 0, 0,
|
|
|
|
STATE_NORMAL, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(pl);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
static void
|
|
|
|
PagerShowTt(EWin * ewin)
|
|
|
|
{
|
|
|
|
static EWin *tt_ewin = NULL;
|
|
|
|
ToolTip *tt;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.title || (ewin == tt_ewin))
|
2003-11-30 07:35:43 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (mode.cur_menu_depth) /* Don't show Tooltip when menu is up */
|
|
|
|
return;
|
|
|
|
|
|
|
|
tt = FindItem("PAGER", 0, LIST_FINDBY_NAME, LIST_TYPE_TOOLTIP);
|
|
|
|
if (tt)
|
|
|
|
{
|
|
|
|
if (ewin)
|
|
|
|
ShowToolTip(tt, ewin->client.title, NULL, mode.x, mode.y);
|
|
|
|
else
|
|
|
|
HideToolTip(tt);
|
|
|
|
}
|
|
|
|
|
|
|
|
tt_ewin = ewin;
|
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
|
|
|
PagerHideAllHi(void)
|
|
|
|
{
|
|
|
|
Pager **pl = NULL;
|
|
|
|
int i, pnum;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
pl = (Pager **) ListItemType(&pnum, LIST_TYPE_PAGER);
|
|
|
|
if (pl)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < pnum; i++)
|
|
|
|
PagerHideHi(pl[i]);
|
|
|
|
Efree(pl);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerHideHi(Pager * p)
|
|
|
|
{
|
|
|
|
if (p->hi_visible)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
p->hi_visible = 0;
|
|
|
|
EUnmapWindow(disp, p->hi_win);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
p->hi_ewin = NULL;
|
|
|
|
|
|
|
|
PagerShowTt(NULL);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
static void
|
1999-08-17 15:56:46 -07:00
|
|
|
PagerShowHi(Pager * p, EWin * ewin, int x, int y, int w, int h)
|
|
|
|
{
|
2003-09-28 12:21:34 -07:00
|
|
|
char pq;
|
1999-08-17 15:56:46 -07:00
|
|
|
ImageClass *ic = NULL;
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
if (mode.cur_menu_depth) /* Don't show HiWin when menu is up */
|
|
|
|
return;
|
|
|
|
|
2003-09-28 12:21:34 -07:00
|
|
|
pq = queue_up;
|
|
|
|
|
2003-12-04 08:57:48 -08:00
|
|
|
p->hi_win_w = 2 * w;
|
|
|
|
p->hi_win_h = 2 * h;
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2003-12-04 08:57:48 -08:00
|
|
|
ic = FindItem("PAGER_WIN", 0, LIST_FINDBY_NAME, LIST_TYPE_ICLASS);
|
|
|
|
EMoveResizeWindow(disp, p->hi_win, x, y, w, h);
|
|
|
|
EMapRaised(disp, p->hi_win);
|
|
|
|
if (ewin->mini_pmm.pmap)
|
|
|
|
{
|
|
|
|
Imlib_Image *im;
|
|
|
|
Pixmap pmap, mask;
|
|
|
|
int xx, yy, ww, hh, i;
|
|
|
|
|
|
|
|
imlib_context_set_drawable(ewin->mini_pmm.pmap);
|
|
|
|
im = imlib_create_image_from_drawable(0, 0, 0, ewin->mini_w,
|
|
|
|
ewin->mini_h, 0);
|
|
|
|
imlib_context_set_image(im);
|
|
|
|
if (w > h)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
for (i = w; i < (w * 2); i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
ww = i;
|
|
|
|
hh = (i * h) / w;
|
|
|
|
xx = x + ((w - ww) / 2);
|
|
|
|
yy = y + ((h - hh) / 2);
|
|
|
|
imlib_render_pixmaps_for_whole_image_at_size(&pmap,
|
|
|
|
&mask, ww, hh);
|
|
|
|
ESetWindowBackgroundPixmap(disp, p->hi_win, pmap);
|
|
|
|
imlib_free_pixmap_and_mask(pmap);
|
|
|
|
EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh);
|
|
|
|
XClearWindow(disp, p->hi_win);
|
|
|
|
{
|
|
|
|
int px, py;
|
|
|
|
|
|
|
|
PointerAt(&px, &py);
|
|
|
|
if ((px < x) || (py < y) || (px >= (x + w))
|
|
|
|
|| (py >= (y + h)))
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
imlib_free_image_and_decache();
|
|
|
|
EUnmapWindow(disp, p->hi_win);
|
|
|
|
goto exit;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = h; i < (h * 2); i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
ww = (i * w) / h;
|
|
|
|
hh = i;
|
|
|
|
xx = x + ((w - ww) / 2);
|
|
|
|
yy = y + ((h - hh) / 2);
|
|
|
|
imlib_render_pixmaps_for_whole_image_at_size(&pmap,
|
|
|
|
&mask, ww, hh);
|
|
|
|
ESetWindowBackgroundPixmap(disp, p->hi_win, pmap);
|
|
|
|
imlib_free_pixmap_and_mask(pmap);
|
|
|
|
EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh);
|
|
|
|
XClearWindow(disp, p->hi_win);
|
|
|
|
{
|
|
|
|
int px, py;
|
|
|
|
|
|
|
|
PointerAt(&px, &py);
|
|
|
|
if ((px < x) || (py < y) || (px >= (x + w))
|
|
|
|
|| (py >= (y + h)))
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
imlib_free_image_and_decache();
|
|
|
|
EUnmapWindow(disp, p->hi_win);
|
|
|
|
goto exit;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
EMoveResizeWindow(disp, p->hi_win, x - (w / 2), y - (h / 2),
|
|
|
|
w * 2, h * 2);
|
|
|
|
imlib_context_set_image(im);
|
|
|
|
imlib_context_set_drawable(p->hi_win);
|
|
|
|
imlib_render_image_on_drawable_at_size(0, 0, p->hi_win_w, p->hi_win_h);
|
|
|
|
imlib_free_image_and_decache();
|
|
|
|
}
|
|
|
|
else if (ic)
|
|
|
|
{
|
|
|
|
int xx, yy, ww, hh, i;
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2003-12-04 08:57:48 -08:00
|
|
|
queue_up = 0;
|
|
|
|
if (w > h)
|
|
|
|
{
|
|
|
|
for (i = w; i < (w * 2); i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
ww = i;
|
|
|
|
hh = (i * h) / w;
|
|
|
|
xx = x + ((w - ww) / 2);
|
|
|
|
yy = y + ((h - hh) / 2);
|
|
|
|
IclassApply(ic, p->hi_win, ww, hh, 0, 0, STATE_NORMAL, 0);
|
|
|
|
EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh);
|
|
|
|
XClearWindow(disp, p->hi_win);
|
|
|
|
{
|
|
|
|
int px, py;
|
|
|
|
|
|
|
|
PointerAt(&px, &py);
|
|
|
|
if ((px < x) || (py < y) || (px >= (x + w))
|
|
|
|
|| (py >= (y + h)))
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
EUnmapWindow(disp, p->hi_win);
|
|
|
|
goto exit;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = h; i < (h * 2); i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
ww = (i * w) / h;
|
|
|
|
hh = i;
|
|
|
|
xx = x + ((w - ww) / 2);
|
|
|
|
yy = y + ((h - hh) / 2);
|
|
|
|
IclassApply(ic, p->hi_win, ww, hh, 0, 0, STATE_NORMAL, 0);
|
|
|
|
EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh);
|
|
|
|
XClearWindow(disp, p->hi_win);
|
|
|
|
{
|
|
|
|
int px, py;
|
|
|
|
|
|
|
|
PointerAt(&px, &py);
|
|
|
|
if ((px < x) || (py < y) || (px >= (x + w))
|
|
|
|
|| (py >= (y + h)))
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
EUnmapWindow(disp, p->hi_win);
|
|
|
|
goto exit;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
EMoveResizeWindow(disp, p->hi_win, x - (w / 2), y - (h / 2), w * 2,
|
|
|
|
h * 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Pixmap pmap;
|
|
|
|
GC gc = 0;
|
|
|
|
XGCValues gcv;
|
|
|
|
int xx, yy, ww, hh, i;
|
|
|
|
|
|
|
|
pmap = ECreatePixmap(disp, p->hi_win, w * 2, h * 2, root.depth);
|
|
|
|
ESetWindowBackgroundPixmap(disp, p->hi_win, pmap);
|
|
|
|
if (!gc)
|
|
|
|
gc = XCreateGC(disp, pmap, 0, &gcv);
|
|
|
|
if (w > h)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
for (i = w; i < (w * 2); i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
ww = i;
|
|
|
|
hh = (i * h) / w;
|
|
|
|
xx = x + ((w - ww) / 2);
|
|
|
|
yy = y + ((h - hh) / 2);
|
|
|
|
XSetForeground(disp, gc, BlackPixel(disp, root.scr));
|
|
|
|
XFillRectangle(disp, pmap, gc, 0, 0, ww, hh);
|
|
|
|
XSetForeground(disp, gc, WhitePixel(disp, root.scr));
|
|
|
|
XFillRectangle(disp, pmap, gc, 1, 1, ww - 2, hh - 2);
|
|
|
|
EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh);
|
|
|
|
XClearWindow(disp, p->hi_win);
|
|
|
|
{
|
|
|
|
int px, py;
|
|
|
|
|
|
|
|
PointerAt(&px, &py);
|
|
|
|
if ((px < x) || (py < y) || (px >= (x + w))
|
|
|
|
|| (py >= (y + h)))
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
EFreePixmap(disp, pmap);
|
|
|
|
EUnmapWindow(disp, p->hi_win);
|
|
|
|
goto exit;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = h; i < (h * 2); i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
ww = (i * w) / h;
|
|
|
|
hh = i;
|
|
|
|
xx = x + ((w - ww) / 2);
|
|
|
|
yy = y + ((h - hh) / 2);
|
|
|
|
XSetForeground(disp, gc, BlackPixel(disp, root.scr));
|
|
|
|
XFillRectangle(disp, pmap, gc, 0, 0, ww, hh);
|
|
|
|
XSetForeground(disp, gc, WhitePixel(disp, root.scr));
|
|
|
|
XFillRectangle(disp, pmap, gc, 1, 1, ww - 2, hh - 2);
|
|
|
|
EMoveResizeWindow(disp, p->hi_win, xx, yy, ww, hh);
|
|
|
|
XClearWindow(disp, p->hi_win);
|
|
|
|
{
|
|
|
|
int px, py;
|
|
|
|
|
|
|
|
PointerAt(&px, &py);
|
|
|
|
if ((px < x) || (py < y) || (px >= (x + w))
|
|
|
|
|| (py >= (y + h)))
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-04 08:57:48 -08:00
|
|
|
EFreePixmap(disp, pmap);
|
|
|
|
EUnmapWindow(disp, p->hi_win);
|
|
|
|
goto exit;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
EFreePixmap(disp, pmap);
|
|
|
|
EMoveResizeWindow(disp, p->hi_win, x - (w / 2), y - (h / 2), w * 2,
|
|
|
|
h * 2);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-12-04 08:57:48 -08:00
|
|
|
p->hi_visible = 1;
|
|
|
|
p->hi_ewin = ewin;
|
|
|
|
|
2003-09-28 12:21:34 -07:00
|
|
|
exit:
|
|
|
|
queue_up = pq;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
static void
|
|
|
|
PagerHandleMotion(Pager * p, Window win, int x, int y, int in)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
int hx, hy;
|
2003-11-30 07:35:43 -08:00
|
|
|
Window rw, cw;
|
1999-08-17 15:56:46 -07:00
|
|
|
EWin *ewin = NULL;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
2003-11-08 15:57:49 -08:00
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
XQueryPointer(disp, p->win, &rw, &cw, &hx, &hy, &x, &y, &hx);
|
2003-11-30 07:35:43 -08:00
|
|
|
|
|
|
|
if (x >= 0 && x < p->w && y >= 0 && y < p->h)
|
|
|
|
ewin = EwinInPagerAt(p, x, y);
|
|
|
|
else
|
|
|
|
ewin = NULL;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.zoom)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-11-30 07:35:43 -08:00
|
|
|
if (in == PAGER_EVENT_MOUSE_OUT)
|
|
|
|
PagerShowTt(NULL);
|
2003-12-13 06:07:14 -08:00
|
|
|
else
|
|
|
|
PagerShowTt(ewin);
|
2003-05-22 12:15:03 -07:00
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
|
|
|
if (ewin == NULL)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-11-30 07:35:43 -08:00
|
|
|
PagerHideHi(p);
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
|
|
|
if (in == PAGER_EVENT_MOUSE_OUT)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-12-13 06:07:14 -08:00
|
|
|
PagerShowTt(NULL);
|
2003-11-30 07:35:43 -08:00
|
|
|
}
|
2003-12-13 06:07:14 -08:00
|
|
|
else if ((in == PAGER_EVENT_MOTION) && ewin != p->hi_ewin)
|
2003-11-30 07:35:43 -08:00
|
|
|
{
|
2003-12-13 06:07:14 -08:00
|
|
|
int wx, wy, ww, wh, ax, ay, cx, cy, px, py;
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
PagerHideHi(p);
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
|
|
|
wx = ((ewin->x + (cx * root.w)) * (p->w / ax)) / root.w;
|
|
|
|
wy = ((ewin->y + (cy * root.h)) * (p->h / ay)) / root.h;
|
|
|
|
ww = ((ewin->w) * (p->w / ax)) / root.w;
|
|
|
|
wh = ((ewin->h) * (p->h / ay)) / root.h;
|
2003-12-13 06:07:14 -08:00
|
|
|
XTranslateCoordinates(disp, p->win, root.win, 0, 0, &px, &py, &cw);
|
2003-11-30 07:35:43 -08:00
|
|
|
PagerShowHi(p, ewin, px + wx, py + wy, ww, wh);
|
2003-12-13 06:07:14 -08:00
|
|
|
PagerShowTt(ewin);
|
|
|
|
}
|
|
|
|
else if (in == PAGER_EVENT_MOTION)
|
|
|
|
{
|
|
|
|
PagerShowTt(ewin);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NewPagerForDesktop(int desk)
|
|
|
|
{
|
|
|
|
|
|
|
|
Pager *p;
|
|
|
|
char s[1024];
|
|
|
|
|
2003-11-30 07:35:43 -08:00
|
|
|
p = PagerCreate();
|
1999-08-17 15:56:46 -07:00
|
|
|
if (p)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
p->desktop = desk;
|
|
|
|
Esnprintf(s, sizeof(s), "%i", desk);
|
|
|
|
PagerTitle(p, s);
|
|
|
|
PagerShow(p);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EnableSinglePagerForDesktop(int desk)
|
|
|
|
{
|
|
|
|
Pager **pl;
|
|
|
|
int num;
|
|
|
|
|
|
|
|
pl = PagersForDesktop(desk, &num);
|
|
|
|
if (!pl)
|
2003-11-08 15:57:49 -08:00
|
|
|
NewPagerForDesktop(desk);
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
1999-08-26 11:56:06 -07:00
|
|
|
Efree(pl);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EnableAllPagers(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (!conf.pagers.enable)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-01-12 12:43:18 -08:00
|
|
|
conf.pagers.enable = 1;
|
|
|
|
for (i = 0; i < conf.desks.numdesktops; i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
EnableSinglePagerForDesktop(i);
|
|
|
|
UpdatePagerSel();
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
PagerForDesktop(int desk)
|
|
|
|
{
|
|
|
|
Pager **pl;
|
|
|
|
int num;
|
|
|
|
|
|
|
|
pl = PagersForDesktop(desk, &num);
|
|
|
|
if (pl)
|
1999-08-26 11:56:06 -07:00
|
|
|
Efree(pl);
|
1999-08-17 15:56:46 -07:00
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisablePagersForDesktop(int desk)
|
|
|
|
{
|
|
|
|
Pager **pl;
|
|
|
|
|
|
|
|
int i, num;
|
|
|
|
|
|
|
|
pl = PagersForDesktop(desk, &num);
|
|
|
|
if (pl)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (pl[i]->ewin)
|
|
|
|
ICCCM_Delete(pl[i]->ewin);
|
|
|
|
}
|
|
|
|
Efree(pl);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableAllPagers(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.pagers.enable)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-01-12 12:43:18 -08:00
|
|
|
for (i = 0; i < conf.desks.numdesktops; i++)
|
2003-05-22 12:15:03 -07:00
|
|
|
DisablePagersForDesktop(i);
|
2004-01-12 12:43:18 -08:00
|
|
|
conf.pagers.enable = 0;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerSetHiQ(char onoff)
|
|
|
|
{
|
|
|
|
Pager **pl;
|
|
|
|
EWin **lst;
|
|
|
|
int i, num;
|
|
|
|
|
|
|
|
HIQ = onoff;
|
|
|
|
|
|
|
|
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++)
|
|
|
|
{
|
|
|
|
lst[i]->mini_w = 0;
|
|
|
|
lst[i]->mini_h = 0;
|
|
|
|
}
|
|
|
|
Efree(lst);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
pl = (Pager **) ListItemType(&num, LIST_TYPE_PAGER);
|
|
|
|
if (pl)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
PagerHideHi(pl[i]);
|
|
|
|
PagerRedraw(pl[i], 2);
|
|
|
|
PagerForceUpdate(pl[i]);
|
|
|
|
}
|
|
|
|
Efree(pl);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PagerSetSnap(char onoff)
|
|
|
|
{
|
|
|
|
Pager **pl;
|
|
|
|
EWin **lst;
|
|
|
|
int i, num;
|
1999-08-26 15:49:32 -07:00
|
|
|
char s[256];
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
conf.pagers.snap = onoff;
|
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++)
|
|
|
|
{
|
|
|
|
lst[i]->mini_w = 0;
|
|
|
|
lst[i]->mini_h = 0;
|
|
|
|
}
|
|
|
|
Efree(lst);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
pl = (Pager **) ListItemType(&num, LIST_TYPE_PAGER);
|
|
|
|
if (pl)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
PagerHideHi(pl[i]);
|
|
|
|
PagerRedraw(pl[i], 2);
|
|
|
|
PagerForceUpdate(pl[i]);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.pagers.snap)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2003-12-09 12:25:17 -08:00
|
|
|
Esnprintf(s, sizeof(s), "__.%x", (unsigned)pl[i]->win);
|
2004-01-12 12:43:18 -08:00
|
|
|
if (conf.pagers.scanspeed > 0)
|
|
|
|
DoIn(s, 1 / ((double)conf.pagers.scanspeed),
|
2003-05-22 12:15:03 -07:00
|
|
|
PagerUpdateTimeout, 0, pl[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(pl);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
2003-11-08 15:57:49 -08:00
|
|
|
|
|
|
|
Window
|
|
|
|
PagerGetWin(Pager * p)
|
|
|
|
{
|
|
|
|
return (p) ? p->win : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Window
|
|
|
|
PagerGetHiWin(Pager * p)
|
|
|
|
{
|
|
|
|
return (p) ? p->hi_win : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Pager *
|
|
|
|
FindPager(Window win)
|
|
|
|
{
|
|
|
|
Pager *p, *pr = NULL;
|
|
|
|
Pager **ps;
|
|
|
|
int i, num;
|
|
|
|
|
|
|
|
EDBUG(6, "FindDialog");
|
|
|
|
|
|
|
|
ps = (Pager **) ListItemType(&num, LIST_TYPE_PAGER);
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
p = ps[i];
|
|
|
|
if ((p->win == win) || (p->hi_win == win))
|
|
|
|
{
|
|
|
|
pr = p;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ps)
|
|
|
|
Efree(ps);
|
|
|
|
|
|
|
|
EDBUG_RETURN(pr);
|
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Pager event handlers
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int *gwin_px, *gwin_py;
|
|
|
|
|
2004-01-10 05:40:59 -08:00
|
|
|
void
|
|
|
|
PagerEventUnmap(Pager * p)
|
|
|
|
{
|
|
|
|
PagerHideHi(p);
|
|
|
|
if (p == mode.context_pager)
|
|
|
|
{
|
|
|
|
mode.context_pager = NULL;
|
|
|
|
mode.mode = MODE_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
int
|
2003-11-30 07:35:43 -08:00
|
|
|
PagersEventMotion(XEvent * ev)
|
|
|
|
{
|
2003-12-13 06:07:14 -08:00
|
|
|
int used = 0;
|
2003-11-30 07:35:43 -08:00
|
|
|
Pager *p;
|
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
int x, y, dx, dy;
|
|
|
|
int ax, ay, cx, cy, i, num;
|
|
|
|
EWin **gwins;
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
switch (mode.mode)
|
2003-11-30 07:35:43 -08:00
|
|
|
{
|
2003-12-13 06:07:14 -08:00
|
|
|
case MODE_NONE:
|
|
|
|
p = FindPager(ev->xmotion.window);
|
|
|
|
if (p == NULL)
|
|
|
|
break;
|
|
|
|
used = 1;
|
|
|
|
PagerHandleMotion(p, ev->xmotion.window, ev->xmotion.x,
|
|
|
|
ev->xmotion.y, PAGER_EVENT_MOTION);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MODE_PAGER_DRAG_PENDING:
|
|
|
|
case MODE_PAGER_DRAG:
|
2003-11-30 07:35:43 -08:00
|
|
|
mode.mode = MODE_PAGER_DRAG;
|
|
|
|
p = mode.context_pager;
|
2003-12-13 06:07:14 -08:00
|
|
|
if (p == NULL)
|
|
|
|
break;
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
used = 1;
|
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
dx = mode.x - mode.px;
|
|
|
|
dy = mode.y - mode.py;
|
|
|
|
if (!FindItem
|
|
|
|
((char *)p->hi_ewin, 0, LIST_FINDBY_POINTER, LIST_TYPE_EWIN))
|
|
|
|
p->hi_ewin = NULL;
|
|
|
|
if ((p->hi_ewin) && (!p->hi_ewin->pager) && (!p->hi_ewin->fixedpos))
|
|
|
|
{
|
|
|
|
Window dw;
|
|
|
|
int px, py;
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
GetWinXY(p->hi_win, &x, &y);
|
|
|
|
XRaiseWindow(disp, p->hi_win);
|
|
|
|
x += dx;
|
|
|
|
y += dy;
|
|
|
|
EMoveWindow(disp, p->hi_win, x, y);
|
|
|
|
XTranslateCoordinates(disp, p->win, root.win, 0, 0, &px, &py, &dw);
|
|
|
|
x -= px + (cx * (p->w / ax));
|
|
|
|
y -= py + (cy * (p->h / ay));
|
|
|
|
MoveEwin(p->hi_ewin, (x * root.w * ax) / p->w,
|
|
|
|
(y * root.h * ay) / p->h);
|
|
|
|
}
|
2003-11-30 07:35:43 -08:00
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
gwins =
|
|
|
|
ListWinGroupMembersForEwin(p->hi_ewin, ACTION_MOVE,
|
|
|
|
mode.nogroup, &num);
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if ((gwins[i] != p->hi_ewin) && (!gwins[i]->pager)
|
|
|
|
&& (!gwins[i]->fixedpos))
|
2003-11-30 07:35:43 -08:00
|
|
|
{
|
2003-12-13 06:07:14 -08:00
|
|
|
GetWinXY(gwins[i]->win, &x, &y);
|
|
|
|
x += (dx * root.w * ax) / p->w;
|
|
|
|
y += (dy * root.h * ay) / p->h;
|
|
|
|
MoveEwin(gwins[i], x, y);
|
2003-11-30 07:35:43 -08:00
|
|
|
}
|
|
|
|
}
|
2003-12-13 06:07:14 -08:00
|
|
|
if (gwins)
|
|
|
|
Efree(gwins);
|
|
|
|
break;
|
2003-11-30 07:35:43 -08:00
|
|
|
}
|
2003-12-13 06:07:14 -08:00
|
|
|
|
|
|
|
return used;
|
2003-11-30 07:35:43 -08:00
|
|
|
}
|
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
int
|
2003-11-30 07:35:43 -08:00
|
|
|
PagersEventMouseDown(XEvent * ev)
|
|
|
|
{
|
|
|
|
int i, num;
|
|
|
|
Pager *p;
|
|
|
|
EWin *ewin, **gwins;
|
|
|
|
|
|
|
|
p = FindPager(ev->xbutton.window);
|
|
|
|
if (!p)
|
2003-12-13 06:07:14 -08:00
|
|
|
return 0;
|
2003-11-30 07:35:43 -08:00
|
|
|
|
|
|
|
gwins =
|
|
|
|
ListWinGroupMembersForEwin(p->hi_ewin, ACTION_MOVE, mode.nogroup, &num);
|
|
|
|
gwin_px = calloc(num, sizeof(int));
|
|
|
|
gwin_py = calloc(num, sizeof(int));
|
|
|
|
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
gwin_px[i] = gwins[i]->x;
|
|
|
|
gwin_py[i] = gwins[i]->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gwins)
|
|
|
|
Efree(gwins);
|
|
|
|
|
|
|
|
if (ev->xbutton.window == p->hi_win)
|
|
|
|
{
|
|
|
|
int hx, hy;
|
|
|
|
Window dw;
|
|
|
|
|
|
|
|
XTranslateCoordinates(disp, p->hi_win, p->win, 0, 0, &hx, &hy, &dw);
|
|
|
|
ev->xbutton.x += hx;
|
|
|
|
ev->xbutton.y += hy;
|
|
|
|
}
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if ((int)ev->xbutton.button == conf.pagers.menu_button)
|
2003-11-30 07:35:43 -08:00
|
|
|
{
|
|
|
|
if ((ev->xbutton.x >= 0) && (ev->xbutton.y >= 0)
|
|
|
|
&& (ev->xbutton.x < p->w) && (ev->xbutton.y < p->h))
|
|
|
|
{
|
|
|
|
PagerHideHi(p);
|
2003-12-14 09:24:34 -08:00
|
|
|
PagerMenuShow(p, ev->xbutton.x, ev->xbutton.y);
|
2003-11-30 07:35:43 -08:00
|
|
|
}
|
|
|
|
}
|
2004-01-12 12:43:18 -08:00
|
|
|
else if ((int)ev->xbutton.button == conf.pagers.win_button)
|
2003-11-30 07:35:43 -08:00
|
|
|
{
|
|
|
|
ewin = EwinInPagerAt(p, ev->xbutton.x, ev->xbutton.y);
|
|
|
|
if ((ewin) && (!ewin->pager))
|
|
|
|
{
|
|
|
|
Window dw;
|
|
|
|
int wx, wy, ww, wh, ax, ay, cx, cy, px, py;
|
|
|
|
|
|
|
|
PagerHideHi(p);
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
cx = desks.desk[p->desktop].current_area_x;
|
|
|
|
cy = desks.desk[p->desktop].current_area_y;
|
|
|
|
wx = ((ewin->x + (cx * root.w)) * (p->w / ax)) / root.w;
|
|
|
|
wy = ((ewin->y + (cy * root.h)) * (p->h / ay)) / root.h;
|
|
|
|
ww = ((ewin->w) * (p->w / ax)) / root.w;
|
|
|
|
wh = ((ewin->h) * (p->h / ay)) / root.h;
|
|
|
|
XTranslateCoordinates(disp, p->win, root.win, 0, 0, &px, &py, &dw);
|
|
|
|
EMoveResizeWindow(disp, p->hi_win, px + wx, py + wy, ww, wh);
|
|
|
|
ESetWindowBackgroundPixmap(disp, p->hi_win, ewin->mini_pmm.pmap);
|
|
|
|
EMapRaised(disp, p->hi_win);
|
|
|
|
GrabThePointer(p->hi_win);
|
|
|
|
p->hi_visible = 1;
|
|
|
|
p->hi_ewin = ewin;
|
|
|
|
p->hi_win_w = ww;
|
|
|
|
p->hi_win_h = wh;
|
|
|
|
mode.mode = MODE_PAGER_DRAG_PENDING;
|
|
|
|
mode.context_pager = p;
|
|
|
|
}
|
|
|
|
}
|
2003-12-13 06:07:14 -08:00
|
|
|
|
|
|
|
return 1;
|
2003-11-30 07:35:43 -08:00
|
|
|
}
|
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
int
|
2003-11-30 07:35:43 -08:00
|
|
|
PagersEventMouseUp(XEvent * ev)
|
|
|
|
{
|
2003-12-13 06:07:14 -08:00
|
|
|
int used = 0;
|
2003-11-30 07:35:43 -08:00
|
|
|
int i, num;
|
|
|
|
Pager *p;
|
|
|
|
EWin *ewin, **gwins;
|
|
|
|
int pax, pay;
|
|
|
|
|
|
|
|
p = FindPager(ev->xbutton.window);
|
2003-12-13 06:07:14 -08:00
|
|
|
if (p == NULL)
|
|
|
|
goto exit;
|
|
|
|
|
2004-01-12 12:43:18 -08:00
|
|
|
if (((int)ev->xbutton.button == conf.pagers.sel_button))
|
2003-11-30 07:35:43 -08:00
|
|
|
{
|
|
|
|
PagerAreaAt(p, ev->xbutton.x, ev->xbutton.y, &pax, &pay);
|
|
|
|
GotoDesktop(p->desktop);
|
|
|
|
if (p->desktop != desks.current)
|
|
|
|
{
|
2004-01-03 04:29:58 -08:00
|
|
|
SoundPlay("SOUND_DESKTOP_SHUT");
|
2003-11-30 07:35:43 -08:00
|
|
|
}
|
|
|
|
SetCurrentArea(pax, pay);
|
|
|
|
}
|
2004-01-12 12:43:18 -08:00
|
|
|
else if (((int)ev->xbutton.button == conf.pagers.win_button))
|
2003-11-30 07:35:43 -08:00
|
|
|
{
|
|
|
|
if (ev->xbutton.window == p->hi_win)
|
|
|
|
{
|
|
|
|
int hx, hy;
|
|
|
|
Window dw;
|
|
|
|
|
|
|
|
XTranslateCoordinates(disp, p->hi_win, p->win, 0, 0, &hx, &hy,
|
|
|
|
&dw);
|
|
|
|
ev->xbutton.x += hx;
|
|
|
|
ev->xbutton.y += hy;
|
|
|
|
}
|
|
|
|
if (!FindItem
|
|
|
|
((char *)p->hi_ewin, 0, LIST_FINDBY_POINTER, LIST_TYPE_EWIN))
|
|
|
|
p->hi_ewin = NULL;
|
|
|
|
if ((mode.mode == MODE_PAGER_DRAG) && (p->hi_ewin))
|
|
|
|
{
|
|
|
|
ewin = NULL;
|
|
|
|
for (i = 0; i < desks.desk[desks.current].num; i++)
|
|
|
|
{
|
|
|
|
EWin *ew;
|
|
|
|
|
|
|
|
ew = desks.desk[desks.current].list[i];
|
|
|
|
if (((ew->pager) || (ew->ibox))
|
|
|
|
&& ((ew->desktop == desks.current) || (ew->sticky)))
|
|
|
|
{
|
|
|
|
if ((ev->xbutton.x_root >=
|
|
|
|
(ew->x + ew->border->border.left))
|
|
|
|
&& (ev->xbutton.x_root <
|
|
|
|
(ew->x + ew->w - ew->border->border.right))
|
|
|
|
&& (ev->xbutton.y_root >=
|
|
|
|
(ew->y + ew->border->border.top))
|
|
|
|
&& (ev->xbutton.y_root <
|
|
|
|
(ew->y + ew->h - ew->border->border.bottom)))
|
|
|
|
{
|
|
|
|
ewin = ew;
|
|
|
|
i = desks.desk[desks.current].num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ewin = GetEwinPointerInClient();
|
|
|
|
if ((ewin) && (ewin->pager))
|
|
|
|
{
|
|
|
|
Pager *pp;
|
|
|
|
int w, h, x, y, ax, ay, cx, cy, px, py;
|
|
|
|
int wx, wy, base_x = 0, base_y = 0;
|
|
|
|
Window dw;
|
|
|
|
|
|
|
|
pp = ewin->pager;
|
|
|
|
cx = desks.desk[pp->desktop].current_area_x;
|
|
|
|
cy = desks.desk[pp->desktop].current_area_y;
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
GetWinXY(p->hi_win, &x, &y);
|
|
|
|
GetWinWH(p->hi_win, &w, &h);
|
|
|
|
XTranslateCoordinates(disp, pp->win, root.win, 0, 0, &px,
|
|
|
|
&py, &dw);
|
|
|
|
wx = ((x - px) -
|
|
|
|
(cx * (pp->w / ax))) * (root.w / (pp->w / ax));
|
|
|
|
wy = ((y - py) -
|
|
|
|
(cy * (pp->h / ay))) * (root.h / (pp->h / ay));
|
|
|
|
if (((x + w) <= px) || ((y + h) <= py)
|
|
|
|
|| (x >= (px + pp->w)) || (y >= (py + pp->h)))
|
|
|
|
{
|
|
|
|
int ndesk, nx, ny;
|
|
|
|
|
|
|
|
ndesk = desks.current;
|
|
|
|
nx = (int)ev->xbutton.x_root -
|
|
|
|
desks.desk[desks.current].x -
|
|
|
|
((int)p->hi_ewin->w / 2);
|
|
|
|
ny = (int)ev->xbutton.y_root -
|
|
|
|
desks.desk[desks.current].y -
|
|
|
|
((int)p->hi_ewin->h / 2);
|
|
|
|
MoveEwin(p->hi_ewin, nx, ny);
|
|
|
|
if (!p->hi_ewin->sticky)
|
|
|
|
MoveEwinToDesktop(p->hi_ewin, ndesk);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gwins =
|
|
|
|
ListWinGroupMembersForEwin(p->hi_ewin,
|
|
|
|
ACTION_MOVE,
|
|
|
|
mode.nogroup, &num);
|
|
|
|
/* get get the location of the base win so we can move the */
|
|
|
|
/* rest of the windows in the group to the correct offset */
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
if (gwins[i] == p->hi_ewin)
|
|
|
|
{
|
|
|
|
base_x = gwin_px[i];
|
|
|
|
base_y = gwin_py[i];
|
|
|
|
}
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (!gwins[i]->sticky)
|
|
|
|
MoveEwinToDesktopAt(gwins[i], pp->desktop,
|
|
|
|
wx + (gwin_px[i] -
|
|
|
|
base_x),
|
|
|
|
wy + (gwin_py[i] - base_y));
|
|
|
|
else
|
|
|
|
MoveEwin(gwins[i],
|
|
|
|
((root.w * ax) + wx +
|
|
|
|
(gwin_px[i] - base_x)) % root.w,
|
|
|
|
((root.h * ay) + wy +
|
|
|
|
(gwin_py[i] - base_y)) % root.h);
|
|
|
|
}
|
|
|
|
if (gwins)
|
|
|
|
Efree(gwins);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((ewin) && (ewin->ibox) && (!((p->hi_ewin->ibox)
|
|
|
|
/* || ((ewin->client.need_input) && ((ewin->skiptask) || (ewin->skipwinlist))) */
|
|
|
|
)))
|
|
|
|
{
|
|
|
|
gwins =
|
|
|
|
ListWinGroupMembersForEwin(p->hi_ewin, ACTION_MOVE,
|
|
|
|
mode.nogroup, &num);
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (!gwins[i]->pager)
|
|
|
|
{
|
|
|
|
MoveEwin(gwins[i], gwin_px[i], gwin_py[i]);
|
|
|
|
IconboxIconifyEwin(ewin->ibox, gwins[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gwins)
|
|
|
|
Efree(gwins);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int ndesk, nx, ny, base_x = 0, base_y =
|
|
|
|
0, ax, ay;
|
|
|
|
|
|
|
|
ndesk = desks.current;
|
|
|
|
nx = (int)ev->xbutton.x_root -
|
|
|
|
desks.desk[desks.current].x - ((int)p->hi_ewin->w / 2);
|
|
|
|
ny = (int)ev->xbutton.y_root -
|
|
|
|
desks.desk[desks.current].y - ((int)p->hi_ewin->h / 2);
|
|
|
|
GetAreaSize(&ax, &ay);
|
|
|
|
|
|
|
|
gwins =
|
|
|
|
ListWinGroupMembersForEwin(p->hi_ewin, ACTION_MOVE,
|
|
|
|
mode.nogroup, &num);
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
if (gwins[i] == p->hi_ewin)
|
|
|
|
{
|
|
|
|
base_x = gwin_px[i];
|
|
|
|
base_y = gwin_py[i];
|
|
|
|
}
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (!gwins[i]->sticky)
|
|
|
|
MoveEwin(gwins[i], nx + (gwin_px[i] - base_x),
|
|
|
|
ny + (gwin_py[i] - base_y));
|
|
|
|
else
|
|
|
|
MoveEwin(gwins[i],
|
|
|
|
((root.w * ax) + nx +
|
|
|
|
(gwin_px[i] - base_x)) % root.w,
|
|
|
|
((root.h * ay) + ny +
|
|
|
|
(gwin_py[i] - base_y)) % root.h);
|
|
|
|
if (!gwins[i]->sticky)
|
|
|
|
MoveEwinToDesktop(gwins[i], ndesk);
|
|
|
|
}
|
|
|
|
if (gwins)
|
|
|
|
Efree(gwins);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((ev->xbutton.x >= 0) && (ev->xbutton.y >= 0)
|
|
|
|
&& (ev->xbutton.x < p->w) && (ev->xbutton.y < p->h))
|
|
|
|
{
|
|
|
|
PagerAreaAt(p, ev->xbutton.x, ev->xbutton.y, &pax, &pay);
|
|
|
|
GotoDesktop(p->desktop);
|
|
|
|
SetCurrentArea(pax, pay);
|
|
|
|
ewin = EwinInPagerAt(p, ev->xbutton.x, ev->xbutton.y);
|
|
|
|
if (ewin)
|
|
|
|
{
|
|
|
|
RaiseEwin(ewin);
|
|
|
|
FocusToEWin(ewin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (p->hi_ewin)
|
|
|
|
{
|
|
|
|
RedrawPagersForDesktop(p->hi_ewin->desktop, 3);
|
|
|
|
ForceUpdatePagersForDesktop(p->hi_ewin->desktop);
|
|
|
|
PagerHideHi(p);
|
|
|
|
}
|
|
|
|
mode.mode = MODE_NONE;
|
|
|
|
mode.context_pager = NULL;
|
|
|
|
}
|
|
|
|
|
2003-12-13 06:07:14 -08:00
|
|
|
exit:
|
2003-11-30 07:35:43 -08:00
|
|
|
/* unallocate the space that was holding the old positions of the */
|
|
|
|
/* windows */
|
|
|
|
if (gwin_px)
|
|
|
|
{
|
|
|
|
Efree(gwin_px);
|
|
|
|
gwin_px = NULL;
|
|
|
|
Efree(gwin_py);
|
|
|
|
gwin_py = NULL;
|
|
|
|
}
|
2003-12-13 06:07:14 -08:00
|
|
|
|
|
|
|
return used;
|
2003-11-30 07:35:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
PagersEventMouseIn(XEvent * ev)
|
|
|
|
{
|
|
|
|
Pager *p;
|
|
|
|
Window win = ev->xcrossing.window;
|
|
|
|
|
|
|
|
p = FindPager(win);
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
PagerHandleMotion(p, win, ev->xcrossing.x, ev->xcrossing.y,
|
|
|
|
PAGER_EVENT_MOUSE_IN);
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
PagersEventMouseOut(XEvent * ev)
|
|
|
|
{
|
|
|
|
Pager *p;
|
|
|
|
Window win = ev->xcrossing.window;
|
|
|
|
|
|
|
|
p = FindPager(win);
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
PagerHandleMotion(p, win, ev->xcrossing.x, ev->xcrossing.y,
|
|
|
|
PAGER_EVENT_MOUSE_OUT);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|