Mercurial > dwm-meillo
annotate dwm.h @ 455:4e3e22673073
fixed some other comments, now also the code side seems to be at a level to be reviewed by experienced programmers
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Mon, 11 Sep 2006 11:28:28 +0200 |
parents | ffb462fb7903 |
children | d11d739ad9df |
rev | line source |
---|---|
0 | 1 /* |
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | |
3 * See LICENSE file for license details. | |
4 */ | |
5 | |
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
|
6 #include "config.h" |
32 | 7 #include <X11/Xlib.h> |
8 | |
143 | 9 /* 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
|
10 #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) |
a26b32ff8911
cleaned config.*h to prevent some confusion
arg@10ksloc.org
parents:
148
diff
changeset
|
11 #define MOUSEMASK (BUTTONMASK | PointerMotionMask) |
157
93012e947eae
renamed WM_PROTOCOL_DELWIN into PROTODELWIN
arg@10ksloc.org
parents:
150
diff
changeset
|
12 #define PROTODELWIN 1 |
143 | 13 |
452 | 14 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ |
15 enum { WMProtocols, WMDelete, WMLast }; /* default atoms */ | |
16 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | |
17 enum { ColFG, ColBG, ColLast }; /* color */ | |
18 | |
19 typedef enum { | |
20 TopLeft, TopRight, BotLeft, BotRight | |
21 } Corner; /* window corners */ | |
22 | |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
23 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
|
24 const char *cmd; |
49
466591c2f967
implemented tagging a client
Anselm R. Garbe <garbeam@wmii.de>
parents:
46
diff
changeset
|
25 int i; |
452 | 26 } Arg; /* argument type */ |
99
a19556fe83b5
applied Sanders resize patch, fixed lower bug
arg@10ksloc.org
parents:
95
diff
changeset
|
27 |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
28 typedef struct { |
32 | 29 int ascent; |
30 int descent; | |
31 int height; | |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
32 XFontSet set; |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
33 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
|
34 } Fnt; |
32 | 35 |
452 | 36 typedef struct { |
32 | 37 int x, y, w, h; |
353
8a06efe5b563
new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents:
352
diff
changeset
|
38 unsigned long norm[ColLast]; |
8a06efe5b563
new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents:
352
diff
changeset
|
39 unsigned long sel[ColLast]; |
8a06efe5b563
new color stuff/new rendering stuff
Anselm R. Garbe <arg@10kloc.org>
parents:
352
diff
changeset
|
40 unsigned long status[ColLast]; |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
41 Drawable drawable; |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
42 Fnt font; |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
43 GC gc; |
452 | 44 } DC; /* draw context */ |
32 | 45 |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
46 typedef struct Client Client; |
0 | 47 struct Client { |
31 | 48 char name[256]; |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
49 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
|
50 int x, y, w, h; |
453 | 51 int tx, ty, tw, th; /* title window geometry */ |
20 | 52 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
29 | 53 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
|
54 long flags; |
381
b00cc483d13b
still something wrong with reorder()
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
55 unsigned int border, weight; |
80
8125f908c80c
several additions in mouse handling ;)
Anselm R. Garbe <garbeam@wmii.de>
parents:
78
diff
changeset
|
56 Bool isfloat; |
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
|
57 Bool *tags; |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
58 Client *next; |
127
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
59 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
|
60 Client *snext; |
0 | 61 Window win; |
342 | 62 Window twin; |
0 | 63 }; |
64 | |
452 | 65 extern const char *tags[]; /* all tags */ |
66 extern char stext[1024]; /* status text */ | |
67 extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ | |
68 extern int mw, screen, sx, sy, sw, sh; /* screen geometry, master width */ | |
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
|
69 extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */ |
452 | 70 extern void (*handler[LASTEvent])(XEvent *); /* event handler */ |
71 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
|
72 extern Atom wmatom[WMLast], netatom[NetLast]; |
452 | 73 extern Bool running, issel, maximized, *seltag; /* seltag is array of Bool */ |
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
|
74 extern Client *clients, *sel, *stack; /* global cleint list and stack */ |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
75 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
|
76 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
|
77 extern Display *dpy; |
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
78 extern Window root, barwin; |
3
e969f3575b7a
several new changes, made gridmenu working
Anselm R. Garbe <garbeam@wmii.de>
parents:
2
diff
changeset
|
79 |
5 | 80 /* 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
|
81 extern void ban(Client *c); /* ban c from screen */ |
452 | 82 extern void focus(Client *c); /* focus c, c may be NULL */ |
83 extern Client *getclient(Window w); /* return client of w */ | |
84 extern Client *getctitle(Window w); /* return client of title window */ | |
85 extern void gravitate(Client *c, Bool invert); /* gravitate c */ | |
86 extern void killclient(Arg *arg); /* kill c nicely */ | |
87 extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ | |
88 extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize 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
|
89 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
|
90 extern void updatetitle(Client *c); /* update the name of c */ |
452 | 91 extern void togglemax(Arg *arg); /* (un)maximize c */ |
92 extern void unmanage(Client *c); /* destroy c */ | |
13
5cc5e55a132d
added protocol killing stuff
Anselm R. Garbe <garbeam@wmii.de>
parents:
10
diff
changeset
|
93 |
33
e90449e03167
new stuff (some warning elimination)
Anselm R. Garbe <garbeam@wmii.de>
parents:
32
diff
changeset
|
94 /* draw.c */ |
452 | 95 extern void drawall(); /* draw all visible client titles and the bar */ |
96 extern void drawstatus(); /* draw the bar */ | |
97 extern void drawtitle(Client *c); /* draw title of c */ | |
98 extern unsigned long getcolor(const char *colstr); /* return color of colstr */ | |
99 extern void setfont(const char *fontstr); /* set the font for DC */ | |
100 extern unsigned int textw(const char *text); /* return the text width of text */ | |
33
e90449e03167
new stuff (some warning elimination)
Anselm R. Garbe <garbeam@wmii.de>
parents:
32
diff
changeset
|
101 |
75 | 102 /* event.c */ |
452 | 103 extern void grabkeys(); /* grab all keys defined in config.h */ |
104 extern void procevent(); /* process pending X events */ | |
18
1efa34c6e1b6
added mouse-based resizals
Anselm R. Garbe <garbeam@wmii.de>
parents:
16
diff
changeset
|
105 |
43 | 106 /* main.c */ |
452 | 107 extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */ |
108 extern void quit(Arg *arg); /* quit dwm nicely */ | |
109 extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ | |
110 extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ | |
43 | 111 |
75 | 112 /* tag.c */ |
452 | 113 extern void initrregs(); /* initialize regexps of rules defined in config.h */ |
114 extern Client *getnext(Client *c); /* returns next visible client */ | |
115 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
|
116 extern void settags(Client *c, Client *trans); /* sets tags of c */ |
452 | 117 extern void tag(Arg *arg); /* tags c accordingly to arg's index */ |
118 extern void toggletag(Arg *arg); /* toggles c tags accordingly to arg's index */ | |
73 | 119 |
32 | 120 /* util.c */ |
452 | 121 extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ |
122 extern void eprint(const char *errstr, ...); /* prints error string and exits with return code 1 */ | |
123 extern void *erealloc(void *ptr, unsigned int size); /* reallocates memory, exits on error */ | |
453 | 124 extern void spawn(Arg *arg); /* forks a new subprocess accordingly to arg's cmd */ |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
292
diff
changeset
|
125 |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
292
diff
changeset
|
126 /* view.c */ |
452 | 127 extern void detach(Client *c); /* detaches c from global client list */ |
128 extern void dofloat(Arg *arg); /* arranges all windows in a floating way, arg is ignored */ | |
129 extern void dotile(Arg *arg); /* arranges all windows in a tiled way, arg is ignored */ | |
130 extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ | |
131 extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ | |
132 extern Bool isvisible(Client *c); /* returns True if client is visible */ | |
133 extern void resizecol(Arg *arg); /* resizes the master width accordingly to arg's index value */ | |
134 extern void restack(); /* restores z layers of all clients */ | |
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
|
135 extern void togglemode(Arg *arg); /* toggles global arrange function (between dotile and dofloat) */ |
ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents:
453
diff
changeset
|
136 extern void toggleview(Arg *arg); /* toggles the tag accordingly to arg's index (in)visible */ |
ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents:
453
diff
changeset
|
137 extern void view(Arg *arg); /* views the tag accordingly to arg's index */ |
ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
Anselm R. Garbe <arg@10kloc.org>
parents:
453
diff
changeset
|
138 extern void viewall(Arg *arg); /* views all tags, arg is ignored */ |
452 | 139 extern void zoom(Arg *arg); /* zooms the focused client to master column, arg is ignored */ |