From 75b0d38725a9dbbd1f43a27f94d70988298890d4 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 1 Feb 2012 13:52:35 -0600 Subject: [PATCH 1/5] clear rectangle in shadow --- compton.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/compton.c b/compton.c index 53224f1..8dd15a3 100644 --- a/compton.c +++ b/compton.c @@ -578,6 +578,7 @@ make_shadow(Display *dpy, double opacity, * center (fill the complete data array) */ +#if 0 if (Gsize > 0) { d = shadow_top[opacity_int * (Gsize + 1) + Gsize]; } else { @@ -586,6 +587,10 @@ make_shadow(Display *dpy, double opacity, } memset(data, d, sheight * swidth); +#endif + + // zero the pixmap + memset(data, 0, sheight * swidth); /* * corners @@ -616,6 +621,10 @@ make_shadow(Display *dpy, double opacity, * top/bottom */ + // shadow_radius is 12 by default + // this makes gsize 36 by default + //ylimit -= (shadow_radius + 4); + x_diff = swidth - (gsize * 2); if (x_diff > 0 && ylimit > 0) { for (y = 0; y < ylimit; y++) { @@ -630,10 +639,15 @@ make_shadow(Display *dpy, double opacity, } } + //ylimit = gsize; + /* * sides */ + //xlimit -= (shadow_radius + 4); + //gsize = 16; + for (x = 0; x < xlimit; x++) { if (xlimit == Gsize) { d = shadow_top[opacity_int * (Gsize + 1) + x]; @@ -647,6 +661,19 @@ make_shadow(Display *dpy, double opacity, } } + // zero extra pixels + //int r = shadow_radius; + //int sr = r + 4; + //int er = r + 8; + int r = gsize / 2; + int sr = r - 2; + int er = r + 2; + for (y = sr; y < (sheight - er); y++) { + for (x = sr; x < (swidth - er); x++) { + data[y * swidth + x] = 0; + } + } + return ximage; } @@ -878,6 +905,7 @@ win_extents(Display *dpy, win *w) { if (!w->shadow) { double opacity = shadow_opacity; +#if 0 if (w->mode != WINDOW_SOLID) { opacity = opacity * ((double)w->opacity) / ((double)OPAQUE); } @@ -885,6 +913,7 @@ win_extents(Display *dpy, win *w) { if (HAS_FRAME_OPACITY(w)) { opacity = opacity * frame_opacity; } +#endif w->shadow = shadow_picture( dpy, opacity, w->alpha_pict, From 73ab1244b14843fd948ebc1f8ce5742ed81d09a0 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 1 Feb 2012 13:57:52 -0600 Subject: [PATCH 2/5] different clear shadow dimensions --- compton.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compton.c b/compton.c index 8dd15a3..653a799 100644 --- a/compton.c +++ b/compton.c @@ -666,8 +666,8 @@ make_shadow(Display *dpy, double opacity, //int sr = r + 4; //int er = r + 8; int r = gsize / 2; - int sr = r - 2; - int er = r + 2; + int sr = r - 4; + int er = r + 4; for (y = sr; y < (sheight - er); y++) { for (x = sr; x < (swidth - er); x++) { data[y * swidth + x] = 0; From a2028a02f328094c2fe16584709f553aeb038495 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 1 Feb 2012 14:00:02 -0600 Subject: [PATCH 3/5] better dimensions? --- compton.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compton.c b/compton.c index 653a799..77907ca 100644 --- a/compton.c +++ b/compton.c @@ -662,11 +662,12 @@ make_shadow(Display *dpy, double opacity, } // zero extra pixels + //if (width > gsize && height > gsize) { //int r = shadow_radius; //int sr = r + 4; //int er = r + 8; int r = gsize / 2; - int sr = r - 4; + int sr = r - 2; int er = r + 4; for (y = sr; y < (sheight - er); y++) { for (x = sr; x < (swidth - er); x++) { From 6a71094d8a55381d2d0a2a1818cfb3997dce8c8d Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 4 Feb 2012 21:04:02 -0600 Subject: [PATCH 4/5] dont clear shadow on small windows --- compton.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/compton.c b/compton.c index 77907ca..0ffa003 100644 --- a/compton.c +++ b/compton.c @@ -662,16 +662,18 @@ make_shadow(Display *dpy, double opacity, } // zero extra pixels - //if (width > gsize && height > gsize) { - //int r = shadow_radius; - //int sr = r + 4; - //int er = r + 8; - 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; + if (width > gsize && height > gsize) { + //int r = shadow_radius; + //int sr = r + 4; + //int er = r + 8; + 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; + data[y * swidth + x] = 50; + } } } From 9b973d6e127a8049bf7a59d80c989ef3d55e906a Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 4 Feb 2012 21:46:13 -0600 Subject: [PATCH 5/5] better focus setup, add experimental zero shadow option --- compton.c | 56 +++++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/compton.c b/compton.c index 0ffa003..2a03bee 100644 --- a/compton.c +++ b/compton.c @@ -179,6 +179,8 @@ int fade_delta = 10; int fade_time = 0; Bool fade_trans = False; +Bool clear_shadow = False; + double inactive_opacity = 0; double frame_opacity = 0; @@ -188,6 +190,7 @@ double frame_opacity = 0; #define IS_NORMAL_WIN(w) \ ((w) && ((w)->window_type == WINTYPE_NORMAL \ || (w)->window_type == WINTYPE_UTILITY)) +// || (w)->window_type == WINTYPE_UNKNOWN)) #define HAS_FRAME_OPACITY(w) (frame_opacity && (w)->top_width) @@ -578,7 +581,7 @@ make_shadow(Display *dpy, double opacity, * center (fill the complete data array) */ -#if 0 +if (!clear_shadow) { if (Gsize > 0) { d = shadow_top[opacity_int * (Gsize + 1) + Gsize]; } else { @@ -587,10 +590,10 @@ make_shadow(Display *dpy, double opacity, } memset(data, d, sheight * swidth); -#endif - +} else { // zero the pixmap memset(data, 0, sheight * swidth); +} /* * corners @@ -621,10 +624,6 @@ make_shadow(Display *dpy, double opacity, * top/bottom */ - // shadow_radius is 12 by default - // this makes gsize 36 by default - //ylimit -= (shadow_radius + 4); - x_diff = swidth - (gsize * 2); if (x_diff > 0 && ylimit > 0) { for (y = 0; y < ylimit; y++) { @@ -639,15 +638,10 @@ make_shadow(Display *dpy, double opacity, } } - //ylimit = gsize; - /* * sides */ - //xlimit -= (shadow_radius + 4); - //gsize = 16; - for (x = 0; x < xlimit; x++) { if (xlimit == Gsize) { d = shadow_top[opacity_int * (Gsize + 1) + x]; @@ -662,17 +656,14 @@ make_shadow(Display *dpy, double opacity, } // zero extra pixels + if (clear_shadow) if (width > gsize && height > gsize) { - //int r = shadow_radius; - //int sr = r + 4; - //int er = r + 8; 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; - data[y * swidth + x] = 50; + data[y * swidth + x] = 0; } } } @@ -908,7 +899,7 @@ win_extents(Display *dpy, win *w) { if (!w->shadow) { double opacity = shadow_opacity; -#if 0 +if (!clear_shadow) { if (w->mode != WINDOW_SOLID) { opacity = opacity * ((double)w->opacity) / ((double)OPAQUE); } @@ -916,7 +907,7 @@ win_extents(Display *dpy, win *w) { if (HAS_FRAME_OPACITY(w)) { opacity = opacity * frame_opacity; } -#endif +} w->shadow = shadow_picture( dpy, opacity, w->alpha_pict, @@ -2219,6 +2210,9 @@ usage(char *program) { fprintf(stderr, " -C\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, " -f\n " "Fade windows in/out when opening/closing.\n"); @@ -2299,7 +2293,7 @@ main(int argc, char **argv) { /* don't bother to draw a shadow for the desktop */ 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) { case 'd': display = optarg; @@ -2363,6 +2357,9 @@ main(int argc, char **argv) { case 'e': frame_opacity = (double)atof(optarg); break; + case 'z': + clear_shadow = True; + break; case 'n': case 'a': case 's': @@ -2531,12 +2528,6 @@ main(int argc, char **argv) { case FocusIn: { 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); if (IS_NORMAL_WIN(fw)) { set_opacity(dpy, fw, OPAQUE); @@ -2546,11 +2537,14 @@ main(int argc, char **argv) { case FocusOut: { if (!inactive_opacity) break; - // this fixes deiconify refocus - // need != notifygrab here otherwise windows wont - // lower opacity when grabbed for dragging - if (ev.xfocus.mode != NotifyGrab - && ev.xfocus.detail == NotifyVirtual) break; + if (ev.xfocus.mode == NotifyGrab + || (ev.xfocus.mode == NotifyNormal + && (ev.xfocus.detail == NotifyNonlinear + || ev.xfocus.detail == NotifyNonlinearVirtual))) { + ; + } else { + break; + } win *fw = find_win(dpy, ev.xfocus.window); if (IS_NORMAL_WIN(fw)) {