166 static void keypress(XEvent *e); |
166 static void keypress(XEvent *e); |
167 static void killclient(const Arg *arg); |
167 static void killclient(const Arg *arg); |
168 static void manage(Window w, XWindowAttributes *wa); |
168 static void manage(Window w, XWindowAttributes *wa); |
169 static void mappingnotify(XEvent *e); |
169 static void mappingnotify(XEvent *e); |
170 static void maprequest(XEvent *e); |
170 static void maprequest(XEvent *e); |
|
171 static void monocle(void); |
171 static void movemouse(const Arg *arg); |
172 static void movemouse(const Arg *arg); |
172 static Client *nexttiled(Client *c); |
173 static Client *nexttiled(Client *c); |
173 static void propertynotify(XEvent *e); |
174 static void propertynotify(XEvent *e); |
174 static void quit(const Arg *arg); |
175 static void quit(const Arg *arg); |
175 static void resize(Client *c, int x, int y, int w, int h, Bool sizehints); |
176 static void resize(Client *c, int x, int y, int w, int h, Bool sizehints); |
176 static void resizemouse(const Arg *arg); |
177 static void resizemouse(const Arg *arg); |
177 static void restack(void); |
178 static void restack(void); |
178 static void run(void); |
179 static void run(void); |
179 static void scan(void); |
180 static void scan(void); |
180 static void setclientstate(Client *c, long state); |
181 static void setclientstate(Client *c, long state); |
|
182 static void setlayout(const Arg *arg); |
181 static void setmfact(const Arg *arg); |
183 static void setmfact(const Arg *arg); |
182 static void setup(void); |
184 static void setup(void); |
183 static void spawn(const Arg *arg); |
185 static void spawn(const Arg *arg); |
184 static void tag(const Arg *arg); |
186 static void tag(const Arg *arg); |
185 static int textnw(const char *text, uint len); |
187 static int textnw(const char *text, uint len); |
186 static void tile(void); |
188 static void tile(void); |
187 static void togglebar(const Arg *arg); |
189 static void togglebar(const Arg *arg); |
188 static void togglefloating(const Arg *arg); |
190 static void togglefloating(const Arg *arg); |
189 static void togglelayout(const Arg *arg); |
|
190 static void togglemax(const Arg *arg); |
|
191 static void toggletag(const Arg *arg); |
191 static void toggletag(const Arg *arg); |
192 static void toggleview(const Arg *arg); |
192 static void toggleview(const Arg *arg); |
193 static void unmanage(Client *c); |
193 static void unmanage(Client *c); |
194 static void unmapnotify(XEvent *e); |
194 static void unmapnotify(XEvent *e); |
195 static void updatebar(void); |
195 static void updatebar(void); |
223 [MapRequest] = maprequest, |
223 [MapRequest] = maprequest, |
224 [PropertyNotify] = propertynotify, |
224 [PropertyNotify] = propertynotify, |
225 [UnmapNotify] = unmapnotify |
225 [UnmapNotify] = unmapnotify |
226 }; |
226 }; |
227 static Atom wmatom[WMLast], netatom[NetLast]; |
227 static Atom wmatom[WMLast], netatom[NetLast]; |
228 static Bool ismax = False; |
|
229 static Bool otherwm, readin; |
228 static Bool otherwm, readin; |
230 static Bool running = True; |
229 static Bool running = True; |
231 static uint tagset[] = {1, 1}; /* after start, first tag is selected */ |
230 static uint tagset[] = {1, 1}; /* after start, first tag is selected */ |
232 static Client *clients = NULL; |
231 static Client *clients = NULL; |
233 static Client *sel = NULL; |
232 static Client *sel = NULL; |
273 arrange(void) { |
272 arrange(void) { |
274 Client *c; |
273 Client *c; |
275 |
274 |
276 for(c = clients; c; c = c->next) |
275 for(c = clients; c; c = c->next) |
277 if(c->tags & tagset[seltags]) { /* is visible */ |
276 if(c->tags & tagset[seltags]) { /* is visible */ |
278 if(ismax && !c->isfixed) { |
277 if(!lt->arrange || c->isfloating) |
279 XMoveResizeWindow(dpy, c->win, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); |
|
280 c->ismoved = True; |
|
281 } |
|
282 else if(!lt->arrange || c->isfloating) |
|
283 resize(c, c->x, c->y, c->w, c->h, True); |
278 resize(c, c->x, c->y, c->w, c->h, True); |
284 c->isbanned = False; |
279 c->isbanned = False; |
285 } |
280 } |
286 else if(!c->isbanned) { |
281 else if(!c->isbanned) { |
287 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
282 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
288 c->isbanned = c->ismoved = True; |
283 c->isbanned = True; |
289 } |
284 } |
290 |
285 |
291 focus(NULL); |
286 focus(NULL); |
292 if(lt->arrange && !ismax) |
287 if(lt->arrange) |
293 lt->arrange(); |
288 lt->arrange(); |
294 restack(); |
289 restack(); |
295 } |
290 } |
296 |
291 |
297 void |
292 void |
416 XWindowChanges wc; |
411 XWindowChanges wc; |
417 |
412 |
418 if((c = getclient(ev->window))) { |
413 if((c = getclient(ev->window))) { |
419 if(ev->value_mask & CWBorderWidth) |
414 if(ev->value_mask & CWBorderWidth) |
420 c->bw = ev->border_width; |
415 c->bw = ev->border_width; |
421 if(ismax && !c->isbanned && !c->isfixed) |
|
422 XMoveResizeWindow(dpy, c->win, wx, wy, ww - 2 * c->bw, wh + 2 * c->bw); |
|
423 else if(c->isfloating || !lt->arrange) { |
416 else if(c->isfloating || !lt->arrange) { |
424 if(ev->value_mask & CWX) |
417 if(ev->value_mask & CWX) |
425 c->x = sx + ev->x; |
418 c->x = sx + ev->x; |
426 if(ev->value_mask & CWY) |
419 if(ev->value_mask & CWY) |
427 c->y = sy + ev->y; |
420 c->y = sy + ev->y; |
962 return; |
955 return; |
963 if(wa.override_redirect) |
956 if(wa.override_redirect) |
964 return; |
957 return; |
965 if(!getclient(ev->window)) |
958 if(!getclient(ev->window)) |
966 manage(ev->window, &wa); |
959 manage(ev->window, &wa); |
|
960 } |
|
961 |
|
962 void |
|
963 monocle(void) { |
|
964 Client *c; |
|
965 |
|
966 for(c = nexttiled(clients); c; c = nexttiled(c->next)) |
|
967 resize(c, wx, wy, ww, wh, resizehints); |
967 } |
968 } |
968 |
969 |
969 void |
970 void |
970 movemouse(const Arg *arg) { |
971 movemouse(const Arg *arg) { |
971 int x1, y1, ocx, ocy, di, nx, ny; |
972 int x1, y1, ocx, ocy, di, nx, ny; |
1184 XWindowChanges wc; |
1184 XWindowChanges wc; |
1185 |
1185 |
1186 drawbar(); |
1186 drawbar(); |
1187 if(!sel) |
1187 if(!sel) |
1188 return; |
1188 return; |
1189 if(ismax || sel->isfloating || !lt->arrange) |
1189 if(sel->isfloating || !lt->arrange) |
1190 XRaiseWindow(dpy, sel->win); |
1190 XRaiseWindow(dpy, sel->win); |
1191 if(!ismax && lt->arrange) { |
1191 if(lt->arrange) { |
1192 wc.stack_mode = Below; |
1192 wc.stack_mode = Below; |
1193 wc.sibling = barwin; |
1193 wc.sibling = barwin; |
1194 for(c = stack; c; c = c->snext) |
1194 for(c = stack; c; c = c->snext) |
1195 if(!c->isfloating && !c->isbanned) { |
1195 if(!c->isfloating && !c->isbanned) { |
1196 XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); |
1196 XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); |
1294 |
1294 |
1295 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
1295 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
1296 PropModeReplace, (unsigned char *)data, 2); |
1296 PropModeReplace, (unsigned char *)data, 2); |
1297 } |
1297 } |
1298 |
1298 |
|
1299 void |
|
1300 setlayout(const Arg *arg) { |
|
1301 static Layout *prevlt = &layouts[1 % LENGTH(layouts)]; |
|
1302 |
|
1303 if(!arg || !arg->v || arg->v == lt) |
|
1304 lt = prevlt; |
|
1305 else { |
|
1306 prevlt = lt; |
|
1307 lt = (Layout *)arg->v; |
|
1308 } |
|
1309 if(sel) |
|
1310 arrange(); |
|
1311 else |
|
1312 drawbar(); |
|
1313 } |
|
1314 |
1299 /* arg > 1.0 will set mfact absolutly */ |
1315 /* arg > 1.0 will set mfact absolutly */ |
1300 void |
1316 void |
1301 setmfact(const Arg *arg) { |
1317 setmfact(const Arg *arg) { |
1302 float f; |
1318 float f; |
1303 |
1319 |