From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/keyboard.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 08c76eb1389..94860f2e36c 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -1266,9 +1266,11 @@ INT macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size)
if (!len) { - static const WCHAR format[] = {'K','e','y',' ','0','x','%','0','2','x',0}; - snprintfW(buffer, size, format, vkey); - len = strlenW(buffer); + char name[16]; + len = sprintf(name, "Key 0x%02x", vkey); + len = min(len + 1, size); + ascii_to_unicode(buffer, name, len); + if (len) buffer[--len] = 0; }
if (!len)
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index d2780aa8bcb..eefc915d6e2 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -808,7 +808,11 @@ static void *import_utf8_to_unicodetext(CFDataRef data, size_t *ret_size) dst[j++] = 0;
if ((ret = malloc(j * sizeof(WCHAR)))) - *ret_size = MultiByteToWideChar(CP_UTF8, 0, dst, j, ret, j) * sizeof(WCHAR); + { + DWORD dst_size; + RtlUTF8ToUnicodeN(ret, j * sizeof(WCHAR), &dst_size, dst, j); + *ret_size = dst_size; + }
free(dst); } @@ -1031,10 +1035,12 @@ static CFDataRef export_html(void *data, size_t size) static CFDataRef export_unicodetext_to_utf8(void *data, size_t size) { CFMutableDataRef ret; - INT dst_len; + WCHAR *src = data; + DWORD dst_len = 0;
- dst_len = WideCharToMultiByte(CP_UTF8, 0, data, -1, NULL, 0, NULL, NULL); - if (dst_len) dst_len--; /* Leave off null terminator. */ + /* Leave off null terminator. */ + if (size >= sizeof(WCHAR) && !src[size / sizeof(WCHAR) - 1]) size -= sizeof(WCHAR); + RtlUnicodeToUTF8N(NULL, 0, &dst_len, src, size); ret = CFDataCreateMutable(NULL, dst_len); if (ret) { @@ -1043,7 +1049,7 @@ static CFDataRef export_unicodetext_to_utf8(void *data, size_t size)
CFDataSetLength(ret, dst_len); dst = (LPSTR)CFDataGetMutableBytePtr(ret); - WideCharToMultiByte(CP_UTF8, 0, data, -1, dst, dst_len, NULL, NULL); + RtlUnicodeToUTF8N(dst, dst_len, &dst_len, src, size);
/* Remove carriage returns */ for (i = 0, j = 0; i < dst_len; i++)
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index eefc915d6e2..1b637123e0f 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -567,6 +567,21 @@ static void *import_html(CFDataRef data, size_t *ret_size) }
+static CPTABLEINFO *get_ansi_cp(void) +{ + USHORT utf8_hdr[2] = { 0, CP_UTF8 }; + static CPTABLEINFO cp; + if (!cp.CodePage) + { + if (NtCurrentTeb()->Peb->AnsiCodePageData) + RtlInitCodePageTable(NtCurrentTeb()->Peb->AnsiCodePageData, &cp); + else + RtlInitCodePageTable(utf8_hdr, &cp); + } + return &cp; +} + + /* based on wine_get_dos_file_name */ static WCHAR *get_dos_file_name(const char *path) { @@ -942,21 +957,22 @@ static CFDataRef export_hdrop_to_filenames(void *data, size_t size) unixname = get_unix_file_name(p); else { - int len = MultiByteToWideChar(CP_ACP, 0, p, -1, NULL, 0); - if (len) - { - if (len > buffer_len) - { - free(buffer); - buffer_len = len * 2; - buffer = malloc(buffer_len * sizeof(*buffer)); - } + CPTABLEINFO *cp = get_ansi_cp(); + DWORD len = strlen(p) + 1;
- MultiByteToWideChar(CP_ACP, 0, p, -1, buffer, buffer_len); - unixname = get_unix_file_name(buffer); + if (len * 3 > buffer_len) + { + free(buffer); + buffer_len = len * 3; + buffer = malloc(buffer_len * sizeof(*buffer)); } + + if (cp->CodePage == CP_UTF8) + RtlUTF8ToUnicodeN(buffer, buffer_len * sizeof(WCHAR), &len, p, len); else - unixname = NULL; + RtlCustomCPToUnicodeN(cp, buffer, buffer_len * sizeof(WCHAR), &len, p, len); + + unixname = get_unix_file_name(buffer); } if (!unixname) {
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 1b637123e0f..d7d28c69acb 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -1473,8 +1473,9 @@ static void set_win32_clipboard_formats_from_mac_pasteboard(CFArrayRef types)
for (i = 0; i < count; i++) { + struct set_clipboard_params params = { 0 }; TRACE("adding format %s\n", debugstr_format(formats[i]->format_id)); - SetClipboardData(formats[i]->format_id, 0); + NtUserSetClipboardData(formats[i]->format_id, 0, ¶ms); }
free(current_mac_formats);
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@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); }
This merge request was approved by Huw Davies.