sanitized names
c0705eeb
7 file(s) · +72 −72
| 17 | 17 | }; |
|
| 18 | 18 | ||
| 19 | 19 | Client * |
|
| 20 | - | next(Client *c) |
|
| 20 | + | getnext(Client *c) |
|
| 21 | 21 | { |
|
| 22 | 22 | for(; c && !c->tags[tsel]; c = c->next); |
|
| 23 | 23 | return c; |
|
| 24 | 24 | } |
|
| 25 | 25 | ||
| 26 | 26 | void |
|
| 27 | - | ban_client(Client *c) |
|
| 27 | + | ban(Client *c) |
|
| 28 | 28 | { |
|
| 29 | 29 | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
|
| 30 | 30 | XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty); |
|
| 48 | 48 | } |
|
| 49 | 49 | ||
| 50 | 50 | void |
|
| 51 | - | update_name(Client *c) |
|
| 51 | + | settitle(Client *c) |
|
| 52 | 52 | { |
|
| 53 | 53 | XTextProperty name; |
|
| 54 | 54 | int n; |
|
| 76 | 76 | } |
|
| 77 | 77 | ||
| 78 | 78 | void |
|
| 79 | - | update_size(Client *c) |
|
| 79 | + | setsize(Client *c) |
|
| 80 | 80 | { |
|
| 81 | 81 | XSizeHints size; |
|
| 82 | 82 | long msize; |
|
| 114 | 114 | } |
|
| 115 | 115 | ||
| 116 | 116 | void |
|
| 117 | - | craise(Client *c) |
|
| 117 | + | higher(Client *c) |
|
| 118 | 118 | { |
|
| 119 | 119 | XRaiseWindow(dpy, c->win); |
|
| 120 | 120 | XRaiseWindow(dpy, c->title); |
|
| 136 | 136 | XFlush(dpy); |
|
| 137 | 137 | sel = c; |
|
| 138 | 138 | if(old && old != c) |
|
| 139 | - | draw_client(old); |
|
| 140 | - | draw_client(c); |
|
| 139 | + | drawtitle(old); |
|
| 140 | + | drawtitle(c); |
|
| 141 | 141 | XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); |
|
| 142 | 142 | XFlush(dpy); |
|
| 143 | 143 | while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
|
| 196 | 196 | c->h = wa->height; |
|
| 197 | 197 | c->th = bh; |
|
| 198 | 198 | c->border = 1; |
|
| 199 | - | c->proto = win_proto(c->win); |
|
| 200 | - | update_size(c); |
|
| 199 | + | c->proto = proto(c->win); |
|
| 200 | + | setsize(c); |
|
| 201 | 201 | XSelectInput(dpy, c->win, |
|
| 202 | 202 | StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
|
| 203 | 203 | XGetTransientForHint(dpy, c->win, &trans); |
|
| 210 | 210 | DefaultVisual(dpy, screen), |
|
| 211 | 211 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); |
|
| 212 | 212 | ||
| 213 | - | update_name(c); |
|
| 213 | + | settitle(c); |
|
| 214 | 214 | init_tags(c); |
|
| 215 | 215 | ||
| 216 | 216 | for(l = &clients; *l; l = &(*l)->next); |
|
| 236 | 236 | focus(c); |
|
| 237 | 237 | } |
|
| 238 | 238 | else { |
|
| 239 | - | ban_client(c); |
|
| 239 | + | ban(c); |
|
| 240 | 240 | XMapRaised(dpy, c->win); |
|
| 241 | 241 | XMapRaised(dpy, c->title); |
|
| 242 | 242 | } |
|
| 339 | 339 | } |
|
| 340 | 340 | ||
| 341 | 341 | static int |
|
| 342 | - | dummy_error_handler(Display *dsply, XErrorEvent *err) |
|
| 342 | + | dummy_xerror(Display *dsply, XErrorEvent *err) |
|
| 343 | 343 | { |
|
| 344 | 344 | return 0; |
|
| 345 | 345 | } |
|
| 350 | 350 | Client **l; |
|
| 351 | 351 | ||
| 352 | 352 | XGrabServer(dpy); |
|
| 353 | - | XSetErrorHandler(dummy_error_handler); |
|
| 353 | + | XSetErrorHandler(dummy_xerror); |
|
| 354 | 354 | ||
| 355 | 355 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
| 356 | 356 | XDestroyWindow(dpy, c->title); |
|
| 366 | 366 | free(c); |
|
| 367 | 367 | ||
| 368 | 368 | XFlush(dpy); |
|
| 369 | - | XSetErrorHandler(error_handler); |
|
| 369 | + | XSetErrorHandler(xerror); |
|
| 370 | 370 | XUngrabServer(dpy); |
|
| 371 | 371 | arrange(NULL); |
|
| 372 | 372 | if(sel) |
|
| 11 | 11 | #include "dwm.h" |
|
| 12 | 12 | ||
| 13 | 13 | void |
|
| 14 | - | draw_bar() |
|
| 14 | + | drawstatus() |
|
| 15 | 15 | { |
|
| 16 | 16 | int i; |
|
| 17 | 17 | ||
| 44 | 44 | } |
|
| 45 | 45 | ||
| 46 | 46 | void |
|
| 47 | - | draw_client(Client *c) |
|
| 47 | + | drawtitle(Client *c) |
|
| 48 | 48 | { |
|
| 49 | 49 | int i; |
|
| 50 | 50 | if(c == sel) { |
|
| 51 | - | draw_bar(); |
|
| 51 | + | drawstatus(); |
|
| 52 | 52 | XUnmapWindow(dpy, c->title); |
|
| 53 | 53 | XSetWindowBorder(dpy, c->win, dc.fg); |
|
| 54 | 54 | return; |
|
| 145 | 145 | } |
|
| 146 | 146 | ||
| 147 | 147 | unsigned long |
|
| 148 | - | initcolor(const char *colstr) |
|
| 148 | + | getcolor(const char *colstr) |
|
| 149 | 149 | { |
|
| 150 | 150 | XColor color; |
|
| 151 | 151 | Colormap cmap = DefaultColormap(dpy, screen); |
|
| 172 | 172 | } |
|
| 173 | 173 | ||
| 174 | 174 | void |
|
| 175 | - | initfont(const char *fontstr) |
|
| 175 | + | setfont(const char *fontstr) |
|
| 176 | 176 | { |
|
| 177 | 177 | char **missing, *def; |
|
| 178 | 178 | int i, n; |
|
| 107 | 107 | extern void unmanage(Client *c); |
|
| 108 | 108 | extern Client *getclient(Window w); |
|
| 109 | 109 | extern void focus(Client *c); |
|
| 110 | - | extern void update_name(Client *c); |
|
| 110 | + | extern void settitle(Client *c); |
|
| 111 | 111 | extern void resize(Client *c, Bool inc); |
|
| 112 | - | extern void update_size(Client *c); |
|
| 112 | + | extern void setsize(Client *c); |
|
| 113 | 113 | extern Client *gettitle(Window w); |
|
| 114 | - | extern void craise(Client *c); |
|
| 114 | + | extern void higher(Client *c); |
|
| 115 | 115 | extern void lower(Client *c); |
|
| 116 | 116 | extern void gravitate(Client *c, Bool invert); |
|
| 117 | - | extern void ban_client(Client *c); |
|
| 118 | - | extern Client *next(Client *c); |
|
| 117 | + | extern void ban(Client *c); |
|
| 118 | + | extern Client *getnext(Client *c); |
|
| 119 | 119 | ||
| 120 | 120 | /* draw.c */ |
|
| 121 | - | extern void draw_bar(); |
|
| 122 | - | extern void draw_client(Client *c); |
|
| 121 | + | extern void drawstatus(); |
|
| 122 | + | extern void drawtitle(Client *c); |
|
| 123 | 123 | extern void drawtext(const char *text, Bool invert, Bool border); |
|
| 124 | - | extern unsigned long initcolor(const char *colstr); |
|
| 125 | - | extern void initfont(const char *fontstr); |
|
| 124 | + | extern unsigned long getcolor(const char *colstr); |
|
| 125 | + | extern void setfont(const char *fontstr); |
|
| 126 | 126 | extern unsigned int textnw(char *text, unsigned int len); |
|
| 127 | 127 | extern unsigned int textw(char *text); |
|
| 128 | 128 | extern unsigned int texth(void); |
|
| 132 | 132 | extern void keypress(XEvent *e); |
|
| 133 | 133 | ||
| 134 | 134 | /* main.c */ |
|
| 135 | - | extern int error_handler(Display *dsply, XErrorEvent *e); |
|
| 136 | - | extern void send_message(Window w, Atom a, long value); |
|
| 137 | - | extern int win_proto(Window w); |
|
| 135 | + | extern int xerror(Display *dsply, XErrorEvent *e); |
|
| 136 | + | extern void sendevent(Window w, Atom a, long value); |
|
| 137 | + | extern int proto(Window w); |
|
| 138 | 138 | extern void quit(Arg *arg); |
|
| 139 | 139 | ||
| 140 | 140 | /* screen.c */ |
|
| 129 | 129 | else if((c = getclient(ev->window))) { |
|
| 130 | 130 | if(arrange == tiling && !c->floating) |
|
| 131 | 131 | return; |
|
| 132 | - | craise(c); |
|
| 132 | + | higher(c); |
|
| 133 | 133 | switch(ev->button) { |
|
| 134 | 134 | default: |
|
| 135 | 135 | break; |
|
| 225 | 225 | ||
| 226 | 226 | if(ev->count == 0) { |
|
| 227 | 227 | if(barwin == ev->window) |
|
| 228 | - | draw_bar(); |
|
| 228 | + | drawstatus(); |
|
| 229 | 229 | else if((c = gettitle(ev->window))) |
|
| 230 | - | draw_client(c); |
|
| 230 | + | drawtitle(c); |
|
| 231 | 231 | } |
|
| 232 | 232 | } |
|
| 233 | 233 | ||
| 262 | 262 | ||
| 263 | 263 | if((c = getclient(ev->window))) { |
|
| 264 | 264 | if(ev->atom == wm_atom[WMProtocols]) { |
|
| 265 | - | c->proto = win_proto(c->win); |
|
| 265 | + | c->proto = proto(c->win); |
|
| 266 | 266 | return; |
|
| 267 | 267 | } |
|
| 268 | 268 | switch (ev->atom) { |
|
| 273 | 273 | arrange(NULL); |
|
| 274 | 274 | break; |
|
| 275 | 275 | case XA_WM_NORMAL_HINTS: |
|
| 276 | - | update_size(c); |
|
| 276 | + | setsize(c); |
|
| 277 | 277 | break; |
|
| 278 | 278 | } |
|
| 279 | 279 | if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) { |
|
| 280 | - | update_name(c); |
|
| 281 | - | draw_client(c); |
|
| 280 | + | settitle(c); |
|
| 281 | + | drawtitle(c); |
|
| 282 | 282 | } |
|
| 283 | 283 | } |
|
| 284 | 284 | } |
|
| 99 | 99 | if(!sel) |
|
| 100 | 100 | return; |
|
| 101 | 101 | ||
| 102 | - | if(sel == next(clients) && sel->next) { |
|
| 103 | - | if((c = next(sel->next))) |
|
| 102 | + | if(sel == getnext(clients) && sel->next) { |
|
| 103 | + | if((c = getnext(sel->next))) |
|
| 104 | 104 | sel = c; |
|
| 105 | 105 | } |
|
| 106 | 106 | ||
| 122 | 122 | sel->y = sy + bh; |
|
| 123 | 123 | sel->w = sw - 2 * sel->border; |
|
| 124 | 124 | sel->h = sh - 2 * sel->border - bh; |
|
| 125 | - | craise(sel); |
|
| 125 | + | higher(sel); |
|
| 126 | 126 | resize(sel, False); |
|
| 127 | 127 | } |
|
| 128 | 128 | ||
| 157 | 157 | return; |
|
| 158 | 158 | ||
| 159 | 159 | if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { |
|
| 160 | - | craise(c); |
|
| 160 | + | higher(c); |
|
| 161 | 161 | focus(c); |
|
| 162 | 162 | } |
|
| 163 | 163 | } |
|
| 170 | 170 | if(!sel) |
|
| 171 | 171 | return; |
|
| 172 | 172 | ||
| 173 | - | if(!(c = next(sel->next))) |
|
| 174 | - | c = next(clients); |
|
| 173 | + | if(!(c = getnext(sel->next))) |
|
| 174 | + | c = getnext(clients); |
|
| 175 | 175 | if(c) { |
|
| 176 | - | craise(c); |
|
| 176 | + | higher(c); |
|
| 177 | 177 | c->revert = sel; |
|
| 178 | 178 | focus(c); |
|
| 179 | 179 | } |
|
| 185 | 185 | if(!sel) |
|
| 186 | 186 | return; |
|
| 187 | 187 | if(sel->proto & WM_PROTOCOL_DELWIN) |
|
| 188 | - | send_message(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]); |
|
| 188 | + | sendevent(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]); |
|
| 189 | 189 | else |
|
| 190 | 190 | XKillClient(dpy, sel->win); |
|
| 191 | 191 | } |
|
| 46 | 46 | static Bool other_wm_running; |
|
| 47 | 47 | static const char version[] = |
|
| 48 | 48 | "dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; |
|
| 49 | - | static int (*x_error_handler) (Display *, XErrorEvent *); |
|
| 49 | + | static int (*x_xerror) (Display *, XErrorEvent *); |
|
| 50 | 50 | ||
| 51 | 51 | static void |
|
| 52 | 52 | usage() { error("usage: dwm [-v]\n"); } |
|
| 94 | 94 | } |
|
| 95 | 95 | ||
| 96 | 96 | int |
|
| 97 | - | win_proto(Window w) |
|
| 97 | + | proto(Window w) |
|
| 98 | 98 | { |
|
| 99 | 99 | unsigned char *protocols; |
|
| 100 | 100 | long res; |
|
| 114 | 114 | } |
|
| 115 | 115 | ||
| 116 | 116 | void |
|
| 117 | - | send_message(Window w, Atom a, long value) |
|
| 117 | + | sendevent(Window w, Atom a, long value) |
|
| 118 | 118 | { |
|
| 119 | 119 | XEvent e; |
|
| 120 | 120 | ||
| 135 | 135 | * calls exit(). |
|
| 136 | 136 | */ |
|
| 137 | 137 | int |
|
| 138 | - | error_handler(Display *dpy, XErrorEvent *error) |
|
| 138 | + | xerror(Display *dpy, XErrorEvent *error) |
|
| 139 | 139 | { |
|
| 140 | 140 | if(error->error_code == BadWindow |
|
| 141 | 141 | || (error->request_code == X_SetInputFocus |
|
| 153 | 153 | return 0; |
|
| 154 | 154 | fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", |
|
| 155 | 155 | error->request_code, error->error_code); |
|
| 156 | - | return x_error_handler(dpy, error); /* may call exit() */ |
|
| 156 | + | return x_xerror(dpy, error); /* may call exit() */ |
|
| 157 | 157 | } |
|
| 158 | 158 | ||
| 159 | 159 | /* |
|
| 161 | 161 | * is already running. |
|
| 162 | 162 | */ |
|
| 163 | 163 | static int |
|
| 164 | - | startup_error_handler(Display *dpy, XErrorEvent *error) |
|
| 164 | + | startup_xerror(Display *dpy, XErrorEvent *error) |
|
| 165 | 165 | { |
|
| 166 | 166 | other_wm_running = True; |
|
| 167 | 167 | return -1; |
|
| 215 | 215 | ||
| 216 | 216 | /* check if another WM is already running */ |
|
| 217 | 217 | other_wm_running = False; |
|
| 218 | - | XSetErrorHandler(startup_error_handler); |
|
| 218 | + | XSetErrorHandler(startup_xerror); |
|
| 219 | 219 | /* this causes an error if some other WM is running */ |
|
| 220 | 220 | XSelectInput(dpy, root, SubstructureRedirectMask); |
|
| 221 | 221 | XFlush(dpy); |
|
| 224 | 224 | error("dwm: another window manager is already running\n"); |
|
| 225 | 225 | ||
| 226 | 226 | XSetErrorHandler(0); |
|
| 227 | - | x_error_handler = XSetErrorHandler(error_handler); |
|
| 227 | + | x_xerror = XSetErrorHandler(xerror); |
|
| 228 | 228 | ||
| 229 | 229 | /* init atoms */ |
|
| 230 | 230 | wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |
|
| 242 | 242 | grabkeys(); |
|
| 243 | 243 | ||
| 244 | 244 | /* style */ |
|
| 245 | - | dc.bg = initcolor(BGCOLOR); |
|
| 246 | - | dc.fg = initcolor(FGCOLOR); |
|
| 247 | - | dc.border = initcolor(BORDERCOLOR); |
|
| 248 | - | initfont(FONT); |
|
| 245 | + | dc.bg = getcolor(BGCOLOR); |
|
| 246 | + | dc.fg = getcolor(FGCOLOR); |
|
| 247 | + | dc.border = getcolor(BORDERCOLOR); |
|
| 248 | + | setfont(FONT); |
|
| 249 | 249 | ||
| 250 | 250 | sx = sy = 0; |
|
| 251 | 251 | sw = DisplayWidth(dpy, screen); |
|
| 267 | 267 | ||
| 268 | 268 | dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); |
|
| 269 | 269 | dc.gc = XCreateGC(dpy, root, 0, 0); |
|
| 270 | - | draw_bar(); |
|
| 270 | + | drawstatus(); |
|
| 271 | 271 | ||
| 272 | 272 | issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); |
|
| 273 | 273 | ||
| 315 | 315 | stext[n++] = i; |
|
| 316 | 316 | } |
|
| 317 | 317 | stext[n] = 0; |
|
| 318 | - | draw_bar(); |
|
| 318 | + | drawstatus(); |
|
| 319 | 319 | } |
|
| 320 | 320 | } |
|
| 321 | 321 | } |
|
| 15 | 15 | tsel = arg->i; |
|
| 16 | 16 | arrange(NULL); |
|
| 17 | 17 | ||
| 18 | - | for(c = clients; c; c = next(c->next)) |
|
| 19 | - | draw_client(c); |
|
| 20 | - | draw_bar(); |
|
| 18 | + | for(c = clients; c; c = getnext(c->next)) |
|
| 19 | + | drawtitle(c); |
|
| 20 | + | drawstatus(); |
|
| 21 | 21 | } |
|
| 22 | 22 | ||
| 23 | 23 | void |
|
| 30 | 30 | if(c->tags[tsel]) |
|
| 31 | 31 | resize(c, True); |
|
| 32 | 32 | else |
|
| 33 | - | ban_client(c); |
|
| 33 | + | ban(c); |
|
| 34 | 34 | } |
|
| 35 | 35 | if(sel && !sel->tags[tsel]) { |
|
| 36 | - | if((sel = next(clients))) { |
|
| 37 | - | craise(sel); |
|
| 36 | + | if((sel = getnext(clients))) { |
|
| 37 | + | higher(sel); |
|
| 38 | 38 | focus(sel); |
|
| 39 | 39 | } |
|
| 40 | 40 | } |
|
| 41 | - | draw_bar(); |
|
| 41 | + | drawstatus(); |
|
| 42 | 42 | } |
|
| 43 | 43 | ||
| 44 | 44 | void |
|
| 61 | 61 | for(i = 0, c = clients; c; c = c->next) { |
|
| 62 | 62 | if(c->tags[tsel]) { |
|
| 63 | 63 | if(c->floating) { |
|
| 64 | - | craise(c); |
|
| 64 | + | higher(c); |
|
| 65 | 65 | resize(c, True); |
|
| 66 | 66 | continue; |
|
| 67 | 67 | } |
|
| 87 | 87 | i++; |
|
| 88 | 88 | } |
|
| 89 | 89 | else |
|
| 90 | - | ban_client(c); |
|
| 90 | + | ban(c); |
|
| 91 | 91 | } |
|
| 92 | 92 | if(!sel || (sel && !sel->tags[tsel])) { |
|
| 93 | - | if((sel = next(clients))) { |
|
| 94 | - | craise(sel); |
|
| 93 | + | if((sel = getnext(clients))) { |
|
| 94 | + | higher(sel); |
|
| 95 | 95 | focus(sel); |
|
| 96 | 96 | } |
|
| 97 | 97 | } |
|
| 98 | - | draw_bar(); |
|
| 98 | + | drawstatus(); |
|
| 99 | 99 | } |
|
| 100 | 100 | ||