Add wxWindow::EnableTouchEvents()

Don't request touch event generation for all windows by default, this
has an inherent overhead and is not needed for 99% of the application
windows, so require calling EnableTouchEvents() explicitly to do it
instead.

Note that this requires properly initializing gesture recognizers in
wxOSX now that they're not always allocated, otherwise releasing them
when destroying the window would crash.
This commit is contained in:
Vadim Zeitlin
2017-11-21 19:23:34 +01:00
parent e7f4e232fa
commit 842dd1cfd9
14 changed files with 131 additions and 36 deletions

View File

@@ -77,6 +77,9 @@ public:
virtual bool Reparent( wxWindowBase *newParent ) wxOVERRIDE;
virtual void WarpPointer(int x, int y) wxOVERRIDE;
#ifdef __WXGTK3__
virtual bool EnableTouchEvents(int eventsMask) wxOVERRIDE;
#endif // __WXGTK3__
virtual void Refresh( bool eraseBackground = true,
const wxRect *rect = (const wxRect *) NULL ) wxOVERRIDE;

View File

@@ -100,6 +100,7 @@ public:
virtual bool Reparent(wxWindowBase *newParent) wxOVERRIDE;
virtual void WarpPointer(int x, int y) wxOVERRIDE;
virtual bool EnableTouchEvents(int eventsMask) wxOVERRIDE;
virtual void Refresh( bool eraseBackground = true,
const wxRect *rect = (const wxRect *) NULL ) wxOVERRIDE;

View File

@@ -128,6 +128,7 @@ public :
void SetToolTip( wxToolTip* tooltip );
void InstallEventHandler( WXWidget control = NULL );
bool EnableTouchEvents(int eventsMask);
virtual bool ShouldHandleKeyNavigation(const wxKeyEvent &event) const;
bool DoHandleKeyNavigation(const wxKeyEvent &event);

View File

@@ -326,6 +326,8 @@ public :
virtual void InstallEventHandler( WXWidget control = NULL ) = 0;
virtual bool EnableTouchEvents(int eventsMask) = 0;
// Mechanism used to keep track of whether a change should send an event
// Do SendEvents(false) when starting actions that would trigger programmatic events
// and SendEvents(true) at the end of the block.

View File

@@ -105,6 +105,7 @@ public :
void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
void InstallEventHandler( WXWidget control = NULL );
bool EnableTouchEvents(int WXUNUSED(eventsMask)) { return false; }
virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);

View File

@@ -77,6 +77,7 @@ public:
virtual void SetFocus() wxOVERRIDE;
virtual void WarpPointer( int x, int y ) wxOVERRIDE;
virtual bool EnableTouchEvents(int eventsMask) wxOVERRIDE;
virtual void Refresh( bool eraseBackground = true,
const wxRect *rect = NULL ) wxOVERRIDE;

View File

@@ -133,6 +133,13 @@ enum wxShowEffect
wxSHOW_EFFECT_MAX
};
// Values for EnableTouchEvents() mask.
enum
{
wxTOUCH_NONE = 0x0000,
wxTOUCH_ALL_GESTURES = 0x00ff
};
// flags for SendSizeEvent()
enum
{
@@ -1033,6 +1040,13 @@ public:
virtual bool HasCapture() const
{ return (wxWindow *)this == GetCapture(); }
// enable the specified touch events for this window, return false if
// the requested events are not supported
virtual bool EnableTouchEvents(int WXUNUSED(eventsMask))
{
return false;
}
// painting the window
// -------------------