/* static functions */
static void
-detachstack(Client *c)
-{
+detachstack(Client *c) {
Client **tc;
for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
*tc = c->snext;
}
static void
-grabbuttons(Client *c, Bool focused)
-{
+grabbuttons(Client *c, Bool focused) {
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
if(focused) {
else
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
-
}
static void
-resizetitle(Client *c)
-{
+resizetitle(Client *c) {
c->tw = textw(c->name);
if(c->tw > c->w)
c->tw = c->w + 2;
XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
else
XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
-
}
static int
-xerrordummy(Display *dsply, XErrorEvent *ee)
-{
+xerrordummy(Display *dsply, XErrorEvent *ee) {
return 0;
}
/* extern functions */
void
-ban(Client *c)
-{
+ban(Client *c) {
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
}
void
-focus(Client *c)
-{
+focus(Client *c) {
Client *old;
if(!issel)
}
Client *
-getclient(Window w)
-{
+getclient(Window w) {
Client *c;
for(c = clients; c; c = c->next)
}
Client *
-getctitle(Window w)
-{
+getctitle(Window w) {
Client *c;
for(c = clients; c; c = c->next)
}
void
-gravitate(Client *c, Bool invert)
-{
+gravitate(Client *c, Bool invert) {
int dx = 0, dy = 0;
switch(c->grav) {
}
void
-killclient(Arg *arg)
-{
+killclient(Arg *arg) {
if(!sel)
return;
if(sel->proto & PROTODELWIN)
}
void
-manage(Window w, XWindowAttributes *wa)
-{
+manage(Window w, XWindowAttributes *wa) {
Client *c;
Window trans;
XSetWindowAttributes twa;
}
void
-resize(Client *c, Bool sizehints, Corner sticky)
-{
+resize(Client *c, Bool sizehints, Corner sticky) {
int bottom = c->y + c->h;
int right = c->x + c->w;
XWindowChanges wc;
}
void
-updatesize(Client *c)
-{
+updatesize(Client *c) {
long msize;
XSizeHints size;
}
void
-updatetitle(Client *c)
-{
+updatetitle(Client *c) {
char **list = NULL;
int n;
XTextProperty name;
}
void
-togglemax(Arg *arg)
-{
+togglemax(Arg *arg) {
int ox, oy, ow, oh;
Client *c;
XEvent ev;
}
void
-unmanage(Client *c)
-{
+unmanage(Client *c) {
Client *nc;
XGrabServer(dpy);
/* static */
static unsigned int
-textnw(const char *text, unsigned int len)
-{
+textnw(const char *text, unsigned int len) {
XRectangle r;
if(dc.font.set) {
}
static void
-drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
-{
+drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
int x, y, w, h;
static char buf[256];
unsigned int len, olen;
/* extern */
void
-drawall()
-{
+drawall() {
Client *c;
for(c = clients; c; c = getnext(c->next))
}
void
-drawstatus()
-{
+drawstatus() {
int i, x;
dc.x = dc.y = 0;
}
void
-drawtitle(Client *c)
-{
+drawtitle(Client *c) {
if(c == sel && issel) {
drawstatus();
XUnmapWindow(dpy, c->twin);
}
unsigned long
-getcolor(const char *colstr)
-{
+getcolor(const char *colstr) {
Colormap cmap = DefaultColormap(dpy, screen);
XColor color;
}
void
-setfont(const char *fontstr)
-{
+setfont(const char *fontstr) {
char **missing, *def;
int i, n;
}
unsigned int
-textw(const char *text)
-{
+textw(const char *text) {
return textnw(text, strlen(text)) + dc.font.height;
}
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
static void
-movemouse(Client *c)
-{
+movemouse(Client *c) {
int x1, y1, ocx, ocy, di;
unsigned int dui;
Window dummy;
for(;;) {
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
switch (ev.type) {
- default: break;
+ default:
+ break;
case Expose:
handler[Expose](&ev);
break;
}
static void
-resizemouse(Client *c)
-{
+resizemouse(Client *c) {
int ocx, ocy;
int nw, nh;
Corner sticky;
for(;;) {
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
switch(ev.type) {
- default: break;
+ default:
+ break;
case Expose:
handler[Expose](&ev);
break;
}
static void
-buttonpress(XEvent *e)
-{
+buttonpress(XEvent *e) {
int x;
Arg a;
Client *c;
}
static void
-synconfig(Client *c, int x, int y, int w, int h, unsigned int border)
-{
+synconfig(Client *c, int x, int y, int w, int h, unsigned int border) {
XEvent synev;
synev.type = ConfigureNotify;
}
static void
-configurerequest(XEvent *e)
-{
+configurerequest(XEvent *e) {
unsigned long newmask;
Client *c;
XConfigureRequestEvent *ev = &e->xconfigurerequest;
}
static void
-destroynotify(XEvent *e)
-{
+destroynotify(XEvent *e) {
Client *c;
XDestroyWindowEvent *ev = &e->xdestroywindow;
}
static void
-enternotify(XEvent *e)
-{
+enternotify(XEvent *e) {
Client *c;
XCrossingEvent *ev = &e->xcrossing;
}
static void
-expose(XEvent *e)
-{
+expose(XEvent *e) {
Client *c;
XExposeEvent *ev = &e->xexpose;
}
static void
-keypress(XEvent *e)
-{
+keypress(XEvent *e) {
static unsigned int len = sizeof(key) / sizeof(key[0]);
unsigned int i;
KeySym keysym;
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
for(i = 0; i < len; i++) {
- if(keysym == key[i].keysym &&
- CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
+ if(keysym == key[i].keysym
+ && CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
{
if(key[i].func)
key[i].func(&key[i].arg);
}
static void
-leavenotify(XEvent *e)
-{
+leavenotify(XEvent *e) {
XCrossingEvent *ev = &e->xcrossing;
if((ev->window == root) && !ev->same_screen) {
}
static void
-mappingnotify(XEvent *e)
-{
+mappingnotify(XEvent *e) {
XMappingEvent *ev = &e->xmapping;
XRefreshKeyboardMapping(ev);
}
static void
-maprequest(XEvent *e)
-{
+maprequest(XEvent *e) {
static XWindowAttributes wa;
XMapRequestEvent *ev = &e->xmaprequest;
}
static void
-propertynotify(XEvent *e)
-{
+propertynotify(XEvent *e) {
Client *c;
Window trans;
XPropertyEvent *ev = &e->xproperty;
}
static void
-unmapnotify(XEvent *e)
-{
+unmapnotify(XEvent *e) {
Client *c;
XUnmapEvent *ev = &e->xunmap;
};
void
-grabkeys()
-{
+grabkeys() {
static unsigned int len = sizeof(key) / sizeof(key[0]);
unsigned int i;
KeyCode code;
}
void
-procevent()
-{
+procevent() {
XEvent ev;
while(XPending(dpy)) {
(handler[ev.type])(&ev); /* call handler */
}
}
-
static Bool otherwm, readin;
static void
-cleanup()
-{
+cleanup() {
close(STDIN_FILENO);
while(sel) {
resize(sel, True, TopLeft);
}
static void
-scan()
-{
+scan() {
unsigned int i, num;
Window *wins, d1, d2;
XWindowAttributes wa;
}
static void
-setup()
-{
+setup() {
int i, j;
unsigned int mask;
Window w;
}
XFree(modmap);
- wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask;
+ wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
+ | EnterWindowMask | LeaveWindowMask;
wa.cursor = cursor[CurNormal];
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
* is already running.
*/
static int
-xerrorstart(Display *dsply, XErrorEvent *ee)
-{
+xerrorstart(Display *dsply, XErrorEvent *ee) {
otherwm = True;
return -1;
}
/* extern */
int
-getproto(Window w)
-{
+getproto(Window w) {
int i, format, protos, status;
unsigned long extra, res;
Atom *protocols, real;
}
void
-sendevent(Window w, Atom a, long value)
-{
+sendevent(Window w, Atom a, long value) {
XEvent e;
e.type = ClientMessage;
}
void
-quit(Arg *arg)
-{
+quit(Arg *arg) {
readin = running = False;
}
* default error handler, which may call exit.
*/
int
-xerror(Display *dpy, XErrorEvent *ee)
-{
+xerror(Display *dpy, XErrorEvent *ee) {
if(ee->error_code == BadWindow
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
}
int
-main(int argc, char *argv[])
-{
+main(int argc, char *argv[]) {
int r, xfd;
fd_set rd;
/* extern */
Client *
-getnext(Client *c)
-{
+getnext(Client *c) {
for(; c && !isvisible(c); c = c->next);
return c;
}
Client *
-getprev(Client *c)
-{
+getprev(Client *c) {
for(; c && !isvisible(c); c = c->prev);
return c;
}
void
-initrregs()
-{
+initrregs() {
unsigned int i;
regex_t *reg;
}
void
-settags(Client *c, Client *trans)
-{
+settags(Client *c, Client *trans) {
char prop[512];
unsigned int i, j;
regmatch_t tmp;
}
void
-tag(Arg *arg)
-{
+tag(Arg *arg) {
unsigned int i;
if(!sel)
}
void
-toggletag(Arg *arg)
-{
+toggletag(Arg *arg) {
unsigned int i;
if(!sel)
/* extern */
void *
-emallocz(unsigned int size)
-{
+emallocz(unsigned int size) {
void *res = calloc(1, size);
if(!res)
}
void
-eprint(const char *errstr, ...)
-{
+eprint(const char *errstr, ...) {
va_list ap;
va_start(ap, errstr);
}
void *
-erealloc(void *ptr, unsigned int size)
-{
+erealloc(void *ptr, unsigned int size) {
void *res = realloc(ptr, size);
if(!res)
eprint("fatal: could not malloc() %u bytes\n", size);
}
void
-spawn(Arg *arg)
-{
+spawn(Arg *arg) {
static char *shell = NULL;
if(!shell && !(shell = getenv("SHELL")))
/* static */
static Client *
-minclient()
-{
+minclient() {
Client *c, *min;
if((clients && clients->isfloat) || arrange == dofloat)
}
static void
-reorder()
-{
+reorder() {
Client *c, *newclients, *tail;
newclients = tail = NULL;
}
static Client *
-nexttiled(Client *c)
-{
+nexttiled(Client *c) {
for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
return c;
}
void (*arrange)(Arg *) = DEFMODE;
void
-detach(Client *c)
-{
+detach(Client *c) {
if(c->prev)
c->prev->next = c->next;
if(c->next)
}
void
-dofloat(Arg *arg)
-{
+dofloat(Arg *arg) {
Client *c;
maximized = False;
}
void
-dotile(Arg *arg)
-{
+dotile(Arg *arg) {
int h, i, n, w;
Client *c;
}
void
-focusnext(Arg *arg)
-{
+focusnext(Arg *arg) {
Client *c;
if(!sel)
}
void
-focusprev(Arg *arg)
-{
+focusprev(Arg *arg) {
Client *c;
if(!sel)
}
Bool
-isvisible(Client *c)
-{
+isvisible(Client *c) {
unsigned int i;
for(i = 0; i < ntags; i++)
}
void
-resizecol(Arg *arg)
-{
+resizecol(Arg *arg) {
unsigned int n;
Client *c;
}
void
-restack()
-{
+restack() {
Client *c;
XEvent ev;
}
void
-togglemode(Arg *arg)
-{
+togglemode(Arg *arg) {
arrange = (arrange == dofloat) ? dotile : dofloat;
if(sel)
arrange(NULL);
}
void
-toggleview(Arg *arg)
-{
+toggleview(Arg *arg) {
unsigned int i;
seltag[arg->i] = !seltag[arg->i];
}
void
-view(Arg *arg)
-{
+view(Arg *arg) {
unsigned int i;
for(i = 0; i < ntags; i++)
}
void
-viewall(Arg *arg)
-{
+viewall(Arg *arg) {
unsigned int i;
for(i = 0; i < ntags; i++)
}
void
-zoom(Arg *arg)
-{
+zoom(Arg *arg) {
unsigned int n;
Client *c;