From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/winemac.drv/display.c | 27 ++++++++++++++++----------- dlls/winemac.drv/macdrv.h | 7 +++++++ 2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 4b6740b9274..dc22131e36a 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -806,7 +806,7 @@ static BOOL get_primary_adapter(WCHAR *name) DWORD i;
dd.cb = sizeof(dd); - for (i = 0; EnumDisplayDevicesW(NULL, i, &dd, 0); ++i) + for (i = 0; !NtUserEnumDisplayDevices(NULL, i, &dd, 0); ++i) { if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { @@ -856,9 +856,11 @@ LONG macdrv_ChangeDisplaySettingsEx(LPCWSTR devname, LPDEVMODEW devmode,
if (!devname && !devmode) { + UNICODE_STRING str; memset(&default_mode, 0, sizeof(default_mode)); default_mode.dmSize = sizeof(default_mode); - if (!EnumDisplaySettingsExW(primary_adapter, ENUM_REGISTRY_SETTINGS, &default_mode, 0)) + RtlInitUnicodeString(&str, primary_adapter); + if (!NtUserEnumDisplaySettings(&str, ENUM_REGISTRY_SETTINGS, &default_mode, 0)) { ERR("Default mode not found for %s!\n", wine_dbgstr_w(primary_adapter)); return DISP_CHANGE_BADMODE; @@ -1009,7 +1011,7 @@ better: height *= 2; }
- SendMessageW(GetDesktopWindow(), WM_MACDRV_UPDATE_DESKTOP_RECT, mode_bpp, + send_message(NtUserGetDesktopWindow(), WM_MACDRV_UPDATE_DESKTOP_RECT, mode_bpp, MAKELPARAM(width, height)); ret = DISP_CHANGE_SUCCESSFUL; } @@ -1378,16 +1380,19 @@ static void init_registry_display_settings(void) { DEVMODEW dm = {.dmSize = sizeof(dm)}; DISPLAY_DEVICEW dd = {sizeof(dd)}; + UNICODE_STRING str; DWORD i = 0; LONG ret;
- while (EnumDisplayDevicesW(NULL, i++, &dd, 0)) + while (!NtUserEnumDisplayDevices(NULL, i++, &dd, 0)) { + RtlInitUnicodeString(&str, dd.DeviceName); + /* Skip if the device already has registry display settings */ - if (EnumDisplaySettingsExW(dd.DeviceName, ENUM_REGISTRY_SETTINGS, &dm, 0)) + if (NtUserEnumDisplaySettings(&str, ENUM_REGISTRY_SETTINGS, &dm, 0)) continue;
- if (!EnumDisplaySettingsExW(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm, 0)) + if (!NtUserEnumDisplaySettings(&str, ENUM_CURRENT_SETTINGS, &dm, 0)) { ERR("Failed to query current display settings for %s.\n", wine_dbgstr_w(dd.DeviceName)); continue; @@ -1397,8 +1402,8 @@ static void init_registry_display_settings(void) wine_dbgstr_w(dd.DeviceName), dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmDisplayFrequency, dm.dmPosition.x, dm.dmPosition.y);
- ret = ChangeDisplaySettingsExW(dd.DeviceName, &dm, NULL, - CDS_GLOBAL | CDS_NORESET | CDS_UPDATEREGISTRY, NULL); + ret = NtUserChangeDisplaySettings(&str, &dm, NULL, + CDS_GLOBAL | CDS_NORESET | CDS_UPDATEREGISTRY, NULL); if (ret != DISP_CHANGE_SUCCESSFUL) ERR("Failed to save registry display settings for %s, returned %d.\n", wine_dbgstr_w(dd.DeviceName), ret); @@ -1412,7 +1417,7 @@ static void init_registry_display_settings(void) */ void macdrv_displays_changed(const macdrv_event *event) { - HWND hwnd = GetDesktopWindow(); + HWND hwnd = NtUserGetDesktopWindow();
/* A system display change will get delivered to all GUI-attached threads, so the desktop-window-owning thread will get it and all others should @@ -1420,7 +1425,7 @@ void macdrv_displays_changed(const macdrv_event *event) will only get delivered to the activated process. So, it needs to process it (by sending it to the desktop window). */ if (event->displays_changed.activating || - GetWindowThreadProcessId(hwnd, NULL) == GetCurrentThreadId()) + NtUserGetWindowThread(hwnd, NULL) == GetCurrentThreadId()) { CGDirectDisplayID mainDisplay = CGMainDisplayID(); CGDisplayModeRef mode = CGDisplayCopyDisplayMode(mainDisplay); @@ -1442,7 +1447,7 @@ void macdrv_displays_changed(const macdrv_event *event) height *= 2; }
- SendMessageW(hwnd, WM_MACDRV_UPDATE_DESKTOP_RECT, mode_bpp, + send_message(hwnd, WM_MACDRV_UPDATE_DESKTOP_RECT, mode_bpp, MAKELPARAM(width, height)); } } diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 29fbe8a8cb9..2cac6acf4f3 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -295,6 +295,13 @@ extern void macdrv_im_set_text(const macdrv_event *event) DECLSPEC_HIDDEN; extern void macdrv_sent_text_input(const macdrv_event *event) DECLSPEC_HIDDEN; extern BOOL query_ime_char_rect(macdrv_query* query) DECLSPEC_HIDDEN;
+/* user helpers */ + +static inline LRESULT send_message(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + return NtUserMessageCall(hwnd, msg, wparam, lparam, NULL, NtUserSendMessage, FALSE); +} + /* registry helpers */
extern HKEY open_hkcu_key( const char *name ) DECLSPEC_HIDDEN;