From 44aa7a7730d1ac1a33cf5066ac099d1dd77b91c2 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 9 Dec 2008 20:44:57 -0500 Subject: [PATCH] Fix some quirks with column dividers on differently sized/placed screens. --- cmd/wmii/dat.h | 1 + cmd/wmii/div.c | 70 +++++++++++++++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h index c6913fb1..3414e6eb 100644 --- a/cmd/wmii/dat.h +++ b/cmd/wmii/dat.h @@ -196,6 +196,7 @@ struct Divide { Area* left; Area* right; bool mapped; + int side; int x; }; diff --git a/cmd/wmii/div.c b/cmd/wmii/div.c index 7ee8394b..abb71a89 100644 --- a/cmd/wmii/div.c +++ b/cmd/wmii/div.c @@ -10,30 +10,32 @@ static CTuple divcolor; static Handlers handlers; static Divide* -getdiv(Divide **dp) { +getdiv(Divide ***dp) { WinAttr wa; Divide *d; - if(*dp) - return *dp; + if(**dp) { + d = **dp; + d->side = 0; + }else { + d = emallocz(sizeof *d); - d = emallocz(sizeof *d); - - wa.override_redirect = true; - wa.cursor = cursor[CurDHArrow]; - wa.event_mask = - ExposureMask - | EnterWindowMask - | ButtonPressMask - | ButtonReleaseMask; - d->w = createwindow(&scr.root, Rect(0, 0, 1, 1), scr.depth, InputOutput, &wa, - CWOverrideRedirect - | CWEventMask - | CWCursor); - d->w->aux = d; - sethandler(d->w, &handlers); - - *dp = d; + wa.override_redirect = true; + wa.cursor = cursor[CurDHArrow]; + wa.event_mask = + ExposureMask + | EnterWindowMask + | ButtonPressMask + | ButtonReleaseMask; + d->w = createwindow(&scr.root, Rect(0, 0, 1, 1), scr.depth, InputOutput, &wa, + CWOverrideRedirect + | CWEventMask + | CWCursor); + d->w->aux = d; + sethandler(d->w, &handlers); + **dp = d; + } + *dp = &d->next; return d; } @@ -64,7 +66,7 @@ div_set(Divide *d, int x) { } static void -drawimg(Image *img, ulong cbg, ulong cborder) { +drawimg(Image *img, ulong cbg, ulong cborder, int side) { Point pt[6]; pt[0] = Pt(0, 0); @@ -76,12 +78,22 @@ drawimg(Image *img, ulong cbg, ulong cborder) { pt[4] = Pt(pt[3].x, Dx(img->r)/2 - 1); pt[5] = Pt(Dx(img->r) - 1, 0); + if (side & 1) + pt[0].x = pt[1].x = pt[2].x + 1; + if (side & 2) + pt[5].x = pt[4].x = pt[3].x - 1; + fillpoly(img, pt, nelem(pt), cbg); drawpoly(img, pt, nelem(pt), CapNotLast, 1, cborder); } static void drawdiv(Divide *d) { + + fill(divmask, divmask->r, 0); + drawimg(divmask, 1, 1, d->side); + drawimg(divimg, divcolor.bg, divcolor.border, d->side); + copyimage(d->w, divimg->r, divimg, ZP); setshapemask(d->w, divmask, ZP); } @@ -108,10 +120,6 @@ update_imgs(void) { divmask = allocimage(w, h, 1); divcolor = def.normcolor; - fill(divmask, divmask->r, 0); - drawimg(divmask, 1, 1); - drawimg(divimg, divcolor.bg, divcolor.border); - for(d = divs; d && d->w->mapped; d = d->next) drawdiv(d); } @@ -129,19 +137,23 @@ div_update_all(void) { dp = &divs; ap = nil; foreach_column(v, s, a) { - d = getdiv(dp); - dp = &d->next; + if (ap && ap->screen != s) + ap = nil; + + d = getdiv(&dp); d->left = ap; d->right = a; div_set(d, a->r.min.x); ap = a; + if (!ap) + d->side |= 1; if(!a->next) { - d = getdiv(dp); - dp = &d->next; + d = getdiv(&dp); d->left = a; d->right = nil; div_set(d, a->r.max.x); + d->side |= 2; } } for(d = *dp; d; d = d->next)