int oldx, oldy, oldw, oldh;
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
+ int opacity;
unsigned int tags;
Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, screen_hog;
Client *next;
static Window root;
// unfocused windows get transparent (feature)
-static const unsigned long unfocused_opacity[] = { 0xbfffffff };
-static const unsigned long invisible_opacity[] = { 0x00000000 };
+static const unsigned long opacities[] = { 0, 0xbfffffff, 0x00000000 }; // first unused
static void window_set_opaque(Client *c);
static void window_set_translucent(Client *c);
static void window_set_invisible(Client *c);
+static void window_set_opacity(Client *c, int opacity_index);
+static void update_window_opacities(Monitor *m);
+void
+window_set_opacity(Client *c, int opacity_index) {
+ if (c->opacity == opacity_index) {
+ return;
+ }
+ c->opacity = opacity_index;
+ if (opacity_index == 0) {
+ XDeleteProperty(dpy, c->win, netatom[NetWMWindowOpacity]);
+ } else {
+ XChangeProperty(dpy, c->win, netatom[NetWMWindowOpacity], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)(&opacities[opacity_index]), 1);
+ }
+}
void
window_set_opaque(Client *c) {
- XDeleteProperty(dpy, c->win, netatom[NetWMWindowOpacity]);
+ window_set_opacity(c, 0);
}
void
window_set_translucent(Client *c) {
- XChangeProperty(dpy, c->win, netatom[NetWMWindowOpacity], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)unfocused_opacity, 1);
+ window_set_opacity(c, 1);
}
void
window_set_invisible(Client *c) {
- XChangeProperty(dpy, c->win, netatom[NetWMWindowOpacity], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)invisible_opacity, 1);
+ window_set_opacity(c, 2);
+}
+void
+update_window_opacities(Monitor *m) {
+ Client *master, *slave, *c;
+ Bool selection_floating = False;
+ slave = master = nexttiled(m->clients);
+ if (master) slave = nexttiled(master->next);
+ if (m->sel && m->sel != master) {
+ if (nexttiled(m->sel) == m->sel) // if selection is tiled
+ slave = m->sel;
+ else
+ selection_floating = True;
+ }
+ for (c = m->clients; c; c = c->next) {
+ if (ISVISIBLE(c)) {
+ if (c->isfloating || c == m->sel || (c == master && selection_floating)) {
+ window_set_opaque(c);
+ } else if (c == master || c == slave) {
+ window_set_translucent(c);
+ } else {
+ window_set_invisible(c);
+ }
+ }
+ }
}
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
}
selmon->sel = c;
+ update_window_opacities(selmon);
drawbars();
if(c && (!root || (c->win!=root)) )
window_set_opaque(c);
if(!(c = calloc(1, sizeof(Client))))
die("fatal: could not malloc() %u bytes\n", sizeof(Client));
+ c->opacity = -1; // who knows
c->win = w;
updatetitle(c);
if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
void
unfocus(Client *c, Bool setfocus) {
- Client *w;
if(!c)
return;
- if(!root || c->win!=root) {
- w = nexttiled(c->mon->clients);
- if (!w) {
- // no tiled windows
- window_set_translucent(c);
- } else if (w == c) {
- // master
- window_set_translucent(c);
- } else {
- w = nexttiled(w->next);
- if (!w) {
- // c must not be tiled
- window_set_translucent(c);
- } else {
- if (w == c) { // first slave
- window_set_translucent(c);
- } else {
- window_set_invisible(c);
- window_set_translucent(w);
- }
- }
- }
- }
grabbuttons(c, False);
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->rgb);
if(setfocus) {