[0.4.14][UXTHEME][NTUSER] Improve Themed Scrollbars (#3868) (#3953)

Squashed backport of:
0.4.15-dev-3086-g 236649c626 (#3868) and
0.4.15-dev-3147-g 3bf7e3ac13 (#3953)

to fix some regressions for themed scrollbars that were introduced by
0.4.14-dev-1134-g 00adb1a3f9

fixes all or most parts of CORE-16735 without introducing CORE-17754 and CORE-17755
This commit is contained in:
Joachim Henze 2021-07-31 08:16:03 -05:00
parent c437ff6128
commit 2671cc4d9d
3 changed files with 77 additions and 11 deletions

View file

@ -576,6 +576,29 @@ dodefault:
return g_user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi);
}
INT WINAPI ThemeSetScrollInfo(HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
{
PWND_DATA pwndData;
SCROLLINFO siout;
LPSCROLLINFO lpsiout = &siout;
BOOL IsThemed = FALSE;
pwndData = ThemeGetWndData(hWnd);
if (!pwndData)
goto dodefault;
if (pwndData->hthemeScrollbar)
IsThemed = TRUE;
memcpy(&siout, lpsi, sizeof(SCROLLINFO));
if (IsThemed)
siout.fMask |= SIF_THEMED;
dodefault:
return g_user32ApiHook.SetScrollInfo(hWnd, fnBar, lpsiout, bRedraw);
}
/**********************************************************************
* Exports
*/
@ -611,6 +634,7 @@ ThemeInitApiHook(UAPIHK State, PUSERAPIHOOK puah)
puah->SetWindowRgn = ThemeSetWindowRgn;
puah->GetScrollInfo = ThemeGetScrollInfo;
puah->SetScrollInfo = ThemeSetScrollInfo;
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCPAINT);
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCACTIVATE);

View file

@ -1221,6 +1221,7 @@ extern "C" {
#define SIF_RANGE 1
#define SIF_DISABLENOSCROLL 8
#define SIF_TRACKPOS 16
#define SIF_THEMED 128 /* REACTOS Specific Only */
#define SWP_DRAWFRAME 32
#define SWP_FRAMECHANGED 32
#define SWP_HIDEWINDOW 128

View file

@ -276,6 +276,7 @@ co_IntGetScrollInfo(PWND Window, INT nBar, PSBDATA pSBData, LPSCROLLINFO lpsi)
ASSERT_REFS_CO(Window);
lpsi->fMask &= ~SIF_THEMED; // Remove Theme bit
if(!SBID_IS_VALID(nBar))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
@ -334,6 +335,7 @@ NEWco_IntGetScrollInfo(
UINT Mask;
PSBTRACK pSBTrack = pWnd->head.pti->pSBTrack;
lpsi->fMask &= ~SIF_THEMED; // Remove Theme bit
if (!SBID_IS_VALID(nBar))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
@ -486,10 +488,13 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
UINT new_flags;
INT action = 0;
PSBDATA pSBData;
DWORD OldPos = 0;
DWORD OldPos = 0, CurrentPos = 0;
BOOL bChangeParams = FALSE; /* Don't show/hide scrollbar if params don't change */
UINT MaxPage;
int MaxPos;
/* [0] = HORZ, [1] = VERT */
static PWND PrevHwnd[2] = { 0 };
static DWORD PrevPos[2] = { 0 };
ASSERT_REFS_CO(Window);
@ -511,7 +516,7 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
EngSetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
if (lpsi->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL | SIF_PREVIOUSPOS))
if ((lpsi->fMask & ~SIF_THEMED) & ~(SIF_ALL | SIF_DISABLENOSCROLL | SIF_PREVIOUSPOS))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
return 0;
@ -611,7 +616,7 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
}
}
else /* Show and enable scroll-bar only if no page only changed. */
if (lpsi->fMask != SIF_PAGE)
if ((lpsi->fMask & ~SIF_THEMED) != SIF_PAGE)
{
if ((nBar != SB_CTL) && bChangeParams)
{
@ -643,8 +648,12 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
return lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos; /* SetWindowPos() already did the painting */
if (bRedraw)
{
if (!(lpsi->fMask & SIF_THEMED)) /* Not Using Themes */
{
TRACE("Not using themes.\n");
if (action & SA_SSI_REPAINT_ARROWS)
{ // Redraw the entire bar.
{
// Redraw the entire bar.
RECTL UpdateRect = psbi->rcScrollBar;
UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left;
UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left;
@ -657,6 +666,38 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
// Redraw only the interior part of the bar.
IntRefeshScrollInterior(Window, nBar, psbi);
}
}
else /* Using Themes */
{
RECTL UpdateRect = psbi->rcScrollBar;
TRACE("Using themes.\n");
UpdateRect.left -= Window->rcClient.left - Window->rcWindow.left;
UpdateRect.right -= Window->rcClient.left - Window->rcWindow.left;
UpdateRect.top -= Window->rcClient.top - Window->rcWindow.top;
UpdateRect.bottom -= Window->rcClient.top - Window->rcWindow.top;
/* Just paint the interior and not the arrows. */
if (!(action & SA_SSI_REPAINT_ARROWS))
{
if (nBar == SB_HORZ)
{
UpdateRect.left += psbi->dxyLineButton;
UpdateRect.right -= psbi->dxyLineButton;
}
if (nBar == SB_VERT)
{
UpdateRect.top += psbi->dxyLineButton;
UpdateRect.bottom -= psbi->dxyLineButton;
}
}
CurrentPos = lpsi->fMask & SIF_PREVIOUSPOS ? OldPos : pSBData->pos;
/* Check for changes to Window or CurrentPos */
if ((Window != PrevHwnd[nBar]) || (CurrentPos != PrevPos[nBar]))
{
co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME);
PrevHwnd[nBar] = Window;
PrevPos[nBar] = CurrentPos;
}
}
} // FIXME: Arrows
/* else if( action & SA_SSI_REPAINT_ARROWS )
{