Avoid using user32.
-- v2: winemac: Directly use win32u for user functions in window.c. winemac: Directly use win32u for user functions in opengl.c. winemac: Directly use win32u for user functions in mouse.c. winemac: Directly use win32u in more places. winemac: Directly use win32u for user functions in clipboard.c. winemac: Directly use win32u for user functions in display.c.
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;
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/clipboard.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 63c8bc76e75..9a498cde2f7 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -220,7 +220,7 @@ const char *debugstr_format(UINT id) { WCHAR buffer[256];
- if (GetClipboardFormatNameW(id, buffer, 256)) + if (NtUserGetClipboardFormatName(id, buffer, 256)) return wine_dbg_sprintf("0x%04x %s", id, debugstr_w(buffer));
switch (id) @@ -280,7 +280,7 @@ static WINE_CLIPFORMAT *insert_clipboard_format(UINT id, CFStringRef type) { WCHAR buffer[256];
- if (!GetClipboardFormatNameW(format->format_id, buffer, ARRAY_SIZE(buffer))) + if (!NtUserGetClipboardFormatName(format->format_id, buffer, ARRAY_SIZE(buffer))) { WARN("failed to get name for format %s; error 0x%08x\n", debugstr_format(format->format_id), GetLastError()); HeapFree(GetProcessHeap(), 0, format); @@ -338,6 +338,14 @@ static WINE_CLIPFORMAT* natural_format_for_format(UINT format_id) }
+static ATOM register_clipboard_format(const WCHAR *name) +{ + ATOM atom; + if (NtAddAtom(name, lstrlenW(name) * sizeof(WCHAR), &atom)) return 0; + return atom; +} + + /************************************************************************** * register_builtin_formats */ @@ -363,7 +371,7 @@ static void register_builtin_formats(void) for (i = 0; i < ARRAY_SIZE(builtin_format_names); i++) { if (!(format = HeapAlloc(GetProcessHeap(), 0, sizeof(*format)))) break; - format->format_id = RegisterClipboardFormatW(builtin_format_names[i].name); + format->format_id = register_clipboard_format(builtin_format_names[i].name); format->import_func = builtin_format_names[i].import; format->export_func = builtin_format_names[i].export; format->synthesized = builtin_format_names[i].synthesized; @@ -421,7 +429,7 @@ static WINE_CLIPFORMAT* format_for_type(CFStringRef type) (UniChar*)name); name[len] = 0;
- format = register_format(RegisterClipboardFormatW(name), type); + format = register_format(register_clipboard_format(name), type); if (!format) ERR("Failed to register format for type %s name %s\n", debugstr_cf(type), debugstr_w(name));
@@ -471,7 +479,7 @@ static HGLOBAL create_dib_from_bitmap(HBITMAP bitmap) { HANDLE ret = 0; BITMAPINFOHEADER header; - HDC hdc = GetDC(0); + HDC hdc = NtUserGetDCEx(0, 0, DCX_USESTYLE); DWORD header_size; BITMAPINFO *bmi;
@@ -487,7 +495,7 @@ static HGLOBAL create_dib_from_bitmap(HBITMAP bitmap) GetDIBits(hdc, bitmap, 0, abs(header.biHeight), (char *)bmi + header_size, bmi, DIB_RGB_COLORS);
done: - ReleaseDC(0, hdc); + NtUserReleaseDC(0, hdc); return ret; }
@@ -507,7 +515,7 @@ static HANDLE create_bitmap_from_dib(HANDLE dib) HDC hdc; unsigned int offset;
- hdc = GetDC(NULL); + hdc = NtUserGetDCEx(NULL, 0, DCX_USESTYLE);
offset = bitmap_info_size(bmi, DIB_RGB_COLORS);
@@ -515,7 +523,7 @@ static HANDLE create_bitmap_from_dib(HANDLE dib) bmi, DIB_RGB_COLORS);
GlobalUnlock(dib); - ReleaseDC(NULL, hdc); + NtUserReleaseDC(NULL, hdc); }
return ret; @@ -1762,13 +1770,13 @@ static void grab_win32_clipboard(void) if (last_types) CFRelease(last_types); last_types = types; /* takes ownership */
- if (!OpenClipboard(clipboard_hwnd)) return; - EmptyClipboard(); + if (!NtUserOpenClipboard(clipboard_hwnd, 0)) return; + NtUserEmptyClipboard(); is_clipboard_owner = TRUE; last_clipboard_update = GetTickCount64(); set_win32_clipboard_formats_from_mac_pasteboard(types); - CloseClipboard(); - SetTimer(clipboard_hwnd, 1, CLIPBOARD_UPDATE_DELAY, NULL); + NtUserCloseClipboard(); + NtUserSetTimer(clipboard_hwnd, 1, CLIPBOARD_UPDATE_DELAY, NULL, TIMERV_DEFAULT_COALESCING); }
@@ -1965,7 +1973,7 @@ static DWORD WINAPI clipboard_thread(void *arg) }
clipboard_thread_id = GetCurrentThreadId(); - AddClipboardFormatListener(clipboard_hwnd); + NtUserAddClipboardFormatListener(clipboard_hwnd); register_builtin_formats(); grab_win32_clipboard();
@@ -2217,7 +2225,7 @@ BOOL query_pasteboard_data(HWND hwnd, CFStringRef type)
last_get_seqno = GetClipboardSequenceNumber();
- CloseClipboard(); + NtUserCloseClipboard();
return ret; }
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/image.c | 6 +++--- dlls/winemac.drv/keyboard.c | 4 ++-- dlls/winemac.drv/macdrv.h | 7 +++++++ dlls/winemac.drv/macdrv_main.c | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/dlls/winemac.drv/image.c b/dlls/winemac.drv/image.c index d501b27a3c3..943ad97b749 100644 --- a/dlls/winemac.drv/image.c +++ b/dlls/winemac.drv/image.c @@ -70,7 +70,7 @@ CGImageRef create_cgimage_from_icon_bitmaps(HDC hdc, HANDLE icon, HBITMAP hbmCol /* draw the cursor frame to a temporary buffer then create a CGImage from that */ memset(color_bits, 0x00, color_size); NtGdiSelectBitmap(hdc, hbmColor); - if (!DrawIconEx(hdc, 0, 0, icon, width, height, istep, NULL, DI_NORMAL)) + if (!NtUserDrawIconEx(hdc, 0, 0, icon, width, height, istep, NULL, DI_NORMAL)) { WARN("Could not draw frame %d (walk past end of frames).\n", istep); return NULL; @@ -129,7 +129,7 @@ CGImageRef create_cgimage_from_icon_bitmaps(HDC hdc, HANDLE icon, HBITMAP hbmCol /* draw the cursor mask to a temporary buffer */ memset(mask_bits, 0xFF, mask_size); NtGdiSelectBitmap(hdc, hbmMask); - if (!DrawIconEx(hdc, 0, 0, icon, width, height, istep, NULL, DI_MASK)) + if (!NtUserDrawIconEx(hdc, 0, 0, icon, width, height, istep, NULL, DI_MASK)) { WARN("Failed to draw frame mask %d.\n", istep); CGImageRelease(cgimage); @@ -199,7 +199,7 @@ CGImageRef create_cgimage_from_icon(HANDLE icon, int width, int height) ICONINFO info; BITMAP bm;
- if (!GetIconInfo(icon, &info)) + if (!NtUserGetIconInfo(icon, &info, NULL, NULL, NULL, 0)) return NULL;
NtGdiExtGetObjectW(info.hbmMask, sizeof(bm), &bm); diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 79f208edfc8..9dca17e5c4e 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -1045,9 +1045,9 @@ void macdrv_keyboard_changed(const macdrv_event *event)
macdrv_compute_keyboard_layout(thread_data);
- ActivateKeyboardLayout(thread_data->active_keyboard_layout, 0); + NtUserActivateKeyboardLayout(thread_data->active_keyboard_layout, 0);
- SendMessageW(GetActiveWindow(), WM_CANCELMODE, 0, 0); + send_message(get_active_window(), WM_CANCELMODE, 0, 0); }
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 2cac6acf4f3..5cde6667a46 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -302,6 +302,13 @@ static inline LRESULT send_message(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp return NtUserMessageCall(hwnd, msg, wparam, lparam, NULL, NtUserSendMessage, FALSE); }
+static inline HWND get_active_window(void) +{ + GUITHREADINFO info; + info.cbSize = sizeof(info); + return NtUserGetGUIThreadInfo(GetCurrentThreadId(), &info) ? info.hwndActive : 0; +} + /* registry helpers */
extern HKEY open_hkcu_key( const char *name ) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index f7b530f50a7..2f05e55cb23 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -558,7 +558,7 @@ struct macdrv_thread_data *macdrv_init_thread_data(void) set_queue_display_fd(macdrv_get_event_queue_fd(data->queue)); TlsSetValue(thread_data_tls_index, data);
- ActivateKeyboardLayout(data->active_keyboard_layout, 0); + NtUserActivateKeyboardLayout(data->active_keyboard_layout, 0); return data; }
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/macdrv.h | 7 +++++++ dlls/winemac.drv/mouse.c | 40 ++++++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 5cde6667a46..29ad7216841 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -309,6 +309,13 @@ static inline HWND get_active_window(void) return NtUserGetGUIThreadInfo(GetCurrentThreadId(), &info) ? info.hwndActive : 0; }
+static inline HWND get_capture(void) +{ + GUITHREADINFO info; + info.cbSize = sizeof(info); + return NtUserGetGUIThreadInfo(GetCurrentThreadId(), &info) ? info.hwndCapture : 0; +} + /* registry helpers */
extern HKEY open_hkcu_key( const char *name ) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index e22cbe5e23f..52e978567de 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -131,7 +131,7 @@ static void send_mouse_input(HWND hwnd, macdrv_window cocoa_window, UINT flags, INPUT input; HWND top_level_hwnd;
- top_level_hwnd = GetAncestor(hwnd, GA_ROOT); + top_level_hwnd = NtUserGetAncestor(hwnd, GA_ROOT);
if ((flags & MOUSEEVENTF_MOVE) && (flags & MOUSEEVENTF_ABSOLUTE) && !drag && cocoa_window != macdrv_thread_data()->capture_window) @@ -500,7 +500,7 @@ static CFDictionaryRef create_cursor_frame(HDC hdc, const ICONINFOEXW *iinfo, HA CFDictionarySetValue(frame, CFSTR("hotSpot"), hot_spot_dict); CFRelease(hot_spot_dict);
- if (GetCursorFrameInfo(icon, 0x0 /* unknown parameter */, istep, &delay_jiffies, &num_steps) != 0) + if (NtUserGetCursorFrameInfo(icon, istep, &delay_jiffies, &num_steps) != 0) duration = delay_jiffies / 60.0; /* convert jiffies (1/60s) to seconds */ else { @@ -554,7 +554,7 @@ static CFArrayRef create_color_cursor(HDC hdc, const ICONINFOEXW *iinfo, HANDLE TRACE("hdc %p iinfo %p icon %p width %d height %d\n", hdc, iinfo, icon, width, height);
/* Retrieve the number of frames to render */ - if (!GetCursorFrameInfo(icon, 0x0 /* unknown parameter */, 0, &delay_jiffies, &nFrames)) + if (!NtUserGetCursorFrameInfo(icon, 0, &delay_jiffies, &nFrames)) { WARN("GetCursorFrameInfo failed\n"); return NULL; @@ -699,7 +699,7 @@ BOOL macdrv_GetCursorPos(LPPOINT pos) void macdrv_SetCapture(HWND hwnd, UINT flags) { struct macdrv_thread_data *thread_data = macdrv_thread_data(); - HWND top = GetAncestor(hwnd, GA_ROOT); + HWND top = NtUserGetAncestor(hwnd, GA_ROOT); macdrv_window cocoa_window = macdrv_get_cocoa_window(top, FALSE);
TRACE("hwnd %p top %p/%p flags 0x%08x\n", hwnd, top, cocoa_window, flags); @@ -711,6 +711,28 @@ BOOL macdrv_GetCursorPos(LPPOINT pos) }
+static BOOL get_icon_info(HICON handle, ICONINFOEXW *ret) +{ + UNICODE_STRING module, res_name; + ICONINFO info; + + module.Buffer = ret->szModName; + module.MaximumLength = sizeof(ret->szModName) - sizeof(WCHAR); + res_name.Buffer = ret->szResName; + res_name.MaximumLength = sizeof(ret->szResName) - sizeof(WCHAR); + if (!NtUserGetIconInfo(handle, &info, &module, &res_name, NULL, 0)) return FALSE; + ret->fIcon = info.fIcon; + ret->xHotspot = info.xHotspot; + ret->yHotspot = info.yHotspot; + ret->hbmColor = info.hbmColor; + ret->hbmMask = info.hbmMask; + ret->wResID = res_name.Length ? 0 : LOWORD(res_name.Buffer); + ret->szModName[module.Length] = 0; + ret->szResName[res_name.Length] = 0; + return TRUE; +} + + /*********************************************************************** * SetCursor (MACDRV.@) */ @@ -742,7 +764,7 @@ void macdrv_SetCursor(HCURSOR cursor) goto done;
info.cbSize = sizeof(info); - if (!GetIconInfoExW(cursor, &info)) + if (!get_icon_info(cursor, &info)) { WARN("GetIconInfoExW failed\n"); return; @@ -919,16 +941,16 @@ void macdrv_mouse_scroll(HWND hwnd, const macdrv_event *event) void macdrv_release_capture(HWND hwnd, const macdrv_event *event) { struct macdrv_thread_data *thread_data = macdrv_thread_data(); - HWND capture = GetCapture(); - HWND capture_top = GetAncestor(capture, GA_ROOT); + HWND capture = get_capture(); + HWND capture_top = NtUserGetAncestor(capture, GA_ROOT);
TRACE("win %p/%p thread_data->capture_window %p GetCapture() %p in %p\n", hwnd, event->window, thread_data->capture_window, capture, capture_top);
if (event->window == thread_data->capture_window && hwnd == capture_top) { - ReleaseCapture(); - if (!PostMessageW(capture, WM_CANCELMODE, 0, 0)) + NtUserReleaseCapture(); + if (!NtUserPostMessage(capture, WM_CANCELMODE, 0, 0)) WARN("failed to post WM_CANCELMODE; error 0x%08x\n", GetLastError()); } }
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/opengl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index bf7effa7aeb..3aa5c340e30 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -1330,7 +1330,7 @@ static int get_dc_pixel_format(HDC hdc) int format; HWND hwnd;
- if ((hwnd = WindowFromDC(hdc))) + if ((hwnd = NtUserWindowFromDC(hdc))) { struct macdrv_win_data *data;
@@ -1526,12 +1526,12 @@ static BOOL set_pixel_format(HDC hdc, int fmt, BOOL allow_reset) { struct macdrv_win_data *data; const pixel_format *pf; - HWND hwnd = WindowFromDC(hdc); + HWND hwnd = NtUserWindowFromDC(hdc); BOOL ret = FALSE;
TRACE("hdc %p format %d\n", hdc, fmt);
- if (!hwnd || hwnd == GetDesktopWindow()) + if (!hwnd || hwnd == NtUserGetDesktopWindow()) { WARN("not a proper window DC %p/%p\n", hdc, hwnd); return FALSE; @@ -3485,7 +3485,7 @@ static BOOL macdrv_wglMakeContextCurrentARB(HDC draw_hdc, HDC read_hdc, struct w return TRUE; }
- if ((hwnd = WindowFromDC(draw_hdc))) + if ((hwnd = NtUserWindowFromDC(draw_hdc))) { if (!(data = get_win_data(hwnd))) { @@ -3555,7 +3555,7 @@ static BOOL macdrv_wglMakeContextCurrentARB(HDC draw_hdc, HDC read_hdc, struct w context->read_pbuffer = NULL; if (read_hdc && read_hdc != draw_hdc) { - if ((hwnd = WindowFromDC(read_hdc))) + if ((hwnd = NtUserWindowFromDC(read_hdc))) { if ((data = get_win_data(hwnd))) { @@ -4543,7 +4543,7 @@ static BOOL WINAPI macdrv_wglSwapBuffers(HDC hdc) sync_context(context); }
- if ((hwnd = WindowFromDC(hdc))) + if ((hwnd = NtUserWindowFromDC(hdc))) { struct macdrv_win_data *data;
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/macdrv.h | 26 +++ dlls/winemac.drv/window.c | 362 ++++++++++++++++++++------------------ 2 files changed, 214 insertions(+), 174 deletions(-)
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 29ad7216841..68ab74dc56e 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -302,6 +302,16 @@ static inline LRESULT send_message(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp return NtUserMessageCall(hwnd, msg, wparam, lparam, NULL, NtUserSendMessage, FALSE); }
+static inline LRESULT send_message_timeout(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, + UINT flags, UINT timeout, PDWORD_PTR res_ptr) +{ + struct send_message_timeout_params params = { .flags = flags, .timeout = timeout }; + LRESULT res = NtUserMessageCall(hwnd, msg, wparam, lparam, ¶ms, + NtUserSendMessageTimeout, FALSE); + if (res_ptr) *res_ptr = params.result; + return res; +} + static inline HWND get_active_window(void) { GUITHREADINFO info; @@ -316,6 +326,22 @@ static inline HWND get_capture(void) return NtUserGetGUIThreadInfo(GetCurrentThreadId(), &info) ? info.hwndCapture : 0; }
+static inline HWND get_focus(void) +{ + GUITHREADINFO info; + info.cbSize = sizeof(info); + return NtUserGetGUIThreadInfo(GetCurrentThreadId(), &info) ? info.hwndFocus : 0; +} + +static inline BOOL intersect_rect( RECT *dst, const RECT *src1, const RECT *src2 ) +{ + dst->left = max(src1->left, src2->left); + dst->top = max(src1->top, src2->top); + dst->right = min(src1->right, src2->right); + dst->bottom = min(src1->bottom, src2->bottom); + return !IsRectEmpty( dst ); +} + /* registry helpers */
extern HKEY open_hkcu_key( const char *name ) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index e0dc2352d37..9faad78ac5e 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -91,11 +91,11 @@ static void get_cocoa_window_features(struct macdrv_win_data *data, */ static inline BOOL can_window_become_foreground(HWND hwnd) { - LONG style = GetWindowLongW(hwnd, GWL_STYLE); + LONG style = NtUserGetWindowLongW(hwnd, GWL_STYLE);
if (!(style & WS_VISIBLE)) return FALSE; if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; - if (hwnd == GetDesktopWindow()) return FALSE; + if (hwnd == NtUserGetDesktopWindow()) return FALSE; return !(style & WS_DISABLED); }
@@ -113,7 +113,7 @@ static void get_cocoa_window_state(struct macdrv_win_data *data, state->floating = (ex_style & WS_EX_TOPMOST) != 0; state->excluded_by_expose = state->excluded_by_cycle = (!(ex_style & WS_EX_APPWINDOW) && - (GetWindow(data->hwnd, GW_OWNER) || (ex_style & (WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE)))); + (NtUserGetWindowRelative(data->hwnd, GW_OWNER) || (ex_style & (WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE)))); if (IsRectEmpty(&data->window_rect)) state->excluded_by_expose = TRUE; state->minimized = (style & WS_MINIMIZE) != 0; @@ -134,7 +134,7 @@ static void get_mac_rect_offset(struct macdrv_win_data *data, DWORD style, RECT
rect->top = rect->bottom = rect->left = rect->right = 0;
- ex_style = GetWindowLongW(data->hwnd, GWL_EXSTYLE); + ex_style = NtUserGetWindowLongW(data->hwnd, GWL_EXSTYLE);
if (!data->shaped) { @@ -192,7 +192,7 @@ static void macdrv_window_to_mac_rect(struct macdrv_win_data *data, DWORD style, static void macdrv_mac_to_window_rect(struct macdrv_win_data *data, RECT *rect) { RECT rc; - DWORD style = GetWindowLongW(data->hwnd, GWL_STYLE); + DWORD style = NtUserGetWindowLongW(data->hwnd, GWL_STYLE);
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return; if (IsRectEmpty(rect)) return; @@ -341,12 +341,12 @@ static void set_cocoa_window_properties(struct macdrv_win_data *data) struct macdrv_window_features wf; struct macdrv_window_state state;
- style = GetWindowLongW(data->hwnd, GWL_STYLE); - ex_style = GetWindowLongW(data->hwnd, GWL_EXSTYLE); + style = NtUserGetWindowLongW(data->hwnd, GWL_STYLE); + ex_style = NtUserGetWindowLongW(data->hwnd, GWL_EXSTYLE);
- owner = GetWindow(data->hwnd, GW_OWNER); + owner = NtUserGetWindowRelative(data->hwnd, GW_OWNER); if (owner) - owner = GetAncestor(owner, GA_ROOT); + owner = NtUserGetAncestor(owner, GA_ROOT); owner_win = macdrv_get_cocoa_window(owner, TRUE); macdrv_set_cocoa_parent_window(data->cocoa_window, owner_win);
@@ -385,14 +385,14 @@ static void sync_window_region(struct macdrv_win_data *data, HRGN win_region) if (hrgn == (HRGN)1) /* hack: win_region == 1 means retrieve region from server */ { if (!(hrgn = NtGdiCreateRectRgn(0, 0, 0, 0))) return; - if (GetWindowRgn(data->hwnd, hrgn) == ERROR) + if (NtUserGetWindowRgnEx(data->hwnd, hrgn, 0) == ERROR) { NtGdiDeleteObjectApp(hrgn); hrgn = 0; } }
- if (hrgn && GetWindowLongW(data->hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL) + if (hrgn && NtUserGetWindowLongW(data->hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL) NtUserMirrorRgn(data->hwnd, hrgn); if (hrgn) { @@ -514,8 +514,8 @@ static void sync_window_opacity(struct macdrv_win_data *data, COLORREF key, BYTE */ static void sync_window_min_max_info(HWND hwnd) { - LONG style = GetWindowLongW(hwnd, GWL_STYLE); - LONG exstyle = GetWindowLongW(hwnd, GWL_EXSTYLE); + LONG style = NtUserGetWindowLongW(hwnd, GWL_STYLE); + LONG exstyle = NtUserGetWindowLongW(hwnd, GWL_EXSTYLE); RECT win_rect, primary_monitor_rect; MINMAXINFO minmax; LONG adjustedStyle; @@ -528,7 +528,7 @@ static void sync_window_min_max_info(HWND hwnd)
if (!macdrv_get_cocoa_window(hwnd, FALSE)) return;
- GetWindowRect(hwnd, &win_rect); + NtUserGetWindowRect(hwnd, &win_rect); minmax.ptReserved.x = win_rect.left; minmax.ptReserved.y = win_rect.top;
@@ -538,8 +538,8 @@ static void sync_window_min_max_info(HWND hwnd) adjustedStyle = style;
primary_monitor_rect.left = primary_monitor_rect.top = 0; - primary_monitor_rect.right = GetSystemMetrics(SM_CXSCREEN); - primary_monitor_rect.bottom = GetSystemMetrics(SM_CYSCREEN); + primary_monitor_rect.right = NtUserGetSystemMetrics(SM_CXSCREEN); + primary_monitor_rect.bottom = NtUserGetSystemMetrics(SM_CYSCREEN); AdjustWindowRectEx(&primary_monitor_rect, adjustedStyle, ((style & WS_POPUP) && GetMenu(hwnd)), exstyle);
xinc = -primary_monitor_rect.left; @@ -551,19 +551,19 @@ static void sync_window_min_max_info(HWND hwnd) minmax.ptMaxPosition.y = -yinc; if (style & (WS_DLGFRAME | WS_BORDER)) { - minmax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK); - minmax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK); + minmax.ptMinTrackSize.x = NtUserGetSystemMetrics(SM_CXMINTRACK); + minmax.ptMinTrackSize.y = NtUserGetSystemMetrics(SM_CYMINTRACK); } else { minmax.ptMinTrackSize.x = 2 * xinc; minmax.ptMinTrackSize.y = 2 * yinc; } - minmax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXMAXTRACK); - minmax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYMAXTRACK); + minmax.ptMaxTrackSize.x = NtUserGetSystemMetrics(SM_CXMAXTRACK); + minmax.ptMaxTrackSize.y = NtUserGetSystemMetrics(SM_CYMAXTRACK);
wpl.length = sizeof(wpl); - if (GetWindowPlacement(hwnd, &wpl) && (wpl.ptMaxPosition.x != -1 || wpl.ptMaxPosition.y != -1)) + if (NtUserGetWindowPlacement(hwnd, &wpl) && (wpl.ptMaxPosition.x != -1 || wpl.ptMaxPosition.y != -1)) { minmax.ptMaxPosition = wpl.ptMaxPosition;
@@ -575,19 +575,19 @@ static void sync_window_min_max_info(HWND hwnd) TRACE("initial ptMaxSize %s ptMaxPosition %s ptMinTrackSize %s ptMaxTrackSize %s\n", wine_dbgstr_point(&minmax.ptMaxSize), wine_dbgstr_point(&minmax.ptMaxPosition), wine_dbgstr_point(&minmax.ptMinTrackSize), wine_dbgstr_point(&minmax.ptMaxTrackSize));
- SendMessageW(hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax); + send_message(hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax);
TRACE("app's ptMaxSize %s ptMaxPosition %s ptMinTrackSize %s ptMaxTrackSize %s\n", wine_dbgstr_point(&minmax.ptMaxSize), wine_dbgstr_point(&minmax.ptMaxPosition), wine_dbgstr_point(&minmax.ptMinTrackSize), wine_dbgstr_point(&minmax.ptMaxTrackSize));
/* if the app didn't change the values, adapt them for the window's monitor */ - if ((monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY))) + if ((monitor = NtUserMonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY))) { MONITORINFO mon_info; RECT monitor_rect;
mon_info.cbSize = sizeof(mon_info); - GetMonitorInfoW(monitor, &mon_info); + NtUserGetMonitorInfo(monitor, &mon_info);
if ((style & WS_MAXIMIZEBOX) && ((style & WS_CAPTION) == WS_CAPTION || !(style & WS_POPUP))) monitor_rect = mon_info.rcWork; @@ -622,8 +622,8 @@ static void sync_window_min_max_info(HWND hwnd) macdrv_window_to_mac_rect(data, style, &min_rect, &data->window_rect, &data->client_rect); min_size = CGSizeMake(min_rect.right - min_rect.left, min_rect.bottom - min_rect.top);
- if (minmax.ptMaxTrackSize.x == GetSystemMetrics(SM_CXMAXTRACK) && - minmax.ptMaxTrackSize.y == GetSystemMetrics(SM_CYMAXTRACK)) + if (minmax.ptMaxTrackSize.x == NtUserGetSystemMetrics(SM_CXMAXTRACK) && + minmax.ptMaxTrackSize.y == NtUserGetSystemMetrics(SM_CYMAXTRACK)) max_size = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX); else { @@ -679,15 +679,15 @@ static void create_cocoa_window(struct macdrv_win_data *data) DWORD layered_flags;
if ((win_rgn = NtGdiCreateRectRgn(0, 0, 0, 0)) && - GetWindowRgn(data->hwnd, win_rgn) == ERROR) + NtUserGetWindowRgnEx(data->hwnd, win_rgn, 0) == ERROR) { NtGdiDeleteObjectApp(win_rgn); win_rgn = 0; } data->shaped = (win_rgn != 0);
- style = GetWindowLongW(data->hwnd, GWL_STYLE); - ex_style = GetWindowLongW(data->hwnd, GWL_EXSTYLE); + style = NtUserGetWindowLongW(data->hwnd, GWL_STYLE); + ex_style = NtUserGetWindowLongW(data->hwnd, GWL_EXSTYLE);
data->whole_rect = data->window_rect; macdrv_window_to_mac_rect(data, style, &data->whole_rect, &data->window_rect, &data->client_rect); @@ -709,14 +709,14 @@ static void create_cocoa_window(struct macdrv_win_data *data) set_cocoa_window_properties(data);
/* set the window text */ - if (!InternalGetWindowText(data->hwnd, text, ARRAY_SIZE(text))) text[0] = 0; + if (!NtUserInternalGetWindowText(data->hwnd, text, ARRAY_SIZE(text))) text[0] = 0; macdrv_set_cocoa_window_title(data->cocoa_window, text, strlenW(text));
/* set the window region */ if (win_rgn || IsRectEmpty(&data->window_rect)) sync_window_region(data, win_rgn);
/* set the window opacity */ - if (!GetLayeredWindowAttributes(data->hwnd, &key, &alpha, &layered_flags)) layered_flags = 0; + if (!NtUserGetLayeredWindowAttributes(data->hwnd, &key, &alpha, &layered_flags)) layered_flags = 0; sync_window_opacity(data, key, alpha, FALSE, layered_flags);
done: @@ -822,23 +822,23 @@ static struct macdrv_win_data *macdrv_create_win_data(HWND hwnd, const RECT *win struct macdrv_win_data *data; HWND parent;
- if (GetWindowThreadProcessId(hwnd, NULL) != GetCurrentThreadId()) return NULL; + if (NtUserGetWindowThread(hwnd, NULL) != GetCurrentThreadId()) return NULL;
- if (!(parent = GetAncestor(hwnd, GA_PARENT))) /* desktop */ + if (!(parent = NtUserGetAncestor(hwnd, GA_PARENT))) /* desktop */ { macdrv_init_thread_data(); return NULL; }
/* don't create win data for HWND_MESSAGE windows */ - if (parent != GetDesktopWindow() && !GetAncestor(parent, GA_PARENT)) return NULL; + if (parent != NtUserGetDesktopWindow() && !NtUserGetAncestor(parent, GA_PARENT)) return NULL;
if (!(data = alloc_win_data(hwnd))) return NULL;
data->whole_rect = data->window_rect = *window_rect; data->client_rect = *client_rect;
- if (parent == GetDesktopWindow()) + if (parent == NtUserGetDesktopWindow()) { create_cocoa_window(data); TRACE("win %p/%p window %s whole %s client %s\n", @@ -866,9 +866,9 @@ static BOOL is_owned_by(HWND hwnd, HWND maybe_owner) { while (1) { - HWND hwnd2 = GetWindow(hwnd, GW_OWNER); + HWND hwnd2 = NtUserGetWindowRelative(hwnd, GW_OWNER); if (!hwnd2) - hwnd2 = GetAncestor(hwnd, GA_ROOT); + hwnd2 = NtUserGetAncestor(hwnd, GA_ROOT); if (!hwnd2 || hwnd2 == hwnd) break; if (hwnd2 == maybe_owner) @@ -885,12 +885,12 @@ static BOOL is_owned_by(HWND hwnd, HWND maybe_owner) */ static BOOL is_all_the_way_front(HWND hwnd) { - BOOL topmost = (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0; + BOOL topmost = (NtUserGetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0; HWND prev = hwnd;
- while ((prev = GetWindow(prev, GW_HWNDPREV))) + while ((prev = NtUserGetWindowRelative(prev, GW_HWNDPREV))) { - if (!topmost && (GetWindowLongW(prev, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0) + if (!topmost && (NtUserGetWindowLongW(prev, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0) return TRUE; if (!is_owned_by(prev, hwnd)) return FALSE; @@ -907,10 +907,12 @@ static void set_focus(HWND hwnd, BOOL raise) { struct macdrv_win_data *data;
- if (!(hwnd = GetAncestor(hwnd, GA_ROOT))) return; + if (!(hwnd = NtUserGetAncestor(hwnd, GA_ROOT))) return;
- if (raise && hwnd == GetForegroundWindow() && hwnd != GetDesktopWindow() && !is_all_the_way_front(hwnd)) - SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOOWNERZORDER); + if (raise && hwnd == NtUserGetForegroundWindow() && hwnd != NtUserGetDesktopWindow() && + !is_all_the_way_front(hwnd)) + NtUserSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
if (!(data = get_win_data(hwnd))) return;
@@ -940,17 +942,17 @@ static void show_window(struct macdrv_win_data *data) GUITHREADINFO info;
/* find window that this one must be after */ - prev = GetWindow(data->hwnd, GW_HWNDPREV); - while (prev && !((GetWindowLongW(prev, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && + prev = NtUserGetWindowRelative(data->hwnd, GW_HWNDPREV); + while (prev && !((NtUserGetWindowLongW(prev, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && (prev_window = macdrv_get_cocoa_window(prev, TRUE)))) - prev = GetWindow(prev, GW_HWNDPREV); + prev = NtUserGetWindowRelative(prev, GW_HWNDPREV); if (!prev_window) { /* find window that this one must be before */ - next = GetWindow(data->hwnd, GW_HWNDNEXT); - while (next && !((GetWindowLongW(next, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && + next = NtUserGetWindowRelative(data->hwnd, GW_HWNDNEXT); + while (next && !((NtUserGetWindowLongW(next, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && (next_window = macdrv_get_cocoa_window(next, TRUE)))) - next = GetWindow(next, GW_HWNDNEXT); + next = NtUserGetWindowRelative(next, GW_HWNDNEXT); }
TRACE("win %p/%p below %p/%p above %p/%p\n", @@ -962,8 +964,8 @@ static void show_window(struct macdrv_win_data *data) data->on_screen = TRUE;
info.cbSize = sizeof(info); - if (GetGUIThreadInfo(GetWindowThreadProcessId(data->hwnd, NULL), &info) && info.hwndFocus && - (data->hwnd == info.hwndFocus || IsChild(data->hwnd, info.hwndFocus))) + if (NtUserGetGUIThreadInfo(NtUserGetWindowThread(data->hwnd, NULL), &info) && info.hwndFocus && + (data->hwnd == info.hwndFocus || NtUserIsChild(data->hwnd, info.hwndFocus))) set_focus(info.hwndFocus, FALSE); if (activate) activate_on_focus_time = 0; @@ -1000,7 +1002,7 @@ static void sync_window_z_order(struct macdrv_win_data *data) { if (data->cocoa_view) { - HWND parent = GetAncestor(data->hwnd, GA_PARENT); + HWND parent = NtUserGetAncestor(data->hwnd, GA_PARENT); macdrv_view superview = macdrv_get_client_cocoa_view(parent); macdrv_window window = NULL; HWND prev; @@ -1016,15 +1018,15 @@ static void sync_window_z_order(struct macdrv_win_data *data) }
/* find window that this one must be after */ - prev = GetWindow(data->hwnd, GW_HWNDPREV); + prev = NtUserGetWindowRelative(data->hwnd, GW_HWNDPREV); while (prev && !(prev_view = macdrv_get_cocoa_view(prev))) - prev = GetWindow(prev, GW_HWNDPREV); + prev = NtUserGetWindowRelative(prev, GW_HWNDPREV); if (!prev_view) { /* find window that this one must be before */ - next = GetWindow(data->hwnd, GW_HWNDNEXT); + next = NtUserGetWindowRelative(data->hwnd, GW_HWNDNEXT); while (next && !(next_view = macdrv_get_cocoa_view(next))) - next = GetWindow(next, GW_HWNDNEXT); + next = NtUserGetWindowRelative(next, GW_HWNDNEXT); }
TRACE("win %p/%p below %p/%p above %p/%p\n", @@ -1201,9 +1203,9 @@ static void move_window_bits(HWND hwnd, macdrv_window window, const RECT *old_re if (!window) { OffsetRect(&dst_rect, -new_window_rect->left, -new_window_rect->top); - parent = GetAncestor(hwnd, GA_PARENT); - hdc_src = GetDCEx(parent, 0, DCX_CACHE); - hdc_dst = GetDCEx(hwnd, 0, DCX_CACHE | DCX_WINDOW); + parent = NtUserGetAncestor(hwnd, GA_PARENT); + hdc_src = NtUserGetDCEx(parent, 0, DCX_CACHE); + hdc_dst = NtUserGetDCEx(hwnd, 0, DCX_CACHE | DCX_WINDOW); } else { @@ -1211,13 +1213,13 @@ static void move_window_bits(HWND hwnd, macdrv_window window, const RECT *old_re /* make src rect relative to the old position of the window */ OffsetRect(&src_rect, -old_client_rect->left, -old_client_rect->top); if (dst_rect.left == src_rect.left && dst_rect.top == src_rect.top) return; - hdc_src = hdc_dst = GetDCEx(hwnd, 0, DCX_CACHE); + hdc_src = hdc_dst = NtUserGetDCEx(hwnd, 0, DCX_CACHE); }
rgn = NtGdiCreateRectRgn(dst_rect.left, dst_rect.top, dst_rect.right, dst_rect.bottom); NtGdiExtSelectClipRgn(hdc_dst, rgn, RGN_COPY); NtGdiDeleteObjectApp(rgn); - ExcludeUpdateRgn(hdc_dst, hwnd); + NtUserExcludeUpdateRgn(hdc_dst, hwnd);
TRACE("copying bits for win %p/%p %s -> %s\n", hwnd, window, wine_dbgstr_rect(&src_rect), wine_dbgstr_rect(&dst_rect)); @@ -1225,8 +1227,8 @@ static void move_window_bits(HWND hwnd, macdrv_window window, const RECT *old_re dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top, hdc_src, src_rect.left, src_rect.top, SRCCOPY, 0, 0);
- ReleaseDC(hwnd, hdc_dst); - if (hdc_src != hdc_dst) ReleaseDC(parent, hdc_src); + NtUserReleaseDC(hwnd, hdc_dst); + if (hdc_src != hdc_dst) NtUserReleaseDC(parent, hdc_src); }
@@ -1279,12 +1281,21 @@ static BOOL set_capture_window_for_move(HWND hwnd) macdrv_SetCapture(hwnd, GUI_INMOVESIZE);
if (previous && previous != hwnd) - SendMessageW(previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd); + send_message(previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd); } return ret; }
+static HMONITOR monitor_from_point(POINT pt, UINT flags) +{ + RECT rect; + + SetRect(&rect, pt.x, pt.y, pt.x + 1, pt.y + 1); + return NtUserMonitorFromRect(&rect, flags); +} + + /*********************************************************************** * move_window * @@ -1298,9 +1309,9 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam) RECT origRect, movedRect, desktopRect; LONG hittest = (LONG)(wparam & 0x0f); POINT capturePoint; - LONG style = GetWindowLongW(hwnd, GWL_STYLE); + LONG style = NtUserGetWindowLongW(hwnd, GWL_STYLE); BOOL moved = FALSE; - DWORD dwPoint = GetMessagePos(); + DWORD dwPoint = NtUserGetThreadInfo()->message_pos; INT captionHeight; HMONITOR mon = 0; MONITORINFO info; @@ -1310,17 +1321,17 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam)
capturePoint.x = (short)LOWORD(dwPoint); capturePoint.y = (short)HIWORD(dwPoint); - ClipCursor(NULL); + NtUserClipCursor(NULL);
TRACE("hwnd %p hittest %d, pos %d,%d\n", hwnd, hittest, capturePoint.x, capturePoint.y);
origRect.left = origRect.right = origRect.top = origRect.bottom = 0; - if (AdjustWindowRectEx(&origRect, style, FALSE, GetWindowLongW(hwnd, GWL_EXSTYLE))) + if (AdjustWindowRectEx(&origRect, style, FALSE, NtUserGetWindowLongW(hwnd, GWL_EXSTYLE))) captionHeight = -origRect.top; else captionHeight = 0;
- GetWindowRect(hwnd, &origRect); + NtUserGetWindowRect(hwnd, &origRect); movedRect = origRect;
if (!hittest) @@ -1331,30 +1342,30 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam) /* Note: to be exactly centered we should take the different types * of border into account, but it shouldn't make more than a few pixels * of difference so let's not bother with that */ - rect.top += GetSystemMetrics(SM_CYBORDER); + rect.top += NtUserGetSystemMetrics(SM_CYBORDER); if (style & WS_SYSMENU) - rect.left += GetSystemMetrics(SM_CXSIZE) + 1; + rect.left += NtUserGetSystemMetrics(SM_CXSIZE) + 1; if (style & WS_MINIMIZEBOX) - rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; + rect.right -= NtUserGetSystemMetrics(SM_CXSIZE) + 1; if (style & WS_MAXIMIZEBOX) - rect.right -= GetSystemMetrics(SM_CXSIZE) + 1; + rect.right -= NtUserGetSystemMetrics(SM_CXSIZE) + 1; capturePoint.x = (rect.right + rect.left) / 2; - capturePoint.y = rect.top + GetSystemMetrics(SM_CYSIZE)/2; + capturePoint.y = rect.top + NtUserGetSystemMetrics(SM_CYSIZE)/2;
- SetCursorPos(capturePoint.x, capturePoint.y); - SendMessageW(hwnd, WM_SETCURSOR, (WPARAM)hwnd, MAKELONG(HTCAPTION, WM_MOUSEMOVE)); + NtUserSetCursorPos(capturePoint.x, capturePoint.y); + send_message(hwnd, WM_SETCURSOR, (WPARAM)hwnd, MAKELONG(HTCAPTION, WM_MOUSEMOVE)); }
desktopRect = rect_from_cgrect(macdrv_get_desktop_rect()); - mon = MonitorFromPoint(capturePoint, MONITOR_DEFAULTTONEAREST); + mon = monitor_from_point(capturePoint, MONITOR_DEFAULTTONEAREST); info.cbSize = sizeof(info); - if (mon && !GetMonitorInfoW(mon, &info)) + if (mon && !NtUserGetMonitorInfo(mon, &info)) mon = 0;
/* repaint the window before moving it around */ - RedrawWindow(hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN); + NtUserRedrawWindow(hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN);
- SendMessageW(hwnd, WM_ENTERSIZEMOVE, 0, 0); + send_message(hwnd, WM_ENTERSIZEMOVE, 0, 0); set_capture_window_for_move(hwnd);
while(1) @@ -1363,8 +1374,8 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam) int dx = 0, dy = 0; HMONITOR newmon;
- if (!GetMessageW(&msg, 0, 0, 0)) break; - if (CallMsgFilterW(&msg, MSGF_SIZE)) continue; + if (!NtUserGetMessage(&msg, 0, 0, 0)) break; + if (NtUserCallMsgFilter(&msg, MSGF_SIZE)) continue;
/* Exit on button-up, Return, or Esc */ if (msg.message == WM_LBUTTONUP || @@ -1373,8 +1384,8 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam)
if (msg.message != WM_KEYDOWN && msg.message != WM_MOUSEMOVE) { - TranslateMessage(&msg); - DispatchMessageW(&msg); + NtUserTranslateMessage(&msg, 0); + NtUserDispatchMessage(&msg); continue; /* We are not interested in other messages */ }
@@ -1393,9 +1404,9 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam) pt.y = max(pt.y, desktopRect.top); pt.y = min(pt.y, desktopRect.bottom - 1);
- if ((newmon = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL)) && newmon != mon) + if ((newmon = monitor_from_point(pt, MONITOR_DEFAULTTONULL)) && newmon != mon) { - if (GetMonitorInfoW(newmon, &info)) + if (NtUserGetMonitorInfo(newmon, &info)) mon = newmon; else mon = 0; @@ -1441,29 +1452,29 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam) { moved = TRUE;
- if (msg.message == WM_KEYDOWN) SetCursorPos(pt.x, pt.y); + if (msg.message == WM_KEYDOWN) NtUserSetCursorPos(pt.x, pt.y); else { OffsetRect(&movedRect, dx, dy); capturePoint = pt;
- SendMessageW(hwnd, WM_MOVING, 0, (LPARAM)&movedRect); - SetWindowPos(hwnd, 0, movedRect.left, movedRect.top, 0, 0, - SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); + send_message(hwnd, WM_MOVING, 0, (LPARAM)&movedRect); + NtUserSetWindowPos(hwnd, 0, movedRect.left, movedRect.top, 0, 0, + SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); } } }
set_capture_window_for_move(0);
- SendMessageW(hwnd, WM_EXITSIZEMOVE, 0, 0); - SendMessageW(hwnd, WM_SETVISIBLE, TRUE, 0L); + send_message(hwnd, WM_EXITSIZEMOVE, 0, 0); + send_message(hwnd, WM_SETVISIBLE, TRUE, 0L);
/* if the move is canceled, restore the previous position */ if (moved && msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) { - SetWindowPos(hwnd, 0, origRect.left, origRect.top, 0, 0, - SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); + NtUserSetWindowPos(hwnd, 0, origRect.left, origRect.top, 0, 0, + SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); }
return 0; @@ -1480,16 +1491,16 @@ static void perform_window_command(HWND hwnd, DWORD style_any, DWORD style_none, TRACE("win %p style_any 0x%08x style_none 0x%08x command 0x%04x hittest 0x%04x\n", hwnd, style_any, style_none, command, hittest);
- style = GetWindowLongW(hwnd, GWL_STYLE); + style = NtUserGetWindowLongW(hwnd, GWL_STYLE); if ((style_any && !(style & style_any)) || (style & (WS_DISABLED | style_none))) { TRACE("not changing win %p style 0x%08x\n", hwnd, style); return; }
- if (GetActiveWindow() != hwnd) + if (get_active_window() != hwnd) { - LRESULT ma = SendMessageW(hwnd, WM_MOUSEACTIVATE, (WPARAM)GetAncestor(hwnd, GA_ROOT), + LRESULT ma = send_message(hwnd, WM_MOUSEACTIVATE, (WPARAM)NtUserGetAncestor(hwnd, GA_ROOT), MAKELPARAM(hittest, WM_NCLBUTTONDOWN)); switch (ma) { @@ -1501,7 +1512,7 @@ static void perform_window_command(HWND hwnd, DWORD style_any, DWORD style_none, break; case MA_ACTIVATE: case 0: - SetActiveWindow(hwnd); + NtUserSetActiveWindow(hwnd); break; default: WARN("unknown WM_MOUSEACTIVATE code %ld\n", ma); @@ -1510,7 +1521,7 @@ static void perform_window_command(HWND hwnd, DWORD style_any, DWORD style_none, }
TRACE("changing win %p\n", hwnd); - PostMessageW(hwnd, WM_SYSCOMMAND, command, 0); + NtUserPostMessage(hwnd, WM_SYSCOMMAND, command, 0); }
@@ -1587,7 +1598,7 @@ LRESULT macdrv_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) */ BOOL macdrv_CreateWindow(HWND hwnd) { - if (hwnd == GetDesktopWindow()) + if (hwnd == NtUserGetDesktopWindow()) { macdrv_init_clipboard(); } @@ -1606,7 +1617,7 @@ void macdrv_DestroyWindow(HWND hwnd)
if (!(data = get_win_data(hwnd))) return;
- if (hwnd == GetCapture()) macdrv_SetCapture(0, 0); + if (hwnd == get_capture()) macdrv_SetCapture(0, 0); if (data->drag_event) SetEvent(data->drag_event);
destroy_cocoa_window(data); @@ -1656,7 +1667,7 @@ void macdrv_SetLayeredWindowAttributes(HWND hwnd, COLORREF key, BYTE alpha, DWOR { sync_window_opacity(data, key, alpha, FALSE, flags); /* since layered attributes are now set, can now show the window */ - if ((GetWindowLongW(hwnd, GWL_STYLE) & WS_VISIBLE) && !data->on_screen) + if ((NtUserGetWindowLongW(hwnd, GWL_STYLE) & WS_VISIBLE) && !data->on_screen) show_window(data); } release_win_data(data); @@ -1678,9 +1689,9 @@ void macdrv_SetParent(HWND hwnd, HWND parent, HWND old_parent) if (parent == old_parent) return; if (!(data = get_win_data(hwnd))) return;
- if (parent != GetDesktopWindow()) /* a child window */ + if (parent != NtUserGetDesktopWindow()) /* a child window */ { - if (old_parent == GetDesktopWindow()) + if (old_parent == NtUserGetDesktopWindow()) { /* destroy the old Mac window */ destroy_cocoa_window(data); @@ -1718,9 +1729,9 @@ void macdrv_SetWindowRgn(HWND hwnd, HRGN hrgn, BOOL redraw) { DWORD procid;
- GetWindowThreadProcessId(hwnd, &procid); + NtUserGetWindowThread(hwnd, &procid); if (procid != GetCurrentProcessId()) - SendMessageW(hwnd, WM_MACDRV_SET_WIN_REGION, 0, 0); + send_message(hwnd, WM_MACDRV_SET_WIN_REGION, 0, 0); } }
@@ -1736,7 +1747,7 @@ void macdrv_SetWindowStyle(HWND hwnd, INT offset, STYLESTRUCT *style)
TRACE("hwnd %p offset %d styleOld 0x%08x styleNew 0x%08x\n", hwnd, offset, style->styleOld, style->styleNew);
- if (hwnd == GetDesktopWindow()) return; + if (hwnd == NtUserGetDesktopWindow()) return; if (!(data = get_win_data(hwnd))) return;
if (data->cocoa_window) @@ -1788,7 +1799,7 @@ UINT macdrv_ShowWindow(HWND hwnd, INT cmd, RECT *rect, UINT swp) hwnd, data ? data->cocoa_window : NULL, cmd, wine_dbgstr_rect(rect), swp);
if (!data || !data->cocoa_window) goto done; - if (GetWindowLongW(hwnd, GWL_STYLE) & WS_MINIMIZE) + if (NtUserGetWindowLongW(hwnd, GWL_STYLE) & WS_MINIMIZE) { if (rect->left != -32000 || rect->top != -32000) { @@ -1839,7 +1850,7 @@ LRESULT macdrv_SysCommand(HWND hwnd, WPARAM wparam, LPARAM lparam) /* prevent a simple ALT press+release from activating the system menu, as that can get confusing */ if (command == SC_KEYMENU && !(WCHAR)lparam && !GetMenu(hwnd) && - (GetWindowLongW(hwnd, GWL_STYLE) & WS_SYSMENU)) + (NtUserGetWindowLongW(hwnd, GWL_STYLE) & WS_SYSMENU)) { TRACE("ignoring SC_KEYMENU wp %lx lp %lx\n", wparam, lparam); ret = 0; @@ -1927,7 +1938,7 @@ BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info, NtGdiSelectBitmap(hdc, dib); if (info->prcDirty) { - IntersectRect(&rect, &rect, info->prcDirty); + intersect_rect(&rect, &rect, info->prcDirty); surface->funcs->lock(surface); memcpy(src_bits, dst_bits, bmi->bmiHeader.biSizeImage); surface->funcs->unlock(surface); @@ -1987,23 +1998,23 @@ LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) } return 0; case WM_MACDRV_UPDATE_DESKTOP_RECT: - if (hwnd == GetDesktopWindow()) + if (hwnd == NtUserGetDesktopWindow()) { CGRect new_desktop_rect; RECT current_desktop_rect;
macdrv_reset_device_metrics(); new_desktop_rect = macdrv_get_desktop_rect(); - if (!GetWindowRect(hwnd, ¤t_desktop_rect) || + if (!NtUserGetWindowRect(hwnd, ¤t_desktop_rect) || !CGRectEqualToRect(cgrect_from_rect(current_desktop_rect), new_desktop_rect)) { - SendMessageTimeoutW(HWND_BROADCAST, WM_MACDRV_RESET_DEVICE_METRICS, 0, 0, - SMTO_ABORTIFHUNG, 2000, NULL); - SetWindowPos(hwnd, 0, CGRectGetMinX(new_desktop_rect), CGRectGetMinY(new_desktop_rect), - CGRectGetWidth(new_desktop_rect), CGRectGetHeight(new_desktop_rect), - SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE); - SendMessageTimeoutW(HWND_BROADCAST, WM_MACDRV_DISPLAYCHANGE, wp, lp, - SMTO_ABORTIFHUNG, 2000, NULL); + send_message_timeout(HWND_BROADCAST, WM_MACDRV_RESET_DEVICE_METRICS, 0, 0, + SMTO_ABORTIFHUNG, 2000, NULL); + NtUserSetWindowPos(hwnd, 0, CGRectGetMinX(new_desktop_rect), CGRectGetMinY(new_desktop_rect), + CGRectGetWidth(new_desktop_rect), CGRectGetHeight(new_desktop_rect), + SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE); + send_message_timeout(HWND_BROADCAST, WM_MACDRV_DISPLAYCHANGE, wp, lp, + SMTO_ABORTIFHUNG, 2000, NULL); } } return 0; @@ -2012,7 +2023,7 @@ LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) return 0; case WM_MACDRV_DISPLAYCHANGE: macdrv_reassert_window_position(hwnd); - SendMessageW(hwnd, WM_DISPLAYCHANGE, wp, lp); + send_message(hwnd, WM_DISPLAYCHANGE, wp, lp); return 0; case WM_MACDRV_ACTIVATE_ON_FOLLOWING_FOCUS: activate_on_following_focus(); @@ -2030,7 +2041,7 @@ static inline RECT get_surface_rect(const RECT *visible_rect) RECT rect; RECT desktop_rect = rect_from_cgrect(macdrv_get_desktop_rect());
- IntersectRect(&rect, visible_rect, &desktop_rect); + intersect_rect(&rect, visible_rect, &desktop_rect); OffsetRect(&rect, -visible_rect->left, -visible_rect->top); rect.left &= ~127; rect.top &= ~127; @@ -2048,7 +2059,7 @@ BOOL macdrv_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags, RECT *visible_rect, struct window_surface **surface) { struct macdrv_win_data *data = get_win_data(hwnd); - DWORD style = GetWindowLongW(hwnd, GWL_STYLE); + DWORD style = NtUserGetWindowLongW(hwnd, GWL_STYLE); RECT surface_rect;
TRACE("%p after %p swp %04x window %s client %s visible %s surface %p\n", hwnd, insert_after, @@ -2102,7 +2113,7 @@ void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags, { struct macdrv_thread_data *thread_data; struct macdrv_win_data *data; - DWORD new_style = GetWindowLongW(hwnd, GWL_STYLE); + DWORD new_style = NtUserGetWindowLongW(hwnd, GWL_STYLE); RECT old_window_rect, old_whole_rect, old_client_rect;
if (!(data = get_win_data(hwnd))) return; @@ -2213,7 +2224,7 @@ void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags,
/* layered windows are not shown until their attributes are set */ if (!data->on_screen && - (data->layered || !(GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED))) + (data->layered || !(NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED))) show_window(data); } else if (!data->on_screen) @@ -2234,16 +2245,17 @@ void macdrv_window_close_requested(HWND hwnd) { HMENU sysmenu;
- if (GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE) + if (NtUserGetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE) { TRACE("not closing win %p class style CS_NOCLOSE\n", hwnd); return; }
- sysmenu = GetSystemMenu(hwnd, FALSE); + sysmenu = NtUserGetSystemMenu(hwnd, FALSE); if (sysmenu) { - UINT state = GetMenuState(sysmenu, SC_CLOSE, MF_BYCOMMAND); + UINT state = NtUserThunkedMenuItemInfo(sysmenu, SC_CLOSE, MF_BYCOMMAND, + NtUserGetMenuState, NULL, NULL); if (state == 0xFFFFFFFF || (state & (MF_DISABLED | MF_GRAYED))) { TRACE("not closing win %p menu state 0x%08x\n", hwnd, state); @@ -2279,7 +2291,7 @@ void macdrv_window_frame_changed(HWND hwnd, const macdrv_event *event)
/* Get geometry */
- parent = GetAncestor(hwnd, GA_PARENT); + parent = NtUserGetAncestor(hwnd, GA_PARENT);
TRACE("win %p/%p new Cocoa frame %s fullscreen %d in_resize %d\n", hwnd, data->cocoa_window, wine_dbgstr_cgrect(event->window_frame_changed.frame), @@ -2287,7 +2299,7 @@ void macdrv_window_frame_changed(HWND hwnd, const macdrv_event *event)
rect = rect_from_cgrect(event->window_frame_changed.frame); macdrv_mac_to_window_rect(data, &rect); - MapWindowPoints(0, parent, (POINT *)&rect, 2); + NtUserMapWindowPoints(0, parent, (POINT *)&rect, 2);
width = rect.right - rect.left; height = rect.bottom - rect.top; @@ -2315,10 +2327,10 @@ void macdrv_window_frame_changed(HWND hwnd, const macdrv_event *event) { int send_sizemove = !event->window_frame_changed.in_resize && !being_dragged && !event->window_frame_changed.skip_size_move_loop; if (send_sizemove) - SendMessageW(hwnd, WM_ENTERSIZEMOVE, 0, 0); - SetWindowPos(hwnd, 0, rect.left, rect.top, width, height, flags); + send_message(hwnd, WM_ENTERSIZEMOVE, 0, 0); + NtUserSetWindowPos(hwnd, 0, rect.left, rect.top, width, height, flags); if (send_sizemove) - SendMessageW(hwnd, WM_EXITSIZEMOVE, 0, 0); + send_message(hwnd, WM_EXITSIZEMOVE, 0, 0); } }
@@ -2330,25 +2342,25 @@ void macdrv_window_frame_changed(HWND hwnd, const macdrv_event *event) */ void macdrv_window_got_focus(HWND hwnd, const macdrv_event *event) { - LONG style = GetWindowLongW(hwnd, GWL_STYLE); + LONG style = NtUserGetWindowLongW(hwnd, GWL_STYLE);
if (!hwnd) return;
TRACE("win %p/%p serial %lu enabled %d visible %d style %08x focus %p active %p fg %p\n", - hwnd, event->window, event->window_got_focus.serial, IsWindowEnabled(hwnd), - IsWindowVisible(hwnd), style, GetFocus(), GetActiveWindow(), GetForegroundWindow()); + hwnd, event->window, event->window_got_focus.serial, NtUserIsWindowEnabled(hwnd), + NtUserIsWindowVisible(hwnd), style, get_focus(), get_active_window(), NtUserGetForegroundWindow());
if (can_window_become_foreground(hwnd) && !(style & WS_MINIMIZE)) { /* simulate a mouse click on the menu to find out * whether the window wants to be activated */ - LRESULT ma = SendMessageW(hwnd, WM_MOUSEACTIVATE, - (WPARAM)GetAncestor(hwnd, GA_ROOT), + LRESULT ma = send_message(hwnd, WM_MOUSEACTIVATE, + (WPARAM)NtUserGetAncestor(hwnd, GA_ROOT), MAKELONG(HTMENU, WM_LBUTTONDOWN)); if (ma != MA_NOACTIVATEANDEAT && ma != MA_NOACTIVATE) { TRACE("setting foreground window to %p\n", hwnd); - SetForegroundWindow(hwnd); + NtUserSetForegroundWindow(hwnd, FALSE); return; } } @@ -2367,13 +2379,13 @@ void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) { if (!hwnd) return;
- TRACE("win %p/%p fg %p\n", hwnd, event->window, GetForegroundWindow()); + TRACE("win %p/%p fg %p\n", hwnd, event->window, NtUserGetForegroundWindow());
- if (hwnd == GetForegroundWindow()) + if (hwnd == NtUserGetForegroundWindow()) { - SendMessageW(hwnd, WM_CANCELMODE, 0, 0); - if (hwnd == GetForegroundWindow()) - SetForegroundWindow(GetDesktopWindow()); + send_message(hwnd, WM_CANCELMODE, 0, 0); + if (hwnd == NtUserGetForegroundWindow()) + NtUserSetForegroundWindow(NtUserGetDesktopWindow(), FALSE); } }
@@ -2397,12 +2409,12 @@ void macdrv_app_activated(void) */ void macdrv_app_deactivated(void) { - ClipCursor(NULL); + NtUserClipCursor(NULL);
- if (GetActiveWindow() == GetForegroundWindow()) + if (get_active_window() == NtUserGetForegroundWindow()) { TRACE("setting fg to desktop\n"); - SetForegroundWindow(GetDesktopWindow()); + NtUserSetForegroundWindow(NtUserGetDesktopWindow(), FALSE); } }
@@ -2440,7 +2452,7 @@ void macdrv_window_did_minimize(HWND hwnd)
/* If all our windows are minimized, disable cursor clipping. */ if (!macdrv_is_any_wine_window_visible()) - ClipCursor(NULL); + NtUserClipCursor(NULL); }
@@ -2459,15 +2471,15 @@ void macdrv_window_did_unminimize(HWND hwnd) if (!(data = get_win_data(hwnd))) return; if (!data->minimized) goto done;
- style = GetWindowLongW(hwnd, GWL_STYLE); + style = NtUserGetWindowLongW(hwnd, GWL_STYLE);
data->minimized = FALSE; if ((style & (WS_MINIMIZE | WS_VISIBLE)) == (WS_MINIMIZE | WS_VISIBLE)) { TRACE("restoring win %p/%p\n", hwnd, data->cocoa_window); release_win_data(data); - SetActiveWindow(hwnd); - SendMessageW(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); + NtUserSetActiveWindow(hwnd); + send_message(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); return; }
@@ -2486,7 +2498,7 @@ done: void macdrv_window_brought_forward(HWND hwnd) { TRACE("win %p\n", hwnd); - SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + NtUserSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); }
@@ -2498,7 +2510,7 @@ void macdrv_window_brought_forward(HWND hwnd) void macdrv_window_resize_ended(HWND hwnd) { TRACE("hwnd %p\n", hwnd); - SendMessageW(hwnd, WM_EXITSIZEMOVE, 0, 0); + send_message(hwnd, WM_EXITSIZEMOVE, 0, 0); }
@@ -2512,21 +2524,21 @@ void macdrv_window_restore_requested(HWND hwnd, const macdrv_event *event) { if (event->window_restore_requested.keep_frame && hwnd) { - DWORD style = GetWindowLongW(hwnd, GWL_STYLE); + DWORD style = NtUserGetWindowLongW(hwnd, GWL_STYLE); struct macdrv_win_data *data;
if ((style & WS_MAXIMIZE) && (style & WS_VISIBLE) && (data = get_win_data(hwnd))) { RECT rect; - HWND parent = GetAncestor(hwnd, GA_PARENT); + HWND parent = NtUserGetAncestor(hwnd, GA_PARENT);
rect = rect_from_cgrect(event->window_restore_requested.frame); macdrv_mac_to_window_rect(data, &rect); - MapWindowPoints(0, parent, (POINT *)&rect, 2); + NtUserMapWindowPoints(0, parent, (POINT *)&rect, 2);
release_win_data(data);
- SetInternalWindowPos(hwnd, SW_SHOW, &rect, NULL); + NtUserSetInternalWindowPos(hwnd, SW_SHOW, &rect, NULL); } }
@@ -2541,7 +2553,7 @@ void macdrv_window_restore_requested(HWND hwnd, const macdrv_event *event) */ void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event) { - DWORD style = GetWindowLongW(hwnd, GWL_STYLE); + DWORD style = NtUserGetWindowLongW(hwnd, GWL_STYLE); struct macdrv_win_data *data; HANDLE drag_event = NULL; BOOL loop = TRUE; @@ -2561,27 +2573,29 @@ void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event) data->drag_event = drag_event; release_win_data(data);
- if (!event->window_drag_begin.no_activate && can_window_become_foreground(hwnd) && GetForegroundWindow() != hwnd) + if (!event->window_drag_begin.no_activate && can_window_become_foreground(hwnd) && + NtUserGetForegroundWindow() != hwnd) { /* ask whether the window wants to be activated */ - LRESULT ma = SendMessageW(hwnd, WM_MOUSEACTIVATE, (WPARAM)GetAncestor(hwnd, GA_ROOT), + LRESULT ma = send_message(hwnd, WM_MOUSEACTIVATE, (WPARAM)NtUserGetAncestor(hwnd, GA_ROOT), MAKELONG(HTCAPTION, WM_LBUTTONDOWN)); if (ma != MA_NOACTIVATEANDEAT && ma != MA_NOACTIVATE) { TRACE("setting foreground window to %p\n", hwnd); - SetForegroundWindow(hwnd); + NtUserSetForegroundWindow(hwnd, FALSE); } }
- ClipCursor(NULL); - SendMessageW(hwnd, WM_ENTERSIZEMOVE, 0, 0); - ReleaseCapture(); + NtUserClipCursor(NULL); + send_message(hwnd, WM_ENTERSIZEMOVE, 0, 0); + NtUserReleaseCapture();
while (loop) { - while (!PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) + while (!NtUserPeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { - DWORD result = MsgWaitForMultipleObjectsEx(1, &drag_event, INFINITE, QS_ALLINPUT, MWMO_INPUTAVAILABLE); + DWORD result = NtUserMsgWaitForMultipleObjectsEx(1, &drag_event, INFINITE, QS_ALLINPUT, + MWMO_INPUTAVAILABLE); if (result == WAIT_OBJECT_0) { loop = FALSE; @@ -2594,15 +2608,15 @@ void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event) if (msg.message == WM_QUIT) break;
- if (!CallMsgFilterW(&msg, MSGF_SIZE) && msg.message != WM_KEYDOWN && + if (!NtUserCallMsgFilter(&msg, MSGF_SIZE) && msg.message != WM_KEYDOWN && msg.message != WM_MOUSEMOVE && msg.message != WM_LBUTTONDOWN && msg.message != WM_LBUTTONUP) { - TranslateMessage(&msg); - DispatchMessageW(&msg); + NtUserTranslateMessage(&msg, 0); + NtUserDispatchMessage(&msg); } }
- SendMessageW(hwnd, WM_EXITSIZEMOVE, 0, 0); + send_message(hwnd, WM_EXITSIZEMOVE, 0, 0);
TRACE("done\n");
@@ -2666,7 +2680,7 @@ static BOOL CALLBACK get_process_windows(HWND hwnd, LPARAM lp) struct quit_info *qi = (struct quit_info*)lp; DWORD pid;
- GetWindowThreadProcessId(hwnd, &pid); + NtUserGetWindowThread(hwnd, &pid); if (pid == GetCurrentProcessId()) { if (qi->count >= qi->capacity) @@ -2857,9 +2871,9 @@ BOOL query_resize_size(HWND hwnd, macdrv_query *query) else corner = WMSZ_BOTTOMRIGHT;
- if (SendMessageW(hwnd, WM_SIZING, corner, (LPARAM)&rect)) + if (send_message(hwnd, WM_SIZING, corner, (LPARAM)&rect)) { - macdrv_window_to_mac_rect(data, GetWindowLongW(hwnd, GWL_STYLE), &rect, + macdrv_window_to_mac_rect(data, NtUserGetWindowLongW(hwnd, GWL_STYLE), &rect, &data->window_rect, &data->client_rect); query->resize_size.rect = cgrect_from_rect(rect); ret = TRUE; @@ -2879,10 +2893,10 @@ BOOL query_resize_start(HWND hwnd) { TRACE("hwnd %p\n", hwnd);
- ClipCursor(NULL); + NtUserClipCursor(NULL);
sync_window_min_max_info(hwnd); - SendMessageW(hwnd, WM_ENTERSIZEMOVE, 0, 0); + send_message(hwnd, WM_ENTERSIZEMOVE, 0, 0);
return TRUE; }
Huw Davies (@huw) commented about dlls/winemac.drv/display.c:
DWORD i; dd.cb = sizeof(dd);
- for (i = 0; EnumDisplayDevicesW(NULL, i, &dd, 0); ++i)
- for (i = 0; NtUserEnumDisplayDevices(NULL, i, &dd, 0); ++i)
`NtUserEnumDisplayDevices()` returns NTSTATUS, so the test needs inverting. I've pushed an update (thanks for opening up your tree!)
This merge request was approved by Huw Davies.