diff --git a/client.c b/client.c index ee5a0d380..82d1ee0ae 100644 --- a/client.c +++ b/client.c @@ -143,6 +143,27 @@ setclientstate(Client * c, long state) PropModeReplace, (unsigned char *) data, 2); } +/** Set client transparency using composite + * \param c client + * \param opacity opacity percentage + */ +static void +setclienttrans(Client *c, double opacity) +{ + unsigned int real_opacity = 0xffffffff; + + if(opacity >= 0 && opacity <= 100) + { + real_opacity = ((opacity / 100.0) * 0xffffffff); + XChangeProperty(c->display, c->win, + XInternAtom(c->display, "_NET_WM_WINDOW_OPACITY", False), + XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &real_opacity, 1L); + } + else + XDeleteProperty(c->display, c->win, XInternAtom(c->display, "_NET_WM_WINDOW_OPACITY", False)); + + XSync(c->display, False); +} /* extern */ /** Attach client to the beginning of the clients stack @@ -231,7 +252,7 @@ focus(Display *disp, DC *drawcontext, Client * c, jdwm_config *jdwmconf) { grabbuttons(sel, False, jdwmconf->modkey, jdwmconf->numlockmask); XSetWindowBorder(sel->display, sel->win, drawcontext->norm[ColBorder]); - setclienttrans(sel, jdwmconf->opacity_unfocused, 0); + setclienttrans(sel, jdwmconf->opacity_unfocused); } if(c) { @@ -249,8 +270,8 @@ focus(Display *disp, DC *drawcontext, Client * c, jdwm_config *jdwmconf) XSetInputFocus(sel->display, sel->win, RevertToPointerRoot, CurrentTime); for(c = stack; c; c = c->snext) if(c != sel) - setclienttrans(c, jdwmconf->opacity_unfocused, 0); - setclienttrans(sel, -1, 0); + setclienttrans(c, jdwmconf->opacity_unfocused); + setclienttrans(sel, -1); } else XSetInputFocus(disp, DefaultRootWindow(disp), RevertToPointerRoot, CurrentTime); @@ -585,30 +606,11 @@ updatesizehints(Client * c) && c->maxw == c->minw && c->maxh == c->minh); } -void -setclienttrans(Client *c, double opacity, unsigned int current_opacity) -{ - unsigned int real_opacity = 0xffffffff; - - if(opacity >= 0 && opacity <= 100) - { - real_opacity = ((opacity / 100.0) * 0xffffffff) + current_opacity; - XChangeProperty(c->display, c->win, - XInternAtom(c->display, "_NET_WM_WINDOW_OPACITY", False), - XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &real_opacity, 1L); - } - else - XDeleteProperty(c->display, c->win, XInternAtom(c->display, "_NET_WM_WINDOW_OPACITY", False)); - - XSync(c->display, False); -} - void uicb_settrans(Display *disp __attribute__ ((unused)), jdwm_config *jdwmconf __attribute__ ((unused)), const char *arg) { - unsigned int current_opacity = 0; double delta = 100.0; unsigned char *data; Atom actual; @@ -628,6 +630,7 @@ uicb_settrans(Display *disp __attribute__ ((unused)), (unsigned char **) &data); if(data) { + unsigned int current_opacity = 0; memcpy(¤t_opacity, data, sizeof(unsigned int)); XFree((void *) data); delta += ((current_opacity * 100.0) / 0xffffffff); @@ -650,7 +653,7 @@ uicb_settrans(Display *disp __attribute__ ((unused)), } if(delta == 100.0 && !set_prop) - setclienttrans(sel, -1, 0); + setclienttrans(sel, -1); else - setclienttrans(sel, delta, current_opacity); + setclienttrans(sel, delta); } diff --git a/client.h b/client.h index 6d930ee3d..bb7710caf 100644 --- a/client.h +++ b/client.h @@ -44,6 +44,5 @@ void saveprops(Client * c, int); /* saves client properties */ void uicb_killclient(Display *, jdwm_config *, const char *); /* kill client */ void uicb_moveresize(Display *, jdwm_config *, const char *); /* move and resize window */ void uicb_settrans(Display *, jdwm_config *, const char *); -void setclienttrans(Client *c, double, unsigned int); #endif