From 91de9fcd6374cbd7b07929057c41fa46b5040be3 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 30 Jun 2012 19:49:51 +0200 Subject: [PATCH] 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. --- sys/src/cmd/mothra/libpanel/scrollbar.c | 10 +++++----- sys/src/cmd/mothra/mothra.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/src/cmd/mothra/libpanel/scrollbar.c b/sys/src/cmd/mothra/libpanel/scrollbar.c index 22d2a1883..8515d53ff 100644 --- a/sys/src/cmd/mothra/libpanel/scrollbar.c +++ b/sys/src/cmd/mothra/libpanel/scrollbar.c @@ -28,11 +28,10 @@ int pl_hitscrollbar(Panel *g, Mouse *m){ 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.yr.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 @@ int pl_hitscrollbar(Panel *g, Mouse *m){ pos, len); g->state=UP; } +out: if(oldstate!=g->state) pldraw(g, g->b); return g->state==DOWN; } diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c index aec45f062..497c832e3 100644 --- a/sys/src/cmd/mothra/mothra.c +++ b/sys/src/cmd/mothra/mothra.c @@ -179,7 +179,7 @@ void mkpanels(void){ 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);