dwm-swapfocus-6.0.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-swapfocus-6.0.diff (1482B)
---
1 URL: http://dwm.suckless.org/patches/swapfocus
2 This patch makes it possible to switch focus with one single shortcut (alt-s)
3 instead of having to think if you should use alt-j or alt-k for reaching the
4 last used window.
5
6 diff -r ec4baab78314 dwm.c
7 --- a/dwm.c Mon Dec 19 15:38:30 2011 +0100
8 +++ b/dwm.c Fri Apr 06 08:23:42 2012 +0200
9 @@ -224,6 +224,7 @@
10 static void showhide(Client *c);
11 static void sigchld(int unused);
12 static void spawn(const Arg *arg);
13 +static void swapfocus();
14 static void tag(const Arg *arg);
15 static void tagmon(const Arg *arg);
16 static int textnw(const char *text, unsigned int len);
17 @@ -253,6 +254,7 @@
18 static void zoom(const Arg *arg);
19
20 /* variables */
21 +static Client *prevclient = NULL;
22 static const char broken[] = "broken";
23 static char stext[256];
24 static int screen;
25 @@ -1675,6 +1677,14 @@
26 }
27
28 void
29 +swapfocus(){
30 + Client *c;
31 + for(c = selmon->clients; c && c != prevclient; c = c->next) ;
32 + if(c == prevclient)
33 + focus(prevclient);
34 +}
35 +
36 +void
37 tag(const Arg *arg) {
38 if(selmon->sel && arg->ui & TAGMASK) {
39 selmon->sel->tags = arg->ui & TAGMASK;
40 @@ -1775,6 +1785,7 @@
41 unfocus(Client *c, Bool setfocus) {
42 if(!c)
43 return;
44 + prevclient = c;
45 grabbuttons(c, False);
46 XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
47 if(setfocus)
48 @@ -2116,6 +2127,7 @@
49 void
50 zoom(const Arg *arg) {
51 Client *c = selmon->sel;
52 + prevclient = selmon->clients;
53
54 if(!selmon->lt[selmon->sellt]->arrange
55 || (selmon->sel && selmon->sel->isfloating))