all repos — dwm @ 0a673ad7a37f3a1bdda7cef316bda300f8f181eb

my dwm build

continued, distinction of Draw and DDC is bad, needs to be merged
anselm@garbe.us unknown
Sun, 18 Nov 2012 17:26:12 +0100
commit

0a673ad7a37f3a1bdda7cef316bda300f8f181eb

parent

3aabc08ede9c6496720124be8ee34c8b39735239

2 files changed, 14 insertions(+), 7 deletions(-)

jump to
M draw.cdraw.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 @@ if(!draw)

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); }
M draw.hdraw.h

@@ -7,6 +7,8 @@ typedef struct _XDraw Draw;

struct _XDraw { unsigned int w, h; Display *dpy; + int screen; + Window win; Drawable drawable; GC gc; DDC *dc;

@@ -46,7 +48,7 @@ int yOff;

} TextExtents; /* Drawable abstraction */ -Draw *draw_create(Display *dpy, Window win, unsigned int w, unsigned int h); +Draw *draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); void draw_resize(Draw *draw, unsigned int w, unsigned int h); void draw_free(Draw *draw);