From 2eda99a1d28a60d8e307e57c2288195d223fe943 Mon Sep 17 00:00:00 2001 From: Egor Date: Tue, 1 Oct 2019 21:51:59 -0700 Subject: ImGui linux XCB: added mouse wheel handling --- Imgui/src/ImGuiImplLinuxXCB.cpp | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'Imgui/src/ImGuiImplLinuxXCB.cpp') diff --git a/Imgui/src/ImGuiImplLinuxXCB.cpp b/Imgui/src/ImGuiImplLinuxXCB.cpp index de9777d..5e73702 100644 --- a/Imgui/src/ImGuiImplLinuxXCB.cpp +++ b/Imgui/src/ImGuiImplLinuxXCB.cpp @@ -243,38 +243,30 @@ bool ImGuiImplLinuxXCB::HandleXCBEvent(xcb_generic_event_t* event) case XCB_BUTTON_PRESS: { xcb_button_press_event_t *press = (xcb_button_press_event_t *)event; - int button = -1; - if (press->detail == XCB_BUTTON_INDEX_1) - button = 0; // Left - if (press->detail == XCB_BUTTON_INDEX_2) - button = 2; // middle - if (press->detail == XCB_BUTTON_INDEX_3) - button = 1; // right - if (button >= 0) + switch (press->detail) { - io.MouseDown[button] = true; - return io.WantCaptureMouse; + case XCB_BUTTON_INDEX_1: io.MouseDown[0] = true; break; // left + case XCB_BUTTON_INDEX_2: io.MouseDown[2] = true; break; // middle + case XCB_BUTTON_INDEX_3: io.MouseDown[1] = true; break; // right + case XCB_BUTTON_INDEX_4: io.MouseWheel += 1; break; + case XCB_BUTTON_INDEX_5: io.MouseWheel -= 1; break; } - return false; + + return io.WantCaptureMouse; } break; case XCB_BUTTON_RELEASE: { xcb_button_release_event_t *press = (xcb_button_release_event_t *)event; - int button = -1; - if (press->detail == XCB_BUTTON_INDEX_1) - button = 0; // Left - if (press->detail == XCB_BUTTON_INDEX_2) - button = 2; // middle - if (press->detail == XCB_BUTTON_INDEX_3) - button = 1; // right - if (button >= 0) + switch (press->detail) { - io.MouseDown[button] = false; - return io.WantCaptureKeyboard; + case XCB_BUTTON_INDEX_1: io.MouseDown[0] = false; break; // left + case XCB_BUTTON_INDEX_2: io.MouseDown[2] = false; break; // middle + case XCB_BUTTON_INDEX_3: io.MouseDown[1] = false; break; // right } - return false; + + return io.WantCaptureMouse; } break; -- cgit v1.2.3