commit a01c4f7b6a817d6846bbd8623b8fce1410c8b407
parent 890ecbce8664c3d565bd8123ce8f0a6d227fb03b
Author: Kris Maglione <jg@suckless.org>
Date: Sun, 25 May 2008 21:53:14 -0400
Some hacky changes to select up/down for collapsed frames. See rc.wmii for new bindings.
Diffstat:
10 files changed, 157 insertions(+), 49 deletions(-)
diff --git a/TODO b/TODO
@@ -1,14 +1,10 @@
BUGS
* collapsed clients outside stacked mode don't always uncollapse when they receive focus
-* resizing within a column affects clients it shouldn't (seems to average client size?)
-* geometry goes wacky with lots of clients in one column
* various qiv brokenness
* dosbox won't grab the mouse
4.0
* Opaque managed moves. I know I've argued against it, but it may be doable.
-* Regex-based tag strings
* Resizable managed area
-* Grow and shrink ctl commands
* New dmenu, with real cursor; snarfable.
diff --git a/cmd/wmii/column.c b/cmd/wmii/column.c
@@ -56,23 +56,89 @@ column_insert(Area *a, Frame *f, Frame *pos) {
area_setsel(a, f);
}
-void
-column_attach(Area *a, Frame *f) {
- uint nframe;
- Frame *ft;
+/* Temporary. */
+static void
+stack_scale(Frame *first, int height) {
+ Frame *f;
+ Area *a;
+ uint dy;
+ int surplus;
+
+ a = first->area;
+
+ /*
+ * Will need something like this.
+ column_fit(a, &ncol, &nuncol);
+ */
+
+ dy = 0;
+ for(f=first; f && !f->collapsed; f=f->anext)
+ dy += Dy(f->colr);
+
+ /* Distribute the surplus.
+ */
+ surplus = height - dy;
+ for(f=first; f && !f->collapsed; f=f->anext)
+ f->colr.max.y += ((float)Dy(f->r) / dy) * surplus;
+}
+
+static void
+stack_info(Frame *f, Frame **firstp, int *dyp, int *nframep) {
+ Frame *ft, *first;
+ int dy, nframe;
nframe = 0;
- for(ft=a->frame; ft; ft=ft->anext)
+ dy = 0;
+ for(ft=f; ft && !ft->collapsed; ft=ft->aprev) {
+ first = ft;
+ nframe++;
+ dy += Dy(ft->colr);
+ }
+ for(ft=f->anext; ft && !ft->collapsed; ft=ft->anext) {
+ if(first == nil)
+ first = ft;
nframe++;
- nframe = max(nframe, 1);
+ dy += Dy(ft->colr);
+ }
+ if(nframep) *nframep = nframe;
+ if(firstp) *firstp = first;
+ if(dyp) *dyp = dy;
+}
+
+void
+column_attach(Area *a, Frame *f) {
+ Frame *first;
+ int nframe, dy, h;
f->colr = a->r;
- f->colr.max.y = Dy(a->r) / nframe;
+
+ if(a->sel) {
+ stack_info(a->sel, &first, &dy, &nframe);
+ h = dy / (nframe+1);
+ f->colr.max.y = f->colr.min.y + h;
+ stack_scale(first, dy - h);
+ }
column_insert(a, f, a->sel);
column_arrange(a, false);
}
+void
+column_detach(Frame *f) {
+ Frame *first;
+ Area *a;
+ int dy;
+
+ a = f->area;
+ stack_info(f, &first, &dy, nil);
+ column_remove(f);
+ if(a->frame) {
+ stack_scale(first, dy);
+ column_arrange(a, false);
+ }else if(a->view->area->next->next)
+ area_destroy(a);
+}
+
static void column_scale(Area*);
void
@@ -124,18 +190,6 @@ column_remove(Frame *f) {
}
}
-void
-column_detach(Frame *f) {
- Area *a;
-
- a = f->area;
- column_remove(f);
- if(a->frame)
- column_arrange(a, false);
- else if(a->view->area->next->next)
- area_destroy(a);
-}
-
static int
column_surplus(Area *a) {
Frame *f;
diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h
@@ -206,8 +206,8 @@ Window* constraintwin(Rectangle);
void destroyconstraintwin(Window*);
void grab_button(XWindow, uint button, ulong mod);
void mouse_checkresize(Frame*, Point, bool);
-void mouse_movegrabbox(Client*);
-void mouse_resize(Client*, Align);
+void mouse_movegrabbox(Client*, bool);
+void mouse_resize(Client*, Align, bool);
void mouse_resizecol(Divide*);
bool readmotion(Point*);
int readmouse(Point*, uint*);
diff --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c
@@ -158,7 +158,7 @@ bdown_event(Window *w, XButtonEvent *e) {
switch(e->button) {
case Button1:
focus(c, false);
- mouse_resize(c, Center);
+ mouse_resize(c, Center, true);
break;
case Button2:
frame_restack(f, nil);
@@ -168,7 +168,7 @@ bdown_event(Window *w, XButtonEvent *e) {
break;
case Button3:
focus(c, false);
- mouse_resize(c, quadrant(f->r, Pt(e->x_root, e->y_root)));
+ mouse_resize(c, quadrant(f->r, Pt(e->x_root, e->y_root)), true);
break;
default:
XAllowEvents(display, ReplayPointer, e->time);
diff --git a/cmd/wmii/layout.c b/cmd/wmii/layout.c
@@ -5,6 +5,7 @@
#include "fns.h"
/* Here be dragons. */
+/* Actually, I'm happy to say, the dragons have dissipated. */
enum {
ButtonMask =
@@ -241,12 +242,20 @@ trampoline(int fn, Frame *f) {
}
void
-mouse_movegrabbox(Client *c) {
+mouse_movegrabbox(Client *c, bool grabmod) {
Frame *f;
+ Point p;
+ float x, y;
int incmode;
f = c->sel;
+ if(grabmod) {
+ p = querypointer(f->client->framewin);
+ x = (float)p.x / Dx(f->r);
+ y = (float)p.y / Dy(f->r);
+ }
+
incmode = def.incmode;
def.incmode = IShow;
view_update(f->view);
@@ -259,7 +268,11 @@ mouse_movegrabbox(Client *c) {
def.incmode = incmode;
view_update(f->view);
- warppointer(grabboxcenter(f));
+ if(grabmod)
+ warppointer(addpt(f->r.min, Pt(x * Dx(f->r),
+ y * Dy(f->r))));
+ else
+ warppointer(grabboxcenter(f));
}
static int
@@ -336,6 +349,8 @@ column_drop(Area *a, Frame *f, int y) {
if(a->frame == nil || y <= a->frame->r.min.y) {
f->collapsed = true;
+ f->colr.min.y = 0;
+ f->colr.max.y = labelh(def.font);
column_openstack(a, nil, labelh(def.font));
column_insert(a, f, nil);
return;
@@ -370,15 +385,15 @@ thcol(Frame *f) {
focus(f->client, false);
+ ret = TDone;
+ if(!grabpointer(&scr.root, nil, cursor[CurIcon], MouseMask))
+ return TDone;
+
pt = querypointer(&scr.root);
pt2.x = f->area->r.min.x;
pt2.y = pt.y;
fw = framewin(f, pt2, OHoriz, Dx(f->area->r));
- ret = TDone;
- if(!grabpointer(&scr.root, nil, cursor[CurIcon], MouseMask))
- goto done;
-
vplace(fw, pt);
for(;;)
switch (readmouse(&pt, &button)) {
@@ -509,10 +524,10 @@ tfloat(Frame *f) {
pt = querypointer(&scr.root);
pt1 = grabboxcenter(f);
goto casmotion;
-label:
+shut_up_ken:
for(;;pt1=pt)
switch (readmouse(&pt, &button)) {
- default: goto label; /* shut up ken */
+ default: goto shut_up_ken;
case MotionNotify:
casmotion:
origin = rectaddpt(origin, subpt(pt, pt1));
diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c
@@ -822,22 +822,51 @@ msg_selectframe(Frame *f, IxpMsg *m, int sym) {
Client *c;
Area *a;
char *s;
- ulong i;
+ bool stack;
+ ulong i, dy;
if(!f)
return Ebadvalue;
a = f->area;
+ stack = false;
+ if(sym == LUP || sym == LDOWN) {
+ s = msg_getword(m);
+ if(s)
+ if(!strcmp(s, "stack"))
+ stack = true;
+ else
+ return Ebadvalue;
+ }
+
SET(fp);
switch(sym) {
case LUP:
- for(fp=a->frame; fp->anext; fp=fp->anext)
- if(fp->anext == f) break;
+ /* XXX */
+ if(stack) {
+ for(; f->aprev && f->aprev->collapsed; f=f->aprev)
+ ;
+ for(fp=a->frame; fp->anext; fp=fp->anext)
+ if(fp->anext == f) break;
+ for(; fp->aprev && fp->collapsed; fp=fp->aprev)
+ ;
+ }else
+ for(fp=a->frame; fp->anext; fp=fp->anext)
+ if(fp->anext == f) break;
break;
case LDOWN:
- fp = f->anext;
- if(fp == nil)
- fp = a->frame;
+ /* XXX */
+ if(stack) {
+ for(fp=f->anext; fp && fp->collapsed; fp=fp->anext)
+ ;
+ if(fp == nil)
+ for(fp=a->frame; fp->collapsed; fp=fp->anext)
+ ;
+ }else {
+ fp = f->anext;
+ if(fp == nil)
+ fp = a->frame;
+ }
break;
case LCLIENT:
s = msg_getword(m);
@@ -854,11 +883,20 @@ msg_selectframe(Frame *f, IxpMsg *m, int sym) {
if(fp == nil)
return "invalid selection";
+ if(fp == f)
+ return nil;
+ /* XXX */
+ if(fp->collapsed && !f->area->floating) {
+ dy = Dy(f->colr);
+ f->colr.max.y = f->colr.min.y + Dy(fp->colr);
+ fp->colr.max.y = fp->colr.min.y + dy;
+ column_arrange(a, false);
+ }
frame_focus(fp);
frame_restack(fp, nil);
- if(f->view == screen->sel)
- view_restack(f->view);
+ if(fp->view == screen->sel)
+ view_restack(fp->view);
return nil;
}
diff --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c
@@ -350,7 +350,7 @@ done:
}
void
-mouse_resize(Client *c, Align align) {
+mouse_resize(Client *c, Align align, bool grabmod) {
Rectangle *rects;
Rectangle frect, origin;
Align grav;
@@ -365,7 +365,7 @@ mouse_resize(Client *c, Align align) {
return;
if(!f->area->floating) {
if(align==Center)
- mouse_movegrabbox(c);
+ mouse_movegrabbox(c, grabmod);
else
mouse_resizecolframe(f, align);
return;
@@ -587,14 +587,14 @@ mouse_checkresize(Frame *f, Point p, bool exec) {
q = quadrant(r, p);
if(rect_haspoint_p(p, f->grabbox)) {
cur = cursor[CurMove];
- if(exec) mouse_movegrabbox(f->client);
+ if(exec) mouse_movegrabbox(f->client, false);
}
else if(f->area->floating) {
if(p.x <= 2 || p.y <= 2
|| r.max.x - p.x <= 2
|| r.max.y - p.y <= 2) {
cur = quad_cursor(q);
- if(exec) mouse_resize(f->client, q);
+ if(exec) mouse_resize(f->client, q, false);
}
}else {
if(f->aprev && p.y <= 2
diff --git a/cmd/wmii/xext.c b/cmd/wmii/xext.c
@@ -117,6 +117,8 @@ bool
render_argb_p(Visual *v) {
XRenderPictFormat *f;
+ if(!have_render)
+ return false;
f = XRenderFindVisualFormat(display, v);
return f
&& f->type == PictTypeDirect
diff --git a/mk/gcc.mk b/mk/gcc.mk
@@ -5,8 +5,7 @@ DEBUGCFLAGS = \
-fno-inline \
-fno-omit-frame-pointer \
-fno-optimize-sibling-calls \
- -fno-unroll-loops \
- -DIXPlint
+ -fno-unroll-loops
CFLAGS += \
-std=c99 \
-pedantic \
diff --git a/rc/rc.wmii.rc b/rc/rc.wmii.rc
@@ -176,6 +176,10 @@ key $MODKEY-$DOWN || fn $key {
wmiir xwrite /tag/sel/ctl select down}
key $MODKEY-$UP || fn $key {
wmiir xwrite /tag/sel/ctl select up}
+key $MODKEY-Control-$DOWN || fn $key {
+ wmiir xwrite /tag/sel/ctl select down stack}
+key $MODKEY-Control-$UP || fn $key {
+ wmiir xwrite /tag/sel/ctl select up stack}
key $MODKEY-Shift-$LEFT || fn $key {
wmiir xwrite /tag/sel/ctl send sel left}