ref: 9f4897c36d123cfe4cec843c8b78cc2ee3ecd097
parent: b5248d50f25f0941f55eee4521425c28d5f6bbd5
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat Jun 30 15:49:51 EDT 2012
mothra: fix scrollbar mouse grab behaviour by default, scrollbars captured the mouse unless all mouse buttons where released. this makes sense in mothra main window, but makes drop down menus with scrollbar unusable. the patch lets one select the behaviour using the USERFL-flag. if set, the scrollbar will capture the mouse. if not set, scrollbar will release the mouse when outside the scrollbar rect.
--- a/sys/src/cmd/mothra/libpanel/scrollbar.c
+++ b/sys/src/cmd/mothra/libpanel/scrollbar.c
@@ -28,11 +28,10 @@
size=subpt(g->r.max, g->r.min);
pl_interior(g->state, &ul, &size);
oldstate=g->state;
- if(m->buttons&OUT && m->buttons&7){- if(m->xy.y<g->r.min.y) m->xy.y=g->r.min.y;
- if(m->xy.y>=g->r.max.y) m->xy.y=g->r.max.y-1;
- if(ptinrect(m->xy, g->r))
- m->buttons&=~OUT;
+ if(!(g->flags & USERFL) && (m->buttons&OUT || !ptinrect(m->xy, g->r))){+ m->buttons&=~OUT;
+ g->state=UP;
+ goto out;
}
if(sp->dir==HORIZ){pos=m->xy.x-ul.x;
@@ -71,6 +70,7 @@
pos, len);
g->state=UP;
}
+out:
if(oldstate!=g->state) pldraw(g, g->b);
return g->state==DOWN;
}
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -179,7 +179,7 @@
cururl=pllabel(p, PACKE|EXPAND, "---");
plplacelabel(cururl, PLACEW);
p=plgroup(root, PACKN|EXPAND);
- bar=plscrollbar(p, PACKW);
+ bar=plscrollbar(p, PACKW|USERFL);
text=pltextview(p, PACKE|EXPAND, Pt(0, 0), 0, dolink);
plscroll(text, 0, bar);
plgrabkb(cmd);
--
⑨