X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=7b3c0abf8688a2f11ab25720415f5b0323cf9964;hp=b902b3b53997efa3ad30ae65dcc2c523c9736237;hb=52d205e6ebfddbfea35ef92630cef55d2d8795e0;hpb=78b170ad113be58d6b22452a6e4fd080c5429be2 diff --git a/dwm.c b/dwm.c index b902b3b..7b3c0ab 100644 --- a/dwm.c +++ b/dwm.c @@ -61,7 +61,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMFullscreen, NetWMWindowOpacity, NetActiveWindow, NetWMWindowType, - NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ + NetWMWindowTypeDialog, NetClientList, NetSupportingWMCheck, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ @@ -90,6 +90,7 @@ struct Client { 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; @@ -210,6 +211,7 @@ static void sigchld(int unused); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); +static void jason_layout(Monitor *); static void tile(Monitor *); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); @@ -271,16 +273,59 @@ static Monitor *mons, *selmon; static Window root; // unfocused windows get transparent (feature) -static const unsigned long unfocused_opacity[] = { 0xbfffffff }; +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) { + 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); + } + } + } } @@ -842,6 +887,7 @@ focus(Client *c) { XDeleteProperty(dpy, root, netatom[NetActiveWindow]); } selmon->sel = c; + update_window_opacities(selmon); drawbars(); if(c && (!root || (c->win!=root)) ) window_set_opaque(c); @@ -1062,6 +1108,7 @@ manage(Window w, XWindowAttributes *wa) { 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))) { @@ -1584,6 +1631,7 @@ setup(void) { netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); + netatom[NetSupportingWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); /* init cursors */ cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); cursor[CurResize] = drw_cur_create(drw, XC_sizing); @@ -1645,8 +1693,8 @@ spawn(const Arg *arg) { break; } } - _SWM_WS[8] = swm_tags[tag][0]; - _SWM_WS[9] = swm_tags[tag][1]; + WORKSPACE_NUMBER[17] = workspace_numbers_str[tag][0]; + WORKSPACE_NUMBER[18] = workspace_numbers_str[tag][1]; } if(arg->v == dmenucmd) dmenumon[0] = '0' + selmon->num; @@ -1709,6 +1757,47 @@ tile(Monitor *m) { } void +jason_layout(Monitor *m) { + unsigned int i, n, mw; + Client *c, *vis_slave; + + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if(n == 0) { + return; + } + + c = nexttiled(m->clients); + if (c == m->sel) { + // if master is selected, show first slave + vis_slave = nexttiled(c->next); + } else { + vis_slave = m->sel; + } + if(n > 1 || (n == 1 && !c->screen_hog)) { + mw = m->ww * m->mfact; + } else { + // one of these: + // * zero tiled windows + // * one tiled window that's not a screen hog + // * miltiple tiled windows + mw = m->ww; + } + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i == 0) { + resize(c, m->wx, m->wy, mw, m->wh, False); + } else { + if (c == vis_slave) { + resize(c, m->wx + mw, m->wy, m->ww - mw, m->wh, False); + } else { + // this function does not get called when focus changes + // resize(c, m->wx + m->ww, m->wy, m->ww - mw, m->wh, False); + resize(c, m->wx + mw, m->wy, m->ww - mw, m->wh, False); + } + } + } +} + +void togglebar(const Arg *arg) { selmon->showbar = !selmon->showbar; updatebarpos(selmon); @@ -1758,8 +1847,6 @@ void unfocus(Client *c, Bool setfocus) { if(!c) return; - if(!root || c->win!=root) - window_set_translucent(c); grabbuttons(c, False); XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->rgb); if(setfocus) { @@ -1820,6 +1907,12 @@ updatebars(void) { m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); + XChangeProperty(dpy, root, netatom[NetSupportingWMCheck], XA_WINDOW, 32, + PropModeReplace, (unsigned char *) &(m->barwin), 1); + XChangeProperty(dpy, m->barwin, netatom[NetSupportingWMCheck], XA_WINDOW, 32, + PropModeReplace, (unsigned char *) &(m->barwin), 1); + XChangeProperty(dpy, m->barwin, netatom[NetWMName], XA_STRING, 8, + PropModeReplace, (unsigned char *) "dwm", 3); XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); XMapRaised(dpy, m->barwin); }