about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorarg@suckless.org <unknown>2007-10-18 10:28:41 +0200
committerarg@suckless.org <unknown>2007-10-18 10:28:41 +0200
commitcd7ebaad25fa5f10a4442f9d80a05f344ca271d3 (patch)
tree22e97b3a40c446855927b6744fbdf081d8de289d
parent8dc03d6e6be7092f9f5595e03295efc2488f65b9 (diff)
downloaddwm-cd7ebaad25fa5f10a4442f9d80a05f344ca271d3.tar.gz
removed dwm.h, just include C-files in config.h if you extend dwm, that's simplier and most flexible than all other possibilities
-rw-r--r--Makefile4
-rw-r--r--dwm.c190
-rw-r--r--dwm.h190
3 files changed, 190 insertions, 194 deletions
diff --git a/Makefile b/Makefile
index 1dde4b2..7c65e6f 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 
 include config.mk
 
-SRC += dwm.c
+SRC = dwm.c
 OBJ = ${SRC:.c=.o}
 
 all: options dwm
@@ -35,7 +35,7 @@ clean:
 dist: clean
 	@echo creating dist tarball
 	@mkdir -p dwm-${VERSION}
-	@cp -R LICENSE Makefile README config.def.h config.mk dwm.h \
+	@cp -R LICENSE Makefile README config.def.h config.mk \
 		dwm.1 ${SRC} dwm-${VERSION}
 	@tar -cf dwm-${VERSION}.tar dwm-${VERSION}
 	@gzip dwm-${VERSION}.tar
diff --git a/dwm.c b/dwm.c
index 8f5ed6d..99920d0 100644
--- a/dwm.c
+++ b/dwm.c
@@ -43,13 +43,199 @@
 #include <X11/Xproto.h>
 #include <X11/Xutil.h>
 
-#include "dwm.h"
-
 /* macros */
 #define BUTTONMASK		(ButtonPressMask | ButtonReleaseMask)
 #define CLEANMASK(mask)		(mask & ~(numlockmask | LockMask))
 #define MOUSEMASK		(BUTTONMASK | PointerMotionMask)
 
+/* enums */
+enum { BarTop, BarBot, BarOff };			/* bar position */
+enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
+enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
+enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
+enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
+
+/* typedefs */
+typedef struct Client Client;
+struct Client {
+	char name[256];
+	int x, y, w, h;
+	int rx, ry, rw, rh; /* revert geometry */
+	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+	int minax, maxax, minay, maxay;
+	long flags;
+	unsigned int border, oldborder;
+	Bool isbanned, isfixed, ismax, isfloating, wasfloating;
+	Bool *tags;
+	Client *next;
+	Client *prev;
+	Client *snext;
+	Window win;
+};
+
+typedef struct {
+	int x, y, w, h;
+	unsigned long norm[ColLast];
+	unsigned long sel[ColLast];
+	Drawable drawable;
+	GC gc;
+	struct {
+		int ascent;
+		int descent;
+		int height;
+		XFontSet set;
+		XFontStruct *xfont;
+	} font;
+} DC; /* draw context */
+
+typedef struct {
+	unsigned long mod;
+	KeySym keysym;
+	void (*func)(const char *arg);
+	const char *arg;
+} Key;
+
+typedef struct {
+	const char *symbol;
+	void (*arrange)(void);
+} Layout;
+
+typedef struct {
+	const char *prop;
+	const char *tags;
+	Bool isfloating;
+} Rule;
+
+typedef struct {
+	regex_t *propregex;
+	regex_t *tagregex;
+} Regs;
+
+/* functions */
+void applyrules(Client *c);
+void arrange(void);
+void attach(Client *c);
+void attachstack(Client *c);
+void ban(Client *c);
+void buttonpress(XEvent *e);
+void checkotherwm(void);
+void cleanup(void);
+void compileregs(void);
+void configure(Client *c);
+void configurenotify(XEvent *e);
+void configurerequest(XEvent *e);
+void destroynotify(XEvent *e);
+void detach(Client *c);
+void detachstack(Client *c);
+void drawbar(void);
+void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
+void drawtext(const char *text, unsigned long col[ColLast]);
+void *emallocz(unsigned int size);
+void enternotify(XEvent *e);
+void eprint(const char *errstr, ...);
+void expose(XEvent *e);
+void floating(void); /* default floating layout */
+void focus(Client *c);
+void focusnext(const char *arg);
+void focusprev(const char *arg);
+Client *getclient(Window w);
+unsigned long getcolor(const char *colstr);
+long getstate(Window w);
+Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
+void grabbuttons(Client *c, Bool focused);
+unsigned int idxoftag(const char *tag);
+void initfont(const char *fontstr);
+Bool isarrange(void (*func)());
+Bool isoccupied(unsigned int t);
+Bool isprotodel(Client *c);
+Bool isvisible(Client *c);
+void keypress(XEvent *e);
+void killclient(const char *arg);
+void leavenotify(XEvent *e);
+void manage(Window w, XWindowAttributes *wa);
+void mappingnotify(XEvent *e);
+void maprequest(XEvent *e);
+void movemouse(Client *c);
+Client *nexttiled(Client *c);
+void propertynotify(XEvent *e);
+void quit(const char *arg);
+void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
+void resizemouse(Client *c);
+void restack(void);
+void run(void);
+void scan(void);
+void setclientstate(Client *c, long state);
+void setlayout(const char *arg);
+void setmwfact(const char *arg);
+void setup(void);
+void spawn(const char *arg);
+void tag(const char *arg);
+unsigned int textnw(const char *text, unsigned int len);
+unsigned int textw(const char *text);
+void tile(void);
+void togglebar(const char *arg);
+void togglefloating(const char *arg);
+void togglemax(const char *arg);
+void toggletag(const char *arg);
+void toggleview(const char *arg);
+void unban(Client *c);
+void unmanage(Client *c);
+void unmapnotify(XEvent *e);
+void updatebarpos(void);
+void updatesizehints(Client *c);
+void updatetitle(Client *c);
+void view(const char *arg);
+void viewprevtag(const char *arg);	/* views previous selected tags */
+int xerror(Display *dpy, XErrorEvent *ee);
+int xerrordummy(Display *dsply, XErrorEvent *ee);
+int xerrorstart(Display *dsply, XErrorEvent *ee);
+void zoom(const char *arg);
+
+/* variables */
+char stext[256];
+double mwfact;
+int screen, sx, sy, sw, sh, wax, way, waw, wah;
+int (*xerrorxlib)(Display *, XErrorEvent *);
+unsigned int bh, bpos;
+unsigned int blw = 0;
+unsigned int ltidx = 0; /* default */
+unsigned int nlayouts = 0;
+unsigned int nrules = 0;
+unsigned int numlockmask = 0;
+void (*handler[LASTEvent]) (XEvent *) = {
+	[ButtonPress] = buttonpress,
+	[ConfigureRequest] = configurerequest,
+	[ConfigureNotify] = configurenotify,
+	[DestroyNotify] = destroynotify,
+	[EnterNotify] = enternotify,
+	[LeaveNotify] = leavenotify,
+	[Expose] = expose,
+	[KeyPress] = keypress,
+	[MappingNotify] = mappingnotify,
+	[MapRequest] = maprequest,
+	[PropertyNotify] = propertynotify,
+	[UnmapNotify] = unmapnotify
+};
+Atom wmatom[WMLast], netatom[NetLast];
+Bool otherwm, readin;
+Bool running = True;
+Bool selscreen = True;
+Client *clients = NULL;
+Client *sel = NULL;
+Client *stack = NULL;
+Cursor cursor[CurLast];
+Display *dpy;
+DC dc = {0};
+Window barwin, root;
+Regs *regs = NULL;
+
+/* configuration, allows nested code to access above variables */
+#include "config.h"
+
+/* statically define the number of tags. */
+unsigned int ntags = sizeof tags / sizeof tags[0];
+Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
+Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};
 void
 applyrules(Client *c) {
 	static char buf[512];
diff --git a/dwm.h b/dwm.h
deleted file mode 100644
index 94dbd8c..0000000
--- a/dwm.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-
-/* enums */
-enum { BarTop, BarBot, BarOff };			/* bar position */
-enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
-enum { ColBorder, ColFG, ColBG, ColLast };		/* color */
-enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
-enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
-
-/* typedefs */
-typedef struct Client Client;
-struct Client {
-	char name[256];
-	int x, y, w, h;
-	int rx, ry, rw, rh; /* revert geometry */
-	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
-	int minax, maxax, minay, maxay;
-	long flags;
-	unsigned int border, oldborder;
-	Bool isbanned, isfixed, ismax, isfloating, wasfloating;
-	Bool *tags;
-	Client *next;
-	Client *prev;
-	Client *snext;
-	Window win;
-};
-
-typedef struct {
-	int x, y, w, h;
-	unsigned long norm[ColLast];
-	unsigned long sel[ColLast];
-	Drawable drawable;
-	GC gc;
-	struct {
-		int ascent;
-		int descent;
-		int height;
-		XFontSet set;
-		XFontStruct *xfont;
-	} font;
-} DC; /* draw context */
-
-typedef struct {
-	unsigned long mod;
-	KeySym keysym;
-	void (*func)(const char *arg);
-	const char *arg;
-} Key;
-
-typedef struct {
-	const char *symbol;
-	void (*arrange)(void);
-} Layout;
-
-typedef struct {
-	const char *prop;
-	const char *tags;
-	Bool isfloating;
-} Rule;
-
-typedef struct {
-	regex_t *propregex;
-	regex_t *tagregex;
-} Regs;
-
-/* functions */
-void applyrules(Client *c);
-void arrange(void);
-void attach(Client *c);
-void attachstack(Client *c);
-void ban(Client *c);
-void buttonpress(XEvent *e);
-void checkotherwm(void);
-void cleanup(void);
-void compileregs(void);
-void configure(Client *c);
-void configurenotify(XEvent *e);
-void configurerequest(XEvent *e);
-void destroynotify(XEvent *e);
-void detach(Client *c);
-void detachstack(Client *c);
-void drawbar(void);
-void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
-void drawtext(const char *text, unsigned long col[ColLast]);
-void *emallocz(unsigned int size);
-void enternotify(XEvent *e);
-void eprint(const char *errstr, ...);
-void expose(XEvent *e);
-void floating(void); /* default floating layout */
-void focus(Client *c);
-void focusnext(const char *arg);
-void focusprev(const char *arg);
-Client *getclient(Window w);
-unsigned long getcolor(const char *colstr);
-long getstate(Window w);
-Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
-void grabbuttons(Client *c, Bool focused);
-unsigned int idxoftag(const char *tag);
-void initfont(const char *fontstr);
-Bool isarrange(void (*func)());
-Bool isoccupied(unsigned int t);
-Bool isprotodel(Client *c);
-Bool isvisible(Client *c);
-void keypress(XEvent *e);
-void killclient(const char *arg);
-void leavenotify(XEvent *e);
-void manage(Window w, XWindowAttributes *wa);
-void mappingnotify(XEvent *e);
-void maprequest(XEvent *e);
-void movemouse(Client *c);
-Client *nexttiled(Client *c);
-void propertynotify(XEvent *e);
-void quit(const char *arg);
-void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
-void resizemouse(Client *c);
-void restack(void);
-void run(void);
-void scan(void);
-void setclientstate(Client *c, long state);
-void setlayout(const char *arg);
-void setmwfact(const char *arg);
-void setup(void);
-void spawn(const char *arg);
-void tag(const char *arg);
-unsigned int textnw(const char *text, unsigned int len);
-unsigned int textw(const char *text);
-void tile(void);
-void togglebar(const char *arg);
-void togglefloating(const char *arg);
-void togglemax(const char *arg);
-void toggletag(const char *arg);
-void toggleview(const char *arg);
-void unban(Client *c);
-void unmanage(Client *c);
-void unmapnotify(XEvent *e);
-void updatebarpos(void);
-void updatesizehints(Client *c);
-void updatetitle(Client *c);
-void view(const char *arg);
-void viewprevtag(const char *arg);	/* views previous selected tags */
-int xerror(Display *dpy, XErrorEvent *ee);
-int xerrordummy(Display *dsply, XErrorEvent *ee);
-int xerrorstart(Display *dsply, XErrorEvent *ee);
-void zoom(const char *arg);
-
-/* variables */
-char stext[256];
-double mwfact;
-int screen, sx, sy, sw, sh, wax, way, waw, wah;
-int (*xerrorxlib)(Display *, XErrorEvent *);
-unsigned int bh, bpos;
-unsigned int blw = 0;
-unsigned int ltidx = 0; /* default */
-unsigned int nlayouts = 0;
-unsigned int nrules = 0;
-unsigned int numlockmask = 0;
-void (*handler[LASTEvent]) (XEvent *) = {
-	[ButtonPress] = buttonpress,
-	[ConfigureRequest] = configurerequest,
-	[ConfigureNotify] = configurenotify,
-	[DestroyNotify] = destroynotify,
-	[EnterNotify] = enternotify,
-	[LeaveNotify] = leavenotify,
-	[Expose] = expose,
-	[KeyPress] = keypress,
-	[MappingNotify] = mappingnotify,
-	[MapRequest] = maprequest,
-	[PropertyNotify] = propertynotify,
-	[UnmapNotify] = unmapnotify
-};
-Atom wmatom[WMLast], netatom[NetLast];
-Bool otherwm, readin;
-Bool running = True;
-Bool selscreen = True;
-Client *clients = NULL;
-Client *sel = NULL;
-Client *stack = NULL;
-Cursor cursor[CurLast];
-Display *dpy;
-DC dc = {0};
-Window barwin, root;
-Regs *regs = NULL;
-
-/* configuration, allows nested code to access above variables */
-#include "config.h"
-
-/* statically define the number of tags. */
-unsigned int ntags = sizeof tags / sizeof tags[0];
-Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
-Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};
a id='n201' href='#n201'>201 202 203 204 205 206 207 208 209 210 211 212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727