[hackers] [wmii] Fixed cycling of floating frames, and stacking issues on 'send toggle'

From: Kris Maglione <jg_AT_suckless.org>
Date: Fri Feb 09 02:35:25 2007

changeset: 1789:b3d475b0ce82
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Thu Feb 08 20:31:12 2007 -0500
summary: Fixed cycling of floating frames, and stacking issues on 'send toggle'

diff -r 55deb7f197d6 -r b3d475b0ce82 area.c
--- a/area.c Thu Feb 08 13:40:16 2007 -0500
+++ b/area.c Thu Feb 08 20:31:12 2007 -0500
@@ -217,7 +217,7 @@ void
 void
 attach_to_area(Area *a, Frame *f, Bool send) {
         unsigned int h, n_frame;
- Frame **fa, *ft;
+ Frame *ft;
         Client *c;
         View *v;
 
@@ -242,10 +242,11 @@ attach_to_area(Area *a, Frame *f, Bool s
                         arrange_view(v);
                 }
         }
- fa = a->sel ? &a->sel->anext : &a->frame;
- f->anext = *fa;
- *fa = f;
         f->area = a;
+ if(a->sel)
+ insert_frame(nil, f, False);
+ else
+ insert_frame(a->sel, f, False);
         a->sel = f;
         if(!c->floating) { /* column */
                 f->rect.height = h;
@@ -256,7 +257,7 @@ attach_to_area(Area *a, Frame *f, Bool s
 
 void
 detach_from_area(Area *a, Frame *f) {
- Frame **ft, *pr;
+ Frame *pr;
         Client *c;
         View *v;
         Area *ta;
@@ -264,16 +265,16 @@ detach_from_area(Area *a, Frame *f) {
 
         v = a->view;
         c = f->client;
- pr = nil;
-
- for(ft=&a->frame; *ft; ft=&(*ft)->anext) {
- if(*ft == f) break;
- pr = *ft;
- }
- assert(*ft == f);
- *ft = f->anext;
- if(a->sel == f)
- a->sel = pr ? pr : *ft;
+
+ for(pr = a->frame; pr; pr = pr->anext)
+ if(pr == f) break;
+ remove_frame(f);
+ if(a->sel == f) {
+ a->sel = pr;
+ if(f->anext)
+ a->sel = f->anext;
+ }
+
         if(!a->floating) {
                 if(a->frame)
                         arrange_column(a, False);
@@ -285,7 +286,7 @@ detach_from_area(Area *a, Frame *f) {
                                 destroy_area(a);
                         else if(!a->frame && v->area->frame) {
                                 /* focus floating area if it contains something */
- v->sel = v->area;
+ focus(v->area->sel->client, False);
                                 write_event("FocusFloating\n");
                         }
                         arrange_view(v);
@@ -299,11 +300,11 @@ detach_from_area(Area *a, Frame *f) {
                         if(cl && cl->frame) {
                                 a = cl->sel->area;
                                 if(a->view == v)
- v->sel = a;
+ focus(a->sel->client, False);
                         }
                 }
                 else if(v->area->next->frame)
- v->sel = v->area->next; /* focus first col as fallback */
+ focus(v->area->next->sel->client, False); /* focus first col as fallback */
                 i = 0;
                 for(ta=v->area; ta && ta != v->sel; ta=ta->next)
                         i++;
@@ -323,7 +324,7 @@ select_area(Area *a, char *arg) {
         v = a->view;
         f = a->sel;
         if(!strncmp(arg, "toggle", 7)) {
- if(a != v->area)
+ if(!a->floating)
                         new = v->area;
                 else if(v->revert)
                         new = v->revert;
diff -r 55deb7f197d6 -r b3d475b0ce82 client.c
--- a/client.c Thu Feb 08 13:40:16 2007 -0500
+++ b/client.c Thu Feb 08 20:31:12 2007 -0500
@@ -614,11 +614,9 @@ send_client(Frame *f, char *arg) {
         }else
                 return Ebadvalue;
         flush_masked_events(EnterWindowMask);
+ if(f->view == screen->sel)
+ focus(f->client, True);
         update_views();
- if(f->view == screen->sel) {
- focus_client(f->client, False);
- focus_view(screen, f->view);
- }
         return nil;
 }
 
diff -r 55deb7f197d6 -r b3d475b0ce82 frame.c
--- a/frame.c Thu Feb 08 13:40:16 2007 -0500
+++ b/frame.c Thu Feb 08 20:31:12 2007 -0500
@@ -44,21 +44,34 @@ remove_frame(Frame *f) {
         for(ft = &a->frame; *ft; ft=&(*ft)->anext)
                 if(*ft == f) break;
         *ft = f->anext;
+
+ if(a->floating) {
+ for(ft = &a->stack; *ft; ft=&(*ft)->snext)
+ if(*ft == f) break;
+ *ft = f->snext;
+ }
 }
 
 void
 insert_frame(Frame *pos, Frame *f, Bool before) {
+ Frame *ft, **p;
         Area *a = f->area;
 
         if(before) {
- Frame *ft;
                 for(ft=a->frame; ft; ft=ft->anext)
                         if(ft->anext == pos) break;
                 pos=ft;
         }
- Frame **p = pos ? &pos->anext : &a->frame;
+ p = &a->frame;
+ if(pos)
+ p = &pos->anext;
         f->anext = *p;
         *p = f;
+
+ if(a->floating) {
+ f->snext = a->stack;
+ a->stack = f;
+ }
 }
 
 void
@@ -90,11 +103,11 @@ frame_to_top(Frame *f) {
         a = f->area;
         if(!a->floating)
                 return;
- for(tf=&a->frame; *tf; tf=&(*tf)->anext)
+ for(tf=&a->stack; *tf; tf=&(*tf)->snext)
                 if(*tf == f) break;
- *tf = f->anext;
- f->anext = a->frame;
- a->frame = f;
+ *tf = f->snext;
+ f->snext = a->stack;
+ a->stack = f;
 }
 
 void
diff -r 55deb7f197d6 -r b3d475b0ce82 view.c
--- a/view.c Thu Feb 08 13:40:16 2007 -0500
+++ b/view.c Thu Feb 08 20:31:12 2007 -0500
@@ -183,14 +183,14 @@ restack_view(View *v) {
         }
 
         wins[0] = screen->barwin;
- for(a=v->area; a; a=a->next) {
+ for(f=v->area->stack; f; f=f->snext)
+ wins[n++] = f->client->framewin;;
+ for(a=v->area->next; a; a=a->next) {
                 if(a->frame) {
                         wins[n++] = a->sel->client->framewin;
- for(f=a->frame; f; f=f->anext) {
- Client *c = f->client;
+ for(f=a->frame; f; f=f->anext)
                                 if(f != a->sel)
- wins[n++] = c->framewin;
- }
+ wins[n++] = f->client->framewin;;
                 }
         }
         if(n)
diff -r 55deb7f197d6 -r b3d475b0ce82 wmii.h
--- a/wmii.h Thu Feb 08 13:40:16 2007 -0500
+++ b/wmii.h Thu Feb 08 20:31:12 2007 -0500
@@ -106,6 +106,7 @@ struct Area {
 struct Area {
         Area *next;
         Frame *frame;
+ Frame *stack;
         Frame *sel;
         View *view;
         Bool floating;
@@ -117,6 +118,7 @@ struct Frame {
 struct Frame {
         Frame *cnext;
         Frame *anext;
+ Frame *snext;
         View *view;
         Area *area;
         unsigned short id;
Received on Fri Feb 09 2007 - 02:35:25 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:01 UTC