renamed view.c into screen.c
238dd5d2
4 file(s) · +67 −69
| 3 | 3 | ||
| 4 | 4 | include config.mk |
|
| 5 | 5 | ||
| 6 | - | SRC = client.c draw.c event.c main.c manage.c util.c |
|
| 6 | + | SRC = client.c draw.c event.c main.c screen.c util.c |
|
| 7 | 7 | OBJ = ${SRC:.c=.o} |
|
| 8 | 8 | ||
| 9 | 9 | all: options dwm |
| 10 | 10 | /* static */ |
|
| 11 | 11 | ||
| 12 | 12 | static void |
|
| 13 | + | attachstack(Client *c) { |
|
| 14 | + | c->snext = stack; |
|
| 15 | + | stack = c; |
|
| 16 | + | } |
|
| 17 | + | ||
| 18 | + | static void |
|
| 19 | + | detachstack(Client *c) { |
|
| 20 | + | Client **tc; |
|
| 21 | + | for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); |
|
| 22 | + | *tc = c->snext; |
|
| 23 | + | } |
|
| 24 | + | ||
| 25 | + | static void |
|
| 13 | 26 | grabbuttons(Client *c, Bool focused) { |
|
| 14 | 27 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
| 15 | 28 | ||
| 68 | 81 | PropModeReplace, (unsigned char *)data, 2); |
|
| 69 | 82 | } |
|
| 70 | 83 | ||
| 84 | + | static void |
|
| 85 | + | togglemax(Client *c) { |
|
| 86 | + | XEvent ev; |
|
| 87 | + | ||
| 88 | + | if(c->isfixed) |
|
| 89 | + | return; |
|
| 90 | + | if((c->ismax = !c->ismax)) { |
|
| 91 | + | c->rx = c->x; |
|
| 92 | + | c->ry = c->y; |
|
| 93 | + | c->rw = c->w; |
|
| 94 | + | c->rh = c->h; |
|
| 95 | + | resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True); |
|
| 96 | + | } |
|
| 97 | + | else |
|
| 98 | + | resize(c, c->rx, c->ry, c->rw, c->rh, True); |
|
| 99 | + | while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
|
| 100 | + | } |
|
| 101 | + | ||
| 71 | 102 | static int |
|
| 72 | 103 | xerrordummy(Display *dsply, XErrorEvent *ee) { |
|
| 73 | 104 | return 0; |
|
| 81 | 112 | clients->prev = c; |
|
| 82 | 113 | c->next = clients; |
|
| 83 | 114 | clients = c; |
|
| 84 | - | } |
|
| 85 | - | ||
| 86 | - | void |
|
| 87 | - | attachstack(Client *c) { |
|
| 88 | - | c->snext = stack; |
|
| 89 | - | stack = c; |
|
| 90 | 115 | } |
|
| 91 | 116 | ||
| 92 | 117 | void |
|
| 119 | 144 | } |
|
| 120 | 145 | ||
| 121 | 146 | void |
|
| 122 | - | detachstack(Client *c) { |
|
| 123 | - | Client **tc; |
|
| 124 | - | for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); |
|
| 125 | - | *tc = c->snext; |
|
| 126 | - | } |
|
| 127 | - | ||
| 128 | - | void |
|
| 129 | 147 | focus(Client *c) { |
|
| 130 | 148 | if(c && !isvisible(c)) |
|
| 131 | 149 | return; |
|
| 254 | 272 | if(isvisible(c)) |
|
| 255 | 273 | focus(c); |
|
| 256 | 274 | arrange(); |
|
| 275 | + | } |
|
| 276 | + | ||
| 277 | + | Client * |
|
| 278 | + | nexttiled(Client *c) { |
|
| 279 | + | for(; c && (c->isfloat || !isvisible(c)); c = c->next); |
|
| 280 | + | return c; |
|
| 257 | 281 | } |
|
| 258 | 282 | ||
| 259 | 283 | void |
|
| 416 | 440 | XUngrabServer(dpy); |
|
| 417 | 441 | arrange(); |
|
| 418 | 442 | } |
|
| 443 | + | ||
| 444 | + | void |
|
| 445 | + | zoom(Arg *arg) { |
|
| 446 | + | unsigned int n; |
|
| 447 | + | Client *c; |
|
| 448 | + | ||
| 449 | + | if(!sel) |
|
| 450 | + | return; |
|
| 451 | + | if(sel->isfloat || (arrange == dofloat)) { |
|
| 452 | + | togglemax(sel); |
|
| 453 | + | return; |
|
| 454 | + | } |
|
| 455 | + | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
|
| 456 | + | n++; |
|
| 457 | + | ||
| 458 | + | if((c = sel) == nexttiled(clients)) |
|
| 459 | + | if(!(c = nexttiled(c->next))) |
|
| 460 | + | return; |
|
| 461 | + | detach(c); |
|
| 462 | + | attach(c); |
|
| 463 | + | focus(c); |
|
| 464 | + | arrange(); |
|
| 465 | + | } |
|
| 99 | 99 | extern Window root, barwin; |
|
| 100 | 100 | ||
| 101 | 101 | /* client.c */ |
|
| 102 | - | extern void attach(Client *c); /* attaches c to global client list */ |
|
| 103 | - | extern void attachstack(Client *c); /* attaches client to stack */ |
|
| 104 | 102 | extern void configure(Client *c); /* send synthetic configure event */ |
|
| 105 | - | extern void detach(Client *c); /* detaches c from global client list */ |
|
| 106 | - | extern void detachstack(Client *c); /* detaches client from stack */ |
|
| 107 | 103 | extern void focus(Client *c); /* focus c, c may be NULL */ |
|
| 108 | 104 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ |
|
| 109 | 105 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ |
|
| 110 | 106 | extern Client *getclient(Window w); /* return client of w */ |
|
| 111 | 107 | extern void killclient(Arg *arg); /* kill c nicely */ |
|
| 112 | 108 | extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ |
|
| 109 | + | Client *nexttiled(Client *c); /* returns tiled successor of c */ |
|
| 113 | 110 | extern void resize(Client *c, int x, int y, |
|
| 114 | 111 | int w, int h, Bool sizehints); /* resize c*/ |
|
| 115 | 112 | extern void updatesizehints(Client *c); /* update the size hint variables of c */ |
|
| 116 | 113 | extern void updatetitle(Client *c); /* update the name of c */ |
|
| 117 | 114 | extern void unmanage(Client *c); /* destroy c */ |
|
| 115 | + | extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */ |
|
| 118 | 116 | ||
| 119 | 117 | /* draw.c */ |
|
| 120 | 118 | extern void drawstatus(void); /* draw the bar */ |
|
| 131 | 129 | extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ |
|
| 132 | 130 | extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ |
|
| 133 | 131 | ||
| 134 | - | /* manage.c */ |
|
| 132 | + | /* screen.c */ |
|
| 135 | 133 | extern void compileregexps(void); /* initialize regexps of rules defined in config.h */ |
|
| 136 | 134 | extern void dofloat(void); /* arranges all windows floating */ |
|
| 137 | 135 | extern void dotile(void); /* arranges all windows tiled */ |
|
| 146 | 144 | extern void toggletag(Arg *arg); /* toggles c tags with arg's index */ |
|
| 147 | 145 | extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */ |
|
| 148 | 146 | extern void view(Arg *arg); /* views the tag with arg's index */ |
|
| 149 | - | extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */ |
|
| 150 | 147 | ||
| 151 | 148 | /* util.c */ |
|
| 152 | 149 | extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ |
|
| 153 | 150 | extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ |
|
| 154 | 151 | extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ |
|
| 152 | + | ||
| 32 | 32 | static Regexps *regexps = NULL; |
|
| 33 | 33 | static unsigned int len = 0; |
|
| 34 | 34 | ||
| 35 | - | static Client * |
|
| 36 | - | nextmanaged(Client *c) { |
|
| 37 | - | for(; c && (c->isfloat || !isvisible(c)); c = c->next); |
|
| 38 | - | return c; |
|
| 39 | - | } |
|
| 40 | - | ||
| 41 | - | static void |
|
| 42 | - | togglemax(Client *c) { |
|
| 43 | - | XEvent ev; |
|
| 44 | - | ||
| 45 | - | if(c->isfixed) |
|
| 46 | - | return; |
|
| 47 | - | if((c->ismax = !c->ismax)) { |
|
| 48 | - | c->rx = c->x; |
|
| 49 | - | c->ry = c->y; |
|
| 50 | - | c->rw = c->w; |
|
| 51 | - | c->rh = c->h; |
|
| 52 | - | resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True); |
|
| 53 | - | } |
|
| 54 | - | else |
|
| 55 | - | resize(c, c->rx, c->ry, c->rw, c->rh, True); |
|
| 56 | - | while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
|
| 57 | - | } |
|
| 58 | - | ||
| 59 | 35 | /* extern */ |
|
| 60 | 36 | ||
| 61 | 37 | void |
|
| 112 | 88 | unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; |
|
| 113 | 89 | Client *c; |
|
| 114 | 90 | ||
| 115 | - | for(n = 0, c = nextmanaged(clients); c; c = nextmanaged(c->next)) |
|
| 91 | + | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
|
| 116 | 92 | n++; |
|
| 117 | 93 | /* window geoms */ |
|
| 118 | 94 | mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1); |
|
| 209 | 185 | if(arrange != dofloat) { |
|
| 210 | 186 | if(!sel->isfloat) |
|
| 211 | 187 | XLowerWindow(dpy, sel->win); |
|
| 212 | - | for(c = nextmanaged(clients); c; c = nextmanaged(c->next)) { |
|
| 188 | + | for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
|
| 213 | 189 | if(c == sel) |
|
| 214 | 190 | continue; |
|
| 215 | 191 | XLowerWindow(dpy, c->win); |
|
| 319 | 295 | seltag[arg->i] = True; |
|
| 320 | 296 | arrange(); |
|
| 321 | 297 | } |
|
| 322 | - | ||
| 323 | - | void |
|
| 324 | - | zoom(Arg *arg) { |
|
| 325 | - | unsigned int n; |
|
| 326 | - | Client *c; |
|
| 327 | - | ||
| 328 | - | if(!sel) |
|
| 329 | - | return; |
|
| 330 | - | if(sel->isfloat || (arrange == dofloat)) { |
|
| 331 | - | togglemax(sel); |
|
| 332 | - | return; |
|
| 333 | - | } |
|
| 334 | - | for(n = 0, c = nextmanaged(clients); c; c = nextmanaged(c->next)) |
|
| 335 | - | n++; |
|
| 336 | - | ||
| 337 | - | if((c = sel) == nextmanaged(clients)) |
|
| 338 | - | if(!(c = nextmanaged(c->next))) |
|
| 339 | - | return; |
|
| 340 | - | detach(c); |
|
| 341 | - | attach(c); |
|
| 342 | - | focus(c); |
|
| 343 | - | arrange(); |
|
| 344 | - | } |
|