changeset: 2106:33f031e8647c
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Apr 21 17:01:49 2007 -0400
summary: Bunch of fixes. Redraw divs when updated without waiting for expose.
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/area.c
--- a/cmd/wmii/area.c Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/area.c Sat Apr 21 17:01:49 2007 -0400
@@ -23,8 +23,9 @@ Area *
Area *
create_area(View *v, Area *pos, uint w) {
static ushort id = 1;
- uint areanum, colnum, i;
+ uint areanum, i;
uint minwidth;
+ int colnum;
Area *a;
minwidth = Dx(screen->r)/NCOL;
@@ -36,10 +37,10 @@ create_area(View *v, Area *pos, uint w)
for(a = v->area; a; a = a->next)
areanum++;
- colnum = max((areanum - 1), 0);
+ colnum = areanum - 1;
if(w == 0) {
- if(colnum) {
- w = newcolw(v, max(i-1, 0));
+ if(colnum >= 0) {
+ w = newcolw(v, i);
if (w == 0)
w = Dx(screen->r) / (colnum + 1);
}
@@ -63,8 +64,9 @@ create_area(View *v, Area *pos, uint w)
a->sel = nil;
a->r = screen->r;
- a->r.max.x = a->r.min.x + w;
- a->r.max.x = screen->brect.min.y;
+ a->r.min.x = 0;
+ a->r.max.x = w;
+ a->r.max.y = screen->brect.min.y;
if(pos) {
a->next = pos->next;
@@ -300,10 +302,7 @@ place_frame(Frame *f) {
if(c->trans)
return;
- if(Dx(c->r) >= Dx(a->r)
- || Dy(c->r) >= Dy(a->r)
- || c->size.flags & USPosition
- || c->size.flags & PPosition)
+ if(c->fullscreen || c->w.hints->position)
return;
if(!field) {
mx = Dx(screen->r) / dx;
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/client.c
--- a/cmd/wmii/client.c Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/client.c Sat Apr 21 17:01:49 2007 -0400
@@ -36,6 +36,7 @@ create_client(XWindow w, XWindowAttribut
c = emallocz(sizeof(Client));
c->border = wa->border_width;
+
c->r.min = Pt(wa->x, wa->y);
c->r.max = addpt(c->r.min, Pt(wa->width, wa->height));
@@ -124,7 +125,7 @@ destroy_client(Client *c) {
Client **tc;
XEvent ev;
- if(verbose) fprintf(stderr, "client.c:destroy_client(%p) %s\n", c, c->name);
+ Debug fprintf(stderr, "client.c:destroy_client(%p) %s\n", c, c->name);
for(tc=&client; *tc; tc=&(*tc)->next)
if(*tc == c) {
@@ -179,6 +180,7 @@ manage_client(Client *c) {
free(tags);
+ r = c->w.r;
reparent_client(c, c->framewin, Pt(def.border, labelh(def.font)));
if(!strlen(c->tags))
@@ -186,11 +188,13 @@ manage_client(Client *c) {
else
apply_tags(c, c->tags);
- r = gravclient(c, c->w.r);
- if(c->sel->area->floating)
- resize_client(c, &r);
- else
- c->sel->revert = r;
+ if(c->w.hints->position) {
+ r = gravclient(c, r);
+ if(c->sel->area->floating)
+ resize_client(c, &r);
+ else
+ c->sel->revert = r;
+ }
if(!starting)
update_views();
@@ -246,7 +250,7 @@ configreq_event(Window *w, XConfigureReq
static void
destroy_event(Window *w, XDestroyWindowEvent *e) {
- if(verbose) fprintf(stderr, "client.c:destroy_event(%x)\n", (uint)w->w);
+ Debug fprintf(stderr, "client.c:destroy_event(%x)\n", (uint)w->w);
destroy_client(w->aux);
}
@@ -257,11 +261,11 @@ enter_event(Window *w, XCrossingEvent *e
c = w->aux;
if(e->detail != NotifyInferior) {
if(screen->focus != c) {
- if(verbose) fprintf(stderr, "enter_notify(c) => %s\n", c->name);
+ Debug fprintf(stderr, "enter_notify(c) => %s\n", c->name);
focus(c, False);
}
set_cursor(c, cursor[CurNormal]);
- }else if(verbose)
+ }else Debug
fprintf(stderr, "enter_notify(c[NotifyInferior]) => %s\n", c->name);
}
@@ -658,13 +662,10 @@ focus_client(Client *c) {
focus_client(Client *c) {
flushevents(FocusChangeMask, True);
- if(verbose)
- fprintf(stderr, "focus_client(%p[%x]) => %s\n", c, clientwin(c), clientname(c));
+ Debug fprintf(stderr, "focus_client(%p[%x]) => %s\n", c, clientwin(c), clientname(c));
if(screen->focus != c) {
- if(verbose)
- fprintf(stderr, "\t%s => %s\n",
- clientname(screen->focus), clientname(c));
+ Debug fprintf(stderr, "\t%s => %s\n", clientname(screen->focus), clientname(c));
if(c)
setfocus(&c->w, RevertToParent);
else
@@ -879,8 +880,10 @@ apply_tags(Client *c, const char *tags)
buf[0] = 0;
for(n = 0; tags[n]; n++)
if(tags[n] != ' ' && tags[n] != '\t') break;
+
if(tags[n] == '+' || tags[n] == '-')
strncpy(buf, c->tags, sizeof(c->tags));
+
strlcat(buf, &tags[n], sizeof(buf));
trim(buf, " \t/");
@@ -895,9 +898,7 @@ apply_tags(Client *c, const char *tags)
}
while(buf[n] && n < sizeof(buf) && j < 32) {
for(i = n; i < sizeof(buf) - 1; i++)
- if(buf[i] == '+'
- || buf[i] == '-'
- || buf[i] == '\0')
+ if(buf[i] == '+' || buf[i] == '-' || buf[i] == '\0')
break;
last = buf[i];
buf[i] = '\0';
@@ -907,9 +908,9 @@ apply_tags(Client *c, const char *tags)
c->floating = add;
else if(!strncmp(&buf[n], "!", 2))
cur = view ? screen->sel->name : "nil";
- else if(strncmp(&buf[n], "sel", 4)
- && strncmp(&buf[n], ".", 2)
- && strncmp(&buf[n], "..", 3))
+ else if(strcmp(&buf[n], "sel")
+ && strcmp(&buf[n], ".")
+ && strcmp(&buf[n], ".."))
cur = &buf[n];
n = i + 1;
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/column.c
--- a/cmd/wmii/column.c Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/column.c Sat Apr 21 17:01:49 2007 -0400
@@ -31,7 +31,7 @@ str2colmode(const char *str) {
}
static Divide*
-get_div(Divide **dp) {
+getdiv(Divide **dp) {
WinAttr wa;
Divide *d;
@@ -59,12 +59,12 @@ get_div(Divide **dp) {
}
static void
-map_div(Divide *d) {
+mapdiv(Divide *d) {
mapwin(d->w);
}
static void
-unmap_div(Divide *d) {
+unmapdiv(Divide *d) {
unmapwin(d->w);
}
@@ -77,11 +77,11 @@ setdiv(Divide *d, int x) {
r.max.y = screen->brect.min.y;
reshapewin(d->w, r);
- map_div(d);
-}
-
-static void
-draw_img(Image *img, ulong cbg, ulong cborder) {
+ mapdiv(d);
+}
+
+static void
+drawimg(Image *img, ulong cbg, ulong cborder) {
Point pt[6];
pt[0] = Pt(0, 0);
@@ -98,7 +98,14 @@ draw_img(Image *img, ulong cbg, ulong cb
}
void
+drawdiv(Divide *d) {
+ copyimage(d->w, divimg->r, divimg, ZP);
+ setshapemask(d->w, divmask, ZP);
+}
+
+void
update_imgs() {
+ Divide *d;
int w, h;
w = 2 * (labelh(def.font) / 3);
@@ -118,8 +125,11 @@ update_imgs() {
divc = def.normcolor;
fill(divmask, divmask->r, 0);
- draw_img(divmask, 1, 1);
- draw_img(divimg, divc.bg, divc.border);
+ drawimg(divmask, 1, 1);
+ drawimg(divimg, divc.bg, divc.border);
+
+ for(d = divs; d && d->w->mapped; d = d->next)
+ drawdiv(d);
}
void
@@ -133,24 +143,18 @@ update_divs() {
v = screen->sel;
dp = &divs;
for(a = v->area->next; a; a = a->next) {
- d = get_div(dp);
+ d = getdiv(dp);
dp = &d->next;
setdiv(d, a->r.min.x);
if(!a->next) {
- d = get_div(dp);
+ d = getdiv(dp);
dp = &d->next;
setdiv(d, a->r.max.x);
}
}
for(d = *dp; d; d = d->next)
- unmap_div(d);
-}
-
-void
-draw_div(Divide *d) {
- copyimage(d->w, divimg->r, divimg, ZP);
- setshapemask(d->w, divmask, ZP);
+ unmapdiv(d);
}
/* Div Handlers */
@@ -167,7 +171,7 @@ expose_event(Window *w, XExposeEvent *e)
Divide *d;
d = w->aux;
- draw_div(d);
+ drawdiv(d);
}
static Handlers divhandler = {
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/dat.h Sat Apr 21 17:01:49 2007 -0400
@@ -243,3 +243,6 @@ Bool verbose;
Bool verbose;
char *user;
char *execstr;
+
+#define Debug if(verbose)
+
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/event.c
--- a/cmd/wmii/event.c Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/event.c Sat Apr 21 17:01:49 2007 -0400
@@ -10,8 +10,7 @@
void
dispatch_event(XEvent *e) {
- if(verbose)
- printevent(e);
+ Debug printevent(e);
if(handler[e->type])
handler[e->type](e);
}
@@ -88,8 +87,7 @@ destroynotify(XEvent *e) {
if(w->handler->destroy)
w->handler->destroy(w, ev);
}else {
- if(verbose)
- fprintf(stderr, "DestroyWindow(%x) (no handler)\n", (uint)ev->window);
+ Debug fprintf(stderr, "DestroyWindow(%x) (no handler)\n", (uint)ev->window);
if((c = win2client(ev->window)))
fprintf(stderr, "Badness: Unhandled DestroyNotify: "
"Client: %p, Window: %x, Name: %s\n", c, (uint)c->w.w, c->name);
@@ -130,7 +128,7 @@ leavenotify(XEvent *e) {
void
print_focus(Client *c, char *to) {
- if(verbose) {
+ Debug {
fprintf(stderr, "screen->focus: %p[%x] => %p[%x]\n",
screen->focus, clientwin(screen->focus), c, clientwin(c));
fprintf(stderr, "\t%s => %s\n", clientname(screen->focus), to);
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/frame.c Sat Apr 21 17:01:49 2007 -0400
@@ -170,7 +170,7 @@ enter_event(Window *w, XCrossingEvent *e
c = w->aux;
f = c->sel;
if(screen->focus != c) {
- if(verbose) fprintf(stderr, "enter_notify(f) => %s\n", f->client->name);
+ Debug fprintf(stderr, "enter_notify(f) => %s\n", f->client->name);
if(f->area->floating || !f->collapsed)
focus(f->client, False);
}
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/fs.c
--- a/cmd/wmii/fs.c Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/fs.c Sat Apr 21 17:01:49 2007 -0400
@@ -811,6 +811,7 @@ fs_write(Ixp9Req *r) {
{ uint n;
char *p, *toks[32];
+ errstr = nil;
p = toutf8n(r->ifcall.data, r->ifcall.count);
n = tokenize(toks, 32, p, '\n');
for(i = 0; i < n; i++) {
@@ -821,14 +822,9 @@ fs_write(Ixp9Req *r) {
}
free(p);
}
- if(screen->sel)
- focus_view(screen, screen->sel);
- if(errstr) {
- respond(r, errstr);
- return;
- }
+ focus_view(screen, screen->sel);
r->ofcall.count = r->ifcall.count;
- respond(r, nil);
+ respond(r, errstr);
return;
case FsFEvent:
if(r->ifcall.data[r->ifcall.count-1] == '\n')
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/mouse.c Sat Apr 21 17:01:49 2007 -0400
@@ -272,17 +272,18 @@ horiz:
case ButtonRelease:
switch(ev.xbutton.button) {
case 1:
- if(f->anext && (f->aprev && fw->fp != f->aprev->aprev)) {
+ if(f->anext && (!f->aprev || fw->fp != f->aprev || fw->fp != f->aprev->aprev)) {
f->anext->r.min.y = f->r.min.y;
resize_frame(f->anext, f->anext->r);
}
- else if(f->aprev && fw->fp == f->aprev->aprev) {
- fw->fp = f->aprev->aprev;
- f->aprev->r = f->r;
+ else if(f->aprev) {
+ if(fw->fp == f->aprev->aprev) {
+ fw->fp = f->aprev->aprev;
+ f->aprev->r = f->r;
+ }else
+ f->aprev->r.max.y = f->r.max.y;
+ resize_frame(f->aprev, f->aprev->r);
}
- else
- f->aprev->r.max.y = f->r.max.y;
- resize_frame(f->aprev, f->aprev->r);
remove_frame(f);
f->area = fw->ra;
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/view.c
--- a/cmd/wmii/view.c Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/view.c Sat Apr 21 17:01:49 2007 -0400
@@ -230,50 +230,50 @@ restack_view(View *v) {
void
scale_view(View *v, int w) {
- uint xoff, num_col;
- uint min_width;
- Area *a;
- float scale, dx;
- int wdiff;
-
- min_width = Dx(screen->r)/NCOL;
+ uint xoff, numcol;
+ uint minwidth;
+ Area *a;
+ float scale;
+ int wdiff, dx;
+
+ minwidth = Dx(screen->r)/NCOL;
if(!v->area->next)
return;
- num_col = 0;
+ numcol = 0;
dx = 0;
for(a=v->area->next; a; a=a->next) {
- num_col++;
+ numcol++;
dx += Dx(a->r);
}
scale = (float)w / dx;
xoff = 0;
for(a=v->area->next; a; a=a->next) {
+ a->r.max.x = xoff + Dx(a->r) * scale;
a->r.min.x = xoff;
- a->r.max.x = xoff + Dx(a->r) * scale;
if(!a->next)
a->r.max.x = w;
xoff = a->r.max.x;
}
- /* min_width can only be respected when there is enough space;
+ /* minwidth can only be respected when there is enough space;
* the caller should guarantee this */
- if(num_col * min_width > w)
- return;
-
+ if(numcol * minwidth > w)
+ return;
+
+ dx = numcol * minwidth;
xoff = 0;
- for(a=v->area->next, num_col--; a; a=a->next, num_col--) {
+ for(a=v->area->next, numcol--; a; a=a->next, numcol--) {
a->r.min.x = xoff;
-
- if(Dx(a->r) < min_width)
- a->r.max.x = xoff + min_width;
- else if((wdiff = xoff + Dx(a->r) - w + num_col * min_width) > 0)
+
+ if(Dx(a->r) < minwidth)
+ a->r.max.x = xoff + minwidth;
+ else if((wdiff = xoff + Dx(a->r) - w + dx) > 0)
a->r.max.x -= wdiff;
if(!a->next)
a->r.max.x = w;
-
xoff = a->r.max.x;
}
}
@@ -492,11 +492,12 @@ newcolw(View *v, int num) {
char buf[sizeof r->value];
char *toks[16];
- strncpy(buf, r->value, sizeof(buf));
+ strcpy(buf, r->value);
+
n = tokenize(toks, 16, buf, '+');
- if(n > num)
+ if(num < n)
if(sscanf(toks[num], "%u", &n) == 1)
- return Dx(screen->r) * ((double)n / 100);
+ return Dx(screen->r) * (n / 100.0);
break;
}
return 0;
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/x11.c Sat Apr 21 17:01:49 2007 -0400
@@ -660,18 +660,17 @@ sethints(Window *w) {
Point p;
long size;
- if(!XGetWMNormalHints(display, w->w, &xs, &size)) {
- free(w->hints);
- w->hints = nil;
- return;
- }
-
if(w->hints == nil)
w->hints = emalloc(sizeof *h);
+
h = w->hints;
memset(h, 0, sizeof *h);
h->max = Pt(MaxInt, MaxInt);
+
+ if(!XGetWMNormalHints(display, w->w, &xs, &size))
+ return;
+
if(xs.flags&PMinSize) {
p.x = xs.min_width;
p.y = xs.min_height;
@@ -705,6 +704,8 @@ sethints(Window *w) {
p.y = xs.max_aspect.y;
h->aspect.max = p;
}
+
+ h->position = ((xs.flags&(USPosition|PPosition)) != 0);
p = ZP;
if((xs.flags&PWinGravity) == 0)
@@ -733,7 +734,10 @@ Rectangle
Rectangle
sizehint(WinHints *h, Rectangle r) {
Point p, p2, o;
-
+
+ if(h == nil)
+ return r;
+
o = r.min;
r = rectsubpt(r, o);
diff -r 2205ca9eb791 -r 33f031e8647c cmd/wmii/x11.h
--- a/cmd/wmii/x11.h Sat Apr 21 01:13:40 2007 -0400
+++ b/cmd/wmii/x11.h Sat Apr 21 17:01:49 2007 -0400
@@ -50,6 +50,7 @@ struct WinHints {
Rectangle aspect;
Point grav;
Bool gravstatic;
+ Bool position;
};
struct Handlers {
Received on Fri Jun 01 2007 - 03:09:48 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:00 UTC