1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2006-01-06 23:20:58 -08:00
|
|
|
* Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors
|
|
|
|
* Copyright (C) 2004-2006 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
|
|
|
#include "E.h"
|
2006-01-07 00:53:15 -08:00
|
|
|
#ifdef USE_ECORE_X
|
2006-02-18 01:50:17 -08:00
|
|
|
#include <Ecore_X.h>
|
2006-01-07 00:53:15 -08:00
|
|
|
#endif
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "xwin.h"
|
2006-03-19 06:59:48 -08:00
|
|
|
#include <X11/Xatom.h>
|
1999-08-17 15:56:46 -07:00
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xresource.h>
|
|
|
|
|
2005-06-30 05:57:34 -07:00
|
|
|
#define DEBUG_XWIN 0
|
|
|
|
|
2004-05-31 13:03:06 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
EventCallbackFunc *func;
|
|
|
|
void *prm;
|
|
|
|
} EventCallbackItem;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int num;
|
|
|
|
EventCallbackItem *lst;
|
|
|
|
} EventCallbackList;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
struct _xwin
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
struct _xwin *next;
|
|
|
|
struct _xwin *prev;
|
2004-05-31 13:03:06 -07:00
|
|
|
EventCallbackList cbl;
|
2003-07-12 00:52:03 -07:00
|
|
|
Window parent;
|
|
|
|
Window win;
|
|
|
|
int x, y, w, h;
|
|
|
|
char mapped;
|
2004-12-28 15:46:49 -08:00
|
|
|
char in_use;
|
2005-06-30 05:57:34 -07:00
|
|
|
signed char do_del;
|
2004-12-28 15:46:49 -08:00
|
|
|
char attached;
|
2003-07-12 00:52:03 -07:00
|
|
|
int num_rect;
|
|
|
|
int ord;
|
|
|
|
XRectangle *rects;
|
|
|
|
int depth;
|
|
|
|
Pixmap bgpmap;
|
|
|
|
int bgcol;
|
2006-04-29 12:39:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _xwin EXID; /* FIXME - Remove */
|
2003-07-12 00:52:03 -07:00
|
|
|
|
|
|
|
static XContext xid_context = 0;
|
|
|
|
|
2005-06-30 05:57:34 -07:00
|
|
|
static EXID *xid_first = NULL;
|
|
|
|
static EXID *xid_last = NULL;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
#if USE_NEW_WIN_API
|
|
|
|
Window
|
|
|
|
Xwin(const Win win)
|
|
|
|
{
|
|
|
|
return win->win;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-07-12 00:52:03 -07:00
|
|
|
static EXID *
|
2004-12-28 15:46:49 -08:00
|
|
|
EXidCreate(void)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-05-31 13:03:06 -07:00
|
|
|
xid = Ecalloc(1, sizeof(EXID));
|
2005-01-30 03:02:43 -08:00
|
|
|
xid->bgcol = -1;
|
2003-07-12 00:52:03 -07:00
|
|
|
|
|
|
|
return xid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-12-28 15:46:49 -08:00
|
|
|
EXidDestroy(EXID * xid)
|
|
|
|
{
|
2005-06-30 05:57:34 -07:00
|
|
|
#if DEBUG_XWIN
|
2004-12-28 15:46:49 -08:00
|
|
|
Eprintf("EXidDestroy: %p %#lx\n", xid, xid->win);
|
|
|
|
#endif
|
2005-06-04 01:29:55 -07:00
|
|
|
if (xid->rects)
|
|
|
|
XFree(xid->rects);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (xid->cbl.lst)
|
|
|
|
Efree(xid->cbl.lst);
|
|
|
|
Efree(xid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
EXidAdd(EXID * xid)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2005-06-30 05:57:34 -07:00
|
|
|
#if DEBUG_XWIN
|
|
|
|
Eprintf("EXidAdd: %p %#lx\n", xid, xid->win);
|
|
|
|
#endif
|
2003-07-12 00:52:03 -07:00
|
|
|
if (!xid_context)
|
|
|
|
xid_context = XUniqueContext();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2003-07-12 00:52:03 -07:00
|
|
|
XSaveContext(disp, xid->win, xid_context, (XPointer) xid);
|
2005-06-30 05:57:34 -07:00
|
|
|
|
|
|
|
if (!xid_first)
|
|
|
|
{
|
|
|
|
xid_first = xid_last = xid;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xid->prev = xid_last;
|
|
|
|
xid_last->next = xid;
|
|
|
|
xid_last = xid;
|
|
|
|
}
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2005-06-30 05:57:34 -07:00
|
|
|
EXidDel(EXID * xid)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2005-06-30 05:57:34 -07:00
|
|
|
#if DEBUG_XWIN
|
|
|
|
Eprintf("EXidDel: %p %#lx\n", xid, xid->win);
|
2005-06-04 01:29:55 -07:00
|
|
|
#endif
|
2005-06-30 05:57:34 -07:00
|
|
|
if (xid == xid_first)
|
|
|
|
{
|
|
|
|
if (xid == xid_last)
|
|
|
|
{
|
|
|
|
xid_first = xid_last = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xid_first = xid->next;
|
|
|
|
xid->next->prev = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (xid == xid_last)
|
|
|
|
{
|
|
|
|
xid_last = xid->prev;
|
|
|
|
xid->prev->next = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xid->prev->next = xid->next;
|
|
|
|
xid->next->prev = xid->prev;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-06-30 05:57:34 -07:00
|
|
|
XDeleteContext(disp, xid->win, xid_context);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (xid->in_use)
|
|
|
|
xid->do_del = 1;
|
|
|
|
else
|
|
|
|
EXidDestroy(xid);
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
#if USE_NEW_WIN_API
|
|
|
|
#define EXidFind(win) (win)
|
|
|
|
#define EXidLookup ELookupXwin
|
|
|
|
#else
|
|
|
|
#define EXidFind EXidLookup
|
|
|
|
EXID *EXidLookup(Window xwin);
|
|
|
|
#endif
|
|
|
|
EXID *
|
|
|
|
EXidLookup(Window xwin)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
2004-12-28 15:46:49 -08:00
|
|
|
XPointer xp;
|
2003-07-12 00:52:03 -07:00
|
|
|
|
2005-06-30 05:57:34 -07:00
|
|
|
if (!xid_context)
|
|
|
|
return NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
xp = NULL;
|
2006-04-29 12:39:21 -07:00
|
|
|
if (XFindContext(disp, xwin, xid_context, &xp) == XCNOENT)
|
2004-12-28 15:46:49 -08:00
|
|
|
xp = NULL;
|
|
|
|
xid = (EXID *) xp;
|
2005-06-04 01:29:55 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
return xid;
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static EXID *
|
|
|
|
EXidSet(Window win, Window parent, int x, int y, int w, int h, int depth)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidCreate();
|
2003-07-12 00:52:03 -07:00
|
|
|
xid->parent = parent;
|
|
|
|
xid->win = win;
|
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
|
|
|
xid->w = w;
|
|
|
|
xid->h = h;
|
2004-12-28 15:46:49 -08:00
|
|
|
xid->depth = depth;
|
2005-06-30 05:57:34 -07:00
|
|
|
#if DEBUG_XWIN
|
2004-12-28 15:46:49 -08:00
|
|
|
Eprintf("EXidSet: %#lx\n", xid->win);
|
|
|
|
#endif
|
|
|
|
EXidAdd(xid);
|
|
|
|
|
|
|
|
return xid;
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
2004-05-31 13:03:06 -07:00
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EventCallbackRegister(Win win, int type __UNUSED__, EventCallbackFunc * func,
|
2004-05-31 13:03:06 -07:00
|
|
|
void *prm)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
EventCallbackItem *eci;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
|
|
|
if (!xid)
|
2006-04-18 10:53:15 -07:00
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
ERegisterWindow(Xwin(win)); /* FIXME - We shouldn't go here */
|
2006-04-18 10:53:15 -07:00
|
|
|
xid = EXidFind(win);
|
|
|
|
if (!xid)
|
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
Eprintf("EventCallbackRegister win=%#lx ???\n", Xwin(win));
|
2006-04-18 10:53:15 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
|
|
|
Eprintf("EventCallbackRegister: %p %#lx\n", xid, win);
|
|
|
|
#endif
|
2004-05-31 13:03:06 -07:00
|
|
|
|
|
|
|
xid->cbl.num++;
|
|
|
|
xid->cbl.lst =
|
|
|
|
Erealloc(xid->cbl.lst, xid->cbl.num * sizeof(EventCallbackItem));
|
|
|
|
eci = xid->cbl.lst + xid->cbl.num - 1;
|
|
|
|
eci->func = func;
|
|
|
|
eci->prm = prm;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EventCallbackUnregister(Win win, int type __UNUSED__,
|
2004-05-31 13:03:06 -07:00
|
|
|
EventCallbackFunc * func, void *prm)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
EventCallbackList *ecl;
|
|
|
|
EventCallbackItem *eci;
|
|
|
|
int i;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
|
|
|
#if 0
|
|
|
|
Eprintf("EventCallbackUnregister: %p %#lx\n", xid, win);
|
|
|
|
#endif
|
2004-05-31 13:03:06 -07:00
|
|
|
if (xid == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ecl = &xid->cbl;
|
|
|
|
eci = ecl->lst;
|
|
|
|
for (i = 0; i < ecl->num; i++, eci++)
|
|
|
|
if (eci->func == func && eci->prm == prm)
|
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
ecl->num--;
|
|
|
|
if (ecl->num)
|
|
|
|
{
|
|
|
|
for (; i < ecl->num; i++, eci++)
|
|
|
|
*eci = *(eci + 1);
|
|
|
|
xid->cbl.lst =
|
|
|
|
Erealloc(xid->cbl.lst, ecl->num * sizeof(EventCallbackItem));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Efree(xid->cbl.lst);
|
|
|
|
xid->cbl.lst = NULL;
|
|
|
|
}
|
2004-05-31 13:03:06 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EventCallbacksProcess(Win win, XEvent * ev)
|
2004-05-31 13:03:06 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
EventCallbackList *ecl;
|
|
|
|
EventCallbackItem *eci;
|
|
|
|
int i;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
xid = EXidFind(win);
|
2004-05-31 13:03:06 -07:00
|
|
|
if (xid == NULL)
|
|
|
|
return;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid->in_use = 1;
|
2004-05-31 13:03:06 -07:00
|
|
|
ecl = &xid->cbl;
|
|
|
|
eci = ecl->lst;
|
|
|
|
for (i = 0; i < ecl->num; i++, eci++)
|
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
if (EventDebug(EDBUG_TYPE_DISPATCH))
|
2004-05-31 13:03:06 -07:00
|
|
|
Eprintf("EventDispatch: type=%d win=%#lx func=%p prm=%p\n",
|
|
|
|
ev->type, ev->xany.window, eci->func, eci->prm);
|
2006-04-29 12:39:21 -07:00
|
|
|
#if USE_NEW_WIN_API
|
|
|
|
eci->func(xid, ev, eci->prm);
|
|
|
|
#else
|
|
|
|
eci->func(xid->win, ev, eci->prm);
|
|
|
|
#endif
|
2004-12-28 15:46:49 -08:00
|
|
|
if (xid->do_del)
|
|
|
|
{
|
|
|
|
EXidDestroy(xid);
|
|
|
|
return;
|
|
|
|
}
|
2004-05-31 13:03:06 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
xid->in_use = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
Win
|
|
|
|
ECreateWindow(Win parent, int x, int y, int w, int h, int saveunder)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
EXID *win;
|
|
|
|
Window xwin, xpar;
|
1999-08-17 15:56:46 -07:00
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
attr.backing_store = NotUseful;
|
2005-08-07 03:51:07 -07:00
|
|
|
attr.override_redirect = False;
|
2004-05-04 12:04:42 -07:00
|
|
|
attr.colormap = VRoot.cmap;
|
1999-08-17 15:56:46 -07:00
|
|
|
attr.border_pixel = 0;
|
1999-11-06 01:32:32 -08:00
|
|
|
/* attr.background_pixel = 0; */
|
1999-08-17 15:56:46 -07:00
|
|
|
attr.background_pixmap = None;
|
2004-03-20 07:49:05 -08:00
|
|
|
if ((saveunder == 1) && (Conf.save_under))
|
1999-08-17 15:56:46 -07:00
|
|
|
attr.save_under = True;
|
|
|
|
else if (saveunder == 2)
|
|
|
|
attr.save_under = True;
|
|
|
|
else
|
|
|
|
attr.save_under = False;
|
2005-04-29 10:37:30 -07:00
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
xpar = (parent != NoWin) ? Xwin(parent) : VRoot.xwin;
|
|
|
|
xwin = XCreateWindow(disp, xpar, x, y, w, h, 0,
|
|
|
|
VRoot.depth, InputOutput, VRoot.vis,
|
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixmap | CWBorderPixel, &attr);
|
|
|
|
win = EXidSet(xwin, xpar, x, y, w, h, VRoot.depth);
|
|
|
|
|
|
|
|
#if USE_NEW_WIN_API
|
2005-04-29 10:37:30 -07:00
|
|
|
return win;
|
2006-04-29 12:39:21 -07:00
|
|
|
#else
|
|
|
|
return xwin;
|
|
|
|
#endif
|
2005-04-29 10:37:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Creates a window, but takes the visual, depth and the colormap from c_attr. */
|
2006-04-29 12:39:21 -07:00
|
|
|
Win
|
|
|
|
ECreateVisualWindow(Win parent, int x, int y, int w, int h, int saveunder,
|
2005-04-29 10:37:30 -07:00
|
|
|
XWindowAttributes * c_attr)
|
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
EXID *win;
|
|
|
|
Window xwin, xpar;
|
2005-04-29 10:37:30 -07:00
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
attr.backing_store = NotUseful;
|
2005-08-07 03:51:07 -07:00
|
|
|
attr.override_redirect = False;
|
2005-04-29 10:37:30 -07:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.colormap = c_attr->colormap;
|
|
|
|
/* attr.background_pixel = 0; */
|
|
|
|
attr.background_pixmap = None;
|
|
|
|
if ((saveunder == 1) && (Conf.save_under))
|
|
|
|
attr.save_under = True;
|
|
|
|
else if (saveunder == 2)
|
|
|
|
attr.save_under = True;
|
|
|
|
else
|
|
|
|
attr.save_under = False;
|
2003-07-12 00:52:03 -07:00
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
xpar = (parent != NoWin) ? Xwin(parent) : VRoot.xwin;
|
|
|
|
xwin = XCreateWindow(disp, xpar, x, y, w, h, 0,
|
|
|
|
c_attr->depth, InputOutput, c_attr->visual,
|
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixmap | CWBorderPixel, &attr);
|
|
|
|
win = EXidSet(xwin, xpar, x, y, w, h, VRoot.depth);
|
|
|
|
|
|
|
|
#if USE_NEW_WIN_API
|
2005-01-25 13:58:28 -08:00
|
|
|
return win;
|
2006-04-29 12:39:21 -07:00
|
|
|
#else
|
|
|
|
return xwin;
|
|
|
|
#endif
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
Win
|
|
|
|
ECreateEventWindow(Win parent, int x, int y, int w, int h)
|
2005-03-02 11:20:27 -08:00
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
EXID *win;
|
|
|
|
Window xwin, xpar;
|
2005-03-02 11:20:27 -08:00
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
attr.override_redirect = False;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
xpar = (parent != NoWin) ? Xwin(parent) : VRoot.xwin;
|
|
|
|
xwin = XCreateWindow(disp, xpar, x, y, w, h, 0, 0, InputOnly,
|
|
|
|
CopyFromParent, CWOverrideRedirect, &attr);
|
|
|
|
win = EXidSet(xwin, xpar, x, y, w, h, VRoot.depth);
|
|
|
|
|
|
|
|
#if USE_NEW_WIN_API
|
2005-03-02 11:20:27 -08:00
|
|
|
return win;
|
2006-04-29 12:39:21 -07:00
|
|
|
#else
|
|
|
|
return xwin;
|
|
|
|
#endif
|
2005-03-02 11:20:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 /* Not used */
|
|
|
|
/*
|
|
|
|
* create a window which will accept the keyboard focus when no other
|
|
|
|
* windows have it
|
|
|
|
*/
|
2006-04-29 12:39:21 -07:00
|
|
|
Win
|
|
|
|
ECreateFocusWindow(Win parent, int x, int y, int w, int h)
|
2005-03-02 11:20:27 -08:00
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
EXID *win;
|
2005-03-02 11:20:27 -08:00
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
attr.backing_store = NotUseful;
|
2005-08-07 03:51:07 -07:00
|
|
|
attr.override_redirect = False;
|
2005-03-02 11:20:27 -08:00
|
|
|
attr.colormap = VRoot.cmap;
|
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = KeyPressMask | FocusChangeMask;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
Window xwin, xpar;
|
|
|
|
|
2005-03-02 11:20:27 -08:00
|
|
|
win = XCreateWindow(disp, parent, x, y, w, h, 0, 0, InputOnly,
|
|
|
|
CopyFromParent,
|
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel | CWEventMask,
|
|
|
|
&attr);
|
|
|
|
|
|
|
|
XSetWindowBackground(disp, win, 0);
|
|
|
|
XMapWindow(disp, win);
|
|
|
|
XSetInputFocus(disp, win, RevertToParent, CurrentTime);
|
|
|
|
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EMoveWindow(Win win, int x, int y)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
|
|
|
Eprintf("EMoveWindow: %p %#lx: %d,%d %dx%d -> %d,%d\n",
|
|
|
|
xid, xid->win, xid->x, xid->y, xid->w, xid->h, x, y);
|
|
|
|
#endif
|
2006-04-29 12:39:21 -07:00
|
|
|
if ((x == xid->x) && (y == xid->y))
|
|
|
|
return;
|
|
|
|
|
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
XMoveWindow(disp, Xwin(win), x, y);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EResizeWindow(Win win, int w, int h)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
if ((w == xid->w) && (h == xid->h))
|
|
|
|
return;
|
|
|
|
|
|
|
|
xid->w = w;
|
|
|
|
xid->h = h;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
XResizeWindow(disp, Xwin(win), w, h);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EMoveResizeWindow(Win win, int x, int y, int w, int h)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
|
|
|
Eprintf("EMoveResizeWindow: %p %#lx: %d,%d %dx%d -> %d,%d %dx%d\n",
|
|
|
|
xid, xid->win, xid->x, xid->y, xid->w, xid->h, x, y, w, h);
|
|
|
|
#endif
|
2006-04-29 12:39:21 -07:00
|
|
|
if ((w == xid->w) && (h == xid->h) && (x == xid->x) && (y == xid->y))
|
|
|
|
return;
|
|
|
|
|
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
|
|
|
xid->w = w;
|
|
|
|
xid->h = h;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
XMoveResizeWindow(disp, Xwin(win), x, y, w, h);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2005-06-30 05:57:34 -07:00
|
|
|
static int
|
|
|
|
ExDelTree(EXID * xid)
|
|
|
|
{
|
|
|
|
Window win;
|
|
|
|
int nsub;
|
|
|
|
|
|
|
|
xid->do_del = -1;
|
|
|
|
|
|
|
|
nsub = 0;
|
|
|
|
win = xid->win;
|
|
|
|
for (xid = xid_first; xid; xid = xid->next)
|
|
|
|
{
|
|
|
|
if (xid->parent != win)
|
|
|
|
continue;
|
|
|
|
ExDelTree(xid);
|
|
|
|
nsub++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsub;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ExDestroyWindow(EXID * xid)
|
|
|
|
{
|
|
|
|
EXID *next;
|
|
|
|
int nsub;
|
|
|
|
|
|
|
|
#if DEBUG_XWIN
|
|
|
|
Eprintf("ExDestroyWindow: %p %#lx\n", xid, xid->win);
|
|
|
|
#endif
|
|
|
|
if (xid->parent != None)
|
|
|
|
XDestroyWindow(disp, xid->win);
|
|
|
|
|
|
|
|
/* Mark the ones to be deleted */
|
|
|
|
nsub = ExDelTree(xid);
|
|
|
|
if (nsub == 0)
|
|
|
|
{
|
|
|
|
/* No children */
|
|
|
|
EXidDel(xid);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete entire tree */
|
|
|
|
for (xid = xid_first; xid; xid = next)
|
|
|
|
{
|
|
|
|
next = xid->next;
|
|
|
|
if (xid->do_del < 0)
|
|
|
|
EXidDel(xid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EDestroyWindow(Win win)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2005-06-30 05:57:34 -07:00
|
|
|
ExDestroyWindow(xid);
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
2006-04-29 12:39:21 -07:00
|
|
|
XDestroyWindow(disp, Xwin(win));
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2003-07-12 00:52:03 -07:00
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EWindowSync(Win win)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
Window rr;
|
|
|
|
int x, y;
|
|
|
|
unsigned int w, h, bw, depth;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
|
|
|
if (!xid)
|
|
|
|
return;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
XGetGeometry(disp, Xwin(win), &rr, &x, &y, &w, &h, &bw, &depth);
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
|
|
|
Eprintf("EWindowSync: %p %#lx: %d,%d %dx%d -> %d,%d %dx%d\n",
|
|
|
|
xid, xid->win, xid->x, xid->y, xid->w, xid->h, x, y, w, h);
|
|
|
|
#endif
|
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
|
|
|
xid->w = w;
|
|
|
|
xid->h = h;
|
|
|
|
xid->depth = depth;
|
|
|
|
}
|
|
|
|
|
2005-05-28 04:43:57 -07:00
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EWindowSetMapped(Win win, int mapped)
|
2005-05-28 04:43:57 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
|
|
|
if (!xid)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xid->mapped = mapped;
|
|
|
|
}
|
|
|
|
|
|
|
|
Window
|
2006-04-29 12:39:21 -07:00
|
|
|
EXWindowGetParent(Window xwin)
|
2005-05-28 04:43:57 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
Window parent, rt;
|
|
|
|
Window *pch = NULL;
|
|
|
|
unsigned int nch = 0;
|
|
|
|
|
|
|
|
parent = None;
|
2006-04-29 12:39:21 -07:00
|
|
|
if (!XQueryTree(disp, xwin, &rt, &parent, &pch, &nch))
|
2005-05-28 04:43:57 -07:00
|
|
|
parent = None;
|
|
|
|
else if (pch)
|
|
|
|
XFree(pch);
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
xid = EXidLookup(xwin);
|
2005-05-28 04:43:57 -07:00
|
|
|
if (xid)
|
|
|
|
xid->parent = parent;
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
#if USE_NEW_WIN_API
|
|
|
|
Win
|
|
|
|
ECreateWinFromXwin(Window xwin)
|
|
|
|
{
|
|
|
|
Win win;
|
|
|
|
Window rr;
|
|
|
|
int x, y;
|
|
|
|
unsigned int w, h, bw, depth;
|
|
|
|
|
|
|
|
if (!XGetGeometry(disp, xwin, &rr, &x, &y, &w, &h, &bw, &depth))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
win = EXidCreate();
|
|
|
|
if (!win)
|
|
|
|
return NULL;
|
|
|
|
win->win = xwin;
|
|
|
|
win->x = x;
|
|
|
|
win->y = y;
|
|
|
|
win->w = w;
|
|
|
|
win->h = h;
|
|
|
|
win->depth = depth;
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Win
|
|
|
|
ERegisterWindow(Window xwin)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
EXID *xid;
|
|
|
|
Window rr;
|
|
|
|
int x, y;
|
|
|
|
unsigned int w, h, bw, depth;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
xid = EXidLookup(xwin);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (xid)
|
2006-04-29 12:39:21 -07:00
|
|
|
goto done;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
XGetGeometry(disp, xwin, &rr, &x, &y, &w, &h, &bw, &depth);
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
|
|
|
Eprintf("ERegisterWindow %#lx %d+%d %dx%d\n", win, x, y, w, h);
|
|
|
|
#endif
|
2006-04-29 12:39:21 -07:00
|
|
|
xid = EXidSet(xwin, None, x, y, w, h, depth);
|
2004-12-28 15:46:49 -08:00
|
|
|
xid->attached = 1;
|
2006-04-29 12:39:21 -07:00
|
|
|
|
|
|
|
done:
|
|
|
|
#if USE_NEW_WIN_API
|
|
|
|
return xid;
|
|
|
|
#else
|
|
|
|
return xwin;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EUnregisterXwin(Window xwin)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
|
|
|
xid = EXidLookup(xwin);
|
|
|
|
if (xid)
|
|
|
|
EXidDel(xid); /* FIXME - We shouldn't go here */
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EUnregisterWindow(Win win)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-06-30 05:57:34 -07:00
|
|
|
EXID *xid;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
|
|
|
if (xid)
|
|
|
|
EXidDel(xid);
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EMapWindow(Win win)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
if (xid->mapped)
|
|
|
|
return;
|
|
|
|
xid->mapped = 1;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
XMapWindow(disp, Xwin(win));
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EUnmapWindow(Win win)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
if (!xid->mapped)
|
|
|
|
return;
|
|
|
|
xid->mapped = 0;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
XUnmapWindow(disp, Xwin(win));
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EReparentWindow(Win win, Win parent, int x, int y)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
2005-01-23 10:23:04 -08:00
|
|
|
Eprintf
|
|
|
|
("EReparentWindow: %p %#lx: %d %#lx->%#lx %d,%d %dx%d -> %d,%d\n",
|
|
|
|
xid, xid->win, xid->mapped, xid->parent, parent, xid->x, xid->y,
|
|
|
|
xid->w, xid->h, x, y);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2006-04-29 12:39:21 -07:00
|
|
|
if (Xwin(parent) == xid->parent)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
|
|
|
if ((x != xid->x) || (y != xid->y))
|
|
|
|
{
|
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
2006-04-29 12:39:21 -07:00
|
|
|
XMoveWindow(disp, Xwin(win), x, y);
|
|
|
|
return;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
xid->parent = Xwin(parent);
|
2003-05-22 12:15:03 -07:00
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
XReparentWindow(disp, Xwin(win), Xwin(parent), x, y);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EMapRaised(Win win)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if (xid->mapped)
|
2006-04-29 12:39:21 -07:00
|
|
|
{
|
|
|
|
XRaiseWindow(disp, Xwin(win));
|
|
|
|
return;
|
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
xid->mapped = 1;
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
XMapRaised(disp, Xwin(win));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
EXGetGeometry(Drawable draw, Window * root_return, int *x, int *y,
|
|
|
|
int *w, int *h, int *bw, int *depth)
|
|
|
|
{
|
|
|
|
int ok;
|
|
|
|
Window rr;
|
|
|
|
int xx, yy;
|
|
|
|
unsigned int ww, hh, bb, dd;
|
|
|
|
|
|
|
|
ok = XGetGeometry(disp, draw, &rr, &xx, &yy, &ww, &hh, &bb, &dd);
|
|
|
|
if (!ok)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (root_return)
|
|
|
|
*root_return = rr;
|
|
|
|
if (x)
|
|
|
|
*x = xx;
|
|
|
|
if (y)
|
|
|
|
*y = yy;
|
|
|
|
if (w)
|
|
|
|
*w = ww;
|
|
|
|
if (h)
|
|
|
|
*h = hh;
|
|
|
|
if (bw)
|
|
|
|
*bw = bb;
|
|
|
|
if (depth)
|
|
|
|
*depth = dd;
|
|
|
|
|
|
|
|
done:
|
|
|
|
#if 0 /* Debug */
|
|
|
|
if (!ok)
|
|
|
|
Eprintf("EGetGeometry win=%#x, error %d\n", (unsigned)win, ok);
|
|
|
|
#endif
|
|
|
|
return ok;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-04-29 12:39:21 -07:00
|
|
|
EGetGeometry(Win win, Window * root_return, int *x, int *y,
|
2005-04-23 01:28:04 -07:00
|
|
|
int *w, int *h, int *bw, int *depth)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2003-09-28 12:21:34 -07:00
|
|
|
int ok;
|
1999-08-17 15:56:46 -07:00
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if (x)
|
|
|
|
*x = xid->x;
|
|
|
|
if (y)
|
|
|
|
*y = xid->y;
|
|
|
|
if (w)
|
|
|
|
*w = xid->w;
|
|
|
|
if (h)
|
|
|
|
*h = xid->h;
|
|
|
|
if (bw)
|
|
|
|
*bw = 0;
|
|
|
|
if (depth)
|
|
|
|
*depth = xid->depth;
|
|
|
|
if (root_return)
|
2006-04-29 12:39:21 -07:00
|
|
|
*root_return = VRoot.xwin;
|
2003-09-28 12:21:34 -07:00
|
|
|
ok = 1;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2003-09-28 12:21:34 -07:00
|
|
|
else
|
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
ok = EXGetGeometry(Xwin(win), root_return, x, y, w, h, bw, depth);
|
2003-09-28 12:21:34 -07:00
|
|
|
}
|
|
|
|
return ok;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EConfigureWindow(Win win, unsigned int mask, XWindowChanges * wc)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
char doit = 0;
|
|
|
|
|
|
|
|
if ((mask & CWX) && (wc->x != xid->x))
|
|
|
|
{
|
|
|
|
xid->x = wc->x;
|
|
|
|
doit = 1;
|
|
|
|
}
|
|
|
|
if ((mask & CWY) && (wc->y != xid->y))
|
|
|
|
{
|
|
|
|
xid->y = wc->y;
|
|
|
|
doit = 1;
|
|
|
|
}
|
|
|
|
if ((mask & CWWidth) && (wc->width != xid->w))
|
|
|
|
{
|
|
|
|
xid->w = wc->width;
|
|
|
|
doit = 1;
|
|
|
|
}
|
|
|
|
if ((mask & CWHeight) && (wc->height != xid->h))
|
|
|
|
{
|
|
|
|
xid->h = wc->height;
|
|
|
|
doit = 1;
|
|
|
|
}
|
|
|
|
if ((doit) || (mask & (CWBorderWidth | CWSibling | CWStackMode)))
|
2006-04-29 12:39:21 -07:00
|
|
|
XConfigureWindow(disp, Xwin(win), mask, wc);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
XConfigureWindow(disp, Xwin(win), mask, wc);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
ESetWindowBackgroundPixmap(Win win, Pixmap pmap)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
xid->bgpmap = pmap;
|
2005-12-06 15:43:11 -08:00
|
|
|
xid->bgcol = 0xffffffff; /* Hmmm.. */
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
XSetWindowBackgroundPixmap(disp, Xwin(win), pmap);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
ESetWindowBackground(Win win, int col)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
1999-08-17 15:56:46 -07:00
|
|
|
if (xid)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if (xid->bgpmap)
|
|
|
|
{
|
|
|
|
xid->bgpmap = 0;
|
|
|
|
xid->bgcol = col;
|
|
|
|
}
|
|
|
|
else if (xid->bgcol != col)
|
|
|
|
{
|
|
|
|
xid->bgcol = col;
|
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
else
|
|
|
|
return;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
XSetWindowBackground(disp, Xwin(win), col);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 07:05:25 -07:00
|
|
|
int
|
2006-04-29 12:39:21 -07:00
|
|
|
ETranslateCoordinates(Win src_w, Win dst_w,
|
2005-07-10 07:05:25 -07:00
|
|
|
int src_x, int src_y,
|
|
|
|
int *dest_x_return,
|
|
|
|
int *dest_y_return, Window * child_return)
|
|
|
|
{
|
|
|
|
Window child;
|
|
|
|
|
|
|
|
if (!child_return)
|
|
|
|
child_return = &child;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
return XTranslateCoordinates(disp, Xwin(src_w), Xwin(dst_w), src_x, src_y,
|
2005-07-10 07:05:25 -07:00
|
|
|
dest_x_return, dest_y_return, child_return);
|
|
|
|
}
|
|
|
|
|
2005-08-07 13:33:21 -07:00
|
|
|
void
|
2006-04-23 16:18:23 -07:00
|
|
|
EXWarpPointer(Window xwin, int x, int y)
|
2005-08-07 13:33:21 -07:00
|
|
|
{
|
2006-04-23 16:18:23 -07:00
|
|
|
XWarpPointer(disp, None, xwin, 0, 0, 0, 0, x, y);
|
2005-08-07 13:33:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2006-04-23 16:18:23 -07:00
|
|
|
EXQueryPointer(Window xwin, int *px, int *py, Window * pchild,
|
|
|
|
unsigned int *pmask)
|
2005-08-07 13:33:21 -07:00
|
|
|
{
|
|
|
|
Window root, child;
|
|
|
|
int root_x, root_y;
|
|
|
|
unsigned int mask;
|
|
|
|
|
2006-04-24 09:06:05 -07:00
|
|
|
if (xwin == None)
|
2006-04-29 12:39:21 -07:00
|
|
|
xwin = VRoot.xwin;
|
2006-04-24 09:06:05 -07:00
|
|
|
|
2005-08-07 13:33:21 -07:00
|
|
|
if (!px)
|
|
|
|
px = &root_x;
|
|
|
|
if (!py)
|
|
|
|
py = &root_y;
|
|
|
|
if (!pchild)
|
|
|
|
pchild = &child;
|
|
|
|
if (!pmask)
|
|
|
|
pmask = &mask;
|
|
|
|
|
2006-04-23 16:18:23 -07:00
|
|
|
return XQueryPointer(disp, xwin, &root, pchild, &root_x, &root_y, px, py,
|
2005-08-07 13:33:21 -07:00
|
|
|
pmask);
|
|
|
|
}
|
|
|
|
|
2005-03-02 11:20:27 -08:00
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
ESelectInputAdd(Win win, long mask)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2005-03-02 11:20:27 -08:00
|
|
|
XWindowAttributes xwa;
|
2003-07-12 00:52:03 -07:00
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
XGetWindowAttributes(disp, Xwin(win), &xwa);
|
2005-03-02 11:20:27 -08:00
|
|
|
xwa.your_event_mask |= mask;
|
2006-04-29 12:39:21 -07:00
|
|
|
XSelectInput(disp, Xwin(win), xwa.your_event_mask);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2005-11-20 14:47:41 -08:00
|
|
|
int
|
|
|
|
EDrawableCheck(Drawable draw, int grab)
|
|
|
|
{
|
|
|
|
int ok;
|
|
|
|
|
2006-02-27 11:14:25 -08:00
|
|
|
if (draw == None)
|
|
|
|
return 0;
|
|
|
|
|
2005-11-20 14:47:41 -08:00
|
|
|
if (grab)
|
|
|
|
EGrabServer();
|
|
|
|
|
2006-04-23 15:11:26 -07:00
|
|
|
ok = EXGetGeometry(draw, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
2005-11-20 14:47:41 -08:00
|
|
|
|
|
|
|
if (grab && !ok)
|
|
|
|
EUngrabServer();
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2005-05-21 13:58:18 -07:00
|
|
|
#define DEBUG_SHAPE_OPS 0
|
|
|
|
#define DEBUG_SHAPE_PROPAGATE 0
|
|
|
|
|
|
|
|
#if DEBUG_SHAPE_OPS
|
|
|
|
static void
|
|
|
|
EShapeShow(const char *txt, XRectangle * pr, int nr)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
Eprintf("%s nr=%d\n", txt, nr);
|
|
|
|
for (i = 0; i < nr; i++)
|
|
|
|
Eprintf(" %d - %4d,%4d %4dx%4d\n", i,
|
|
|
|
pr[i].x, pr[i].y, pr[i].width, pr[i].height);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
2005-06-12 09:06:41 -07:00
|
|
|
ExShapeUpdate(EXID * xid)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
|
|
|
if (xid->rects)
|
|
|
|
{
|
|
|
|
XFree(xid->rects);
|
|
|
|
xid->num_rect = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
xid->rects =
|
|
|
|
XShapeGetRectangles(disp, xid->win, ShapeBounding, &(xid->num_rect),
|
|
|
|
&(xid->ord));
|
|
|
|
if (xid->rects)
|
|
|
|
{
|
|
|
|
if (xid->num_rect == 1)
|
|
|
|
{
|
|
|
|
if ((xid->rects[0].x == 0) && (xid->rects[0].y == 0)
|
|
|
|
&& (xid->rects[0].width == xid->w)
|
|
|
|
&& (xid->rects[0].height == xid->h))
|
|
|
|
{
|
|
|
|
xid->num_rect = 0;
|
|
|
|
XFree(xid->rects);
|
|
|
|
xid->rects = NULL;
|
2005-10-15 13:27:32 -07:00
|
|
|
XShapeCombineMask(disp, xid->win, ShapeBounding, 0, 0,
|
|
|
|
None, ShapeSet);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
}
|
2005-06-12 09:06:41 -07:00
|
|
|
else if (xid->num_rect > 4096)
|
|
|
|
{
|
|
|
|
Eprintf("*** ExShapeUpdate: nrect=%d - Not likely, ignoring.\n",
|
|
|
|
xid->num_rect);
|
|
|
|
XShapeCombineMask(disp, xid->win, ShapeBounding, 0, 0, None,
|
|
|
|
ShapeSet);
|
|
|
|
xid->num_rect = 0;
|
|
|
|
XFree(xid->rects);
|
|
|
|
xid->rects = NULL;
|
|
|
|
}
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xid->num_rect = -1;
|
|
|
|
}
|
|
|
|
#if DEBUG_SHAPE_OPS
|
2005-06-12 09:06:41 -07:00
|
|
|
EShapeShow("ExShapeUpdate", xid->rects, xid->num_rect);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
static void
|
|
|
|
ExShapeCombineMask(EXID * xid, int dest, int x, int y, Pixmap pmap, int op)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
char wasshaped = 0;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
if (xid->rects)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
xid->num_rect = 0;
|
|
|
|
XFree(xid->rects);
|
|
|
|
xid->rects = NULL;
|
|
|
|
wasshaped = 1;
|
|
|
|
}
|
2005-05-21 13:58:18 -07:00
|
|
|
#if DEBUG_SHAPE_OPS
|
2005-10-15 13:27:32 -07:00
|
|
|
Eprintf("ExShapeCombineMask %#lx %d,%d %dx%d mask=%#lx wassh=%d\n",
|
|
|
|
xid->win, xid->x, xid->y, xid->w, xid->h, pmap, wasshaped);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
2005-06-12 09:06:41 -07:00
|
|
|
if (pmap)
|
|
|
|
{
|
|
|
|
XShapeCombineMask(disp, xid->win, dest, x, y, pmap, op);
|
|
|
|
ExShapeUpdate(xid);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
2005-06-12 09:06:41 -07:00
|
|
|
else if (wasshaped)
|
|
|
|
XShapeCombineMask(disp, xid->win, dest, x, y, pmap, op);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EShapeCombineMaskTiled(Win win, int dest, int x, int y,
|
2005-05-21 13:58:18 -07:00
|
|
|
Pixmap pmap, int op, int w, int h)
|
|
|
|
{
|
|
|
|
XGCValues gcv;
|
|
|
|
GC gc;
|
|
|
|
Window tm;
|
|
|
|
|
|
|
|
gcv.fill_style = FillTiled;
|
|
|
|
gcv.tile = pmap;
|
|
|
|
gcv.ts_x_origin = 0;
|
|
|
|
gcv.ts_y_origin = 0;
|
|
|
|
tm = ECreatePixmap(win, w, h, 1);
|
2006-04-17 14:55:34 -07:00
|
|
|
gc = EXCreateGC(tm, GCFillStyle | GCTile |
|
|
|
|
GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
|
2005-05-21 13:58:18 -07:00
|
|
|
XFillRectangle(disp, tm, gc, 0, 0, w, h);
|
2006-04-17 14:55:34 -07:00
|
|
|
EXFreeGC(gc);
|
2005-05-21 13:58:18 -07:00
|
|
|
EShapeCombineMask(win, dest, x, y, tm, op);
|
|
|
|
EFreePixmap(tm);
|
|
|
|
}
|
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
static void
|
|
|
|
ExShapeCombineRectangles(EXID * xid, int dest, int x, int y,
|
|
|
|
XRectangle * rect, int n_rects, int op, int ordering)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
|
|
|
#if DEBUG_SHAPE_OPS
|
2005-06-12 09:06:41 -07:00
|
|
|
Eprintf("ExShapeCombineRectangles %#lx %d\n", xid->win, n_rects);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
if (n_rects == 1 && op == ShapeSet)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
if ((rect[0].x == 0) && (rect[0].y == 0) &&
|
|
|
|
(rect[0].width == xid->w) && (rect[0].height == xid->h))
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
xid->num_rect = 0;
|
|
|
|
XFree(xid->rects);
|
|
|
|
xid->rects = NULL;
|
|
|
|
XShapeCombineMask(disp, xid->win, dest, x, y, None, op);
|
|
|
|
return;
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
}
|
2005-06-12 09:06:41 -07:00
|
|
|
XShapeCombineRectangles(disp, xid->win, dest, x, y, rect, n_rects, op,
|
|
|
|
ordering);
|
|
|
|
if (n_rects > 1)
|
|
|
|
{
|
|
|
|
/* Limit shape to window extents */
|
|
|
|
XRectangle r;
|
|
|
|
|
|
|
|
r.x = r.y = 0;
|
|
|
|
r.width = xid->w;
|
|
|
|
r.height = xid->h;
|
|
|
|
XShapeCombineRectangles(disp, xid->win, ShapeBounding, 0, 0, &r,
|
|
|
|
1, ShapeIntersect, Unsorted);
|
|
|
|
}
|
|
|
|
ExShapeUpdate(xid);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
static void
|
|
|
|
ExShapeCombineShape(EXID * xdst, int dest, int x, int y,
|
|
|
|
EXID * xsrc, int src_kind, int op)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
XShapeCombineShape(disp, xdst->win, dest, x, y, xsrc->win, src_kind, op);
|
|
|
|
ExShapeUpdate(xdst);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
XRectangle *
|
2006-04-29 12:39:21 -07:00
|
|
|
EShapeGetRectangles(Win win, int dest, int *rn, int *ord)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
|
|
|
if (xid && !xid->attached)
|
|
|
|
{
|
|
|
|
XRectangle *r;
|
|
|
|
|
|
|
|
#if DEBUG_SHAPE_OPS
|
|
|
|
Eprintf("EShapeGetRectangles-A %#lx nr=%d\n", win, xid->num_rect);
|
|
|
|
#endif
|
|
|
|
*rn = xid->num_rect;
|
|
|
|
*ord = xid->ord;
|
|
|
|
if (xid->num_rect > 0)
|
|
|
|
{
|
|
|
|
r = Emalloc(sizeof(XRectangle) * xid->num_rect);
|
2005-10-30 11:40:49 -08:00
|
|
|
if (!r)
|
|
|
|
return NULL;
|
2005-05-21 13:58:18 -07:00
|
|
|
memcpy(r, xid->rects, sizeof(XRectangle) * xid->num_rect);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XRectangle *r, *rr;
|
|
|
|
|
|
|
|
#if DEBUG_SHAPE_OPS
|
|
|
|
Eprintf("EShapeGetRectangles-B %#lx nr=%d\n", win, xid->num_rect);
|
|
|
|
#endif
|
2006-04-29 12:39:21 -07:00
|
|
|
r = XShapeGetRectangles(disp, Xwin(win), dest, rn, ord);
|
2005-05-21 13:58:18 -07:00
|
|
|
if (r)
|
|
|
|
{
|
|
|
|
rr = Emalloc(sizeof(XRectangle) * *rn);
|
2005-10-30 11:40:49 -08:00
|
|
|
if (!rr)
|
|
|
|
return NULL;
|
2005-05-21 13:58:18 -07:00
|
|
|
memcpy(rr, r, sizeof(XRectangle) * *rn);
|
|
|
|
XFree(r);
|
|
|
|
return rr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
static int
|
|
|
|
ExShapeCopy(EXID * xdst, EXID * xsrc)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
|
|
|
XRectangle *rl;
|
2005-06-12 09:06:41 -07:00
|
|
|
int rn;
|
|
|
|
|
|
|
|
if (xsrc->attached)
|
|
|
|
ExShapeUpdate(xsrc);
|
2005-05-21 13:58:18 -07:00
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
rn = xsrc->num_rect;
|
|
|
|
rl = xsrc->rects;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
|
|
|
if (rn < 0)
|
|
|
|
{
|
|
|
|
/* Source has empty shape */
|
2005-06-12 09:06:41 -07:00
|
|
|
ExShapeCombineShape(xdst, ShapeBounding, 0, 0,
|
|
|
|
xsrc, ShapeBounding, ShapeSet);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
else if (rn == 0)
|
|
|
|
{
|
|
|
|
/* Source has default shape (no shape) */
|
2005-06-12 09:06:41 -07:00
|
|
|
ExShapeCombineMask(xdst, ShapeBounding, 0, 0, None, ShapeSet);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
else if (rn == 1)
|
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
if ((rl[0].x <= 0) && (rl[0].y <= 0) && (rl[0].width >= xsrc->w)
|
|
|
|
&& (rl[0].height >= xsrc->h))
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
|
|
|
rn = 0;
|
2005-06-12 09:06:41 -07:00
|
|
|
ExShapeCombineMask(xdst, ShapeBounding, 0, 0, None, ShapeSet);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
ExShapeCombineShape(xdst, ShapeBounding, 0, 0,
|
|
|
|
xsrc, ShapeBounding, ShapeSet);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
ExShapeCombineShape(xdst, ShapeBounding, 0, 0,
|
|
|
|
xsrc, ShapeBounding, ShapeSet);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return rn != 0;
|
|
|
|
}
|
|
|
|
|
2006-01-22 10:25:41 -08:00
|
|
|
static int
|
2005-06-12 09:06:41 -07:00
|
|
|
ExShapePropagate(EXID * xid)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
EXID *xch;
|
2005-05-21 13:58:18 -07:00
|
|
|
Window rt, par, *list = NULL;
|
|
|
|
unsigned int i, num, num_rects;
|
2005-06-12 09:06:41 -07:00
|
|
|
int k, rn;
|
|
|
|
int x, y, w, h;
|
2005-05-21 13:58:18 -07:00
|
|
|
XRectangle *rects, *rl;
|
|
|
|
XWindowAttributes att;
|
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
if (!xid || xid->w <= 0 || xid->h <= 0)
|
2006-01-22 10:25:41 -08:00
|
|
|
return 0;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
|
|
|
#if DEBUG_SHAPE_PROPAGATE
|
2005-06-12 09:06:41 -07:00
|
|
|
Eprintf("ExShapePropagate %#lx %d,%d %dx%d\n", win, xid->x, xid->y, xid->w,
|
|
|
|
xid->h);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
XQueryTree(disp, xid->win, &rt, &par, &list, &num);
|
2005-05-21 13:58:18 -07:00
|
|
|
if (!list)
|
2006-01-22 10:25:41 -08:00
|
|
|
return 0;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
|
|
|
num_rects = 0;
|
|
|
|
rects = NULL;
|
|
|
|
|
|
|
|
/* go through all child windows and create/inset spans */
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
xch = EXidLookup(list[i]);
|
2005-06-12 09:06:41 -07:00
|
|
|
if (!xch)
|
|
|
|
continue; /* Should never happen */
|
2005-05-21 13:58:18 -07:00
|
|
|
XGetWindowAttributes(disp, list[i], &att);
|
|
|
|
#if DEBUG_SHAPE_PROPAGATE > 1
|
|
|
|
Eprintf("%3d %#lx(%d): %4d,%4d %4dx%4d\n", i, list[i], att.map_state,
|
|
|
|
att.x, att.y, att.width, att.height);
|
|
|
|
#endif
|
|
|
|
if ((att.class != InputOutput) || (att.map_state == IsUnmapped))
|
|
|
|
continue;
|
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
x = xch->x;
|
|
|
|
y = xch->y;
|
|
|
|
w = xch->w;
|
|
|
|
h = xch->h;
|
|
|
|
if (x >= xid->w || y >= xid->h || x + w < 0 || y + h < 0)
|
2005-05-21 13:58:18 -07:00
|
|
|
continue;
|
|
|
|
|
2005-06-12 09:06:41 -07:00
|
|
|
rn = xch->num_rect;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
|
|
|
if (rn > 0)
|
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
rl = xch->rects;
|
2005-05-21 13:58:18 -07:00
|
|
|
rects = Erealloc(rects, (num_rects + rn) * sizeof(XRectangle));
|
|
|
|
/* go through all clip rects in thsi window's shape */
|
|
|
|
for (k = 0; k < rn; k++)
|
|
|
|
{
|
|
|
|
/* for each clip rect, add it to the rect list */
|
|
|
|
rects[num_rects + k].x = x + rl[k].x;
|
|
|
|
rects[num_rects + k].y = y + rl[k].y;
|
|
|
|
rects[num_rects + k].width = rl[k].width;
|
|
|
|
rects[num_rects + k].height = rl[k].height;
|
|
|
|
#if DEBUG_SHAPE_PROPAGATE > 1
|
|
|
|
Eprintf(" - %d: %4d,%4d %4dx%4d\n", k,
|
|
|
|
rects[num_rects + k].x,
|
|
|
|
rects[num_rects + k].y, rects[num_rects + k].width,
|
|
|
|
rects[num_rects + k].height);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
num_rects += rn;
|
|
|
|
}
|
|
|
|
else if (rn == 0)
|
|
|
|
{
|
|
|
|
/* Unshaped */
|
|
|
|
rects = Erealloc(rects, (num_rects + 1) * sizeof(XRectangle));
|
|
|
|
|
|
|
|
rects[num_rects].x = x;
|
|
|
|
rects[num_rects].y = y;
|
|
|
|
rects[num_rects].width = w;
|
|
|
|
rects[num_rects].height = h;
|
|
|
|
num_rects++;
|
|
|
|
}
|
|
|
|
}
|
2005-06-12 09:06:41 -07:00
|
|
|
XFree(list);
|
2005-05-21 13:58:18 -07:00
|
|
|
|
|
|
|
#if DEBUG_SHAPE_PROPAGATE > 1
|
2005-06-12 09:06:41 -07:00
|
|
|
Eprintf("ExShapePropagate %#lx nr=%d\n", win, num_rects);
|
2005-05-21 13:58:18 -07:00
|
|
|
for (i = 0; i < num_rects; i++)
|
|
|
|
Eprintf("%3d %4d,%4d %4dx%4d\n", i, rects[i].x, rects[i].y,
|
|
|
|
rects[i].width, rects[i].height);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* set the rects as the shape mask */
|
|
|
|
if (rects)
|
|
|
|
{
|
2005-06-12 09:06:41 -07:00
|
|
|
ExShapeCombineRectangles(xid, ShapeBounding, 0, 0, rects,
|
|
|
|
num_rects, ShapeSet, Unsorted);
|
2005-05-21 13:58:18 -07:00
|
|
|
Efree(rects);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Empty shape */
|
2005-06-12 09:06:41 -07:00
|
|
|
ExShapeCombineRectangles(xid, ShapeBounding, 0, 0, NULL, 0, ShapeSet,
|
|
|
|
Unsorted);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
2006-01-22 10:25:41 -08:00
|
|
|
|
|
|
|
return xid->num_rect;
|
2005-06-12 09:06:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EShapeCombineMask(Win win, int dest, int x, int y, Pixmap pmap, int op)
|
2005-06-12 09:06:41 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
|
|
|
if (xid)
|
|
|
|
ExShapeCombineMask(xid, dest, x, y, pmap, op);
|
|
|
|
else
|
2006-04-29 12:39:21 -07:00
|
|
|
XShapeCombineMask(disp, Xwin(win), dest, x, y, pmap, op);
|
2005-06-12 09:06:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EShapeCombineRectangles(Win win, int dest, int x, int y,
|
2005-06-12 09:06:41 -07:00
|
|
|
XRectangle * rect, int n_rects, int op, int ordering)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
|
|
|
if (xid)
|
|
|
|
ExShapeCombineRectangles(xid, dest, x, y, rect, n_rects, op, ordering);
|
|
|
|
else
|
2006-04-29 12:39:21 -07:00
|
|
|
XShapeCombineRectangles(disp, Xwin(win), dest, x, y, rect, n_rects, op,
|
2005-06-12 09:06:41 -07:00
|
|
|
ordering);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
EShapeCombineShape(Win win, int dest, int x, int y,
|
|
|
|
Win src_win, int src_kind, int op)
|
2005-06-12 09:06:41 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
XShapeCombineShape(disp, Xwin(win), dest, x, y, Xwin(src_win), src_kind, op);
|
2005-06-12 09:06:41 -07:00
|
|
|
xid = EXidFind(win);
|
|
|
|
if (xid)
|
|
|
|
ExShapeUpdate(xid);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-04-29 12:39:21 -07:00
|
|
|
EShapeCopy(Win dst, Win src)
|
2005-06-12 09:06:41 -07:00
|
|
|
{
|
|
|
|
EXID *xsrc, *xdst;
|
|
|
|
|
|
|
|
xsrc = EXidFind(src);
|
|
|
|
xdst = EXidFind(dst);
|
|
|
|
if (!xsrc || !xdst)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return ExShapeCopy(xdst, xsrc);
|
|
|
|
}
|
|
|
|
|
2006-01-22 10:25:41 -08:00
|
|
|
int
|
2006-04-29 12:39:21 -07:00
|
|
|
EShapePropagate(Win win)
|
2005-06-12 09:06:41 -07:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
2006-01-22 10:25:41 -08:00
|
|
|
|
|
|
|
return ExShapePropagate(xid);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-04-29 12:39:21 -07:00
|
|
|
EShapeCheck(Win win)
|
2006-01-22 10:25:41 -08:00
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
|
|
|
|
|
|
|
return xid->num_rect;
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
2005-10-16 09:27:48 -07:00
|
|
|
Pixmap
|
2006-04-25 15:40:06 -07:00
|
|
|
EXCreatePixmapCopy(Pixmap src, unsigned int w, unsigned int h,
|
|
|
|
unsigned int depth)
|
2005-10-16 09:27:48 -07:00
|
|
|
{
|
|
|
|
Pixmap pmap;
|
|
|
|
GC gc;
|
|
|
|
|
2006-04-25 15:40:06 -07:00
|
|
|
pmap = EXCreatePixmap(src, w, h, depth);
|
2006-04-17 14:55:34 -07:00
|
|
|
gc = EXCreateGC(src, 0, NULL);
|
2005-10-16 09:27:48 -07:00
|
|
|
XCopyArea(disp, src, pmap, gc, 0, 0, w, h, 0, 0);
|
2006-04-17 14:55:34 -07:00
|
|
|
EXFreeGC(gc);
|
2005-10-16 09:27:48 -07:00
|
|
|
|
|
|
|
return pmap;
|
|
|
|
}
|
|
|
|
|
2006-04-17 01:43:09 -07:00
|
|
|
void
|
2006-04-25 15:40:06 -07:00
|
|
|
EXCopyArea(Drawable src, Drawable dst, int sx, int sy, unsigned int w,
|
|
|
|
unsigned int h, int dx, int dy)
|
2006-04-17 01:43:09 -07:00
|
|
|
{
|
|
|
|
GC gc;
|
|
|
|
|
2006-04-17 14:55:34 -07:00
|
|
|
gc = EXCreateGC(src, 0, NULL);
|
2006-04-17 01:43:09 -07:00
|
|
|
XCopyArea(disp, src, dst, gc, sx, sy, w, h, dx, dy);
|
2006-04-17 14:55:34 -07:00
|
|
|
EXFreeGC(gc);
|
2006-04-17 01:43:09 -07:00
|
|
|
}
|
|
|
|
|
2005-03-02 11:20:27 -08:00
|
|
|
GC
|
2006-04-17 14:55:34 -07:00
|
|
|
EXCreateGC(Drawable draw, unsigned long mask, XGCValues * val)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2005-03-02 11:20:27 -08:00
|
|
|
XGCValues xgcv;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-03-02 11:20:27 -08:00
|
|
|
if (val)
|
|
|
|
{
|
|
|
|
mask |= GCGraphicsExposures;
|
|
|
|
val->graphics_exposures = False;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mask = GCGraphicsExposures;
|
|
|
|
val = &xgcv;
|
|
|
|
val->graphics_exposures = False;
|
|
|
|
}
|
2006-04-17 14:55:34 -07:00
|
|
|
return XCreateGC(disp, draw, mask, val);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2005-03-02 11:20:27 -08:00
|
|
|
int
|
2006-04-17 14:55:34 -07:00
|
|
|
EXFreeGC(GC gc)
|
2005-02-12 15:48:02 -08:00
|
|
|
{
|
2005-03-02 11:20:27 -08:00
|
|
|
return XFreeGC(disp, gc);
|
2005-02-12 15:48:02 -08:00
|
|
|
}
|
|
|
|
|
2004-04-24 06:16:38 -07:00
|
|
|
void
|
|
|
|
ESetColor(XColor * pxc, int r, int g, int b)
|
|
|
|
{
|
|
|
|
pxc->red = (r << 8) | r;
|
|
|
|
pxc->green = (g << 8) | g;
|
|
|
|
pxc->blue = (b << 8) | b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-12-28 15:46:49 -08:00
|
|
|
EGetColor(const XColor * pxc, int *pr, int *pg, int *pb)
|
2004-04-24 06:16:38 -07:00
|
|
|
{
|
|
|
|
*pr = pxc->red >> 8;
|
|
|
|
*pg = pxc->green >> 8;
|
|
|
|
*pb = pxc->blue >> 8;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Build mask from window shape rects */
|
|
|
|
/* Snatched from imlib_create_scaled_image_from_drawable() */
|
|
|
|
Pixmap
|
2006-04-29 12:39:21 -07:00
|
|
|
EWindowGetShapePixmap(Win win)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
Pixmap mask;
|
|
|
|
GC gc;
|
|
|
|
XRectangle *rect;
|
|
|
|
int i, w, h;
|
|
|
|
int rect_num, rect_ord;
|
|
|
|
|
2005-03-06 13:29:46 -08:00
|
|
|
EGetGeometry(win, NULL, NULL, NULL, &w, &h, NULL, NULL);
|
2005-02-22 13:45:25 -08:00
|
|
|
mask = ECreatePixmap(win, w, h, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-04-25 15:40:06 -07:00
|
|
|
gc = EXCreateGC(mask, 0, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
XSetForeground(disp, gc, 0);
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
rect =
|
|
|
|
XShapeGetRectangles(disp, Xwin(win), ShapeBounding, &rect_num, &rect_ord);
|
2004-12-28 15:46:49 -08:00
|
|
|
XFillRectangle(disp, mask, gc, 0, 0, w, h);
|
|
|
|
if (rect)
|
|
|
|
{
|
|
|
|
XSetForeground(disp, gc, 1);
|
|
|
|
for (i = 0; i < rect_num; i++)
|
|
|
|
XFillRectangle(disp, mask, gc, rect[i].x, rect[i].y,
|
|
|
|
rect[i].width, rect[i].height);
|
|
|
|
XFree(rect);
|
|
|
|
}
|
|
|
|
|
2006-04-25 15:40:06 -07:00
|
|
|
EXFreeGC(gc);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
2005-05-07 04:20:02 -07:00
|
|
|
EGrabServer(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2005-08-15 09:57:13 -07:00
|
|
|
if (Mode.grabs.server_grabbed <= 0)
|
2005-08-27 07:11:17 -07:00
|
|
|
{
|
|
|
|
if (EventDebug(EDBUG_TYPE_GRABS))
|
|
|
|
Eprintf("EGrabServer\n");
|
|
|
|
XGrabServer(disp);
|
|
|
|
}
|
2005-08-15 09:57:13 -07:00
|
|
|
Mode.grabs.server_grabbed++;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-05-07 04:20:02 -07:00
|
|
|
EUngrabServer(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2005-08-15 09:57:13 -07:00
|
|
|
if (Mode.grabs.server_grabbed == 1)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
XUngrabServer(disp);
|
|
|
|
XFlush(disp);
|
2005-08-27 07:11:17 -07:00
|
|
|
if (EventDebug(EDBUG_TYPE_GRABS))
|
|
|
|
Eprintf("EUngrabServer\n");
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2005-08-15 09:57:13 -07:00
|
|
|
Mode.grabs.server_grabbed--;
|
|
|
|
if (Mode.grabs.server_grabbed < 0)
|
|
|
|
Mode.grabs.server_grabbed = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
2005-05-07 04:20:02 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
EServerIsGrabbed(void)
|
|
|
|
{
|
2005-08-15 09:57:13 -07:00
|
|
|
return Mode.grabs.server_grabbed;
|
2005-05-07 04:20:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EFlush(void)
|
|
|
|
{
|
|
|
|
XFlush(disp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ESync(void)
|
|
|
|
{
|
|
|
|
XSync(disp, False);
|
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Display *
|
2005-04-07 09:38:57 -07:00
|
|
|
EDisplayOpen(const char *dstr, int scr)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
char dbuf[256], *s;
|
2004-12-28 15:46:49 -08:00
|
|
|
Display *dpy;
|
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
if (scr >= 0)
|
|
|
|
{
|
|
|
|
/* Override screen */
|
|
|
|
Esnprintf(dbuf, sizeof(dbuf) - 10, dstr);
|
|
|
|
s = strchr(dbuf, ':');
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
s = strchr(s, '.');
|
|
|
|
if (s)
|
|
|
|
*s = '\0';
|
|
|
|
}
|
|
|
|
Esnprintf(dbuf + strlen(dbuf), 10, ".%d", scr);
|
|
|
|
dstr = dbuf;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
#ifdef USE_ECORE_X
|
|
|
|
ecore_x_init(dstr);
|
|
|
|
dpy = ecore_x_display_get();
|
|
|
|
#else
|
|
|
|
dpy = XOpenDisplay(dstr);
|
|
|
|
#endif
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
return dpy;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-12-28 15:46:49 -08:00
|
|
|
EDisplayClose(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!disp)
|
|
|
|
return;
|
|
|
|
#ifdef USE_ECORE_X
|
|
|
|
ecore_x_shutdown();
|
|
|
|
#else
|
|
|
|
XCloseDisplay(disp);
|
|
|
|
#endif
|
|
|
|
XSetErrorHandler((XErrorHandler) NULL);
|
|
|
|
XSetIOErrorHandler((XIOErrorHandler) NULL);
|
|
|
|
disp = NULL;
|
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
void
|
|
|
|
EDisplayDisconnect(void)
|
|
|
|
{
|
|
|
|
if (!disp)
|
|
|
|
return;
|
|
|
|
#ifdef USE_ECORE_X
|
|
|
|
ecore_x_disconnect();
|
|
|
|
#else
|
|
|
|
close(ConnectionNumber(disp));
|
|
|
|
#endif
|
|
|
|
XSetErrorHandler((XErrorHandler) NULL);
|
|
|
|
XSetIOErrorHandler((XIOErrorHandler) NULL);
|
|
|
|
|
|
|
|
disp = NULL;
|
|
|
|
}
|
|
|
|
|
2005-05-12 12:02:15 -07:00
|
|
|
Time
|
|
|
|
EGetTimestamp(void)
|
|
|
|
{
|
|
|
|
static Window win_ts = None;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
XEvent ev;
|
|
|
|
|
|
|
|
if (win_ts == None)
|
|
|
|
{
|
2005-08-07 03:51:07 -07:00
|
|
|
attr.override_redirect = False;
|
2006-04-29 12:39:21 -07:00
|
|
|
win_ts = XCreateWindow(disp, VRoot.xwin, -100, -100, 1, 1, 0,
|
2005-05-12 12:02:15 -07:00
|
|
|
CopyFromParent, InputOnly, CopyFromParent,
|
|
|
|
CWOverrideRedirect, &attr);
|
|
|
|
XSelectInput(disp, win_ts, PropertyChangeMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
XChangeProperty(disp, win_ts, XA_WM_NAME, XA_STRING, 8,
|
|
|
|
PropModeAppend, (unsigned char *)"", 0);
|
|
|
|
XWindowEvent(disp, win_ts, PropertyChangeMask, &ev);
|
|
|
|
|
|
|
|
return ev.xproperty.time;
|
|
|
|
}
|