changeset: 2082:f8cc207478c3
user: Kris Maglione <jg_AT_suckless.org>
date: Mon Apr 16 14:51:24 2007 -0400
summary: Some updates to divider drawing.
diff -r b358a8133947 -r f8cc207478c3 cmd/wmii/column.c
--- a/cmd/wmii/column.c Mon Apr 16 14:06:32 2007 -0400
+++ b/cmd/wmii/column.c Mon Apr 16 14:51:24 2007 -0400
@@ -10,9 +10,8 @@
#include "dat.h"
#include "fns.h"
-int divw, divh;
-GC divgc;
-GC maskgc;
+static Image *divimg, *divmask;
+static CTuple divc;
char *modes[] = {
[Coldefault] = "default",
@@ -37,43 +36,6 @@ str2colmode(const char *str) {
if(!strcasecmp(str, modes[i]))
return i;
return -1;
-}
-
-static void
-draw_pmap(Image *img, ulong cbg, ulong cborder) {
- Point pt[6];
-
- pt[0] = Pt(0, 0);
- pt[1] = Pt(divw/2 - 1, divw/2 - 1);
-
- pt[2] = Pt(pt[1].x, divh);
- pt[3] = Pt(divw/2, pt[2].y);
-
- pt[4] = Pt(pt[3].x, divw/2 - 1);
- pt[5] = Pt(divw - 1, 0);
-
- fillpoly(img, pt, nelem(pt), cbg);
- drawpoly(img, pt, nelem(pt), CapNotLast, 1, cborder);
-}
-
-void
-update_dividers() {
- if(divimg) {
- freeimage(divimg);
- freeimage(divmask);
- }
-
- divw = 2 * (labelh(def.font) / 3);
- divw = max(divw, 10);
- divh = Dy(screen->rect);
-
- divimg = allocimage(divw, divh, scr.depth);
- divmask = allocimage(divw, divh, 1);
-
- fill(divmask, divmask->r, 0);
-
- draw_pmap(divimg, def.normcolor.bg, def.normcolor.border);
- draw_pmap(divmask, 1, 1);
}
static Divide*
@@ -117,11 +79,53 @@ setdiv(Divide *d, int x) {
Rectangle r;
d->x = x;
- r = rectaddpt(divimg->r, Pt(x - divw/2, 0));
+ r = rectaddpt(divimg->r, Pt(x - Dx(divimg->r)/2, 0));
r.max.y = screen->brect.min.y;
reshapewin(d->w, r);
map_div(d);
+}
+
+static void
+draw_img(Image *img, ulong cbg, ulong cborder) {
+ Point pt[6];
+
+ pt[0] = Pt(0, 0);
+ pt[1] = Pt(Dx(img->r)/2 - 1, Dx(img->r)/2 - 1);
+
+ pt[2] = Pt(pt[1].x, Dy(img->r));
+ pt[3] = Pt(Dx(img->r)/2, pt[2].y);
+
+ pt[4] = Pt(pt[3].x, Dx(img->r)/2 - 1);
+ pt[5] = Pt(Dx(img->r) - 1, 0);
+
+ fillpoly(img, pt, nelem(pt), cbg);
+ drawpoly(img, pt, nelem(pt), CapNotLast, 1, cborder);
+}
+
+void
+update_imgs() {
+ int w, h;
+
+ w = 2 * (labelh(def.font) / 3);
+ w = max(w, 10);
+ h = Dy(screen->rect);
+
+ if(divimg) {
+ if(w == Dx(divimg->r) && h == Dy(divimg->r)
+ && !memcmp(&divc, &def.normcolor, sizeof(divc)))
+ return;
+ freeimage(divimg);
+ freeimage(divmask);
+ }
+
+ divimg = allocimage(w, h, scr.depth);
+ divmask = allocimage(w, h, 1);
+ divc = def.normcolor;
+
+ fill(divmask, divmask->r, 0);
+ draw_img(divmask, 1, 1);
+ draw_img(divimg, divc.bg, divc.border);
}
void
@@ -130,7 +134,7 @@ update_divs() {
Area *a;
View *v;
- update_dividers();
+ update_imgs();
v = screen->sel;
dp = &divs;
diff -r b358a8133947 -r f8cc207478c3 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Mon Apr 16 14:06:32 2007 -0400
+++ b/cmd/wmii/dat.h Mon Apr 16 14:51:24 2007 -0400
@@ -224,7 +224,6 @@ Bool sel_screen;
Bool sel_screen;
Image xor;
-Image *divimg, *divmask;
Atom atom[AtomLast];
Cursor cursor[CurLast];
diff -r b358a8133947 -r f8cc207478c3 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Mon Apr 16 14:06:32 2007 -0400
+++ b/cmd/wmii/fns.h Mon Apr 16 14:51:24 2007 -0400
@@ -55,7 +55,6 @@ void apply_tags(Client*, const char*);
/* column.c */
Divide *win2div(XWindow);
-void update_dividers();
void update_divs();
void draw_div(Divide*);
void arrange_column(Area*, Bool dirty);
Received on Fri Jun 01 2007 - 03:09:11 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:54 UTC