[hackers] wmii: new tip (= 1764)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Wed, 07 Feb 2007 03:50:04 +0100

changeset: 1764:b0d30e3d9b2b
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Tue Feb 06 21:48:28 2007 -0500
files: area.c client.c column.c frame.c mouse.c view.c wmii.h
description:
Fixed sizing bug of clients with multiple tags, with cleanup along the way.

changeset: 1763:13b5480ce730
user: Kris Maglione <jg_AT_suckless.org>
date: Tue Feb 06 20:47:03 2007 -0500
files: area.c
description:
Cleanup in area.c

diff -r 350ce657c652 -r b0d30e3d9b2b area.c
--- a/area.c Tue Feb 06 17:12:24 2007 -0500
+++ b/area.c Tue Feb 06 21:48:28 2007 -0500
@@ -46,7 +46,7 @@ create_area(View *v, Area *pos, unsigned
         }
         if(w < min_width)
                 w = min_width;
- if(col_num && col_num * min_width + w > screen->rect.width)
+ if(col_num && (col_num * min_width + w) > screen->rect.width)
                 return nil;
         if(i)
                 scale_view(v, screen->rect.width - w);
@@ -67,7 +67,8 @@ create_area(View *v, Area *pos, unsigned
         if(i) write_event("CreateColumn %d\n", i);
 
         i = 0;
- for(ta=v->area; ta && ta != v->sel; ta=ta->next) i++;
+ for(ta=v->area; ta != v->sel; ta=ta->next)
+ i++;
         if(i) write_event("ColumnFocus %d\n", i);
         else write_event("FocusFloating\n");
         return a;
@@ -77,15 +78,21 @@ destroy_area(Area *a) {
 destroy_area(Area *a) {
         Client *c;
         Area *ta;
- View *v = a->view;
+ View *v;
         unsigned int i;
+
+ v = a->view;
+
         assert(!a->frame && "wmiiwm: fatal, destroying non-empty area");
         if(v->revert == a)
                 v->revert = nil;
         for(c=client; c; c=c->next)
                 if(c->revert == a)
                         c->revert = nil;
- for(ta=v->area, i = 0; ta && ta->next != a; ta=ta->next, i++);
+
+ i = 0;
+ for(ta=v->area; ta && ta->next != a; ta=ta->next)
+ i++;
         if(ta) {
                 ta->next = a->next;
                 if(v->sel == a) {
@@ -100,15 +107,23 @@ static void
 static void
 place_client(Area *a, Client *c) {
         static unsigned int mx, my;
- static Bool *field = nil;
- Frame *fr;
- Bool fit = False;
- BlitzAlign align = CENTER;
- unsigned int i, j, x, y, maxx, maxy, dx, dy, cx, cy, diff, num = 0;
- XPoint p1 = {0, 0}, p2 = {0, 0};
- Frame *f = c->sel;
- int snap = screen->rect.height / 66;
+ static Bool *field;
+ BlitzAlign align;
+ XPoint p1 = {0, 0};
+ XPoint p2 = {0, 0};
         XRectangle *rects;
+ Frame *f, *fr;
+ Bool fit;
+ unsigned int i, j, x, y, dx, dy, cx, cy, maxx, maxy, diff, num;
+ int snap;
+
+ snap = screen->rect.height / 66;
+ num = 0;
+ fit = False;
+ align = CENTER;
+ field = nil;
+
+ f = c->sel;
 
         if(c->trans)
                 return;
@@ -203,11 +218,17 @@ attach_to_area(Area *a, Frame *f, Bool s
 attach_to_area(Area *a, Frame *f, Bool send) {
         unsigned int h, n_frame;
         Frame **fa, *ft;
- View *v = a->view;
- Client *c = f->client;
-
- for(ft=a->frame, n_frame=1; ft; ft=ft->anext, n_frame++);
+ Client *c;
+ View *v;
+
+ v = a->view;
+ c = f->client;
         h = 0;
+
+ n_frame = 1;
+ for(ft=a->frame; ft; ft=ft->anext)
+ n_frame++;
+
         c->floating = a->floating;
         if(!c->floating) {
                 h = a->rect.height / n_frame;
@@ -235,11 +256,15 @@ attach_to_area(Area *a, Frame *f, Bool s
 
 void
 detach_from_area(Area *a, Frame *f) {
- Frame **ft, *pr = nil;
- Client *c = f->client;
- View *v = a->view;
+ Frame **ft, *pr;
+ Client *c;
+ View *v;
         Area *ta;
         unsigned int i;
+
+ v = a->view;
+ c = f->client;
+ pr = nil;
 
         for(ft=&a->frame; *ft; ft=&(*ft)->anext) {
                 if(*ft == f) break;
@@ -253,7 +278,9 @@ detach_from_area(Area *a, Frame *f) {
                 if(a->frame)
                         arrange_column(a, False);
                 else {
- for(ta=v->area, i = 0; ta && ta != a; ta=ta->next, i++);
+ i = 0;
+ for(ta=v->area; ta && ta != a; ta=ta->next)
+ i++;
                         if(v->area->next->next)
                                 destroy_area(a);
                         else if(!a->frame && v->area->frame) {
@@ -277,7 +304,9 @@ detach_from_area(Area *a, Frame *f) {
                 }
                 else if(v->area->next->frame)
                         v->sel = v->area->next; /* focus first col as fallback */
- for(ta=v->area, i = 0; ta && ta != v->sel; ta=ta->next, i++);
+ i = 0;
+ for(ta=v->area; ta && ta != v->sel; ta=ta->next)
+ i++;
                 if(i) write_event("ColumnFocus %d\n", i);
                 else write_event("FocusFloating\n");
         }
@@ -339,12 +368,15 @@ select_area(Area *a, char *arg) {
         else {
                 if(sscanf(arg, "%d", &i) != 1)
                         return Ebadvalue;
- for(new=view->area; i && new->next; new=new->next, i--);
+ for(new=view->area; i && new->next; new=new->next)
+ i--;
         }
         if(new->sel)
                 focus_client(new->sel->client, True);
         if(v->sel != new) {
- for(ta=v->area, i = 0; ta && ta != new; ta=ta->next, i++);
+ i = 0;
+ for(ta=v->area; ta && ta != new; ta=ta->next)
+ i++;
                 if(i) write_event("ColumnFocus %d\n", i);
                 else write_event("FocusFloating\n");
                 v->sel = new;
diff -r 350ce657c652 -r b0d30e3d9b2b client.c
--- a/client.c Tue Feb 06 17:12:24 2007 -0500
+++ b/client.c Tue Feb 06 21:48:28 2007 -0500
@@ -462,50 +462,42 @@ match_sizehints(Client *c, XRectangle *r
 }
 
 void
-resize_client(Client *c, XRectangle *r, Bool ignore_xcall) {
- Frame *f = c->sel;
- Bool floating = f->area->floating;
-
- BlitzAlign stickycorner = 0;
- if(f->rect.x != r->x && f->rect.x + f->rect.width == r->x + r->width)
- stickycorner |= EAST;
+resize_client(Client *c, XRectangle *r) {
+ Frame *f;
+ Bool floating;
+
+ f = c->sel;
+ floating = f->area->floating;
+
+ resize_frame(f, r);
+
+ if(floating) {
+ if((c->rect.width == screen->rect.width) &&
+ (c->rect.height == screen->rect.height)) {
+ f->rect.x = -def.border;
+ f->rect.y = -labelh(&def.font);
+ }else{
+ check_frame_constraints(&f->rect);
+ }
+ }
+
+ if(f->area->view == screen->sel)
+ XMoveResizeWindow(blz.dpy, c->framewin, f->rect.x,
+ f->rect.y, f->rect.width, f->rect.height);
         else
- stickycorner |= WEST;
- if(f->rect.y != r->y && f->rect.y + f->rect.height == r->y + r->height)
- stickycorner |= SOUTH;
- else
- stickycorner |= NORTH;
- f->rect = *r;
- if((f->area->mode != Colstack) || (f->area->sel == f))
- match_sizehints(c, &c->sel->rect, floating, stickycorner);
- if(!ignore_xcall) {
- if(floating) {
- if((c->rect.width == screen->rect.width) &&
- (c->rect.height == screen->rect.height)) {
- f->rect.x = -def.border;
- f->rect.y = -labelh(&def.font);
- }else{
- check_frame_constraints(&f->rect);
- }
- }
- if(f->area->view == screen->sel)
- XMoveResizeWindow(blz.dpy, c->framewin, f->rect.x,
- f->rect.y, f->rect.width, f->rect.height);
- else
- XMoveResizeWindow(blz.dpy, c->framewin, 2 * screen->rect.width + f->rect.x,
- f->rect.y, f->rect.width, f->rect.height);
- }
+ XMoveResizeWindow(blz.dpy, c->framewin, 2 * screen->rect.width + f->rect.x,
+ f->rect.y, f->rect.width, f->rect.height);
+
         c->rect.x = def.border;
         c->rect.y = labelh(&def.font);
         if((f->area->sel == f) || (f->area->mode != Colstack)) {
                 c->rect.width = f->rect.width - 2 * def.border;
                 c->rect.height = f->rect.height - def.border - labelh(&def.font);
         }
- if(!ignore_xcall) {
- XMoveResizeWindow(blz.dpy, c->win, c->rect.x, c->rect.y,
- c->rect.width, c->rect.height);
- configure_client(c);
- }
+
+ XMoveResizeWindow(blz.dpy, c->win, c->rect.x, c->rect.y,
+ c->rect.width, c->rect.height);
+ configure_client(c);
 }
 
 void
@@ -545,7 +537,7 @@ move_client(Client *c, char *arg) {
         if(!f->area->floating)
                 resize_column(f->client, &new);
         else
- resize_client(f->client, &new, False);
+ resize_client(f->client, &new);
 }
 
 void
@@ -561,7 +553,7 @@ size_client(Client *c, char *arg) {
         if(!f->area->floating)
                 resize_column(f->client, &new);
         else
- resize_client(f->client, &new, False);
+ resize_client(f->client, &new);
 }
 
 char *
diff -r 350ce657c652 -r b0d30e3d9b2b column.c
--- a/column.c Tue Feb 06 17:12:24 2007 -0500
+++ b/column.c Tue Feb 06 21:48:28 2007 -0500
@@ -57,7 +57,6 @@ relax_column(Area *a) {
                 for(f=a->frame; f; f=f->anext) {
                         f->rect.x = a->rect.x + (a->rect.width - f->rect.width) / 2;
                         f->rect.y = a->rect.y + (a->rect.height - f->rect.height) / 2;
- resize_client(f->client, &f->rect, True);
                 }
                 return;
         }
@@ -78,7 +77,7 @@ relax_column(Area *a) {
                         for(f=a->frame; f && (hx < hdiff); f=f->anext) {
                                 unsigned int tmp = f->rect.height;
                                 f->rect.height += hx;
- resize_client(f->client, &f->rect, True);
+ match_sizehints(f->client, &f->rect, f->area->floating, NORTH|EAST);
                                 hdiff -= (f->rect.height - tmp);
                         }
         }
@@ -92,7 +91,8 @@ relax_column(Area *a) {
                         f->rect.x = a->rect.x + (a->rect.width - f->rect.width) / 2;
                         yoff = f->rect.y + f->rect.height + hdiff;
                 }
- resize_client(f->client, &f->rect, True);
+ if(a->mode != Colstack || f == a->sel)
+ match_sizehints(f->client, &f->rect, f->area->floating, NORTH|EAST);
         }
 }
 
@@ -156,7 +156,7 @@ arrange_column(Area *a, Bool dirty) {
                         f->rect.y = yoff;
                         f->rect.width = a->rect.width;
                         yoff += f->rect.height;
- //resize_client(f->client, &f->rect, True);
+ match_sizehints(f->client, &f->rect, f->area->floating, NORTH|EAST);
                 }
                 break;
         case Colstack:
@@ -171,7 +171,6 @@ arrange_column(Area *a, Bool dirty) {
                         else
                                 f->rect.height = labelh(&def.font);
                         yoff += f->rect.height;
- //resize_client(f->client, &f->rect, True);
                 }
                 break;
 Fallthrough:
@@ -179,7 +178,7 @@ Fallthrough:
                 for(f=a->frame; f; f=f->anext) {
                         f->rect = a->rect;
                         if(f != a->sel) f->rect.x = screen->rect.width * 2;
- //resize_client(f->client, &f->rect, True);
+ match_sizehints(f->client, &f->rect, f->area->floating, NORTH|EAST);
                 }
                 break;
         default:
@@ -196,7 +195,7 @@ match_horiz(Area *a, XRectangle *r) {
         for(f=a->frame; f; f=f->anext) {
                 f->rect.x = r->x;
                 f->rect.width = r->width;
- //resize_client(f->client, &f->rect, True);
+ resize_frame(f, &f->rect);
         }
 }
 
@@ -281,16 +280,16 @@ AfterHorizontal:
                 north->rect.height = new->y - north->rect.y;
                 f->rect.height += f->rect.y - new->y;
                 f->rect.y = new->y;
- //resize_client(north->client, &north->rect, True);
- //resize_client(f->client, &f->rect, True);
+ resize_frame(north, &north->rect);
+ resize_frame(f, &f->rect);
         }
         if(south && (new->y + new->height != f->rect.y + f->rect.height)) {
                 south->rect.height -= new->y + new->height - south->rect.y;
                 south->rect.y = new->y + new->height;
                 f->rect.y = new->y;
                 f->rect.height = new->height;
- //resize_client(f->client, &f->rect, False);
- //resize_client(south->client, &south->rect, True);
+ resize_frame(f, &f->rect);
+ resize_frame(south, &south->rect);
         }
 AfterVertical:
         relax_column(a);
diff -r 350ce657c652 -r b0d30e3d9b2b frame.c
--- a/frame.c Tue Feb 06 17:12:24 2007 -0500
+++ b/frame.c Tue Feb 06 21:48:28 2007 -0500
@@ -59,6 +59,27 @@ insert_frame(Frame *pos, Frame *f, Bool
         Frame **p = pos ? &pos->anext : &a->frame;
         f->anext = *p;
         *p = f;
+}
+
+void
+resize_frame(Frame *f, XRectangle *r) {
+ BlitzAlign stickycorner = 0;
+ Client *c;
+
+ c = f->client;
+
+ if(f->rect.x != r->x && (f->rect.x + f->rect.width) == (r->x + r->width))
+ stickycorner |= EAST;
+ else
+ stickycorner |= WEST;
+ if(f->rect.y != r->y && (f->rect.y + f->rect.height) == (r->y + r->height))
+ stickycorner |= SOUTH;
+ else
+ stickycorner |= NORTH;
+
+ f->rect = *r;
+ if((f->area->mode != Colstack) || (f->area->sel == f))
+ match_sizehints(c, &f->rect, f->area->floating, stickycorner);
 }
 
 void
diff -r 350ce657c652 -r b0d30e3d9b2b mouse.c
--- a/mouse.c Tue Feb 06 17:12:24 2007 -0500
+++ b/mouse.c Tue Feb 06 21:48:28 2007 -0500
@@ -371,7 +371,7 @@ do_mouse_resize(Client *c, BlitzAlign al
                         if(!floating)
                                 resize_column(c, &frect);
                         else
- resize_client(c, &frect, False);
+ resize_client(c, &frect);
 
                         if(rects)
                                 free(rects);
diff -r 350ce657c652 -r b0d30e3d9b2b view.c
--- a/view.c Tue Feb 06 17:12:24 2007 -0500
+++ b/view.c Tue Feb 06 21:48:28 2007 -0500
@@ -116,7 +116,7 @@ focus_view(WMScreen *s, View *v) {
         for(c=client; c; c=c->next)
                 if((f = c->sel)) {
                         if(f->view == v) {
- resize_client(c, &f->rect, False);
+ resize_client(c, &f->rect);
                                 //XMoveWindow(blz.dpy, c->framewin, f->rect.x, f->rect.y);
                         }else
                                 XMoveWindow(blz.dpy, c->framewin, 2 * s->rect.width + f->rect.x,
diff -r 350ce657c652 -r b0d30e3d9b2b wmii.h
--- a/wmii.h Tue Feb 06 17:12:24 2007 -0500
+++ b/wmii.h Tue Feb 06 21:48:28 2007 -0500
@@ -272,7 +272,7 @@ extern void manage_client(Client *c);
 extern void manage_client(Client *c);
 extern void focus_client(Client *c, Bool restack);
 extern void focus(Client *c, Bool restack);
-extern void resize_client(Client *c, XRectangle *r, Bool ignore_xcall);
+extern void resize_client(Client *c, XRectangle *r);
 extern void match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky);
 extern char *send_client(Frame *f, char *arg);
 extern char * message_client(Client *c, char *message);
@@ -318,7 +318,8 @@ extern Frame *create_frame(Client *c, Vi
 extern Frame *create_frame(Client *c, View *v);
 extern void remove_frame(Frame *f);
 extern void insert_frame(Frame *pos, Frame *f, Bool before);
-void swap_frames(Frame *fa, Frame *fb);
+extern void resize_frame(Frame *f, XRectangle *r);
+extern void swap_frames(Frame *fa, Frame *fb);
 extern void draw_frame(Frame *f);
 extern void draw_frames();
 extern void update_frame_widget_colors(Frame *f);
Received on Wed Feb 07 2007 - 03:50:04 UTC

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