[hackers] wmii: new tip (= 1743)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Mon, 05 Feb 2007 10:40:06 +0100

changeset: 1743:bc3b7b5021ed
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Mon Feb 05 04:38:32 2007 -0500
files: draw.c frame.c wmii.h
description:
Replaced XDrawLines with XDrawRectangles... let's see if anything breaks (+ some cleanups)

diff -r f55eda8b5c24 -r bc3b7b5021ed draw.c
--- a/draw.c Mon Feb 05 02:45:51 2007 -0500
+++ b/draw.c Mon Feb 05 04:38:32 2007 -0500
@@ -73,13 +73,13 @@ labelh(BlitzFont *font) {
 
 void
 draw_tile(BlitzBrush *b) {
- drawbg(b->blitz->dpy, b->drawable, b->gc, b->rect,
+ drawbg(b->blitz->dpy, b->drawable, b->gc, &b->rect,
                         b->color, True, b->border);
 }
 
 void
 draw_border(BlitzBrush *b) {
- drawbg(b->blitz->dpy, b->drawable, b->gc, b->rect,
+ drawbg(b->blitz->dpy, b->drawable, b->gc, &b->rect,
                         b->color, False, True);
 }
 
@@ -137,29 +137,18 @@ draw_label(BlitzBrush *b, char *text) {
 }
 
 void
-drawbg(Display *dpy, Drawable drawable, GC gc, XRectangle rect,
+drawbg(Display *dpy, Drawable drawable, GC gc, XRectangle *rect,
                         BlitzColor c, Bool fill, Bool border)
 {
- XPoint points[5];
         if(fill) {
                 XSetForeground(dpy, gc, c.bg);
- XFillRectangles(dpy, drawable, gc, &rect, 1);
+ XFillRectangles(dpy, drawable, gc, rect, 1);
         }
         if(!border)
                 return;
         XSetLineAttributes(dpy, gc, 1, LineSolid, CapButt, JoinMiter);
         XSetForeground(dpy, gc, c.border);
- points[0].x = rect.x;
- points[0].y = rect.y;
- points[1].x = rect.width - 1;
- points[1].y = 0;
- points[2].x = 0;
- points[2].y = rect.height - 1;
- points[3].x = -(rect.width - 1);
- points[3].y = 0;
- points[4].x = 0;
- points[4].y = -(rect.height - 1);
- XDrawLines(dpy, drawable, gc, points, 5, CoordModePrevious);
+ XDrawRectangles(dpy, drawable, gc, rect, 1);
 }
 
 void
diff -r f55eda8b5c24 -r bc3b7b5021ed frame.c
--- a/frame.c Mon Feb 05 02:45:51 2007 -0500
+++ b/frame.c Mon Feb 05 04:38:32 2007 -0500
@@ -69,10 +69,10 @@ swap_frames(Frame *fa, Frame *fb) {
         if(fa == fb) return;
 
         a = fa->area;
- for(fp_a = &a->frame; *fp_a; fp_a=&(*fp_a)->anext)
+ for(fp_a = &a->frame; *fp_a; fp_a = &(*fp_a)->anext)
                 if(*fp_a == fa) break;
         a = fb->area;
- for(fp_b = &a->frame; *fp_b; fp_b=&(*fp_b)->anext)
+ for(fp_b = &a->frame; *fp_b; fp_b = &(*fp_b)->anext)
                 if(*fp_b == fb) break;
 
         if(fa->anext == fb) {
@@ -146,18 +146,21 @@ void
 void
 check_frame_constraints(XRectangle *rect) {
         int max_height;
- max_height = screen->rect.height - labelh(&def.font);
+ int barheight;
+
+ barheight = screen->brect.height;
+ max_height = screen->rect.height - barheight;
 
         if(rect->height > max_height)
                 rect->height = max_height;
         if(rect->width > screen->rect.width)
                 rect->width = screen->rect.width;
- if(rect->x + screen->brect.height > screen->rect.width)
- rect->x = screen->rect.width - screen->brect.height;
- if(rect->y + screen->brect.height > max_height)
- rect->y = max_height - screen->brect.height;
- if(rect->x + rect->width < screen->brect.height)
- rect->x = screen->brect.height - rect->width;
- if(rect->y + rect->height < screen->brect.height)
- rect->y = screen->brect.height - rect->height;
+ if(rect->x + barheight > screen->rect.width)
+ rect->x = screen->rect.width - barheight;
+ if(rect->y + barheight > max_height)
+ rect->y = max_height - barheight;
+ if(rect->x + rect->width < barheight)
+ rect->x = barheight - rect->width;
+ if(rect->y + rect->height < barheight)
+ rect->y = barheight - rect->height;
 }
diff -r f55eda8b5c24 -r bc3b7b5021ed wmii.h
--- a/wmii.h Mon Feb 05 02:45:51 2007 -0500
+++ b/wmii.h Mon Feb 05 04:38:32 2007 -0500
@@ -301,7 +301,7 @@ extern void draw_rect(BlitzBrush *b);
 extern void draw_rect(BlitzBrush *b);
 
 extern void drawbg(Display *dpy, Drawable drawable, GC gc,
- XRectangle rect, BlitzColor c, Bool fill, Bool border);
+ XRectangle *rect, BlitzColor c, Bool fill, Bool border);
 extern void drawcursor(Display *dpy, Drawable drawable, GC gc,
                                 int x, int y, unsigned int h, BlitzColor c);
 extern unsigned int textwidth(BlitzFont *font, char *text);
Received on Mon Feb 05 2007 - 10:40:06 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:53 UTC