summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorMikko Mustonen <mustonen.mikko@outlook.com>2018-07-20 19:16:09 +0300
committerMikko Mustonen <mustonen.mikko@outlook.com>2018-08-12 12:41:31 +0300
commit51fa23a52a71fcbae5743587b35b179dcc226b92 (patch)
tree48c1dc6df75e80864e5aa9a0e6a9c040ed5e7215 /platform/x11
parent64595f0f6ad2aab38fb14f85c077c6e147326624 (diff)
Added double clicking to all buttons
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/os_x11.cpp22
-rw-r--r--platform/x11/os_x11.h1
2 files changed, 17 insertions, 6 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 9d1e3291b7..83d0fbc99d 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -96,6 +96,8 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
xmbstring = NULL;
x11_window = 0;
last_click_ms = 0;
+ last_click_button_index = -1;
+ last_click_pos = Point2(-100, -100);
args = OS::get_singleton()->get_cmdline_args();
current_videomode = p_desired;
main_loop = NULL;
@@ -1909,17 +1911,25 @@ void OS_X11::process_xevents() {
mb->set_pressed((event.type == ButtonPress));
- if (event.type == ButtonPress && event.xbutton.button == 1) {
+ if (event.type == ButtonPress) {
uint64_t diff = get_ticks_usec() / 1000 - last_click_ms;
- if (diff < 400 && Point2(last_click_pos).distance_to(Point2(event.xbutton.x, event.xbutton.y)) < 5) {
+ if (mb->get_button_index() == last_click_button_index) {
- last_click_ms = 0;
- last_click_pos = Point2(-100, -100);
- mb->set_doubleclick(true);
+ if (diff < 400 && Point2(last_click_pos).distance_to(Point2(event.xbutton.x, event.xbutton.y)) < 5) {
- } else {
+ last_click_ms = 0;
+ last_click_pos = Point2(-100, -100);
+ last_click_button_index = -1;
+ mb->set_doubleclick(true);
+ }
+
+ } else if (mb->get_button_index() < 4 || mb->get_button_index() > 7) {
+ last_click_button_index = mb->get_button_index();
+ }
+
+ if (!mb->is_doubleclick()) {
last_click_ms += diff;
last_click_pos = Point2(event.xbutton.x, event.xbutton.y);
}
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 44455a2d8d..06310adb76 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -125,6 +125,7 @@ class OS_X11 : public OS_Unix {
bool last_mouse_pos_valid;
Point2i last_click_pos;
uint64_t last_click_ms;
+ int last_click_button_index;
uint32_t last_button_state;
#ifdef TOUCH_ENABLED
struct {