]> git.saurik.com Git - wxWidgets.git/commitdiff
Generate events for two auxiliary mouse buttons in wxGTK.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Jul 2011 23:37:15 +0000 (23:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Jul 2011 23:37:15 +0000 (23:37 +0000)
Add code to generate wxEVT_AUXN_XXX events to wxGTK.

Closes #13310.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68215 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/gtk/window.cpp

index 2c63d6ab3484091461c47420e03ed152b14c4c50..23e7993a223b7c87c2f529788c773af730c175c6 100644 (file)
@@ -434,7 +434,15 @@ Major new features in this release
   was added.
 
 
-2.9.2:
+2.9.3:
+------
+
+GTK:
+
+- Generate events for two auxiliary mouse buttons in wxGTK (Marcin Wojdyr).
+
+
+2.9.2: (released 2011-07-05)
 ------
 
 All:
index 23c4a3cbb9557f9adcaf62b23b0c2697a00ad90f..e7da36cf0703a960661297e90c63803dbe62156e 100644 (file)
@@ -1145,6 +1145,10 @@ template<typename T> void InitMouseEvent(wxWindowGTK *win,
     event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK) != 0;
     event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK) != 0;
     event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK) != 0;
+
+    // In gdk/win32 VK_XBUTTON1 is translated to GDK_BUTTON4_MASK
+    // and VK_XBUTTON2 to GDK_BUTTON5_MASK. In x11/gdk buttons 4/5
+    // are wheel rotation and buttons 8/9 don't change the state.
     event.m_aux1Down = (gdk_event->state & GDK_BUTTON4_MASK) != 0;
     event.m_aux2Down = (gdk_event->state & GDK_BUTTON5_MASK) != 0;
 
@@ -1196,6 +1200,20 @@ static void AdjustEventButtonState(wxMouseEvent& event)
         event.m_rightDown = !event.m_rightDown;
         return;
     }
+
+    if ((event.GetEventType() == wxEVT_AUX1_DOWN) ||
+        (event.GetEventType() == wxEVT_AUX1_DCLICK))
+    {
+        event.m_aux1Down = true;
+        return;
+    }
+
+    if ((event.GetEventType() == wxEVT_AUX2_DOWN) ||
+        (event.GetEventType() == wxEVT_AUX2_DCLICK))
+    {
+        event.m_aux2Down = true;
+        return;
+    }
 }
 
 // find the window to send the mouse event too
@@ -1425,6 +1443,42 @@ gtk_window_button_press_callback( GtkWidget *widget,
         }
     }
 
+    else if (gdk_event->button == 8)
+    {
+        switch (gdk_event->type)
+        {
+            case GDK_3BUTTON_PRESS:
+            case GDK_BUTTON_PRESS:
+                event_type = wxEVT_AUX1_DOWN;
+                break;
+
+            case GDK_2BUTTON_PRESS:
+                event_type = wxEVT_AUX1_DCLICK;
+                break;
+
+            default:
+                ;
+        }
+    }
+
+    else if (gdk_event->button == 9)
+    {
+        switch (gdk_event->type)
+        {
+            case GDK_3BUTTON_PRESS:
+            case GDK_BUTTON_PRESS:
+                event_type = wxEVT_AUX2_DOWN;
+                break;
+
+            case GDK_2BUTTON_PRESS:
+                event_type = wxEVT_AUX2_DCLICK;
+                break;
+
+            default:
+                ;
+        }
+    }
+
     if ( event_type == wxEVT_NULL )
     {
         // unknown mouse button or click type
@@ -1508,6 +1562,14 @@ gtk_window_button_release_callback( GtkWidget *WXUNUSED(widget),
             event_type = wxEVT_RIGHT_UP;
             break;
 
+        case 8:
+            event_type = wxEVT_AUX1_UP;
+            break;
+
+        case 9:
+            event_type = wxEVT_AUX2_UP;
+            break;
+
         default:
             // unknown button, don't process
             return FALSE;
@@ -2038,6 +2100,7 @@ wxMouseState wxGetMouseState()
     ms.SetLeftDown((mask & GDK_BUTTON1_MASK) != 0);
     ms.SetMiddleDown((mask & GDK_BUTTON2_MASK) != 0);
     ms.SetRightDown((mask & GDK_BUTTON3_MASK) != 0);
+    // see the comment in InitMouseEvent()
     ms.SetAux1Down((mask & GDK_BUTTON4_MASK) != 0);
     ms.SetAux2Down((mask & GDK_BUTTON5_MASK) != 0);