Merge branch 'clear_shadow'

This commit is contained in:
Christopher Jeffrey 2012-02-05 00:10:27 -06:00
commit ca5ef3978e
1 changed files with 38 additions and 12 deletions

View File

@ -179,6 +179,8 @@ int fade_delta = 10;
int fade_time = 0; int fade_time = 0;
Bool fade_trans = False; Bool fade_trans = False;
Bool clear_shadow = False;
double inactive_opacity = 0; double inactive_opacity = 0;
double frame_opacity = 0; double frame_opacity = 0;
@ -188,6 +190,7 @@ double frame_opacity = 0;
#define IS_NORMAL_WIN(w) \ #define IS_NORMAL_WIN(w) \
((w) && ((w)->window_type == WINTYPE_NORMAL \ ((w) && ((w)->window_type == WINTYPE_NORMAL \
|| (w)->window_type == WINTYPE_UTILITY)) || (w)->window_type == WINTYPE_UTILITY))
// || (w)->window_type == WINTYPE_UNKNOWN))
#define HAS_FRAME_OPACITY(w) (frame_opacity && (w)->top_width) #define HAS_FRAME_OPACITY(w) (frame_opacity && (w)->top_width)
@ -578,6 +581,7 @@ make_shadow(Display *dpy, double opacity,
* center (fill the complete data array) * center (fill the complete data array)
*/ */
if (!clear_shadow) {
if (Gsize > 0) { if (Gsize > 0) {
d = shadow_top[opacity_int * (Gsize + 1) + Gsize]; d = shadow_top[opacity_int * (Gsize + 1) + Gsize];
} else { } else {
@ -586,6 +590,10 @@ make_shadow(Display *dpy, double opacity,
} }
memset(data, d, sheight * swidth); memset(data, d, sheight * swidth);
} else {
// zero the pixmap
memset(data, 0, sheight * swidth);
}
/* /*
* corners * corners
@ -647,6 +655,19 @@ make_shadow(Display *dpy, double opacity,
} }
} }
// zero extra pixels
if (clear_shadow)
if (width > gsize && height > gsize) {
int r = gsize / 2;
int sr = r - 2;
int er = r + 4;
for (y = sr; y < (sheight - er); y++) {
for (x = sr; x < (swidth - er); x++) {
data[y * swidth + x] = 0;
}
}
}
return ximage; return ximage;
} }
@ -878,6 +899,7 @@ win_extents(Display *dpy, win *w) {
if (!w->shadow) { if (!w->shadow) {
double opacity = shadow_opacity; double opacity = shadow_opacity;
if (!clear_shadow) {
if (w->mode != WINDOW_SOLID) { if (w->mode != WINDOW_SOLID) {
opacity = opacity * ((double)w->opacity) / ((double)OPAQUE); opacity = opacity * ((double)w->opacity) / ((double)OPAQUE);
} }
@ -885,6 +907,7 @@ win_extents(Display *dpy, win *w) {
if (HAS_FRAME_OPACITY(w)) { if (HAS_FRAME_OPACITY(w)) {
opacity = opacity * frame_opacity; opacity = opacity * frame_opacity;
} }
}
w->shadow = shadow_picture( w->shadow = shadow_picture(
dpy, opacity, w->alpha_pict, dpy, opacity, w->alpha_pict,
@ -2187,6 +2210,9 @@ usage(char *program) {
fprintf(stderr, fprintf(stderr,
" -C\n " " -C\n "
"Avoid drawing shadows on dock/panel windows.\n"); "Avoid drawing shadows on dock/panel windows.\n");
fprintf(stderr,
" -z\n "
"Zero the part of the shadow's mask behind the window (experimental).");
fprintf(stderr, fprintf(stderr,
" -f\n " " -f\n "
"Fade windows in/out when opening/closing.\n"); "Fade windows in/out when opening/closing.\n");
@ -2267,7 +2293,7 @@ main(int argc, char **argv) {
/* don't bother to draw a shadow for the desktop */ /* don't bother to draw a shadow for the desktop */
win_type_shadow[WINTYPE_DESKTOP] = False; win_type_shadow[WINTYPE_DESKTOP] = False;
while ((o = getopt(argc, argv, "D:I:O:d:r:o:m:l:t:i:e:scnfFCaS")) != -1) { while ((o = getopt(argc, argv, "D:I:O:d:r:o:m:l:t:i:e:scnfFCaSz")) != -1) {
switch (o) { switch (o) {
case 'd': case 'd':
display = optarg; display = optarg;
@ -2331,6 +2357,9 @@ main(int argc, char **argv) {
case 'e': case 'e':
frame_opacity = (double)atof(optarg); frame_opacity = (double)atof(optarg);
break; break;
case 'z':
clear_shadow = True;
break;
case 'n': case 'n':
case 'a': case 'a':
case 's': case 's':
@ -2499,12 +2528,6 @@ main(int argc, char **argv) {
case FocusIn: { case FocusIn: {
if (!inactive_opacity) break; if (!inactive_opacity) break;
// stop focusing windows the cursor is over.
// with this, windows dont focus right after being
// deiconified, this needs to be fixed by blocking
// the right kind of FocusOut event
if (ev.xfocus.detail == NotifyPointer) break;
win *fw = find_win(dpy, ev.xfocus.window); win *fw = find_win(dpy, ev.xfocus.window);
if (IS_NORMAL_WIN(fw)) { if (IS_NORMAL_WIN(fw)) {
set_opacity(dpy, fw, OPAQUE); set_opacity(dpy, fw, OPAQUE);
@ -2514,11 +2537,14 @@ main(int argc, char **argv) {
case FocusOut: { case FocusOut: {
if (!inactive_opacity) break; if (!inactive_opacity) break;
// this fixes deiconify refocus if (ev.xfocus.mode == NotifyGrab
// need != notifygrab here otherwise windows wont || (ev.xfocus.mode == NotifyNormal
// lower opacity when grabbed for dragging && (ev.xfocus.detail == NotifyNonlinear
if (ev.xfocus.mode != NotifyGrab || ev.xfocus.detail == NotifyNonlinearVirtual))) {
&& ev.xfocus.detail == NotifyVirtual) break; ;
} else {
break;
}
win *fw = find_win(dpy, ev.xfocus.window); win *fw = find_win(dpy, ev.xfocus.window);
if (IS_NORMAL_WIN(fw)) { if (IS_NORMAL_WIN(fw)) {