aboutsummaryrefslogtreecommitdiffstats
path: root/draw.c
diff options
context:
space:
mode:
authoranselm@garbe.us <unknown>2012-11-18 17:26:12 +0100
committeranselm@garbe.us <unknown>2012-11-18 17:26:12 +0100
commit0a673ad7a37f3a1bdda7cef316bda300f8f181eb (patch)
treebe4cfdbd6569b0999f4d68fa07db04bdef87934a /draw.c
parent3aabc08ede9c6496720124be8ee34c8b39735239 (diff)
downloaddwm-0a673ad7a37f3a1bdda7cef316bda300f8f181eb.tar.gz
continued, distinction of Draw and DDC is bad, needs to be merged
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/draw.c b/draw.c
index 04e7f0d..df5aeec 100644
--- a/draw.c
+++ b/draw.c
@@ -5,12 +5,16 @@
#include "draw.h"
Draw *
-draw_create(Display *dpy, Window win, unsigned int w, unsigned int h) {
+draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h) {
Draw *draw = (Draw *)calloc(1, sizeof(Draw));
+ draw->dpy = dpy;
+ draw->screen = screen;
+ draw->win = win;
draw->w = w;
draw->h = h;
- /* TODO: drawable creation */
- /* TODO: gc allocation */
+ draw->drawable = XCreatePixmap(dpy, win, w, h, DefaultDepth(dpy, screen));
+ draw->gc = XCreateGC(dpy, win, 0, NULL);
+ XSetLineAttributes(dpy, draw->gc, 1, LineSolid, CapButt, JoinMiter);
return draw;
}
@@ -20,13 +24,14 @@ draw_resize(Draw *draw, unsigned int w, unsigned int h) {
return;
draw->w = w;
draw->h = h;
- /* TODO: resize drawable */
+ XFreePixmap(draw->dpy, draw->drawable);
+ draw->drawable = XCreatePixmap(draw->dpy, draw->win, w, h, DefaultDepth(draw->dpy, draw->screen));
}
void
draw_free(Draw *draw) {
- /* TODO: deallocate DDCs */
- /* TODO: deallocate drawable */
+ XFreePixmap(draw->dpy, draw->drawable);
+ XFreeGC(draw->dpy, draw->gc);
free(draw);
}
remember that computers suck.