1 /* See LICENSE file for copyright and license details. */
12 void (*arrange)(void);
16 static char prop[128];
17 static unsigned int ltidx = 0; /* default */
20 floating(void) { /* default floating layout */
23 for(c = clients; c; c = c->next)
25 resize(c, c->x, c->y, c->w, c->h, True);
28 static unsigned int nlayouts = 0;
38 for(c = clients; c; c = c->next)
43 layouts[ltidx].arrange();
49 focusnext(const char *arg) {
54 for(c = sel->next; c && !isvisible(c); c = c->next);
56 for(c = clients; c && !isvisible(c); c = c->next);
64 focusprev(const char *arg) {
69 for(c = sel->prev; c && !isvisible(c); c = c->prev);
71 for(c = clients; c && c->next; c = c->next);
72 for(; c && !isvisible(c); c = c->prev);
83 return layouts[ltidx].symbol;
88 return layouts[ltidx].arrange == floating;
92 isarrange(void (*func)())
94 return func == layouts[ltidx].arrange;
101 nlayouts = sizeof layouts / sizeof layouts[0];
102 for(blw = i = 0; i < nlayouts; i++) {
103 w = textw(layouts[i].symbol);
113 if(gettextprop(root, dwmprops, prop, sizeof prop)) {
114 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
115 seltags[i] = prop[i] == '1';
116 if(i < sizeof prop - 1 && prop[i] != '\0') {
117 if(prop[i] < nlayouts)
124 nexttiled(Client *c) {
125 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
138 if(sel->isfloating || isfloating())
139 XRaiseWindow(dpy, sel->win);
141 wc.stack_mode = Below;
143 if(!sel->isfloating) {
144 XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
145 wc.sibling = sel->win;
147 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
150 XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
155 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
162 for(i = 0; i < ntags && i < sizeof prop - 1; i++)
163 prop[i] = seltags[i] ? '1' : '0';
164 if(i < sizeof prop - 1)
165 prop[i++] = (char)ltidx;
167 XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
168 PropModeReplace, (unsigned char *)prop, i);
172 setlayout(const char *arg) {
176 if(++ltidx == nlayouts)
181 if(i < 0 || i >= nlayouts)
193 togglebar(const char *arg) {
195 bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
203 togglemax(const char *arg) {
206 if(!sel || (!isfloating() && !sel->isfloating) || sel->isfixed)
208 if((sel->ismax = !sel->ismax)) {
213 resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
216 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
218 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));