X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=5c25c2426c6d18ec3ddffbd135d903afafa17e8b;hp=6f716e9925912a11e9e436c624e5b6001d7aff7c;hb=99144036af9457eb08c709d3fba7f6ffb42039dc;hpb=6af273771cb0e28e4394c78ab0322f77025a57f3 diff --git a/dwm.c b/dwm.c index 6f716e9..5c25c24 100644 --- a/dwm.c +++ b/dwm.c @@ -60,7 +60,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, - NetWMFullscreen, NetActiveWindow, NetWMWindowType, + NetWMFullscreen, NetWMWindowOpacity, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, @@ -267,6 +267,20 @@ static Fnt *fnt; static Monitor *mons, *selmon; static Window root; +// unfocused windows get transparent (feature) +static const unsigned long unfocused_opacity[] = { 0xbfffffff }; +static void window_set_opaque(Client *c); +static void window_set_translucent(Client *c); +void +window_set_opaque(Client *c) { + XDeleteProperty(dpy, c->win, netatom[NetWMWindowOpacity]); +} +void +window_set_translucent(Client *c) { + XChangeProperty(dpy, c->win, netatom[NetWMWindowOpacity], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)unfocused_opacity, 1); +} + + /* configuration, allows nested code to access above variables */ #include "config.h" @@ -801,6 +815,8 @@ focus(Client *c) { } selmon->sel = c; drawbars(); + if(c && (!root || (c->win!=root)) ) + window_set_opaque(c); } void @@ -831,7 +847,14 @@ focusstack(const Arg *arg) { if(!selmon->sel) return; - if(arg->i > 0) { + if(arg->i == 0) { + for(i = selmon->clients; i != selmon->sel; i = i->next) { + if(ISVISIBLE(i)) { + c = i; + break; + } + } + } else if(arg->i > 0) { for(c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); if(!c) for(c = selmon->clients; c && !ISVISIBLE(c); c = c->next); @@ -1123,6 +1146,7 @@ movemouse(const Arg *arg) { Client *c; Monitor *m; XEvent ev; + Time lasttime = 0; if(!(c = selmon->sel)) return; @@ -1145,6 +1169,10 @@ movemouse(const Arg *arg) { handler[ev.type](&ev); break; case MotionNotify: + if ((ev.xmotion.time - lasttime) <= (1000 / 60)) + continue; + lasttime = ev.xmotion.time; + nx = ocx + (ev.xmotion.x - x); ny = ocy + (ev.xmotion.y - y); if(nx >= selmon->wx && nx <= selmon->wx + selmon->ww @@ -1264,11 +1292,11 @@ resizeclient(Client *c, int x, int y, int w, int h) { void resizemouse(const Arg *arg) { - int ocx, ocy; - int nw, nh; + int ocx, ocy, nw, nh; Client *c; Monitor *m; XEvent ev; + Time lasttime = 0; if(!(c = selmon->sel)) return; @@ -1290,6 +1318,10 @@ resizemouse(const Arg *arg) { handler[ev.type](&ev); break; case MotionNotify: + if ((ev.xmotion.time - lasttime) <= (1000 / 60)) + continue; + lasttime = ev.xmotion.time; + nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); if(c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww @@ -1514,6 +1546,7 @@ setup(void) { netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); + netatom[NetWMWindowOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False); 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); @@ -1542,6 +1575,7 @@ setup(void) { XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); XSelectInput(dpy, root, wa.event_mask); grabkeys(); + focus(NULL); } void @@ -1674,6 +1708,8 @@ 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) { @@ -2045,7 +2081,7 @@ zoom(const Arg *arg) { int main(int argc, char *argv[]) { if(argc == 2 && !strcmp("-v", argv[1])) - die("dwm-"VERSION", © 2006-2012 dwm engineers, see LICENSE for details\n"); + die("dwm-"VERSION", © 2006-2014 dwm engineers, see LICENSE for details\n"); else if(argc != 1) die("usage: dwm [-v]\n"); if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())