From 07427c4fbd96dd243a342327d905acb69d342213 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 May 2014 22:12:32 +0000 Subject: [PATCH] Fix busy cursor handling in modal dialogs under MSW. Modal dialogs shown during wxBusyCursor effect shouldn't show the busy cursor as they do accept input, but did in wxMSW (as could be seen in e.g. the widgets sample after enabling the "Global busy cursor" in the menu and showing the text entry dialog via "Text|Set Help Hint"). Fix this by explicitly checking for the special case of having a modal dialog as parent at wxWindow level as doing it in wxDialog simply didn't work as its WM_SETCURSOR handler wasn't called at all for determining the cursor to use for its children because they handled WM_SETCURSOR themselves in the global busy state, without letting DefWindowProc(), which propagates this message upwards the window hierarchy, to have it at all. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76449 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/dialog.cpp | 28 ---------------------------- src/msw/window.cpp | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index d199ae278b..7ce0760d50 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -430,34 +430,6 @@ WXLRESULT wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPar ::InvalidateRect(GetHwnd(), NULL, false /* erase bg */); } break; - -#ifndef __WXMICROWIN__ - case WM_SETCURSOR: - // we want to override the busy cursor for modal dialogs: - // typically, wxBeginBusyCursor() is called and then a modal dialog - // is shown, but the modal dialog shouldn't have hourglass cursor - if ( IsModal() && wxIsBusy() ) - { - // set our cursor for all windows (but see below) - wxCursor cursor = m_cursor; - if ( !cursor.IsOk() ) - cursor = wxCURSOR_ARROW; - - ::SetCursor(GetHcursorOf(cursor)); - - // in any case, stop here and don't let wxWindow process this - // message (it would set the busy cursor) - processed = true; - - // but return false to tell the child window (if the event - // comes from one of them and not from ourselves) that it can - // set its own cursor if it has one: thus, standard controls - // (e.g. text ctrl) still have correct cursors in a dialog - // invoked while wxIsBusy() - rc = false; - } - break; -#endif // __WXMICROWIN__ } if ( !processed ) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 21a5a71613..0e3f79e4db 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -34,6 +34,7 @@ #include "wx/dc.h" #include "wx/dcclient.h" #include "wx/dcmemory.h" + #include "wx/dialog.h" #include "wx/utils.h" #include "wx/app.h" #include "wx/layout.h" @@ -4198,7 +4199,20 @@ bool wxWindowMSW::HandleSetCursor(WXHWND WXUNUSED(hWnd), // 3. if still no cursor but we're in a TLW, set the global cursor HCURSOR hcursor = 0; + + // Check for "business" is complicated by the fact that modal dialogs shown + // while busy cursor is in effect shouldn't show it as they are active and + // accept input from the user, unlike all the other windows. + bool isBusy = false; if ( wxIsBusy() ) + { + wxDialog* const + dlg = wxDynamicCast(wxGetTopLevelParent(this), wxDialog); + if ( !dlg || !dlg->IsModal() ) + isBusy = true; + } + + if ( isBusy ) { hcursor = wxGetCurrentBusyCursor(); }