[dasher: 19/21] Fix Two-button-dynamic response to mouse presses, + iPhone touchup coords
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 19/21] Fix Two-button-dynamic response to mouse presses, + iPhone touchup coords
- Date: Thu, 14 Jul 2011 17:32:44 +0000 (UTC)
commit 3d42803554fafb39af1c6aeaa4c8af79248b594e
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Wed Jul 13 15:40:12 2011 +0100
Fix Two-button-dynamic response to mouse presses, + iPhone touchup coords
Former avoids problems if (accidentally) drag mouse between top/bottom halves;
latter probably unnecessary given former fix, but a healthy dose of paranoia(!)
Src/DasherCore/TwoButtonDynamicFilter.cpp | 15 +++++++++------
Src/DasherCore/TwoButtonDynamicFilter.h | 3 +++
Src/iPhone/Classes/EAGLView.mm | 7 +++++--
3 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/Src/DasherCore/TwoButtonDynamicFilter.cpp b/Src/DasherCore/TwoButtonDynamicFilter.cpp
index 3f0321f..b05da49 100644
--- a/Src/DasherCore/TwoButtonDynamicFilter.cpp
+++ b/Src/DasherCore/TwoButtonDynamicFilter.cpp
@@ -49,7 +49,7 @@ static SModuleSettings sSettings[] = {
};
CTwoButtonDynamicFilter::CTwoButtonDynamicFilter(CSettingsUser *pCreator, CDasherInterfaceBase *pInterface, CFrameRate *pFramerate)
- : CButtonMultiPress(pCreator, pInterface, pFramerate, 14, _("Two Button Dynamic Mode"))
+ : CButtonMultiPress(pCreator, pInterface, pFramerate, 14, _("Two Button Dynamic Mode")), m_iMouseButton(-1)
{
//ensure that m_dLagMul is properly initialised
HandleEvent(LP_DYNAMIC_BUTTON_LAG);
@@ -98,7 +98,7 @@ void CTwoButtonDynamicFilter::KeyDown(unsigned long Time, int iId, CDasherView *
//simulate press of button 2/3 according to whether click in top/bottom half
myint iDasherX, iDasherY;
m_pInterface->GetActiveInputDevice()->GetDasherCoords(iDasherX, iDasherY, pView);
- iId = (iDasherY < CDasherModel::ORIGIN_Y) ? 2 : 3;
+ m_iMouseButton = iId = (iDasherY < CDasherModel::ORIGIN_Y) ? 2 : 3;
}
CButtonMultiPress::KeyDown(Time, iId, pView, pInput, pModel);
}
@@ -106,10 +106,13 @@ void CTwoButtonDynamicFilter::KeyDown(unsigned long Time, int iId, CDasherView *
void CTwoButtonDynamicFilter::KeyUp(unsigned long Time, int iId, CDasherView *pView, CDasherInput *pInput, CDasherModel *pModel) {
if (iId == 100 && !GetBoolParameter(BP_BACKOFF_BUTTON)) {
//mouse click - will be ignored by superclass method.
- //simulate press of button 2/3 according to whether click in top/bottom half
- myint iDasherX, iDasherY;
- m_pInterface->GetActiveInputDevice()->GetDasherCoords(iDasherX, iDasherY, pView);
- iId = (iDasherY < CDasherModel::ORIGIN_Y) ? 2 : 3;
+ //Although we could check current mouse coordinates,
+ // since we don't generally do anything in response to KeyUp, seems more consistent just to
+ // simulate release of whichever button we depressed in response to mousedown...
+ if (m_iMouseButton!=-1) {//paranoia about e.g. pause/resume inbetween press/release?
+ iId = m_iMouseButton;
+ m_iMouseButton=-1;
+ }
}
CButtonMultiPress::KeyUp(Time, iId, pView, pInput,pModel);
}
diff --git a/Src/DasherCore/TwoButtonDynamicFilter.h b/Src/DasherCore/TwoButtonDynamicFilter.h
index 901290e..984392e 100644
--- a/Src/DasherCore/TwoButtonDynamicFilter.h
+++ b/Src/DasherCore/TwoButtonDynamicFilter.h
@@ -51,6 +51,9 @@ class CTwoButtonDynamicFilter : public CButtonMultiPress {
virtual bool TimerImpl(unsigned long Time, CDasherView *m_pDasherView, CDasherModel *m_pDasherModel, CExpansionPolicy **pol);
virtual void ActionButton(int iTime, int iButton, int iType, CDasherModel *pModel);
double m_dLagMul;
+ ///id of physical key, whose pressing we have emulated, in response
+ /// to a mouse down event on one or other half of the canvas...
+ int m_iMouseButton;
};
}
/// @}
diff --git a/Src/iPhone/Classes/EAGLView.mm b/Src/iPhone/Classes/EAGLView.mm
index 49a80d9..4e4bf98 100644
--- a/Src/iPhone/Classes/EAGLView.mm
+++ b/Src/iPhone/Classes/EAGLView.mm
@@ -160,10 +160,13 @@ bool operator==(CGPoint p,CGPoint q) {
NSAssert(it != allTouches.end(), @"Release touch not in progress?");
map<int,CGPoint>::iterator it2=fingerPosns.find(it->second);
NSAssert(it2 != fingerPosns.end(), @"No coordinates for touch?");
- CGPoint p=it2->second;
+ //For consistency with MacOS and Gtk2, and to allow filters
+ // to check the coordinates of the click up, call KeyUp first...
+ it2->second=[touch locationInView:self];
+ dasherApp.dasherInterface->KeyUp(time, allTouches.size()+99);
+ //...and only _then_ forget the coordinates:
fingerPosns.erase(it2);
allTouches.erase(it);
- dasherApp.dasherInterface->KeyUp(time, allTouches.size()+100);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]