// headers
// ---------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "window.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
// 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 MouseEventInfoDummy
+{
+ // 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;
}
return false;
HWND hWnd = GetHwnd();
- int cshow = show ? SW_SHOW : SW_HIDE;
- ::ShowWindow(hWnd, cshow);
- if ( show && IsTopLevel() )
+ // we could be called before the underlying window is created (this is
+ // actually useful to prevent it from being initially shown), e.g.
+ //
+ // wxFoo *foo = new wxFoo;
+ // foo->Hide();
+ // foo->Create(parent, ...);
+ //
+ // should work without errors
+ if ( hWnd )
{
- wxBringWindowToTop(hWnd);
+ ::ShowWindow(hWnd, show ? SW_SHOW : SW_HIDE);
+
+ if ( show && IsTopLevel() )
+ {
+ wxBringWindowToTop(hWnd);
+ }
}
return true;
}
}
-void wxWindowMSW::MSWUpdateUIState()
+void wxWindowMSW::MSWUpdateUIState(int action)
{
// WM_UPDATEUISTATE only appeared in Windows 2000 so it can do us no good
// to use it on older systems -- and could possibly do some harm
// include just one UISF_XXX or both, both are affected, no idea
// why
::SendMessage(GetHwnd(), WM_UPDATEUISTATE,
- MAKEWPARAM(UIS_INITIALIZE,
- UISF_HIDEFOCUS | UISF_HIDEACCEL), 0);
+ MAKEWPARAM(action, UISF_HIDEFOCUS | UISF_HIDEACCEL), 0);
}
}
// this by default, we need to manually send this message
// so that controls could change their appearance
// appropriately
- MSWUpdateUIState();
+ MSWUpdateUIState(UIS_CLEAR);
return true;
}
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