changeset: 2384:1f19e60bd76c
user: Kris Maglione <jg_AT_suckless.org>
date: Fri Oct 17 10:39:13 2008 -0400
files: cmd/wmii.rc.rc cmd/wmii/area.c cmd/wmii/bar.c cmd/wmii/client.c cmd/wmii/column.c cmd/wmii/dat.h cmd/wmii/div.c cmd/wmii/event.c cmd/wmii/ewmh.c cmd/wmii/float.c cmd/wmii/fns.h cmd/wmii/frame.c cmd/wmii/fs.c cmd/wmii/key.c cmd/wmii/layout.c cmd/wmii/main.c cmd/wmii/message.c cmd/wmii/mouse.c cmd/wmii/view.c
description:
Be smarter in EWMH strut allocation. Some smaller fixes.
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii.rc.rc
--- a/cmd/wmii.rc.rc Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii.rc.rc Fri Oct 17 10:39:13 2008 -0400
@@ -161,11 +161,13 @@
}
fn Action {
- cmd=$1 action=Action-$cmd { shift
- if(wi_fn-p $action)
- $action $*
- if not
- wi_runcmd `{wi_script $cmd} $*
- }
+ cmd=$1 action=Action-$"cmd { shift
+ if(! ~ $cmd '') {
+ if(wi_fn-p $action)
+ $action $*
+ if not
+ wi_runcmd `{wi_script $cmd} $*
+ }
+ }
}
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/area.c
--- a/cmd/wmii/area.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/area.c Fri Oct 17 10:39:13 2008 -0400
@@ -90,10 +90,11 @@
a->view = v;
a->screen = scrn;
a->id = id++;
- if(v->areas)
+ a->floating = !v->floating;
+ if(a->floating)
+ a->mode = Coldefault;
+ else
a->mode = def.colmode;
- else
- a->mode = Coldefault;
a->frame = nil;
a->sel = nil;
@@ -101,9 +102,8 @@
a->r.min.x = 0;
a->r.max.x = width;
- if(!v->floating) {
+ if(a->floating) {
v->floating = a;
- a->floating = true;
a->screen = -1;
}
else if(pos) {
@@ -273,7 +273,7 @@
view_update(v);
}
- if(v != screen->sel)
+ if(v != selview)
return;
move_focus(old_a->sel, f);
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/bar.c
--- a/cmd/wmii/bar.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/bar.c Fri Oct 17 10:39:13 2008 -0400
@@ -166,16 +166,16 @@
}
r = rectsubpt(s->brect, s->brect.min);
- fill(screen->ibuf, r, def.normcolor.bg);
+ fill(disp.ibuf, r, def.normcolor.bg);
foreach_bar(s, b) {
align = Center;
if(b == s->bar[BRight])
align = East;
- fill(screen->ibuf, b->r, b->col.bg);
- drawstring(screen->ibuf, def.font, b->r, align, b->text, b->col.fg);
- border(screen->ibuf, b->r, 1, b->col.border);
+ fill(disp.ibuf, b->r, b->col.bg);
+ drawstring(disp.ibuf, def.font, b->r, align, b->text, b->col.fg);
+ border(disp.ibuf, b->r, 1, b->col.border);
}
- copyimage(s->barwin, r, screen->ibuf, ZP);
+ copyimage(s->barwin, r, disp.ibuf, ZP);
}
Bar*
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/client.c
--- a/cmd/wmii/client.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/client.c Fri Oct 17 10:39:13 2008 -0400
@@ -265,7 +265,7 @@
r = client_grav(c, ZR);
hide = false;
- if(!c->sel || c->sel->view != screen->sel)
+ if(!c->sel || c->sel->view != selview)
hide = true;
XGrabServer(display);
@@ -312,8 +312,8 @@
Client*
selclient(void) {
- if(screen->sel->sel->sel)
- return screen->sel->sel->sel->client;
+ if(selview->sel->sel)
+ return selview->sel->sel->client;
return nil;
}
@@ -471,7 +471,7 @@
*/
v = f->view;
- if(v != screen->sel)
+ if(v != selview)
view_focus(screen, v);
frame_focus(c->sel);
}
@@ -488,9 +488,9 @@
Dprint(DFocus, "client_focus([%C]%s)\n", c, clientname(c));
Dprint(DFocus, "\t[%C]%s\n\t=> [%C]%s\n",
- screen->focus, clientname(screen->focus),
+ disp.focus, clientname(disp.focus),
c, clientname(c));
- if(screen->focus != c) {
+ if(disp.focus != c) {
if(c) {
if(!c->noinput)
setfocus(&c->w, RevertToParent);
@@ -514,7 +514,7 @@
f = c->sel;
frame_resize(f, r);
- if(f->view != screen->sel) {
+ if(f->view != selview) {
client_unmap(c, IconicState);
unmap_frame(c);
return;
@@ -605,7 +605,7 @@
for(f=c->frame; f; f=f->cnext) {
if(f->oldarea == 0) {
frame_resize(f, f->floatr);
- if(f->view == screen->sel) /* FIXME */
+ if(f->view == selview) /* FIXME */
client_resize(f->client, f->r);
}
@@ -642,7 +642,7 @@
c->urgent = urgent;
ewmh_updatestate(c);
if(c->sel) {
- if(c->sel->view == screen->sel)
+ if(c->sel->view == selview)
frame_draw(c->sel);
for(f=c->frame; f; f=f->cnext) {
SET(ff);
@@ -856,7 +856,7 @@
c = w->aux;
if(e->detail != NotifyInferior) {
if(e->detail != NotifyVirtual)
- if(e->serial != ignoreenter && screen->focus != c) {
+ if(e->serial != ignoreenter && disp.focus != c) {
Dprint(DFocus, "enter_notify([%C]%s)\n", c, c->name);
focus(c, false);
}
@@ -874,10 +874,10 @@
print_focus("focusin_event", c, c->name);
if(e->mode == NotifyGrab)
- screen->hasgrab = c;
+ disp.hasgrab = c;
- old = screen->focus;
- screen->focus = c;
+ old = disp.focus;
+ disp.focus = c;
if(c != old) {
if(c->sel)
frame_draw(c->sel);
@@ -889,12 +889,12 @@
Client *c;
c = w->aux;
- if((e->mode == NotifyWhileGrabbed) && (screen->hasgrab != &c_root)) {
- if(screen->focus)
- screen->hasgrab = screen->focus;
- }else if(screen->focus == c) {
+ if((e->mode == NotifyWhileGrabbed) && (disp.hasgrab != &c_root)) {
+ if(disp.focus)
+ disp.hasgrab = disp.focus;
+ }else if(disp.focus == c) {
print_focus("focusout_event", &c_magic, "<magic>");
- screen->focus = &c_magic;
+ disp.focus = &c_magic;
if(c->sel)
frame_draw(c->sel);
}
@@ -969,7 +969,7 @@
if(*tags) {
if(!*fp || cmp > 0) {
f = frame_create(c, view_create(*tags));
- if(f->view == screen->sel || !c->sel)
+ if(f->view == selview || !c->sel)
c->sel = f;
kludge = c; /* FIXME */
view_attach(f->view, f);
@@ -1111,7 +1111,7 @@
c->floating = add;
else
if(!strcmp(buf+n, "!") || !strcmp(buf+n, "sel"))
- cur = screen->sel->name;
+ cur = selview->name;
else
if(!Mbsearch(buf+n, badtags, bsstrcmp))
cur = buf+n;
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/column.c
--- a/cmd/wmii/column.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/column.c Fri Oct 17 10:39:13 2008 -0400
@@ -481,7 +481,7 @@
for(f=a->frame; f; f=f->anext)
f->r = f->colr;
column_settle(a);
- if(a->view == screen->sel)
+ if(a->view == selview)
for(f=a->frame; f; f=f->anext)
client_resize(f->client, f->r);
}
@@ -563,7 +563,7 @@
/* XXX */
if(a->sel->collapsed)
area_setsel(a, a->sel);
- if(v == screen->sel) {
+ if(v == selview) {
//view_restack(v);
client_resize(a->sel->client, a->sel->r);
for(f=a->frame; f; f=f->anext)
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/dat.h Fri Oct 17 10:39:13 2008 -0400
@@ -324,12 +324,7 @@
EXTERN struct WMScreen {
Bar* bar[2];
- View* sel;
- Client* focus;
- Client* hasgrab;
Window* barwin;
- Image* ibuf;
- Image* ibuf32;
bool showing;
int barpos;
int idx;
@@ -337,9 +332,19 @@
Rectangle r;
Rectangle brect;
} **screens, *screen;
+EXTERN uint nscreens;
+
+EXTERN struct {
+ Client* focus;
+ Client* hasgrab;
+ Image* ibuf;
+ Image* ibuf32;
+ bool sel;
+} disp;
EXTERN Client* client;
EXTERN View* view;
+EXTERN View* selview;
EXTERN Key* key;
EXTERN Divide* divs;
EXTERN Client c_magic;
@@ -361,10 +366,8 @@
EXTERN Ixp9Srv p9srv;
/* X11 */
-EXTERN uint nscreens;
EXTERN uint valid_mask;
EXTERN uint numlock_mask;
-EXTERN bool sel_screen;
EXTERN Image* ibuf;
EXTERN Image* ibuf32;
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/div.c
--- a/cmd/wmii/div.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/div.c Fri Oct 17 10:39:13 2008 -0400
@@ -54,8 +54,8 @@
d->x = x;
r = rectaddpt(divimg->r, Pt(x - Dx(divimg->r)/2, 0));
/* XXX: Multihead. */
- r.min.y = screen->sel->screenr.min.y;
- r.max.y = screen->sel->screenr.max.y;
+ r.min.y = selview->screenr.min.y;
+ r.max.y = selview->screenr.max.y;
reshapewin(d->w, r);
mapdiv(d);
@@ -92,7 +92,7 @@
w = 2 * (labelh(def.font) / 3);
w = max(w, 10);
/* XXX: Multihead. */
- h = Dy(screen->sel->screenr);
+ h = Dy(selview->screenr);
if(divimg) {
if(w == Dx(divimg->r) && h == Dy(divimg->r)
@@ -123,7 +123,7 @@
update_imgs();
- v = screen->sel;
+ v = selview;
dp = &divs;
foreach_area(v, s, a) {
d = getdiv(dp);
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/event.c
--- a/cmd/wmii/event.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/event.c Fri Oct 17 10:39:13 2008 -0400
@@ -174,7 +174,7 @@
if((w = findwin(ev->window)))
handle(w, enter, ev);
else if(ev->window == scr.root.w) {
- sel_screen = true;
+ disp.sel = true;
frame_draw_all();
}
}
@@ -184,16 +184,16 @@
xtime = ev->time;
if((ev->window == scr.root.w) && !ev->same_screen) {
- sel_screen = true;
+ disp.sel = true;
frame_draw_all();
}
}
void
print_focus(const char *fn, Client *c, const char *to) {
- Dprint(DFocus, "%s() screen->focus:\n", fn);
- Dprint(DFocus, "\t%C => %C\n", screen->focus, c);
- Dprint(DFocus, "\t%s => %s\n", clientname(screen->focus), to);
+ Dprint(DFocus, "%s() disp.focus:\n", fn);
+ Dprint(DFocus, "\t%C => %C\n", disp.focus, c);
+ Dprint(DFocus, "\t%s => %s\n", clientname(disp.focus), to);
}
static void
@@ -204,7 +204,7 @@
/* Yes, we're focusing in on nothing, here. */
if(ev->detail == NotifyDetailNone) {
print_focus("focusin", &c_magic, "<magic[none]>");
- screen->focus = &c_magic;
+ disp.focus = &c_magic;
setfocus(screen->barwin, RevertToParent);
return;
}
@@ -215,22 +215,22 @@
||(ev->detail == NotifyInferior)
||(ev->detail == NotifyAncestor)))
return;
- if((ev->mode == NotifyWhileGrabbed) && (screen->hasgrab != &c_root))
+ if((ev->mode == NotifyWhileGrabbed) && (disp.hasgrab != &c_root))
return;
if(ev->window == screen->barwin->w) {
print_focus("focusin", nil, "<nil>");
- screen->focus = nil;
+ disp.focus = nil;
}
else if((w = findwin(ev->window)))
handle(w, focusin, ev);
else if(ev->mode == NotifyGrab) {
if(ev->window == scr.root.w)
- screen->hasgrab = &c_root;
+ disp.hasgrab = &c_root;
/* Some unmanaged window has grabbed focus */
- else if((c = screen->focus)) {
+ else if((c = disp.focus)) {
print_focus("focusin", &c_magic, "<magic>");
- screen->focus = &c_magic;
+ disp.focus = &c_magic;
if(c->sel)
frame_draw(c->sel);
}
@@ -249,7 +249,7 @@
||(ev->detail == NotifyAncestor)))
return;
if(ev->mode == NotifyUngrab)
- screen->hasgrab = nil;
+ disp.hasgrab = nil;
if((ev->mode == NotifyGrab)
&& XCheckMaskEvent(display, KeyPressMask, &me))
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/ewmh.c
--- a/cmd/wmii/ewmh.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/ewmh.c Fri Oct 17 10:39:13 2008 -0400
@@ -312,7 +312,7 @@
Dprint(DEwmh, "\tright: %R\n", c->strut->right);
Dprint(DEwmh, "\tbottom: %R\n", c->strut->bottom);
free(strut);
- view_update(screen->sel);
+ view_update(selview);
}
static void
@@ -439,7 +439,7 @@
int i;
f = c->sel;
- if(f == nil || f->view != screen->sel)
+ if(f == nil || f->view != selview)
return;
i = 0;
@@ -496,7 +496,7 @@
if(starting)
return;
- i = viewidx(screen->sel);
+ i = viewidx(selview);
changeprop_long(&scr.root, Net("CURRENT_DESKTOP"), "CARDINAL", &i, 1);
}
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/float.c
--- a/cmd/wmii/float.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/float.c Fri Oct 17 10:39:13 2008 -0400
@@ -53,7 +53,7 @@
void
float_resizeframe(Frame *f, Rectangle r) {
- if(f->area->view == screen->sel)
+ if(f->area->view == selview)
client_resize(f->client, r);
else
frame_resize(f, r);
@@ -100,12 +100,65 @@
vector_rpush(vec, r);
}
+Vector_rect*
+unique_rects(Vector_rect *vec, Rectangle orig) {
+ static Vector_rect vec1, vec2;
+ Vector_rect *v1, *v2, *v;
+ Rectangle r1, r2;
+ int i, j;
+
+ v1 = &vec1;
+ v2 = &vec2;
+ v1->n = 0;
+ vector_rpush(v1, orig);
+ for(i=0; i < vec->n; i++) {
+ v2->n = 0;
+ r1 = vec->ary[i];
+ for(j=0; j < v1->n; j++) {
+ r2 = v1->ary[j];
+ if(!rect_intersect_p(r1, r2)) {
+ rect_push(v2, r2);
+ continue;
+ }
+ if(r2.min.x < r1.min.x)
+ rect_push(v2, Rect(r2.min.x, r2.min.y, r1.min.x, r2.max.y));
+ if(r2.min.y < r1.min.y)
+ rect_push(v2, Rect(r2.min.x, r2.min.y, r2.max.x, r1.min.y));
+ if(r2.max.x > r1.max.x)
+ rect_push(v2, Rect(r1.max.x, r2.min.y, r2.max.x, r2.max.y));
+ if(r2.max.y > r1.max.y)
+ rect_push(v2, Rect(r2.min.x, r1.max.y, r2.max.x, r2.max.y));
+ }
+ v = v1;
+ v1 = v2;
+ v2 = v;
+ }
+ return v1;
+}
+
+Rectangle
+max_rect(Vector_rect *vec) {
+ Rectangle *r, *rp;
+ int i, a, area;
+
+ area = 0;
+ r = 0;
+ for(i=0; i < vec->n; i++) {
+ rp = &vec->ary[i];
+ a = Dx(*rp) * Dy(*rp);
+ if(a > area) {
+ area = a;
+ r = rp;
+ }
+ }
+ return r ? *r : ZR;
+}
+
static void
float_placeframe(Frame *f) {
- static Vector_rect rvec, rvec2;
- Vector_rect *vp, *vp2, *vptemp;
- Rectangle *rp;
- Rectangle r, fr;
+ static Vector_rect vec;
+ Vector_rect *vp;
+ Rectangle r;
Point dim, p;
Client *c;
Frame *ff;
@@ -125,49 +178,36 @@
return;
}
- dim.x = Dx(f->r);
- dim.y = Dy(f->r);
-
- rvec.n = 0;
- rvec2.n = 0;
- vp = &rvec;
- vp2 = &rvec2;
-
/* Find all rectangles on the floating layer into which
* the new frame would fit.
*/
- vector_rpush(vp, a->r);
- for(ff=a->frame; ff; ff=ff->anext) {
- /* TODO: Find out why this is needed.
+ vec.n = 0;
+ for(ff=a->frame; ff; ff=ff->anext)
+ /* TODO: Find out why this check is needed.
* The frame hasn't been inserted yet, but somehow,
* its old rectangle winds up in the list.
*/
- if(ff->client == f->client)
+ if(ff->client != f->client)
+ vector_rpush(&vec, ff->r);
+ vp = unique_rects(&vec, a->r);
+
+ area = LONG_MAX;
+ dim.x = Dx(f->r);
+ dim.y = Dy(f->r);
+ p = ZP;
+
+ for(i=0; i < vp->n; i++) {
+ r = vp->ary[i];
+ if(Dx(r) < dim.x || Dy(r) < dim.y)
continue;
- fr = ff->r;
- vp2->n = 0;
- for(i=0; i < vp->n; i++) {
- r = vp->ary[i];
- if(!rect_intersect_p(fr, r)) {
- rect_push(vp2, r);
- continue;
- }
- if(r.min.x < fr.min.x && fr.min.x - r.min.x >= dim.x)
- rect_push(vp2, Rect(r.min.x, r.min.y, fr.min.x, r.max.y));
- if(r.max.x > fr.max.x && r.max.x - fr.max.x >= dim.x)
- rect_push(vp2, Rect(fr.max.x, r.min.y, r.max.x, r.max.y));
- if(r.min.y < fr.min.y && fr.min.y - r.min.y >= dim.y)
- rect_push(vp2, Rect(r.min.x, r.min.y, r.max.x, fr.min.y));
- if(r.max.y > fr.max.y && r.max.y - fr.max.y >= dim.y)
- rect_push(vp2, Rect(r.min.x, fr.max.y, r.max.x, r.max.y));
+ l = Dx(r) * Dy(r);
+ if(l < area) {
+ area = l;
+ p = r.min;
}
- vptemp = vp;
- vp = vp2;
- vp2 = vptemp;
}
- p = ZP;
- if(vp->n == 0) {
+ if(area == LONG_MAX) {
/* Cascade. */
ff = a->sel;
if(ff)
@@ -175,16 +215,6 @@
if(p.x + Dx(f->r) > Dx(screen->r) ||
p.y + Dy(f->r) > screen->brect.min.y)
p = ZP;
- }else {
- area = LONG_MAX;
- for(i=0; i < vp->n; i++) {
- rp = &vp->ary[i];
- l = Dx(*rp) * Dy(*rp);
- if(l < area) {
- area = l;
- p = rp->min;
- }
- }
}
f->floatr = rectsetorigin(f->r, p);
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/fns.h Fri Oct 17 10:39:13 2008 -0400
@@ -139,6 +139,8 @@
void float_attach(Area*, Frame*);
void float_detach(Frame*);
void float_resizeframe(Frame*, Rectangle);
+Vector_rect* unique_rects(Vector_rect*, Rectangle);
+Rectangle max_rect(Vector_rect*);
/* frame.c */
Frame* frame_create(Client*, View*);
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/frame.c Fri Oct 17 10:39:13 2008 -0400
@@ -210,7 +210,7 @@
c = w->aux;
f = c->sel;
- if(screen->focus != c || selclient() != c) {
+ if(disp.focus != c || selclient() != c) {
Dprint(DFocus, "enter_notify(f) => [%C]%s%s\n",
f->client, f->client->name, ignoreenter == e->serial ? " (ignored)" : "");
if(e->detail != NotifyInferior)
@@ -425,7 +425,7 @@
uint w;
int n, m;
- if(f->view != screen->sel)
+ if(f->view != selview)
return;
if(f->area == nil) /* Blech. */
return;
@@ -435,7 +435,7 @@
fr = rectsetorigin(c->framewin->r, ZP);
/* Pick colors. */
- if(c == selclient() || c == screen->focus)
+ if(c == selclient() || c == disp.focus)
col = &def.focuscolor;
else
col = &def.normcolor;
@@ -454,7 +454,7 @@
/* Odd focus. Unselected, with keyboard focus. */
/* Draw a border just inside the titlebar. */
- if(c != selclient() && c == screen->focus) {
+ if(c != selclient() && c == disp.focus) {
border(img, insetrect(r, 1), 1, def.normcolor.bg);
border(img, insetrect(r, 2), 1, def.focuscolor.border);
}
@@ -471,7 +471,7 @@
/* Odd focus. Selected, without keyboard focus. */
/* Draw a border around the grabbox. */
- if(c != screen->focus && col == &def.focuscolor)
+ if(c != disp.focus && col == &def.focuscolor)
border(img, insetrect(r, -1), 1, def.normcolor.bg);
/* Draw a border on borderless+titleless selected apps. */
@@ -535,7 +535,7 @@
Client *c;
for(c=client; c; c=c->next)
- if(c->sel && c->sel->view == screen->sel)
+ if(c->sel && c->sel->view == selview)
frame_draw(c->sel);
}
@@ -574,7 +574,7 @@
noinput = (old_f && old_f->client->noinput) ||
(f && f->client->noinput) ||
- screen->hasgrab != &c_root;
+ disp.hasgrab != &c_root;
if(noinput) {
if(old_f)
frame_draw(old_f);
@@ -616,7 +616,7 @@
if(old_a != v->oldsel && f != old_f)
v->oldsel = nil;
- if(v != screen->sel || a != v->sel)
+ if(v != selview || a != v->sel)
return;
move_focus(old_f, f);
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/fs.c
--- a/cmd/wmii/fs.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/fs.c Fri Oct 17 10:39:13 2008 -0400
@@ -278,11 +278,11 @@
break;
case FsDTags:
if(!name || !strcmp(name, "sel")) {
- if(screen->sel) {
+ if(selview) {
push_file("sel");
file->volatil = true;
- file->p.view = screen->sel;
- file->id = screen->sel->id;
+ file->p.view = selview;
+ file->id = selview->id;
}if(name) goto LastItem;
}
for(v=view; v; v=v->next) {
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/key.c
--- a/cmd/wmii/key.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/key.c Fri Oct 17 10:39:13 2008 -0400
@@ -153,7 +153,7 @@
XKeyEvent e;
Client *c;
- c = screen->focus;
+ c = disp.focus;
if(c == nil || c->w.w == 0)
return;
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/layout.c
--- a/cmd/wmii/layout.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/layout.c Fri Oct 17 10:39:13 2008 -0400
@@ -102,7 +102,7 @@
f = w->aux;
c = &def.focuscolor;
- buf = screen->ibuf;
+ buf = disp.ibuf;
r = rectsubpt(w->r, w->r.min);
fill(buf, r, c->bg);
@@ -123,10 +123,10 @@
Area *a;
int s;
- v = screen->sel;
+ v = selview;
/* XXX: Multihead. Check this over. */
for(s=0; s < nscreens; s++) {
- if(!rect_haspoint_p(pt, screen[s].r))
+ if(!rect_haspoint_p(pt, screens[s]->r))
continue;
for(a=v->areas[s]; a; a=a->next)
if(pt.x < a->r.max.x)
@@ -145,7 +145,7 @@
long l;
int hr;
- v = screen->sel;
+ v = selview;
a = find_area(pt);
if(a == nil)
@@ -196,7 +196,7 @@
View *v;
int minw;
- v = screen->sel;
+ v = selview;
a = find_area(pt);
if(a == nil)
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/main.c
--- a/cmd/wmii/main.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/main.c Fri Oct 17 10:39:13 2008 -0400
@@ -191,6 +191,8 @@
ibuf32 = nil; /* Probably shouldn't do this until it's needed. */
if(render_visual)
ibuf32 = allocimage(Dx(scr.rect), Dy(scr.rect), 32);
+ disp.ibuf = ibuf;
+ disp.ibuf32 = ibuf32;
/* Resize and initialize screens. */
for(i=0; i < nscreens; i++) {
@@ -202,14 +204,13 @@
screen->r = rects[i];
else
screen->r = rectsetorigin(screen->r, scr.rect.max);
+ print("screens[%d]->r = %R\n", i, screens[i]->r);
def.snap = Dy(screen->r) / 63;
- screen->ibuf = ibuf;
- screen->ibuf32 = ibuf32;
bar_init(screens[i]);
}
screen = screens[0];
- if(screen->sel)
- view_update(screen->sel);
+ if(selview)
+ view_update(selview);
}
static void
@@ -397,7 +398,7 @@
loadcolor(&def.focuscolor, FOCUSCOLORS);
loadcolor(&def.normcolor, NORMCOLORS);
- sel_screen = pointerscreen();
+ disp.sel = pointerscreen();
init_screens();
@@ -411,7 +412,7 @@
CWEventMask
| CWCursor);
- screen->focus = nil;
+ disp.focus = nil;
setfocus(screen->barwin, RevertToParent);
view_select("1");
@@ -421,7 +422,7 @@
view_update_all();
ewmh_updateviews();
- event("FocusTag %s\n", screen->sel->name);
+ event("FocusTag %s\n", selview->name);
i = ixp_serverloop(&srv);
if(i)
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/message.c
--- a/cmd/wmii/message.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/message.c Fri Oct 17 10:39:13 2008 -0400
@@ -445,13 +445,13 @@
s = msg_getword(m);
if(!setdef(&screen->barpos, s, barpostab, nelem(barpostab)))
return Ebadvalue;
- view_update(screen->sel);
+ view_update(selview);
break;
case LBORDER:
if(!getulong(msg_getword(m), &n))
return Ebadvalue;
def.border = n;
- view_update(screen->sel);
+ view_update(selview);
break;
case LCOLMODE:
s = msg_getword(m);
@@ -467,7 +467,7 @@
break;
case LFOCUSCOLORS:
ret = msg_parsecolors(m, &def.focuscolor);
- view_update(screen->sel);
+ view_update(selview);
break;
case LFONT:
fn = loadfont(m->pos);
@@ -478,7 +478,7 @@
bar_resize(screens[n]);
}else
ret = "can't load font";
- view_update(screen->sel);
+ view_update(selview);
break;
case LGRABMOD:
s = msg_getword(m);
@@ -493,11 +493,11 @@
case LINCMODE:
if(!setdef(&def.incmode, msg_getword(m), incmodetab, nelem(incmodetab)))
return Ebadvalue;
- view_update(screen->sel);
+ view_update(selview);
break;
case LNORMCOLORS:
ret = msg_parsecolors(m, &def.normcolor);
- view_update(screen->sel);
+ view_update(selview);
break;
case LSELCOLORS:
warning("selcolors have been removed");
@@ -546,7 +546,7 @@
bufprint("grabmod %s\n", def.grabmod);
bufprint("incmode %s\n", incmodetab[screen->barpos]);
bufprint("normcolors %s\n", def.normcolor.colstr);
- bufprint("view %s\n", screen->sel->name);
+ bufprint("view %s\n", selview->name);
return buffer;
}
@@ -978,7 +978,7 @@
frame_focus(fp);
frame_restack(fp, nil);
- if(fp->view == screen->sel)
+ if(fp->view == selview)
view_restack(fp->view);
return nil;
}
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/mouse.c Fri Oct 17 10:39:13 2008 -0400
@@ -216,7 +216,7 @@
f->collapsed = false;
- v = screen->sel;
+ v = selview;
d = divs;
for(a=v->firstarea; a != f->area; a=a->next)
d = d->next;
@@ -318,7 +318,7 @@
Point pt;
uint minw;
- v = screen->sel;
+ v = selview;
for(a = v->firstarea, dp = divs; a; a = a->next, dp = dp->next)
if(dp->next == d) break;
diff -r 4a055cc39dd1 -r 1f19e60bd76c cmd/wmii/view.c
--- a/cmd/wmii/view.c Thu Oct 16 20:15:03 2008 -0400
+++ b/cmd/wmii/view.c Fri Oct 17 10:39:13 2008 -0400
@@ -28,10 +28,10 @@
static void
_view_select(View *v) {
- if(screen->sel != v) {
- if(screen->sel)
- event("UnfocusTag %s\n",screen->sel->name);
- screen->sel = v;
+ if(selview != v) {
+ if(selview)
+ event("UnfocusTag %s\n",selview->name);
+ selview = v;
event("FocusTag %s\n", v->name);
event("AreaFocus %a\n", v->sel);
ewmh_updateview();
@@ -96,7 +96,7 @@
apply_tags(c, c->tags);
view_arrange(v);
- if(!screen->sel)
+ if(!selview)
_view_select(v);
ewmh_updateviews();
return v;
@@ -140,7 +140,7 @@
event("DestroyTag %s\n", v->name);
- if(v == screen->sel) {
+ if(v == selview) {
for(tv=view; tv; tv=tv->next)
if(tv->next == *vp) break;
if(tv == nil)
@@ -200,39 +200,32 @@
void
view_update_rect(View *v) {
- Rectangle r, sr, brect, scrnr;
+ static Vector_rect vec;
+ static Vector_rect *vp;
+ Rectangle r, sr, rr, brect, scrnr;
WMScreen *scrn;
Strut *strut;
Frame *f;
- int left, right, top, bottom;
- int s;
+ int s, i;
+ /* These short variable names are hell, eh? */
/* XXX:
- * Incidentally, really need to move screen->sel elsewhere.
- if(v != screen->sel)
+ if(v != selview)
return false;
*/
-
-
- top = 0;
- left = 0;
- right = 0;
- bottom = 0;
+ vec.n = 0;
for(f=v->floating->frame; f; f=f->anext) {
strut = f->client->strut;
if(!strut)
continue;
- /* Can do better in the future. */
- top = max(top, strut->top.max.y);
- left = max(left, strut->left.max.x);
- right = min(right, strut->right.min.x);
- bottom = min(bottom, strut->bottom.min.y);
+ vector_rpush(&vec, strut->top);
+ vector_rpush(&vec, strut->left);
+ vector_rpush(&vec, rectaddpt(strut->right, Pt(scr.rect.max.x, 0)));
+ vector_rpush(&vec, rectaddpt(strut->bottom, Pt(0, scr.rect.max.y)));
}
- scrnr = scr.rect;
- scrnr.min.y += top;
- scrnr.min.x += left;
- scrnr.max.x += right;
- scrnr.max.y += bottom;
+ /* Find the largest screen space not occupied by struts. */
+ vp = unique_rects(&vec, scr.rect);
+ scrnr = max_rect(vp);
/* FIXME: Multihead. */
v->floating->r = scr.rect;
@@ -241,33 +234,33 @@
scrn = screens[s];
r = fix_rect(scrn->r, scrnr);
+ /* Ugly. Very, very ugly. */
+ /*
+ * Try to find some rectangle near the edge of the
+ * screen where the bar will fit. This way, for
+ * instance, a system tray can be placed there
+ * without taking up too much extra screen real
+ * estate.
+ */
+ rr = r;
+ brect = scrn->brect;
+ for(i=0; i < vp->n; i++) {
+ sr = rect_intersection(vp->ary[i], scrn->r);
+ if(Dx(sr) < Dx(r)/2 || Dy(sr) < Dy(brect))
+ continue;
+ if(scrn->barpos == BTop && sr.min.y < rr.min.y
+ || scrn->barpos != BTop && sr.max.y > rr.max.y)
+ rr = sr;
+ }
if(scrn->barpos == BTop) {
- bar_sety(scrn, r.min.y);
- r.min.y += Dy(scrn->brect);
+ bar_sety(scrn, rr.min.y);
+ r.min.y = max(r.min.y, scrn->brect.max.y);
}else {
- r.max.y -= Dy(scrn->brect);
- bar_sety(scrn, r.max.y);
+ bar_sety(scrn, rr.max.y - Dy(brect));
+ r.max.y = min(r.max.y, scrn->brect.min.y);
}
-
+ bar_setbounds(scrn, rr.min.x, rr.max.x);
v->r[s] = r;
-
- brect = scrn->brect;
- brect.min.x = r.min.x;
- brect.max.x = r.max.x;
- for(f=v->floating->frame; f; f=f->anext) {
- /* This is not pretty. :( */
- strut = f->client->strut;
- if(!strut)
- continue;
- sr = strut->left;
- if(rect_intersect_p(brect, sr))
- brect.min.x = sr.max.x;
- sr = rectaddpt(strut->right, Pt(scr.rect.max.x, 0));
- if(rect_intersect_p(brect, sr))
- brect.max.x = sr.min.x;
- }
-
- bar_setbounds(scrn, brect.min.x, brect.max.x);
}
}
@@ -279,7 +272,7 @@
bool fscrn;
int s;
- if(v != screen->sel)
+ if(v != selview)
return;
if(starting)
return;
@@ -410,7 +403,7 @@
if(c->sel == f)
c->sel = f->cnext;
- if(v == screen->sel)
+ if(v == selview)
view_update(v);
else if(empty_p(v))
view_destroy(v);
@@ -436,7 +429,7 @@
Area *a;
bool fscrn;
- if(v != screen->sel)
+ if(v != selview)
return;
wins.n = 0;
@@ -543,7 +536,7 @@
a->r.max.y = v->r[s].max.y;
column_arrange(a, false);
}
- if(v == screen->sel)
+ if(v == selview)
div_update_all();
}
@@ -571,7 +564,7 @@
view_update_all(void) {
View *n, *v, *old;
- old = screen->sel;
+ old = selview;
for(v=view; v; v=v->next)
frames_update_sel(v);
@@ -581,7 +574,7 @@
view_destroy(v);
}
- view_update(screen->sel);
+ view_update(selview);
}
uint
Received on Fri Oct 17 2008 - 16:08:46 UTC
This archive was generated by hypermail 2.2.0 : Fri Oct 17 2008 - 16:12:07 UTC