better focus setup, add experimental zero shadow option

This commit is contained in:
Christopher Jeffrey 2012-02-04 21:46:13 -06:00
parent 6a71094d8a
commit 9b973d6e12
1 changed files with 25 additions and 31 deletions

View File

@ -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)) {