garbeam@0: /* garbeam@0: * (C)opyright MMVI Anselm R. Garbe garbeam@0: * See LICENSE file for license details. garbeam@0: */ garbeam@0: arg@166: #include "config.h" garbeam@32: #include garbeam@32: arg@143: /* mask shorthands, used in event.c and client.c */ arg@150: #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) arg@150: #define MOUSEMASK (BUTTONMASK | PointerMotionMask) arg@157: #define PROTODELWIN 1 arg@143: arg@452: enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ arg@452: enum { WMProtocols, WMDelete, WMLast }; /* default atoms */ arg@452: enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ arg@452: enum { ColFG, ColBG, ColLast }; /* color */ arg@452: arg@452: typedef enum { arg@452: TopLeft, TopRight, BotLeft, BotRight arg@452: } Corner; /* window corners */ arg@452: arg@333: typedef union { arg@189: const char *cmd; garbeam@49: int i; arg@452: } Arg; /* argument type */ arg@99: arg@333: typedef struct { garbeam@32: int ascent; garbeam@32: int descent; garbeam@32: int height; garbeam@84: XFontSet set; garbeam@84: XFontStruct *xfont; arg@333: } Fnt; garbeam@32: arg@452: typedef struct { garbeam@32: int x, y, w, h; arg@353: unsigned long norm[ColLast]; arg@353: unsigned long sel[ColLast]; arg@353: unsigned long status[ColLast]; garbeam@84: Drawable drawable; garbeam@84: Fnt font; garbeam@84: GC gc; arg@452: } DC; /* draw context */ garbeam@32: arg@333: typedef struct Client Client; garbeam@0: struct Client { garbeam@31: char name[256]; garbeam@13: int proto; arg@115: int x, y, w, h; arg@453: int tx, ty, tw, th; /* title window geometry */ garbeam@20: int basew, baseh, incw, inch, maxw, maxh, minw, minh; garbeam@29: int grav; arg@164: long flags; arg@381: unsigned int border, weight; garbeam@80: Bool isfloat; arg@178: Bool *tags; garbeam@84: Client *next; arg@127: Client *prev; arg@446: Client *snext; garbeam@0: Window win; arg@342: Window twin; garbeam@0: }; garbeam@0: arg@452: extern const char *tags[]; /* all tags */ arg@452: extern char stext[1024]; /* status text */ arg@452: extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ arg@452: extern int mw, screen, sx, sy, sw, sh; /* screen geometry, master width */ arg@454: extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */ arg@452: extern void (*handler[LASTEvent])(XEvent *); /* event handler */ arg@452: extern void (*arrange)(Arg *); /* arrange function, indicates mode */ garbeam@84: extern Atom wmatom[WMLast], netatom[NetLast]; arg@452: extern Bool running, issel, maximized, *seltag; /* seltag is array of Bool */ arg@454: extern Client *clients, *sel, *stack; /* global cleint list and stack */ garbeam@84: extern Cursor cursor[CurLast]; arg@454: extern DC dc; /* global draw context */ garbeam@84: extern Display *dpy; garbeam@84: extern Window root, barwin; garbeam@3: garbeam@5: /* client.c */ arg@454: extern void ban(Client *c); /* ban c from screen */ arg@452: extern void focus(Client *c); /* focus c, c may be NULL */ arg@452: extern Client *getclient(Window w); /* return client of w */ arg@452: extern Client *getctitle(Window w); /* return client of title window */ arg@452: extern void gravitate(Client *c, Bool invert); /* gravitate c */ arg@452: extern void killclient(Arg *arg); /* kill c nicely */ arg@452: extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ arg@452: extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/ arg@454: extern void updatesize(Client *c); /* update the size structs of c */ arg@454: extern void updatetitle(Client *c); /* update the name of c */ arg@452: extern void togglemax(Arg *arg); /* (un)maximize c */ arg@452: extern void unmanage(Client *c); /* destroy c */ garbeam@13: garbeam@33: /* draw.c */ arg@452: extern void drawall(); /* draw all visible client titles and the bar */ arg@452: extern void drawstatus(); /* draw the bar */ arg@452: extern void drawtitle(Client *c); /* draw title of c */ arg@452: extern unsigned long getcolor(const char *colstr); /* return color of colstr */ arg@452: extern void setfont(const char *fontstr); /* set the font for DC */ arg@452: extern unsigned int textw(const char *text); /* return the text width of text */ garbeam@33: garbeam@75: /* event.c */ arg@452: extern void grabkeys(); /* grab all keys defined in config.h */ arg@452: extern void procevent(); /* process pending X events */ garbeam@18: garbeam@43: /* main.c */ arg@452: extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */ arg@452: extern void quit(Arg *arg); /* quit dwm nicely */ arg@452: extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ arg@452: extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ garbeam@43: garbeam@75: /* tag.c */ arg@452: extern void initrregs(); /* initialize regexps of rules defined in config.h */ arg@452: extern Client *getnext(Client *c); /* returns next visible client */ arg@452: extern Client *getprev(Client *c); /* returns previous visible client */ arg@454: extern void settags(Client *c, Client *trans); /* sets tags of c */ arg@452: extern void tag(Arg *arg); /* tags c accordingly to arg's index */ arg@452: extern void toggletag(Arg *arg); /* toggles c tags accordingly to arg's index */ garbeam@73: garbeam@32: /* util.c */ arg@452: extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ arg@452: extern void eprint(const char *errstr, ...); /* prints error string and exits with return code 1 */ arg@452: extern void *erealloc(void *ptr, unsigned int size); /* reallocates memory, exits on error */ arg@453: extern void spawn(Arg *arg); /* forks a new subprocess accordingly to arg's cmd */ arg@327: arg@327: /* view.c */ arg@452: extern void detach(Client *c); /* detaches c from global client list */ arg@452: extern void dofloat(Arg *arg); /* arranges all windows in a floating way, arg is ignored */ arg@452: extern void dotile(Arg *arg); /* arranges all windows in a tiled way, arg is ignored */ arg@452: extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ arg@452: extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ arg@452: extern Bool isvisible(Client *c); /* returns True if client is visible */ arg@452: extern void resizecol(Arg *arg); /* resizes the master width accordingly to arg's index value */ arg@452: extern void restack(); /* restores z layers of all clients */ arg@454: extern void togglemode(Arg *arg); /* toggles global arrange function (between dotile and dofloat) */ arg@454: extern void toggleview(Arg *arg); /* toggles the tag accordingly to arg's index (in)visible */ arg@454: extern void view(Arg *arg); /* views the tag accordingly to arg's index */ arg@454: extern void viewall(Arg *arg); /* views all tags, arg is ignored */ arg@452: extern void zoom(Arg *arg); /* zooms the focused client to master column, arg is ignored */