summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client.c46
1 files changed, 31 insertions, 15 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)
77 c = getnext(clients, tsel); 77 c = getnext(clients, tsel);
78 if(c) { 78 if(c) {
79 higher(c); 79 higher(c);
80 c->revert = sel;
81 focus(c); 80 focus(c);
82 } 81 }
83} 82}
@@ -93,7 +92,11 @@ focusprev(Arg *arg)
93 if(sel->ismax) 92 if(sel->ismax)
94 togglemax(NULL); 93 togglemax(NULL);
95 94
96 if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { 95 if(!(c = getprev(sel->prev))) {
96 for(c = clients; c && c->next; c = c->next);
97 c = getprev(c);
98 }
99 if(c) {
97 higher(c); 100 higher(c);
98 focus(c); 101 focus(c);
99 } 102 }
@@ -127,6 +130,8 @@ gravitate(Client *c, Bool invert)
127 int dx = 0, dy = 0; 130 int dx = 0, dy = 0;
128 131
129 switch(c->grav) { 132 switch(c->grav) {
133 default:
134 break;
130 case StaticGravity: 135 case StaticGravity:
131 case NorthWestGravity: 136 case NorthWestGravity:
132 case NorthGravity: 137 case NorthGravity:
@@ -143,11 +148,11 @@ gravitate(Client *c, Bool invert)
143 case SouthWestGravity: 148 case SouthWestGravity:
144 dy = -(c->h); 149 dy = -(c->h);
145 break; 150 break;
146 default:
147 break;
148 } 151 }
149 152
150 switch (c->grav) { 153 switch (c->grav) {
154 default:
155 break;
151 case StaticGravity: 156 case StaticGravity:
152 case NorthWestGravity: 157 case NorthWestGravity:
153 case WestGravity: 158 case WestGravity:
@@ -164,8 +169,6 @@ gravitate(Client *c, Bool invert)
164 case SouthEastGravity: 169 case SouthEastGravity:
165 dx = -(c->w + c->border); 170 dx = -(c->w + c->border);
166 break; 171 break;
167 default:
168 break;
169 } 172 }
170 173
171 if(invert) { 174 if(invert) {
@@ -204,7 +207,6 @@ lower(Client *c)
204void 207void
205manage(Window w, XWindowAttributes *wa) 208manage(Window w, XWindowAttributes *wa)
206{ 209{
207 int diff;
208 Client *c; 210 Client *c;
209 Window trans; 211 Window trans;
210 XSetWindowAttributes twa; 212 XSetWindowAttributes twa;
@@ -224,7 +226,7 @@ manage(Window w, XWindowAttributes *wa)
224 c->proto = getproto(c->win); 226 c->proto = getproto(c->win);
225 setsize(c); 227 setsize(c);
226 XSelectInput(dpy, c->win, 228 XSelectInput(dpy, c->win,
227 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 229 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
228 XGetTransientForHint(dpy, c->win, &trans); 230 XGetTransientForHint(dpy, c->win, &trans);
229 twa.override_redirect = 1; 231 twa.override_redirect = 1;
230 twa.background_pixmap = ParentRelative; 232 twa.background_pixmap = ParentRelative;
@@ -237,6 +239,8 @@ manage(Window w, XWindowAttributes *wa)
237 239
238 settags(c); 240 settags(c);
239 241
242 if(clients)
243 clients->prev = c;
240 c->next = clients; 244 c->next = clients;
241 clients = c; 245 clients = c;
242 246
@@ -264,6 +268,7 @@ manage(Window w, XWindowAttributes *wa)
264 else { 268 else {
265 XMapRaised(dpy, c->win); 269 XMapRaised(dpy, c->win);
266 XMapRaised(dpy, c->title); 270 XMapRaised(dpy, c->title);
271
267 } 272 }
268} 273}
269 274
@@ -273,9 +278,15 @@ pop(Client *c)
273 Client **l; 278 Client **l;
274 279
275 for(l = &clients; *l && *l != c; l = &(*l)->next); 280 for(l = &clients; *l && *l != c; l = &(*l)->next);
281 if(c->prev)
282 c->prev->next = c->next;
283 if(c->next)
284 c->next->prev = c->prev;
276 *l = c->next; 285 *l = c->next;
277 286
278 c->next = clients; /* pop */ 287 if(clients)
288 clients->prev = c;
289 c->next = clients;
279 clients = c; 290 clients = c;
280 arrange(NULL); 291 arrange(NULL);
281} 292}
@@ -439,13 +450,18 @@ unmanage(Client *c)
439 XDestroyWindow(dpy, c->title); 450 XDestroyWindow(dpy, c->title);
440 451
441 for(l = &clients; *l && *l != c; l = &(*l)->next); 452 for(l = &clients; *l && *l != c; l = &(*l)->next);
453 if(c->prev)
454 c->prev->next = c->next;
455 if(c->next)
456 c->next->prev = c->prev;
442 *l = c->next; 457 *l = c->next;
443 for(l = &clients; *l; l = &(*l)->next) 458 if(sel == c) {
444 if((*l)->revert == c) 459 sel = getnext(c->next, tsel);
445 (*l)->revert = NULL; 460 if(!sel)
446 if(sel == c) 461 sel = getprev(c->prev);
447 sel = sel->revert ? sel->revert : clients; 462 if(!sel)
448 463 sel = clients;
464 }
449 free(c); 465 free(c);
450 466
451 XSync(dpy, False); 467 XSync(dpy, False);