dwm-meillo
diff client.c @ 73:c2ddb9dbbd10
rearranged
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Fri, 14 Jul 2006 22:33:38 +0200 |
parents | 7681ef838201 |
children | 5370ef170cc9 |
line diff
1.1 --- a/client.c Fri Jul 14 18:59:25 2006 +0200 1.2 +++ b/client.c Fri Jul 14 22:33:38 2006 +0200 1.3 @@ -11,14 +11,12 @@ 1.4 1.5 #include "dwm.h" 1.6 1.7 -void (*arrange)(Arg *) = tiling; 1.8 - 1.9 static Rule rule[] = { 1.10 /* class instance tags floating */ 1.11 { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, 1.12 }; 1.13 1.14 -static Client * 1.15 +Client * 1.16 next(Client *c) 1.17 { 1.18 for(; c && !c->tags[tsel]; c = c->next); 1.19 @@ -26,202 +24,12 @@ 1.20 } 1.21 1.22 void 1.23 -zoom(Arg *arg) 1.24 -{ 1.25 - Client **l, *c; 1.26 - 1.27 - if(!sel) 1.28 - return; 1.29 - 1.30 - if(sel == next(clients) && sel->next) { 1.31 - if((c = next(sel->next))) 1.32 - sel = c; 1.33 - } 1.34 - 1.35 - for(l = &clients; *l && *l != sel; l = &(*l)->next); 1.36 - *l = sel->next; 1.37 - 1.38 - sel->next = clients; /* pop */ 1.39 - clients = sel; 1.40 - arrange(NULL); 1.41 - focus(sel); 1.42 -} 1.43 - 1.44 -void 1.45 -max(Arg *arg) 1.46 -{ 1.47 - if(!sel) 1.48 - return; 1.49 - sel->x = sx; 1.50 - sel->y = sy + bh; 1.51 - sel->w = sw - 2 * sel->border; 1.52 - sel->h = sh - 2 * sel->border - bh; 1.53 - craise(sel); 1.54 - resize(sel, False); 1.55 -} 1.56 - 1.57 -void 1.58 -view(Arg *arg) 1.59 -{ 1.60 - Client *c; 1.61 - 1.62 - tsel = arg->i; 1.63 - arrange(NULL); 1.64 - 1.65 - for(c = clients; c; c = next(c->next)) 1.66 - draw_client(c); 1.67 - draw_bar(); 1.68 -} 1.69 - 1.70 -void 1.71 -tappend(Arg *arg) 1.72 -{ 1.73 - if(!sel) 1.74 - return; 1.75 - 1.76 - sel->tags[arg->i] = tags[arg->i]; 1.77 - arrange(NULL); 1.78 -} 1.79 - 1.80 -void 1.81 -ttrunc(Arg *arg) 1.82 -{ 1.83 - int i; 1.84 - if(!sel) 1.85 - return; 1.86 - 1.87 - for(i = 0; i < TLast; i++) 1.88 - sel->tags[i] = NULL; 1.89 - tappend(arg); 1.90 -} 1.91 - 1.92 -static void 1.93 ban_client(Client *c) 1.94 { 1.95 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 1.96 XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty); 1.97 } 1.98 1.99 -void 1.100 -floating(Arg *arg) 1.101 -{ 1.102 - Client *c; 1.103 - 1.104 - arrange = floating; 1.105 - for(c = clients; c; c = c->next) { 1.106 - if(c->tags[tsel]) 1.107 - resize(c, True); 1.108 - else 1.109 - ban_client(c); 1.110 - } 1.111 - if(sel && !sel->tags[tsel]) { 1.112 - if((sel = next(clients))) { 1.113 - craise(sel); 1.114 - focus(sel); 1.115 - } 1.116 - } 1.117 - draw_bar(); 1.118 -} 1.119 - 1.120 -void 1.121 -tiling(Arg *arg) 1.122 -{ 1.123 - Client *c; 1.124 - int n, i, w, h; 1.125 - 1.126 - w = sw - mw; 1.127 - arrange = tiling; 1.128 - for(n = 0, c = clients; c; c = c->next) 1.129 - if(c->tags[tsel] && !c->floating) 1.130 - n++; 1.131 - 1.132 - if(n > 1) 1.133 - h = (sh - bh) / (n - 1); 1.134 - else 1.135 - h = sh - bh; 1.136 - 1.137 - for(i = 0, c = clients; c; c = c->next) { 1.138 - if(c->tags[tsel]) { 1.139 - if(c->floating) { 1.140 - craise(c); 1.141 - resize(c, True); 1.142 - continue; 1.143 - } 1.144 - if(n == 1) { 1.145 - c->x = sx; 1.146 - c->y = sy + bh; 1.147 - c->w = sw - 2 * c->border; 1.148 - c->h = sh - 2 * c->border - bh; 1.149 - } 1.150 - else if(i == 0) { 1.151 - c->x = sx; 1.152 - c->y = sy + bh; 1.153 - c->w = mw - 2 * c->border; 1.154 - c->h = sh - 2 * c->border - bh; 1.155 - } 1.156 - else { 1.157 - c->x = sx + mw; 1.158 - c->y = sy + (i - 1) * h + bh; 1.159 - c->w = w - 2 * c->border; 1.160 - c->h = h - 2 * c->border; 1.161 - } 1.162 - resize(c, False); 1.163 - i++; 1.164 - } 1.165 - else 1.166 - ban_client(c); 1.167 - } 1.168 - if(!sel || (sel && !sel->tags[tsel])) { 1.169 - if((sel = next(clients))) { 1.170 - craise(sel); 1.171 - focus(sel); 1.172 - } 1.173 - } 1.174 - draw_bar(); 1.175 -} 1.176 - 1.177 -void 1.178 -prevc(Arg *arg) 1.179 -{ 1.180 - Client *c; 1.181 - 1.182 - if(!sel) 1.183 - return; 1.184 - 1.185 - if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { 1.186 - craise(c); 1.187 - focus(c); 1.188 - } 1.189 -} 1.190 - 1.191 -void 1.192 -nextc(Arg *arg) 1.193 -{ 1.194 - Client *c; 1.195 - 1.196 - if(!sel) 1.197 - return; 1.198 - 1.199 - if(!(c = next(sel->next))) 1.200 - c = next(clients); 1.201 - if(c) { 1.202 - craise(c); 1.203 - c->revert = sel; 1.204 - focus(c); 1.205 - } 1.206 -} 1.207 - 1.208 -void 1.209 -ckill(Arg *arg) 1.210 -{ 1.211 - if(!sel) 1.212 - return; 1.213 - if(sel->proto & WM_PROTOCOL_DELWIN) 1.214 - send_message(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]); 1.215 - else 1.216 - XKillClient(dpy, sel->win); 1.217 -} 1.218 - 1.219 static void 1.220 resize_title(Client *c) 1.221 { 1.222 @@ -230,8 +38,8 @@ 1.223 c->tw = 0; 1.224 for(i = 0; i < TLast; i++) 1.225 if(c->tags[i]) 1.226 - c->tw += textw(c->tags[i]) + dc.font.height; 1.227 - c->tw += textw(c->name) + dc.font.height; 1.228 + c->tw += textw(c->tags[i]); 1.229 + c->tw += textw(c->name); 1.230 if(c->tw > c->w) 1.231 c->tw = c->w + 2; 1.232 c->tx = c->x + c->w - c->tw + 2; 1.233 @@ -584,35 +392,3 @@ 1.234 return c; 1.235 return NULL; 1.236 } 1.237 - 1.238 -void 1.239 -draw_client(Client *c) 1.240 -{ 1.241 - int i; 1.242 - if(c == sel) { 1.243 - draw_bar(); 1.244 - XUnmapWindow(dpy, c->title); 1.245 - XSetWindowBorder(dpy, c->win, dc.fg); 1.246 - return; 1.247 - } 1.248 - 1.249 - XSetWindowBorder(dpy, c->win, dc.bg); 1.250 - XMapWindow(dpy, c->title); 1.251 - 1.252 - dc.x = dc.y = 0; 1.253 - 1.254 - dc.w = 0; 1.255 - for(i = 0; i < TLast; i++) { 1.256 - if(c->tags[i]) { 1.257 - dc.x += dc.w; 1.258 - dc.w = textw(c->tags[i]) + dc.font.height; 1.259 - drawtext(c->tags[i], False, True); 1.260 - } 1.261 - } 1.262 - dc.x += dc.w; 1.263 - dc.w = textw(c->name) + dc.font.height; 1.264 - drawtext(c->name, False, True); 1.265 - XCopyArea(dpy, dc.drawable, c->title, dc.gc, 1.266 - 0, 0, c->tw, c->th, 0, 0); 1.267 - XFlush(dpy); 1.268 -}