1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2004-01-19 14:30:35 -08:00
|
|
|
* Copyright (C) 2000-2004 Carsten Haitzler, Geoff Harrison and various contributors
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xresource.h>
|
|
|
|
|
2004-05-31 13:03:06 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
EventCallbackFunc *func;
|
|
|
|
void *prm;
|
|
|
|
} EventCallbackItem;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int num;
|
|
|
|
EventCallbackItem *lst;
|
|
|
|
} EventCallbackList;
|
|
|
|
|
2003-07-12 00:52:03 -07:00
|
|
|
typedef struct _exid
|
|
|
|
{
|
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;
|
|
|
|
char do_del;
|
|
|
|
char attached;
|
2003-07-12 00:52:03 -07:00
|
|
|
int num_rect;
|
|
|
|
int ord;
|
|
|
|
XRectangle *rects;
|
|
|
|
int depth;
|
|
|
|
Pixmap bgpmap;
|
|
|
|
int bgcol;
|
2004-05-31 13:03:06 -07:00
|
|
|
} EXID;
|
2003-07-12 00:52:03 -07:00
|
|
|
|
|
|
|
static XContext xid_context = 0;
|
|
|
|
|
|
|
|
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));
|
2003-07-12 00:52:03 -07:00
|
|
|
|
|
|
|
return xid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-12-28 15:46:49 -08:00
|
|
|
EXidDestroy(EXID * xid)
|
|
|
|
{
|
|
|
|
if (xid->rects)
|
|
|
|
XFree(xid->rects);
|
|
|
|
#if 0
|
|
|
|
Eprintf("EXidDestroy: %p %#lx\n", xid, xid->win);
|
|
|
|
#endif
|
|
|
|
if (xid->cbl.lst)
|
|
|
|
Efree(xid->cbl.lst);
|
|
|
|
Efree(xid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
EXidAdd(EXID * xid)
|
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);
|
|
|
|
AddItem(xid, "", xid->win, LIST_TYPE_XID);
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
EXidDelete(Window win)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2003-12-11 13:13:50 -08:00
|
|
|
EXID *xid;
|
2003-07-12 00:52:03 -07:00
|
|
|
|
|
|
|
if (xid_context == 0)
|
|
|
|
xid_context = XUniqueContext();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
xid = RemoveItem("", win, LIST_FINDBY_ID, LIST_TYPE_XID);
|
|
|
|
if (!xid)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
Eprintf("EXidDelete: %p %#lx\n", xid, xid->win);
|
|
|
|
#endif
|
|
|
|
XDeleteContext(disp, win, xid_context);
|
|
|
|
if (xid->in_use)
|
|
|
|
xid->do_del = 1;
|
|
|
|
else
|
|
|
|
EXidDestroy(xid);
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static EXID *
|
|
|
|
EXidFind(Window win)
|
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
|
|
|
|
|
|
|
if (xid_context == 0)
|
|
|
|
xid_context = XUniqueContext();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
xp = NULL;
|
|
|
|
if (XFindContext(disp, win, xid_context, &xp) == XCNOENT)
|
|
|
|
xp = NULL;
|
|
|
|
xid = (EXID *) xp;
|
|
|
|
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;
|
|
|
|
#if 0
|
|
|
|
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
|
|
|
|
EventCallbackRegister(Window win, int type __UNUSED__, EventCallbackFunc * func,
|
|
|
|
void *prm)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
EventCallbackItem *eci;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
|
|
|
if (!xid)
|
|
|
|
ERegisterWindow(win);
|
|
|
|
xid = EXidFind(win);
|
|
|
|
#if 0
|
|
|
|
Eprintf("EventCallbackRegister: %p %#lx\n", xid, win);
|
|
|
|
#endif
|
|
|
|
if (!xid)
|
|
|
|
{
|
|
|
|
Eprintf("EventCallbackRegister win=%#lx ???\n", win);
|
|
|
|
return;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Not used/tested */
|
2004-05-31 13:03:06 -07:00
|
|
|
void
|
|
|
|
EventCallbackUnregister(Window win, int type __UNUSED__,
|
|
|
|
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
|
|
|
|
EventCallbacksProcess(XEvent * ev)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
EventCallbackList *ecl;
|
|
|
|
EventCallbackItem *eci;
|
|
|
|
int i;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(ev->xany.window);
|
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);
|
|
|
|
eci->func(ev, eci->prm);
|
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
|
|
|
}
|
|
|
|
|
2003-03-27 21:16:21 -08:00
|
|
|
Window
|
|
|
|
ECreateWindow(Window parent, int x, int y, int w, int h, int saveunder)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
Window win;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
EDBUG(6, "ECreateWindow");
|
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.override_redirect = True;
|
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;
|
2004-12-28 15:46:49 -08:00
|
|
|
win = XCreateWindow(disp, parent, x, y, w, h, 0, VRoot.depth, InputOutput,
|
|
|
|
VRoot.vis,
|
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixmap | CWBorderPixel, &attr);
|
|
|
|
EXidSet(win, parent, x, y, w, h, VRoot.depth);
|
2003-07-12 00:52:03 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-12-28 15:46:49 -08:00
|
|
|
EMoveWindow(Display * d __UNUSED__, Window 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
|
2003-05-22 12:15:03 -07:00
|
|
|
if ((x != xid->x) || (y != xid->y))
|
|
|
|
{
|
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_window_move(win, x, y);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_window_move(win, x, y);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-12-28 15:46:49 -08:00
|
|
|
EResizeWindow(Display * d __UNUSED__, Window 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
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
if ((w != xid->w) || (h != xid->h))
|
|
|
|
{
|
|
|
|
xid->w = w;
|
|
|
|
xid->h = h;
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_window_resize(win, w, h);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_window_resize(win, w, h);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-12-28 15:46:49 -08:00
|
|
|
EMoveResizeWindow(Display * d __UNUSED__, Window 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
|
2003-05-22 12:15:03 -07:00
|
|
|
if ((w != xid->w) || (h != xid->h) || (x != xid->x) || (y != xid->y))
|
|
|
|
{
|
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
|
|
|
xid->w = w;
|
|
|
|
xid->h = h;
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_window_move_resize(win, x, y, w, h);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_window_move_resize(win, x, y, w, h);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EDestroyWindow(Display * d, Window win)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0 /* FIXME */
|
2004-01-09 01:11:33 -08:00
|
|
|
SlideoutsHideIfContextWin(win);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2004-01-09 01:11:33 -08:00
|
|
|
|
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
|
|
|
EXID **lst;
|
|
|
|
int i, num;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
EXidDelete(win);
|
2003-05-22 12:15:03 -07:00
|
|
|
XDestroyWindow(d, win);
|
|
|
|
lst = (EXID **) ListItemType(&num, LIST_TYPE_XID);
|
|
|
|
if (lst)
|
|
|
|
{
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (lst[i]->parent == win)
|
|
|
|
EDestroyWindow(d, lst[i]->win);
|
|
|
|
}
|
|
|
|
Efree(lst);
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
|
|
|
XDestroyWindow(d, win);
|
|
|
|
}
|
|
|
|
|
2003-07-12 00:52:03 -07:00
|
|
|
void
|
2004-12-28 15:46:49 -08:00
|
|
|
EWindowSync(Window win)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
Window rr;
|
|
|
|
int x, y;
|
|
|
|
unsigned int w, h, bw, depth;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
|
|
|
if (!xid)
|
|
|
|
return;
|
|
|
|
|
|
|
|
XGetGeometry(disp, win, &rr, &x, &y, &w, &h, &bw, &depth);
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ERegisterWindow(Window win)
|
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;
|
|
|
|
|
|
|
|
xid = EXidFind(win);
|
|
|
|
if (xid)
|
|
|
|
return;
|
|
|
|
|
|
|
|
XGetGeometry(disp, win, &rr, &x, &y, &w, &h, &bw, &depth);
|
|
|
|
#if 0
|
|
|
|
Eprintf("ERegisterWindow %#lx %d+%d %dx%d\n", win, x, y, w, h);
|
|
|
|
#endif
|
|
|
|
xid = EXidSet(win, None, x, y, w, h, depth);
|
|
|
|
xid->attached = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EUnregisterWindow(Window win)
|
|
|
|
{
|
|
|
|
EXidDelete(win);
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
|
|
|
EMapWindow(Display * d, Window win)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
xid->mapped = 1;
|
|
|
|
XMapWindow(d, win);
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
|
|
|
XMapWindow(d, win);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EUnmapWindow(Display * d, Window win)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
xid->mapped = 0;
|
|
|
|
XUnmapWindow(d, win);
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
|
|
|
XUnmapWindow(d, win);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-06-04 12:45:55 -07:00
|
|
|
EShapeCombineMask(Display * d, Window win, int dest, int x, int y, Pixmap pmap,
|
2003-05-22 12:15:03 -07:00
|
|
|
int op)
|
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 wasshaped = 0;
|
|
|
|
|
|
|
|
if (xid->rects)
|
|
|
|
{
|
|
|
|
xid->num_rect = 0;
|
|
|
|
XFree(xid->rects);
|
|
|
|
xid->rects = NULL;
|
|
|
|
wasshaped = 1;
|
|
|
|
}
|
|
|
|
if (pmap)
|
|
|
|
{
|
|
|
|
XShapeCombineMask(d, win, dest, x, y, pmap, op);
|
|
|
|
xid->rects =
|
|
|
|
XShapeGetRectangles(d, win, dest, &(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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((!pmap) && (wasshaped))
|
|
|
|
XShapeCombineMask(d, win, dest, x, y, pmap, op);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
|
|
|
XShapeCombineMask(d, win, dest, x, y, pmap, op);
|
|
|
|
}
|
|
|
|
|
2003-12-28 09:57:31 -08:00
|
|
|
void
|
|
|
|
EShapeCombineMaskTiled(Display * d, Window win, int dest, int x, int y,
|
|
|
|
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;
|
2004-12-28 15:46:49 -08:00
|
|
|
tm = ecore_x_pixmap_new(win, w, h, 1);
|
|
|
|
gc = XCreateGC(d, tm, GCFillStyle | GCTile |
|
2003-12-28 09:57:31 -08:00
|
|
|
GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
|
2004-12-28 15:46:49 -08:00
|
|
|
XFillRectangle(d, tm, gc, 0, 0, w, h);
|
|
|
|
XFreeGC(d, gc);
|
|
|
|
EShapeCombineMask(d, win, dest, x, y, tm, op);
|
|
|
|
ecore_x_pixmap_del(tm);
|
2003-12-28 09:57:31 -08:00
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
|
|
|
EShapeCombineRectangles(Display * d, Window win, int dest, int x, int y,
|
2003-05-22 12:15:03 -07:00
|
|
|
XRectangle * rect, int n_rects, int op, int ordering)
|
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 (n_rects == 1)
|
|
|
|
{
|
|
|
|
if ((rect[0].x == 0) && (rect[0].y == 0)
|
|
|
|
&& (rect[0].width == xid->w) && (rect[0].height == xid->h))
|
|
|
|
{
|
|
|
|
xid->num_rect = 0;
|
|
|
|
XFree(xid->rects);
|
|
|
|
xid->rects = NULL;
|
|
|
|
XShapeCombineMask(d, win, dest, x, y, None, op);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xid->num_rect = 0;
|
|
|
|
if (xid->rects)
|
|
|
|
XFree(xid->rects);
|
|
|
|
XShapeCombineRectangles(d, win, dest, x, y, rect, n_rects, op,
|
|
|
|
ordering);
|
|
|
|
xid->rects =
|
|
|
|
XShapeGetRectangles(d, win, dest, &(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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
|
|
|
XShapeCombineRectangles(d, win, dest, x, y, rect, n_rects, op, ordering);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EShapeCombineShape(Display * d, Window win, int dest, int x, int y,
|
2003-05-22 12:15:03 -07:00
|
|
|
Window src_win, int src_kind, int op)
|
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->num_rect = 0;
|
|
|
|
if (xid->rects)
|
|
|
|
XFree(xid->rects);
|
|
|
|
XShapeCombineShape(d, win, dest, x, y, src_win, src_kind, op);
|
|
|
|
xid->rects =
|
|
|
|
XShapeGetRectangles(d, win, dest, &(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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
|
|
|
XShapeCombineShape(d, win, dest, x, y, src_win, src_kind, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
XRectangle *
|
|
|
|
EShapeGetRectangles(Display * d, Window win, int dest, int *rn, int *ord)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
|
|
|
if (xid && !xid->attached)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
XRectangle *r;
|
|
|
|
|
|
|
|
*rn = xid->num_rect;
|
|
|
|
*ord = xid->ord;
|
|
|
|
if (xid->num_rect > 0)
|
|
|
|
{
|
|
|
|
r = Emalloc(sizeof(XRectangle) * xid->num_rect);
|
|
|
|
memcpy(r, xid->rects, sizeof(XRectangle) * xid->num_rect);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
XRectangle *r, *rr;
|
|
|
|
|
|
|
|
r = XShapeGetRectangles(d, win, dest, rn, ord);
|
|
|
|
if (r)
|
|
|
|
{
|
|
|
|
rr = Emalloc(sizeof(XRectangle) * *rn);
|
|
|
|
memcpy(rr, r, sizeof(XRectangle) * *rn);
|
|
|
|
XFree(r);
|
|
|
|
return rr;
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EReparentWindow(Display * d, Window win, Window parent, int x, int y)
|
|
|
|
{
|
|
|
|
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
|
2003-05-22 12:15:03 -07:00
|
|
|
if (parent == xid->parent)
|
|
|
|
{
|
|
|
|
if ((x != xid->x) || (y != xid->y))
|
|
|
|
{
|
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_window_move(win, x, y);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xid->parent = parent;
|
|
|
|
xid->x = x;
|
|
|
|
xid->y = y;
|
|
|
|
XReparentWindow(d, win, parent, x, y);
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
|
|
|
XReparentWindow(d, win, parent, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EMapRaised(Display * d, Window win)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
XRaiseWindow(d, win);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xid->mapped = 1;
|
|
|
|
XMapRaised(d, win);
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
|
|
|
XMapRaised(d, win);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
EGetGeometry(Display * d, Window win, Window * root_return, int *x, int *y,
|
2003-05-22 12:15:03 -07:00
|
|
|
unsigned int *w, unsigned int *h, unsigned int *bw,
|
|
|
|
unsigned 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)
|
2004-05-04 12:04:42 -07:00
|
|
|
*root_return = VRoot.win;
|
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
|
|
|
|
{
|
|
|
|
ok = XGetGeometry(d, win, root_return, x, y, w, h, bw, depth);
|
|
|
|
}
|
2004-03-14 01:03:26 -08:00
|
|
|
#if 0 /* Debug */
|
2003-09-28 12:21:34 -07:00
|
|
|
if (!ok)
|
2004-04-08 05:54:46 -07:00
|
|
|
Eprintf("EGetGeometry win=%#x, error %d\n", (unsigned)win, ok);
|
2003-09-28 12:21:34 -07:00
|
|
|
#endif
|
|
|
|
return ok;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EConfigureWindow(Display * d, Window win, unsigned int mask,
|
2003-05-22 12:15:03 -07:00
|
|
|
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)))
|
|
|
|
XConfigureWindow(d, 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
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
XConfigureWindow(d, win, mask, wc);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ESetWindowBackgroundPixmap(Display * d, Window win, Pixmap pmap)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
XSetWindowBackgroundPixmap(d, win, pmap);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-27 21:46:04 -07:00
|
|
|
else
|
|
|
|
XSetWindowBackgroundPixmap(d, win, pmap);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ESetWindowBackground(Display * d, Window win, int col)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
XSetWindowBackground(d, win, col);
|
|
|
|
}
|
|
|
|
else if (xid->bgcol != col)
|
|
|
|
{
|
|
|
|
xid->bgcol = col;
|
|
|
|
XSetWindowBackground(d, win, col);
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
else
|
1999-08-27 22:55:20 -07:00
|
|
|
XSetWindowBackground(d, win, col);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2003-03-27 21:16:21 -08:00
|
|
|
Window
|
|
|
|
ECreateEventWindow(Window parent, int x, int y, int w, int h)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
Window win;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
EDBUG(6, "ECreateEventWindow");
|
|
|
|
attr.override_redirect = False;
|
2004-12-28 15:46:49 -08:00
|
|
|
win = XCreateWindow(disp, parent, x, y, w, h, 0, 0, InputOnly, VRoot.vis,
|
|
|
|
CWOverrideRedirect, &attr);
|
|
|
|
EXidSet(win, parent, x, y, w, h, VRoot.depth);
|
2003-07-12 00:52:03 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* create a window which will accept the keyboard focus when no other
|
|
|
|
* windows have it
|
|
|
|
*/
|
2003-03-27 21:16:21 -08:00
|
|
|
Window
|
|
|
|
ECreateFocusWindow(Window parent, int x, int y, int w, int h)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
Window win;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
EDBUG(6, "ECreateFocusWindow");
|
|
|
|
|
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.override_redirect = True;
|
2004-05-04 12:04:42 -07:00
|
|
|
attr.colormap = VRoot.cmap;
|
1999-08-17 15:56:46 -07:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.event_mask = KeyPressMask | FocusChangeMask;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
win = XCreateWindow(disp, parent, x, y, w, h, 0, 0, InputOnly,
|
|
|
|
CopyFromParent,
|
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel | CWEventMask,
|
|
|
|
&attr);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
XSetWindowBackground(disp, win, 0);
|
|
|
|
XMapWindow(disp, win);
|
|
|
|
XSetInputFocus(disp, win, RevertToParent, CurrentTime);
|
|
|
|
|
|
|
|
EDBUG_RETURN(win);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
EWindowGetShapePixmap(Window win)
|
|
|
|
{
|
|
|
|
Pixmap mask;
|
|
|
|
GC gc;
|
|
|
|
XRectangle *rect;
|
|
|
|
int i, w, h;
|
|
|
|
int rect_num, rect_ord;
|
|
|
|
|
|
|
|
GetWinWH(win, &w, &h);
|
|
|
|
mask = ecore_x_pixmap_new(win, w, h, 1);
|
|
|
|
|
|
|
|
gc = XCreateGC(disp, mask, 0, NULL);
|
|
|
|
XSetForeground(disp, gc, 0);
|
|
|
|
|
|
|
|
rect = XShapeGetRectangles(disp, win, ShapeBounding, &rect_num, &rect_ord);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
XFreeGC(disp, gc);
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef USE_ECORE_X
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_grab(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-03-20 07:49:05 -08:00
|
|
|
if (Mode.server_grabbed <= 0)
|
1999-08-17 15:56:46 -07:00
|
|
|
XGrabServer(disp);
|
2004-03-20 07:49:05 -08:00
|
|
|
Mode.server_grabbed++;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_ungrab(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-03-20 07:49:05 -08:00
|
|
|
if (Mode.server_grabbed == 1)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
XUngrabServer(disp);
|
|
|
|
XFlush(disp);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-03-20 07:49:05 -08:00
|
|
|
Mode.server_grabbed--;
|
|
|
|
if (Mode.server_grabbed < 0)
|
|
|
|
Mode.server_grabbed = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
GetWinXY(Window win, int *x, int *y)
|
|
|
|
{
|
|
|
|
Window w1;
|
|
|
|
unsigned int w, h, b, d;
|
|
|
|
|
|
|
|
EDBUG(7, "GetWinXY");
|
|
|
|
EGetGeometry(disp, win, &w1, x, y, &w, &h, &b, &d);
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
2004-04-04 14:30:59 -07:00
|
|
|
Window
|
|
|
|
GetWinParent(Window win)
|
|
|
|
{
|
|
|
|
EXID *xid;
|
|
|
|
|
|
|
|
EDBUG(7, "GetWinParent");
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
xid = EXidFind(win);
|
2004-04-04 14:30:59 -07:00
|
|
|
if (xid)
|
|
|
|
return xid->parent;
|
|
|
|
|
|
|
|
EDBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
|
|
|
GetWinWH(Window win, unsigned int *w, unsigned int *h)
|
|
|
|
{
|
|
|
|
Window w1;
|
|
|
|
int x, y;
|
|
|
|
unsigned int b, d;
|
|
|
|
|
|
|
|
EDBUG(7, "GetWinWH");
|
|
|
|
EGetGeometry(disp, win, &w1, &x, &y, w, h, &b, &d);
|
|
|
|
EDBUG_RETURN_;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
GetWinDepth(Window win)
|
|
|
|
{
|
|
|
|
Window w1;
|
|
|
|
unsigned int w, h, b, d;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
EDBUG(7, "GetWinDepth");
|
|
|
|
EGetGeometry(disp, win, &w1, &x, &y, &w, &h, &b, &d);
|
|
|
|
EDBUG_RETURN(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
WinExists(Window win)
|
|
|
|
{
|
|
|
|
Window w1;
|
|
|
|
int x, y;
|
|
|
|
unsigned int w, h;
|
|
|
|
unsigned int b, d;
|
|
|
|
|
|
|
|
EDBUG(7, "WinExists");
|
|
|
|
if (EGetGeometry(disp, win, &w1, &x, &y, &w, &h, &b, &d))
|
|
|
|
EDBUG_RETURN(1);
|
|
|
|
EDBUG_RETURN(0);
|
|
|
|
}
|
|
|
|
|
2005-01-23 10:23:04 -08:00
|
|
|
Window
|
|
|
|
WinGetParent(Window win)
|
|
|
|
{
|
|
|
|
Window parent, rt;
|
|
|
|
Window *pch = NULL;
|
|
|
|
unsigned int nch = 0;
|
|
|
|
|
|
|
|
if (!XQueryTree(disp, win, &rt, &parent, &pch, &nch))
|
|
|
|
return None;
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2003-03-27 21:16:21 -08:00
|
|
|
Window
|
|
|
|
WindowAtXY_0(Window base, int bx, int by, int x, int y)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
Window *list = NULL;
|
|
|
|
XWindowAttributes att;
|
|
|
|
Window child = 0, parent_win = 0, root_win = 0;
|
|
|
|
int i;
|
|
|
|
unsigned int ww, wh, num;
|
|
|
|
int wx, wy;
|
|
|
|
|
|
|
|
EDBUG(7, "WindowAtXY_0");
|
|
|
|
if (!XGetWindowAttributes(disp, base, &att))
|
|
|
|
EDBUG_RETURN(0);
|
|
|
|
if (att.class == InputOnly)
|
|
|
|
EDBUG_RETURN(0);
|
1999-09-07 11:18:16 -07:00
|
|
|
if (att.map_state != IsViewable)
|
|
|
|
EDBUG_RETURN(0);
|
1999-08-17 15:56:46 -07:00
|
|
|
wx = att.x;
|
|
|
|
wy = att.y;
|
|
|
|
ww = att.width;
|
|
|
|
wh = att.height;
|
|
|
|
|
|
|
|
wx += bx;
|
|
|
|
wy += by;
|
|
|
|
|
2000-07-28 10:23:35 -07:00
|
|
|
if (!((x >= wx) && (y >= wy) && (x < (int)(wx + ww))
|
2003-05-22 12:15:03 -07:00
|
|
|
&& (y < (int)(wy + wh))))
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN(0);
|
|
|
|
|
|
|
|
if (!XQueryTree(disp, base, &root_win, &parent_win, &list, &num))
|
|
|
|
EDBUG_RETURN(base);
|
|
|
|
if (list)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
for (i = num - 1;; i--)
|
|
|
|
{
|
|
|
|
if ((child = WindowAtXY_0(list[i], wx, wy, x, y)) != 0)
|
|
|
|
{
|
|
|
|
XFree(list);
|
|
|
|
EDBUG_RETURN(child);
|
|
|
|
}
|
|
|
|
if (!i)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
XFree(list);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
EDBUG_RETURN(base);
|
|
|
|
}
|
|
|
|
|
2003-03-27 21:16:21 -08:00
|
|
|
Window
|
|
|
|
WindowAtXY(int x, int y)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
Window *list = NULL;
|
|
|
|
Window child = 0, parent_win = 0, root_win = 0;
|
|
|
|
unsigned int num;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
EDBUG(7, "WindowAtXY");
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_grab();
|
2004-05-04 12:04:42 -07:00
|
|
|
if (!XQueryTree(disp, VRoot.win, &root_win, &parent_win, &list, &num))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_ungrab();
|
2004-05-04 12:04:42 -07:00
|
|
|
EDBUG_RETURN(VRoot.win);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
if (list)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
i = num - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
XWindowAttributes xwa;
|
|
|
|
|
|
|
|
XGetWindowAttributes(disp, list[i], &xwa);
|
|
|
|
if (xwa.map_state != IsViewable)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((child = WindowAtXY_0(list[i], 0, 0, x, y)) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
XFree(list);
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_ungrab();
|
2003-05-22 12:15:03 -07:00
|
|
|
EDBUG_RETURN(child);
|
|
|
|
}
|
|
|
|
while (--i > 0);
|
|
|
|
XFree(list);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
ecore_x_ungrab();
|
2004-05-04 12:04:42 -07:00
|
|
|
EDBUG_RETURN(VRoot.win);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2005-01-02 07:38:52 -08:00
|
|
|
Bool
|
1999-08-17 15:56:46 -07:00
|
|
|
PointerAt(int *x, int *y)
|
|
|
|
{
|
|
|
|
Window dw;
|
|
|
|
int dd;
|
|
|
|
unsigned int mm;
|
|
|
|
|
2005-01-02 07:38:52 -08:00
|
|
|
if (!x || !y)
|
|
|
|
x = y = ⅆ
|
|
|
|
|
|
|
|
/* Return True if pointer is on "our" screen */
|
|
|
|
return XQueryPointer(disp, VRoot.win, &dw, &dw, &dd, &dd, x, y, &mm);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Display *
|
|
|
|
EDisplayOpen(const char *dstr)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
Display *dpy;
|
|
|
|
|
|
|
|
if (!dstr)
|
|
|
|
dstr = getenv("DISPLAY");
|
|
|
|
if (!dstr)
|
|
|
|
dstr = ":0";
|
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EDrawableDumpImage(Drawable draw, const char *txt)
|
|
|
|
{
|
|
|
|
static int seqn = 0;
|
|
|
|
char buf[1024];
|
|
|
|
Imlib_Image *im;
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
w = h = 0;
|
|
|
|
GetWinWH(draw, &w, &h);
|
|
|
|
if (w <= 0 || h <= 0)
|
|
|
|
return;
|
|
|
|
imlib_context_set_drawable(draw);
|
|
|
|
im = imlib_create_image_from_drawable(None, 0, 0, w, h, 1);
|
|
|
|
imlib_context_set_image(im);
|
|
|
|
imlib_image_set_format("png");
|
|
|
|
sprintf(buf, "%s-%#lx-%d", txt, draw, seqn++);
|
|
|
|
Eprintf("EDrawableDumpImage: %s\n", buf);
|
|
|
|
imlib_save_image(buf);
|
|
|
|
imlib_free_image_and_decache();
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|