1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2007-01-13 11:14:29 -08:00
|
|
|
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
2015-01-17 12:07:31 -08:00
|
|
|
* Copyright (C) 2004-2023 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.
|
|
|
|
*/
|
2015-01-15 22:25:38 -08:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-06-28 11:54:59 -07:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2006-03-19 06:59:48 -08:00
|
|
|
#include <X11/Xatom.h>
|
2015-01-15 22:25:38 -08:00
|
|
|
#include <X11/Xlib.h>
|
1999-08-17 15:56:46 -07:00
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xresource.h>
|
2008-06-05 01:55:21 -07:00
|
|
|
#include <X11/extensions/shape.h>
|
2009-08-18 10:27:08 -07:00
|
|
|
#if USE_XRENDER
|
2006-06-01 13:18:40 -07:00
|
|
|
#include <X11/extensions/Xrender.h>
|
2014-11-09 05:58:23 -08:00
|
|
|
#define RENDER_VERSION VERS(RENDER_MAJOR, RENDER_MINOR)
|
2006-06-01 13:18:40 -07:00
|
|
|
#endif
|
2022-12-21 11:05:56 -08:00
|
|
|
#if USE_COMPOSITE
|
|
|
|
#include <X11/extensions/Xcomposite.h>
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
#endif
|
2009-12-26 02:35:42 -08:00
|
|
|
#if USE_XI2
|
2013-12-28 04:07:33 -08:00
|
|
|
#include <X11/extensions/XInput2.h>
|
2009-12-26 02:35:42 -08:00
|
|
|
#endif
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2015-01-15 22:25:38 -08:00
|
|
|
#include "E.h"
|
|
|
|
#include "edebug.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "xwin.h"
|
|
|
|
#if USE_GLX
|
|
|
|
#include "eglx.h"
|
|
|
|
#endif
|
|
|
|
|
2007-09-10 13:13:59 -07:00
|
|
|
#define DEBUG_XWIN 0
|
|
|
|
#define DEBUG_PIXMAP 0
|
2005-06-30 05:57:34 -07:00
|
|
|
|
2021-01-09 00:45:09 -08:00
|
|
|
__EXPORT__ EDisplay Dpy;
|
|
|
|
__EXPORT__ Display *disp;
|
2008-03-29 03:48:45 -07:00
|
|
|
|
2020-12-08 08:58:48 -08:00
|
|
|
#if USE_XRENDER
|
2023-10-21 02:04:12 -07:00
|
|
|
static Visual *argb_visual = NULL;
|
|
|
|
static EX_Colormap argb_cmap = NoXID;
|
2006-06-03 07:11:34 -07:00
|
|
|
#endif
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
static XContext xid_context = 0;
|
2003-07-12 00:52:03 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
static Win win_first = NULL;
|
|
|
|
static Win win_last = NULL;
|
2005-06-30 05:57:34 -07:00
|
|
|
|
2007-05-25 15:40:47 -07:00
|
|
|
#define WinBgInvalidate(win) if (win->bg_owned > 0) win->bg_owned = -1
|
|
|
|
|
2008-03-29 10:18:58 -07:00
|
|
|
void
|
|
|
|
EXInit(void)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
memset(&Dpy, 0, sizeof(Dpy));
|
2008-03-29 10:18:58 -07:00
|
|
|
}
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
static Win
|
2012-12-24 03:05:48 -08:00
|
|
|
_EXidCreate(void)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win win;
|
2003-07-12 00:52:03 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win = ECALLOC(struct _xwin, 1);
|
2003-07-12 00:52:03 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win->bgcol = 0xffffffff;
|
2007-05-07 16:47:48 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win;
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-24 03:05:48 -08:00
|
|
|
_EXidDestroy(Win win)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-06-30 05:57:34 -07:00
|
|
|
#if DEBUG_XWIN
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x\n", __func__, win, win->xwin);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->rects)
|
|
|
|
XFree(win->rects);
|
|
|
|
Efree(win->cbl.lst);
|
|
|
|
Efree(win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-24 03:05:48 -08:00
|
|
|
_EXidAdd(Win win)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2005-06-30 05:57:34 -07:00
|
|
|
#if DEBUG_XWIN
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x\n", __func__, win, win->xwin);
|
2005-06-30 05:57:34 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!xid_context)
|
|
|
|
xid_context = XUniqueContext();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XSaveContext(disp, win->xwin, xid_context, (XPointer) win);
|
2005-06-30 05:57:34 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win_first)
|
|
|
|
{
|
|
|
|
win_first = win_last = win;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
win->prev = win_last;
|
|
|
|
win_last->next = win;
|
|
|
|
win_last = win;
|
|
|
|
}
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2012-12-24 03:05:48 -08:00
|
|
|
_EXidDel(Win win)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2005-06-30 05:57:34 -07:00
|
|
|
#if DEBUG_XWIN
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x\n", __func__, win, win->xwin);
|
2005-06-04 01:29:55 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win == win_first)
|
|
|
|
{
|
|
|
|
if (win == win_last)
|
|
|
|
{
|
|
|
|
win_first = win_last = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
win_first = win->next;
|
|
|
|
win->next->prev = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (win == win_last)
|
|
|
|
{
|
|
|
|
win_last = win->prev;
|
|
|
|
win->prev->next = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
win->prev->next = win->next;
|
|
|
|
win->next->prev = win->prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
XDeleteContext(disp, win->xwin, xid_context);
|
|
|
|
if (win->in_use)
|
|
|
|
win->do_del = 1;
|
|
|
|
else
|
|
|
|
_EXidDestroy(win);
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
#define EXidLookup ELookupXwin
|
2006-05-07 08:08:01 -07:00
|
|
|
|
2007-05-07 16:47:48 -07:00
|
|
|
Win
|
2009-12-03 11:29:30 -08:00
|
|
|
EXidLookup(EX_Window xwin)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win win;
|
2003-07-12 00:52:03 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!xid_context)
|
|
|
|
return NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win = NULL;
|
|
|
|
if (XFindContext(disp, xwin, xid_context, (XPointer *) & win) == XCNOENT)
|
|
|
|
win = NULL;
|
2005-06-04 01:29:55 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win;
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
static Win
|
2009-12-03 11:29:30 -08:00
|
|
|
_EXidSet(EX_Window xwin, Win parent, int x, int y, int w, int h, int depth,
|
2023-10-21 02:04:12 -07:00
|
|
|
Visual *visual, EX_Colormap cmap)
|
|
|
|
{
|
|
|
|
Win win;
|
|
|
|
|
|
|
|
win = _EXidCreate();
|
|
|
|
win->parent = parent;
|
|
|
|
win->xwin = xwin;
|
|
|
|
win->x = x;
|
|
|
|
win->y = y;
|
|
|
|
win->w = w;
|
|
|
|
win->h = h;
|
|
|
|
win->depth = depth;
|
|
|
|
win->visual = visual;
|
|
|
|
win->cmap = cmap;
|
|
|
|
win->argb = depth == 32;
|
2005-06-30 05:57:34 -07:00
|
|
|
#if DEBUG_XWIN
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %#x\n", __func__, win->xwin);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
_EXidAdd(win);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win;
|
2003-07-12 00:52:03 -07:00
|
|
|
}
|
|
|
|
|
2004-05-31 13:03:06 -07:00
|
|
|
void
|
2023-10-21 02:04:12 -07:00
|
|
|
EventCallbackRegister(Win win, EventCallbackFunc *func, void *prm)
|
2004-05-31 13:03:06 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EventCallbackItem *eci;
|
2004-05-31 13:03:06 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x: func=%p prm=%p\n", __func__,
|
|
|
|
win, win->xwin, func, prm);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2004-05-31 13:03:06 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win->cbl.num++;
|
|
|
|
win->cbl.lst = EREALLOC(EventCallbackItem, win->cbl.lst, win->cbl.num);
|
|
|
|
eci = win->cbl.lst + win->cbl.num - 1;
|
|
|
|
eci->func = func;
|
|
|
|
eci->prm = prm;
|
2004-05-31 13:03:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-10-21 02:04:12 -07:00
|
|
|
EventCallbackUnregister(Win win, EventCallbackFunc *func, void *prm)
|
2004-05-31 13:03:06 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EventCallbackList *ecl;
|
|
|
|
EventCallbackItem *eci;
|
|
|
|
int i;
|
2004-05-31 13:03:06 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x: func=%p prm=%p\n", __func__,
|
|
|
|
win, win->xwin, func, prm);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2004-05-31 13:03:06 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
ecl = &win->cbl;
|
|
|
|
eci = ecl->lst;
|
|
|
|
for (i = 0; i < ecl->num; i++, eci++)
|
|
|
|
if (eci->func == func && eci->prm == prm)
|
|
|
|
{
|
|
|
|
ecl->num--;
|
|
|
|
if (ecl->num)
|
|
|
|
{
|
|
|
|
for (; i < ecl->num; i++, eci++)
|
|
|
|
*eci = *(eci + 1);
|
|
|
|
win->cbl.lst =
|
|
|
|
EREALLOC(EventCallbackItem, win->cbl.lst, ecl->num);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EFREE_NULL(win->cbl.lst);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EventCallbacksProcess(Win win, XEvent *ev)
|
|
|
|
{
|
|
|
|
EventCallbackList *ecl;
|
|
|
|
EventCallbackItem *eci;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!win)
|
|
|
|
return;
|
|
|
|
|
|
|
|
win->in_use = 1;
|
|
|
|
ecl = &win->cbl;
|
|
|
|
eci = ecl->lst;
|
|
|
|
for (i = 0; i < ecl->num; i++, eci++)
|
|
|
|
{
|
|
|
|
if (EDebug(EDBUG_TYPE_DISPATCH))
|
|
|
|
Eprintf("%s: type=%d win=%#lx func=%p prm=%p\n", __func__,
|
|
|
|
ev->type, ev->xany.window, eci->func, eci->prm);
|
|
|
|
eci->func(win, ev, eci->prm);
|
|
|
|
if (win->do_del)
|
|
|
|
{
|
|
|
|
_EXidDestroy(win);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
win->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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win win;
|
|
|
|
EX_Window xwin;
|
|
|
|
XSetWindowAttributes attr;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.override_redirect = False;
|
|
|
|
attr.colormap = parent->cmap;
|
|
|
|
attr.border_pixel = 0;
|
1999-11-06 01:32:32 -08:00
|
|
|
/* attr.background_pixel = 0; */
|
2023-10-21 02:04:12 -07:00
|
|
|
attr.background_pixmap = NoXID;
|
|
|
|
if ((saveunder == 1) && (Conf.save_under))
|
|
|
|
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
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
xwin = XCreateWindow(disp, parent->xwin, x, y, w, h, 0,
|
|
|
|
CopyFromParent, InputOutput, CopyFromParent,
|
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixmap | CWBorderPixel, &attr);
|
|
|
|
win = _EXidSet(xwin, parent, x, y, w, h, parent->depth, parent->visual,
|
|
|
|
parent->cmap);
|
2006-04-29 12:39:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win;
|
2005-04-29 10:37:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-03 07:11:34 -07:00
|
|
|
#if USE_COMPOSITE
|
2023-10-21 02:04:12 -07:00
|
|
|
static Win
|
2012-12-24 03:05:48 -08:00
|
|
|
_ECreateWindowVDC(Win parent, int x, int y, int w, int h,
|
2023-10-21 02:04:12 -07:00
|
|
|
Visual *vis, unsigned int depth, EX_Colormap cmap)
|
2005-04-29 10:37:30 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win win;
|
|
|
|
EX_Window xwin;
|
|
|
|
XSetWindowAttributes attr;
|
2007-03-18 22:37:57 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
attr.background_pixmap = NoXID;
|
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.override_redirect = False;
|
|
|
|
attr.colormap = cmap;
|
2007-03-18 22:37:57 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
xwin = XCreateWindow(disp, parent->xwin, x, y, w, h, 0,
|
|
|
|
depth, InputOutput, vis,
|
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixmap | CWBorderPixel, &attr);
|
|
|
|
win = _EXidSet(xwin, parent, x, y, w, h, depth, vis, cmap);
|
2007-03-18 22:37:57 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win;
|
2007-03-18 22:37:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Win
|
|
|
|
ECreateArgbWindow(Win parent, int x, int y, int w, int h, Win cwin)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
int depth;
|
|
|
|
Visual *vis;
|
|
|
|
EX_Colormap cmap;
|
2005-04-29 10:37:30 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (cwin && Conf.testing.argb_clients_inherit_attr)
|
|
|
|
{
|
|
|
|
depth = cwin->depth;
|
|
|
|
vis = cwin->visual;
|
|
|
|
cmap = cwin->cmap;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
depth = 32;
|
|
|
|
vis = EVisualFindARGB();
|
|
|
|
cmap = argb_cmap;
|
|
|
|
}
|
2006-06-03 07:11:34 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return _ECreateWindowVDC(parent, x, y, w, h, vis, depth, cmap);
|
2007-03-18 22:37:57 -07:00
|
|
|
}
|
2003-07-12 00:52:03 -07:00
|
|
|
|
2007-03-18 22:37:57 -07:00
|
|
|
#if USE_GLX
|
2023-10-21 02:04:12 -07:00
|
|
|
static Win
|
2012-12-24 03:05:48 -08:00
|
|
|
_ECreateWindowVD(Win parent, int x, int y, int w, int h,
|
2023-10-21 02:04:12 -07:00
|
|
|
Visual *vis, unsigned int depth)
|
2007-03-18 22:37:57 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Colormap cmap;
|
2006-06-03 07:11:34 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!vis || depth == 0)
|
|
|
|
return 0;
|
2007-06-24 09:48:16 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
cmap = XCreateColormap(disp, WinGetXwin(VROOT), vis, AllocNone);
|
2007-03-18 22:37:57 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return _ECreateWindowVDC(parent, x, y, w, h, vis, depth, cmap);
|
2006-06-03 07:11:34 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Win
|
|
|
|
ECreateObjectWindow(Win parent, int x, int y, int w, int h, int saveunder,
|
2023-10-21 02:04:12 -07:00
|
|
|
int type, Win cwin)
|
|
|
|
{
|
|
|
|
Win win;
|
|
|
|
int argb = 0;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case WIN_TYPE_NO_ARGB:
|
|
|
|
break;
|
|
|
|
case WIN_TYPE_CLIENT:
|
|
|
|
if (Conf.testing.argb_clients || EVisualIsARGB(cwin->visual))
|
|
|
|
argb = 1;
|
|
|
|
break;
|
|
|
|
case WIN_TYPE_INTERNAL:
|
|
|
|
if (Conf.testing.argb_internal_objects)
|
|
|
|
argb = 1;
|
|
|
|
break;
|
2007-05-20 01:08:59 -07:00
|
|
|
#if USE_GLX
|
2023-10-21 02:04:12 -07:00
|
|
|
case WIN_TYPE_GLX: /* Internal GL */
|
|
|
|
win =
|
|
|
|
_ECreateWindowVD(parent, x, y, w, h, EGlGetVisual(), EGlGetDepth());
|
|
|
|
return win;
|
2007-05-20 01:08:59 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
}
|
2006-06-03 07:11:34 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (argb)
|
|
|
|
win = ECreateArgbWindow(parent, x, y, w, h, cwin);
|
|
|
|
else
|
|
|
|
win = ECreateWindow(parent, x, y, w, h, saveunder);
|
2006-06-03 07:11:34 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2011-02-12 08:43:52 -08:00
|
|
|
#else
|
|
|
|
|
|
|
|
Win
|
|
|
|
ECreateObjectWindow(Win parent, int x, int y, int w, int h, int saveunder,
|
2023-10-21 02:04:12 -07:00
|
|
|
int type __UNUSED__, Win cwin __UNUSED__)
|
2011-02-12 08:43:52 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
return ECreateWindow(parent, x, y, w, h, saveunder);
|
2011-02-12 08:43:52 -08:00
|
|
|
}
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
#endif /* USE_COMPOSITE */
|
2011-02-12 08:43:52 -08:00
|
|
|
|
2006-06-03 07:11:34 -07:00
|
|
|
Win
|
|
|
|
ECreateClientWindow(Win parent, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
#if USE_COMPOSITE
|
2023-10-21 02:04:12 -07:00
|
|
|
if (Conf.testing.argb_internal_clients)
|
|
|
|
return ECreateArgbWindow(parent, x, y, w, h, NULL);
|
2006-06-03 07:11:34 -07:00
|
|
|
#endif
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return ECreateWindow(parent, x, y, w, h, 0);
|
2006-06-03 07:11:34 -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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win win;
|
|
|
|
EX_Window xwin;
|
|
|
|
XSetWindowAttributes attr;
|
2005-03-02 11:20:27 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
attr.override_redirect = False;
|
2005-03-02 11:20:27 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
xwin = XCreateWindow(disp, parent->xwin, x, y, w, h, 0, 0, InputOnly,
|
|
|
|
CopyFromParent, CWOverrideRedirect, &attr);
|
|
|
|
win = _EXidSet(xwin, parent, x, y, w, h, 0, NULL, NoXID);
|
2006-04-29 12:39:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win;
|
2005-03-02 11:20:27 -08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x: %d,%d %dx%d -> %d,%d\n", __func__,
|
|
|
|
win, win->xwin, win->x, win->y, win->w, win->h, x, y);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if ((x == win->x) && (y == win->y))
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win->x = x;
|
|
|
|
win->y = y;
|
2006-04-29 12:39:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XMoveWindow(disp, win->xwin, 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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if ((w == win->w) && (h == win->h))
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
WinBgInvalidate(win);
|
|
|
|
win->w = w;
|
|
|
|
win->h = h;
|
2006-04-29 12:39:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XResizeWindow(disp, win->xwin, 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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x: %d,%d %dx%d -> %d,%d %dx%d\n", __func__,
|
|
|
|
win, win->xwin, win->x, win->y, win->w, win->h, x, y, w, h);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if ((w == win->w) && (h == win->h) && (x == win->x) && (y == win->y))
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (w != win->w || h != win->h)
|
|
|
|
WinBgInvalidate(win);
|
2007-05-25 15:40:47 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win->x = x;
|
|
|
|
win->y = y;
|
|
|
|
win->w = w;
|
|
|
|
win->h = h;
|
2006-04-29 12:39:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XMoveResizeWindow(disp, win->xwin, x, y, w, h);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2005-06-30 05:57:34 -07:00
|
|
|
static int
|
2012-12-24 03:05:48 -08:00
|
|
|
_ExDelTree(Win win)
|
2005-06-30 05:57:34 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win win2;
|
|
|
|
int nsub;
|
2005-06-30 05:57:34 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win->do_del = -1;
|
2005-06-30 05:57:34 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
nsub = 0;
|
|
|
|
for (win2 = win_first; win2; win2 = win2->next)
|
|
|
|
{
|
|
|
|
if (win2->parent != win)
|
|
|
|
continue;
|
|
|
|
_ExDelTree(win2);
|
|
|
|
nsub++;
|
|
|
|
}
|
2005-06-30 05:57:34 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return nsub;
|
2005-06-30 05:57:34 -07:00
|
|
|
}
|
|
|
|
|
2006-05-11 14:11:07 -07:00
|
|
|
void
|
|
|
|
EDestroyWindow(Win win)
|
2005-06-30 05:57:34 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win next;
|
|
|
|
int nsub;
|
2005-06-30 05:57:34 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2005-06-30 05:57:34 -07:00
|
|
|
#if DEBUG_XWIN
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x\n", __func__, win, win->xwin);
|
2005-06-30 05:57:34 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->parent)
|
|
|
|
{
|
|
|
|
EFreeWindowBackgroundPixmap(win);
|
|
|
|
XDestroyWindow(disp, win->xwin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark the ones to be deleted */
|
|
|
|
nsub = _ExDelTree(win);
|
|
|
|
if (nsub == 0)
|
|
|
|
{
|
|
|
|
/* No children */
|
|
|
|
_EXidDel(win);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete entire tree */
|
|
|
|
for (win = win_first; win; win = next)
|
|
|
|
{
|
|
|
|
next = win->next;
|
|
|
|
if (win->do_del < 0)
|
|
|
|
_EXidDel(win);
|
|
|
|
}
|
2005-06-30 05:57:34 -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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Window rr;
|
|
|
|
int x, y;
|
|
|
|
unsigned int w, h, bw, depth;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XGetGeometry(disp, win->xwin, &rr, &x, &y, &w, &h, &bw, &depth);
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x: %d,%d %dx%d -> %d,%d %dx%d\n", __func__,
|
|
|
|
win, win->xwin, win->x, win->y, win->w, win->h, x, y, w, h);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
win->x = x;
|
|
|
|
win->y = y;
|
|
|
|
win->w = w;
|
|
|
|
win->h = h;
|
|
|
|
win->depth = depth;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2006-09-08 16:13:57 -07:00
|
|
|
void
|
|
|
|
EWindowSetGeometry(Win win, int x, int y, int w, int h, int bw)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-09-08 16:13:57 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win->x = x;
|
|
|
|
win->y = y;
|
|
|
|
win->w = w;
|
|
|
|
win->h = h;
|
|
|
|
win->bw = bw;
|
2006-09-08 16:13:57 -07:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2005-05-28 04:43:57 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win->mapped = mapped;
|
2005-05-28 04:43:57 -07:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Window
|
|
|
|
EXWindowGetParent(EX_Window xwin)
|
2005-05-28 04:43:57 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Window parent, rt;
|
|
|
|
Window *pch = NULL;
|
|
|
|
unsigned int nch = 0;
|
2005-05-28 04:43:57 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
parent = NoXID;
|
|
|
|
if (!XQueryTree(disp, xwin, &rt, &parent, &pch, &nch))
|
|
|
|
parent = NoXID;
|
|
|
|
else if (pch)
|
|
|
|
XFree(pch);
|
2005-05-28 04:43:57 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return parent;
|
2005-05-28 04:43:57 -07:00
|
|
|
}
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
Win
|
2009-12-03 11:29:30 -08:00
|
|
|
ECreateWinFromXwin(EX_Window xwin)
|
2006-04-29 12:39:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
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->xwin = xwin;
|
|
|
|
win->x = x;
|
|
|
|
win->y = y;
|
|
|
|
win->w = w;
|
|
|
|
win->h = h;
|
|
|
|
win->depth = depth;
|
|
|
|
win->visual = WinGetVisual(VROOT);
|
|
|
|
win->cmap = WinGetCmap(VROOT);
|
2010-08-11 12:13:11 -07:00
|
|
|
#if DEBUG_XWIN
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p %#x\n", __func__, win, win->xwin);
|
2010-08-11 12:13:11 -07:00
|
|
|
#endif
|
2006-05-13 06:25:30 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win;
|
2006-04-29 12:39:21 -07:00
|
|
|
}
|
2006-05-07 08:08:01 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
EDestroyWin(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
_EXidDestroy(win);
|
2006-05-07 08:08:01 -07:00
|
|
|
}
|
2006-04-29 12:39:21 -07:00
|
|
|
|
|
|
|
Win
|
2023-10-21 02:04:12 -07:00
|
|
|
ERegisterWindow(EX_Window xwin, XWindowAttributes *pxwa)
|
2003-07-12 00:52:03 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win win;
|
|
|
|
XWindowAttributes xwa;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win = EXidLookup(xwin);
|
|
|
|
if (win)
|
|
|
|
goto done;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!pxwa)
|
|
|
|
{
|
|
|
|
pxwa = &xwa;
|
|
|
|
if (!EXGetWindowAttributes(xwin, pxwa))
|
|
|
|
goto done;
|
|
|
|
}
|
2006-05-21 05:09:14 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %p #%x %d+%d %dx%d\n", __func__, win, xwin,
|
|
|
|
pxwa->x, pxwa->y, pxwa->width, pxwa->height);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
win = _EXidSet(xwin, NoXID, pxwa->x, pxwa->y, pxwa->width, pxwa->height,
|
|
|
|
pxwa->depth, pxwa->visual, pxwa->colormap);
|
|
|
|
win->mapped = pxwa->map_state != IsUnmapped;
|
|
|
|
win->attached = 1;
|
2006-04-29 12:39:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
done:
|
|
|
|
return win;
|
2006-04-29 12:39:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EUnregisterXwin(EX_Window xwin)
|
2006-04-29 12:39:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win win;
|
2006-04-29 12:39:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
win = EXidLookup(xwin);
|
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-02 13:06:32 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
/* FIXME - We shouldn't go here */
|
|
|
|
_EXidDel(win);
|
|
|
|
#if 1 /* Debug - Fix code if we get here */
|
|
|
|
Eprintf("*** FIXME - %s %#x\n", __func__, xwin);
|
2006-05-02 13:06:32 -07:00
|
|
|
#endif
|
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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->cbl.lst)
|
|
|
|
{
|
|
|
|
if (EDebug(1))
|
|
|
|
Eprintf("%s(%#x) Ignored (%d callbacks remain)\n",
|
|
|
|
__func__, win->xwin, win->cbl.num);
|
|
|
|
return;
|
|
|
|
}
|
2006-08-07 16:26:36 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
_EXidDel(win);
|
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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->mapped)
|
|
|
|
return;
|
|
|
|
win->mapped = 1;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XMapWindow(disp, win->xwin);
|
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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win->mapped)
|
|
|
|
return;
|
|
|
|
win->mapped = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XUnmapWindow(disp, win->xwin);
|
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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
#if 0
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf
|
|
|
|
("%s: %p %#x: %d %#x->%#x %d,%d %dx%d -> %d,%d\n", __func__,
|
|
|
|
win, win->xwin, win->mapped, (win->parent) ? win->parent->xwin : NoXID,
|
|
|
|
parent->xwin, win->x, win->y, win->w, win->h, x, y);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if (parent == win->parent)
|
|
|
|
{
|
|
|
|
if ((x != win->x) || (y != win->y))
|
|
|
|
{
|
|
|
|
win->x = x;
|
|
|
|
win->y = y;
|
|
|
|
XMoveWindow(disp, win->xwin, x, y);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
win->parent = parent;
|
|
|
|
win->x = x;
|
|
|
|
win->y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
XReparentWindow(disp, win->xwin, parent->xwin, 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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->mapped)
|
|
|
|
{
|
|
|
|
XRaiseWindow(disp, win->xwin);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
win->mapped = 1;
|
|
|
|
}
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XMapRaised(disp, win->xwin);
|
2006-04-29 12:39:21 -07:00
|
|
|
}
|
|
|
|
|
2013-11-23 08:08:12 -08:00
|
|
|
int
|
2023-10-21 02:04:12 -07:00
|
|
|
EXGetWindowAttributes(EX_Window xwin, XWindowAttributes *pxwa)
|
2013-11-23 08:08:12 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
return XGetWindowAttributes(disp, xwin, pxwa);
|
2013-11-23 08:08:12 -08:00
|
|
|
}
|
|
|
|
|
2006-04-29 12:39:21 -07:00
|
|
|
int
|
2021-08-14 04:39:43 -07:00
|
|
|
EXGetSize(EX_Drawable draw, int *w, int *h)
|
2006-04-29 12:39:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
int ok;
|
|
|
|
Window rr;
|
|
|
|
int xx, yy;
|
|
|
|
unsigned int ww, hh, bb, dd;
|
2006-04-29 12:39:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
ok = XGetGeometry(disp, draw, &rr, &xx, &yy, &ww, &hh, &bb, &dd);
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
#if 0 /* Debug */
|
|
|
|
Eprintf("%s win=%#x, error %d\n", __func__, draw, ok);
|
2021-08-13 02:03:50 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if (w)
|
|
|
|
*w = 0;
|
|
|
|
if (h)
|
|
|
|
*h = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (w)
|
|
|
|
*w = ww;
|
|
|
|
if (h)
|
|
|
|
*h = hh;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EGetWindowAttributes(Win win, XWindowAttributes *pxwa)
|
|
|
|
{
|
|
|
|
if (!win)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pxwa->x = win->x;
|
|
|
|
pxwa->y = win->y;
|
|
|
|
pxwa->width = win->w;
|
|
|
|
pxwa->height = win->h;
|
|
|
|
pxwa->border_width = win->bw;
|
|
|
|
pxwa->depth = win->depth;
|
|
|
|
pxwa->visual = win->visual;
|
|
|
|
pxwa->colormap = win->cmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 /* Unused */
|
|
|
|
void
|
|
|
|
EConfigureWindow(Win win, unsigned int mask, XWindowChanges *wc)
|
|
|
|
{
|
|
|
|
char doit = 0;
|
|
|
|
|
|
|
|
if (!win)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((mask & CWX) && (wc->x != win->x))
|
|
|
|
{
|
|
|
|
win->x = wc->x;
|
|
|
|
doit = 1;
|
|
|
|
}
|
|
|
|
if ((mask & CWY) && (wc->y != win->y))
|
|
|
|
{
|
|
|
|
win->y = wc->y;
|
|
|
|
doit = 1;
|
|
|
|
}
|
|
|
|
if ((mask & CWWidth) && (wc->width != win->w))
|
|
|
|
{
|
|
|
|
WinBgInvalidate(win);
|
|
|
|
win->w = wc->width;
|
|
|
|
doit = 1;
|
|
|
|
}
|
|
|
|
if ((mask & CWHeight) && (wc->height != win->h))
|
|
|
|
{
|
|
|
|
WinBgInvalidate(win);
|
|
|
|
win->h = wc->height;
|
|
|
|
doit = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((doit) || (mask & (CWBorderWidth | CWSibling | CWStackMode)))
|
|
|
|
XConfigureWindow(disp, win->xwin, mask, wc);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
2007-09-05 12:12:56 -07:00
|
|
|
#endif
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ESetWindowBackgroundPixmap(Win win, EX_Pixmap pmap, int kept)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->bgpmap && win->bg_owned)
|
|
|
|
EFreeWindowBackgroundPixmap(win);
|
|
|
|
win->bgpmap = kept ? pmap : NoXID;
|
|
|
|
win->bg_owned = 0; /* Don't manage pixmap */
|
|
|
|
win->bgcol = 0xffffffff; /* Hmmm.. */
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XSetWindowBackgroundPixmap(disp, win->xwin, pmap);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap
|
2007-05-25 15:40:47 -07:00
|
|
|
EGetWindowBackgroundPixmap(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Pixmap pmap;
|
2007-05-25 15:40:47 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return NoXID;
|
2007-05-25 15:40:47 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->bg_owned < 0) /* Free if invalidated */
|
|
|
|
EFreeWindowBackgroundPixmap(win);
|
|
|
|
else if (win->bgpmap)
|
|
|
|
return win->bgpmap;
|
2007-05-25 15:40:47 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
/* Allocate/set new */
|
|
|
|
pmap = ECreatePixmap(win, win->w, win->h, 0);
|
|
|
|
ESetWindowBackgroundPixmap(win, pmap, 1);
|
|
|
|
win->bg_owned = 1; /* Manage pixmap */
|
2007-05-25 15:40:47 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return pmap;
|
2007-05-25 15:40:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EFreeWindowBackgroundPixmap(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win || !win->bgpmap)
|
|
|
|
return;
|
2007-05-25 15:40:47 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->bg_owned)
|
|
|
|
EFreePixmap(win->bgpmap);
|
|
|
|
win->bgpmap = NoXID;
|
|
|
|
win->bg_owned = 0;
|
2007-05-25 15:40:47 -07:00
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
2006-05-21 11:44:18 -07:00
|
|
|
ESetWindowBackground(Win win, unsigned int col)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->bgpmap)
|
|
|
|
{
|
|
|
|
EFreeWindowBackgroundPixmap(win);
|
|
|
|
win->bgcol = col;
|
|
|
|
}
|
|
|
|
else if (win->bgcol != col)
|
|
|
|
{
|
|
|
|
win->bgcol = col;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
2006-05-11 14:11:07 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XSetWindowBackground(disp, win->xwin, col);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2012-12-27 10:21:56 -08:00
|
|
|
#if USE_XI2
|
|
|
|
void
|
2023-10-21 02:04:12 -07:00
|
|
|
EXIMaskSetup(EXIEventMask *em, int dev, unsigned int event_mask)
|
2012-12-27 10:21:56 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
em->em.mask_len = sizeof(em->mb);
|
|
|
|
em->em.mask = em->mb;
|
|
|
|
memset(em->mb, 0, sizeof(em->mb));
|
2012-12-27 10:21:56 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
em->em.deviceid = dev;
|
2012-12-27 10:21:56 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (event_mask & KeyPressMask)
|
|
|
|
XISetMask(em->mb, XI_KeyPress);
|
|
|
|
if (event_mask & KeyReleaseMask)
|
|
|
|
XISetMask(em->mb, XI_KeyRelease);
|
2012-12-27 10:21:56 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (event_mask & ButtonPressMask)
|
|
|
|
XISetMask(em->mb, XI_ButtonPress);
|
|
|
|
if (event_mask & ButtonReleaseMask)
|
|
|
|
XISetMask(em->mb, XI_ButtonRelease);
|
|
|
|
if (event_mask & PointerMotionMask)
|
|
|
|
XISetMask(em->mb, XI_Motion);
|
2012-12-27 10:21:58 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (event_mask & EnterWindowMask)
|
|
|
|
XISetMask(em->mb, XI_Enter);
|
|
|
|
if (event_mask & LeaveWindowMask)
|
|
|
|
XISetMask(em->mb, XI_Leave);
|
2012-12-27 10:22:01 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (event_mask & FocusChangeMask)
|
|
|
|
{
|
|
|
|
XISetMask(em->mb, XI_FocusIn);
|
|
|
|
XISetMask(em->mb, XI_FocusOut);
|
|
|
|
}
|
2012-12-27 10:21:56 -08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-03-30 05:13:16 -07:00
|
|
|
void
|
|
|
|
ESelectInput(Win win, unsigned int event_mask)
|
|
|
|
{
|
2009-12-26 02:35:42 -08:00
|
|
|
#if USE_XI2
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int evold_mask;
|
2009-12-26 02:35:42 -08:00
|
|
|
|
2012-12-27 10:21:53 -08:00
|
|
|
#define EVENTS_TO_XI_KBD (KeyPressMask | KeyReleaseMask)
|
|
|
|
#define EVENTS_TO_XI_PTR (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
|
2012-12-27 10:21:58 -08:00
|
|
|
#define EVENTS_TO_XI_WEL (EnterWindowMask | LeaveWindowMask)
|
2012-12-27 10:22:01 -08:00
|
|
|
#define EVENTS_TO_XI_WFO (FocusChangeMask)
|
|
|
|
#define EVENTS_TO_XI \
|
|
|
|
(EVENTS_TO_XI_KBD | EVENTS_TO_XI_PTR | EVENTS_TO_XI_WEL | EVENTS_TO_XI_WFO)
|
2009-12-26 02:35:42 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
evold_mask = win->event_mask;
|
|
|
|
win->event_mask = event_mask;
|
2009-12-26 02:35:42 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (((event_mask ^ evold_mask) & EVENTS_TO_XI) && XEXT_AVAILABLE(XEXT_XI))
|
|
|
|
{
|
|
|
|
EXIEventMask em;
|
2009-12-26 02:35:42 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
EXIMaskSetup(&em, XIAllMasterDevices, event_mask & EVENTS_TO_XI);
|
|
|
|
XISelectEvents(disp, win->xwin, &em.em, 1);
|
2012-12-27 10:21:53 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
event_mask &= ~EVENTS_TO_XI;
|
|
|
|
evold_mask &= ~EVENTS_TO_XI;
|
|
|
|
}
|
2009-12-26 02:35:42 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (event_mask ^ evold_mask)
|
|
|
|
{
|
|
|
|
XSelectInput(disp, win->xwin, event_mask);
|
|
|
|
}
|
2012-12-27 10:21:53 -08:00
|
|
|
#else
|
2023-10-21 02:04:12 -07:00
|
|
|
XSelectInput(disp, win->xwin, event_mask);
|
2012-12-27 10:21:53 -08:00
|
|
|
#endif
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
2009-12-20 04:13:31 -08:00
|
|
|
void
|
|
|
|
ESelectInputChange(Win win, unsigned int set, unsigned int clear)
|
|
|
|
{
|
2009-12-26 02:35:42 -08:00
|
|
|
#if USE_XI2
|
2023-10-21 02:04:12 -07:00
|
|
|
ESelectInput(win, (win->event_mask | set) & ~clear);
|
2009-12-26 02:35:42 -08:00
|
|
|
#else
|
2023-10-21 02:04:12 -07:00
|
|
|
XWindowAttributes xwa;
|
2009-12-20 04:13:31 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
EXGetWindowAttributes(win->xwin, &xwa);
|
|
|
|
xwa.your_event_mask |= set;
|
|
|
|
xwa.your_event_mask &= ~clear;
|
|
|
|
XSelectInput(disp, win->xwin, xwa.your_event_mask);
|
2009-12-26 02:35:42 -08:00
|
|
|
#endif
|
2009-12-20 04:13:31 -08:00
|
|
|
}
|
|
|
|
|
2008-03-30 05:13:16 -07:00
|
|
|
void
|
2023-10-21 02:04:12 -07:00
|
|
|
EChangeWindowAttributes(Win win, unsigned int mask, XSetWindowAttributes *attr)
|
2008-03-30 05:13:16 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XChangeWindowAttributes(disp, win->xwin, mask, attr);
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ESetWindowBorderWidth(Win win, unsigned int bw)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XSetWindowBorderWidth(disp, win->xwin, bw);
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ERaiseWindow(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XRaiseWindow(disp, win->xwin);
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ELowerWindow(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XLowerWindow(disp, win->xwin);
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-10-21 02:04:12 -07:00
|
|
|
EXRestackWindows(EX_Window *windows, int nwindows)
|
2008-03-30 05:13:16 -07:00
|
|
|
{
|
2009-12-03 11:29:30 -08:00
|
|
|
#if SIZEOF_INT == SIZEOF_LONG
|
2023-10-21 02:04:12 -07:00
|
|
|
XRestackWindows(disp, (Window *) windows, nwindows);
|
2009-12-03 11:29:30 -08:00
|
|
|
#else
|
2023-10-21 02:04:12 -07:00
|
|
|
int i;
|
|
|
|
Window *_wins;
|
2009-12-03 11:29:30 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
_wins = EMALLOC(Window, nwindows);
|
|
|
|
if (!_wins)
|
|
|
|
return;
|
2009-12-03 11:29:30 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
for (i = 0; i < nwindows; i++)
|
|
|
|
_wins[i] = windows[i];
|
|
|
|
XRestackWindows(disp, _wins, nwindows);
|
2009-12-03 11:29:30 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
Efree(_wins);
|
2009-12-03 11:29:30 -08:00
|
|
|
#endif
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EClearWindow(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XClearWindow(disp, win->xwin);
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
2013-12-28 12:10:18 -08:00
|
|
|
void
|
|
|
|
EClearWindowExpose(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XClearArea(disp, win->xwin, 0, 0, 0, 0, True);
|
2013-12-28 12:10:18 -08:00
|
|
|
}
|
|
|
|
|
2008-03-30 05:13:16 -07:00
|
|
|
void
|
|
|
|
EClearArea(Win win, int x, int y, unsigned int w, unsigned int h)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XClearArea(disp, win->xwin, x, y, w, h, False);
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
2005-07-10 07:05:25 -07:00
|
|
|
int
|
2008-03-30 05:13:16 -07:00
|
|
|
ETranslateCoordinates(Win src_w, Win dst_w, int src_x, int src_y,
|
2023-10-21 02:04:12 -07:00
|
|
|
int *dest_x_return, int *dest_y_return,
|
|
|
|
EX_Window *child_return)
|
2005-07-10 07:05:25 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Window child;
|
|
|
|
Bool rc;
|
2009-12-03 11:29:30 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rc = XTranslateCoordinates(disp, src_w->xwin, dst_w->xwin, src_x, src_y,
|
|
|
|
dest_x_return, dest_y_return, &child);
|
2005-07-10 07:05:25 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (child_return)
|
|
|
|
*child_return = child;
|
2005-07-10 07:05:25 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return rc;
|
2005-07-10 07:05:25 -07:00
|
|
|
}
|
|
|
|
|
2005-08-07 13:33:21 -07:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EXWarpPointer(EX_Window xwin, int x, int y)
|
2005-08-07 13:33:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XWarpPointer(disp, NoXID, xwin, 0, 0, 0, 0, x, y);
|
2005-08-07 13:33:21 -07:00
|
|
|
}
|
|
|
|
|
2010-11-19 23:30:26 -08:00
|
|
|
void
|
|
|
|
EWarpPointer(Win win, int x, int y)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EXWarpPointer(win ? win->xwin : NoXID, x, y);
|
2010-11-19 23:30:26 -08:00
|
|
|
}
|
|
|
|
|
2013-12-28 03:29:26 -08:00
|
|
|
int
|
2023-10-21 02:04:12 -07:00
|
|
|
EXQueryPointer(EX_Window xwin, int *px, int *py, EX_Window *pchild,
|
|
|
|
unsigned int *pmask)
|
2005-08-07 13:33:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Window root, child;
|
|
|
|
int root_x, root_y;
|
|
|
|
unsigned int mask;
|
|
|
|
Bool rc;
|
2005-08-07 13:33:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (xwin == NoXID)
|
|
|
|
xwin = WinGetXwin(VROOT);
|
2006-04-24 09:06:05 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!px)
|
|
|
|
px = &root_x;
|
|
|
|
if (!py)
|
|
|
|
py = &root_y;
|
|
|
|
if (!pmask)
|
|
|
|
pmask = &mask;
|
2005-08-07 13:33:21 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rc = XQueryPointer(disp, xwin, &root, &child, &root_x, &root_y, px, py,
|
|
|
|
pmask);
|
2009-12-03 11:29:30 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (pchild)
|
|
|
|
*pchild = child;
|
2009-12-03 11:29:30 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return rc;
|
2005-08-07 13:33:21 -07:00
|
|
|
}
|
|
|
|
|
2013-12-28 03:29:26 -08:00
|
|
|
int
|
2023-10-21 02:04:12 -07:00
|
|
|
EQueryPointer(Win win, int *px, int *py, EX_Window *pchild, unsigned int *pmask)
|
2006-08-24 14:52:28 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Window xwin;
|
2006-08-24 14:52:28 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
xwin = (win) ? win->xwin : WinGetXwin(VROOT);
|
2006-08-24 14:52:28 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return EXQueryPointer(xwin, px, py, pchild, pmask);
|
2006-08-24 14:52:28 -07:00
|
|
|
}
|
|
|
|
|
2005-11-20 14:47:41 -08:00
|
|
|
int
|
2009-12-03 11:29:30 -08:00
|
|
|
EXDrawableOk(EX_Drawable draw)
|
2005-11-20 14:47:41 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (draw == NoXID)
|
|
|
|
return 0;
|
2006-02-27 11:14:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return EXGetSize(draw, NULL, NULL);
|
2005-11-20 14:47:41 -08:00
|
|
|
}
|
|
|
|
|
2013-12-27 14:20:52 -08:00
|
|
|
int
|
2009-12-03 11:29:30 -08:00
|
|
|
EXWindowOk(EX_Window xwin)
|
2013-12-27 14:20:52 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XWindowAttributes xwa;
|
2013-12-27 14:20:52 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (xwin == NoXID)
|
|
|
|
return 0;
|
2013-12-27 14:20:52 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return EXGetWindowAttributes(xwin, &xwa);
|
2013-12-27 14:20:52 -08:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_KeyCode
|
|
|
|
EKeysymToKeycode(EX_KeySym keysym)
|
2008-03-30 05:13:16 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
return XKeysymToKeycode(disp, keysym);
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_KeyCode
|
2008-03-30 05:13:16 -07:00
|
|
|
EKeynameToKeycode(const char *name)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
return XKeysymToKeycode(disp, XStringToKeysym(name));
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
2014-10-15 13:24:09 -07:00
|
|
|
#define DEBUG_SHAPE_OPS 0
|
2005-05-21 13:58:18 -07:00
|
|
|
#define DEBUG_SHAPE_PROPAGATE 0
|
|
|
|
|
2006-06-04 05:57:30 -07:00
|
|
|
#if DEBUG_SHAPE_OPS || DEBUG_SHAPE_PROPAGATE
|
2005-05-21 13:58:18 -07:00
|
|
|
static void
|
2023-10-21 02:04:12 -07:00
|
|
|
_EShapeShow(const char *txt, EX_Window xwin, XRectangle *pr, int nr)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
int i;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s %#x nr=%d\n", txt, xwin, nr);
|
|
|
|
for (i = 0; i < nr; i++)
|
|
|
|
Eprintf(" %3d - %4d,%4d %4dx%4d\n", i,
|
|
|
|
pr[i].x, pr[i].y, pr[i].width, pr[i].height);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-07-09 23:08:19 -07:00
|
|
|
int
|
2007-05-07 16:47:48 -07:00
|
|
|
EShapeUpdate(Win win)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->rects)
|
|
|
|
{
|
|
|
|
XFree(win->rects);
|
|
|
|
win->num_rect = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
win->rects =
|
|
|
|
XShapeGetRectangles(disp, win->xwin, ShapeBounding, &(win->num_rect),
|
|
|
|
&(win->ord));
|
|
|
|
if (win->rects)
|
|
|
|
{
|
|
|
|
if (win->num_rect == 1)
|
|
|
|
{
|
|
|
|
if ((win->rects[0].x == 0) && (win->rects[0].y == 0)
|
|
|
|
&& (win->rects[0].width == win->w)
|
|
|
|
&& (win->rects[0].height == win->h))
|
|
|
|
{
|
|
|
|
win->num_rect = 0;
|
|
|
|
XFree(win->rects);
|
|
|
|
win->rects = NULL;
|
|
|
|
XShapeCombineMask(disp, win->xwin, ShapeBounding, 0, 0,
|
|
|
|
NoXID, ShapeSet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (win->num_rect > 4096)
|
|
|
|
{
|
|
|
|
Eprintf("*** %s: nrect=%d - Not likely, ignoring.\n", __func__,
|
|
|
|
win->num_rect);
|
|
|
|
XShapeCombineMask(disp, win->xwin, ShapeBounding, 0, 0, NoXID,
|
|
|
|
ShapeSet);
|
|
|
|
win->num_rect = 0;
|
|
|
|
XFree(win->rects);
|
|
|
|
win->rects = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
win->num_rect = -1;
|
|
|
|
}
|
2005-05-21 13:58:18 -07:00
|
|
|
#if DEBUG_SHAPE_OPS
|
2023-10-21 02:04:12 -07:00
|
|
|
_EShapeShow(__func__, win->xwin, win->rects, win->num_rect);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
return win->num_rect != 0;
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
2008-06-05 01:55:21 -07:00
|
|
|
static void
|
2009-12-03 11:29:30 -08:00
|
|
|
_EShapeCombineMask(Win win, int dest, int x, int y, EX_Pixmap pmap, int op)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
char wasshaped = 0;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2006-05-13 10:05:00 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->rects || win->num_rect < 0)
|
|
|
|
{
|
|
|
|
win->num_rect = 0;
|
|
|
|
if (win->rects)
|
|
|
|
XFree(win->rects);
|
|
|
|
win->rects = NULL;
|
|
|
|
wasshaped = 1;
|
|
|
|
}
|
2005-05-21 13:58:18 -07:00
|
|
|
#if DEBUG_SHAPE_OPS
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s %#x %d,%d %dx%d mask=%#x wassh=%d\n", __func__,
|
|
|
|
win->xwin, win->x, win->y, win->w, win->h, pmap, wasshaped);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if (pmap)
|
|
|
|
{
|
|
|
|
XShapeCombineMask(disp, win->xwin, dest, x, y, pmap, op);
|
|
|
|
EShapeUpdate(win);
|
|
|
|
}
|
|
|
|
else if (wasshaped)
|
|
|
|
XShapeCombineMask(disp, win->xwin, dest, x, y, pmap, op);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
2008-06-05 01:55:21 -07:00
|
|
|
static void
|
2012-12-24 03:05:48 -08:00
|
|
|
_EShapeCombineMaskTiled(Win win, int dest, int x, int y,
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Pixmap pmap, int op, int w, int h)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XGCValues gcv;
|
|
|
|
GC gc;
|
|
|
|
EX_Window tm;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
gcv.fill_style = FillTiled;
|
|
|
|
gcv.tile = pmap;
|
|
|
|
gcv.ts_x_origin = 0;
|
|
|
|
gcv.ts_y_origin = 0;
|
|
|
|
tm = ECreatePixmap(win, w, h, 1);
|
|
|
|
gc = EXCreateGC(tm, GCFillStyle | GCTile |
|
|
|
|
GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
|
|
|
|
XFillRectangle(disp, tm, gc, 0, 0, w, h);
|
|
|
|
EXFreeGC(gc);
|
|
|
|
_EShapeCombineMask(win, dest, x, y, tm, op);
|
|
|
|
EFreePixmap(tm);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
2008-06-05 01:55:21 -07:00
|
|
|
static void
|
2012-12-24 03:05:48 -08:00
|
|
|
_EShapeCombineRectangles(Win win, int dest, int x, int y,
|
2023-10-21 02:04:12 -07:00
|
|
|
XRectangle *rect, int n_rects, int op, int ordering)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return;
|
2005-05-21 13:58:18 -07:00
|
|
|
#if DEBUG_SHAPE_OPS
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s %#x %d\n", __func__, win->xwin, n_rects);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (n_rects == 1 && op == ShapeSet)
|
|
|
|
{
|
|
|
|
if ((rect[0].x == 0) && (rect[0].y == 0) &&
|
|
|
|
(rect[0].width == win->w) && (rect[0].height == win->h))
|
|
|
|
{
|
|
|
|
win->num_rect = 0;
|
|
|
|
XFree(win->rects);
|
|
|
|
win->rects = NULL;
|
|
|
|
XShapeCombineMask(disp, win->xwin, dest, x, y, NoXID, op);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XShapeCombineRectangles(disp, win->xwin, 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 = win->w;
|
|
|
|
r.height = win->h;
|
|
|
|
XShapeCombineRectangles(disp, win->xwin, ShapeBounding, 0, 0, &r,
|
|
|
|
1, ShapeIntersect, Unsorted);
|
|
|
|
}
|
|
|
|
EShapeUpdate(win);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
2008-06-05 01:55:21 -07:00
|
|
|
static void
|
2012-12-24 03:05:48 -08:00
|
|
|
_EShapeCombineShape(Win win, int dest, int x, int y,
|
2023-10-21 02:04:12 -07:00
|
|
|
Win src_win, int src_kind, int op)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XShapeCombineShape(disp, win->xwin, dest, x, y, src_win->xwin, src_kind,
|
|
|
|
op);
|
|
|
|
EShapeUpdate(win);
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
2006-05-13 10:05:00 -07:00
|
|
|
int
|
|
|
|
EShapePropagate(Win win)
|
2005-05-21 13:58:18 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Win xch;
|
|
|
|
unsigned int num_rects;
|
|
|
|
int k, rn;
|
|
|
|
int x, y, w, h;
|
|
|
|
XRectangle *rects, *rectsn, *rl;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win || win->w <= 0 || win->h <= 0)
|
|
|
|
return 0;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
|
|
|
#if DEBUG_SHAPE_PROPAGATE
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s %#x %d,%d %dx%d\n", __func__, win->xwin,
|
|
|
|
win->x, win->y, win->w, win->h);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
num_rects = 0;
|
|
|
|
rects = NULL;
|
2005-05-21 13:58:18 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
/* go through all child windows and create/inset spans */
|
|
|
|
for (xch = win_first; xch; xch = xch->next)
|
|
|
|
{
|
|
|
|
if (xch->parent != win)
|
|
|
|
continue;
|
2006-05-24 09:36:47 -07:00
|
|
|
|
2005-05-21 13:58:18 -07:00
|
|
|
#if DEBUG_SHAPE_PROPAGATE > 1
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%#x(%d/%d): %4d,%4d %4dx%4d\n",
|
|
|
|
xch->xwin, xch->mapped, xch->num_rect,
|
|
|
|
xch->x, xch->y, xch->w, xch->h);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!xch->mapped)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
x = xch->x;
|
|
|
|
y = xch->y;
|
|
|
|
w = xch->w;
|
|
|
|
h = xch->h;
|
|
|
|
if (x >= win->w || y >= win->h || x + w < 0 || y + h < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rn = xch->num_rect;
|
|
|
|
|
|
|
|
if (rn > 0)
|
|
|
|
{
|
|
|
|
rl = xch->rects;
|
|
|
|
rectsn = EREALLOC(XRectangle, rects, num_rects + rn);
|
|
|
|
if (!rectsn)
|
|
|
|
goto bail_out;
|
|
|
|
rects = rectsn;
|
|
|
|
|
|
|
|
/* go through all clip rects in this window's shape */
|
|
|
|
for (k = 0; k < rn; k++)
|
|
|
|
{
|
|
|
|
/* for each clip rect, add it to the rect list */
|
|
|
|
rects[num_rects].x = x + rl[k].x;
|
|
|
|
rects[num_rects].y = y + rl[k].y;
|
|
|
|
rects[num_rects].width = rl[k].width;
|
|
|
|
rects[num_rects].height = rl[k].height;
|
2005-05-21 13:58:18 -07:00
|
|
|
#if DEBUG_SHAPE_PROPAGATE > 1
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf(" - %x %d: %4d,%4d %4dx%4d\n", xch->xwin, k,
|
|
|
|
rects[num_rects].x, rects[num_rects].y,
|
|
|
|
rects[num_rects].width, rects[num_rects].height);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
num_rects++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (rn == 0)
|
|
|
|
{
|
|
|
|
/* Unshaped */
|
|
|
|
rectsn = EREALLOC(XRectangle, rects, num_rects + 1);
|
|
|
|
if (!rectsn)
|
|
|
|
goto bail_out;
|
|
|
|
rects = rectsn;
|
|
|
|
|
|
|
|
rects[num_rects].x = x;
|
|
|
|
rects[num_rects].y = y;
|
|
|
|
rects[num_rects].width = w;
|
|
|
|
rects[num_rects].height = h;
|
2014-12-14 03:00:36 -08:00
|
|
|
#if DEBUG_SHAPE_PROPAGATE > 1
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf(" - %x : %4d,%4d %4dx%4d\n", xch->xwin,
|
|
|
|
rects[num_rects].x, rects[num_rects].y,
|
|
|
|
rects[num_rects].width, rects[num_rects].height);
|
2014-12-14 03:00:36 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
num_rects++;
|
|
|
|
}
|
|
|
|
}
|
2005-05-21 13:58:18 -07:00
|
|
|
|
2006-05-24 09:36:47 -07:00
|
|
|
#if DEBUG_SHAPE_PROPAGATE
|
2023-10-21 02:04:12 -07:00
|
|
|
_EShapeShow(__func__, win->xwin, rects, num_rects);
|
2005-05-21 13:58:18 -07:00
|
|
|
#endif
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
/* set the rects as the shape mask */
|
|
|
|
if (rects)
|
|
|
|
{
|
|
|
|
_EShapeCombineRectangles(win, ShapeBounding, 0, 0, rects,
|
|
|
|
num_rects, ShapeSet, Unsorted);
|
|
|
|
Efree(rects);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Empty shape */
|
|
|
|
_EShapeCombineRectangles(win, ShapeBounding, 0, 0, NULL, 0, ShapeSet,
|
|
|
|
Unsorted);
|
|
|
|
}
|
2006-01-22 10:25:41 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win->num_rect;
|
2008-01-06 06:08:40 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
bail_out:
|
|
|
|
Efree(rects);
|
|
|
|
_EShapeCombineMask(win, ShapeBounding, 0, 0, NoXID, ShapeSet);
|
|
|
|
return 0;
|
2005-06-12 09:06:41 -07:00
|
|
|
}
|
|
|
|
|
2006-01-22 10:25:41 -08:00
|
|
|
int
|
2006-04-29 12:39:21 -07:00
|
|
|
EShapeCheck(Win win)
|
2006-01-22 10:25:41 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
return 0;
|
2006-01-22 10:25:41 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return win->num_rect;
|
2005-05-21 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
2008-06-05 01:55:21 -07:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EShapeSetMask(Win win, int x, int y, EX_Pixmap mask)
|
2008-06-05 01:55:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
_EShapeCombineMask(win, ShapeBounding, x, y, mask, ShapeSet);
|
2008-06-05 01:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EShapeUnionMask(Win win, int x, int y, EX_Pixmap mask)
|
2008-06-05 01:55:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
_EShapeCombineMask(win, ShapeBounding, x, y, mask, ShapeUnion);
|
2008-06-05 01:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EShapeSetMaskTiled(Win win, int x, int y, EX_Pixmap mask, int w, int h)
|
2008-06-05 01:55:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
_EShapeCombineMaskTiled(win, ShapeBounding, x, y, mask, ShapeSet, w, h);
|
2008-06-05 01:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-10-21 02:04:12 -07:00
|
|
|
EShapeSetRects(Win win, int x, int y, XRectangle *rect, int n_rects)
|
2008-06-05 01:55:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
_EShapeCombineRectangles(win, ShapeBounding, x, y, rect, n_rects,
|
|
|
|
ShapeSet, Unsorted);
|
2008-06-05 01:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-10-21 02:04:12 -07:00
|
|
|
EShapeUnionRects(Win win, int x, int y, XRectangle *rect, int n_rects)
|
2008-06-05 01:55:21 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
_EShapeCombineRectangles(win, ShapeBounding, x, y, rect, n_rects,
|
|
|
|
ShapeUnion, Unsorted);
|
2008-06-05 01:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
EShapeSetShape(Win win, int x, int y, Win src_win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
_EShapeCombineShape(win, ShapeBounding, x, y,
|
|
|
|
src_win, ShapeBounding, ShapeSet);
|
|
|
|
return win->num_rect != 0;
|
2008-06-05 01:55:21 -07:00
|
|
|
}
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
static EX_Pixmap
|
2010-01-23 06:26:28 -08:00
|
|
|
_EWindowGetShapePixmap(Win win, unsigned int fg, unsigned int bg)
|
2008-06-05 02:20:25 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Pixmap mask;
|
|
|
|
GC gc;
|
|
|
|
int i;
|
|
|
|
const XRectangle *rect;
|
2008-06-05 02:20:25 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win->num_rect == 0) /* Not shaped */
|
|
|
|
return NoXID;
|
2008-06-05 02:20:25 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
mask = ECreatePixmap(win, win->w, win->h, 1);
|
|
|
|
gc = EXCreateGC(mask, 0, NULL);
|
2008-06-05 02:20:25 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XSetForeground(disp, gc, bg);
|
|
|
|
XFillRectangle(disp, mask, gc, 0, 0, win->w, win->h);
|
2008-06-05 02:20:25 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XSetForeground(disp, gc, fg);
|
|
|
|
rect = win->rects;
|
|
|
|
for (i = 0; i < win->num_rect; i++)
|
|
|
|
XFillRectangle(disp, mask, gc, rect[i].x, rect[i].y,
|
|
|
|
rect[i].width, rect[i].height);
|
2008-06-05 02:20:25 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
EXFreeGC(gc);
|
2008-06-05 02:20:25 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return mask;
|
2008-06-05 02:20:25 -07:00
|
|
|
}
|
|
|
|
|
2010-01-23 06:26:28 -08:00
|
|
|
/* Build mask from window shape rects */
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap
|
2010-01-23 06:26:28 -08:00
|
|
|
EWindowGetShapePixmap(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
return _EWindowGetShapePixmap(win, 1, 0);
|
2010-01-23 06:26:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Build inverted mask from window shape rects */
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap
|
2010-01-23 06:26:28 -08:00
|
|
|
EWindowGetShapePixmapInverted(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
return _EWindowGetShapePixmap(win, 0, 1);
|
2010-01-23 06:26:28 -08:00
|
|
|
}
|
|
|
|
|
2022-04-16 02:22:23 -07:00
|
|
|
void
|
|
|
|
EWindowPassPointer(Win win, int pass)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XRectangle r;
|
2022-04-16 02:22:23 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (pass)
|
|
|
|
{
|
|
|
|
/* Set input shape to none */
|
|
|
|
XShapeCombineRectangles(disp, win->xwin, ShapeInput, 0,
|
|
|
|
0, NULL, 0, ShapeSet, Unsorted);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Set input shape to default */
|
|
|
|
r.x = r.y = 0;
|
|
|
|
r.width = win->w;
|
|
|
|
r.height = win->h;
|
|
|
|
XShapeCombineRectangles(disp, win->xwin, ShapeInput, 0,
|
|
|
|
0, &r, 1, ShapeSet, Unsorted);
|
|
|
|
}
|
2022-04-16 02:22:23 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap
|
2006-05-07 08:08:01 -07:00
|
|
|
ECreatePixmap(Win win, unsigned int width, unsigned int height,
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int depth)
|
2006-05-07 08:08:01 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Pixmap pmap;
|
2007-09-10 13:13:59 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (depth == 0)
|
|
|
|
depth = win->depth;
|
2007-09-10 13:13:59 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
pmap = XCreatePixmap(disp, win->xwin, width, height, depth);
|
2007-09-10 13:13:59 -07:00
|
|
|
#if DEBUG_PIXMAP
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %#x\n", __func__, pmap);
|
2007-09-10 13:13:59 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
return pmap;
|
2006-05-07 08:08:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EFreePixmap(EX_Pixmap pmap)
|
2006-05-07 08:08:01 -07:00
|
|
|
{
|
2007-09-10 13:13:59 -07:00
|
|
|
#if DEBUG_PIXMAP
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %#x\n", __func__, pmap);
|
2007-09-10 13:13:59 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
XFreePixmap(disp, pmap);
|
2006-05-07 08:08:01 -07:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap
|
|
|
|
EXCreatePixmapCopy(EX_Pixmap src, unsigned int w, unsigned int h,
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int depth)
|
2005-10-16 09:27:48 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Pixmap pmap;
|
|
|
|
GC gc;
|
2005-10-16 09:27:48 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
pmap = XCreatePixmap(disp, src, w, h, depth);
|
|
|
|
gc = EXCreateGC(src, 0, NULL);
|
|
|
|
XCopyArea(disp, src, pmap, gc, 0, 0, w, h, 0, 0);
|
|
|
|
EXFreeGC(gc);
|
2007-09-10 13:13:59 -07:00
|
|
|
#if DEBUG_PIXMAP
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("%s: %#x\n", __func__, pmap);
|
2007-09-10 13:13:59 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
return pmap;
|
2005-10-16 09:27:48 -07:00
|
|
|
}
|
|
|
|
|
2013-12-28 12:50:34 -08:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EXCopyAreaGC(EX_Drawable src, EX_Drawable dst, GC gc, int sx, int sy,
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int w, unsigned int h, int dx, int dy)
|
2013-12-28 12:50:34 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XCopyArea(disp, src, dst, gc, sx, sy, w, h, dx, dy);
|
2013-12-28 12:50:34 -08:00
|
|
|
}
|
|
|
|
|
2006-04-17 01:43:09 -07:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EXCopyArea(EX_Drawable src, EX_Drawable dst, int sx, int sy,
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int w, unsigned int h, int dx, int dy)
|
2006-04-17 01:43:09 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
GC gc = (GC) Dpy.root_gc;
|
2006-04-17 01:43:09 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XCopyArea(disp, src, dst, gc, sx, sy, w, h, dx, dy);
|
2006-04-17 01:43:09 -07:00
|
|
|
}
|
|
|
|
|
2008-02-03 08:52:38 -08:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EXCopyAreaTiled(EX_Drawable src, EX_Pixmap mask, EX_Drawable dst,
|
2023-10-21 02:04:12 -07:00
|
|
|
int sx, int sy, unsigned int w, unsigned int h, int dx, int dy)
|
2008-02-03 08:52:38 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
GC gc;
|
|
|
|
XGCValues gcv;
|
2008-02-03 08:52:38 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
gcv.fill_style = FillTiled;
|
|
|
|
gcv.tile = src;
|
|
|
|
gcv.ts_x_origin = sx;
|
|
|
|
gcv.ts_y_origin = sy;
|
|
|
|
gcv.clip_mask = mask;
|
|
|
|
gc = EXCreateGC(dst, GCFillStyle |
|
|
|
|
GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCClipMask,
|
|
|
|
&gcv);
|
|
|
|
XFillRectangle(disp, dst, gc, dx, dy, w, h);
|
|
|
|
EXFreeGC(gc);
|
2008-02-03 08:52:38 -08:00
|
|
|
}
|
|
|
|
|
2013-12-28 13:35:10 -08:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EXFillAreaSolid(EX_Drawable dst, int x, int y, unsigned int w, unsigned int h,
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int pixel)
|
2013-12-28 13:35:10 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
GC gc;
|
|
|
|
XGCValues gcv;
|
2013-12-28 13:35:10 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
gcv.foreground = pixel;
|
|
|
|
gc = EXCreateGC(dst, GCForeground, &gcv);
|
|
|
|
XFillRectangle(disp, dst, gc, x, y, w, h);
|
|
|
|
EXFreeGC(gc);
|
2013-12-28 13:35:10 -08:00
|
|
|
}
|
|
|
|
|
2013-12-28 13:55:44 -08:00
|
|
|
static void
|
2009-12-03 11:29:30 -08:00
|
|
|
_EXDrawRectangle(EX_Drawable dst, GC gc, int x, int y,
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int w, unsigned int h, unsigned int pixel)
|
2013-12-28 13:55:44 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XSetForeground(disp, gc, pixel);
|
|
|
|
XDrawRectangle(disp, dst, gc, x, y, w, h);
|
2013-12-28 13:55:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-12-03 11:29:30 -08:00
|
|
|
_EXFillRectangle(EX_Drawable dst, GC gc, int x, int y,
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int w, unsigned int h, unsigned int pixel)
|
2013-12-28 13:55:44 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XSetForeground(disp, gc, pixel);
|
|
|
|
XFillRectangle(disp, dst, gc, x, y, w, h);
|
2013-12-28 13:55:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EXPaintRectangle(EX_Drawable dst, int x, int y,
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int w, unsigned int h,
|
|
|
|
unsigned int fg, unsigned int bg)
|
2013-12-28 13:55:44 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
GC gc;
|
2013-12-28 13:55:44 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (w == 0 || h == 0)
|
|
|
|
return;
|
|
|
|
gc = EXCreateGC(dst, 0, NULL);
|
|
|
|
_EXDrawRectangle(dst, gc, x, y, w - 1, h - 1, fg);
|
|
|
|
if (w > 2 && h > 2)
|
|
|
|
_EXFillRectangle(dst, gc, x + 1, y + 1, w - 2, h - 2, bg);
|
|
|
|
EXFreeGC(gc);
|
2013-12-28 13:55:44 -08:00
|
|
|
}
|
|
|
|
|
2005-03-02 11:20:27 -08:00
|
|
|
GC
|
2023-10-21 02:04:12 -07:00
|
|
|
EXCreateGC(EX_Drawable draw, unsigned int mask, XGCValues *val)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XGCValues xgcv;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (val)
|
|
|
|
{
|
|
|
|
mask |= GCGraphicsExposures;
|
|
|
|
val->graphics_exposures = False;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mask = GCSubwindowMode | GCGraphicsExposures;
|
|
|
|
val = &xgcv;
|
|
|
|
val->subwindow_mode = IncludeInferiors;
|
|
|
|
val->graphics_exposures = False;
|
|
|
|
}
|
|
|
|
return XCreateGC(disp, draw, mask, val);
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2010-01-23 06:26:31 -08:00
|
|
|
void
|
2006-04-17 14:55:34 -07:00
|
|
|
EXFreeGC(GC gc)
|
2005-02-12 15:48:02 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (gc)
|
|
|
|
XFreeGC(disp, gc);
|
2005-02-12 15:48:02 -08:00
|
|
|
}
|
|
|
|
|
2008-03-30 05:13:16 -07:00
|
|
|
void
|
2023-10-21 02:04:12 -07:00
|
|
|
EXSendEvent(EX_Window xwin, unsigned int event_mask, XEvent *ev)
|
2008-03-30 05:13:16 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XSendEvent(disp, xwin, False, event_mask, ev);
|
2008-03-30 05:13:16 -07:00
|
|
|
}
|
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
unsigned int
|
2009-12-03 11:29:30 -08:00
|
|
|
EAllocColor(EX_Colormap cmap, unsigned int argb)
|
2006-05-14 09:00:20 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XColor xc;
|
2006-05-14 09:00:20 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
COLOR32_TO_RGB16(argb, xc.red, xc.green, xc.blue);
|
|
|
|
XAllocColor(disp, cmap, &xc);
|
2004-04-24 06:16:38 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return xc.pixel;
|
2004-04-24 06:16:38 -07:00
|
|
|
}
|
|
|
|
|
2006-06-01 13:18:40 -07:00
|
|
|
/*
|
|
|
|
* Display
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2008-03-29 03:48:45 -07:00
|
|
|
int
|
2005-04-07 09:38:57 -07:00
|
|
|
EDisplayOpen(const char *dstr, int scr)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
char dbuf[256], *s;
|
|
|
|
unsigned int ddpy, dscr;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!dstr)
|
|
|
|
goto do_open;
|
2010-10-27 10:47:35 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
Esnprintf(dbuf, sizeof(dbuf), "%s", dstr);
|
|
|
|
s = strchr(dbuf, ':');
|
|
|
|
if (!s)
|
|
|
|
return -1;
|
|
|
|
s++;
|
2010-09-09 14:19:48 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
ddpy = dscr = 0;
|
|
|
|
sscanf(s, "%u.%u", &ddpy, &dscr);
|
|
|
|
if (scr >= 0) /* Override screen */
|
|
|
|
dscr = scr;
|
|
|
|
Esnprintf(s, sizeof(dbuf) - (s - dbuf), "%u.%u", ddpy, dscr);
|
|
|
|
dstr = dbuf;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
do_open:
|
|
|
|
disp = XOpenDisplay(dstr);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return (disp) ? 0 : -1;
|
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
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!disp)
|
|
|
|
return;
|
|
|
|
XCloseDisplay(disp);
|
|
|
|
XSetErrorHandler(NULL);
|
|
|
|
XSetIOErrorHandler(NULL);
|
|
|
|
disp = NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
void
|
|
|
|
EDisplayDisconnect(void)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!disp)
|
|
|
|
return;
|
|
|
|
close(ConnectionNumber(disp));
|
|
|
|
XSetErrorHandler(NULL);
|
|
|
|
XSetIOErrorHandler(NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
disp = NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2010-07-29 13:39:25 -07:00
|
|
|
static EXErrorHandler *EXErrorFunc = NULL;
|
|
|
|
static EXIOErrorHandler *EXIOErrorFunc = NULL;
|
2010-04-11 04:42:57 -07:00
|
|
|
|
2008-03-29 03:48:45 -07:00
|
|
|
static int
|
2023-10-21 02:04:12 -07:00
|
|
|
_HandleXError(Display *dpy __UNUSED__, XErrorEvent *ev)
|
2008-03-29 03:48:45 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (EDebug(1) && EXErrorFunc)
|
|
|
|
EXErrorFunc((XEvent *) ev);
|
2008-03-29 03:48:45 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
Dpy.last_error_code = ev->error_code;
|
2008-03-29 03:48:45 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return 0;
|
2008-03-29 03:48:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2023-10-21 02:04:12 -07:00
|
|
|
_HandleXIOError(Display *dpy __UNUSED__)
|
2008-03-29 03:48:45 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
disp = NULL;
|
2008-03-29 03:48:45 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (EXIOErrorFunc)
|
|
|
|
EXIOErrorFunc();
|
2008-03-29 03:48:45 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return 0;
|
2008-03-29 03:48:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-10-21 02:04:12 -07:00
|
|
|
EDisplaySetErrorHandlers(EXErrorHandler *error, EXIOErrorHandler *fatal)
|
2008-03-29 03:48:45 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
/* set up an error handler for then E would normally have fatal X errors */
|
|
|
|
EXErrorFunc = error;
|
|
|
|
XSetErrorHandler(_HandleXError);
|
2008-03-29 03:48:45 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
/* set up a handler for when the X Connection goes down */
|
|
|
|
EXIOErrorFunc = fatal;
|
|
|
|
XSetIOErrorHandler(_HandleXIOError);
|
2008-03-29 03:48:45 -07:00
|
|
|
}
|
|
|
|
|
2006-06-01 13:18:40 -07:00
|
|
|
/*
|
|
|
|
* Server
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
EGrabServer(void)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (Dpy.server_grabbed <= 0)
|
|
|
|
{
|
|
|
|
if (EDebug(EDBUG_TYPE_GRABS))
|
|
|
|
Eprintf("%s\n", __func__);
|
|
|
|
XGrabServer(disp);
|
|
|
|
}
|
|
|
|
Dpy.server_grabbed++;
|
2006-06-01 13:18:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EUngrabServer(void)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (Dpy.server_grabbed == 1)
|
|
|
|
{
|
|
|
|
XUngrabServer(disp);
|
|
|
|
XFlush(disp);
|
|
|
|
if (EDebug(EDBUG_TYPE_GRABS))
|
|
|
|
Eprintf("%s\n", __func__);
|
|
|
|
}
|
|
|
|
Dpy.server_grabbed--;
|
|
|
|
if (Dpy.server_grabbed < 0)
|
|
|
|
Dpy.server_grabbed = 0;
|
2006-06-01 13:18:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
EServerIsGrabbed(void)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
return Dpy.server_grabbed;
|
2006-06-01 13:18:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EFlush(void)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XFlush(disp);
|
2006-06-01 13:18:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-02-13 13:31:29 -08:00
|
|
|
ESync(unsigned int mask)
|
2006-06-01 13:18:40 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (mask & Conf.testing.no_sync_mask)
|
|
|
|
return;
|
|
|
|
XSync(disp, False);
|
2006-06-01 13:18:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Visuals
|
|
|
|
*/
|
|
|
|
|
2009-08-18 10:27:08 -07:00
|
|
|
#if USE_XRENDER
|
2006-06-01 13:18:40 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
Visual *
|
2006-06-01 13:18:40 -07:00
|
|
|
EVisualFindARGB(void)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XVisualInfo *xvi, xvit;
|
|
|
|
int i, num;
|
|
|
|
Visual *vis;
|
2006-06-01 13:18:40 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (argb_visual)
|
|
|
|
return argb_visual;
|
2020-12-08 08:58:48 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
xvit.screen = Dpy.screen;
|
|
|
|
xvit.depth = 32;
|
2007-01-16 17:10:44 -08:00
|
|
|
#if __cplusplus
|
2023-10-21 02:04:12 -07:00
|
|
|
xvit.c_class = TrueColor;
|
2007-01-16 17:10:44 -08:00
|
|
|
#else
|
2023-10-21 02:04:12 -07:00
|
|
|
xvit.class = TrueColor;
|
2007-01-16 17:10:44 -08:00
|
|
|
#endif
|
2006-06-01 13:18:40 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
xvi = XGetVisualInfo(disp,
|
|
|
|
VisualScreenMask | VisualDepthMask | VisualClassMask,
|
|
|
|
&xvit, &num);
|
|
|
|
if (!xvi)
|
|
|
|
return NULL;
|
2006-06-01 13:18:40 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (EVisualIsARGB(xvi[i].visual))
|
|
|
|
break;
|
|
|
|
}
|
2006-06-01 13:18:40 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
vis = (i < num) ? xvi[i].visual : NULL;
|
2006-06-01 13:18:40 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XFree(xvi);
|
2006-06-01 13:18:40 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
argb_visual = vis;
|
|
|
|
argb_cmap = XCreateColormap(disp, WinGetXwin(VROOT), vis, AllocNone);
|
2020-12-08 08:58:48 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return vis;
|
2006-06-01 13:18:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2023-10-21 02:04:12 -07:00
|
|
|
EVisualIsARGB(Visual *vis)
|
2006-06-01 13:18:40 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XRenderPictFormat *pictfmt;
|
2006-06-01 13:18:40 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
pictfmt = XRenderFindVisualFormat(disp, vis);
|
|
|
|
if (!pictfmt)
|
|
|
|
return 0;
|
2006-06-01 13:18:40 -07:00
|
|
|
|
|
|
|
#if 0
|
2023-10-21 02:04:12 -07:00
|
|
|
Eprintf("Visual ID=%#lx Type=%d, alphamask=%d\n", vis->visualid,
|
|
|
|
pictfmt->type, pictfmt->direct.alphaMask);
|
2006-06-01 13:18:40 -07:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
return pictfmt->type == PictTypeDirect && pictfmt->direct.alphaMask;
|
2006-06-01 13:18:40 -07:00
|
|
|
}
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
#endif /* USE_XRENDER */
|
2006-06-01 13:18:40 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Misc
|
|
|
|
*/
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Time
|
2005-05-12 12:02:15 -07:00
|
|
|
EGetTimestamp(void)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
static EX_Window win_ts = NoXID;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
XEvent ev;
|
2005-05-12 12:02:15 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (win_ts == NoXID)
|
|
|
|
{
|
|
|
|
attr.override_redirect = False;
|
|
|
|
win_ts = XCreateWindow(disp, WinGetXwin(VROOT), -100, -100, 1, 1, 0,
|
|
|
|
CopyFromParent, InputOnly, CopyFromParent,
|
|
|
|
CWOverrideRedirect, &attr);
|
|
|
|
XSelectInput(disp, win_ts, PropertyChangeMask);
|
|
|
|
}
|
2005-05-12 12:02:15 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
XChangeProperty(disp, win_ts, XA_WM_NAME, XA_STRING, 8,
|
|
|
|
PropModeAppend, (unsigned char *)"", 0);
|
|
|
|
XWindowEvent(disp, win_ts, PropertyChangeMask, &ev);
|
2005-05-12 12:02:15 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return ev.xproperty.time;
|
2005-05-12 12:02:15 -07:00
|
|
|
}
|
2009-12-20 04:13:25 -08:00
|
|
|
|
|
|
|
#if USE_COMPOSITE
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap
|
2010-01-10 09:17:02 -08:00
|
|
|
EWindowGetPixmap(const Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XWindowAttributes xwa;
|
2010-03-13 01:36:59 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (EXGetWindowAttributes(win->xwin, &xwa) == 0 ||
|
|
|
|
xwa.map_state == IsUnmapped)
|
|
|
|
return NoXID;
|
2010-03-13 01:36:59 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return XCompositeNameWindowPixmap(disp, WinGetXwin(win));
|
2010-01-10 09:17:02 -08:00
|
|
|
}
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
#endif /* USE_COMPOSITE */
|
2012-01-06 16:24:38 -08:00
|
|
|
|
|
|
|
#if USE_XRENDER
|
|
|
|
|
2009-12-20 04:13:25 -08:00
|
|
|
/*
|
|
|
|
* Pictures
|
|
|
|
*/
|
|
|
|
#define _R(x) (((x) >> 16) & 0xff)
|
|
|
|
#define _G(x) (((x) >> 8) & 0xff)
|
|
|
|
#define _B(x) (((x) ) & 0xff)
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Picture
|
|
|
|
EPictureCreate(Win win, EX_Drawable draw)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Picture pict;
|
|
|
|
XRenderPictFormat *pictfmt;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (!win)
|
|
|
|
win = VROOT;
|
|
|
|
pictfmt = XRenderFindVisualFormat(disp, WinGetVisual(win));
|
|
|
|
pict = XRenderCreatePicture(disp, draw, pictfmt, 0, NULL);
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return pict;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
2015-01-24 15:05:10 -08:00
|
|
|
EX_Picture
|
|
|
|
EPictureCreateII(Win win, EX_Drawable draw)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Picture pict;
|
|
|
|
XRenderPictFormat *pictfmt;
|
|
|
|
XRenderPictureAttributes pa;
|
2015-01-24 15:05:10 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
pictfmt = XRenderFindVisualFormat(disp, WinGetVisual(win));
|
|
|
|
pa.subwindow_mode = IncludeInferiors;
|
|
|
|
pict = XRenderCreatePicture(disp, draw, pictfmt, CPSubwindowMode, &pa);
|
2015-01-24 15:05:10 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return pict;
|
2015-01-24 15:05:10 -08:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Picture
|
|
|
|
EPictureCreateSolid(EX_Window xwin, int argb, unsigned int a, unsigned int rgb)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Display *dpy = disp;
|
|
|
|
XRenderColor c;
|
|
|
|
EX_Picture pict;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
c.alpha = (unsigned short)(a * 0x101);
|
|
|
|
c.red = (unsigned short)(_R(rgb) * 0x101);
|
|
|
|
c.green = (unsigned short)(_G(rgb) * 0x101);
|
|
|
|
c.blue = (unsigned short)(_B(rgb) * 0x101);
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2015-06-18 08:33:18 -07:00
|
|
|
#if RENDER_VERSION >= VERS(0, 11)
|
2023-10-21 02:04:12 -07:00
|
|
|
/* Version 0.10 should be good but apparently sometimes isn't
|
|
|
|
* (or is it some broken driver?).
|
|
|
|
* Anyway, let's require 0.11 and avoid some trouble. */
|
|
|
|
if (ExtVersion(XEXT_RENDER) >= VERS(0, 11))
|
|
|
|
{
|
|
|
|
pict = XRenderCreateSolidFill(dpy, &c);
|
|
|
|
}
|
|
|
|
else
|
2014-11-09 05:58:23 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
{
|
|
|
|
EX_Pixmap pmap;
|
|
|
|
XRenderPictFormat *pictfmt;
|
|
|
|
XRenderPictureAttributes pa;
|
2014-11-09 05:58:23 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
pmap = XCreatePixmap(dpy, xwin, 1, 1, argb ? 32 : 8);
|
|
|
|
pictfmt = XRenderFindStandardFormat(dpy,
|
|
|
|
argb ? PictStandardARGB32 :
|
|
|
|
PictStandardA8);
|
|
|
|
pa.repeat = True;
|
|
|
|
pict = XRenderCreatePicture(dpy, pmap, pictfmt, CPRepeat, &pa);
|
|
|
|
XRenderFillRectangle(dpy, PictOpSrc, pict, &c, 0, 0, 1, 1);
|
|
|
|
XFreePixmap(dpy, pmap);
|
|
|
|
}
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return pict;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Picture
|
2023-10-21 02:04:12 -07:00
|
|
|
EPictureCreateBuffer(Win win, int w, int h, int argb, EX_Pixmap *ppmap)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_Picture pict;
|
|
|
|
EX_Pixmap pmap;
|
|
|
|
XRenderPictFormat *pictfmt;
|
|
|
|
int depth;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
depth = argb ? 32 : WinGetDepth(win);
|
|
|
|
pictfmt = argb ?
|
|
|
|
XRenderFindStandardFormat(disp, PictStandardARGB32) :
|
|
|
|
XRenderFindVisualFormat(disp, WinGetVisual(win));
|
|
|
|
pmap = XCreatePixmap(disp, WinGetXwin(win), w, h, depth);
|
|
|
|
pict = XRenderCreatePicture(disp, pmap, pictfmt, 0, NULL);
|
|
|
|
if (ppmap)
|
|
|
|
*ppmap = pmap;
|
|
|
|
else
|
|
|
|
XFreePixmap(disp, pmap);
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return pict;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
2010-08-21 07:39:59 -07:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EPictureDestroy(EX_Picture pict)
|
2010-08-21 07:39:59 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XRenderFreePicture(disp, pict);
|
2010-08-21 07:39:59 -07:00
|
|
|
}
|
|
|
|
|
2014-08-17 05:25:36 -07:00
|
|
|
void
|
|
|
|
EPictureFillRect(EX_Picture pict, int x, int y, int w, int h,
|
2023-10-21 02:04:12 -07:00
|
|
|
unsigned int color)
|
2014-08-17 05:25:36 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XRenderColor c;
|
2014-08-17 05:25:36 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
COLOR32_TO_ARGB16(color, c.alpha, c.red, c.green, c.blue);
|
|
|
|
XRenderFillRectangle(disp, PictOpSrc, pict, &c, x, y, w, h);
|
2014-08-17 05:25:36 -07:00
|
|
|
}
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
#endif /* USE_XRENDER */
|
2012-01-06 16:24:38 -08:00
|
|
|
|
|
|
|
#if USE_COMPOSITE
|
|
|
|
|
2021-04-27 02:06:19 -07:00
|
|
|
void
|
|
|
|
EGCSetClip(GC gc, EX_SrvRegion clip)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XFixesSetGCClipRegion(disp, gc, 0, 0, clip);
|
2021-04-27 02:06:19 -07:00
|
|
|
}
|
|
|
|
|
2009-12-20 04:13:29 -08:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
EPictureSetClip(EX_Picture pict, EX_SrvRegion clip)
|
2009-12-20 04:13:29 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XFixesSetPictureClipRegion(disp, pict, 0, 0, clip);
|
2009-12-20 04:13:29 -08:00
|
|
|
}
|
|
|
|
|
2009-12-20 04:13:25 -08:00
|
|
|
/*
|
|
|
|
* Regions
|
|
|
|
*/
|
|
|
|
#define DEBUG_REGIONS 0
|
|
|
|
|
|
|
|
#if DEBUG_REGIONS
|
2023-10-21 02:04:12 -07:00
|
|
|
static int n_rgn_c = 0;
|
|
|
|
static int n_rgn_d = 0;
|
2009-12-20 04:13:25 -08:00
|
|
|
#endif
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_SrvRegion
|
2009-12-20 04:13:25 -08:00
|
|
|
ERegionCreate(void)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_SrvRegion rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rgn = XFixesCreateRegion(disp, NULL, 0);
|
2009-12-20 04:13:25 -08:00
|
|
|
|
|
|
|
#if DEBUG_REGIONS
|
2023-10-21 02:04:12 -07:00
|
|
|
n_rgn_c++;
|
|
|
|
Eprintf("%s: %#x %d %d %d\n", __func__, rgn,
|
|
|
|
n_rgn_c - n_rgn_d, n_rgn_c, n_rgn_d);
|
2009-12-20 04:13:25 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
return rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_SrvRegion
|
2009-12-20 04:13:25 -08:00
|
|
|
ERegionCreateRect(int x, int y, int w, int h)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_SrvRegion rgn;
|
|
|
|
XRectangle rct;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rct.x = x;
|
|
|
|
rct.y = y;
|
|
|
|
rct.width = w;
|
|
|
|
rct.height = h;
|
|
|
|
rgn = XFixesCreateRegion(disp, &rct, 1);
|
2009-12-20 04:13:25 -08:00
|
|
|
|
|
|
|
#if DEBUG_REGIONS
|
2023-10-21 02:04:12 -07:00
|
|
|
n_rgn_c++;
|
|
|
|
Eprintf("%s: %#x %d %d %d\n", __func__, rgn,
|
|
|
|
n_rgn_c - n_rgn_d, n_rgn_c, n_rgn_d);
|
2009-12-20 04:13:25 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
return rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#if USE_DESK_EXPOSE
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_SrvRegion
|
2023-10-21 02:04:12 -07:00
|
|
|
ERegionCreateFromRects(XRectangle *rectangles, int nrectangles)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_SrvRegion rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rgn = XFixesCreateRegion(disp, rectangles, nrectangles);
|
2009-12-20 04:13:25 -08:00
|
|
|
|
|
|
|
#if DEBUG_REGIONS
|
2023-10-21 02:04:12 -07:00
|
|
|
n_rgn_c++;
|
|
|
|
Eprintf("%s: %#x %d %d %d\n", __func__, rgn,
|
|
|
|
n_rgn_c - n_rgn_d, n_rgn_c, n_rgn_d);
|
2009-12-20 04:13:25 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
return rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_SrvRegion
|
2009-12-20 04:13:25 -08:00
|
|
|
ERegionCreateFromWindow(Win win)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_SrvRegion rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rgn = XFixesCreateRegionFromWindow(disp, WinGetXwin(win),
|
|
|
|
WindowRegionBounding);
|
2009-12-20 04:13:25 -08:00
|
|
|
|
|
|
|
#if DEBUG_REGIONS
|
2023-10-21 02:04:12 -07:00
|
|
|
n_rgn_c++;
|
|
|
|
Eprintf("%s: %#x %d %d %d\n", __func__, rgn,
|
|
|
|
n_rgn_c - n_rgn_d, n_rgn_c, n_rgn_d);
|
2009-12-20 04:13:25 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
return rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
2014-08-17 05:25:36 -07:00
|
|
|
EX_SrvRegion
|
|
|
|
ERegionCreateFromBitmap(EX_Pixmap mask)
|
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
return XFixesCreateRegionFromBitmap(disp, mask);
|
2014-08-17 05:25:36 -07:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_SrvRegion
|
|
|
|
ERegionCopy(EX_SrvRegion rgn, EX_SrvRegion src)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XFixesCopyRegion(disp, rgn, src);
|
|
|
|
return rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_SrvRegion
|
|
|
|
ERegionClone(EX_SrvRegion src)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_SrvRegion rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rgn = ERegionCreate();
|
|
|
|
ERegionCopy(rgn, src);
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
return rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionDestroy(EX_SrvRegion rgn)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
|
|
|
#if DEBUG_REGIONS
|
2023-10-21 02:04:12 -07:00
|
|
|
n_rgn_d++;
|
|
|
|
Eprintf("%s: %#x %d %d %d\n", __func__, rgn,
|
|
|
|
n_rgn_c - n_rgn_d, n_rgn_c, n_rgn_d);
|
2009-12-20 04:13:25 -08:00
|
|
|
#endif
|
2023-10-21 02:04:12 -07:00
|
|
|
XFixesDestroyRegion(disp, rgn);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionEmpty(EX_SrvRegion rgn)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XFixesSetRegion(disp, rgn, NULL, 0);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionSetRect(EX_SrvRegion rgn, int x, int y, int w, int h)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XRectangle rct;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rct.x = x;
|
|
|
|
rct.y = y;
|
|
|
|
rct.width = w;
|
|
|
|
rct.height = h;
|
|
|
|
XFixesSetRegion(disp, rgn, &rct, 1);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionTranslate(EX_SrvRegion rgn, int dx, int dy)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
if (dx == 0 && dy == 0)
|
|
|
|
return;
|
|
|
|
XFixesTranslateRegion(disp, rgn, dx, dy);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionIntersect(EX_SrvRegion dst, EX_SrvRegion src)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XFixesIntersectRegion(disp, dst, dst, src);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionUnion(EX_SrvRegion dst, EX_SrvRegion src)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XFixesUnionRegion(disp, dst, dst, src);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionSubtract(EX_SrvRegion dst, EX_SrvRegion src)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
XFixesSubtractRegion(disp, dst, dst, src);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
2010-10-25 10:44:59 -07:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionIntersectOffset(EX_SrvRegion dst, int dx, int dy, EX_SrvRegion src,
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_SrvRegion tmp)
|
2010-10-25 10:44:59 -07:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Display *dpy = disp;
|
|
|
|
EX_SrvRegion rgn;
|
2010-10-25 10:44:59 -07:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rgn = src;
|
|
|
|
if (dx != 0 || dy != 0)
|
|
|
|
{
|
|
|
|
rgn = ERegionCopy(tmp, src);
|
|
|
|
XFixesTranslateRegion(dpy, rgn, dx, dy);
|
|
|
|
}
|
|
|
|
XFixesIntersectRegion(dpy, dst, dst, rgn);
|
2010-10-25 10:44:59 -07:00
|
|
|
}
|
|
|
|
|
2009-12-20 04:13:25 -08:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionSubtractOffset(EX_SrvRegion dst, int dx, int dy, EX_SrvRegion src,
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_SrvRegion tmp)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Display *dpy = disp;
|
|
|
|
EX_SrvRegion rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rgn = src;
|
|
|
|
if (dx != 0 || dy != 0)
|
|
|
|
{
|
|
|
|
rgn = ERegionCopy(tmp, src);
|
|
|
|
XFixesTranslateRegion(dpy, rgn, dx, dy);
|
|
|
|
}
|
|
|
|
XFixesSubtractRegion(dpy, dst, dst, rgn);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
#if 0 /* Unused */
|
2009-12-20 04:13:25 -08:00
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionUnionOffset(EX_SrvRegion dst, int dx, int dy, EX_SrvRegion src,
|
2023-10-21 02:04:12 -07:00
|
|
|
EX_SrvRegion tmp)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
Display *dpy = disp;
|
|
|
|
EX_SrvRegion rgn;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
rgn = src;
|
|
|
|
if (dx != 0 || dy != 0)
|
|
|
|
{
|
|
|
|
rgn = ERegionCopy(tmp, src);
|
|
|
|
XFixesTranslateRegion(dpy, rgn, dx, dy);
|
|
|
|
}
|
|
|
|
XFixesUnionRegion(dpy, dst, dst, rgn);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
2009-12-20 04:13:27 -08:00
|
|
|
#endif
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
#if 0 /* Unused (for debug) */
|
2009-12-20 04:13:25 -08:00
|
|
|
int
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionIsEmpty(EX_SrvRegion rgn)
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
int nr;
|
|
|
|
XRectangle *pr;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
pr = XFixesFetchRegion(disp, rgn, &nr);
|
|
|
|
if (pr)
|
|
|
|
XFree(pr);
|
|
|
|
return nr == 0;
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
2009-12-03 11:29:30 -08:00
|
|
|
ERegionShow(const char *txt, EX_SrvRegion rgn,
|
2023-10-21 02:04:12 -07:00
|
|
|
void (*prf)(const char *fmt, ...))
|
2009-12-20 04:13:25 -08:00
|
|
|
{
|
2023-10-21 02:04:12 -07:00
|
|
|
int i, nr;
|
|
|
|
XRectangle *pr;
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
prf = (prf) ? prf : Eprintf;
|
2010-01-10 09:16:59 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
if (rgn == NoXID)
|
|
|
|
{
|
|
|
|
prf(" - region: %s %#x is None\n", txt, rgn);
|
|
|
|
return;
|
|
|
|
}
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
pr = XFixesFetchRegion(disp, rgn, &nr);
|
|
|
|
if (!pr || nr <= 0)
|
|
|
|
{
|
|
|
|
prf(" - region: %s %#x is empty\n", txt, rgn);
|
|
|
|
goto done;
|
|
|
|
}
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
prf(" - region: %s %#x:\n", txt, rgn);
|
|
|
|
for (i = 0; i < nr; i++)
|
|
|
|
prf("%4d: %4d+%4d %4dx%4d\n", i, pr[i].x, pr[i].y, pr[i].width,
|
|
|
|
pr[i].height);
|
2009-12-20 04:13:25 -08:00
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
done:
|
|
|
|
if (pr)
|
|
|
|
XFree(pr);
|
2009-12-20 04:13:25 -08:00
|
|
|
}
|
|
|
|
|
2023-10-21 02:04:12 -07:00
|
|
|
#endif /* USE_COMPOSITE */
|