all repos — dwm @ b597fa46370af6594c0980f6c2ddefbe943ee933

fork of suckless dynamic window manager

dwm.h (view raw)

  1/*
  2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  3 * See LICENSE file for license details.
  4 */
  5
  6#include "config.h"
  7#include <X11/Xlib.h>
  8
  9/* mask shorthands, used in event.c and client.c */
 10#define BUTTONMASK		(ButtonPressMask | ButtonReleaseMask)
 11#define MOUSEMASK		(BUTTONMASK | PointerMotionMask)
 12#define PROTODELWIN		1
 13
 14enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
 15enum { WMProtocols, WMDelete, WMLast };			/* default atoms */
 16enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
 17enum { ColFG, ColBG, ColLast };				/* color */
 18
 19typedef enum {
 20	TopLeft, TopRight, BotLeft, BotRight
 21} Corner; /* window corners */
 22
 23typedef union {
 24	const char *cmd;
 25	int i;
 26} Arg; /* argument type */
 27
 28typedef struct {
 29	int ascent;
 30	int descent;
 31	int height;
 32	XFontSet set;
 33	XFontStruct *xfont;
 34} Fnt;
 35
 36typedef struct {
 37	int x, y, w, h;
 38	unsigned long norm[ColLast];
 39	unsigned long sel[ColLast];
 40	unsigned long status[ColLast];
 41	Drawable drawable;
 42	Fnt font;
 43	GC gc;
 44} DC; /* draw context */
 45
 46typedef struct Client Client;
 47struct Client {
 48	char name[256];
 49	int proto;
 50	int x, y, w, h;
 51	int tx, ty, tw, th; /* title window geometry */
 52	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
 53	int grav;
 54	long flags; 
 55	unsigned int border, weight;
 56	Bool isfloat;
 57	Bool *tags;
 58	Client *next;
 59	Client *prev;
 60	Client *snext;
 61	Window win;
 62	Window twin;
 63};
 64
 65extern const char *tags[];			/* all tags */
 66extern char stext[1024];			/* status text */
 67extern int bx, by, bw, bh, bmw;			/* bar geometry, bar mode label width */
 68extern int mw, screen, sx, sy, sw, sh;		/* screen geometry, master width */
 69extern unsigned int ntags, numlockmask;		/* number of tags, dynamic lock mask */
 70extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
 71extern void (*arrange)(Arg *);			/* arrange function, indicates mode  */
 72extern Atom wmatom[WMLast], netatom[NetLast];
 73extern Bool running, issel, maximized, *seltag;	/* seltag is array of Bool */
 74extern Client *clients, *sel, *stack;		/* global cleint list and stack */
 75extern Cursor cursor[CurLast];
 76extern DC dc;					/* global draw context */
 77extern Display *dpy;
 78extern Window root, barwin;
 79
 80/* client.c */
 81extern void ban(Client *c);			/* ban c from screen */
 82extern void focus(Client *c);			/* focus c, c may be NULL */
 83extern Client *getclient(Window w);		/* return client of w */
 84extern Client *getctitle(Window w);		/* return client of title window */
 85extern void gravitate(Client *c, Bool invert);	/* gravitate c */
 86extern void killclient(Arg *arg);		/* kill c nicely */
 87extern void manage(Window w, XWindowAttributes *wa);	/* manage new client */
 88extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
 89extern void updatesize(Client *c);			/* update the size structs of c */
 90extern void updatetitle(Client *c);		/* update the name of c */
 91extern void togglemax(Arg *arg);		/* (un)maximize c */
 92extern void unmanage(Client *c);		/* destroy c */
 93
 94/* draw.c */
 95extern void drawall();				/* draw all visible client titles and the bar */
 96extern void drawstatus();			/* draw the bar */
 97extern void drawtitle(Client *c);		/* draw title of c */
 98extern unsigned long getcolor(const char *colstr);	/* return color of colstr */
 99extern void setfont(const char *fontstr);	/* set the font for DC */
100extern unsigned int textw(const char *text);	/* return the text width of text */
101
102/* event.c */
103extern void grabkeys();				/* grab all keys defined in config.h */
104extern void procevent();			/* process pending X events */
105
106/* main.c */
107extern int getproto(Window w);			/* return protocol mask of WMProtocols property of w */
108extern void quit(Arg *arg);			/* quit dwm nicely */
109extern void sendevent(Window w, Atom a, long value);	/* send synthetic event to w */
110extern int xerror(Display *dsply, XErrorEvent *ee);	/* dwm's X error handler */
111
112/* tag.c */
113extern void initrregs();			/* initialize regexps of rules defined in config.h */
114extern Client *getnext(Client *c);		/* returns next visible client */
115extern Client *getprev(Client *c);		/* returns previous visible client */
116extern void settags(Client *c, Client *trans);	/* sets tags of c */
117extern void tag(Arg *arg);			/* tags c accordingly to arg's index */
118extern void toggletag(Arg *arg);		/* toggles c tags accordingly to arg's index */
119
120/* util.c */
121extern void *emallocz(unsigned int size);	/* allocates zero-initialized memory, exits on error */
122extern void eprint(const char *errstr, ...);	/* prints error string and exits with return code 1 */
123extern void *erealloc(void *ptr, unsigned int size);	/* reallocates memory, exits on error */
124extern void spawn(Arg *arg);			/* forks a new subprocess accordingly to arg's cmd */
125
126/* view.c */
127extern void detach(Client *c);			/* detaches c from global client list */
128extern void dofloat(Arg *arg);			/* arranges all windows in a floating way, arg is ignored */
129extern void dotile(Arg *arg);			/* arranges all windows in a tiled way, arg is ignored */
130extern void focusnext(Arg *arg);		/* focuses next visible client, arg is ignored  */
131extern void focusprev(Arg *arg);		/* focuses previous visible client, arg is ignored */
132extern Bool isvisible(Client *c);		/* returns True if client is visible */
133extern void resizecol(Arg *arg);		/* resizes the master width accordingly to arg's index value */
134extern void restack();				/* restores z layers of all clients */
135extern void togglemode(Arg *arg);		/* toggles global arrange function (between dotile and dofloat) */
136extern void toggleview(Arg *arg);		/* toggles the tag accordingly to arg's index (in)visible */
137extern void view(Arg *arg);			/* views the tag accordingly to arg's index */
138extern void viewall(Arg *arg);			/* views all tags, arg is ignored */
139extern void zoom(Arg *arg);			/* zooms the focused client to master column, arg is ignored */