better focus setup, add experimental zero shadow option
This commit is contained in:
parent
6a71094d8a
commit
9b973d6e12
56
compton.c
56
compton.c
|
@ -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,7 +581,7 @@ make_shadow(Display *dpy, double opacity,
|
||||||
* center (fill the complete data array)
|
* center (fill the complete data array)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if 0
|
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 {
|
||||||
|
@ -587,10 +590,10 @@ make_shadow(Display *dpy, double opacity,
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(data, d, sheight * swidth);
|
memset(data, d, sheight * swidth);
|
||||||
#endif
|
} else {
|
||||||
|
|
||||||
// zero the pixmap
|
// zero the pixmap
|
||||||
memset(data, 0, sheight * swidth);
|
memset(data, 0, sheight * swidth);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* corners
|
* corners
|
||||||
|
@ -621,10 +624,6 @@ make_shadow(Display *dpy, double opacity,
|
||||||
* top/bottom
|
* top/bottom
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// shadow_radius is 12 by default
|
|
||||||
// this makes gsize 36 by default
|
|
||||||
//ylimit -= (shadow_radius + 4);
|
|
||||||
|
|
||||||
x_diff = swidth - (gsize * 2);
|
x_diff = swidth - (gsize * 2);
|
||||||
if (x_diff > 0 && ylimit > 0) {
|
if (x_diff > 0 && ylimit > 0) {
|
||||||
for (y = 0; y < ylimit; y++) {
|
for (y = 0; y < ylimit; y++) {
|
||||||
|
@ -639,15 +638,10 @@ make_shadow(Display *dpy, double opacity,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ylimit = gsize;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sides
|
* sides
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//xlimit -= (shadow_radius + 4);
|
|
||||||
//gsize = 16;
|
|
||||||
|
|
||||||
for (x = 0; x < xlimit; x++) {
|
for (x = 0; x < xlimit; x++) {
|
||||||
if (xlimit == Gsize) {
|
if (xlimit == Gsize) {
|
||||||
d = shadow_top[opacity_int * (Gsize + 1) + x];
|
d = shadow_top[opacity_int * (Gsize + 1) + x];
|
||||||
|
@ -662,17 +656,14 @@ make_shadow(Display *dpy, double opacity,
|
||||||
}
|
}
|
||||||
|
|
||||||
// zero extra pixels
|
// zero extra pixels
|
||||||
|
if (clear_shadow)
|
||||||
if (width > gsize && height > gsize) {
|
if (width > gsize && height > gsize) {
|
||||||
//int r = shadow_radius;
|
|
||||||
//int sr = r + 4;
|
|
||||||
//int er = r + 8;
|
|
||||||
int r = gsize / 2;
|
int r = gsize / 2;
|
||||||
int sr = r - 2;
|
int sr = r - 2;
|
||||||
int er = r + 4;
|
int er = r + 4;
|
||||||
for (y = sr; y < (sheight - er); y++) {
|
for (y = sr; y < (sheight - er); y++) {
|
||||||
for (x = sr; x < (swidth - er); x++) {
|
for (x = sr; x < (swidth - er); x++) {
|
||||||
//data[y * swidth + x] = 0;
|
data[y * swidth + x] = 0;
|
||||||
data[y * swidth + x] = 50;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -908,7 +899,7 @@ win_extents(Display *dpy, win *w) {
|
||||||
if (!w->shadow) {
|
if (!w->shadow) {
|
||||||
double opacity = shadow_opacity;
|
double opacity = shadow_opacity;
|
||||||
|
|
||||||
#if 0
|
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);
|
||||||
}
|
}
|
||||||
|
@ -916,7 +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;
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
w->shadow = shadow_picture(
|
w->shadow = shadow_picture(
|
||||||
dpy, opacity, w->alpha_pict,
|
dpy, opacity, w->alpha_pict,
|
||||||
|
@ -2219,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");
|
||||||
|
@ -2299,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;
|
||||||
|
@ -2363,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':
|
||||||
|
@ -2531,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);
|
||||||
|
@ -2546,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)) {
|
||||||
|
|
Loading…
Reference in New Issue