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 /* TODO deserialize ltidx if present */
102 nlayouts = sizeof layouts / sizeof layouts[0];
103 for(blw = i = 0; i < nlayouts; i++) {
104 w = textw(layouts[i].symbol);
115 /* check if window has set a property */
117 XGetTextProperty(dpy, root, &name, dwmprops);
118 if(name.nitems && name.encoding == XA_STRING) {
119 strncpy(prop, (char *)name.value, sizeof prop - 1);
120 prop[sizeof prop - 1] = '\0';
122 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
123 seltags[i] = prop[i] == '1';
124 if(i < sizeof prop - 1 && prop[i] != '\0') {
133 nexttiled(Client *c) {
134 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
147 if(sel->isfloating || isfloating())
148 XRaiseWindow(dpy, sel->win);
150 wc.stack_mode = Below;
152 if(!sel->isfloating) {
153 XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
154 wc.sibling = sel->win;
156 for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
159 XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
164 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
171 for(i = 0; i < ntags && i < sizeof prop - 1; i++)
172 prop[i] = seltags[i] ? '1' : '0';
173 if(i < sizeof prop - 1)
174 prop[i++] = (char)ltidx;
176 XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
177 PropModeReplace, (unsigned char *)prop, i);
181 setlayout(const char *arg) {
185 if(++ltidx == nlayouts)
190 if(i < 0 || i >= nlayouts)
202 togglebar(const char *arg) {
204 bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
212 togglemax(const char *arg) {
215 if(!sel || (!isfloating() && !sel->isfloating) || sel->isfixed)
217 if((sel->ismax = !sel->ismax)) {
222 resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
225 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
227 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));