Two-Dimensional scrolling (was: Re: Fwd: [Bug 34362] mouse button support)

Jörg Walter jwalt-kde at garni.ch
Fri Dec 27 18:30:52 GMT 2002


On Friday, 27. December 2002 09:36, Ralf Nolden wrote:
>
> Well, ok. As much as that would work, I guess it would still be better to
> have Trolltech include support for a 5th and 6th button on a mouse in Qt.
>

Since somebody hit this subject, there's a question that's bugging me and 
which I never got around to ask: I have a Logitech Trackman Marble which has 
an extra button which on windows switches into scroll mode. That is, moving 
the ball while pressing the button it works like two scroll wheels, one 
horizontal, one vertical. Luckily I found out how to make XFree understand 
the button and to map ball motion onto button presses.
The short story is that vertical "wheel" motion works fine. I created a small 
patch for Qt so that I even get horizontal "wheel" motion correct. However, I 
don't know if my button mapping is correct and might conflict with the stuff 
in this thread. Vertical wheel motion in X11 is mapped to buttons 4 and 5, so 
I took 6 and 7 for horizontal movement. Is this mapping correct? Or how 
should I have solved that?

Here is the patch I use (also attached for your convenience):

diff -rubBP -X /usr/lib/portage/lib/diff.ignore 
work.old/qt-x11-free-3.0.5/src/kernel/qapplication_x11.cpp 
work/qt-x11-free-3.0.5/src/kernel/qapplication_x11.cpp
--- work.old/qt-x11-free-3.0.5/src/kernel/qapplication_x11.cpp  Fri Aug 30 
11:34:36 2002
+++ work/qt-x11-free-3.0.5/src/kernel/qapplication_x11.cpp      Fri Aug 30 
10:08:38 2002
@@ -91,6 +91,10 @@
 #endif

 #include "qt_x11.h"
+#ifndef Button6
+#define Button6 (Button5+1)
+#define Button7 (Button6+1)
+#endif

 #if defined(QT_MODULE_OPENGL)
 #include <GL/glx.h>
@@ -4635,6 +4639,8 @@
            break;
        case Button4:
        case Button5:
+       case Button6:
+       case Button7:
            // the fancy mouse wheel.

            // take care about grabbing. We do this here since it
@@ -4666,8 +4672,8 @@
                // indicates forward rotation, a negative one
                // backward rotation respectively.
                int btn = event->xbutton.button;
-               delta *= 120 * ( (btn == Button4) ? 1 : -1 );
-               translateWheelEvent( globalPos.x(), globalPos.y(), delta, 
state, (state&AltButton)?Horizontal:Vertical );
+               delta *= 120 * ( (btn == Button4 || btn == Button6) ? 1 : -1 
);
+               translateWheelEvent( globalPos.x(), globalPos.y(), delta, 
state, 
((state&AltButton)||(event->xbutton.button==Button6||event->xbutton.button==Button7))?Horizontal:Vertical 
);
            }
            return TRUE;
        }

Btw, if anyone regards this as being useful, feel free to forward it to the 
appropriate people.

-- 
CU
  Joerg

PGP Public Key at http://ich.bin.kein.hoschi.de/~trouble/public_key.asc
PGP Key fingerprint = D34F 57C4 99D8 8F16 E16E  7779 CDDC 41A4 4C48 6F94
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt-3.0.5-r1-xywheel.patch
Type: text/x-diff
Size: 1292 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20021227/17ccecf0/attachment.patch>


More information about the kde-core-devel mailing list