Mercurial > aewl
annotate dwm.h @ 525:7433954e80af
final fix for man page
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Thu, 05 Oct 2006 13:44:48 +0200 |
parents | 1a9a0877650c |
children | 451f19d48845 |
rev | line source |
---|---|
0 | 1 /* |
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | |
3 * See LICENSE file for license details. | |
457
e97ad13f04dc
added a general comment to dwm.h how dwm is basically organized
Anselm R. Garbe <arg@10kloc.org>
parents:
456
diff
changeset
|
4 * |
e97ad13f04dc
added a general comment to dwm.h how dwm is basically organized
Anselm R. Garbe <arg@10kloc.org>
parents:
456
diff
changeset
|
5 * dynamic window manager is designed like any other X client as well. It is |
e97ad13f04dc
added a general comment to dwm.h how dwm is basically organized
Anselm R. Garbe <arg@10kloc.org>
parents:
456
diff
changeset
|
6 * driven through handling X events. In contrast to other X clients, a window |
468 | 7 * manager selects for SubstructureRedirectMask on the root window, to receive |
8 * events about window (dis-)appearance. Only one X connection at a time is | |
9 * allowed to select for this event mask. | |
457
e97ad13f04dc
added a general comment to dwm.h how dwm is basically organized
Anselm R. Garbe <arg@10kloc.org>
parents:
456
diff
changeset
|
10 * |
468 | 11 * Calls to fetch an X event from the event queue are blocking. Due reading |
469
a2cc7adf9d4d
improved intro comment in dwm.h, updated config.mk
arg@mmvi
parents:
468
diff
changeset
|
12 * status text from standard input, a select()-driven main loop has been |
468 | 13 * implemented which selects for reads on the X connection and STDIN_FILENO to |
14 * handle all data smoothly. The event handlers of dwm are organized in an | |
15 * array which is accessed whenever a new event has been fetched. This allows | |
16 * event dispatching in O(1) time. | |
457
e97ad13f04dc
added a general comment to dwm.h how dwm is basically organized
Anselm R. Garbe <arg@10kloc.org>
parents:
456
diff
changeset
|
17 * |
460
ab4b08d49d24
some more simplifications of intro comment in dwm.h, this should suffice for comments in dwm
Anselm R. Garbe <arg@10kloc.org>
parents:
459
diff
changeset
|
18 * Each child of the root window is called a client, except windows which have |
ab4b08d49d24
some more simplifications of intro comment in dwm.h, this should suffice for comments in dwm
Anselm R. Garbe <arg@10kloc.org>
parents:
459
diff
changeset
|
19 * set the override_redirect flag. Clients are organized in a global |
ab4b08d49d24
some more simplifications of intro comment in dwm.h, this should suffice for comments in dwm
Anselm R. Garbe <arg@10kloc.org>
parents:
459
diff
changeset
|
20 * doubly-linked client list, the focus history is remembered through a global |
ab4b08d49d24
some more simplifications of intro comment in dwm.h, this should suffice for comments in dwm
Anselm R. Garbe <arg@10kloc.org>
parents:
459
diff
changeset
|
21 * stack list. Each client contains an array of Bools of the same size as the |
ab4b08d49d24
some more simplifications of intro comment in dwm.h, this should suffice for comments in dwm
Anselm R. Garbe <arg@10kloc.org>
parents:
459
diff
changeset
|
22 * global tags array to indicate the tags of a client. For each client dwm |
468 | 23 * creates a small title window, which is resized whenever the (_NET_)WM_NAME |
24 * properties are updated or the client is moved/resized. | |
457
e97ad13f04dc
added a general comment to dwm.h how dwm is basically organized
Anselm R. Garbe <arg@10kloc.org>
parents:
456
diff
changeset
|
25 * |
459
3c3f429dca99
made introduction comment in dwm.h shorter
Anselm R. Garbe <arg@10kloc.org>
parents:
457
diff
changeset
|
26 * Keys and tagging rules are organized as arrays and defined in the config.h |
3c3f429dca99
made introduction comment in dwm.h shorter
Anselm R. Garbe <arg@10kloc.org>
parents:
457
diff
changeset
|
27 * file. These arrays are kept static in event.o and tag.o respectively, |
3c3f429dca99
made introduction comment in dwm.h shorter
Anselm R. Garbe <arg@10kloc.org>
parents:
457
diff
changeset
|
28 * because no other part of dwm needs access to them. The current mode is |
469
a2cc7adf9d4d
improved intro comment in dwm.h, updated config.mk
arg@mmvi
parents:
468
diff
changeset
|
29 * represented by the arrange() function pointer, which wether points to |
a2cc7adf9d4d
improved intro comment in dwm.h, updated config.mk
arg@mmvi
parents:
468
diff
changeset
|
30 * dofloat() or dotile(). |
457
e97ad13f04dc
added a general comment to dwm.h how dwm is basically organized
Anselm R. Garbe <arg@10kloc.org>
parents:
456
diff
changeset
|
31 * |
468 | 32 * To understand everything else, start reading main.c:main(). |
0 | 33 */ |
34 | |
166
e0535db04dfe
removed the CONFIG variable from config.mk, renamed config.h into config.default.h, after first clone/extract one needs to copy config.default.h to config.h, that is easier than always heavy typing make CONFIG=blafasel
arg@10ksloc.org
parents:
164
diff
changeset
|
35 #include "config.h" |
32 | 36 #include <X11/Xlib.h> |
37 | |
143 | 38 /* mask shorthands, used in event.c and client.c */ |
150
a26b32ff8911
cleaned config.*h to prevent some confusion
arg@10ksloc.org
parents:
148
diff
changeset
|
39 #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) |
a26b32ff8911
cleaned config.*h to prevent some confusion
arg@10ksloc.org
parents:
148
diff
changeset
|
40 #define MOUSEMASK (BUTTONMASK | PointerMotionMask) |
502 | 41 /* other stuff used in different places */ |
42 #define BORDERPX 1 | |
157
93012e947eae
renamed WM_PROTOCOL_DELWIN into PROTODELWIN
arg@10ksloc.org
parents:
150
diff
changeset
|
43 #define PROTODELWIN 1 |
143 | 44 |
452 | 45 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ |
46 enum { WMProtocols, WMDelete, WMLast }; /* default atoms */ | |
47 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | |
48 enum { ColFG, ColBG, ColLast }; /* color */ | |
49 | |
50 typedef enum { | |
505
2c29d74b11dc
first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents:
502
diff
changeset
|
51 StackLeft, StackBottom, StackRight |
2c29d74b11dc
first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents:
502
diff
changeset
|
52 } StackPos; /* stack position*/ |
2c29d74b11dc
first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents:
502
diff
changeset
|
53 |
2c29d74b11dc
first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents:
502
diff
changeset
|
54 typedef enum { |
452 | 55 TopLeft, TopRight, BotLeft, BotRight |
56 } Corner; /* window corners */ | |
57 | |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
58 typedef union { |
189
523df4a3c1c4
using execl now, argv changed, using cmd and const char defs directly in the KEYS struct
arg@10ksloc.org
parents:
178
diff
changeset
|
59 const char *cmd; |
49
466591c2f967
implemented tagging a client
Anselm R. Garbe <garbeam@wmii.de>
parents:
46
diff
changeset
|
60 int i; |
452 | 61 } Arg; /* argument type */ |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
62 |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
63 typedef struct { |
32 | 64 int ascent; |
65 int descent; | |
66 int height; | |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
67 XFontSet set; |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
68 XFontStruct *xfont; |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
69 } Fnt; |
32 | 70 |
452 | 71 typedef struct { |
32 | 72 int x, y, w, h; |
353
8a06efe5b563
new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents:
352
diff
changeset
|
73 unsigned long norm[ColLast]; |
8a06efe5b563
new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents:
352
diff
changeset
|
74 unsigned long sel[ColLast]; |
8a06efe5b563
new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents:
352
diff
changeset
|
75 unsigned long status[ColLast]; |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
76 Drawable drawable; |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
77 Fnt font; |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
78 GC gc; |
452 | 79 } DC; /* draw context */ |
32 | 80 |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
81 typedef struct Client Client; |
0 | 82 struct Client { |
31 | 83 char name[256]; |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
84 int proto; |
115
329fd7dae530
removed c->f{x,y,w,h} and c->t{x,y,w,h} in favor for the new rule handling remembering two kinds of geometries is unnecessary, removed the randomized (x,y) setting on dofloat startup, was kind too random und unpredictable
arg@10ksloc.org
parents:
114
diff
changeset
|
85 int x, y, w, h; |
480 | 86 int rx, ry, rw, rh; /* revert geometry */ |
453 | 87 int tx, ty, tw, th; /* title window geometry */ |
20 | 88 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
29 | 89 int grav; |
164
21071ae1fe68
made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
arg@10ksloc.org
parents:
157
diff
changeset
|
90 long flags; |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
91 unsigned int border, weight; |
480 | 92 Bool isfloat, ismax; |
178
e848966a1ac6
removed TLast tag enum, now tags is simple defined as char *[] array, the rest is calculated correctly, rules take an int array for the tags
arg@10ksloc.org
parents:
173
diff
changeset
|
93 Bool *tags; |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
94 Client *next; |
127
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
95 Client *prev; |
446
a2e587651c79
using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents:
431
diff
changeset
|
96 Client *snext; |
0 | 97 Window win; |
342 | 98 Window twin; |
0 | 99 }; |
100 | |
452 | 101 extern const char *tags[]; /* all tags */ |
102 extern char stext[1024]; /* status text */ | |
103 extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ | |
524
1a9a0877650c
keep master ratio on resizecol -> arrange
Anselm R. Garbe <arg@10kloc.org>
parents:
522
diff
changeset
|
104 extern int screen, sx, sy, sw, sh; /* screen geometry */ |
1a9a0877650c
keep master ratio on resizecol -> arrange
Anselm R. Garbe <arg@10kloc.org>
parents:
522
diff
changeset
|
105 extern unsigned int master, ntags, numlockmask; /* master percent, number of tags, dynamic lock mask */ |
452 | 106 extern void (*handler[LASTEvent])(XEvent *); /* event handler */ |
107 extern void (*arrange)(Arg *); /* arrange function, indicates mode */ | |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
108 extern Atom wmatom[WMLast], netatom[NetLast]; |
473
2d8af0d7920d
implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents:
469
diff
changeset
|
109 extern Bool running, issel, *seltag; /* seltag is array of Bool */ |
488 | 110 extern Client *clients, *sel, *stack; /* global client list and stack */ |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
111 extern Cursor cursor[CurLast]; |
454
ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents:
453
diff
changeset
|
112 extern DC dc; /* global draw context */ |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
113 extern Display *dpy; |
505
2c29d74b11dc
first step to a more flexible dotile() algorithm
Anselm R. Garbe <arg@10kloc.org>
parents:
502
diff
changeset
|
114 extern StackPos stackpos; |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
115 extern Window root, barwin; |
3
e969f3575b7a
several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents:
2
diff
changeset
|
116 |
5 | 117 /* client.c */ |
454
ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents:
453
diff
changeset
|
118 extern void ban(Client *c); /* ban c from screen */ |
491
12395ef46d97
added configure(), but this doesn't really fix those frking broken SDL apps
arg@mmvi
parents:
488
diff
changeset
|
119 extern void configure(Client *c); /* send synthetic configure event */ |
452 | 120 extern void focus(Client *c); /* focus c, c may be NULL */ |
121 extern Client *getclient(Window w); /* return client of w */ | |
122 extern Client *getctitle(Window w); /* return client of title window */ | |
123 extern void gravitate(Client *c, Bool invert); /* gravitate c */ | |
124 extern void killclient(Arg *arg); /* kill c nicely */ | |
125 extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ | |
126 extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/ | |
500
d5ad819f2a66
fixing the settags issue, preparing 1.7.1
Anselm R. Garbe <arg@10kloc.org>
parents:
491
diff
changeset
|
127 extern void resizetitle(Client *c); /* resizes c->twin correctly */ |
454
ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents:
453
diff
changeset
|
128 extern void updatesize(Client *c); /* update the size structs of c */ |
ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents:
453
diff
changeset
|
129 extern void updatetitle(Client *c); /* update the name of c */ |
452 | 130 extern void unmanage(Client *c); /* destroy c */ |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
131 |
33
e90449e03167
new stuff (some warning elimination)
Anselm R. Garbe <garbeam@wmii.de>
parents:
32
diff
changeset
|
132 /* draw.c */ |
487 | 133 extern void drawall(void); /* draw all visible client titles and the bar */ |
134 extern void drawstatus(void); /* draw the bar */ | |
452 | 135 extern void drawtitle(Client *c); /* draw title of c */ |
136 extern unsigned long getcolor(const char *colstr); /* return color of colstr */ | |
137 extern void setfont(const char *fontstr); /* set the font for DC */ | |
456
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
138 extern unsigned int textw(const char *text); /* return the width of text in px*/ |
33
e90449e03167
new stuff (some warning elimination)
Anselm R. Garbe <garbeam@wmii.de>
parents:
32
diff
changeset
|
139 |
75 | 140 /* event.c */ |
487 | 141 extern void grabkeys(void); /* grab all keys defined in config.h */ |
142 extern void procevent(void); /* process pending X events */ | |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
143 |
43 | 144 /* main.c */ |
452 | 145 extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */ |
146 extern void quit(Arg *arg); /* quit dwm nicely */ | |
147 extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ | |
148 extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ | |
43 | 149 |
75 | 150 /* tag.c */ |
487 | 151 extern void initrregs(void); /* initialize regexps of rules defined in config.h */ |
452 | 152 extern Client *getnext(Client *c); /* returns next visible client */ |
153 extern Client *getprev(Client *c); /* returns previous visible client */ | |
454
ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents:
453
diff
changeset
|
154 extern void settags(Client *c, Client *trans); /* sets tags of c */ |
456
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
155 extern void tag(Arg *arg); /* tags c with arg's index */ |
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
156 extern void toggletag(Arg *arg); /* toggles c tags with arg's index */ |
73 | 157 |
32 | 158 /* util.c */ |
452 | 159 extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ |
456
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
160 extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ |
452 | 161 extern void *erealloc(void *ptr, unsigned int size); /* reallocates memory, exits on error */ |
456
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
162 extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
292
diff
changeset
|
163 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
292
diff
changeset
|
164 /* view.c */ |
452 | 165 extern void detach(Client *c); /* detaches c from global client list */ |
456
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
166 extern void dofloat(Arg *arg); /* arranges all windows floating, arg is ignored */ |
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
167 extern void dotile(Arg *arg); /* arranges all windows, arg is ignored */ |
452 | 168 extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ |
169 extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ | |
170 extern Bool isvisible(Client *c); /* returns True if client is visible */ | |
524
1a9a0877650c
keep master ratio on resizecol -> arrange
Anselm R. Garbe <arg@10kloc.org>
parents:
522
diff
changeset
|
171 extern void resizecol(Arg *arg); /* resizes the master percent with arg's index value */ |
487 | 172 extern void restack(void); /* restores z layers of all clients */ |
508
ede48935f2b3
added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents:
507
diff
changeset
|
173 extern void togglestackpos(Arg *arg); /* toggles stack position */ |
456
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
174 extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */ |
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
175 extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */ |
d11d739ad9df
some other simplifications
Anselm R. Garbe <arg@10kloc.org>
parents:
454
diff
changeset
|
176 extern void view(Arg *arg); /* views the tag with arg's index */ |
454
ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents:
453
diff
changeset
|
177 extern void viewall(Arg *arg); /* views all tags, arg is ignored */ |
508
ede48935f2b3
added the new dotile as described on ml
Anselm R. Garbe <arg@10kloc.org>
parents:
507
diff
changeset
|
178 extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */ |