Module: wine Branch: stable Commit: 704b6ef41c28c843f5ed538d4dc8742b2aaf64a3 URL: https://gitlab.winehq.org/wine/wine/-/commit/704b6ef41c28c843f5ed538d4dc8742...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Tue Mar 1 15:06:38 2022 +0800
uxtheme: Search parts of any state in IsThemePartDefined().
Tests show that IsThemePartDefined() doesn't use state ID to search parts. If a part of any state is present, the part is considered as defined. For example, disabled state of part EditText of class Edit is present in theme files but there is no default state for part EditText. So IsThemePartDefined(theme, EP_EDITTEXT, 0) failed previously and it should succeed.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52581 Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit f11129d9c47b6ad0f52e4d2e88d17d9a0c2fe552) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/uxtheme/msstyles.c | 30 ++++++++++++++++++++++++++++++ dlls/uxtheme/msstyles.h | 1 + dlls/uxtheme/system.c | 6 +++--- dlls/uxtheme/tests/system.c | 13 +++---------- 4 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/dlls/uxtheme/msstyles.c b/dlls/uxtheme/msstyles.c index c0f626d54aa..8c9225f1e1f 100644 --- a/dlls/uxtheme/msstyles.c +++ b/dlls/uxtheme/msstyles.c @@ -451,6 +451,36 @@ static PTHEME_CLASS MSSTYLES_AddClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWST return cur; }
+/*********************************************************************** + * MSSTYLES_FindPart + * + * Find a part + * + * PARAMS + * tc Class to search + * iPartId Part ID to find + * + * RETURNS + * The part found, or NULL + */ +PTHEME_PARTSTATE MSSTYLES_FindPart(PTHEME_CLASS tc, int iPartId) +{ + PTHEME_PARTSTATE cur = tc->partstate; + + while (cur) + { + if (cur->iPartId == iPartId) + return cur; + + cur = cur->next; + } + + if (tc->overrides) + return MSSTYLES_FindPart(tc->overrides, iPartId); + + return NULL; +} + /*********************************************************************** * MSSTYLES_FindPartState * diff --git a/dlls/uxtheme/msstyles.h b/dlls/uxtheme/msstyles.h index 12292cefae4..67f81315d7a 100644 --- a/dlls/uxtheme/msstyles.h +++ b/dlls/uxtheme/msstyles.h @@ -95,6 +95,7 @@ BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue) DECLSPE BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId) DECLSPEC_HIDDEN; PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf) DECLSPEC_HIDDEN; UINT MSSTYLES_GetThemeDPI(PTHEME_CLASS tc) DECLSPEC_HIDDEN; +PTHEME_PARTSTATE MSSTYLES_FindPart(PTHEME_CLASS tc, int iPartId) DECLSPEC_HIDDEN; PTHEME_PARTSTATE MSSTYLES_FindPartState(PTHEME_CLASS tc, int iPartId, int iStateId, PTHEME_CLASS *tcNext) DECLSPEC_HIDDEN; PTHEME_PROPERTY MSSTYLES_FindProperty(PTHEME_CLASS tc, int iPartId, int iStateId, int iPropertyPrimitive, int iPropertyId) DECLSPEC_HIDDEN; PTHEME_PROPERTY MSSTYLES_FindMetric(int iPropertyPrimitive, int iPropertyId) DECLSPEC_HIDDEN; diff --git a/dlls/uxtheme/system.c b/dlls/uxtheme/system.c index 61a608e5962..5e245b16d3a 100644 --- a/dlls/uxtheme/system.c +++ b/dlls/uxtheme/system.c @@ -809,9 +809,9 @@ BOOL WINAPI IsThemePartDefined(HTHEME hTheme, int iPartId, int iStateId) SetLastError(E_HANDLE); return FALSE; } - if(MSSTYLES_FindPartState(hTheme, iPartId, iStateId, NULL)) - return TRUE; - return FALSE; + + SetLastError(NO_ERROR); + return !iStateId && MSSTYLES_FindPart(hTheme, iPartId); }
/*********************************************************************** diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c index 40233bbe57d..b0124c14362 100644 --- a/dlls/uxtheme/tests/system.c +++ b/dlls/uxtheme/tests/system.c @@ -297,7 +297,6 @@ static void test_IsThemePartDefined(void) int state; BOOL defined; DWORD error; - BOOL todo; } tests[] = { @@ -308,7 +307,7 @@ static void test_IsThemePartDefined(void) {L"Button", BP_PUSHBUTTON, PBS_NORMAL, FALSE, NO_ERROR}, {L"Button", BP_PUSHBUTTON, PBS_DEFAULTED_ANIMATING, FALSE, NO_ERROR}, {L"Button", BP_PUSHBUTTON, PBS_DEFAULTED_ANIMATING + 1, FALSE, NO_ERROR}, - {L"Edit", EP_EDITTEXT, 0, TRUE, NO_ERROR, TRUE}, + {L"Edit", EP_EDITTEXT, 0, TRUE, NO_ERROR}, {L"Edit", EP_EDITTEXT, ETS_NORMAL, FALSE, NO_ERROR}, {L"Edit", EP_EDITTEXT, ETS_FOCUSED, FALSE, NO_ERROR}, }; @@ -334,9 +333,7 @@ static void test_IsThemePartDefined(void) SetLastError(0xdeadbeef); ret = IsThemePartDefined(theme, tests[i].part, tests[i].state); error = GetLastError(); - todo_wine_if(tests[i].todo) ok(ret == tests[i].defined, "Expected %d.\n", tests[i].defined); - todo_wine_if(error == 0xdeadbeef && tests[i].error == NO_ERROR) ok(error == tests[i].error, "Expected %#x, got %#x.\n", tests[i].error, error);
if (theme) @@ -586,12 +583,8 @@ static void test_OpenThemeData(void) SetLastError(0xdeadbeef); bTPDefined = IsThemePartDefined(hTheme, 0 , 0); todo_wine - { - ok( bTPDefined == FALSE, "Expected FALSE\n"); - ok( GetLastError() == ERROR_SUCCESS, - "Expected ERROR_SUCCESS, got 0x%08x\n", - GetLastError()); - } + ok( bTPDefined == FALSE, "Expected FALSE\n" ); + ok( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got 0x%08x\n", GetLastError() );
DestroyWindow(hWnd); }