summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--draw.h76
-rw-r--r--dwm.c2
2 files changed, 78 insertions, 0 deletions
diff --git a/draw.h b/draw.h
new file mode 100644
index 0000000..955067d
--- /dev/null
+++ b/draw.h
@@ -0,0 +1,76 @@
1/* See LICENSE file for copyright and license details. */
2
3/* X11 types - begin */
4struct _XDraw {
5 unsigned int w, h;
6 Display *dpy;
7 Drawable drawable;
8 GC gc;
9};
10typedef struct _XDraw Draw;
11
12struct _XCol {
13 unsigned long rgb;
14};
15typedef struct _XCol Col;
16
17struct _XFont {
18 int ascent;
19 int descent;
20 unsigned int h, w;
21 XFontSet set;
22 XFontStruct *xfont;
23};
24typedef struct _XFont Fnt;
25/* X11 types - end */
26
27typedef struct {
28 Draw *draw;
29 Col *fg;
30 Col *bg;
31 Fnt *font;
32 Bool fill;
33} DDC;
34
35typedef struct {
36 unsigned int w;
37 unsigned int h;
38 int x;
39 int y;
40 int xOff;
41 int yOff;
42} TextExtents;
43
44/* Drawable abstraction */
45Draw *draw_create(Display *dpy, Window win, unsigned int w, unsigned int h);
46void draw_resize(Draw *draw, unsigned int w, unsigned int h);
47void draw_free(Draw *draw);
48
49/* Drawing context abstraction */
50DDC *dc_create(Draw *draw);
51void dc_free(DDC *dc);
52
53/* Fnt abstraction */
54Fnt *font_create(const char *fontname);
55void font_free(Fnt *font);
56
57/* Colour abstraction */
58Col *col_create(const char *colname);
59void col_free(Col *col);
60
61/* Drawing context manipulation */
62void dc_setfont(DDC *dc, Fnt *font);
63void dc_setfg(DDC *dc, Col col);
64void dc_setbg(DDC *dc, Col col);
65void dc_setfill(DDC *dc, Bool fill);
66
67/* Drawing functions */
68void dc_drawrect(DDC *dc, int x, int y, unsigned int w, unsigned int h);
69void dc_drawtext(DDC *dc, int x, int y, const char *text);
70
71/* Map functions */
72void dc_map(DDC *dc, int x, int y, unsigned int w, unsigned int h);
73
74/* Text functions */
75void dc_getextents(DDC *dc, const char *text, TextExtents *extents);
76
diff --git a/dwm.c b/dwm.c
index 4986b07..95b0a7e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -43,6 +43,8 @@
43#include <X11/extensions/Xinerama.h> 43#include <X11/extensions/Xinerama.h>
44#endif /* XINERAMA */ 44#endif /* XINERAMA */
45 45
46#include "draw.h"
47
46/* macros */ 48/* macros */
47#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) 49#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
48#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) 50#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))