[hackers] [wmii] Cleanup. Experiment with a new dragbox design.

From: Kris Maglione <jg_AT_suckless.org>
Date: Mon Feb 12 05:26:39 2007

changeset: 1850:51442e2e67fc
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sun Feb 11 23:24:11 2007 -0500
summary: Cleanup. Experiment with a new dragbox design.

diff -r 51a8198adb08 -r 51442e2e67fc area.c
--- a/area.c Sun Feb 11 22:17:20 2007 -0500
+++ b/area.c Sun Feb 11 23:24:11 2007 -0500
@@ -260,8 +260,8 @@ place_client(Area *a, Client *c) {
                         y = 0;
                 else
                         y = fr->rect.y / dy;
- maxx = (fr->rect.x + fr->rect.width) / dx;
- maxy = (fr->rect.y + fr->rect.height) / dy;
+ maxx = r_east(&fr->rect) / dx;
+ maxy = r_south(&fr->rect) / dy;
                 for(j = y; j < my && j < maxy; j++)
                         for(i = x; i < mx && i < maxx; i++)
                                 field[j*mx + i] = False;
@@ -286,13 +286,13 @@ place_client(Area *a, Client *c) {
                 p1.x *= dx;
                 p1.y *= dy;
         }
- if(fit && (p1.x + f->rect.width < a->rect.x + a->rect.width))
+ if(fit && (p1.x + f->rect.width < r_south(&a->rect)))
                 f->rect.x = p1.x;
         else {
                 diff = a->rect.width - f->rect.width;
                 f->rect.x = a->rect.x + (random() % (diff ? diff : 1));
         }
- if(fit && (p1.y + f->rect.height < a->rect.y + a->rect.height))
+ if(fit && (p1.y + f->rect.height < (r_south(&a->rect))))
                 f->rect.y = p1.y;
         else {
                 diff = a->rect.height - f->rect.height;
diff -r 51a8198adb08 -r 51442e2e67fc client.c
--- a/client.c Sun Feb 11 22:17:20 2007 -0500
+++ b/client.c Sun Feb 11 23:24:11 2007 -0500
@@ -58,7 +58,7 @@ create_client(Window w, XWindowAttribute
                 /* depth */ DefaultDepth(blz.dpy, blz.screen),
                 /* class */ CopyFromParent,
                 /* visual */ DefaultVisual(blz.dpy, blz.screen),
- /* valuemask */ CWOverrideRedirect | CWEventMask,
+ /* valuemask */ CWOverrideRedirect | CWEventMask | CWBackPixmap,
                 /* attributes */&fwa
                 );
         c->gc = XCreateGC(blz.dpy, c->framewin, 0, 0);
diff -r 51a8198adb08 -r 51442e2e67fc frame.c
--- a/frame.c Sun Feb 11 22:17:20 2007 -0500
+++ b/frame.c Sun Feb 11 23:24:11 2007 -0500
@@ -214,28 +214,41 @@ void
 void
 draw_frame(Frame *f) {
         if(def.border) {
- f->tile.border = def.border;
+ f->tile.border = 1;
                 f->tile.rect = f->rect;
                 f->tile.rect.x = f->tile.rect.y = 0;
         }
         f->grabbox.rect = f->tile.rect;
- f->grabbox.rect.height = labelh(&def.font);
- f->grabbox.rect.width = def.font.height;
- f->titlebar.rect = f->grabbox.rect;
+ f->grabbox.rect.x += 2;
+ f->grabbox.rect.y += 2;
+ f->grabbox.rect.height = labelh(&def.font) - 4;
+ f->grabbox.rect.width = def.font.height - 3;
+ f->grabbox.border = 1;
         f->titlebar.rect.x = f->grabbox.rect.x + f->grabbox.rect.width;
- f->titlebar.rect.width = f->rect.width - f->titlebar.rect.x;
+ f->titlebar.rect.y = f->tile.rect.y;
+ f->titlebar.rect.width = f->rect.width - f->titlebar.rect.x;
+ f->titlebar.rect.height = labelh(&def.font);
         f->titlebar.border = 0;
         draw_tile(&f->tile);
         draw_label(&f->titlebar, f->client->name);
- f->grabbox.border = 3;
- draw_tile(&f->grabbox);
+ draw_border(&f->tile);
         /* XXX: Hack */
         f->titlebar.rect.x = 0;
- f->titlebar.rect.width += f->grabbox.rect.width;
+ f->titlebar.rect.width = f->rect.width;
         f->titlebar.border = 1;
         draw_border(&f->titlebar);
- XCopyArea(blz.dpy, pmap, f->client->framewin, f->client->gc,
- 0, 0, f->rect.width, f->rect.height, 0, 0);
+ draw_tile(&f->grabbox);
+ XCopyArea(
+ /* display */ blz.dpy,
+ /* src */ pmap,
+ /* dest */ f->client->framewin,
+ /* gc */ f->client->gc,
+ /* x, y */ 0, 0,
+ /* width */ f->rect.width,
+ /* height */ f->rect.height,
+ /* dest_x */ 0,
+ /* dest_y */ 0
+ );
         XSync(blz.dpy, False);
 }
 
diff -r 51a8198adb08 -r 51442e2e67fc mouse.c
--- a/mouse.c Sun Feb 11 22:17:20 2007 -0500
+++ b/mouse.c Sun Feb 11 23:24:11 2007 -0500
@@ -71,13 +71,13 @@ snap_line(SnapArgs *a) {
         /* horizontal */
         if(a->y1 == a->y2 && (a->mask & (NORTH|SOUTH))) {
                 for(i=0; i < a->num; i++) {
- if(!((a->rects[i].x + a->rects[i].width < a->x1) ||
- (a->rects[i].x > a->x2))) {
+ if(!(r_east(&a->rects[i]) < a->x1) ||
+ (a->rects[i].x > a->x2)) {
                                 
                                 if(abs(a->rects[i].y - a->y1) <= abs(*a->delta))
                                         *a->delta = a->rects[i].y - a->y1;
                                 
- t_xy = a->rects[i].y + a->rects[i].height;
+ t_xy = r_south(&a->rects[i]);
                                 if(abs(t_xy - a->y1) < abs(*a->delta))
                                         *a->delta = t_xy - a->y1;
                         }
@@ -87,13 +87,13 @@ snap_line(SnapArgs *a) {
                 /* This is the same as above, tr/xy/yx/,
                  * s/width/height/, s/height/width/ */
                 for(i=0; i < a->num; i++) {
- if(!((a->rects[i].y + a->rects[i].height < a->y1) ||
- (a->rects[i].y > a->y2))) {
+ if(!(r_south(&a->rects[i]) < a->y1) ||
+ (a->rects[i].y > a->y2)) {
                                 
                                 if(abs(a->rects[i].x - a->x1) <= abs(*a->delta))
                                         *a->delta = a->rects[i].x - a->x1;
                                 
- t_xy = a->rects[i].x + a->rects[i].width;
+ t_xy = r_east(&a->rects[i]);
                                 if(abs(t_xy - a->x1) < abs(*a->delta))
                                         *a->delta = t_xy - a->x1;
                         }
@@ -110,21 +110,21 @@ snap_rect(XRectangle *rects, int num, XR
         BlitzAlign ret;
 
         a.x1 = current->x;
- a.x2 = current->x + current->width;
+ a.x2 = r_east(current);
         a.delta = &dy;
         if(*mask & NORTH) {
                 a.y2 = a.y1 = current->y;
                 snap_line(&a);
         }
         if(*mask & SOUTH) {
- a.y2 = a.y1 = current->y + current->height;
+ a.y2 = a.y1 = r_south(current);
                 snap_line(&a);
         }
         a.y1 = current->y;
- a.y2 = current->y + current->height;
+ a.y2 = r_south(current);
         a.delta = &dx;
         if(*mask & EAST) {
- a.x1 = a.x2 = current->x + current->width;
+ a.x1 = a.x2 = r_east(current);
                 snap_line(&a);
         }
         if(*mask & WEST) {
@@ -153,11 +153,17 @@ draw_xor_border(XRectangle *r) {
 
         XSetLineAttributes(blz.dpy, xorgc, 1, LineSolid, CapNotLast, JoinMiter);
         if(xor.height > 4 && xor.width > 2)
- XDrawLine(blz.dpy, blz.root, xorgc, xor.x + 2, xor.y + xor.height / 2,
- xor.x + xor.width - 2, xor.y + xor.height / 2);
+ XDrawLine(blz.dpy, blz.root, xorgc,
+ xor.x + 2,
+ xor.y + xor.height / 2,
+ r_east(&xor) - 2,
+ xor.y + xor.height / 2);
         if(xor.width > 4 && xor.height > 2)
- XDrawLine(blz.dpy, blz.root, xorgc, xor.x + xor.width / 2, xor.y + 2,
- xor.x + xor.width / 2, xor.y + xor.height - 2);
+ XDrawLine(blz.dpy, blz.root, xorgc,
+ xor.x + xor.width / 2,
+ xor.y + 2,
+ xor.x + xor.width / 2,
+ r_south(&xor) - 2);
         XSetLineAttributes(blz.dpy, xorgc, 4, LineSolid, CapNotLast, JoinMiter);
         XDrawRectangles(blz.dpy, blz.root, xorgc, &xor, 1);
         XSync(blz.dpy, False);
@@ -175,7 +181,7 @@ find_droppoint(Frame *frame, int x, int
 
         a_prev = v->area;
         for(a = a_prev->next; a && a->next; a = a->next) {
- if(x < (a->rect.x + a->rect.width))
+ if(x < r_east(&a->rect))
                         break;
                 a_prev = a;
         }
@@ -190,8 +196,8 @@ find_droppoint(Frame *frame, int x, int
                 }
                 return;
         }
- if(x > (a->rect.x + a->rect.width - labelh(&def.font))) {
- rect->x = a->rect.x + a->rect.width - 4;
+ if(x > (r_east(&a->rect) - labelh(&def.font))) {
+ rect->x = r_east(&a->rect) - 4;
                 rect->width = 8;
 
                 if(do_move) {
@@ -209,7 +215,7 @@ find_droppoint(Frame *frame, int x, int
         for(f = a->frame; f; f = f->anext) {
                 if(y < f->rect.y)
                         break;
- if(y < (f->rect.y + f->rect.height))
+ if(y < r_south(&f->rect))
                         break;
                 f_close = f;
         }
@@ -219,7 +225,7 @@ find_droppoint(Frame *frame, int x, int
                 rect->y = f->rect.y;
                 rect->height = 2;
                 if(f_close) {
- rect->y = (f_close->rect.y + f_close->rect.height);
+ rect->y = r_south(&f_close->rect);
                         rect->height = f->rect.y - rect->y;
                 }
                 if(do_move) {
@@ -233,8 +239,8 @@ find_droppoint(Frame *frame, int x, int
                 }
                 return;
         }
- if(y > (f->rect.y + f->rect.height - labelh(&def.font))) {
- rect->y = f->rect.y + f->rect.height;
+ if(y > r_south(&f->rect) - labelh(&def.font)) {
+ rect->y = r_south(&f->rect);
                 rect->height = (screen->rect.height - labelh(&def.font) - rect->y);
                 if(f->anext)
                         rect->height = (f->anext->rect.y - rect->y);
Received on Mon Feb 12 2007 - 05:26:39 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:11 UTC