[hackers] [wmii] Draw the bar for each Xinerama screen || Kris Maglione

From: <hg_AT_suckless.org>
Date: Tue, 14 Oct 2008 06:55:33 +0000 (UTC)

changeset: 2363:20adda22f741
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Tue Oct 14 02:55:29 2008 -0400
files: cmd/wmii/area.c cmd/wmii/bar.c cmd/wmii/float.c cmd/wmii/fns.h cmd/wmii/view.c
description:
Draw the bar for each Xinerama screen

diff -r 05c8f936ecf2 -r 20adda22f741 cmd/wmii/area.c
--- a/cmd/wmii/area.c Tue Oct 14 02:13:28 2008 -0400
+++ b/cmd/wmii/area.c Tue Oct 14 02:55:29 2008 -0400
@@ -49,57 +49,55 @@
 }
 
 Area*
-area_create(View *v, Area *pos, int scrn, uint w) {
+area_create(View *v, Area *pos, int scrn, uint width) {
         static ushort id = 1;
         uint i;
         uint minwidth;
- int colnum;
+ int numcols;
         Area *a;
 
+ SET(i);
         if(v->areas) { /* Creating a column. */
                 minwidth = Dx(v->r)/NCOL;
- i = v->floating == nil;
- if(pos)
- i = area_idx(pos);
-
- colnum = 0;
+ i = pos ? area_idx(pos) : 1;
+ numcols = 0;
                 for(a=v->areas[scrn]; a; a=a->next)
- colnum++;
+ numcols++;
 
                 /* TODO: Need a better sizing/placing algorithm.
                  */
- if(w == 0) {
- if(colnum >= 0) {
- w = view_newcolw(v, i);
- if (w == 0)
- w = Dx(v->r) / (colnum + 1);
+ if(width == 0) {
+ if(numcols >= 0) {
+ width = view_newcolwidth(v, i);
+ if (width == 0)
+ width = Dx(v->r) / (numcols + 1);
                         }
                         else
- w = Dx(v->r);
+ width = Dx(v->r);
                 }
 
- if(w < minwidth)
- w = minwidth;
- if(colnum && (colnum * minwidth + w) > Dx(v->r))
+ if(width < minwidth)
+ width = minwidth;
+ if(numcols && (numcols * minwidth + width) > Dx(v->r))
                         return nil;
 
- view_scale(v, Dx(v->r) - w);
+ view_scale(v, Dx(v->r) - width);
         }
 
         a = emallocz(sizeof *a);
         a->view = v;
+ a->screen = scrn;
         a->id = id++;
         if(v->areas)
                 a->mode = def.colmode;
         else
                 a->mode = Coldefault;
- a->screen = scrn;
         a->frame = nil;
         a->sel = nil;
 
         a->r = v->r;
         a->r.min.x = 0;
- a->r.max.x = w;
+ a->r.max.x = width;
 
         if(!v->floating) {
                 v->floating = a;
@@ -118,7 +116,7 @@
         if(a->next)
                 a->next->prev = a;
 
- if(v->sel == nil)
+ if(v->sel == nil && !a->floating)
                 area_focus(a);
 
         if(!a->floating)
@@ -128,7 +126,7 @@
 
 void
 area_destroy(Area *a) {
- Area *ta;
+ Area *newfocus;
         View *v;
         int idx;
 
@@ -145,25 +143,26 @@
         idx = area_idx(a);
 
         if(a->prev && !a->prev->floating)
- ta = a->prev;
+ newfocus = a->prev;
         else
- ta = a->next;
+ newfocus = a->next;
 
         /* Can only destroy the floating area when destroying a
          * view---after destroying all columns.
          */
- assert(a->prev || a->next == nil);
+ assert(!a->floating || a->prev || a->next);
         if(a->prev)
                 a->prev->next = a->next;
+ else
+ v->areas[a->screen] = a->next;
         if(a->next)
                 a->next->prev = a->prev;
 
- if(ta && v->sel == a)
- area_focus(ta);
+ if(newfocus && v->sel == a)
+ area_focus(newfocus);
+
         view_arrange(v);
         event("DestroyArea %d\n", idx);
- /* Deprecated */
- event("DestroyColumn %d\n", idx);
 
         free(a);
 }
@@ -186,9 +185,9 @@
         /* Temporary kludge. */
         if(!to->floating
         && to->floating != fromfloating
- && !eqrect(f->colr, ZR)) {
+ && !eqrect(f->colr, ZR))
                 column_attachrect(to, f, f->colr);
- }else
+ else
                 area_attach(to, f);
 }
 
@@ -197,10 +196,12 @@
         View *v;
 
         v = a->view;
+ /* XXX: Stack. */
         for(; f && f->collapsed && f->anext; f=f->anext)
                 ;
         for(; f && f->collapsed && f->aprev; f=f->aprev)
                 ;
+
         if(a == v->sel && f)
                 frame_focus(f);
         else
@@ -255,6 +256,7 @@
                 return;
 
         v->sel = a;
+ /* XXX: Multihead. */
         if(!a->floating)
                 v->selcol = area_idx(a);
         if(a != old_a)
diff -r 05c8f936ecf2 -r 20adda22f741 cmd/wmii/bar.c
--- a/cmd/wmii/bar.c Tue Oct 14 02:13:28 2008 -0400
+++ b/cmd/wmii/bar.c Tue Oct 14 02:55:29 2008 -0400
@@ -250,7 +250,7 @@
 static void
 expose_event(Window *w, XExposeEvent *e) {
         USED(w, e);
- bar_draw(screen);
+ bar_draw(w->aux);
 }
 
 static Handlers handlers = {
diff -r 05c8f936ecf2 -r 20adda22f741 cmd/wmii/float.c
--- a/cmd/wmii/float.c Tue Oct 14 02:13:28 2008 -0400
+++ b/cmd/wmii/float.c Tue Oct 14 02:55:29 2008 -0400
@@ -31,7 +31,6 @@
         a = f->area;
         sel = view_findarea(v, v->selcol, false);
         oldsel = v->oldsel;
- if(!(sel || !v->areas[a->screen]->next)) warning("%s:%d: !(sel || !v->area->next)", __FILE__, __LINE__);
         pr = f->aprev;
 
         frame_remove(f);
@@ -76,6 +75,7 @@
                         f->collapsed = (f != a->sel);
                 break;
         default:
+ print("colmode: %x\n", a->mode);
                 die("not reached");
                 break;
         }
diff -r 05c8f936ecf2 -r 20adda22f741 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Tue Oct 14 02:13:28 2008 -0400
+++ b/cmd/wmii/fns.h Tue Oct 14 02:55:29 2008 -0400
@@ -235,7 +235,7 @@
 char* view_index(View*);
 void view_init(View*, int iscreen);
 char** view_names(void);
-uint view_newcolw(View*, int i);
+uint view_newcolwidth(View*, int i);
 void view_restack(View*);
 void view_scale(View*, int w);
 Client* view_selclient(View*);
diff -r 05c8f936ecf2 -r 20adda22f741 cmd/wmii/view.c
--- a/cmd/wmii/view.c Tue Oct 14 02:13:28 2008 -0400
+++ b/cmd/wmii/view.c Tue Oct 14 02:55:29 2008 -0400
@@ -495,6 +495,7 @@
                 /* This is wrong... */
                 a->r.min.y = v->r.min.y;
                 a->r.max.y = v->r.max.y;
+ print("a->r: %R %R %R\n", a->r, v->r, screen->r);
                 column_arrange(a, false);
         }
         if(v == screen->sel)
@@ -541,7 +542,7 @@
 }
 
 uint
-view_newcolw(View *v, int num) {
+view_newcolwidth(View *v, int num) {
         Rule *r;
         char *toks[16];
         char buf[sizeof r->value];
Received on Tue Oct 14 2008 - 06:55:33 UTC

This archive was generated by hypermail 2.2.0 : Tue Oct 14 2008 - 07:00:07 UTC