sbstnc / dmenu-ee

dmenu-ee // dynamic menu extended edition
Other
16 stars 5 forks source link

Scroll only 3 lines per wheel? #3

Open luebking opened 8 years ago

luebking commented 8 years ago

One could add a switch to control this, interpreting "0" (the default) as the present page scrolling behavior. Opinions?

diff --git a/dmenu.c b/dmenu.c
index 6c66db8..36580aa 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -725,14 +725,18 @@ buttonpress(XEvent *e) {
        }
        /* scroll up */
        if(ev->button == Button4 && prev) {
-               sel = curr = prev;
+               int i = 0;
+               while(++i < 4 && sel && sel->left)
+                       curr = sel = sel->left;
                calcoffsets();
                drawmenu();
                return;
        }
        /* scroll down */
        if(ev->button == Button5 && next) {
-               sel = curr = next;
+               int i = 0;
+               while(++i < 4 && sel && sel->right)
+                       curr = sel = sel->right;
                calcoffsets();
                drawmenu();
                return;
luebking commented 8 years ago

Better variant (keeps highlight under the pointer):

diff --git a/dmenu.c b/dmenu.c
index 6c66db8..182eab3 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -725,14 +725,22 @@ buttonpress(XEvent *e) {
        }
        /* scroll up */
        if(ev->button == Button4 && prev) {
-               sel = curr = prev;
+               int i = 0;
+               while(++i < 4 && sel && sel->left && curr && curr->left) {
+                       curr = curr->left;
+                       sel = sel->left;
+               }
                calcoffsets();
                drawmenu();
                return;
        }
        /* scroll down */
        if(ev->button == Button5 && next) {
-               sel = curr = next;
+               int i = 0;
+               while(++i < 4 && sel && sel->right && curr && curr->right) {
+                       curr = curr->right;
+                       sel = sel->right;
+               }
                calcoffsets();
                drawmenu();
                return;
ghost commented 7 years ago

Hi, this worked nicely with dmenu-4.6, but with dmenu-4.7 it's not. There's hardly any differences between the mousesupport patch versions either.

luebking commented 7 years ago

Patch still applies and works (for me) on dmenu-ee git master - commit e41155235c53a1d6af2251280b4a629588bb01f (which fell behind dmenu upstream?)

How do you patch http://tools.suckless.org/dmenu/ in total?

ghost commented 7 years ago

Yeah it's somewhat behind upstream.. I patch official 'mousesupport-4.7', then '3linesperwheel' and a adapted version of 'xyw' for dmenu-4.7. I was sure this would fly, but I must be overlooking something. Thanks!