[hackers] [wmii] More of the previous. Add wrapping. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Mon, 20 Oct 2008 00:50:14 +0000 (UTC)

changeset: 2397:f996653c3859
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sun Oct 19 20:50:13 2008 -0400
files: cmd/wmii/area.c cmd/wmii/column.c cmd/wmii/fns.h cmd/wmii/message.c cmd/wmii/screen.c
description:
More of the previous. Add wrapping.

diff -r 49001679f1bc -r f996653c3859 cmd/wmii/area.c
--- a/cmd/wmii/area.c Sun Oct 19 18:46:02 2008 -0400
+++ b/cmd/wmii/area.c Sun Oct 19 20:50:13 2008 -0400
@@ -37,7 +37,7 @@
 }
 
 Area*
-area_find(View *v, Rectangle r, int dir) {
+area_find(View *v, Rectangle r, int dir, bool wrap) {
         static Vector_ptr vec;
         Area *a;
         int s;
@@ -46,7 +46,7 @@
         foreach_column(v, s, a)
                 vector_ppush(&vec, a);
 
- return findthing(r, dir, &vec, area_rect);
+ return findthing(r, dir, &vec, area_rect, wrap);
 }
 
 int
diff -r 49001679f1bc -r f996653c3859 cmd/wmii/column.c
--- a/cmd/wmii/column.c Sun Oct 19 18:46:02 2008 -0400
+++ b/cmd/wmii/column.c Sun Oct 19 20:50:13 2008 -0400
@@ -212,7 +212,7 @@
 
 /* TODO: Move elsewhere. */
 bool
-find(Area **ap, Frame **fp, int dir) {
+find(Area **ap, Frame **fp, int dir, bool wrap) {
         Rectangle r;
         Frame *f;
         Area *a;
@@ -225,7 +225,7 @@
                 *fp = stack_find(a, f, dir);
                 if(*fp)
                         return true;
- *ap = area_find(a->view, r, dir);
+ *ap = area_find(a->view, r, dir, wrap);
                 if(!*ap)
                         return false;
                 *fp = stack_find(*ap, *fp, dir);
@@ -233,7 +233,7 @@
         }
         if(dir != East && dir != West)
                 die("not reached");
- *ap = area_find(a->view, r, dir);
+ *ap = area_find(a->view, r, dir, wrap);
         if(!*ap)
                 return false;
         *fp = ap[0]->sel;
diff -r 49001679f1bc -r f996653c3859 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Sun Oct 19 18:46:02 2008 -0400
+++ b/cmd/wmii/fns.h Sun Oct 19 20:50:13 2008 -0400
@@ -40,7 +40,7 @@
 Area* area_create(View*, Area *pos, int scrn, uint w);
 void area_destroy(Area*);
 void area_detach(Frame*);
-Area* area_find(View*, Rectangle, int);
+Area* area_find(View*, Rectangle, int, bool);
 void area_focus(Area*);
 int area_idx(Area*);
 void area_moveto(Area*, Frame*);
@@ -109,7 +109,7 @@
 void div_draw(Divide*);
 void div_set(Divide*, int x);
 void div_update_all(void);
-bool find(Area**, Frame**, int);
+bool find(Area**, Frame**, int, bool);
 int stack_count(Frame*, int*);
 Frame* stack_find(Area*, Frame*, int);
 
@@ -247,7 +247,7 @@
 void root_init(void);
 
 /* screen.c */
-void* findthing(Rectangle, int, Vector_ptr*, Rectangle(*)(void*));
+void* findthing(Rectangle, int, Vector_ptr*, Rectangle(*)(void*), bool);
 int ownerscreen(Rectangle);
 
 /* rule.c */
diff -r 49001679f1bc -r f996653c3859 cmd/wmii/message.c
--- a/cmd/wmii/message.c Sun Oct 19 18:46:02 2008 -0400
+++ b/cmd/wmii/message.c Sun Oct 19 20:50:13 2008 -0400
@@ -917,7 +917,7 @@
                         return Ebadvalue;
         }
         else {
- if(!find(&a, &f, DIR(sym)))
+ if(!find(&a, &f, DIR(sym), true))
                         return Ebadvalue;
         }
 
@@ -927,7 +927,8 @@
                 return nil;
 
         /* XXX */
- if(a == fp->area && f->collapsed && !f->area->floating && f->area->mode == Coldefault) {
+ if(fp && fp->area == a)
+ if(f->collapsed && !f->area->floating && f->area->mode == Coldefault) {
                 dy = Dy(f->colr);
                 f->colr.max.y = f->colr.min.y + Dy(fp->colr);
                 fp->colr.max.y = fp->colr.min.y + dy;
@@ -937,7 +938,7 @@
         frame_focus(f);
         frame_restack(f, nil);
         if(f->view == selview)
- view_restack(fp->view);
+ view_restack(a->view);
         return nil;
 }
 
diff -r 49001679f1bc -r f996653c3859 cmd/wmii/screen.c
--- a/cmd/wmii/screen.c Sun Oct 19 18:46:02 2008 -0400
+++ b/cmd/wmii/screen.c Sun Oct 19 20:50:13 2008 -0400
@@ -79,8 +79,38 @@
 }
 #endif
 
+static Rectangle
+leastthing(Rectangle rect, int direction, Vector_ptr *vec, Rectangle (*key)(void*)) {
+ void *p;
+ Rectangle r;
+ Point pt;
+ int i, best, d;
+
+ SET(d);
+ for(i=0; i < vec->n; i++) {
+ p = vec->ary[i];
+ r = key(p);
+ switch(direction) {
+ case South: d = r.min.y; break;
+ case North: d = -r.max.y; break;
+ case East: d = r.min.x; break;
+ case West: d = -r.max.x; break;
+ }
+ if(i == 0 || d < best)
+ best = d;
+ }
+ pt = rect.min;
+ switch(direction) {
+ case South: pt.y = best - Dy(rect); break;
+ case North: pt.y = -best + Dy(rect); break;
+ case East: pt.x = best - Dy(rect); break;
+ case West: pt.x = -best + Dy(rect); break;
+ }
+ return rectsetorigin(rect, pt);
+}
+
 void*
-findthing(Rectangle rect, int direction, Vector_ptr *vec, Rectangle (*key)(void*)) {
+findthing(Rectangle rect, int direction, Vector_ptr *vec, Rectangle (*key)(void*), bool wrap) {
         Rectangle isect;
         Rectangle r, bestisect, bestr;
         void *best, *p;
@@ -125,6 +155,10 @@
                 }
         }
 #undef frob
+ if(!best && wrap) {
+ r = leastthing(rect, direction, vec, key);
+ return findthing(r, direction, vec, key, false);
+ }
         return best;
 }
 
Received on Mon Oct 20 2008 - 00:50:14 UTC

This archive was generated by hypermail 2.2.0 : Mon Oct 20 2008 - 01:00:07 UTC