summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--config.mk4
-rw-r--r--dwm.c65
-rw-r--r--dwm.h59
3 files changed, 63 insertions, 65 deletions
diff --git a/config.mk b/config.mk
index 9944f2a..ce7cdc7 100644
--- a/config.mk
+++ b/config.mk
@@ -17,8 +17,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
17# flags 17# flags
18CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" 18CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
19LDFLAGS = -s ${LIBS} 19LDFLAGS = -s ${LIBS}
20#CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" 20CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
21#LDFLAGS = -g ${LIBS} 21LDFLAGS = -g ${LIBS}
22 22
23# Solaris 23# Solaris
24#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" 24#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
diff --git a/dwm.c b/dwm.c
index ab9c11b..8f5ed6d 100644
--- a/dwm.c
+++ b/dwm.c
@@ -25,8 +25,6 @@
25 * 25 *
26 * To understand everything else, start reading main(). 26 * To understand everything else, start reading main().
27 */ 27 */
28#include "dwm.h"
29
30#include <errno.h> 28#include <errno.h>
31#include <locale.h> 29#include <locale.h>
32#include <stdarg.h> 30#include <stdarg.h>
@@ -41,73 +39,17 @@
41#include <X11/cursorfont.h> 39#include <X11/cursorfont.h>
42#include <X11/keysym.h> 40#include <X11/keysym.h>
43#include <X11/Xatom.h> 41#include <X11/Xatom.h>
42#include <X11/Xlib.h>
44#include <X11/Xproto.h> 43#include <X11/Xproto.h>
45#include <X11/Xutil.h> 44#include <X11/Xutil.h>
46 45
46#include "dwm.h"
47
47/* macros */ 48/* macros */
48#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) 49#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
49#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) 50#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
50#define MOUSEMASK (BUTTONMASK | PointerMotionMask) 51#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
51 52
52/* local typedefs */
53typedef struct {
54 const char *prop;
55 const char *tags;
56 Bool isfloating;
57} Rule;
58
59typedef struct {
60 regex_t *propregex;
61 regex_t *tagregex;
62} Regs;
63
64/* variables */
65char stext[256];
66double mwfact;
67int screen, sx, sy, sw, sh, wax, way, waw, wah;
68int (*xerrorxlib)(Display *, XErrorEvent *);
69unsigned int bh, bpos;
70unsigned int blw = 0;
71unsigned int ltidx = 0; /* default */
72unsigned int nlayouts = 0;
73unsigned int nrules = 0;
74unsigned int numlockmask = 0;
75void (*handler[LASTEvent]) (XEvent *) = {
76 [ButtonPress] = buttonpress,
77 [ConfigureRequest] = configurerequest,
78 [ConfigureNotify] = configurenotify,
79 [DestroyNotify] = destroynotify,
80 [EnterNotify] = enternotify,
81 [LeaveNotify] = leavenotify,
82 [Expose] = expose,
83 [KeyPress] = keypress,
84 [MappingNotify] = mappingnotify,
85 [MapRequest] = maprequest,
86 [PropertyNotify] = propertynotify,
87 [UnmapNotify] = unmapnotify
88};
89Atom wmatom[WMLast], netatom[NetLast];
90Bool otherwm, readin;
91Bool running = True;
92Bool selscreen = True;
93Client *clients = NULL;
94Client *sel = NULL;
95Client *stack = NULL;
96Cursor cursor[CurLast];
97Display *dpy;
98DC dc = {0};
99Window barwin, root;
100Regs *regs = NULL;
101
102/* configuration, allows nested code to access above variables */
103#include "config.h"
104
105/* Statically define the number of tags. */
106unsigned int ntags = sizeof tags / sizeof tags[0];
107Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
108Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};
109
110/* functions*/
111void 53void
112applyrules(Client *c) { 54applyrules(Client *c) {
113 static char buf[512]; 55 static char buf[512];
@@ -1032,7 +974,6 @@ quit(const char *arg) {
1032 974
1033void 975void
1034resize(Client *c, int x, int y, int w, int h, Bool sizehints) { 976resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
1035 double dx, dy, max, min, ratio;
1036 XWindowChanges wc; 977 XWindowChanges wc;
1037 978
1038 if(sizehints) { 979 if(sizehints) {
diff --git a/dwm.h b/dwm.h
index ff50d47..526653a 100644
--- a/dwm.h
+++ b/dwm.h
@@ -1,5 +1,4 @@
1/* See LICENSE file for copyright and license details. */ 1/* See LICENSE file for copyright and license details. */
2#include <X11/Xlib.h>
3 2
4/* enums */ 3/* enums */
5enum { BarTop, BarBot, BarOff }; /* bar position */ 4enum { BarTop, BarBot, BarOff }; /* bar position */
@@ -53,6 +52,17 @@ typedef struct {
53 void (*arrange)(void); 52 void (*arrange)(void);
54} Layout; 53} Layout;
55 54
55typedef struct {
56 const char *prop;
57 const char *tags;
58 Bool isfloating;
59} Rule;
60
61typedef struct {
62 regex_t *propregex;
63 regex_t *tagregex;
64} Regs;
65
56/* functions */ 66/* functions */
57void applyrules(Client *c); 67void applyrules(Client *c);
58void arrange(void); 68void arrange(void);
@@ -132,3 +142,50 @@ int xerror(Display *dpy, XErrorEvent *ee);
132int xerrordummy(Display *dsply, XErrorEvent *ee); 142int xerrordummy(Display *dsply, XErrorEvent *ee);
133int xerrorstart(Display *dsply, XErrorEvent *ee); 143int xerrorstart(Display *dsply, XErrorEvent *ee);
134void zoom(const char *arg); 144void zoom(const char *arg);
145
146/* variables */
147char stext[256];
148double mwfact;
149int screen, sx, sy, sw, sh, wax, way, waw, wah;
150int (*xerrorxlib)(Display *, XErrorEvent *);
151unsigned int bh, bpos;
152unsigned int blw = 0;
153unsigned int ltidx = 0; /* default */
154unsigned int nlayouts = 0;
155unsigned int nrules = 0;
156unsigned int numlockmask = 0;
157void (*handler[LASTEvent]) (XEvent *) = {
158 [ButtonPress] = buttonpress,
159 [ConfigureRequest] = configurerequest,
160 [ConfigureNotify] = configurenotify,
161 [DestroyNotify] = destroynotify,
162 [EnterNotify] = enternotify,
163 [LeaveNotify] = leavenotify,
164 [Expose] = expose,
165 [KeyPress] = keypress,
166 [MappingNotify] = mappingnotify,
167 [MapRequest] = maprequest,
168 [PropertyNotify] = propertynotify,
169 [UnmapNotify] = unmapnotify
170};
171Atom wmatom[WMLast], netatom[NetLast];
172Bool otherwm, readin;
173Bool running = True;
174Bool selscreen = True;
175Client *clients = NULL;
176Client *sel = NULL;
177Client *stack = NULL;
178Cursor cursor[CurLast];
179Display *dpy;
180DC dc = {0};
181Window barwin, root;
182Regs *regs = NULL;
183
184/* configuration, allows nested code to access above variables */
185#include "config.h"
186
187/* Statically define the number of tags. */
188unsigned int ntags = sizeof tags / sizeof tags[0];
189Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
190Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};
191