Replaced XDrawLines with XDrawRectangles... let's see if anything breaks (+ some cleanups)

This commit is contained in:
Kris Maglione 2007-02-05 04:38:32 -05:00
parent 1b2966fb38
commit 88d43166f6
3 changed files with 20 additions and 28 deletions

21
draw.c
View File

@ -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

25
frame.c
View File

@ -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 @@ draw_frames() {
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;
}

2
wmii.h
View File

@ -301,7 +301,7 @@ extern void draw_tile(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);