Jacek Caban : winemac: Directly use ntdll in more places.

Alexandre Julliard julliard at winehq.org
Fri May 27 16:35:29 CDT 2022


Module: wine
Branch: master
Commit: 671f6b2af60250f5e0e9d07a821a1d935d67b898
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=671f6b2af60250f5e0e9d07a821a1d935d67b898

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu May 26 01:32:31 2022 +0200

winemac: Directly use ntdll in more places.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>

---

 dlls/winemac.drv/clipboard.c   | 10 +++++-----
 dlls/winemac.drv/macdrv_main.c | 10 +++++-----
 dlls/winemac.drv/mouse.c       |  6 +++---
 dlls/winemac.drv/opengl.c      |  2 +-
 dlls/winemac.drv/window.c      | 17 +++++++++--------
 5 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c
index d7d28c69acb..dca62997028 100644
--- a/dlls/winemac.drv/clipboard.c
+++ b/dlls/winemac.drv/clipboard.c
@@ -190,7 +190,7 @@ static DWORD clipboard_thread_id;
 static HWND clipboard_hwnd;
 static BOOL is_clipboard_owner;
 static macdrv_window clipboard_cocoa_window;
-static ULONG64 last_clipboard_update;
+static ULONG last_clipboard_update;
 static DWORD last_get_seqno;
 static WINE_CLIPFORMAT **current_mac_formats;
 static unsigned int nb_current_mac_formats;
@@ -1542,7 +1542,7 @@ static void grab_win32_clipboard(void)
     if (!NtUserOpenClipboard(clipboard_hwnd, 0)) return;
     NtUserEmptyClipboard();
     is_clipboard_owner = TRUE;
-    last_clipboard_update = GetTickCount64();
+    last_clipboard_update = NtGetTickCount();
     set_win32_clipboard_formats_from_mac_pasteboard(types);
     NtUserCloseClipboard();
     NtUserSetTimer(clipboard_hwnd, 1, CLIPBOARD_UPDATE_DELAY, NULL, TIMERV_DEFAULT_COALESCING);
@@ -1559,15 +1559,15 @@ static void update_clipboard(void)
 {
     static BOOL updating;
 
-    TRACE("is_clipboard_owner %d last_clipboard_update %llu now %llu\n",
-          is_clipboard_owner, (unsigned long long)last_clipboard_update, (unsigned long long)GetTickCount64());
+    TRACE("is_clipboard_owner %d last_clipboard_update %u now %u\n",
+          is_clipboard_owner, last_clipboard_update, NtGetTickCount());
 
     if (updating) return;
     updating = TRUE;
 
     if (is_clipboard_owner)
     {
-        if (GetTickCount64() - last_clipboard_update > CLIPBOARD_UPDATE_DELAY)
+        if (NtGetTickCount() - last_clipboard_update > CLIPBOARD_UPDATE_DELAY)
             grab_win32_clipboard();
     }
     else if (!macdrv_is_pasteboard_owner(clipboard_cocoa_window))
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c
index fbd4663373b..a0dc9c494da 100644
--- a/dlls/winemac.drv/macdrv_main.c
+++ b/dlls/winemac.drv/macdrv_main.c
@@ -507,7 +507,7 @@ static void set_queue_display_fd(int fd)
     if (wine_server_fd_to_handle(fd, GENERIC_READ | SYNCHRONIZE, 0, &handle))
     {
         MESSAGE("macdrv: Can't allocate handle for event queue fd\n");
-        ExitProcess(1);
+        NtTerminateProcess(0, 1);
     }
     SERVER_START_REQ(set_queue_fd)
     {
@@ -518,9 +518,9 @@ static void set_queue_display_fd(int fd)
     if (ret)
     {
         MESSAGE("macdrv: Can't store handle for event queue fd\n");
-        ExitProcess(1);
+        NtTerminateProcess(0, 1);
     }
-    CloseHandle(handle);
+    NtClose(handle);
 }
 
 
@@ -537,13 +537,13 @@ struct macdrv_thread_data *macdrv_init_thread_data(void)
     if (!(data = calloc(1, sizeof(*data))))
     {
         ERR("could not create data\n");
-        ExitProcess(1);
+        NtTerminateProcess(0, 1);
     }
 
     if (!(data->queue = macdrv_create_event_queue(macdrv_handle_event)))
     {
         ERR("macdrv: Can't create event queue.\n");
-        ExitProcess(1);
+        NtTerminateProcess(0, 1);
     }
 
     macdrv_get_input_source_info(&data->keyboard_layout_uchr, &data->keyboard_type, &data->iso_keyboard, &input_source);
diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c
index 4d672029833..d5db014dece 100644
--- a/dlls/winemac.drv/mouse.c
+++ b/dlls/winemac.drv/mouse.c
@@ -853,7 +853,7 @@ void macdrv_mouse_button(HWND hwnd, const macdrv_event *event)
     TRACE("win %p button %d %s at (%d,%d) time %lu (%lu ticks ago)\n", hwnd, event->mouse_button.button,
           (event->mouse_button.pressed ? "pressed" : "released"),
           event->mouse_button.x, event->mouse_button.y,
-          event->mouse_button.time_ms, (GetTickCount() - event->mouse_button.time_ms));
+          event->mouse_button.time_ms, (NtGetTickCount() - event->mouse_button.time_ms));
 
     if (event->mouse_button.pressed)
     {
@@ -900,7 +900,7 @@ void macdrv_mouse_moved(HWND hwnd, const macdrv_event *event)
     TRACE("win %p/%p %s (%d,%d) drag %d time %lu (%lu ticks ago)\n", hwnd, event->window,
           (event->type == MOUSE_MOVED) ? "relative" : "absolute",
           event->mouse_moved.x, event->mouse_moved.y, event->mouse_moved.drag,
-          event->mouse_moved.time_ms, (GetTickCount() - event->mouse_moved.time_ms));
+          event->mouse_moved.time_ms, (NtGetTickCount() - event->mouse_moved.time_ms));
 
     if (event->type == MOUSE_MOVED_ABSOLUTE)
         flags |= MOUSEEVENTF_ABSOLUTE;
@@ -920,7 +920,7 @@ void macdrv_mouse_scroll(HWND hwnd, const macdrv_event *event)
     TRACE("win %p/%p scroll (%d,%d) at (%d,%d) time %lu (%lu ticks ago)\n", hwnd,
           event->window, event->mouse_scroll.x_scroll, event->mouse_scroll.y_scroll,
           event->mouse_scroll.x, event->mouse_scroll.y,
-          event->mouse_scroll.time_ms, (GetTickCount() - event->mouse_scroll.time_ms));
+          event->mouse_scroll.time_ms, (NtGetTickCount() - event->mouse_scroll.time_ms));
 
     if (event->mouse_scroll.y_scroll)
         send_mouse_input(hwnd, event->window, MOUSEEVENTF_WHEEL | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c
index 9f884e33c18..cf58588981f 100644
--- a/dlls/winemac.drv/opengl.c
+++ b/dlls/winemac.drv/opengl.c
@@ -2218,7 +2218,7 @@ static void macdrv_glFlush(void)
     if (skip_single_buffer_flushes)
     {
         const pixel_format *pf = &pixel_formats[context->format - 1];
-        DWORD now = GetTickCount();
+        DWORD now = NtGetTickCount();
 
         TRACE("double buffer %d last flush time %d now %d\n", (int)pf->double_buffer,
               context->last_flush_time, now);
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index 4d55a277833..36e34abbd12 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -918,7 +918,7 @@ static void set_focus(HWND hwnd, BOOL raise)
 
     if (data->cocoa_window && data->on_screen)
     {
-        BOOL activate = activate_on_focus_time && (GetTickCount() - activate_on_focus_time < 2000);
+        BOOL activate = activate_on_focus_time && (NtGetTickCount() - activate_on_focus_time < 2000);
         /* Set Mac focus */
         macdrv_give_cocoa_window_focus(data->cocoa_window, activate);
         activate_on_focus_time = 0;
@@ -959,7 +959,7 @@ static void show_window(struct macdrv_win_data *data)
               data->hwnd, data->cocoa_window, prev, prev_window, next, next_window);
 
         if (!prev_window)
-            activate = activate_on_focus_time && (GetTickCount() - activate_on_focus_time < 2000);
+            activate = activate_on_focus_time && (NtGetTickCount() - activate_on_focus_time < 2000);
         macdrv_order_cocoa_window(data->cocoa_window, prev_window, next_window, activate);
         data->on_screen = TRUE;
 
@@ -1236,7 +1236,7 @@ static void move_window_bits(HWND hwnd, macdrv_window window, const RECT *old_re
  */
 void activate_on_following_focus(void)
 {
-    activate_on_focus_time = GetTickCount();
+    activate_on_focus_time = NtGetTickCount();
     if (!activate_on_focus_time) activate_on_focus_time = 1;
 }
 
@@ -1617,7 +1617,7 @@ void macdrv_DestroyWindow(HWND hwnd)
     if (!(data = get_win_data(hwnd))) return;
 
     if (hwnd == get_capture()) macdrv_SetCapture(0, 0);
-    if (data->drag_event) SetEvent(data->drag_event);
+    if (data->drag_event) NtSetEvent(data->drag_event, NULL);
 
     destroy_cocoa_window(data);
     destroy_cocoa_view(data);
@@ -2555,6 +2555,7 @@ void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event)
     DWORD style = NtUserGetWindowLongW(hwnd, GWL_STYLE);
     struct macdrv_win_data *data;
     HANDLE drag_event = NULL;
+    OBJECT_ATTRIBUTES attr;
     BOOL loop = TRUE;
     MSG msg;
 
@@ -2566,8 +2567,8 @@ void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event)
     if (!(data = get_win_data(hwnd))) return;
     if (data->drag_event) goto done;
 
-    drag_event = CreateEventW(NULL, TRUE, FALSE, NULL);
-    if (!drag_event) goto done;
+    InitializeObjectAttributes(&attr, NULL, OBJ_OPENIF, NULL, NULL);
+    if (NtCreateEvent(&drag_event, EVENT_ALL_ACCESS, &attr, NotificationEvent, FALSE)) goto done;
 
     data->drag_event = drag_event;
     release_win_data(data);
@@ -2624,7 +2625,7 @@ void macdrv_window_drag_begin(HWND hwnd, const macdrv_event *event)
 
 done:
     release_win_data(data);
-    if (drag_event) CloseHandle(drag_event);
+    if (drag_event) NtClose(drag_event);
 }
 
 
@@ -2641,7 +2642,7 @@ void macdrv_window_drag_end(HWND hwnd)
 
     if (!(data = get_win_data(hwnd))) return;
     if (data->drag_event)
-        SetEvent(data->drag_event);
+        NtSetEvent(data->drag_event, NULL);
     release_win_data(data);
 }
 




More information about the wine-cvs mailing list