From 6f3ed5fd64c6708b9811f8c0d58f26b786433655 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sun, 12 Jun 2022 17:28:56 +0200 Subject: [PATCH] win32u: Move NtUserInvalidateRect and NtUserInvalidateRgn implementation from user32. Signed-off-by: Jacek Caban --- dlls/user32/button.c | 12 ++++++------ dlls/user32/combo.c | 16 ++++++++-------- dlls/user32/edit.c | 6 +++--- dlls/user32/listbox.c | 28 ++++++++++++++-------------- dlls/user32/menu.c | 4 ++-- dlls/user32/painting.c | 35 ----------------------------------- dlls/user32/scroll.c | 2 +- dlls/user32/user32.spec | 4 ++-- dlls/win32u/dce.c | 30 ++++++++++++++++++++++++++++++ dlls/win32u/gdiobj.c | 2 ++ dlls/win32u/win32u.spec | 4 ++-- dlls/win32u/win32u_private.h | 2 ++ dlls/win32u/wrappers.c | 12 ++++++++++++ include/ntuser.h | 2 ++ 14 files changed, 86 insertions(+), 73 deletions(-) diff --git a/dlls/user32/button.c b/dlls/user32/button.c index f4b570126f7..d1dc6a3c6ff 100644 --- a/dlls/user32/button.c +++ b/dlls/user32/button.c @@ -382,7 +382,7 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam ); else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam ); if (btn_type == BS_GROUPBOX) /* Yes, only for BS_GROUPBOX */ - InvalidateRect( hWnd, NULL, TRUE ); + NtUserInvalidateRect( hWnd, NULL, TRUE ); else paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); return 1; /* success. FIXME: check text length */ @@ -390,7 +390,7 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, case WM_SETFONT: set_button_font( hWnd, (HFONT)wParam ); - if (lParam) InvalidateRect(hWnd, NULL, TRUE); + if (lParam) NtUserInvalidateRect(hWnd, NULL, TRUE); break; case WM_GETFONT: @@ -415,11 +415,11 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, if (style & BS_NOTIFY) BUTTON_NOTIFY_PARENT(hWnd, BN_KILLFOCUS); - InvalidateRect( hWnd, NULL, FALSE ); + NtUserInvalidateRect( hWnd, NULL, FALSE ); break; case WM_SYSCOLORCHANGE: - InvalidateRect( hWnd, NULL, FALSE ); + NtUserInvalidateRect( hWnd, NULL, FALSE ); break; case BM_SETSTYLE: @@ -429,7 +429,7 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, /* Only redraw if lParam flag is set.*/ if (lParam) - InvalidateRect( hWnd, NULL, TRUE ); + NtUserInvalidateRect( hWnd, NULL, TRUE ); break; @@ -452,7 +452,7 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, return 0; } oldHbitmap = (HBITMAP)SetWindowLongPtrW( hWnd, HIMAGE_GWL_OFFSET, lParam ); - InvalidateRect( hWnd, NULL, FALSE ); + NtUserInvalidateRect( hWnd, NULL, FALSE ); return (LRESULT)oldHbitmap; case BM_GETIMAGE: diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 73ec5691e88..fe7b33235c0 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -1084,9 +1084,9 @@ BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL ok, BOOL bRedrawButton ) * CBRepaintButton */ static void CBRepaintButton( LPHEADCOMBO lphc ) - { - InvalidateRect(lphc->self, &lphc->buttonRect, TRUE); - UpdateWindow(lphc->self); +{ + NtUserInvalidateRect(lphc->self, &lphc->buttonRect, TRUE); + UpdateWindow(lphc->self); } /*********************************************************************** @@ -1104,7 +1104,7 @@ static void COMBO_SetFocus( LPHEADCOMBO lphc ) /* lphc->wState |= CBF_FOCUSED; */ if( !(lphc->wState & CBF_EDIT) ) - InvalidateRect(lphc->self, &lphc->textRect, TRUE); + NtUserInvalidateRect(lphc->self, &lphc->textRect, TRUE); CB_NOTIFY( lphc, CBN_SETFOCUS ); lphc->wState |= CBF_FOCUSED; @@ -1130,7 +1130,7 @@ static void COMBO_KillFocus( LPHEADCOMBO lphc ) /* redraw text */ if( !(lphc->wState & CBF_EDIT) ) - InvalidateRect(lphc->self, &lphc->textRect, TRUE); + NtUserInvalidateRect(lphc->self, &lphc->textRect, TRUE); CB_NOTIFY( lphc, CBN_KILLFOCUS ); } @@ -1561,7 +1561,7 @@ static LRESULT COMBO_SelectString( LPHEADCOMBO lphc, INT start, LPARAM pText, BO CBUpdateEdit( lphc, index ); else { - InvalidateRect(lphc->self, &lphc->textRect, TRUE); + NtUserInvalidateRect(lphc->self, &lphc->textRect, TRUE); } } return (LRESULT)index; @@ -1854,7 +1854,7 @@ LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar EnableWindow( lphc->hWndLBox, (BOOL)wParam ); /* Force the control to repaint when the enabled state changes. */ - InvalidateRect(lphc->self, NULL, TRUE); + NtUserInvalidateRect(lphc->self, NULL, TRUE); return TRUE; case WM_SETREDRAW: if( wParam ) @@ -2003,7 +2003,7 @@ LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar if( (lphc->wState & CBF_EDIT) && CB_HASSTRINGS(lphc) ) SendMessageW(lphc->hWndEdit, WM_SETTEXT, 0, (LPARAM)L""); else - InvalidateRect(lphc->self, NULL, TRUE); + NtUserInvalidateRect(lphc->self, NULL, TRUE); return TRUE; case CB_INITSTORAGE: return SendMessageW(lphc->hWndLBox, LB_INITSTORAGE, wParam, lParam); diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index 70f105b9a0a..439e33c0b14 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -1421,7 +1421,7 @@ static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase) es->flags &= ~EF_UPDATE; EDIT_NOTIFY_PARENT(es, EN_UPDATE); } - InvalidateRgn(es->hwndSelf, hrgn, bErase); + NtUserInvalidateRgn(es->hwndSelf, hrgn, bErase); } @@ -1436,7 +1436,7 @@ static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase) es->flags &= ~EF_UPDATE; EDIT_NOTIFY_PARENT(es, EN_UPDATE); } - InvalidateRect(es->hwndSelf, rc, bErase); + NtUserInvalidateRect(es->hwndSelf, rc, bErase); } /********************************************************************* @@ -4873,7 +4873,7 @@ LRESULT EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, B } if (old_style ^ es->style) - InvalidateRect(es->hwndSelf, NULL, TRUE); + NtUserInvalidateRect(es->hwndSelf, NULL, TRUE); result = 1; break; diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index b8f127c0963..1e7231b4c05 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -443,7 +443,7 @@ static LRESULT LISTBOX_SetTopItem( LB_DESCR *descr, INT index, BOOL scroll ) SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); } else - InvalidateRect( descr->self, NULL, TRUE ); + NtUserInvalidateRect( descr->self, NULL, TRUE ); descr->top_item = index; LISTBOX_UpdateScroll( descr ); return LB_OKAY; @@ -465,7 +465,7 @@ static void LISTBOX_UpdatePage( LB_DESCR *descr ) if (page_size == descr->page_size) return; descr->page_size = page_size; if (descr->style & LBS_MULTICOLUMN) - InvalidateRect( descr->self, NULL, TRUE ); + NtUserInvalidateRect( descr->self, NULL, TRUE ); LISTBOX_SetTopItem( descr, descr->top_item, FALSE ); } @@ -510,7 +510,7 @@ static void LISTBOX_UpdateSize( LB_DESCR *descr ) /* Invalidate the focused item so it will be repainted correctly */ if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) == 1) { - InvalidateRect( descr->self, &rect, FALSE ); + NtUserInvalidateRect( descr->self, &rect, FALSE ); } } @@ -741,7 +741,7 @@ static void LISTBOX_SetRedraw( LB_DESCR *descr, BOOL on ) descr->style &= ~LBS_NOREDRAW; if (descr->style & LBS_DISPLAYCHANGED) { /* page was changed while setredraw false, refresh automatically */ - InvalidateRect(descr->self, NULL, TRUE); + NtUserInvalidateRect(descr->self, NULL, TRUE); if ((descr->top_item + descr->page_size) > descr->nb_items) { /* reset top of page if less than number of items/page */ descr->top_item = descr->nb_items - descr->page_size; @@ -1246,14 +1246,14 @@ static void LISTBOX_InvalidateItems( LB_DESCR *descr, INT index ) return; } rect.bottom = descr->height; - InvalidateRect( descr->self, &rect, TRUE ); + NtUserInvalidateRect( descr->self, &rect, TRUE ); if (descr->style & LBS_MULTICOLUMN) { /* Repaint the other columns */ rect.left = rect.right; rect.right = descr->width; rect.top = 0; - InvalidateRect( descr->self, &rect, TRUE ); + NtUserInvalidateRect( descr->self, &rect, TRUE ); } } } @@ -1263,7 +1263,7 @@ static void LISTBOX_InvalidateItemRect( LB_DESCR *descr, INT index ) RECT rect; if (LISTBOX_GetItemRect( descr, index, &rect ) == 1) - InvalidateRect( descr->self, &rect, TRUE ); + NtUserInvalidateRect( descr->self, &rect, TRUE ); } /*********************************************************************** @@ -1314,7 +1314,7 @@ static LRESULT LISTBOX_SetItemHeight( LB_DESCR *descr, INT index, INT height, BO LISTBOX_UpdatePage( descr ); LISTBOX_UpdateScroll( descr ); if (repaint) - InvalidateRect( descr->self, 0, TRUE ); + NtUserInvalidateRect( descr->self, 0, TRUE ); } return LB_OKAY; } @@ -1339,12 +1339,12 @@ static void LISTBOX_SetHorizontalPos( LB_DESCR *descr, INT pos ) RECT rect; /* Invalidate the focused item so it will be repainted correctly */ if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) == 1) - InvalidateRect( descr->self, &rect, TRUE ); + NtUserInvalidateRect( descr->self, &rect, TRUE ); NtUserScrollWindowEx( descr->self, diff, 0, NULL, NULL, 0, NULL, SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); } else - InvalidateRect( descr->self, NULL, TRUE ); + NtUserInvalidateRect( descr->self, NULL, TRUE ); } @@ -1863,7 +1863,7 @@ static LRESULT LISTBOX_SetCount( LB_DESCR *descr, UINT count ) } else SendMessageW(descr->self, LB_RESETCONTENT, 0, 0); - InvalidateRect( descr->self, NULL, TRUE ); + NtUserInvalidateRect( descr->self, NULL, TRUE ); return LB_OKAY; } @@ -2696,7 +2696,7 @@ LRESULT ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam case LB_RESETCONTENT: LISTBOX_ResetContent( descr ); LISTBOX_UpdateScroll( descr ); - InvalidateRect( descr->self, NULL, TRUE ); + NtUserInvalidateRect( descr->self, NULL, TRUE ); return 0; case LB_ADDSTRING: @@ -3076,7 +3076,7 @@ LRESULT ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam return LISTBOX_Destroy( descr ); case WM_ENABLE: - InvalidateRect( descr->self, NULL, TRUE ); + NtUserInvalidateRect( descr->self, NULL, TRUE ); return 0; case WM_SETREDRAW: @@ -3102,7 +3102,7 @@ LRESULT ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam return (LRESULT)descr->font; case WM_SETFONT: LISTBOX_SetFont( descr, (HFONT)wParam ); - if (lParam) InvalidateRect( descr->self, 0, TRUE ); + if (lParam) NtUserInvalidateRect( descr->self, 0, TRUE ); return 0; case WM_SETFOCUS: descr->in_focus = TRUE; diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index a06ef21c634..d0637a61809 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -1728,14 +1728,14 @@ MENU_EnsureMenuItemVisible(LPPOPUPMENU lppop, UINT wIndex, HDC hdc) { arrow_rect.top = 0; arrow_rect.bottom = lppop->items_rect.top; - InvalidateRect(lppop->hWnd, &arrow_rect, FALSE); + NtUserInvalidateRect(lppop->hWnd, &arrow_rect, FALSE); } if (nOldPos + scroll_height == lppop->nTotalHeight || lppop->nScrollPos + scroll_height == lppop->nTotalHeight) { arrow_rect.top = lppop->items_rect.bottom; arrow_rect.bottom = lppop->Height; - InvalidateRect(lppop->hWnd, &arrow_rect, FALSE); + NtUserInvalidateRect(lppop->hWnd, &arrow_rect, FALSE); } } } diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index 419c952d998..89451e4e46b 100644 --- a/dlls/user32/painting.c +++ b/dlls/user32/painting.c @@ -62,41 +62,6 @@ BOOL WINAPI UpdateWindow( HWND hwnd ) } -/*********************************************************************** - * InvalidateRgn (USER32.@) - */ -BOOL WINAPI InvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase ) -{ - if (!hwnd) - { - SetLastError( ERROR_INVALID_WINDOW_HANDLE ); - return FALSE; - } - - return NtUserRedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) ); -} - - -/*********************************************************************** - * InvalidateRect (USER32.@) - * - * MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws - * all windows and sends WM_ERASEBKGND and WM_NCPAINT. - */ -BOOL WINAPI InvalidateRect( HWND hwnd, const RECT *rect, BOOL erase ) -{ - UINT flags = RDW_INVALIDATE | (erase ? RDW_ERASE : 0); - - if (!hwnd) - { - flags = RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW; - rect = NULL; - } - - return NtUserRedrawWindow( hwnd, rect, 0, flags ); -} - - /*********************************************************************** * ValidateRgn (USER32.@) */ diff --git a/dlls/user32/scroll.c b/dlls/user32/scroll.c index 8bf1f4312ab..b6f15b4a295 100644 --- a/dlls/user32/scroll.c +++ b/dlls/user32/scroll.c @@ -1507,7 +1507,7 @@ LRESULT WINAPI USER_ScrollBarProc( HWND hwnd, UINT message, WPARAM wParam, LPARA rect.bottom=rect.top+thumbSize; } NtUserHideCaret( hwnd ); - InvalidateRect(hwnd,&rect,0); + NtUserInvalidateRect( hwnd, &rect, 0 ); DestroyCaret(); } break; diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 1399f488720..d34bff5715e 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -448,8 +448,8 @@ @ stdcall InternalGetWindowIcon(ptr long) NtUserInternalGetWindowIcon @ stdcall InternalGetWindowText(long ptr long) NtUserInternalGetWindowText @ stdcall IntersectRect(ptr ptr ptr) -@ stdcall InvalidateRect(long ptr long) -@ stdcall InvalidateRgn(long long long) +@ stdcall InvalidateRect(long ptr long) NtUserInvalidateRect +@ stdcall InvalidateRgn(long long long) NtUserInvalidateRgn @ stdcall InvertRect(long ptr) @ stdcall -import IsCharAlphaA(long) @ stdcall -import IsCharAlphaNumericA(long) diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 872112e4a24..67590e80fa3 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -1575,6 +1575,36 @@ INT WINAPI NtUserExcludeUpdateRgn( HDC hdc, HWND hwnd ) return ret; } +/*********************************************************************** + * NtUserInvalidateRgn (win32u.@) + */ +BOOL WINAPI NtUserInvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase ) +{ + if (!hwnd) + { + SetLastError( ERROR_INVALID_WINDOW_HANDLE ); + return FALSE; + } + + return NtUserRedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) ); +} + +/*********************************************************************** + * NtUserInvalidateRect (win32u.@) + */ +BOOL WINAPI NtUserInvalidateRect( HWND hwnd, const RECT *rect, BOOL erase ) +{ + UINT flags = RDW_INVALIDATE | (erase ? RDW_ERASE : 0); + + if (!hwnd) + { + flags = RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW; + rect = NULL; + } + + return NtUserRedrawWindow( hwnd, rect, 0, flags ); +} + /*********************************************************************** * NtUserLockWindowUpdate (win32u.@) */ diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index 9c6415236c2..3c2ec6bb2e9 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1189,6 +1189,8 @@ static struct unix_funcs unix_funcs = NtUserGetWindowPlacement, NtUserHideCaret, NtUserInternalGetWindowIcon, + NtUserInvalidateRect, + NtUserInvalidateRgn, NtUserIsClipboardFormatAvailable, NtUserMapVirtualKeyEx, NtUserMessageCall, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index f296f162fff..54f5f990676 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1047,8 +1047,8 @@ @ stdcall NtUserInternalGetWindowIcon(ptr long) @ stdcall -syscall NtUserInternalGetWindowText(long ptr long) @ stub NtUserInternalToUnicode -@ stub NtUserInvalidateRect -@ stub NtUserInvalidateRgn +@ stdcall NtUserInvalidateRect(long ptr long) +@ stdcall NtUserInvalidateRgn(long long long) @ stub NtUserIsChildWindowDpiMessageEnabled @ stdcall NtUserIsClipboardFormatAvailable(long) @ stub NtUserIsMouseInPointerEnabled diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 80fe2e027e0..d1bc382f031 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -251,6 +251,8 @@ struct unix_funcs BOOL (WINAPI *pNtUserGetWindowPlacement)( HWND hwnd, WINDOWPLACEMENT *placement ); BOOL (WINAPI *pNtUserHideCaret)( HWND hwnd ); HICON (WINAPI *pNtUserInternalGetWindowIcon)( HWND hwnd, UINT type ); + BOOL (WINAPI *pNtUserInvalidateRect)( HWND hwnd, const RECT *rect, BOOL erase ); + BOOL (WINAPI *pNtUserInvalidateRgn)( HWND hwnd, HRGN hrgn, BOOL erase ); BOOL (WINAPI *pNtUserIsClipboardFormatAvailable)( UINT format ); UINT (WINAPI *pNtUserMapVirtualKeyEx)( UINT code, UINT type, HKL layout ); LRESULT (WINAPI *pNtUserMessageCall)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index 6620597b7b1..945ea5d7fd5 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -1048,6 +1048,18 @@ HICON WINAPI NtUserInternalGetWindowIcon( HWND hwnd, UINT type ) return unix_funcs->pNtUserInternalGetWindowIcon( hwnd, type ); } +BOOL WINAPI NtUserInvalidateRect( HWND hwnd, const RECT *rect, BOOL erase ) +{ + if (!unix_funcs) return FALSE; + return unix_funcs->pNtUserInvalidateRect( hwnd, rect, erase ); +} + +BOOL WINAPI NtUserInvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase ) +{ + if (!unix_funcs) return FALSE; + return unix_funcs->pNtUserInvalidateRgn( hwnd, hrgn, erase ); +} + BOOL WINAPI NtUserIsClipboardFormatAvailable( UINT format ) { if (!unix_funcs) return FALSE; diff --git a/include/ntuser.h b/include/ntuser.h index 0415ba076a5..cf8a909493b 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -617,6 +617,8 @@ NTSTATUS WINAPI NtUserInitializeClientPfnArrays( const struct user_client_procs HICON WINAPI NtUserInternalGetWindowIcon( HWND hwnd, UINT type ); INT WINAPI NtUserInternalGetWindowText( HWND hwnd, WCHAR *text, INT count ); BOOL WINAPI NtUserIsClipboardFormatAvailable( UINT format ); +BOOL WINAPI NtUserInvalidateRect( HWND hwnd, const RECT *rect, BOOL erase ); +BOOL WINAPI NtUserInvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase ); BOOL WINAPI NtUserKillTimer( HWND hwnd, UINT_PTR id ); BOOL WINAPI NtUserLockWindowUpdate( HWND hwnd ); UINT WINAPI NtUserMapVirtualKeyEx( UINT code, UINT type, HKL layout );