- Add wxWidgets patch to support Cocoa's NSEventTypeMagnify from the Magic Trackpad.

This was originally submitted by Jared Boone in http://trac.wxwidgets.org/ticket/14322
    and has been updaetd to apply cleanly to wxWidgets-3.0 (and less cleanly to 3.0.1 an 3.0.2).
    The ticket is marked as accepted but not scheduled, so no idea if it will ever make it in.
This commit is contained in:
Garth Corral 2014-10-30 09:39:02 -07:00
parent 96f61af19b
commit 83667d4d39
1 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1,115 @@
Index: include/wx/event.h
===================================================================
--- include/wx/event.h (revision 78078)
+++ include/wx/event.h (working copy)
@@ -716,6 +716,7 @@
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DOWN, wxMouseEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_UP, wxMouseEvent);
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_AUX2_DCLICK, wxMouseEvent);
+wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_MAGNIFY, wxMouseEvent);
// Character input event type
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_CHAR, wxKeyEvent);
@@ -1751,6 +1752,8 @@
bool Aux1DClick() const { return (m_eventType == wxEVT_AUX1_DCLICK); }
bool Aux2DClick() const { return (m_eventType == wxEVT_AUX2_DCLICK); }
+ bool Magnify() const { return (m_eventType == wxEVT_MAGNIFY); }
+
// True if a button is down and the mouse is moving
bool Dragging() const
{
@@ -1805,6 +1808,8 @@
// Is the system set to do page scrolling?
bool IsPageScroll() const { return ((unsigned int)m_linesPerAction == UINT_MAX); }
+ float GetMagnification() const { return m_magnification; }
+
virtual wxEvent *Clone() const { return new wxMouseEvent(*this); }
virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; }
@@ -1824,6 +1829,8 @@
int m_linesPerAction;
int m_columnsPerAction;
+ float m_magnification;
+
protected:
void Assign(const wxMouseEvent& evt);
@@ -4218,6 +4225,7 @@
#define EVT_MOUSE_AUX2_DOWN(func) wx__DECLARE_EVT0(wxEVT_AUX2_DOWN, wxMouseEventHandler(func))
#define EVT_MOUSE_AUX2_UP(func) wx__DECLARE_EVT0(wxEVT_AUX2_UP, wxMouseEventHandler(func))
#define EVT_MOUSE_AUX2_DCLICK(func) wx__DECLARE_EVT0(wxEVT_AUX2_DCLICK, wxMouseEventHandler(func))
+#define EVT_MAGNIFY(func) wx__DECLARE_EVT0(wxEVT_MAGNIFY, wxMouseEventHandler(func))
// All mouse events
#define EVT_MOUSE_EVENTS(func) \
@@ -4239,7 +4247,8 @@
EVT_MOTION(func) \
EVT_LEAVE_WINDOW(func) \
EVT_ENTER_WINDOW(func) \
- EVT_MOUSEWHEEL(func)
+ EVT_MOUSEWHEEL(func) \
+ EVT_MAGNIFY(func)
// Scrolling from wxWindow (sent to wxScrolledWindow)
#define EVT_SCROLLWIN_TOP(func) wx__DECLARE_EVT0(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(func))
Index: src/common/event.cpp
===================================================================
--- src/common/event.cpp (revision 78078)
+++ src/common/event.cpp (working copy)
@@ -207,6 +207,7 @@
wxDEFINE_EVENT( wxEVT_AUX2_DOWN, wxMouseEvent );
wxDEFINE_EVENT( wxEVT_AUX2_UP, wxMouseEvent );
wxDEFINE_EVENT( wxEVT_AUX2_DCLICK, wxMouseEvent );
+wxDEFINE_EVENT( wxEVT_MAGNIFY, wxMouseEvent );
// Character input event type
wxDEFINE_EVENT( wxEVT_CHAR, wxKeyEvent );
@@ -568,6 +569,8 @@
m_wheelDelta = 0;
m_linesPerAction = 0;
m_columnsPerAction = 0;
+
+ m_magnification = 0.0f;
}
void wxMouseEvent::Assign(const wxMouseEvent& event)
@@ -592,6 +595,8 @@
m_linesPerAction = event.m_linesPerAction;
m_columnsPerAction = event.m_columnsPerAction;
m_wheelAxis = event.m_wheelAxis;
+
+ m_magnification = event.m_magnification;
}
// return true if was a button dclick event
Index: src/osx/cocoa/window.mm
===================================================================
--- src/osx/cocoa/window.mm (revision 78078)
+++ src/osx/cocoa/window.mm (working copy)
@@ -728,6 +728,12 @@
case NSMouseMoved :
wxevent.SetEventType( wxEVT_MOTION ) ;
break;
+
+ case NSEventTypeMagnify:
+ wxevent.SetEventType( wxEVT_MAGNIFY );
+ wxevent.m_magnification = [nsEvent magnification];
+ break;
+
default :
break ;
}
@@ -1749,6 +1755,10 @@
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseEntered:), (IMP) wxOSX_mouseEvent, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseExited:), (IMP) wxOSX_mouseEvent, "v@:@" )
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ wxOSX_CLASS_ADD_METHOD(c, @selector(magnifyWithEvent:), (IMP)wxOSX_mouseEvent, "v@:@")
+#endif
+
wxOSX_CLASS_ADD_METHOD(c, @selector(cursorUpdate:), (IMP) wxOSX_cursorUpdate, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(keyDown:), (IMP) wxOSX_keyEvent, "v@:@" )