Bug 423563 - "Map mouse buttons 6-7 to horizontal scrolling on Linux" [p=ventnor.bugzilla@yahoo.com.au (Michael Ventnor) r+sr=roc a1.9=beltzner]
authorreed@reedloden.com
Tue, 18 Mar 2008 12:36:09 -0700
changeset 13248 4f7b412c62150a21b57b93a35a72fb779b43ab6c
parent 13247 1d13811d430444fade02eec6550c4612df3673fd
child 13249 2eafd0fb742143370c3cf042e989765529854f1f
push idunknown
push userunknown
push dateunknown
bugs423563
milestone1.9b5pre
Bug 423563 - "Map mouse buttons 6-7 to horizontal scrolling on Linux" [p=ventnor.bugzilla@yahoo.com.au (Michael Ventnor) r+sr=roc a1.9=beltzner]
widget/src/gtk2/nsWindow.cpp
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -2102,17 +2102,38 @@ nsWindow::OnButtonPressEvent(GtkWidget *
         domButton = nsMouseEvent::eLeftButton;
         break;
     case 2:
         domButton = nsMouseEvent::eMiddleButton;
         break;
     case 3:
         domButton = nsMouseEvent::eRightButton;
         break;
-        // Map buttons 8-9 to back/forward
+    // These are mapped to horizontal scroll
+    case 6:
+    case 7:
+        {
+            nsMouseScrollEvent event(PR_TRUE, NS_MOUSE_SCROLL, this);
+            event.scrollFlags = nsMouseScrollEvent::kIsHorizontal;
+            event.refPoint.x = nscoord(aEvent->x);
+            event.refPoint.y = nscoord(aEvent->y);
+            event.delta = (aEvent->button == 6) ? -2 : 2;
+
+            event.isShift   = (aEvent->state & GDK_SHIFT_MASK) != 0;
+            event.isControl = (aEvent->state & GDK_CONTROL_MASK) != 0;
+            event.isAlt     = (aEvent->state & GDK_MOD1_MASK) != 0;
+            event.isMeta    = (aEvent->state & GDK_MOD4_MASK) != 0;
+
+            event.time = aEvent->time;
+
+            nsEventStatus status;
+            DispatchEvent(&event, status);
+            return;
+        }
+    // Map buttons 8-9 to back/forward
     case 8:
         DispatchCommandEvent(nsWidgetAtoms::Back);
         return;
     case 9:
         DispatchCommandEvent(nsWidgetAtoms::Forward);
         return;
     default:
         return;