[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    scrolling with MMB (patch)
From:       Daniel Naber <dnaber () mini ! gt ! owl ! de>
Date:       2000-09-15 18:02:54
[Download RAW message or body]

Hi,

I know I should be fixing bugs, but this one is just too useful for people 
who don't have a wheel mouse:  it lets you scroll without using the 
scrollbars, using the middle mouse button (just like in Gimp, BTW).

There are two problems:

1. Doesn't work for long pages, it just won't scroll from top to bottom in 
one move. Can anybody help?

2. Doesn't work over links, because that opens a new window. I think this 
problem would vanish if MMB == open link in window in new window would 
happen on button *release*. This is the way it should be anyway, Netscape 
does it this way and common links in konqi work like this, too. Agree?

I hope this can make it into some version > 2.0.0

Regards
 Daniel

["mmb-scrolling.diff" (text/plain)]

Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.300
diff -u -r1.300 khtmlview.cpp
--- khtmlview.cpp	2000/09/15 13:20:01	1.300
+++ khtmlview.cpp	2000/09/15 17:42:15
@@ -109,6 +109,9 @@
     setVScrollBarMode(AlwaysOn);
     setHScrollBarMode(Auto);
 
+    // scrolling with MMB
+    mid_button_clicked = false;
+    
     d = new KHTMLViewPrivate;
 }
 
@@ -300,6 +303,13 @@
 
 void KHTMLView::viewportMousePressEvent( QMouseEvent *_mouse )
 {
+    
+    if( _mouse->button() & MidButton ) {
+       mid_button_clicked = true;
+       x_pos = _mouse->globalX();
+       y_pos = _mouse->globalY();
+    }
+
     if(!m_part->docImpl()) return;
 
     int xm, ym;
@@ -352,6 +362,18 @@
 
 void KHTMLView::viewportMouseMoveEvent( QMouseEvent * _mouse )
 {
+
+    // scrolling with MMB, just like using the real scrollbars:
+    if( mid_button_clicked ) {
+        int scroll_by_x = (_mouse->globalX() - x_pos) * (contentsWidth()/visibleWidth());
+        int scroll_by_y = (_mouse->globalY() - y_pos) * (contentsHeight()/visibleHeight());
+        scrollBy(scroll_by_x, scroll_by_y);
+        // kdDebug( 6000 ) << "* mid button moving by y:" << scroll_by_y << endl;
+        x_pos = _mouse->globalX();
+        y_pos = _mouse->globalY();
+        return;
+    }
+
     if(!m_part->docImpl()) return;
 
 
@@ -420,6 +442,11 @@
 
 void KHTMLView::viewportMouseReleaseEvent( QMouseEvent * _mouse )
 {
+
+    if( _mouse->button() & MidButton ) {
+       mid_button_clicked = false;
+    }
+
     if ( !m_part->docImpl() ) return;
 
     int xm, ym;
Index: khtmlview.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.h,v
retrieving revision 1.108
diff -u -r1.108 khtmlview.h
--- khtmlview.h	2000/09/03 14:00:51	1.108
+++ khtmlview.h	2000/09/15 17:42:19
@@ -197,6 +197,11 @@
     static QPixmap* paintBuffer;
 
     KHTMLViewPrivate *d;
+    
+    // scrolling with MMB
+    bool mid_button_clicked;
+    int x_pos;
+    int y_pos;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic