several additions in mouse handling ;)
901b3ed9
5 file(s) · +59 −65
| 192 | 192 | void |
|
| 193 | 193 | manage(Window w, XWindowAttributes *wa) |
|
| 194 | 194 | { |
|
| 195 | - | Client *c, **l; |
|
| 195 | + | Client *c; |
|
| 196 | 196 | XSetWindowAttributes twa; |
|
| 197 | 197 | Window trans; |
|
| 198 | 198 | ||
| 223 | 223 | settitle(c); |
|
| 224 | 224 | settags(c); |
|
| 225 | 225 | ||
| 226 | - | for(l = &clients; *l; l = &(*l)->next); |
|
| 227 | - | c->next = *l; /* *l == nil */ |
|
| 228 | - | *l = c; |
|
| 226 | + | c->next = clients; |
|
| 227 | + | clients = c; |
|
| 229 | 228 | ||
| 229 | + | XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask, |
|
| 230 | + | GrabModeAsync, GrabModeSync, None, None); |
|
| 230 | 231 | XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, |
|
| 231 | 232 | GrabModeAsync, GrabModeSync, None, None); |
|
| 232 | 233 | XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, |
|
| 234 | 235 | XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, |
|
| 235 | 236 | GrabModeAsync, GrabModeSync, None, None); |
|
| 236 | 237 | ||
| 237 | - | if(!c->dofloat) |
|
| 238 | - | c->dofloat = trans |
|
| 238 | + | if(!c->isfloat) |
|
| 239 | + | c->isfloat = trans |
|
| 239 | 240 | || ((c->maxw == c->minw) && (c->maxh == c->minh)); |
|
| 240 | 241 | ||
| 241 | 242 | arrange(NULL); |
|
| 5 | 5 | .B dwm |
|
| 6 | 6 | .RB [ \-v ] |
|
| 7 | 7 | .SH DESCRIPTION |
|
| 8 | - | .SS Overview |
|
| 9 | 8 | .B dwm |
|
| 10 | - | is a dynamic window manager for X11. It consists of a small status bar at the |
|
| 11 | - | top of the screen and arranges windows in either a tiled or floating mode. |
|
| 9 | + | is a dynamic window manager for X11. It consists of a small status bar and |
|
| 10 | + | arranges windows in either a tiled or floating mode. |
|
| 12 | 11 | .P |
|
| 13 | - | If |
|
| 14 | - | .B dwm |
|
| 15 | - | is in tiled mode, it consists of two columns. The left master column |
|
| 16 | - | contains only one window per time, the right column contains all other windows |
|
| 17 | - | in a stack. In tiled mode |
|
| 12 | + | In tiled mode |
|
| 18 | 13 | .B dwm |
|
| 19 | - | .B don't |
|
| 20 | - | handles incremental resizals, some terminal programs like |
|
| 21 | - | .B xterm |
|
| 22 | - | may not work correctly with this in tiled mode. |
|
| 14 | + | manages all windows in a left master column and a right stacking column. The |
|
| 15 | + | master column contains a single window, the left stacking column all other |
|
| 16 | + | windows. Dialog windows are treated floating. |
|
| 23 | 17 | .P |
|
| 24 | - | If |
|
| 25 | - | .B dwm |
|
| 26 | - | is in floating mode, it arranges all windows with the reqyested geometry and |
|
| 27 | - | allows the user to move or resize them. Some windows, like |
|
| 28 | - | dialog windows, are treated floating even if |
|
| 29 | - | .B dwm |
|
| 30 | - | is in tiled mode. In floating mode |
|
| 18 | + | In floating mode |
|
| 31 | 19 | .B dwm |
|
| 32 | - | handles incremental resizals. |
|
| 20 | + | manages all windows in a conventional way. They can be resized and moved freely |
|
| 21 | + | with the mouse. |
|
| 33 | 22 | .P |
|
| 34 | 23 | Windows are grouped by tags. You can view all windows with a specific tag per |
|
| 35 | 24 | time. However, each window is allowed to contain more than one tag, which |
|
| 36 | 25 | allows to make windows visible in all views. |
|
| 37 | 26 | .P |
|
| 38 | 27 | .B dwm |
|
| 39 | - | reads from |
|
| 40 | - | .I stdin |
|
| 41 | - | to display status text, if written. |
|
| 28 | + | reads from standard input to display status text, if written. |
|
| 42 | 29 | .P |
|
| 43 | 30 | .B dwm |
|
| 44 | - | draws 1-pixel borders around windows to indicate the focus state and save as |
|
| 31 | + | draws 1-pixel borders around windows to indicate the focus state and providing as |
|
| 45 | 32 | much screen real estate as possible. Unfocused windows contain a small bar |
|
| 46 | 33 | in front of the window indicating the tags and the window title. |
|
| 47 | - | .SS Options |
|
| 34 | + | .SH OPTIONS |
|
| 48 | 35 | .TP |
|
| 49 | 36 | .B \-v |
|
| 50 | - | prints version information to |
|
| 51 | - | .I stdout |
|
| 52 | - | , then exits. |
|
| 53 | - | .SS Customization |
|
| 37 | + | prints version information to standard output, then exits. |
|
| 38 | + | .SH CUSTOMIZATION |
|
| 54 | 39 | .B dwm |
|
| 55 | 40 | is customized through editing its source code. It is assumed that |
|
| 56 | - | dwm users are high experienced users who know how a window manager works |
|
| 57 | - | and who are able to patch |
|
| 58 | 41 | .B dwm |
|
| 59 | - | for their needs. This keeps |
|
| 60 | - | .B dwm |
|
| 61 | - | fast, secure and simple, because it does not process any input data, except |
|
| 62 | - | window properties and the status text read from |
|
| 63 | - | .I stdin . |
|
| 64 | - | .SS Default Key Bindings |
|
| 42 | + | users know to patch it for their needs. This keeps it fast, secure and simple, |
|
| 43 | + | because it does not process any input data, except window properties and |
|
| 44 | + | the status text read from standard input. |
|
| 45 | + | .SS Keyboard Control |
|
| 65 | 46 | .TP 16 |
|
| 66 | 47 | .I Key |
|
| 67 | 48 | .I Action |
|
| 71 | 52 | .B window |
|
| 72 | 53 | to the |
|
| 73 | 54 | .B master |
|
| 74 | - | track |
|
| 55 | + | column |
|
| 75 | 56 | .TP |
|
| 76 | 57 | .B Mod1-k |
|
| 77 | 58 | Focus previous |
|
| 127 | 108 | .B nth |
|
| 128 | 109 | tag to cureent |
|
| 129 | 110 | .B window |
|
| 130 | - | .SS Default Mouse Bindings |
|
| 111 | + | .SS Mouse Control |
|
| 131 | 112 | .TP |
|
| 132 | 113 | .B Mod1-Button1 |
|
| 133 | 114 | Moves current |
|
| 142 | 123 | Resizes current |
|
| 143 | 124 | .B window |
|
| 144 | 125 | while dragging |
|
| 145 | - | .SH BUGS |
|
| 146 | - | Some terminal programs do not behave correctly in tiled mode, because |
|
| 147 | - | incremental resizals are ignored to use maximum screen real estate. You can |
|
| 148 | - | patch the code to fix this. |
|
| 71 | 71 | int grav; |
|
| 72 | 72 | unsigned int border; |
|
| 73 | 73 | long flags; |
|
| 74 | - | Bool dofloat; |
|
| 74 | + | Bool isfloat; |
|
| 75 | 75 | Window win; |
|
| 76 | 76 | Window title; |
|
| 77 | 77 | Client *next; |
|
| 82 | 82 | const char *class; |
|
| 83 | 83 | const char *instance; |
|
| 84 | 84 | char *tags[TLast]; |
|
| 85 | - | Bool dofloat; |
|
| 85 | + | Bool isfloat; |
|
| 86 | 86 | }; |
|
| 87 | 87 | ||
| 88 | 88 | struct Key { |
|
| 14 | 14 | /********** CUSTOMIZE **********/ |
|
| 15 | 15 | ||
| 16 | 16 | const char *term[] = { |
|
| 17 | - | "urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn", |
|
| 18 | - | "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL |
|
| 17 | + | "urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white", |
|
| 18 | + | "-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL |
|
| 19 | 19 | }; |
|
| 20 | 20 | const char *browse[] = { "firefox", NULL }; |
|
| 21 | 21 | const char *xlock[] = { "xlock", NULL }; |
|
| 128 | 128 | Client *c; |
|
| 129 | 129 | ||
| 130 | 130 | if(barwin == ev->window) { |
|
| 131 | - | x = 0; |
|
| 132 | - | for(a.i = 0; a.i < TLast; a.i++) { |
|
| 133 | - | x += textw(tags[a.i]); |
|
| 134 | - | if(ev->x < x) { |
|
| 135 | - | view(&a); |
|
| 136 | - | break; |
|
| 131 | + | switch(ev->button) { |
|
| 132 | + | default: |
|
| 133 | + | x = 0; |
|
| 134 | + | for(a.i = 0; a.i < TLast; a.i++) { |
|
| 135 | + | x += textw(tags[a.i]); |
|
| 136 | + | if(ev->x < x) { |
|
| 137 | + | view(&a); |
|
| 138 | + | break; |
|
| 139 | + | } |
|
| 137 | 140 | } |
|
| 141 | + | break; |
|
| 142 | + | case Button4: |
|
| 143 | + | a.i = (tsel + 1 < TLast) ? tsel + 1 : 0; |
|
| 144 | + | view(&a); |
|
| 145 | + | break; |
|
| 146 | + | case Button5: |
|
| 147 | + | a.i = (tsel - 1 >= 0) ? tsel - 1 : TLast - 1; |
|
| 148 | + | view(&a); |
|
| 149 | + | break; |
|
| 138 | 150 | } |
|
| 139 | 151 | } |
|
| 140 | 152 | else if((c = getclient(ev->window))) { |
|
| 141 | - | if(arrange == dotile && !c->dofloat) |
|
| 153 | + | if(arrange == dotile && !c->isfloat) { |
|
| 154 | + | if((ev->state & ControlMask) && (ev->button == Button1)) |
|
| 155 | + | zoom(NULL); |
|
| 142 | 156 | return; |
|
| 157 | + | } |
|
| 158 | + | /* floating windows */ |
|
| 143 | 159 | higher(c); |
|
| 144 | 160 | switch(ev->button) { |
|
| 145 | 161 | default: |
|
| 297 | 313 | default: break; |
|
| 298 | 314 | case XA_WM_TRANSIENT_FOR: |
|
| 299 | 315 | XGetTransientForHint(dpy, c->win, &trans); |
|
| 300 | - | if(!c->dofloat && (c->dofloat = (trans != 0))) |
|
| 316 | + | if(!c->isfloat && (c->isfloat = (trans != 0))) |
|
| 301 | 317 | arrange(NULL); |
|
| 302 | 318 | break; |
|
| 303 | 319 | case XA_WM_NORMAL_HINTS: |
|
| 17 | 17 | }; |
|
| 18 | 18 | ||
| 19 | 19 | static Rule rule[] = { |
|
| 20 | - | /* class instance tags dofloat */ |
|
| 20 | + | /* class instance tags isfloat */ |
|
| 21 | 21 | { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, |
|
| 22 | 22 | }; |
|
| 23 | 23 | ||
| 67 | 67 | w = sw - mw; |
|
| 68 | 68 | arrange = dotile; |
|
| 69 | 69 | for(n = 0, c = clients; c; c = c->next) |
|
| 70 | - | if(c->tags[tsel] && !c->dofloat) |
|
| 70 | + | if(c->tags[tsel] && !c->isfloat) |
|
| 71 | 71 | n++; |
|
| 72 | 72 | ||
| 73 | 73 | if(n > 1) |
|
| 77 | 77 | ||
| 78 | 78 | for(i = 0, c = clients; c; c = c->next) { |
|
| 79 | 79 | if(c->tags[tsel]) { |
|
| 80 | - | if(c->dofloat) { |
|
| 80 | + | if(c->isfloat) { |
|
| 81 | 81 | higher(c); |
|
| 82 | 82 | resize(c, True); |
|
| 83 | 83 | continue; |
|
| 155 | 155 | { |
|
| 156 | 156 | for(j = 0; j < TLast; j++) |
|
| 157 | 157 | c->tags[j] = rule[i].tags[j]; |
|
| 158 | - | c->dofloat = rule[i].dofloat; |
|
| 158 | + | c->isfloat = rule[i].isfloat; |
|
| 159 | 159 | matched = True; |
|
| 160 | 160 | break; |
|
| 161 | 161 | } |
|