From 6c2641404a62c55a231f8004e237aca459501309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sat, 3 Sep 2016 22:16:50 +0200 Subject: allow 4px deadzone for clicks For the shaky ones. Since this introduces a visible gap between trigger and move event, we temporarily manipulate the coordinates in the global last event what covers the outdated patch #134 REQUEST: 178 --- src/Window.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Window.cc b/src/Window.cc index 5377965..ad58263 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -2462,6 +2462,8 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { } +const unsigned int DEADZONE = 4; + void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { if (m_last_pressed_button == static_cast(re.button)) { @@ -2474,7 +2476,7 @@ void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { stopResizing(); else if (m_attaching_tab) attachTo(re.x_root, re.y_root); - else if (m_last_button_x == re.x_root && m_last_button_y == re.y_root) { + else if (std::abs(m_last_button_x - re.x_root) + std::abs(m_last_button_y - re.y_root) < DEADZONE) { int context = 0; context = frame().getContext(re.subwindow ? re.subwindow : re.window, re.x_root, re.y_root); @@ -2505,7 +2507,14 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { // in case someone put MoveX :StartMoving etc into keys, we have // to activate it before doing the actual motionNotify code - Fluxbox::instance()->keys()->doAction(me.type, me.state, m_last_pressed_button, context, &winClient(), me.time); + if (std::abs(m_last_button_x - me.x_root) + std::abs(m_last_button_y - me.y_root) >= DEADZONE) { + XEvent &e = const_cast(Fluxbox::instance()->lastEvent()); // is copy of "me" + e.xmotion.x_root = m_last_button_x; + e.xmotion.y_root = m_last_button_y; + Fluxbox::instance()->keys()->doAction(me.type, me.state, m_last_pressed_button, context, &winClient(), me.time); + e.xmotion.x = me.x_root; + e.xmotion.y = me.y_root; + } if (moving) { -- cgit v0.11.2