annotate dwm.h @ 13:c65d4f8dc8fd

use inverse border color
author paulo
date Sat, 12 Mar 2016 23:30:00 -0800
parents bc03b37b37ba
children
rev   line source
paulo@0 1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
paulo@0 2 * See LICENSE file for license details.
paulo@0 3 *
paulo@0 4 * dynamic window manager is designed like any other X client as well. It is
paulo@0 5 * driven through handling X events. In contrast to other X clients, a window
paulo@0 6 * manager selects for SubstructureRedirectMask on the root window, to receive
paulo@0 7 * events about window (dis-)appearance. Only one X connection at a time is
paulo@0 8 * allowed to select for this event mask.
paulo@0 9 *
paulo@0 10 * Calls to fetch an X event from the event queue are blocking. Due reading
paulo@0 11 * status text from standard input, a select()-driven main loop has been
paulo@0 12 * implemented which selects for reads on the X connection and STDIN_FILENO to
paulo@0 13 * handle all data smoothly. The event handlers of dwm are organized in an
paulo@0 14 * array which is accessed whenever a new event has been fetched. This allows
paulo@0 15 * event dispatching in O(1) time.
paulo@0 16 *
paulo@0 17 * Each child of the root window is called a client, except windows which have
paulo@0 18 * set the override_redirect flag. Clients are organized in a global
paulo@0 19 * doubly-linked client list, the focus history is remembered through a global
paulo@0 20 * stack list. Each client contains an array of Bools of the same size as the
paulo@0 21 * global tags array to indicate the tags of a client. For each client dwm
paulo@0 22 * creates a small title window, which is resized whenever the (_NET_)WM_NAME
paulo@0 23 * properties are updated or the client is moved/resized.
paulo@0 24 *
paulo@0 25 * Keys and tagging rules are organized as arrays and defined in the config.h
paulo@0 26 * file. These arrays are kept static in event.o and tag.o respectively,
paulo@0 27 * because no other part of dwm needs access to them. The current layout is
paulo@0 28 * represented by the lt pointer.
paulo@0 29 *
paulo@0 30 * To understand everything else, start reading main.c:main().
paulo@0 31 */
paulo@0 32
paulo@0 33 #include "config.h"
paulo@0 34 #include <X11/Xlib.h>
paulo@0 35
paulo@6 36 #define LENGTH(X) (sizeof X / sizeof X[0])
paulo@6 37
paulo@0 38 /* mask shorthands, used in event.c and client.c */
paulo@0 39 #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
paulo@0 40
paulo@0 41 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
paulo@0 42 enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
paulo@0 43 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
paulo@0 44 enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
paulo@0 45
paulo@0 46 typedef union {
paulo@0 47 const char *cmd;
paulo@0 48 int i;
paulo@0 49 } Arg; /* argument type */
paulo@0 50
paulo@0 51 typedef struct {
paulo@0 52 int ascent;
paulo@0 53 int descent;
paulo@0 54 int height;
paulo@0 55 XFontSet set;
paulo@0 56 XFontStruct *xfont;
paulo@0 57 } Fnt;
paulo@0 58
paulo@0 59 typedef struct {
paulo@0 60 int x, y, w, h;
paulo@0 61 unsigned long norm[ColLast];
paulo@0 62 unsigned long sel[ColLast];
paulo@11 63 unsigned long inv[ColLast];
paulo@0 64 Drawable drawable;
paulo@0 65 Fnt font;
paulo@0 66 GC gc;
paulo@0 67 } DC; /* draw context */
paulo@0 68
paulo@0 69 typedef struct Client Client;
paulo@0 70 struct Client {
paulo@0 71 char name[256];
paulo@0 72 int x, y, w, h;
paulo@0 73 int rx, ry, rw, rh; /* revert geometry */
paulo@0 74 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
paulo@0 75 int minax, minay, maxax, maxay;
paulo@0 76 long flags;
paulo@0 77 unsigned int border;
paulo@0 78 Bool isbanned, isfixed, ismax, isversatile;
paulo@0 79 Bool *tags;
paulo@0 80 Client *next;
paulo@0 81 Client *prev;
paulo@0 82 Client *snext;
paulo@0 83 Window win;
paulo@0 84 };
paulo@0 85
paulo@0 86 typedef struct {
paulo@0 87 const char *symbol;
paulo@0 88 void (*arrange)(void);
paulo@0 89 } Layout;
paulo@0 90
paulo@0 91 extern const char *tags[]; /* all tags */
paulo@0 92 extern char stext[256]; /* status text */
paulo@0 93 extern int screen, sx, sy, sw, sh; /* screen geometry */
paulo@0 94 extern int wax, way, wah, waw; /* windowarea geometry */
paulo@0 95 extern unsigned int bh, blw; /* bar height, bar layout label width */
paulo@0 96 extern unsigned int master, nmaster; /* master percent, number of master clients */
paulo@0 97 extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
paulo@0 98 extern void (*handler[LASTEvent])(XEvent *); /* event handler */
paulo@0 99 extern Atom wmatom[WMLast], netatom[NetLast];
paulo@0 100 extern Bool selscreen, *seltag; /* seltag is array of Bool */
paulo@0 101 extern Client *clients, *sel, *stack; /* global client list and stack */
paulo@0 102 extern Cursor cursor[CurLast];
paulo@0 103 extern DC dc; /* global draw context */
paulo@0 104 extern Display *dpy;
paulo@0 105 extern Layout *lt;
paulo@3 106 extern Window root, barwin, tbarwin;
paulo@0 107
paulo@0 108 /* client.c */
paulo@0 109 extern void configure(Client *c); /* send synthetic configure event */
paulo@0 110 extern void focus(Client *c); /* focus c, c may be NULL */
paulo@0 111 extern void killclient(Arg *arg); /* kill c nicely */
paulo@0 112 extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
paulo@0 113 extern void resize(Client *c, int x, int y,
paulo@0 114 int w, int h, Bool sizehints); /* resize with given coordinates c*/
paulo@0 115 extern void toggleversatile(Arg *arg); /* toggles focused client between versatile/and non-versatile state */
paulo@0 116 extern void updatesizehints(Client *c); /* update the size hint variables of c */
paulo@0 117 extern void updatetitle(Client *c); /* update the name of c */
paulo@0 118 extern void unmanage(Client *c); /* destroy c */
paulo@0 119 extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
paulo@6 120 extern void zoom_insert(Arg *arg); /* zoom, then go into insert mode */
paulo@0 121 extern void pushup(Arg *arg);
paulo@0 122 extern void pushdown(Arg *arg);
paulo@0 123 extern void moveresize(Arg *arg);
paulo@0 124
paulo@0 125 /* draw.c */
paulo@0 126 extern void drawstatus(void); /* draw the bar */
paulo@0 127 extern void drawtext(const char *text,
paulo@0 128 unsigned long col[ColLast]); /* draw text */
paulo@0 129 extern unsigned int textw(const char *text); /* return the width of text in px*/
paulo@0 130
paulo@0 131 /* event.c */
paulo@0 132 extern void grabkeys(void); /* grab all keys defined in config.h */
paulo@6 133 extern void clearcmd(Arg *arg);
paulo@6 134 extern void setkeymode(Arg *arg);
paulo@6 135 extern unsigned int getkeymode(void);
paulo@6 136 extern void func_insert(void (*argfunc)(Arg *), Arg *arg);
paulo@0 137
paulo@0 138 /* layout.c */
paulo@0 139 extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
paulo@0 140 extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
paulo@0 141 extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */
paulo@0 142 extern void initlayouts(void); /* initialize layout array */
paulo@0 143 extern Client *nexttiled(Client *c); /* returns tiled successor of c */
paulo@0 144 extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */
paulo@0 145 extern void restack(void); /* restores z layers of all clients */
paulo@0 146 extern void setlayout(Arg *arg); /* sets layout, -1 toggles */
paulo@0 147 extern void versatile(void); /* arranges all windows versatile */
paulo@0 148
paulo@0 149 /* main.c */
paulo@0 150 extern void quit(Arg *arg); /* quit dwm nicely */
paulo@0 151 extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
paulo@0 152 extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
paulo@0 153
paulo@0 154 /* tag.c */
paulo@0 155 extern void compileregs(void); /* initialize regexps of rules defined in config.h */
paulo@0 156 extern Bool isvisible(Client *c); /* returns True if client is visible */
paulo@0 157 extern void settags(Client *c, Client *trans); /* sets tags of c */
paulo@0 158 extern void tag(Arg *arg); /* tags c with arg's index */
paulo@0 159 extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
paulo@0 160 extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
paulo@0 161 extern void view(Arg *arg); /* views the tag with arg's index */
paulo@0 162 extern void last_view(Arg *arg); /* go to last viewed tag */
paulo@1 163 extern void next_view(Arg *arg); /* go to next/prev tag */
paulo@8 164 extern void tag_n_view(Arg *arg); /* tag then view */
paulo@0 165
paulo@0 166 /* util.c */
paulo@0 167 extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
paulo@0 168 extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
paulo@0 169 extern void spawn(Arg *arg); /* forks a new subprocess with arg's cmd */
paulo@6 170 extern void spawn_insert(Arg *arg); /* spawn, then go into insert mode */