Stuff for grabbing redirected windows.

SVN revision: 15719
This commit is contained in:
Kim Woelders 2005-07-10 20:16:47 +00:00
parent 285f7fe346
commit 16a3fedcf9
4 changed files with 25 additions and 51 deletions

View File

@ -1539,9 +1539,9 @@ int EobjRaise(EObj * eo);
int EobjLower(EObj * eo);
void EobjChangeShape(EObj * eo);
void EobjsRepaint(void);
Pixmap EobjGetPixmap(const EObj * eo);
#if USE_COMPOSITE
Pixmap EobjGetPixmap(const EObj * eo);
void EobjChangeOpacity(EObj * eo, unsigned int opacity);
#else
#define EobjChangeOpacity(eo, opacity)

View File

@ -46,10 +46,6 @@
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/Xrender.h>
#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2
#define HAS_NAME_WINDOW_PIXMAP 1
#endif
#define CAN_DO_USABLE 0
#define ENABLE_SHADOWS 1
@ -80,9 +76,7 @@ typedef struct
{
EObj *next; /* Paint order */
EObj *prev; /* Paint order */
#if HAS_NAME_WINDOW_PIXMAP
Pixmap pixmap;
#endif
struct
{
int class; /* FIXME - Remove? */
@ -149,9 +143,7 @@ static struct
{
char *args;
char active;
#if HAS_NAME_WINDOW_PIXMAP
char use_pixmap;
#endif
EObj *eo_first;
EObj *eo_last;
} Mode_compmgr;
@ -734,7 +726,6 @@ win_extents(Display * dpy, EObj * eo)
ECmWinInfo *cw = eo->cmhook;
XRectangle r;
#if HAS_NAME_WINDOW_PIXMAP
if (Mode_compmgr.use_pixmap)
{
cw->rcx = eo->x;
@ -743,7 +734,6 @@ win_extents(Display * dpy, EObj * eo)
cw->rch = eo->h + cw->a.border_width * 2;
}
else
#endif
{
cw->rcx = eo->x + cw->a.border_width;
cw->rcy = eo->y + cw->a.border_width;
@ -836,14 +826,17 @@ border_size(EObj * eo)
Pixmap
ECompMgrWinGetPixmap(const EObj * eo)
{
#if HAS_NAME_WINDOW_PIXMAP
ECmWinInfo *cw = eo->cmhook;
return (cw) ? cw->pixmap : None;
#else
eo = NULL;
return None;
#endif
if (!cw)
return None;
if (cw->pixmap != None)
return cw->pixmap;
cw->pixmap = XCompositeNameWindowPixmap(disp, eo->win);
return cw->pixmap;
}
static void
@ -855,18 +848,16 @@ ECompMgrWinInvalidate(EObj * eo, int what)
if (!cw)
return;
#if HAS_NAME_WINDOW_PIXMAP
if ((what & INV_SIZE) && cw->pixmap != None)
{
XFreePixmap(dpy, cw->pixmap);
cw->pixmap = None;
if (cw->picture != None)
if (cw->picture != None && Mode_compmgr.use_pixmap)
{
XRenderFreePicture(dpy, cw->picture);
cw->picture = None;
}
}
#endif
if ((what & INV_GEOM) && cw->borderSize != None)
{
@ -1005,21 +996,8 @@ ECompMgrWinSetPicts(EObj * eo)
return;
}
#if HAS_NAME_WINDOW_PIXMAP
if (cw->pixmap != None)
{
XFreePixmap(disp, cw->pixmap);
cw->pixmap = None;
if (cw->picture != None)
{
XRenderFreePicture(disp, cw->picture);
cw->picture = None;
}
Eprintf("*** ECompMgrWinSetPicts pixmap set!!!\n");
}
if (Mode_compmgr.use_pixmap)
if (cw->pixmap == None && Mode_compmgr.use_pixmap)
cw->pixmap = XCompositeNameWindowPixmap(disp, eo->win);
#endif
if (cw->picture == None)
{
@ -1027,10 +1005,9 @@ ECompMgrWinSetPicts(EObj * eo)
XRenderPictureAttributes pa;
Drawable draw = eo->win;
#if HAS_NAME_WINDOW_PIXMAP
if (cw->pixmap)
if (cw->pixmap && Mode_compmgr.use_pixmap)
draw = cw->pixmap;
#endif
pictfmt = XRenderFindVisualFormat(disp, cw->a.visual);
pa.subwindow_mode = IncludeInferiors;
cw->picture = XRenderCreatePicture(disp, draw,
@ -1081,9 +1058,7 @@ ECompMgrWinNew(EObj * eo)
}
cw->picture = None;
#if HAS_NAME_WINDOW_PIXMAP
cw->pixmap = None;
#endif
#if 0 /* FIXME - Remove? */
ECompMgrWinSetPicts(eo);
#endif
@ -2103,15 +2078,14 @@ ECompMgrInit(void)
goto done;
}
if (!XDamageQueryVersion(disp, &major, &minor))
if (!XCompositeQueryVersion(disp, &major, &minor) ||
(major == 0 && minor < 2))
{
Conf_compmgr.mode = ECM_MODE_OFF;
goto done;
}
#if HAS_NAME_WINDOW_PIXMAP
Mode_compmgr.use_pixmap =
(major > 0 || minor >= 2) && Conf_compmgr.use_name_pixmap;
#endif
Mode_compmgr.use_pixmap = Conf_compmgr.use_name_pixmap;
if (Conf_compmgr.mode == ECM_MODE_OFF)
Conf_compmgr.mode = ECM_MODE_ROOT;

View File

@ -422,16 +422,20 @@ EobjChangeShape(EObj * eo)
#endif
}
#if USE_COMPOSITE
Pixmap
EobjGetPixmap(const EObj * eo)
{
Pixmap pmap = None;
#if USE_COMPOSITE
pmap = ECompMgrWinGetPixmap(eo);
#else
eo = NULL;
#endif
return pmap;
}
#if USE_COMPOSITE
void
EobjChangeOpacity(EObj * eo, unsigned int opacity)
{

View File

@ -103,7 +103,6 @@ IB_SnapEWin(EWin * ewin, int size)
h = hh;
}
#if USE_COMPOSITE
draw = EoGetPixmap(ewin);
if (draw != None)
{
@ -114,20 +113,17 @@ IB_SnapEWin(EWin * ewin, int size)
im = imlib_create_scaled_image_from_drawable(mask, 0, 0, ww, hh,
w, h, !EServerIsGrabbed(),
0);
imlib_context_set_image(im);
imlib_image_set_has_alpha(1); /* Should be set by imlib? */
}
else
#endif
{
draw = EoGetWin(ewin);
imlib_context_set_drawable(draw);
im = imlib_create_scaled_image_from_drawable(None, 0, 0, ww, hh,
w, h, !EServerIsGrabbed(),
1);
imlib_context_set_image(im);
imlib_image_set_has_alpha(1); /* Should be set by imlib? */
}
imlib_context_set_image(im);
imlib_image_set_has_alpha(1);
return im;
}