From 88a69b446bd310e563185dcd4ec73bc29837485a Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Mon, 7 Jan 2019 11:38:42 +0200 Subject: [PATCH] [UXTHEME] Fix a series of problems regarding ThemeCalculateCaptionButtonsPos Only call it when needed. Also make it fail properly if the window theme could not be opened. CORE-15564 --- dll/win32/uxtheme/nonclient.c | 6 +++++- dll/win32/uxtheme/themehooks.c | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dll/win32/uxtheme/nonclient.c b/dll/win32/uxtheme/nonclient.c index 4171e09264d..1ff26a32184 100644 --- a/dll/win32/uxtheme/nonclient.c +++ b/dll/win32/uxtheme/nonclient.c @@ -230,7 +230,11 @@ void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme) return; if (!htheme) - htheme = pwndData->hthemeWindow; + { + htheme = GetNCCaptionTheme(hWnd, style); + if (!htheme) + return; + } if(!GetWindowInfo(hWnd, &wi)) return; diff --git a/dll/win32/uxtheme/themehooks.c b/dll/win32/uxtheme/themehooks.c index 99811808f7a..583fce34d4f 100644 --- a/dll/win32/uxtheme/themehooks.c +++ b/dll/win32/uxtheme/themehooks.c @@ -323,7 +323,8 @@ ThemePreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR case WM_SIZE: case WM_WINDOWPOSCHANGED: { - ThemeCalculateCaptionButtonsPos(hWnd, NULL); + if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT)) + ThemeCalculateCaptionButtonsPos(hWnd, NULL); break; } case WM_THEMECHANGED: @@ -360,7 +361,11 @@ ThemePreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR pwndData->hthemeScrollbar = NULL; } - ThemeCalculateCaptionButtonsPos(hWnd, NULL); + if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT)) + ThemeCalculateCaptionButtonsPos(hWnd, NULL); + + pwndData->DirtyThemeRegion = TRUE; + break; } case WM_NCCREATE: {