Author: jimtabor Date: Sun Jan 18 22:55:03 2015 New Revision: 66056
URL: http://svn.reactos.org/svn/reactos?rev=66056&view=rev Log: [User32] - When sending set cursor with an error hit, it should locate a pop up window if any are visible. See CORE-6651. - Need to fix NtUser co_IntProcessMouseMessage and co_WinPosWindowFromPoint properly. While testing, added hack to help make this work. - REAL fix for CORE-6129.
Modified: trunk/reactos/win32ss/user/user32/windows/defwnd.c
Modified: trunk/reactos/win32ss/user/user32/windows/defwnd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/windows... ============================================================================== --- trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/defwnd.c [iso-8859-1] Sun Jan 18 22:55:03 2015 @@ -153,80 +153,137 @@ } }
+HWND FASTCALL +IntFindChildWindowToOwner(HWND hRoot, HWND hOwner) +{ + HWND Ret; + PWND Child, OwnerWnd, Root, Owner; + + Root = ValidateHwnd(hRoot); + Owner = ValidateHwnd(hOwner); + + for( Child = Root->spwndChild ? DesktopPtrToUser(Root->spwndChild) : NULL; + Child; + Child = Child->spwndNext ? DesktopPtrToUser(Child->spwndNext) : NULL ) + { + OwnerWnd = Child->spwndOwner ? DesktopPtrToUser(Child->spwndOwner) : NULL; + if(!OwnerWnd) + continue; + + if (!(Child->style & WS_POPUP) || !(Child->style & WS_VISIBLE)) + continue; + + if(OwnerWnd == Owner) + { + Ret = Child->head.h; + return Ret; + } + } + ERR("IDCWTO Nothing found\n"); + return NULL; +} + LRESULT DefWndHandleSetCursor(HWND hWnd, WPARAM wParam, LPARAM lParam, ULONG Style) { - /* Not for child windows. */ - if (hWnd != (HWND)wParam) - { - return(0); - } - - switch((INT_PTR) LOWORD(lParam)) - { - case HTERROR: + /* Not for child windows. */ + if (hWnd != (HWND)wParam) + { + return 0; + } + + switch((short)LOWORD(lParam)) + { + case HTERROR: { - WORD Msg = HIWORD(lParam); - if (Msg == WM_LBUTTONDOWN || Msg == WM_MBUTTONDOWN || - Msg == WM_RBUTTONDOWN || Msg == WM_XBUTTONDOWN) - { - MessageBeep(0); - } - break; + //// This is the real fix for CORE-6129! + HWND hwndPopUP; + WORD Msg = HIWORD(lParam); + + if (Msg == WM_LBUTTONDOWN) + { + // Find a pop up window to bring active. + hwndPopUP = IntFindChildWindowToOwner(GetDesktopWindow(), hWnd); + if (hwndPopUP) + { + // Not a child pop up from desktop. + if ( hwndPopUP != GetWindow(GetDesktopWindow(), GW_CHILD) ) + { + // Get original active window. + HWND hwndOrigActive = GetActiveWindow(); + + SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + + //SetActiveWindow(hwndPopUP); + SetForegroundWindow(hwndPopUP); // HACK + + // If the change was made, break out. + if (hwndOrigActive != GetActiveWindow()) + break; + } + } + } + //// + if (Msg == WM_LBUTTONDOWN || Msg == WM_MBUTTONDOWN || + Msg == WM_RBUTTONDOWN || Msg == WM_XBUTTONDOWN) + { + ERR("Beep!\n"); + MessageBeep(0); + } + break; }
- case HTCLIENT: + case HTCLIENT: { - HICON hCursor = (HICON)GetClassLongPtrW(hWnd, GCL_HCURSOR); - if (hCursor) - { - SetCursor(hCursor); - return(TRUE); - } - return(FALSE); + HICON hCursor = (HICON)GetClassLongPtrW(hWnd, GCL_HCURSOR); + if (hCursor) + { + SetCursor(hCursor); + return TRUE; + } + return FALSE; }
- case HTLEFT: - case HTRIGHT: + case HTLEFT: + case HTRIGHT: { - if (Style & WS_MAXIMIZE) - { - break; - } - return((LRESULT)SetCursor(LoadCursorW(0, IDC_SIZEWE))); + if (Style & WS_MAXIMIZE) + { + break; + } + return((LRESULT)SetCursor(LoadCursorW(0, IDC_SIZEWE))); }
- case HTTOP: - case HTBOTTOM: + case HTTOP: + case HTBOTTOM: { - if (Style & WS_MAXIMIZE) - { - break; - } - return((LRESULT)SetCursor(LoadCursorW(0, IDC_SIZENS))); - } - - case HTTOPLEFT: - case HTBOTTOMRIGHT: - { - if (Style & WS_MAXIMIZE) - { - break; - } - return((LRESULT)SetCursor(LoadCursorW(0, IDC_SIZENWSE))); - } - - case HTBOTTOMLEFT: - case HTTOPRIGHT: - { - if (GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_MAXIMIZE) - { - break; - } - return((LRESULT)SetCursor(LoadCursorW(0, IDC_SIZENESW))); - } - } - return((LRESULT)SetCursor(LoadCursorW(0, IDC_ARROW))); + if (Style & WS_MAXIMIZE) + { + break; + } + return((LRESULT)SetCursor(LoadCursorW(0, IDC_SIZENS))); + } + + case HTTOPLEFT: + case HTBOTTOMRIGHT: + { + if (Style & WS_MAXIMIZE) + { + break; + } + return((LRESULT)SetCursor(LoadCursorW(0, IDC_SIZENWSE))); + } + case HTBOTTOMLEFT: + case HTTOPRIGHT: + { + if (GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_MAXIMIZE) + { + break; + } + return((LRESULT)SetCursor(LoadCursorW(0, IDC_SIZENESW))); + } + } + return((LRESULT)SetCursor(LoadCursorW(0, IDC_ARROW))); }
/***********************************************************************