aewl
diff client.c @ 75:f08271b7cb20
rearranged several stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Sat, 15 Jul 2006 16:30:50 +0200 |
parents | 5370ef170cc9 |
children | 4bd49f404f10 |
line diff
1.1 --- a/client.c Fri Jul 14 22:54:09 2006 +0200 1.2 +++ b/client.c Sat Jul 15 16:30:50 2006 +0200 1.3 @@ -11,18 +11,6 @@ 1.4 1.5 #include "dwm.h" 1.6 1.7 -static Rule rule[] = { 1.8 - /* class instance tags floating */ 1.9 - { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, 1.10 -}; 1.11 - 1.12 -Client * 1.13 -getnext(Client *c) 1.14 -{ 1.15 - for(; c && !c->tags[tsel]; c = c->next); 1.16 - return c; 1.17 -} 1.18 - 1.19 void 1.20 ban(Client *c) 1.21 { 1.22 @@ -31,7 +19,7 @@ 1.23 } 1.24 1.25 static void 1.26 -resize_title(Client *c) 1.27 +resizetitle(Client *c) 1.28 { 1.29 int i; 1.30 1.31 @@ -72,7 +60,7 @@ 1.32 } 1.33 } 1.34 XFree(name.value); 1.35 - resize_title(c); 1.36 + resizetitle(c); 1.37 } 1.38 1.39 void 1.40 @@ -143,42 +131,6 @@ 1.41 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 1.42 } 1.43 1.44 -static void 1.45 -init_tags(Client *c) 1.46 -{ 1.47 - XClassHint ch; 1.48 - static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0; 1.49 - unsigned int i, j; 1.50 - Bool matched = False; 1.51 - 1.52 - if(!len) { 1.53 - c->tags[tsel] = tags[tsel]; 1.54 - return; 1.55 - } 1.56 - 1.57 - if(XGetClassHint(dpy, c->win, &ch)) { 1.58 - if(ch.res_class && ch.res_name) { 1.59 - for(i = 0; i < len; i++) 1.60 - if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class)) 1.61 - && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance))) 1.62 - { 1.63 - for(j = 0; j < TLast; j++) 1.64 - c->tags[j] = rule[i].tags[j]; 1.65 - c->floating = rule[i].floating; 1.66 - matched = True; 1.67 - break; 1.68 - } 1.69 - } 1.70 - if(ch.res_class) 1.71 - XFree(ch.res_class); 1.72 - if(ch.res_name) 1.73 - XFree(ch.res_name); 1.74 - } 1.75 - 1.76 - if(!matched) 1.77 - c->tags[tsel] = tags[tsel]; 1.78 -} 1.79 - 1.80 void 1.81 manage(Window w, XWindowAttributes *wa) 1.82 { 1.83 @@ -196,7 +148,7 @@ 1.84 c->h = wa->height; 1.85 c->th = bh; 1.86 c->border = 1; 1.87 - c->proto = proto(c->win); 1.88 + c->proto = getproto(c->win); 1.89 setsize(c); 1.90 XSelectInput(dpy, c->win, 1.91 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 1.92 @@ -211,7 +163,7 @@ 1.93 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 1.94 1.95 settitle(c); 1.96 - init_tags(c); 1.97 + settags(c); 1.98 1.99 for(l = &clients; *l; l = &(*l)->next); 1.100 c->next = *l; /* *l == nil */ 1.101 @@ -224,8 +176,8 @@ 1.102 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, 1.103 GrabModeAsync, GrabModeSync, None, None); 1.104 1.105 - if(!c->floating) 1.106 - c->floating = trans 1.107 + if(!c->dofloat) 1.108 + c->dofloat = trans 1.109 || ((c->maxw == c->minw) && (c->maxh == c->minh)); 1.110 1.111 arrange(NULL); 1.112 @@ -321,7 +273,7 @@ 1.113 c->w = c->maxw; 1.114 if(c->maxh && c->h > c->maxh) 1.115 c->h = c->maxh; 1.116 - resize_title(c); 1.117 + resizetitle(c); 1.118 XSetWindowBorderWidth(dpy, c->win, 1); 1.119 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); 1.120 e.type = ConfigureNotify; 1.121 @@ -339,7 +291,7 @@ 1.122 } 1.123 1.124 static int 1.125 -dummy_xerror(Display *dsply, XErrorEvent *err) 1.126 +xerrordummy(Display *dsply, XErrorEvent *ee) 1.127 { 1.128 return 0; 1.129 } 1.130 @@ -350,7 +302,7 @@ 1.131 Client **l; 1.132 1.133 XGrabServer(dpy); 1.134 - XSetErrorHandler(dummy_xerror); 1.135 + XSetErrorHandler(xerrordummy); 1.136 1.137 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1.138 XDestroyWindow(dpy, c->title); 1.139 @@ -374,7 +326,7 @@ 1.140 } 1.141 1.142 Client * 1.143 -gettitle(Window w) 1.144 +getctitle(Window w) 1.145 { 1.146 Client *c; 1.147 for(c = clients; c; c = c->next) 1.148 @@ -392,3 +344,80 @@ 1.149 return c; 1.150 return NULL; 1.151 } 1.152 + 1.153 +void 1.154 +zoom(Arg *arg) 1.155 +{ 1.156 + Client **l, *c; 1.157 + 1.158 + if(!sel) 1.159 + return; 1.160 + 1.161 + if(sel == getnext(clients) && sel->next) { 1.162 + if((c = getnext(sel->next))) 1.163 + sel = c; 1.164 + } 1.165 + 1.166 + for(l = &clients; *l && *l != sel; l = &(*l)->next); 1.167 + *l = sel->next; 1.168 + 1.169 + sel->next = clients; /* pop */ 1.170 + clients = sel; 1.171 + arrange(NULL); 1.172 + focus(sel); 1.173 +} 1.174 + 1.175 +void 1.176 +maximize(Arg *arg) 1.177 +{ 1.178 + if(!sel) 1.179 + return; 1.180 + sel->x = sx; 1.181 + sel->y = sy + bh; 1.182 + sel->w = sw - 2 * sel->border; 1.183 + sel->h = sh - 2 * sel->border - bh; 1.184 + higher(sel); 1.185 + resize(sel, False); 1.186 +} 1.187 + 1.188 +void 1.189 +focusprev(Arg *arg) 1.190 +{ 1.191 + Client *c; 1.192 + 1.193 + if(!sel) 1.194 + return; 1.195 + 1.196 + if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { 1.197 + higher(c); 1.198 + focus(c); 1.199 + } 1.200 +} 1.201 + 1.202 +void 1.203 +focusnext(Arg *arg) 1.204 +{ 1.205 + Client *c; 1.206 + 1.207 + if(!sel) 1.208 + return; 1.209 + 1.210 + if(!(c = getnext(sel->next))) 1.211 + c = getnext(clients); 1.212 + if(c) { 1.213 + higher(c); 1.214 + c->revert = sel; 1.215 + focus(c); 1.216 + } 1.217 +} 1.218 + 1.219 +void 1.220 +killclient(Arg *arg) 1.221 +{ 1.222 + if(!sel) 1.223 + return; 1.224 + if(sel->proto & WM_PROTOCOL_DELWIN) 1.225 + sendevent(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]); 1.226 + else 1.227 + XKillClient(dpy, sel->win); 1.228 +}