#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <X11/Xatom.h>
#include <X11/Xutil.h>
/* static */
TAGS
RULES
-static char prop[512];
static unsigned int nrules = 0;
static unsigned int nlayouts = 0;
static unsigned int ltidx = 0; /* default */
resize(c, c->x, c->y, c->w, c->h, True);
}
-static void
-setdwmprops(void) {
- unsigned int i;
-
- for(i = 0; i < ntags && i < sizeof prop - 1; i++)
- prop[i] = seltags[i] ? '1' : '0';
- if(i < sizeof prop - 1)
- prop[i++] = (char)ltidx;
- prop[i] = '\0';
- XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
- PropModeReplace, (unsigned char *)prop, i);
-}
-
LAYOUTS
/* extern */
void
applyrules(Client *c) {
+ static char buf[512];
unsigned int i, j;
regmatch_t tmp;
Bool matched = False;
/* rule matching */
XGetClassHint(dpy, c->win, &ch);
- snprintf(prop, sizeof prop, "%s:%s:%s",
+ snprintf(buf, sizeof buf, "%s:%s:%s",
ch.res_class ? ch.res_class : "",
ch.res_name ? ch.res_name : "", c->name);
for(i = 0; i < nrules; i++)
- if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
+ if(regs[i].propregex && !regexec(regs[i].propregex, buf, 1, &tmp, 0)) {
c->isfloating = rules[i].isfloating;
for(j = 0; regs[i].tagregex && j < ntags; j++) {
if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
return False;
}
-void
-getdwmprops(void) {
- unsigned int i;
-
- if(gettextprop(root, dwmprops, prop, sizeof prop)) {
- for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
- seltags[i] = prop[i] == '1';
- if(i < sizeof prop - 1 && prop[i] != '\0') {
- if(prop[i] < nlayouts)
- ltidx = prop[i];
- }
- }
-}
-
Client *
nexttiled(Client *c) {
for(; c && (c->isfloating || !isvisible(c)); c = c->next);
void
setlayout(const char *arg) {
- int i;
+ unsigned int i;
if(!arg) {
if(++ltidx == nlayouts)
ltidx = 0;;
}
else {
- i = atoi(arg);
- if(i < 0 || i >= nlayouts)
+ for(i = 0; i < nlayouts; i++)
+ if(!strcmp(arg, layouts[i].symbol))
+ break;
+ if(i == nlayouts)
return;
ltidx = i;
}
arrange();
else
drawstatus();
- setdwmprops();
}
void
i = idxoftag(arg);
if(i >= 0 && i < ntags)
sel->tags[i] = True;
- setprops(sel);
arrange();
}
if(!sel || isfloating())
return;
sel->isfloating = !sel->isfloating;
- if(sel->isfloating) {
+ if(sel->isfloating)
resize(sel, sel->x, sel->y, sel->w, sel->h, True);
- setprops(sel);
- }
arrange();
}
for(j = 0; j < ntags && !sel->tags[j]; j++);
if(j == ntags)
sel->tags[i] = True;
- setprops(sel);
arrange();
}
for(j = 0; j < ntags && !seltags[j]; j++);
if(j == ntags)
seltags[i] = True; /* cannot toggle last view */
- setdwmprops();
arrange();
}
+void
+updatebarpos(void) {
+ XEvent ev;
+
+ wax = sx;
+ way = sy;
+ wah = sh;
+ waw = sw;
+ switch(bpos) {
+ default:
+ wah -= bh;
+ way += bh;
+ XMoveWindow(dpy, barwin, sx, sy);
+ break;
+ case BarBot:
+ wah -= bh;
+ XMoveWindow(dpy, barwin, sx, sy + wah);
+ break;
+ case BarOff:
+ XMoveWindow(dpy, barwin, sx, sy - bh);
+ break;
+ }
+ XSync(dpy, False);
+ while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+}
+
void
view(const char *arg) {
unsigned int i;
i = idxoftag(arg);
if(i >= 0 && i < ntags)
seltags[i] = True;
- setdwmprops();
arrange();
}