Browse Source

WindowServer+LibGUI: Support the 4th and 5th mouse buttons

We'll call the "Back" and "Forward" since that's what they are normally
mapped to in some other systems.
Andreas Kling 5 years ago
parent
commit
67b92a7d5f

+ 2 - 0
Libraries/LibGUI/Event.h

@@ -257,6 +257,8 @@ enum MouseButton : u8 {
     Left = 1,
     Right = 2,
     Middle = 4,
+    Back = 8,
+    Forward = 16,
 };
 
 class KeyEvent final : public Event {

+ 4 - 0
Libraries/LibGUI/WindowServerConnection.cpp

@@ -178,6 +178,10 @@ MouseButton to_gmousebutton(u32 button)
         return MouseButton::Right;
     case 4:
         return MouseButton::Middle;
+    case 8:
+        return MouseButton::Back;
+    case 16:
+        return MouseButton::Forward;
     default:
         ASSERT_NOT_REACHED();
         break;

+ 2 - 0
Servers/WindowServer/Event.h

@@ -70,6 +70,8 @@ enum class MouseButton : u8 {
     Left = 1,
     Right = 2,
     Middle = 4,
+    Back = 8,
+    Forward = 16,
 };
 
 class KeyEvent final : public Event {

+ 2 - 0
Servers/WindowServer/Screen.cpp

@@ -145,6 +145,8 @@ void Screen::on_receive_mouse_data(const MousePacket& packet)
     post_mousedown_or_mouseup_if_needed(MouseButton::Left);
     post_mousedown_or_mouseup_if_needed(MouseButton::Right);
     post_mousedown_or_mouseup_if_needed(MouseButton::Middle);
+    post_mousedown_or_mouseup_if_needed(MouseButton::Back);
+    post_mousedown_or_mouseup_if_needed(MouseButton::Forward);
     if (m_cursor_location != prev_location) {
         auto message = make<MouseEvent>(Event::MouseMove, m_cursor_location, buttons, MouseButton::None, m_modifiers);
         Core::EventLoop::current().post_event(WindowManager::the(), move(message));

+ 4 - 0
Servers/WindowServer/WindowManager.cpp

@@ -683,6 +683,10 @@ auto WindowManager::DoubleClickInfo::metadata_for_button(MouseButton button) ->
         return m_right;
     case MouseButton::Middle:
         return m_middle;
+    case MouseButton::Back:
+        return m_back;
+    case MouseButton::Forward:
+        return m_forward;
     default:
         ASSERT_NOT_REACHED();
     }

+ 2 - 0
Servers/WindowServer/WindowManager.h

@@ -241,6 +241,8 @@ private:
         ClickMetadata m_left;
         ClickMetadata m_right;
         ClickMetadata m_middle;
+        ClickMetadata m_back;
+        ClickMetadata m_forward;
     };
     DoubleClickInfo m_double_click_info;
     int m_double_click_speed { 0 };