wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit cac086b3fcbe9e4e316d73c66a2a6b795b2255e0
parent 1f7cc79d552d5b2a6b752d99433e08f00a1e24ae
Author: Kris Maglione <jg@suckless.org>
Date:   Tue,  6 Feb 2007 21:48:28 -0500

Fixed sizing bug of clients with multiple tags, with cleanup along the way.


Diffstat:
area.c | 12++++++------
client.c | 66+++++++++++++++++++++++++++++-------------------------------------
column.c | 21++++++++++-----------
frame.c | 21+++++++++++++++++++++
mouse.c | 2+-
view.c | 2+-
wmii.h | 5+++--
7 files changed, 71 insertions(+), 58 deletions(-)

diff --git a/area.c b/area.c @@ -91,7 +91,7 @@ destroy_area(Area *a) { c->revert = nil; i = 0; - for(ta=v->area; ta->next != a; ta=ta->next) + for(ta=v->area; ta && ta->next != a; ta=ta->next) i++; if(ta) { ta->next = a->next; @@ -109,7 +109,8 @@ place_client(Area *a, Client *c) { static unsigned int mx, my; static Bool *field; BlitzAlign align; - XPoint p1, p2; + XPoint p1 = {0, 0}; + XPoint p2 = {0, 0}; XRectangle *rects; Frame *f, *fr; Bool fit; @@ -117,11 +118,10 @@ place_client(Area *a, Client *c) { int snap; snap = screen->rect.height / 66; - p1 = p2 = {0, 0}; num = 0; fit = False; - align = CENTER - field = nil + align = CENTER; + field = nil; f = c->sel; @@ -264,7 +264,7 @@ detach_from_area(Area *a, Frame *f) { v = a->view; c = f->client; - pr = nil + pr = nil; for(ft=&a->frame; *ft; ft=&(*ft)->anext) { if(*ft == f) break; diff --git a/client.c b/client.c @@ -462,50 +462,42 @@ match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky) { } void -resize_client(Client *c, XRectangle *r, Bool ignore_xcall) { - Frame *f = c->sel; - Bool floating = f->area->floating; +resize_client(Client *c, XRectangle *r) { + Frame *f; + Bool floating; - BlitzAlign stickycorner = 0; - 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, &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); - } + 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 - XMoveResizeWindow(blz.dpy, c->framewin, 2 * screen->rect.width + f->rect.x, - f->rect.y, f->rect.width, f->rect.height); } + + 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); + 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 --git a/column.c b/column.c @@ -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 --git a/frame.c b/frame.c @@ -62,6 +62,27 @@ insert_frame(Frame *pos, Frame *f, Bool before) { } 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 swap_frames(Frame *fa, Frame *fb) { XRectangle trect; Area *a; diff --git a/mouse.c b/mouse.c @@ -371,7 +371,7 @@ do_mouse_resize(Client *c, BlitzAlign align) { if(!floating) resize_column(c, &frect); else - resize_client(c, &frect, False); + resize_client(c, &frect); if(rects) free(rects); diff --git a/view.c b/view.c @@ -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 --git a/wmii.h b/wmii.h @@ -272,7 +272,7 @@ extern void reparent_client(Client *c, Window w, int x, int y); 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 unsigned int flush_masked_events(long even_mask); 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);