|
|
@ -5,12 +5,16 @@ |
|
|
|
#include "draw.h" |
|
|
|
#include "draw.h" |
|
|
|
|
|
|
|
|
|
|
|
Draw * |
|
|
|
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 *draw = (Draw *)calloc(1, sizeof(Draw)); |
|
|
|
|
|
|
|
draw->dpy = dpy; |
|
|
|
|
|
|
|
draw->screen = screen; |
|
|
|
|
|
|
|
draw->win = win; |
|
|
|
draw->w = w; |
|
|
|
draw->w = w; |
|
|
|
draw->h = h; |
|
|
|
draw->h = h; |
|
|
|
/* TODO: drawable creation */ |
|
|
|
draw->drawable = XCreatePixmap(dpy, win, w, h, DefaultDepth(dpy, screen)); |
|
|
|
/* TODO: gc allocation */ |
|
|
|
draw->gc = XCreateGC(dpy, win, 0, NULL); |
|
|
|
|
|
|
|
XSetLineAttributes(dpy, draw->gc, 1, LineSolid, CapButt, JoinMiter); |
|
|
|
return draw; |
|
|
|
return draw; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -20,13 +24,14 @@ draw_resize(Draw *draw, unsigned int w, unsigned int h) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
draw->w = w; |
|
|
|
draw->w = w; |
|
|
|
draw->h = h; |
|
|
|
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 |
|
|
|
void |
|
|
|
draw_free(Draw *draw) { |
|
|
|
draw_free(Draw *draw) { |
|
|
|
/* TODO: deallocate DDCs */ |
|
|
|
XFreePixmap(draw->dpy, draw->drawable); |
|
|
|
/* TODO: deallocate drawable */ |
|
|
|
XFreeGC(draw->dpy, draw->gc); |
|
|
|
free(draw); |
|
|
|
free(draw); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|