about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--client.c46
-rw-r--r--config.mk10
-rw-r--r--dwm.h3
-rw-r--r--tag.c7
4 files changed, 45 insertions, 21 deletions
diff --git a/client.c b/client.c
index 1bdebd2..34c69aa 100644
--- a/client.c
+++ b/client.c
@@ -77,7 +77,6 @@ focusnext(Arg *arg)
 		c = getnext(clients, tsel);
 	if(c) {
 		higher(c);
-		c->revert = sel;
 		focus(c);
 	}
 }
@@ -93,7 +92,11 @@ focusprev(Arg *arg)
 	if(sel->ismax)
 		togglemax(NULL);
 
-	if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
+	if(!(c = getprev(sel->prev))) {
+		for(c = clients; c && c->next; c = c->next);
+		c = getprev(c);
+	}
+	if(c) {
 		higher(c);
 		focus(c);
 	}
@@ -127,6 +130,8 @@ gravitate(Client *c, Bool invert)
 	int dx = 0, dy = 0;
 
 	switch(c->grav) {
+	default:
+		break;
 	case StaticGravity:
 	case NorthWestGravity:
 	case NorthGravity:
@@ -143,11 +148,11 @@ gravitate(Client *c, Bool invert)
 	case SouthWestGravity:
 		dy = -(c->h);
 		break;
-	default:
-		break;
 	}
 
 	switch (c->grav) {
+	default:
+		break;
 	case StaticGravity:
 	case NorthWestGravity:
 	case WestGravity:
@@ -164,8 +169,6 @@ gravitate(Client *c, Bool invert)
 	case SouthEastGravity:
 		dx = -(c->w + c->border);
 		break;
-	default:
-		break;
 	}
 
 	if(invert) {
@@ -204,7 +207,6 @@ lower(Client *c)
 void
 manage(Window w, XWindowAttributes *wa)
 {
-	int diff;
 	Client *c;
 	Window trans;
 	XSetWindowAttributes twa;
@@ -224,7 +226,7 @@ manage(Window w, XWindowAttributes *wa)
 	c->proto = getproto(c->win);
 	setsize(c);
 	XSelectInput(dpy, c->win,
-			StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
+		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
 	XGetTransientForHint(dpy, c->win, &trans);
 	twa.override_redirect = 1;
 	twa.background_pixmap = ParentRelative;
@@ -237,6 +239,8 @@ manage(Window w, XWindowAttributes *wa)
 
 	settags(c);
 
+	if(clients)
+		clients->prev = c;
 	c->next = clients;
 	clients = c;
 
@@ -264,6 +268,7 @@ manage(Window w, XWindowAttributes *wa)
 	else {
 		XMapRaised(dpy, c->win);
 		XMapRaised(dpy, c->title);
+
 	}
 }
 
@@ -273,9 +278,15 @@ pop(Client *c)
 	Client **l;
 
 	for(l = &clients; *l && *l != c; l = &(*l)->next);
+	if(c->prev)
+		c->prev->next = c->next;
+	if(c->next)
+		c->next->prev = c->prev;
 	*l = c->next;
 
-	c->next = clients; /* pop */
+	if(clients)
+		clients->prev = c;
+	c->next = clients;
 	clients = c;
 	arrange(NULL);
 }
@@ -439,13 +450,18 @@ unmanage(Client *c)
 	XDestroyWindow(dpy, c->title);
 
 	for(l = &clients; *l && *l != c; l = &(*l)->next);
+	if(c->prev)
+		c->prev->next = c->next;
+	if(c->next)
+		c->next->prev = c->prev;
 	*l = c->next;
-	for(l = &clients; *l; l = &(*l)->next)
-		if((*l)->revert == c)
-			(*l)->revert = NULL;
-	if(sel == c)
-		sel = sel->revert ? sel->revert : clients;
-
+	if(sel == c) {
+		sel = getnext(c->next, tsel);
+		if(!sel)
+			sel = getprev(c->prev);
+		if(!sel)
+			sel = clients;
+	}
 	free(c);
 
 	XSync(dpy, False);
diff --git a/config.mk b/config.mk
index 605f462..f119fbe 100644
--- a/config.mk
+++ b/config.mk
@@ -13,12 +13,12 @@ VERSION = 0.5
 LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
 
 # Linux/BSD
-CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
-	-DVERSION=\"${VERSION}\"
-LDFLAGS = ${LIBS}
-#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
+#CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
 #	-DVERSION=\"${VERSION}\"
-#LDFLAGS = -g ${LIBS}
+#LDFLAGS = ${LIBS}
+CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
+	-DVERSION=\"${VERSION}\"
+LDFLAGS = -g ${LIBS}
 
 
 # Solaris
diff --git a/dwm.h b/dwm.h
index e72bca2..8a7237c 100644
--- a/dwm.h
+++ b/dwm.h
@@ -76,7 +76,7 @@ struct Client {
 	Bool isfloat;
 	Bool ismax;
 	Client *next;
-	Client *revert;
+	Client *prev;
 	Window win;
 	Window title;
 };
@@ -135,6 +135,7 @@ extern void appendtag(Arg *arg);
 extern void dofloat(Arg *arg);
 extern void dotile(Arg *arg);
 extern Client *getnext(Client *c, unsigned int t);
+extern Client *getprev(Client *c);
 extern void heretag(Arg *arg);
 extern void replacetag(Arg *arg);
 extern void settags(Client *c);
diff --git a/tag.c b/tag.c
index 5da3c31..21eb9fa 100644
--- a/tag.c
+++ b/tag.c
@@ -140,6 +140,13 @@ getnext(Client *c, unsigned int t)
 	return c;
 }
 
+Client *
+getprev(Client *c)
+{
+	for(; c && !c->tags[tsel]; c = c->prev);
+	return c;
+}
+
 void
 heretag(Arg *arg)
 {
@akkartik.com> 2020-10-05 10:16:46 -0700 6956' href='/akkartik/mu/commit/subx_opcodes?h=hlt&id=bb3ce6cdea12ff00b998c5a1c6dbf2c83dba77c2'>bb3ce6cd ^
f13576b5 ^
bb3ce6cd ^









924ed08a ^
417a05ee ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132