[hackers] [dwm] continued, distinction of Draw and DDC is bad, needs to be merged || anselm

From: <hg_AT_suckless.org>
Date: Sun, 18 Nov 2012 17:26:02 +0100 (CET)

changeset: 1614:efb9cbffcc19
tag: tip
user: anselm_AT_garbe.us
date: Sun Nov 18 17:26:12 2012 +0100
files: draw.c draw.h
description:
continued, distinction of Draw and DDC is bad, needs to be merged


diff -r 82c9ae7c1c4b -r efb9cbffcc19 draw.c
--- a/draw.c Sun Nov 18 16:39:56 2012 +0100
+++ b/draw.c Sun Nov 18 17:26:12 2012 +0100
_AT_@ -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;
 }
 
_AT_@ -20,13 +24,14 @@
                 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);
 }
 
diff -r 82c9ae7c1c4b -r efb9cbffcc19 draw.h
--- a/draw.h Sun Nov 18 16:39:56 2012 +0100
+++ b/draw.h Sun Nov 18 17:26:12 2012 +0100
_AT_@ -7,6 +7,8 @@
 struct _XDraw {
         unsigned int w, h;
         Display *dpy;
+ int screen;
+ Window win;
         Drawable drawable;
         GC gc;
         DDC *dc;
_AT_@ -46,7 +48,7 @@
 } 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);
 
Received on Sun Nov 18 2012 - 17:26:02 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 18 2012 - 17:36:08 CET