[0.4.13] Update Scrollbar code to state of master 2023-March-12

by porting back:
0.4.15-dev-5784-g 2aea4ab945 [NTUSER] Scrollbar.c pure whitespace fixes
0.4.15-dev-5680-g 5ad5737370 CORE-18050 [NTUSER] Delete temporary workarounds in co_IntSetScrollInfo() (#4985)
0.4.15-dev-5355-g 0484beb04b CORE-18593 [NTUSER] Don't redraw scrollbar if it is hidden command prompt (#4849)
0.4.15-dev-4492-g 03422451b3 Add '\n' to debug logs (partially, only the scrollbar.c part)
0.4.15-dev-3875-g 977c129f33 CORE-18048 [USER32] SetScrollPos should not bypass UserApiHook (#4372)
0.4.15-dev-3849-g fd28a69de6 CORE-17780 [WIN32SS] Store the scrollbar theming enabled flag in the scrollbar (#4367)
0.4.15-dev-3175-g 222acf5a3e CORE-17777 [NTUSER] Scrollbar.c, Avoid potential out-of-bounds-accesses in co_IntSetScrollInfo()
0.4.15-dev-3174-g dda9c3979e CORE-17769 'Rapps Listview manual resize may erroneously not draw the triangles sometimes'
0.4.15-dev-3147-g 3bf7e3ac13 CORE-17754 and CORE-17755 [NTUSER] Improve Themed Scrollbars by Minimizing Updates (#3953)
0.4.15-dev-3086-g 236649c626 CORE-16375 [UXTHEME][NTUSER] Fix flashing of scrollbar when scrolling (#3868)
0.4.15-dev-2375-g ffea5152e6 [WIN32SS][NTUSER] Fix an integer underflow within scrollbar info setting
0.4.14-dev-1134-g 00adb1a3f9 [WIN32SS] Improve Drawing Scrollbars
- CORE-14755 fixed, flashing scrollbar triangles (we know 131 affected apps just from rapps!)
- CORE-13931 fixed, FamiTracker invisible about-dlg
- CORE-14685 improves a bit, but is not entirely fixed
- CORE-11561 'Notepad scrollbars problem' fixed

This will also speed up NSIS installers that display their file-copy-progress by
a self-scrolling listview.
This commit is contained in:
Joachim Henze 2023-03-12 10:58:22 +01:00
parent a8abef6469
commit a23fca7951
4 changed files with 269 additions and 300 deletions

View file

@ -5,7 +5,7 @@
* PURPOSE: uxtheme user api hook functions
* PROGRAMMER: Giannis Adamopoulos
*/
#include "uxthemep.h"
USERAPIHOOK g_user32ApiHook;
@ -21,14 +21,14 @@ PWND_DATA ThemeGetWndData(HWND hWnd)
pwndData = (PWND_DATA)GetPropW(hWnd, (LPCWSTR)MAKEINTATOM(atWndContext));
if(pwndData == NULL)
{
pwndData = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
pwndData = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(WND_DATA));
if(pwndData == NULL)
{
return NULL;
}
SetPropW( hWnd, (LPCWSTR)MAKEINTATOM(atWndContext), pwndData);
}
@ -272,20 +272,20 @@ ThemeDefWindowProcW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
pwndData = (PWND_DATA)GetPropW(hWnd, (LPCWSTR)MAKEINTATOM(atWndContext));
if(!IsAppThemed() ||
if(!IsAppThemed() ||
!(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT) ||
(pwndData && pwndData->HasAppDefinedRgn))
{
return g_user32ApiHook.DefWindowProcW(hWnd,
Msg,
wParam,
return g_user32ApiHook.DefWindowProcW(hWnd,
Msg,
wParam,
lParam);
}
return ThemeWndProc(hWnd,
Msg,
wParam,
lParam,
return ThemeWndProc(hWnd,
Msg,
wParam,
lParam,
g_user32ApiHook.DefWindowProcW);
}
@ -296,20 +296,20 @@ ThemeDefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
pwndData = (PWND_DATA)GetPropW(hWnd, (LPCWSTR)MAKEINTATOM(atWndContext));
if(!IsAppThemed() ||
if(!IsAppThemed() ||
!(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT) ||
(pwndData && pwndData->HasAppDefinedRgn))
{
return g_user32ApiHook.DefWindowProcA(hWnd,
Msg,
wParam,
return g_user32ApiHook.DefWindowProcA(hWnd,
Msg,
wParam,
lParam);
}
return ThemeWndProc(hWnd,
Msg,
wParam,
lParam,
return ThemeWndProc(hWnd,
Msg,
wParam,
lParam,
g_user32ApiHook.DefWindowProcA);
}
@ -508,7 +508,7 @@ ThemeDlgPostWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_
GetDiaogTextureBrush(hTheme, hwndTarget, hdc, phbrush, Msg != WM_CTLCOLORDLG);
#if 1
#if 1
{
WCHAR controlClass[32];
GetClassNameW (hwndTarget, controlClass, sizeof(controlClass) / sizeof(controlClass[0]));
@ -556,16 +556,16 @@ BOOL WINAPI ThemeGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
if (pwndData == NULL)
goto dodefault;
/*
* Uxtheme needs to handle the tracking of the scrollbar itself
/*
* Uxtheme needs to handle the tracking of the scrollbar itself
* This means than if an application needs to get the track position
* with GetScrollInfo, it will get wrong data. So uxtheme needs to
* hook it and set the correct tracking position itself
*/
ret = g_user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi);
if ( lpsi &&
if ( lpsi &&
(lpsi->fMask & SIF_TRACKPOS) &&
pwndData->SCROLL_TrackingWin == hwnd &&
pwndData->SCROLL_TrackingWin == hwnd &&
pwndData->SCROLL_TrackingBar == fnBar)
{
lpsi->nTrackPos = pwndData->SCROLL_TrackingVal;
@ -576,11 +576,34 @@ 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
*/
BOOL CALLBACK
BOOL CALLBACK
ThemeInitApiHook(UAPIHK State, PUSERAPIHOOK puah)
{
if (!puah || State != uahLoadInit)
@ -595,7 +618,7 @@ ThemeInitApiHook(UAPIHK State, PUSERAPIHOOK puah)
/* Store the original functions from user32 */
g_user32ApiHook = *puah;
puah->DefWindowProcA = ThemeDefWindowProcA;
puah->DefWindowProcW = ThemeDefWindowProcW;
puah->PreWndProc = ThemePreWindowProc;
@ -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
#define SWP_DRAWFRAME 32
#define SWP_FRAMECHANGED 32
#define SWP_HIDEWINDOW 128

File diff suppressed because it is too large Load diff

View file

@ -1723,7 +1723,7 @@ SetScrollPos(HWND hWnd, INT nBar, INT nPos, BOOL bRedraw)
ScrollInfo.fMask = SIF_POS|SIF_PREVIOUSPOS;
ScrollInfo.nPos = nPos;
return RealSetScrollInfo(hWnd, nBar, &ScrollInfo, bRedraw);
return SetScrollInfo(hWnd, nBar, &ScrollInfo, bRedraw);
}
/*