aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/dwm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/dwm.h')
-rw-r--r--src/core/dwm.h268
1 files changed, 268 insertions, 0 deletions
diff --git a/src/core/dwm.h b/src/core/dwm.h
new file mode 100644
index 0000000..68eaf93
--- /dev/null
+++ b/src/core/dwm.h
@@ -0,0 +1,268 @@
1/* enums */
2enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
3enum { SchemeNorm, SchemeSel }; /* color schemes */
4enum {
5 NetSupported,
6 NetWMName,
7 NetWMState,
8 NetWMCheck,
9 NetSystemTray,
10 NetSystemTrayOP,
11 NetSystemTrayOrientation,
12 NetSystemTrayOrientationHorz,
13 NetWMFullscreen,
14 NetActiveWindow,
15 NetWMWindowType,
16 NetWMWindowTypeDialog,
17 NetClientList,
18 NetLast
19}; /* EWMH atoms */
20enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
21enum {
22 WMProtocols,
23 WMDelete,
24 WMState,
25 WMTakeFocus,
26 WMLast
27}; /* default atoms */
28enum {
29 ClkTagBar,
30 ClkLtSymbol,
31 ClkStatusText,
32 ClkWinTitle,
33 ClkClientWin,
34 ClkRootWin,
35 ClkLast
36}; /* clicks */
37
38typedef union {
39 int i;
40 unsigned int ui;
41 float f;
42 const void *v;
43} Arg;
44
45typedef struct {
46 unsigned int click;
47 unsigned int mask;
48 unsigned int button;
49 void (*func)(const Arg *arg);
50 const Arg arg;
51} Button;
52
53typedef struct Monitor Monitor;
54typedef struct Client Client;
55struct Client {
56 char name[256];
57 float mina, maxa;
58 int x, y, w, h;
59 int oldx, oldy, oldw, oldh;
60 int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
61 int bw, oldbw;
62 unsigned int tags;
63 int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen,
64 isterminal, noswallow;
65 pid_t pid;
66 Client *next;
67 Client *snext;
68 Client *swallowing;
69 Monitor *mon;
70 Window win;
71};
72
73typedef struct {
74 unsigned int mod;
75 KeySym keysym;
76 void (*func)(const Arg *);
77 const Arg arg;
78} Key;
79
80typedef struct {
81 const char *symbol;
82 void (*arrange)(Monitor *);
83} Layout;
84
85struct Monitor {
86 char ltsymbol[16];
87 float mfact;
88 int nmaster;
89 int num;
90 int by; /* bar geometry */
91 int mx, my, mw, mh; /* screen size */
92 int wx, wy, ww, wh; /* window area */
93 int gappih; /* horizontal gap between windows */
94 int gappiv; /* vertical gap between windows */
95 int gappoh; /* horizontal outer gaps */
96 int gappov; /* vertical outer gaps */
97 unsigned int seltags;
98 unsigned int sellt;
99 unsigned int tagset[2];
100 int showbar;
101 int topbar;
102 Client *clients;
103 Client *sel;
104 Client *stack;
105 Monitor *next;
106 Window barwin;
107 const Layout *lt[2];
108};
109
110typedef struct {
111 const char *class;
112 const char *instance;
113 const char *title;
114 unsigned int tags;
115 int isfloating;
116 int isterminal;
117 int noswallow;
118 int monitor;
119} Rule;
120
121typedef struct Systray Systray;
122struct Systray {
123 Window win;
124 Client *icons;
125};
126
127/* function declarations */
128static void applyrules(Client *c);
129static int applysizehints(Client *c, int *x, int *y, int *w, int *h,
130 int interact);
131static void arrange(Monitor *m);
132static void arrangemon(Monitor *m);
133static void attach(Client *c);
134static void attachstack(Client *c);
135static void buttonpress(XEvent *e);
136static void checkotherwm(void);
137static void cleanup(void);
138static void cleanupmon(Monitor *mon);
139static void clientmessage(XEvent *e);
140static void configure(Client *c);
141static void configurenotify(XEvent *e);
142static void configurerequest(XEvent *e);
143static Monitor *createmon(void);
144static void destroynotify(XEvent *e);
145static void detach(Client *c);
146static void detachstack(Client *c);
147static void drawbar(Monitor *m);
148static void drawbars(void);
149static void enternotify(XEvent *e);
150static void expose(XEvent *e);
151static void focus(Client *c);
152static void focusin(XEvent *e);
153static Atom getatomprop(Client *c, Atom prop);
154static int getrootptr(int *x, int *y);
155static long getstate(Window w);
156static unsigned int getsystraywidth();
157static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
158static void grabbuttons(Client *c, int focused);
159static void grabkeys(void);
160static void keypress(XEvent *e);
161static void killclient(const Arg *arg);
162static void manage(Window w, XWindowAttributes *wa);
163static void mappingnotify(XEvent *e);
164static void maprequest(XEvent *e);
165static void motionnotify(XEvent *e);
166static void movemouse(const Arg *arg);
167static Client *nexttiled(Client *c);
168static void pop(Client *c);
169static void propertynotify(XEvent *e);
170static void quit(const Arg *arg);
171static Monitor *recttomon(int x, int y, int w, int h);
172static void removesystrayicon(Client *i);
173static void resize(Client *c, int x, int y, int w, int h, int interact);
174static void resizebarwin(Monitor *m);
175static void resizeclient(Client *c, int x, int y, int w, int h);
176static void resizemouse(const Arg *arg);
177static void resizerequest(XEvent *e);
178static void restack(Monitor *m);
179static void run(void);
180static void scan(void);
181static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2,
182 long d3, long d4);
183static void sendmon(Client *c, Monitor *m);
184static void setclientstate(Client *c, long state);
185static void setfocus(Client *c);
186static void setfullscreen(Client *c, int fullscreen);
187static void setlayout(const Arg *arg);
188static void setup(void);
189static void seturgent(Client *c, int urg);
190static void showhide(Client *c);
191static void spawn(const Arg *arg);
192static Monitor *systraytomon(Monitor *m);
193static void tag(const Arg *arg);
194static void tile(Monitor *m);
195static void togglebar(const Arg *arg);
196static void togglefloating(const Arg *arg);
197static void togglefullscr(const Arg *arg);
198static void toggletag(const Arg *arg);
199static void toggleview(const Arg *arg);
200static void unfocus(Client *c, int setfocus);
201static void unmanage(Client *c, int destroyed);
202static void unmapnotify(XEvent *e);
203static void updatebarpos(Monitor *m);
204static void updatebars(void);
205static void updateclientlist(void);
206static int updategeom(void);
207static void updatenumlockmask(void);
208static void updatesystray(void);
209static void updatesystrayicongeom(Client *i, int w, int h);
210static void updatesystrayiconstate(Client *i, XPropertyEvent *ev);
211static void updatesizehints(Client *c);
212static void updatestatus(void);
213static void updatetitle(Client *c);
214static void updatewindowtype(Client *c);
215static void updatewmhints(Client *c);
216static void view(const Arg *arg);
217static Client *wintoclient(Window w);
218static Monitor *wintomon(Window w);
219static Client *wintosystrayicon(Window w);
220static int xerror(Display *dpy, XErrorEvent *ee);
221static int xerrordummy(Display *dpy, XErrorEvent *ee);
222static int xerrorstart(Display *dpy, XErrorEvent *ee);
223static void zoom(const Arg *arg);
224
225static pid_t getparentprocess(pid_t p);
226static int isdescprocess(pid_t p, pid_t c);
227static Client *swallowingclient(Window w);
228static Client *termforwin(const Client *c);
229static pid_t winpid(Window w);
230
231/* variables */
232static Systray *systray = NULL;
233static const char broken[] = "broken";
234static char stext[256];
235static int screen;
236static int sw, sh; /* X display screen geometry width, height */
237static int bh; /* bar height */
238static int enablegaps = 1; /* enables gaps, used by togglegaps */
239static int lrpad; /* sum of left and right padding for text */
240static int (*xerrorxlib)(Display *, XErrorEvent *);
241static unsigned int numlockmask = 0;
242static void (*handler[LASTEvent])(XEvent *) = {
243 [ButtonPress] = buttonpress,
244 [ClientMessage] = clientmessage,
245 [ConfigureRequest] = configurerequest,
246 [ConfigureNotify] = configurenotify,
247 [DestroyNotify] = destroynotify,
248 [EnterNotify] = enternotify,
249 [Expose] = expose,
250 [FocusIn] = focusin,
251 [KeyPress] = keypress,
252 [MappingNotify] = mappingnotify,
253 [MapRequest] = maprequest,
254 [MotionNotify] = motionnotify,
255 [PropertyNotify] = propertynotify,
256 [ResizeRequest] = resizerequest,
257 [UnmapNotify] = unmapnotify};
258
259static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];
260static int running = 1;
261static Cur *cursor[CurLast];
262static Clr **scheme;
263static Display *dpy;
264static Drw *drw;
265static Monitor *mons, *selmon;
266static Window root, wmcheckwin;
267
268static xcb_connection_t *xcon;