#ifndef _WX_WINDOW_H_
#define _WX_WINDOW_H_
-// ---------------------------------------------------------------------------
-// headers
-// ---------------------------------------------------------------------------
-
-// [at least] some version of Windows send extra mouse move messages after
-// a mouse click or a key press - to temporarily fix this problem, set the
-// define below to 1
-//
-// a better solution should be found later...
-#define wxUSE_MOUSEEVENT_HACK 0
-
// ---------------------------------------------------------------------------
// constants
// ---------------------------------------------------------------------------
int m_xThumbSize;
int m_yThumbSize;
-#if wxUSE_MOUSEEVENT_HACK
- // the coordinates of the last mouse event and the type of it
- long m_lastMouseX,
- m_lastMouseY;
- int m_lastMouseEvent;
-#endif // wxUSE_MOUSEEVENT_HACK
-
// implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
// by setting this to 0 (in the future this should be removed completely)
#define USE_DEFERRED_SIZING 1
+// set this to 1 to filter out duplicate mouse events, e.g. mouse move events
+// when mouse position didnd't change
+#ifdef __WXWINCE__
+ #define wxUSE_MOUSEEVENT_HACK 0
+#else
+ #define wxUSE_MOUSEEVENT_HACK 1
+#endif
+
// ---------------------------------------------------------------------------
// global variables
// ---------------------------------------------------------------------------
// wxGetStdColourMap() and wxWindow::OnSysColourChanged() (FIXME-MT)
static bool gs_hasStdCmap = false;
+// last mouse event information we need to filter out the duplicates
+#if wxUSE_MOUSEEVENT_HACK
+static struct
+{
+ // mouse position (in screen coordinates)
+ wxPoint pos;
+
+ // last mouse event type
+ wxEventType type;
+} gs_lastMouseEvent;
+#endif // wxUSE_MOUSEEVENT_HACK
+
// ---------------------------------------------------------------------------
// private functions
// ---------------------------------------------------------------------------
m_xThumbSize = 0;
m_yThumbSize = 0;
-#if wxUSE_MOUSEEVENT_HACK
- m_lastMouseX =
- m_lastMouseY = -1;
- m_lastMouseEvent = -1;
-#endif // wxUSE_MOUSEEVENT_HACK
-
m_pendingPosition = wxDefaultPosition;
m_pendingSize = wxDefaultSize;
}
event.SetId(GetId());
#if wxUSE_MOUSEEVENT_HACK
- m_lastMouseX = x;
- m_lastMouseY = y;
- m_lastMouseEvent = event.GetEventType();
+ gs_lastMouseEvent.pos = ClientToScreen(wxPoint(x, y));
+ gs_lastMouseEvent.type = event.GetEventType();
#endif // wxUSE_MOUSEEVENT_HACK
}
#endif // HAVE_TRACKMOUSEEVENT
#if wxUSE_MOUSEEVENT_HACK
- // Window gets a click down message followed by a mouse move message even
- // if position isn't changed! We want to discard the trailing move event
- // if x and y are the same.
- if ( (m_lastMouseEvent == wxEVT_RIGHT_DOWN ||
- m_lastMouseEvent == wxEVT_LEFT_DOWN ||
- m_lastMouseEvent == wxEVT_MIDDLE_DOWN) &&
- (m_lastMouseX == x && m_lastMouseY == y) )
- {
- m_lastMouseEvent = wxEVT_MOTION;
+ // Windows often generates mouse events even if mouse position hasn't
+ // changed (http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/66576)
+ //
+ // Filter this out as it can result in unexpected behaviour compared to
+ // other platforms
+ if ( gs_lastMouseEvent.type == wxEVT_RIGHT_DOWN ||
+ gs_lastMouseEvent.type == wxEVT_LEFT_DOWN ||
+ gs_lastMouseEvent.type == wxEVT_MIDDLE_DOWN ||
+ gs_lastMouseEvent.type == wxEVT_MOTION )
+ {
+ if ( ClientToScreen(wxPoint(x, y)) == gs_lastMouseEvent.pos )
+ {
+ gs_lastMouseEvent.type = wxEVT_MOTION;
- return false;
+ return false;
+ }
}
#endif // wxUSE_MOUSEEVENT_HACK