changeset: 8:ce2c92388d3a
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Thu Aug 05 15:41:47 2010 +0100
files: Makefile draw.h drawrect.c setcanvas.c
description:
simpler setcanvas
diff -r c599c675c202 -r ce2c92388d3a Makefile
--- a/Makefile Mon Aug 02 14:22:14 2010 +0100
+++ b/Makefile Thu Aug 05 15:41:47 2010 +0100
@@ -24,7 +24,7 @@
libdraw.a: ${OBJ}
@echo AR $@
@rm -f $@
- @ar cr $@ $+
+ @ar rc $@ $+
clean:
@echo cleaning
diff -r c599c675c202 -r ce2c92388d3a draw.h
--- a/draw.h Mon Aug 02 14:22:14 2010 +0100
+++ b/draw.h Thu Aug 05 15:41:47 2010 +0100
@@ -29,7 +29,7 @@
/* forward declarations */
void commitdraw(DC *dc, Window w);
-void drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, unsigned long col);
+void drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, unsigned long color);
void drawtext(DC *dc, const char *text, unsigned long col[ColLast]);
void drawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]);
void eprintf(const char *fmt, ...);
@@ -37,7 +37,7 @@
unsigned long getcolor(DC *dc, const char *colstr);
DC *initdraw(void);
void initfont(DC *dc, const char *fontstr);
-void setcanvas(DC *dc, Window win, unsigned int w, unsigned int h);
+void setcanvas(DC *dc, unsigned int w, unsigned int h);
int textnw(DC *dc, const char *text, size_t len);
int textw(DC *dc, const char *text);
void weprintf(const char *fmt, ...);
diff -r c599c675c202 -r ce2c92388d3a drawrect.c
--- a/drawrect.c Mon Aug 02 14:22:14 2010 +0100
+++ b/drawrect.c Thu Aug 05 15:41:47 2010 +0100
@@ -3,10 +3,10 @@
#include "draw.h"
void
-drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, unsigned long col)
+drawrect(DC *dc, int x, int y, unsigned int w, unsigned int h, unsigned long color)
{
XRectangle r = { dc->x + x, dc->y + y, w, h };
- XSetForeground(dc->dpy, dc->gc, col);
+ XSetForeground(dc->dpy, dc->gc, color);
XFillRectangles(dc->dpy, dc->canvas, dc->gc, &r, 1);
}
diff -r c599c675c202 -r ce2c92388d3a setcanvas.c
--- a/setcanvas.c Mon Aug 02 14:22:14 2010 +0100
+++ b/setcanvas.c Thu Aug 05 15:41:47 2010 +0100
@@ -3,10 +3,14 @@
#include "draw.h"
void
-setcanvas(DC *dc, Window win, unsigned int w, unsigned int h) {
- dc->canvas = XCreatePixmap(dc->dpy, win, w, h,
- DefaultDepth(dc->dpy, DefaultScreen(dc->dpy)));
- dc->gc = XCreateGC(dc->dpy, win, 0, NULL);
+setcanvas(DC *dc, unsigned int w, unsigned int h) {
+ int screen;
+ Window root;
+
+ screen = DefaultScreen(dc->dpy);
+ root = RootWindow(dc->dpy, screen);
+ dc->canvas = XCreatePixmap(dc->dpy, root, w, h, DefaultDepth(dc->dpy, screen));
+ dc->gc = XCreateGC(dc->dpy, root, 0, NULL);
XSetLineAttributes(dc->dpy, dc->gc, 1, LineSolid, CapButt, JoinMiter);
dc->x = dc->y = 0;
Received on Thu Aug 05 2010 - 16:42:01 CEST
This archive was generated by hypermail 2.2.0 : Thu Aug 05 2010 - 16:48:04 CEST