From fbf7301c2690f9eaeb6255b8bd7c8b9d28571b4a Mon Sep 17 00:00:00 2001 From: nathankopp Date: Thu, 9 Jan 2020 13:59:24 -0800 Subject: [PATCH] Windows touch (#1461) * When a "mouse" event was caused by a touch instead of the mouse, use touch-specific logic: 1) force the rate to be 1:1; 2) in Windows, don't try to reset the cursor (via. SetCursorPos), which is usually done to avoid the mouse bumping up against the edge of the screen. These work together to allow touch to work as expected on Windows, while preserving existing mouse behavior. * update vstgui subproject --- src/common/gui/CCursorHidingControl.cpp | 25 +++++++++---------------- src/common/gui/CSurgeSlider.cpp | 3 +++ vstgui.surge | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/common/gui/CCursorHidingControl.cpp b/src/common/gui/CCursorHidingControl.cpp index 8fefda3e9a8..241586e3c96 100644 --- a/src/common/gui/CCursorHidingControl.cpp +++ b/src/common/gui/CCursorHidingControl.cpp @@ -43,7 +43,7 @@ CMouseEventResult CCursorHidingControl::onMouseMoved(CPoint& where, const CButto double dy = where.y - _lastPos.y; _lastPos = where; - if (_isDetatched) + if (_isDetatched && !buttons.isTouch()) { double scaling = getMouseDeltaScaling(where, buttons); @@ -57,22 +57,15 @@ CMouseEventResult CCursorHidingControl::onMouseMoved(CPoint& where, const CButto onMouseMoveDelta(where, buttons, dx, dy); #if WINDOWS - if (_isDetatched) + if (_isDetatched && !buttons.isTouch()) { - // test for touch. If we are in a touch screen this cursor reset seems like a messy flip. See #1443 - int value = GetSystemMetrics(SM_DIGITIZER); - bool hasTouch = ( value & ( NID_INTEGRATED_TOUCH | NID_EXTERNAL_TOUCH ) ) ? true : false; - - if (!hasTouch) - { - double ddx = where.x - _detachPos.x; - double ddy = where.y - _detachPos.y; - double d = sqrt(ddx * ddx + ddy * ddy); - if (d > 10 && SetCursorPos(_hideX, _hideY)) - { - _lastPos = _detachPos; - } - } + double ddx = where.x - _detachPos.x; + double ddy = where.y - _detachPos.y; + double d = sqrt(ddx * ddx + ddy * ddy); + if (d > 10 && SetCursorPos(_hideX, _hideY)) + { + _lastPos = _detachPos; + } } #endif diff --git a/src/common/gui/CSurgeSlider.cpp b/src/common/gui/CSurgeSlider.cpp index 872c8e01c19..663b0d86109 100644 --- a/src/common/gui/CSurgeSlider.cpp +++ b/src/common/gui/CSurgeSlider.cpp @@ -465,6 +465,9 @@ double CSurgeSlider::getMouseDeltaScaling(CPoint& where, const CButtonState& but break; } + if (buttons.isTouch()) + rate = 1.0; + if (buttons & kRButton) rate *= 0.1; if (buttons & kShift) diff --git a/vstgui.surge b/vstgui.surge index 8b37ab51867..fdc321ee281 160000 --- a/vstgui.surge +++ b/vstgui.surge @@ -1 +1 @@ -Subproject commit 8b37ab518673b5a3857eee98a10e0a4deff19350 +Subproject commit fdc321ee2819397f9845f1a47cf3594cb8fd5e1b