Detect ARGB windows, don't give them shadows, compose them correctly.
This commit is contained in:
parent
41293ef755
commit
54fb13fa32
|
@ -1,3 +1,9 @@
|
||||||
|
2003-11-11 Keith Packard <keithp@keithp.com>
|
||||||
|
|
||||||
|
* xcompmgr.c: (win_extents), (paint_all), (add_win), (main):
|
||||||
|
Detect ARGB windows, don't give them shadows, compose them
|
||||||
|
correctly.
|
||||||
|
|
||||||
2003-11-10 Keith Packard <keithp@keithp.com>
|
2003-11-10 Keith Packard <keithp@keithp.com>
|
||||||
|
|
||||||
* Makefile:
|
* Makefile:
|
||||||
|
|
43
xcompmgr.c
43
xcompmgr.c
|
@ -66,9 +66,11 @@ XserverRegion allDamage;
|
||||||
int root_height, root_width;
|
int root_height, root_width;
|
||||||
|
|
||||||
#define BACKGROUND_PROP "_XROOTPMAP_ID"
|
#define BACKGROUND_PROP "_XROOTPMAP_ID"
|
||||||
#define WINDOW_PLAIN 0
|
|
||||||
#define WINDOW_DROP 1
|
#define WINDOW_SOLID 0
|
||||||
#define WINDOW_TRANS 2
|
#define WINDOW_TRANS 1
|
||||||
|
#define WINDOW_ARGB 2
|
||||||
|
|
||||||
#define TRANS_OPACITY 0.75
|
#define TRANS_OPACITY 0.75
|
||||||
#define SHADOW_RADIUS 15
|
#define SHADOW_RADIUS 15
|
||||||
#define SHADOW_OPACITY 0.75
|
#define SHADOW_OPACITY 0.75
|
||||||
|
@ -374,6 +376,15 @@ win_extents (Display *dpy, win *w)
|
||||||
{
|
{
|
||||||
XRectangle r;
|
XRectangle r;
|
||||||
|
|
||||||
|
if (w->mode == WINDOW_ARGB)
|
||||||
|
{
|
||||||
|
r.x = w->a.x;
|
||||||
|
r.y = w->a.y;
|
||||||
|
r.width = w->a.width + w->a.border_width * 2;
|
||||||
|
r.height = w->a.height + w->a.border_width * 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (!w->shadow)
|
if (!w->shadow)
|
||||||
{
|
{
|
||||||
double opacity = SHADOW_OPACITY;
|
double opacity = SHADOW_OPACITY;
|
||||||
|
@ -389,6 +400,7 @@ win_extents (Display *dpy, win *w)
|
||||||
r.y = w->a.y + w->a.border_width + w->shadow_dy;
|
r.y = w->a.y + w->a.border_width + w->shadow_dy;
|
||||||
r.width = w->shadow_width;
|
r.width = w->shadow_width;
|
||||||
r.height = w->shadow_height;
|
r.height = w->shadow_height;
|
||||||
|
}
|
||||||
return XFixesCreateRegion (dpy, &r, 1);
|
return XFixesCreateRegion (dpy, &r, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +455,7 @@ paint_all (Display *dpy, XserverRegion region)
|
||||||
if (w->extents)
|
if (w->extents)
|
||||||
XFixesDestroyRegion (dpy, w->extents);
|
XFixesDestroyRegion (dpy, w->extents);
|
||||||
w->extents = win_extents (dpy, w);
|
w->extents = win_extents (dpy, w);
|
||||||
if (w->mode != WINDOW_TRANS)
|
if (w->mode == WINDOW_SOLID)
|
||||||
{
|
{
|
||||||
XFixesSetPictureClipRegion (dpy, rootBuffer, 0, 0, region);
|
XFixesSetPictureClipRegion (dpy, rootBuffer, 0, 0, region);
|
||||||
XFixesSubtractRegion (dpy, region, region, 0, 0, w->borderSize, 0, 0);
|
XFixesSubtractRegion (dpy, region, region, 0, 0, w->borderSize, 0, 0);
|
||||||
|
@ -479,6 +491,13 @@ paint_all (Display *dpy, XserverRegion region)
|
||||||
w->a.y + w->a.border_width,
|
w->a.y + w->a.border_width,
|
||||||
w->a.width,
|
w->a.width,
|
||||||
w->a.height);
|
w->a.height);
|
||||||
|
else if (w->mode == WINDOW_ARGB)
|
||||||
|
XRenderComposite (dpy, PictOpOver, w->picture, None, rootBuffer,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
w->a.x + w->a.border_width,
|
||||||
|
w->a.y + w->a.border_width,
|
||||||
|
w->a.width,
|
||||||
|
w->a.height);
|
||||||
XFixesDestroyRegion (dpy, w->borderClip);
|
XFixesDestroyRegion (dpy, w->borderClip);
|
||||||
w->borderClip = None;
|
w->borderClip = None;
|
||||||
}
|
}
|
||||||
|
@ -560,6 +579,7 @@ add_win (Display *dpy, Window id, Window prev)
|
||||||
win **p;
|
win **p;
|
||||||
XWindowAttributes a;
|
XWindowAttributes a;
|
||||||
XRenderPictureAttributes pa;
|
XRenderPictureAttributes pa;
|
||||||
|
XRenderPictFormat *format;
|
||||||
|
|
||||||
if (!new)
|
if (!new)
|
||||||
return;
|
return;
|
||||||
|
@ -581,12 +601,15 @@ add_win (Display *dpy, Window id, Window prev)
|
||||||
new->damage = None;
|
new->damage = None;
|
||||||
pa.subwindow_mode = IncludeInferiors;
|
pa.subwindow_mode = IncludeInferiors;
|
||||||
if (new->a.class == InputOnly)
|
if (new->a.class == InputOnly)
|
||||||
|
{
|
||||||
new->picture = 0;
|
new->picture = 0;
|
||||||
|
format = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
format = XRenderFindVisualFormat (dpy, new->a.visual);
|
||||||
new->picture = XRenderCreatePicture (dpy, id,
|
new->picture = XRenderCreatePicture (dpy, id,
|
||||||
XRenderFindVisualFormat (dpy,
|
format,
|
||||||
new->a.visual),
|
|
||||||
CPSubwindowMode,
|
CPSubwindowMode,
|
||||||
&pa);
|
&pa);
|
||||||
}
|
}
|
||||||
|
@ -594,10 +617,12 @@ add_win (Display *dpy, Window id, Window prev)
|
||||||
new->shadow = None;
|
new->shadow = None;
|
||||||
new->borderSize = None;
|
new->borderSize = None;
|
||||||
new->extents = None;
|
new->extents = None;
|
||||||
if (new->a.override_redirect)
|
if (format && format->type == PictTypeDirect && format->direct.alphaMask)
|
||||||
|
new->mode = WINDOW_ARGB;
|
||||||
|
else if (new->a.override_redirect)
|
||||||
new->mode = WINDOW_TRANS;
|
new->mode = WINDOW_TRANS;
|
||||||
else
|
else
|
||||||
new->mode = WINDOW_DROP;
|
new->mode = WINDOW_SOLID;
|
||||||
new->next = *p;
|
new->next = *p;
|
||||||
*p = new;
|
*p = new;
|
||||||
if (new->a.map_state == IsViewable)
|
if (new->a.map_state == IsViewable)
|
||||||
|
@ -816,7 +841,6 @@ main ()
|
||||||
allDamage = None;
|
allDamage = None;
|
||||||
XGrabServer (dpy);
|
XGrabServer (dpy);
|
||||||
XCompositeRedirectSubwindows (dpy, root, CompositeRedirectManual);
|
XCompositeRedirectSubwindows (dpy, root, CompositeRedirectManual);
|
||||||
paint_all (dpy, None);
|
|
||||||
XSelectInput (dpy, root,
|
XSelectInput (dpy, root,
|
||||||
SubstructureNotifyMask|
|
SubstructureNotifyMask|
|
||||||
ExposureMask|
|
ExposureMask|
|
||||||
|
@ -827,6 +851,7 @@ main ()
|
||||||
add_win (dpy, children[i], i ? children[i-1] : None);
|
add_win (dpy, children[i], i ? children[i-1] : None);
|
||||||
XFree (children);
|
XFree (children);
|
||||||
XUngrabServer (dpy);
|
XUngrabServer (dpy);
|
||||||
|
paint_all (dpy, None);
|
||||||
last_update = time_in_millis ();
|
last_update = time_in_millis ();
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue