[hackers] [wmii] Don't shunt the bar out of the way of struts if feasible. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sat, 22 May 2010 15:36:28 +0000 (UTC)

changeset: 2621:648f465e63ee
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Sat May 22 11:36:19 2010 -0400
files: cmd/wmii/view.c
description:
Don't shunt the bar out of the way of struts if feasible.

diff -r 56a90284a595 -r 648f465e63ee cmd/wmii/view.c
--- a/cmd/wmii/view.c Sat May 22 11:15:57 2010 -0400
+++ b/cmd/wmii/view.c Sat May 22 11:36:19 2010 -0400
@@ -201,12 +201,14 @@
 
 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;
 
         /* XXX:
         if(v != selview)
@@ -227,7 +229,12 @@
                 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)));
         }
+ vp = unique_rects(&vec, scr.rect);
         scrnr = scr.rect;
         scrnr.min.y += top;
         scrnr.min.x += left;
@@ -249,33 +256,26 @@
                  * without taking up too much extra screen real
                  * estate.
                  */
- if(scrn->barpos == BTop) {
- bar_sety(scrn, r.min.y);
- r.min.y += Dy(scrn->brect);
- }else {
- r.max.y -= Dy(scrn->brect);
- bar_sety(scrn, r.max.y);
+ 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, rr.min.y);
+ r.min.y = max(r.min.y, scrn->brect.max.y);
+ }else {
+ 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);
         }
 }
 
Received on Sat May 22 2010 - 15:36:28 UTC

This archive was generated by hypermail 2.2.0 : Sat May 22 2010 - 15:48:04 UTC