From d577d457e3d15b5c556b9e9dcf82e110cf0d400d Mon Sep 17 00:00:00 2001 From: crs Date: Wed, 21 May 2003 19:38:11 +0000 Subject: [PATCH] Made double tap require moving farther away from the tapped edge before arming. This should reduce spurious double taps. --- lib/server/CServer.cpp | 29 ++++++++++++++++++++++++----- lib/server/CServer.h | 3 ++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/server/CServer.cpp b/lib/server/CServer.cpp index f8f531b8..fa2487d4 100644 --- a/lib/server/CServer.cpp +++ b/lib/server/CServer.cpp @@ -68,6 +68,7 @@ CServer::CServer(const CString& serverName) : m_switchTwoTapDelay(0.0), m_switchTwoTapEngaged(false), m_switchTwoTapArmed(false), + m_switchTwoTapZone(3), m_status(kNotRunning) { // do nothing @@ -726,8 +727,16 @@ CServer::onMouseMovePrimaryNoLock(SInt32 x, SInt32 y) dir = kBottom; } else { - // still on local screen - onNoSwitch(); + // still on local screen. check if we're inside the tap region. + SInt32 tapZone = (zoneSize < m_switchTwoTapZone) ? + m_switchTwoTapZone : zoneSize; + bool inTapZone = (x < ax + tapZone || + x >= ax + aw - tapZone || + y < ay + tapZone || + y >= ay + ah - tapZone); + + // failed to switch + onNoSwitch(inTapZone); return false; } @@ -831,7 +840,17 @@ CServer::onMouseMoveSecondaryNoLock(SInt32 dx, SInt32 dy) break; } if (clearWait) { - onNoSwitch(); + // still on local screen. check if we're inside the + // tap region. + SInt32 tapZone = (zoneSize < m_switchTwoTapZone) ? + m_switchTwoTapZone : zoneSize; + bool inTapZone = (m_x < ax + tapZone || + m_x >= ax + aw - tapZone || + m_y < ay + tapZone || + m_y >= ay + ah - tapZone); + + // failed to switch + onNoSwitch(inTapZone); } } @@ -1290,7 +1309,7 @@ CServer::isSwitchOkay(IClient* newScreen, EDirection dir, SInt32 x, SInt32 y) } void -CServer::onNoSwitch() +CServer::onNoSwitch(bool inTapZone) { if (m_switchTwoTapEngaged) { if (m_switchTwoTapTimer.getTime() > m_switchTwoTapDelay) { @@ -1298,7 +1317,7 @@ CServer::onNoSwitch() m_switchTwoTapEngaged = false; m_switchTwoTapArmed = false; } - else { + else if (!inTapZone) { // we've moved away from the edge and there's still // time to get back for a double tap. m_switchTwoTapArmed = true; diff --git a/lib/server/CServer.h b/lib/server/CServer.h index 1e69f108..89a52bd6 100644 --- a/lib/server/CServer.h +++ b/lib/server/CServer.h @@ -258,7 +258,7 @@ private: // update switch state due to a mouse move that doesn't try to // switch screens. - void onNoSwitch(); + void onNoSwitch(bool inTapZone); // reset switch wait state void clearSwitchState(); @@ -403,6 +403,7 @@ private: CStopwatch m_switchTwoTapTimer; bool m_switchTwoTapEngaged; bool m_switchTwoTapArmed; + SInt32 m_switchTwoTapZone; // the status change jobs and status CJobList m_statusJobs;