Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/dwmapi/dwmapi_main.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/dlls/dwmapi/dwmapi_main.c b/dlls/dwmapi/dwmapi_main.c index 6378a09..e976fda 100644 --- a/dlls/dwmapi/dwmapi_main.c +++ b/dlls/dwmapi/dwmapi_main.c @@ -205,9 +205,31 @@ BOOL WINAPI DwmDefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, */ HRESULT WINAPI DwmGetWindowAttribute(HWND hwnd, DWORD attribute, PVOID pv_attribute, DWORD size) { - FIXME("(%p %d %p %d) stub\n", hwnd, attribute, pv_attribute, size); + if (!hwnd) return E_HANDLE; + if (!pv_attribute) return E_INVALIDARG;
- return E_NOTIMPL; + switch (attribute) + { + case DWMWA_NCRENDERING_ENABLED: + if (size < sizeof(BOOL)) return E_INVALIDARG; + + WARN("DWMWA_NCRENDERING_ENABLED: always returning FALSE.\n"); + *(BOOL*)(pv_attribute) = FALSE; + break; + + case DWMWA_CLOAKED: + if (size < sizeof(DWORD)) return E_INVALIDARG; + + WARN("DWMWA_CLOAKED: always returning 0.\n"); + *(DWORD*)(pv_attribute) = 0; + break; + + default: + FIXME("unimplemented attribute %d, size %u, for hwnd %p.\n", attribute, size, hwnd); + return E_INVALIDARG; + } + + return S_OK; }
/**********************************************************************
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- configure | 1 + configure.ac | 1 + dlls/dwmapi/tests/Makefile.in | 6 +++ dlls/dwmapi/tests/dwmapi.c | 88 +++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 dlls/dwmapi/tests/Makefile.in create mode 100644 dlls/dwmapi/tests/dwmapi.c
diff --git a/configure b/configure index 822669d..5cf03fd 100755 --- a/configure +++ b/configure @@ -20388,6 +20388,7 @@ wine_fn_config_makefile dlls/dssenh/tests enable_tests wine_fn_config_makefile dlls/dswave enable_dswave wine_fn_config_makefile dlls/dswave/tests enable_tests wine_fn_config_makefile dlls/dwmapi enable_dwmapi +wine_fn_config_makefile dlls/dwmapi/tests enable_tests wine_fn_config_makefile dlls/dwrite enable_dwrite wine_fn_config_makefile dlls/dwrite/tests enable_tests wine_fn_config_makefile dlls/dx8vb enable_dx8vb diff --git a/configure.ac b/configure.ac index 7f2c3cd..a69e9df 100644 --- a/configure.ac +++ b/configure.ac @@ -3243,6 +3243,7 @@ WINE_CONFIG_MAKEFILE(dlls/dssenh/tests) WINE_CONFIG_MAKEFILE(dlls/dswave) WINE_CONFIG_MAKEFILE(dlls/dswave/tests) WINE_CONFIG_MAKEFILE(dlls/dwmapi) +WINE_CONFIG_MAKEFILE(dlls/dwmapi/tests) WINE_CONFIG_MAKEFILE(dlls/dwrite) WINE_CONFIG_MAKEFILE(dlls/dwrite/tests) WINE_CONFIG_MAKEFILE(dlls/dx8vb) diff --git a/dlls/dwmapi/tests/Makefile.in b/dlls/dwmapi/tests/Makefile.in new file mode 100644 index 0000000..778a40f --- /dev/null +++ b/dlls/dwmapi/tests/Makefile.in @@ -0,0 +1,6 @@ +TESTDLL = dwmapi.dll +IMPORTS = gdi32 user32 + + +C_SRCS = \ + dwmapi.c diff --git a/dlls/dwmapi/tests/dwmapi.c b/dlls/dwmapi/tests/dwmapi.c new file mode 100644 index 0000000..a520991 --- /dev/null +++ b/dlls/dwmapi/tests/dwmapi.c @@ -0,0 +1,88 @@ +/* + * Copyright 2019 Gabriel Ivăncescu for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "windows.h" +#include <dwmapi.h> +#include "wine/test.h" + +static HRESULT (WINAPI *pDwmGetWindowAttribute)(HWND, DWORD, PVOID, DWORD); + +static HWND test_wnd; +static LRESULT WINAPI test_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + return DefWindowProcA(hwnd, message, wParam, lParam); +} + +static void test_DwmGetWindowAttribute(void) +{ + BOOL nc_rendering; + HRESULT hr; + + hr = pDwmGetWindowAttribute(NULL, DWMWA_NCRENDERING_ENABLED, &nc_rendering, sizeof(nc_rendering)); + ok(hr == E_HANDLE || broken(hr == E_INVALIDARG) /* Vista */, "DwmGetWindowAttribute(DWMWA_NCRENDERING_ENABLED) returned 0x%08x.\n", hr); + hr = pDwmGetWindowAttribute(test_wnd, DWMWA_NCRENDERING_ENABLED, NULL, sizeof(nc_rendering)); + ok(hr == E_INVALIDARG, "DwmGetWindowAttribute(DWMWA_NCRENDERING_ENABLED) returned 0x%08x.\n", hr); + hr = pDwmGetWindowAttribute(test_wnd, DWMWA_NCRENDERING_ENABLED, &nc_rendering, 0); + ok(hr == E_INVALIDARG, "DwmGetWindowAttribute(DWMWA_NCRENDERING_ENABLED) returned 0x%08x.\n", hr); + nc_rendering = FALSE; + hr = pDwmGetWindowAttribute(test_wnd, 0xdeadbeef, &nc_rendering, sizeof(nc_rendering)); + ok(hr == E_INVALIDARG, "DwmGetWindowAttribute(0xdeadbeef) returned 0x%08x.\n", hr); + + nc_rendering = 0xdeadbeef; + hr = pDwmGetWindowAttribute(test_wnd, DWMWA_NCRENDERING_ENABLED, &nc_rendering, sizeof(nc_rendering)); + ok(hr == S_OK, "DwmGetWindowAttribute(DWMWA_NCRENDERING_ENABLED) failed 0x%08x.\n", hr); + ok(nc_rendering == FALSE || nc_rendering == TRUE, "non-boolean value 0x%x.\n", nc_rendering); +} + +START_TEST(dwmapi) +{ + HINSTANCE inst = GetModuleHandleA(NULL); + HMODULE module; + WNDCLASSA cls; + + module = LoadLibraryA("dwmapi.dll"); + if (!module) + { + win_skip("dwmapi.dll not found\n"); + return; + } + + pDwmGetWindowAttribute = (void*)GetProcAddress(module, "DwmGetWindowAttribute"); + + cls.style = 0; + cls.lpfnWndProc = test_wndproc; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = inst; + cls.hIcon = 0; + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = "Test"; + RegisterClassA(&cls); + + test_wnd = CreateWindowExA(0, "Test", "Test Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok(test_wnd != NULL, "Failed to create test window.\n"); + + test_DwmGetWindowAttribute(); + + DestroyWindow(test_wnd); + UnregisterClassA("Test", inst); + FreeLibrary(module); +}
Gabriel Ivăncescu gabrielopcode@gmail.com writes:
+START_TEST(dwmapi) +{
- HINSTANCE inst = GetModuleHandleA(NULL);
- HMODULE module;
- WNDCLASSA cls;
- module = LoadLibraryA("dwmapi.dll");
- if (!module)
- {
win_skip("dwmapi.dll not found\n");
return;
- }
- pDwmGetWindowAttribute = (void*)GetProcAddress(module, "DwmGetWindowAttribute");
There shouldn't be any reason not to link to it directly.
On 12/13/19 1:25 PM, Alexandre Julliard wrote:
Gabriel Ivăncescu gabrielopcode@gmail.com writes:
+START_TEST(dwmapi) +{
- HINSTANCE inst = GetModuleHandleA(NULL);
- HMODULE module;
- WNDCLASSA cls;
- module = LoadLibraryA("dwmapi.dll");
- if (!module)
- {
win_skip("dwmapi.dll not found\n");
return;
- }
- pDwmGetWindowAttribute = (void*)GetProcAddress(module, "DwmGetWindowAttribute");
There shouldn't be any reason not to link to it directly.
As far as I know, it's not available on Windows XP, wouldn't it fail to even load in that case?
Gabriel Ivăncescu gabrielopcode@gmail.com writes:
On 12/13/19 1:25 PM, Alexandre Julliard wrote:
Gabriel Ivăncescu gabrielopcode@gmail.com writes:
+START_TEST(dwmapi) +{
- HINSTANCE inst = GetModuleHandleA(NULL);
- HMODULE module;
- WNDCLASSA cls;
- module = LoadLibraryA("dwmapi.dll");
- if (!module)
- {
win_skip("dwmapi.dll not found\n");
return;
- }
- pDwmGetWindowAttribute = (void*)GetProcAddress(module, "DwmGetWindowAttribute");
There shouldn't be any reason not to link to it directly.
As far as I know, it's not available on Windows XP, wouldn't it fail to even load in that case?
It wouldn't be run at all if the dll is missing.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
This stops Unity games like Variables (steam appid 1054800) from complaining when changing full-screen mode.
dlls/dwmapi/Makefile.in | 1 + dlls/dwmapi/dwmapi_main.c | 7 +++++++ dlls/dwmapi/tests/dwmapi.c | 14 ++++++++++++++ 3 files changed, 22 insertions(+)
diff --git a/dlls/dwmapi/Makefile.in b/dlls/dwmapi/Makefile.in index 3a36913..d273a22 100644 --- a/dlls/dwmapi/Makefile.in +++ b/dlls/dwmapi/Makefile.in @@ -1,5 +1,6 @@ MODULE = dwmapi.dll IMPORTLIB = dwmapi +IMPORTS = user32
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/dwmapi/dwmapi_main.c b/dlls/dwmapi/dwmapi_main.c index e976fda..212c88c 100644 --- a/dlls/dwmapi/dwmapi_main.c +++ b/dlls/dwmapi/dwmapi_main.c @@ -217,6 +217,13 @@ HRESULT WINAPI DwmGetWindowAttribute(HWND hwnd, DWORD attribute, PVOID pv_attrib *(BOOL*)(pv_attribute) = FALSE; break;
+ case DWMWA_EXTENDED_FRAME_BOUNDS: + if (size < sizeof(RECT)) return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + + WARN("DWMWA_EXTENDED_FRAME_BOUNDS: returning window rect.\n"); + GetWindowRect(hwnd, pv_attribute); + break; + case DWMWA_CLOAKED: if (size < sizeof(DWORD)) return E_INVALIDARG;
diff --git a/dlls/dwmapi/tests/dwmapi.c b/dlls/dwmapi/tests/dwmapi.c index a520991..1463140 100644 --- a/dlls/dwmapi/tests/dwmapi.c +++ b/dlls/dwmapi/tests/dwmapi.c @@ -31,6 +31,7 @@ static LRESULT WINAPI test_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARA static void test_DwmGetWindowAttribute(void) { BOOL nc_rendering; + RECT rc, rc2; HRESULT hr;
hr = pDwmGetWindowAttribute(NULL, DWMWA_NCRENDERING_ENABLED, &nc_rendering, sizeof(nc_rendering)); @@ -47,6 +48,19 @@ static void test_DwmGetWindowAttribute(void) hr = pDwmGetWindowAttribute(test_wnd, DWMWA_NCRENDERING_ENABLED, &nc_rendering, sizeof(nc_rendering)); ok(hr == S_OK, "DwmGetWindowAttribute(DWMWA_NCRENDERING_ENABLED) failed 0x%08x.\n", hr); ok(nc_rendering == FALSE || nc_rendering == TRUE, "non-boolean value 0x%x.\n", nc_rendering); + + hr = pDwmGetWindowAttribute(test_wnd, DWMWA_EXTENDED_FRAME_BOUNDS, &rc, sizeof(rc) - 1); + ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) || broken(hr == E_INVALIDARG) /* Vista */, + "DwmGetWindowAttribute(DWMWA_EXTENDED_FRAME_BOUNDS) returned 0x%08x.\n", hr); + hr = pDwmGetWindowAttribute(test_wnd, DWMWA_EXTENDED_FRAME_BOUNDS, &rc, sizeof(rc)); + if (hr != E_HANDLE && broken(hr != DWM_E_COMPOSITIONDISABLED) /* Vista */) /* composition is on */ + { + /* For top-level Windows, the returned rect is always at least as large as GetWindowRect */ + GetWindowRect(test_wnd, &rc2); + ok(hr == S_OK, "DwmGetWindowAttribute(DWMWA_EXTENDED_FRAME_BOUNDS) failed 0x%08x.\n", hr); + ok(rc.left >= rc2.left && rc.right <= rc2.right && rc.top >= rc2.top && rc.bottom <= rc2.bottom, + "returned rect %s not enclosed in window rect %s.\n", wine_dbgstr_rect(&rc), wine_dbgstr_rect(&rc2)); + } }
START_TEST(dwmapi)