From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/win32u/driver.c | 22 +--------------------- dlls/win32u/message.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index 175fde1fa40..ebc512bb4ee 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -792,35 +792,15 @@ static inline LARGE_INTEGER *get_nt_timeout( LARGE_INTEGER *time, DWORD timeout return time; }
-static HANDLE normalize_std_handle( HANDLE handle ) -{ - if (handle == (HANDLE)STD_INPUT_HANDLE) - return NtCurrentTeb()->Peb->ProcessParameters->hStdInput; - if (handle == (HANDLE)STD_OUTPUT_HANDLE) - return NtCurrentTeb()->Peb->ProcessParameters->hStdOutput; - if (handle == (HANDLE)STD_ERROR_HANDLE) - return NtCurrentTeb()->Peb->ProcessParameters->hStdError; - - return handle; -} - static DWORD nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout, DWORD mask, DWORD flags ) { NTSTATUS status; - HANDLE hloc[MAXIMUM_WAIT_OBJECTS]; LARGE_INTEGER time; - unsigned int i;
if (!count && !timeout) return WAIT_TIMEOUT; - if (count > MAXIMUM_WAIT_OBJECTS) - { - SetLastError(ERROR_INVALID_PARAMETER); - return WAIT_FAILED; - } - for (i = 0; i < count; i++) hloc[i] = normalize_std_handle( handles[i] );
- status = NtWaitForMultipleObjects( count, hloc, !(flags & MWMO_WAITALL), !!(flags & MWMO_ALERTABLE), + status = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), !!(flags & MWMO_ALERTABLE), get_nt_timeout( &time, timeout ) ); if (HIWORD(status)) /* is it an error code? */ { diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index d43dca723d2..67990e7b1f4 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -1963,6 +1963,18 @@ static DWORD wait_objects( DWORD count, const HANDLE *handles, DWORD timeout, return ret; }
+static HANDLE normalize_std_handle( HANDLE handle ) +{ + if (handle == (HANDLE)STD_INPUT_HANDLE) + return NtCurrentTeb()->Peb->ProcessParameters->hStdInput; + if (handle == (HANDLE)STD_OUTPUT_HANDLE) + return NtCurrentTeb()->Peb->ProcessParameters->hStdOutput; + if (handle == (HANDLE)STD_ERROR_HANDLE) + return NtCurrentTeb()->Peb->ProcessParameters->hStdError; + + return handle; +} + /*********************************************************************** * NtUserMsgWaitForMultipleObjectsEx (win32u.@) */ @@ -1979,7 +1991,7 @@ DWORD WINAPI NtUserMsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handl }
/* add the queue to the handle list */ - for (i = 0; i < count; i++) wait_handles[i] = handles[i]; + for (i = 0; i < count; i++) wait_handles[i] = normalize_std_handle( handles[i] ); wait_handles[count] = get_server_queue_handle();
return wait_objects( count+1, wait_handles, timeout,
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/win32u/dce.c | 3 ++- dlls/win32u/driver.c | 28 ++++++---------------------- dlls/win32u/input.c | 3 ++- dlls/win32u/message.c | 20 ++++++++++++++++++-- dlls/wineandroid.drv/android.h | 5 +++-- dlls/wineandroid.drv/window.c | 9 +++++---- dlls/winemac.drv/event.c | 18 +++++++++--------- dlls/winemac.drv/macdrv.h | 5 +++-- dlls/winex11.drv/event.c | 18 +++++++++--------- dlls/winex11.drv/x11drv.h | 5 +++-- include/wine/gdi_driver.h | 4 ++-- 11 files changed, 62 insertions(+), 56 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 80f630b5614..c41067af464 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -1432,6 +1432,7 @@ static void update_now( HWND hwnd, UINT rdw_flags ) */ BOOL WINAPI NtUserRedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags ) { + LARGE_INTEGER zero = { .QuadPart = 0 }; static const RECT empty; BOOL ret;
@@ -1452,7 +1453,7 @@ BOOL WINAPI NtUserRedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT fla }
/* process pending expose events before painting */ - if (flags & RDW_UPDATENOW) user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_PAINT, 0 ); + if (flags & RDW_UPDATENOW) user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, &zero, QS_PAINT, 0 );
if (rect && !hrgn) { diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index ebc512bb4ee..f3c1d419b1d 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -784,30 +784,14 @@ static void nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rec { }
-/* helper for kernel32->ntdll timeout format conversion */ -static inline LARGE_INTEGER *get_nt_timeout( LARGE_INTEGER *time, DWORD timeout ) +static NTSTATUS nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, + const LARGE_INTEGER *timeout, + DWORD mask, DWORD flags ) { - if (timeout == INFINITE) return NULL; - time->QuadPart = (ULONGLONG)timeout * -10000; - return time; -} - -static DWORD nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout, - DWORD mask, DWORD flags ) -{ - NTSTATUS status; - LARGE_INTEGER time; + if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT;
- if (!count && !timeout) return WAIT_TIMEOUT; - - status = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), !!(flags & MWMO_ALERTABLE), - get_nt_timeout( &time, timeout ) ); - if (HIWORD(status)) /* is it an error code? */ - { - SetLastError( RtlNtStatusToDosError(status) ); - status = WAIT_FAILED; - } - return status; + return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), + !!(flags & MWMO_ALERTABLE), timeout ); }
static void nulldrv_ReleaseDC( HWND hwnd, HDC hdc ) diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index 28fc5a918c8..877e3f1a064 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -268,7 +268,8 @@ BOOL WINAPI NtUserGetCursorInfo( CURSORINFO *info )
static void check_for_events( UINT flags ) { - if (user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, flags, 0 ) == WAIT_TIMEOUT) + LARGE_INTEGER zero = { .QuadPart = 0 }; + if (user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, &zero, flags, 0 ) == WAIT_TIMEOUT) flush_window_surfaces( TRUE ); }
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 67990e7b1f4..e67f9adcbe7 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -1897,8 +1897,9 @@ static inline void check_for_driver_events( UINT msg ) { if (get_user_thread_info()->message_count > 200) { + LARGE_INTEGER zero = { .QuadPart = 0 }; flush_window_surfaces( FALSE ); - user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_ALLINPUT, 0 ); + user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, &zero, QS_ALLINPUT, 0 ); } else if (msg == WM_TIMER || msg == WM_SYSTIMER) { @@ -1908,9 +1909,18 @@ static inline void check_for_driver_events( UINT msg ) else get_user_thread_info()->message_count++; }
+/* helper for kernel32->ntdll timeout format conversion */ +static inline LARGE_INTEGER *get_nt_timeout( LARGE_INTEGER *time, DWORD timeout ) +{ + if (timeout == INFINITE) return NULL; + time->QuadPart = (ULONGLONG)timeout * -10000; + return time; +} + /* wait for message or signaled handle */ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DWORD mask, DWORD flags ) { + LARGE_INTEGER time; DWORD ret, lock; void *ret_ptr; ULONG ret_len; @@ -1918,7 +1928,13 @@ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DW if (enable_thunk_lock) lock = KeUserModeCallback( NtUserThunkLock, NULL, 0, &ret_ptr, &ret_len );
- ret = user_driver->pMsgWaitForMultipleObjectsEx( count, handles, timeout, mask, flags ); + ret = user_driver->pMsgWaitForMultipleObjectsEx( count, handles, get_nt_timeout( &time, timeout ), + mask, flags ); + if (HIWORD(ret)) /* is it an error code? */ + { + SetLastError( RtlNtStatusToDosError(ret) ); + ret = WAIT_FAILED; + } if (ret == WAIT_TIMEOUT && !count && !timeout) NtYieldExecution(); if ((mask & QS_INPUT) == QS_INPUT) get_user_thread_info()->message_count = 0;
diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index 34f7ef877dc..93e3c2201bf 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -86,8 +86,9 @@ extern SHORT ANDROID_VkKeyScanEx( WCHAR ch, HKL hkl ) DECLSPEC_HIDDEN; extern void ANDROID_SetCursor( HCURSOR handle ) DECLSPEC_HIDDEN; extern BOOL ANDROID_CreateWindow( HWND hwnd ) DECLSPEC_HIDDEN; extern void ANDROID_DestroyWindow( HWND hwnd ) DECLSPEC_HIDDEN; -extern DWORD ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout, - DWORD mask, DWORD flags ) DECLSPEC_HIDDEN; +extern NTSTATUS ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, + const LARGE_INTEGER *timeout, + DWORD mask, DWORD flags ) DECLSPEC_HIDDEN; extern void ANDROID_SetCursor( HCURSOR handle ) DECLSPEC_HIDDEN; extern void ANDROID_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags ) DECLSPEC_HIDDEN; diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 81466259fc5..5143990836f 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -1201,8 +1201,9 @@ static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp, /*********************************************************************** * ANDROID_MsgWaitForMultipleObjectsEx */ -DWORD ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, - DWORD timeout, DWORD mask, DWORD flags ) +NTSTATUS ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, + const LARGE_INTEGER *timeout, + DWORD mask, DWORD flags ) { if (GetCurrentThreadId() == desktop_tid) { @@ -1210,8 +1211,8 @@ DWORD ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, if (current_event) mask = 0; if (process_events( mask )) return count - 1; } - return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL, - timeout, flags & MWMO_ALERTABLE ); + return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), + !!(flags & MWMO_ALERTABLE), timeout ); }
/********************************************************************** diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index a3135f9d2ca..45ceb09c094 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -339,21 +339,21 @@ static int process_events(macdrv_event_queue queue, macdrv_event_mask mask) /*********************************************************************** * MsgWaitForMultipleObjectsEx (MACDRV.@) */ -DWORD macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, - DWORD timeout, DWORD mask, DWORD flags) +NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, + const LARGE_INTEGER *timeout, DWORD mask, DWORD flags) { DWORD ret; struct macdrv_thread_data *data = macdrv_thread_data(); macdrv_event_mask event_mask = get_event_mask(mask);
- TRACE("count %d, handles %p, timeout %u, mask %x, flags %x\n", count, + TRACE("count %d, handles %p, timeout %p, mask %x, flags %x\n", count, handles, timeout, mask, flags);
if (!data) { - if (!count && !timeout) return WAIT_TIMEOUT; - return WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL, - timeout, flags & MWMO_ALERTABLE); + if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT; + return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), + !!(flags & MWMO_ALERTABLE), timeout ); }
if (data->current_event && data->current_event->type != QUERY_EVENT && @@ -363,10 +363,10 @@ DWORD macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, event_mask = 0; /* don't process nested events */
if (process_events(data->queue, event_mask)) ret = count - 1; - else if (count || timeout) + else if (count || !timeout || timeout->QuadPart) { - ret = WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL, - timeout, flags & MWMO_ALERTABLE); + ret = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), + !!(flags & MWMO_ALERTABLE), timeout ); if (ret == count - 1) process_events(data->queue, event_mask); } else ret = WAIT_TIMEOUT; diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index f7ffe0fa1f6..d13a2277e61 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -173,8 +173,9 @@ extern UINT macdrv_GetKeyboardLayoutList(INT size, HKL *list) DECLSPEC_HIDDEN; extern INT macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size) DECLSPEC_HIDDEN; extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_param, UINT flags) DECLSPEC_HIDDEN; -extern DWORD macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, - DWORD timeout, DWORD mask, DWORD flags) DECLSPEC_HIDDEN; +extern NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, + const LARGE_INTEGER *timeout, DWORD mask, + DWORD flags) DECLSPEC_HIDDEN; extern void macdrv_ThreadDetach(void) DECLSPEC_HIDDEN;
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 729a0a7eab6..5a22464d594 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -476,26 +476,26 @@ static BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,X /*********************************************************************** * MsgWaitForMultipleObjectsEx (X11DRV.@) */ -DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, - DWORD timeout, DWORD mask, DWORD flags ) +NTSTATUS X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, + const LARGE_INTEGER *timeout, DWORD mask, DWORD flags ) { struct x11drv_thread_data *data = x11drv_thread_data(); - DWORD ret; + NTSTATUS ret;
if (!data) { - if (!count && !timeout) return WAIT_TIMEOUT; - return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL, - timeout, flags & MWMO_ALERTABLE ); + if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT; + return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), + !!(flags & MWMO_ALERTABLE), timeout ); }
if (data->current_event) mask = 0; /* don't process nested events */
if (process_events( data->display, filter_event, mask )) ret = count - 1; - else if (count || timeout) + else if (count || !timeout || timeout->QuadPart) { - ret = WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL, - timeout, flags & MWMO_ALERTABLE ); + ret = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), + !!(flags & MWMO_ALERTABLE), timeout ); if (ret == count - 1) process_events( data->display, filter_event, mask ); } else ret = WAIT_TIMEOUT; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 4576564fda3..4298ae429ed 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -686,8 +686,9 @@ extern void retry_grab_clipping_window(void) DECLSPEC_HIDDEN; extern BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) DECLSPEC_HIDDEN; extern void move_resize_window( HWND hwnd, int dir ) DECLSPEC_HIDDEN; extern void X11DRV_InitKeyboard( Display *display ) DECLSPEC_HIDDEN; -extern DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout, - DWORD mask, DWORD flags ) DECLSPEC_HIDDEN; +extern NTSTATUS X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, + const LARGE_INTEGER *timeout, + DWORD mask, DWORD flags ) DECLSPEC_HIDDEN; extern HWND *build_hwnd_list(void) DECLSPEC_HIDDEN;
typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void *arg ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index a63e2c3ceda..a1fe01d2a43 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -165,7 +165,7 @@ struct gdi_dc_funcs };
/* increment this when you change the DC function table */ -#define WINE_GDI_DRIVER_VERSION 77 +#define WINE_GDI_DRIVER_VERSION 78
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */ #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */ @@ -299,7 +299,7 @@ struct user_driver_funcs void (*pDestroyWindow)(HWND); void (*pFlashWindowEx)(FLASHWINFO*); void (*pGetDC)(HDC,HWND,HWND,const RECT *,const RECT *,DWORD); - DWORD (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD); + NTSTATUS (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,const LARGE_INTEGER*,DWORD,DWORD); void (*pReleaseDC)(HWND,HDC); BOOL (*pScrollDC)(HDC,INT,INT,HRGN); void (*pSetCapture)(HWND,UINT);
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/xdnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index 8240bbbf5d6..d5ae510db49 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -185,7 +185,7 @@ static BOOL handle_position_event( struct dnd_position_event_params *params ) int accept = 0; /* Assume we're not accepting */ IDropTarget *dropTarget = NULL; DWORD effect = params->effect; - POINTL pointl; + POINTL pointl = { .x = params->point.x, .y = params->point.y }; HWND targetWindow; HRESULT hr;
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/clipboard.c | 14 ++++++------- dlls/winex11.drv/keyboard.c | 12 +++++------ dlls/winex11.drv/mouse.c | 2 +- dlls/winex11.drv/window.c | 4 ++-- dlls/winex11.drv/wintab.c | 6 +++--- dlls/winex11.drv/x11drv.h | 13 ++++++++++++ dlls/winex11.drv/xim.c | 39 ++++++++++++++---------------------- 7 files changed, 47 insertions(+), 43 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index f9e6764fc0a..430bc6c1c81 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -358,9 +358,9 @@ static void register_win32_formats( const UINT *ids, UINT size ) if (find_win32_format( *ids )) continue; /* it already exists */ if (!NtUserGetClipboardFormatName( *ids, buffer, ARRAYSIZE(buffer) )) continue; /* not a named format */ - if (!(len = WideCharToMultiByte( CP_UNIXCP, 0, buffer, -1, NULL, 0, NULL, NULL ))) continue; - if (!(names[count] = malloc( len ))) continue; - WideCharToMultiByte( CP_UNIXCP, 0, buffer, -1, names[count], len, NULL, NULL ); + len = lstrlenW( buffer ); + if (!(names[count] = malloc( len * 3 + 1 ))) continue; + ntdll_wcstoumbs( buffer, len + 1, names[count], len * 3 + 1, FALSE ); new_ids[count++] = *ids; } if (!count) return; @@ -405,7 +405,7 @@ static void register_x11_formats( const Atom *atoms, UINT size )
for (i = pos = 0; i < count; i++) { - if (MultiByteToWideChar( CP_UNIXCP, 0, names[i], -1, buffer, 256 ) && + if (ntdll_umbstowcs( names[i], strlen( names[i] ) + 1, buffer, ARRAYSIZE(buffer) ) && (ids[pos] = register_clipboard_format( buffer ))) new_atoms[pos++] = new_atoms[i]; XFree( names[i] ); @@ -759,7 +759,8 @@ static void *import_compound_text( Atom type, const void *data, size_t size, siz
len = strlen(srcstr[0]) + 1; if (!(ret = malloc( (len * 2 + 1) * sizeof(WCHAR) ))) return NULL; - count = MultiByteToWideChar( CP_UNIXCP, 0, srcstr[0], len, ret + len, len ); + + count = ntdll_umbstowcs( srcstr[0], len, ret + len, len ); ret = unicode_text_from_string( ret, ret + len, count, ret_size );
XFreeStringList(srcstr); @@ -1282,8 +1283,7 @@ static BOOL export_compound_text( Display *display, Window win, Atom prop, Atom
if (!(text = malloc( size / sizeof(WCHAR) * 3 ))) return FALSE; - len = WideCharToMultiByte( CP_UNIXCP, 0, data, size / sizeof(WCHAR), - text, size / sizeof(WCHAR) * 3, NULL, NULL ); + len = ntdll_wcstoumbs( data, size / sizeof(WCHAR), text, size / sizeof(WCHAR) * 3, FALSE ); string_from_unicode_text( text, len, &len );
if (target == x11drv_atom(COMPOUND_TEXT)) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index fac97ef7e35..9337f8bf6e9 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1904,7 +1904,7 @@ SHORT X11DRV_VkKeyScanEx( WCHAR wChar, HKL hkl ) /* FIXME: what happens if wChar is not a Latin1 character and CP_UNIXCP * is UTF-8 (multibyte encoding)? */ - if (!WideCharToMultiByte(CP_UNIXCP, 0, &wChar, 1, &cChar, 1, NULL, NULL)) + if (!ntdll_wcstoumbs( &wChar, 1, &cChar, 1, FALSE )) { WARN("no translation from unicode to CP_UNIXCP for 0x%02x\n", wChar); return -1; @@ -2100,7 +2100,7 @@ UINT X11DRV_MapVirtualKeyEx( UINT wCode, UINT wMapType, HKL hkl ) if (len) { WCHAR wch; - if (MultiByteToWideChar(CP_UNIXCP, 0, s, len, &wch, 1)) ret = toupperW(wch); + if (ntdll_umbstowcs( s, len, &wch, 1 )) ret = toupperW(wch); } break; } @@ -2208,7 +2208,7 @@ INT X11DRV_GetKeyNameText( LONG lParam, LPWSTR lpBuffer, INT nSize ) pthread_mutex_unlock( &kbd_mutex ); TRACE("found scan=%04x keyc=%u keysym=%lx modified_string=%s\n", scanCode, keyc, keys, debugstr_an(name,idx-name)); - rc = MultiByteToWideChar(CP_UNIXCP, 0, name, idx-name+1, lpBuffer, nSize); + rc = ntdll_umbstowcs( name, idx - name + 1, lpBuffer, nSize ); if (!rc) rc = nSize; lpBuffer[--rc] = 0; return rc; @@ -2220,7 +2220,7 @@ INT X11DRV_GetKeyNameText( LONG lParam, LPWSTR lpBuffer, INT nSize ) pthread_mutex_unlock( &kbd_mutex ); TRACE("found scan=%04x keyc=%u keysym=%04x vkey=%04x string=%s\n", scanCode, keyc, (int)keys, vkey, debugstr_a(name)); - rc = MultiByteToWideChar(CP_UNIXCP, 0, name, -1, lpBuffer, nSize); + rc = ntdll_umbstowcs( name, strlen(name) + 1, lpBuffer, nSize ); if (!rc) rc = nSize; lpBuffer[--rc] = 0; return rc; @@ -2515,7 +2515,7 @@ INT X11DRV_ToUnicodeEx( UINT virtKey, UINT scanCode, const BYTE *lpKeyState, dead_char = KEYBOARD_MapDeadKeysym(keysym); if (dead_char) { - MultiByteToWideChar(CP_UNIXCP, 0, &dead_char, 1, bufW, bufW_size); + ntdll_umbstowcs( &dead_char, 1, bufW, bufW_size ); ret = -1; goto found; } @@ -2611,7 +2611,7 @@ INT X11DRV_ToUnicodeEx( UINT virtKey, UINT scanCode, const BYTE *lpKeyState, if(ret) { TRACE_(key)("Translating char 0x%02x to unicode\n", *(BYTE *)lpChar); - ret = MultiByteToWideChar(CP_UNIXCP, 0, lpChar, ret, bufW, bufW_size); + ret = ntdll_umbstowcs( lpChar, ret, bufW, bufW_size ); } }
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index d87cff079ec..1a5230300a3 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -1084,7 +1084,7 @@ static Cursor create_xcursor_system_cursor( const ICONINFOEXW *info ) { const WCHAR *valueW = (const WCHAR *)value->Data; if (!valueW[0]) return 0; /* force standard cursor */ - if (!WideCharToMultiByte( CP_UNIXCP, 0, valueW, -1, valueA, sizeof(valueA), NULL, NULL )) + if (!ntdll_wcstoumbs( valueW, lstrlenW(valueW) + 1, valueA, sizeof(valueA), FALSE )) valueA[0] = 0; goto done; } diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 3b0ccd8d22a..79970f55444 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -443,9 +443,9 @@ static void sync_window_text( Display *display, Window win, const WCHAR *text )
/* allocate new buffer for window text */ len = lstrlenW( text ); - count = WideCharToMultiByte(CP_UNIXCP, 0, text, -1, NULL, 0, NULL, NULL); + count = len * 3 + 1; if (!(buffer = malloc( count ))) return; - WideCharToMultiByte(CP_UNIXCP, 0, text, -1, buffer, count, NULL, NULL); + ntdll_wcstoumbs( text, len + 1, buffer, count, FALSE );
RtlUnicodeToUTF8N( NULL, 0, &count, text, len * sizeof(WCHAR) ); if (!(utf8_buffer = malloc( count ))) diff --git a/dlls/winex11.drv/wintab.c b/dlls/winex11.drv/wintab.c index 331601c3325..aa0d7be2fd0 100644 --- a/dlls/winex11.drv/wintab.c +++ b/dlls/winex11.drv/wintab.c @@ -27,7 +27,6 @@
#include "windef.h" #include "winbase.h" -#include "winnls.h" #include "x11drv.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -616,7 +615,7 @@ BOOL CDECL X11DRV_LoadTabletInfo(HWND hwnddefault) WARN("Unable to open device %s\n",target->name); break; } - MultiByteToWideChar(CP_UNIXCP, 0, target->name, -1, cursor.NAME, WT_MAX_NAME_LEN); + ntdll_umbstowcs(target->name, strlen(target->name) + 1, cursor.NAME, WT_MAX_NAME_LEN);
if (! is_tablet_cursor(target->name, device_type)) { @@ -1031,7 +1030,8 @@ int CDECL X11DRV_AttachEventQueueToTablet(HWND hOwner) if (!gSysCursor[cur_loop].ACTIVE) continue;
/* the cursor name fits in the buffer because too long names are skipped */ - WideCharToMultiByte(CP_UNIXCP, 0, gSysCursor[cur_loop].NAME, -1, cursorNameA, WT_MAX_NAME_LEN, NULL, NULL); + ntdll_wcstoumbs(gSysCursor[cur_loop].NAME, lstrlenW(gSysCursor[cur_loop].NAME) + 1, + cursorNameA, WT_MAX_NAME_LEN, FALSE); for (loop=0; loop < num_devices; loop ++) if (strcmp(devices[loop].name, cursorNameA) == 0) target = &devices[loop]; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 4298ae429ed..2ff6bb00eb6 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -62,6 +62,7 @@ typedef int Status; #include "ntgdi.h" #include "wine/gdi_driver.h" #include "unixlib.h" +#include "winnls.h" #include "wine/list.h"
#define MAX_DASHLEN 16 @@ -916,4 +917,16 @@ static inline UINT asciiz_to_unicode( WCHAR *dst, const char *src ) return (p - dst) * sizeof(WCHAR); }
+/* FIXME: remove once we may use ntdll.so version */ + +static inline DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen ) +{ + return MultiByteToWideChar( CP_UNIXCP, 0, src, srclen, dst, dstlen ); +} + +static inline int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict ) +{ + return WideCharToMultiByte( CP_UNIXCP, 0, src, srclen, dst, dstlen, NULL, NULL ); +} + #endif /* __WINE_X11DRV_H */ diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index 6adf2475de7..ec4be2e0c5d 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -101,23 +101,20 @@ static void X11DRV_ImmSetInternalString(DWORD dwOffset,
void X11DRV_XIMLookupChars( const char *str, DWORD count ) { - DWORD dwOutput; - WCHAR *wcOutput; + WCHAR *output; + DWORD len; HWND focus;
TRACE("%p %u\n", str, count);
- dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, str, count, NULL, 0); - wcOutput = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * dwOutput); - if (wcOutput == NULL) - return; - MultiByteToWideChar(CP_UNIXCP, 0, str, count, wcOutput, dwOutput); + if (!(output = malloc( count * sizeof(WCHAR) ))) return; + len = ntdll_umbstowcs( str, count, output, count );
if ((focus = GetFocus())) IME_UpdateAssociation(focus);
- IME_SetResultString(wcOutput, dwOutput); - HeapFree(GetProcessHeap(), 0, wcOutput); + IME_SetResultString( output, len ); + free( output ); }
static BOOL XIMPreEditStateNotifyCallback(XIC xic, XPointer p, XPointer data) @@ -173,24 +170,18 @@ static void XIMPreEditDrawCallback(XIM ic, XPointer client_data, { if (! P_DR->text->encoding_is_wchar) { - DWORD dwOutput; - WCHAR *wcOutput; + size_t text_len; + WCHAR *output;
TRACE("multibyte\n"); - dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, - P_DR->text->string.multi_byte, -1, - NULL, 0); - wcOutput = HeapAlloc(GetProcessHeap(), 0, sizeof (WCHAR) * dwOutput); - if (wcOutput) + text_len = strlen( P_DR->text->string.multi_byte ); + if ((output = malloc( text_len * sizeof(WCHAR) ))) { - dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, - P_DR->text->string.multi_byte, -1, - wcOutput, dwOutput); - - /* ignore null */ - dwOutput --; - X11DRV_ImmSetInternalString (sel, len, wcOutput, dwOutput); - HeapFree(GetProcessHeap(), 0, wcOutput); + text_len = ntdll_umbstowcs( P_DR->text->string.multi_byte, text_len, + output, text_len ); + + X11DRV_ImmSetInternalString( sel, len, output, text_len ); + free( output ); } } else
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/clipboard.c | 80 ++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 430bc6c1c81..30534af6bf3 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -76,6 +76,8 @@ #include <time.h> #include <assert.h>
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "x11drv.h"
#ifdef HAVE_X11_EXTENSIONS_XFIXES_H @@ -598,6 +600,78 @@ static WCHAR *get_dos_file_name( const char *path ) }
+/*********************************************************************** + * get_nt_pathname + * + * Simplified version of RtlDosPathNameToNtPathName_U. + */ +static BOOL get_nt_pathname( const WCHAR *name, UNICODE_STRING *nt_name ) +{ + static const WCHAR ntprefixW[] = {'\','?','?','\'}; + static const WCHAR uncprefixW[] = {'U','N','C','\'}; + size_t len = lstrlenW( name ); + WCHAR *ptr; + + nt_name->MaximumLength = (len + 8) * sizeof(WCHAR); + if (!(ptr = malloc( nt_name->MaximumLength ))) return FALSE; + nt_name->Buffer = ptr; + + memcpy( ptr, ntprefixW, sizeof(ntprefixW) ); + ptr += ARRAYSIZE(ntprefixW); + if (name[0] == '\' && name[1] == '\') + { + if ((name[2] == '.' || name[2] == '?') && name[3] == '\') + { + name += 4; + len -= 4; + } + else + { + memcpy( ptr, uncprefixW, sizeof(uncprefixW) ); + ptr += ARRAYSIZE(uncprefixW); + name += 2; + len -= 2; + } + } + memcpy( ptr, name, (len + 1) * sizeof(WCHAR) ); + ptr += len; + nt_name->Length = (ptr - nt_name->Buffer) * sizeof(WCHAR); + return TRUE; +} + + +/* based on wine_get_unix_file_name */ +char *get_unix_file_name( const WCHAR *dosW ) +{ + UNICODE_STRING nt_name; + OBJECT_ATTRIBUTES attr; + NTSTATUS status; + ULONG size = 256; + char *buffer; + + if (!get_nt_pathname( dosW, &nt_name )) return NULL; + InitializeObjectAttributes( &attr, &nt_name, 0, 0, NULL ); + for (;;) + { + if (!(buffer = malloc( size ))) + { + free( nt_name.Buffer ); + return NULL; + } + status = wine_nt_to_unix_file_name( &attr, buffer, &size, FILE_OPEN_IF ); + if (status != STATUS_BUFFER_TOO_SMALL) break; + free( buffer ); + } + free( nt_name.Buffer ); + if (status) + { + free( buffer ); + return NULL; + } + return buffer; +} + + /*********************************************************************** * uri_to_dos * @@ -1421,7 +1495,7 @@ static BOOL export_hdrop( Display *display, Window win, Atom prop, Atom target, UINT uriSize; UINT u;
- unixFilename = wine_get_unix_file_name( ptr ); + unixFilename = get_unix_file_name( ptr ); if (unixFilename == NULL) goto failed; ptr += lstrlenW( ptr ) + 1;
@@ -1439,7 +1513,7 @@ static BOOL export_hdrop( Display *display, Window win, Atom prop, Atom target, } else { - HeapFree(GetProcessHeap(), 0, unixFilename); + free( unixFilename ); goto failed; } } @@ -1455,7 +1529,7 @@ static BOOL export_hdrop( Display *display, Window win, Atom prop, Atom target, } textUriList[next++] = '\r'; textUriList[next++] = '\n'; - HeapFree(GetProcessHeap(), 0, unixFilename); + free( unixFilename ); } put_property( display, win, prop, target, 8, textUriList, next ); free( textUriList );
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/clipboard.c | 56 +++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 11 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 30534af6bf3..506d1a81f0f 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -672,6 +672,35 @@ char *get_unix_file_name( const WCHAR *dosW ) }
+static CPTABLEINFO *get_xstring_cp(void) +{ + static CPTABLEINFO cp; + if (!cp.CodePage) + { + USHORT *ptr; + SIZE_T nls_size; + if (NtGetNlsSectionPtr( 11, 28591, NULL, (void **)&ptr, &nls_size )) return NULL; + RtlInitCodePageTable( ptr, &cp ); + } + return &cp; +} + + +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; +} + + /*********************************************************************** * uri_to_dos * @@ -788,8 +817,8 @@ static void *import_string( Atom type, const void *data, size_t size, size_t *re WCHAR *ret;
if (!(ret = malloc( (size * 2 + 1) * sizeof(WCHAR) ))) return NULL; - str_size = MultiByteToWideChar( 28591, 0, data, size, ret + size, size ); - return unicode_text_from_string( ret, ret + size, str_size, ret_size ); + RtlCustomCPToUnicodeN( get_xstring_cp(), ret + size, size * sizeof(WCHAR), &str_size, data, size ); + return unicode_text_from_string( ret, ret + size, str_size / sizeof(WCHAR), ret_size ); }
@@ -1301,7 +1330,7 @@ static BOOL export_string( Display *display, Window win, Atom prop, Atom target, char *text;
if (!(text = malloc( size ))) return FALSE; - len = WideCharToMultiByte( 28591, 0, data, size / sizeof(WCHAR), text, size, NULL, NULL ); + RtlUnicodeToCustomCPN( get_xstring_cp(), text, size, &len, data, size ); string_from_unicode_text( text, len, &len );
put_property( display, win, prop, target, 8, text, len ); @@ -1476,14 +1505,19 @@ static BOOL export_hdrop( Display *display, Window win, Atom prop, Atom target,
if (!drop_files->fWide) { - char *p, *files = (char *)data + drop_files->pFiles; - p = files; - while (*p) p += strlen( p ) + 1; - p++; - - if (!(unicode_data = malloc( (p - files) * sizeof(WCHAR) ))) goto failed; - MultiByteToWideChar( CP_ACP, 0, files, p - files, unicode_data, p - files ); - ptr = unicode_data; + char *files = (char *)data + drop_files->pFiles; + CPTABLEINFO *cp = get_ansi_cp(); + DWORD len = 0; + + while (files[len]) len += strlen( files + len ) + 1; + len++; + + if (!(ptr = unicode_data = malloc( len * sizeof(WCHAR) ))) goto failed; + + if (cp->CodePage == CP_UTF8) + RtlUTF8ToUnicodeN( unicode_data, len * sizeof(WCHAR), &len, files, len ); + else + RtlCustomCPToUnicodeN( cp, unicode_data, len * sizeof(WCHAR), &len, files, len ); } else ptr = (const WCHAR *)((char *)data + drop_files->pFiles);
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/clipboard.c | 17 +++-- dlls/winex11.drv/event.c | 118 ++++++++++++----------------------- dlls/winex11.drv/x11drv.h | 1 + 3 files changed, 54 insertions(+), 82 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 506d1a81f0f..f2f93c9ee38 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -1043,11 +1043,9 @@ static void *import_text_html( Atom type, const void *data, size_t size, size_t
/************************************************************************** - * import_text_uri_list - * - * Import text/uri-list. + * uri_list_to_drop_files */ -static void *import_text_uri_list( Atom type, const void *data, size_t size, size_t *ret_size ) +void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) { const char *uriList = data; char *uri; @@ -1121,6 +1119,17 @@ static void *import_text_uri_list( Atom type, const void *data, size_t size, siz }
+/************************************************************************** + * import_text_uri_list + * + * Import text/uri-list. + */ +static void *import_text_uri_list( Atom type, const void *data, size_t size, size_t *ret_size ) +{ + return uri_list_to_drop_files( data, size, ret_size ); +} + + /************************************************************************** * import_targets * diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 5a22464d594..cb0e91821e4 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1476,6 +1476,20 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) return hQueryWnd; }
+static void post_drop( HWND hwnd, DROPFILES *drop, ULONG size ) +{ + HDROP handle; + + if ((handle = GlobalAlloc( GMEM_SHARE, size ))) + { + DROPFILES *ptr = GlobalLock( handle ); + memcpy( ptr, drop, size ); + ptr->fWide = TRUE; + GlobalUnlock( handle ); + PostMessageW( hwnd, WM_DROPFILES, (WPARAM)handle, 0 ); + } +} + /********************************************************************** * EVENT_DropFromOffix * @@ -1573,14 +1587,11 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event ) { struct x11drv_win_data *win_data; unsigned long data_length; - unsigned long aux_long, drop_len = 0; + unsigned long aux_long; unsigned char *p_data = NULL; /* property data */ - char *p_drop = NULL; - char *p, *next; int x, y; - POINT pos; - DROPFILES *lpDrop; - HDROP hDrop; + DROPFILES *drop; + int format; union { Atom atom_aux; int i; @@ -1592,87 +1603,38 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
XGetWindowProperty( event->display, DefaultRootWindow(event->display), x11drv_atom(DndSelection), 0, 65535, FALSE, - AnyPropertyType, &u.atom_aux, &u.i, + AnyPropertyType, &u.atom_aux, &format, &data_length, &aux_long, &p_data); if (aux_long) WARN("property too large, truncated!\n"); TRACE("urls=%s\n", p_data);
- if( !aux_long && p_data) { /* don't bother if > 64K */ - /* calculate length */ - p = (char*) p_data; - next = strchr(p, '\n'); - while (p) { - if (next) *next=0; - if (strncmp(p,"file:",5) == 0 ) { - INT len = GetShortPathNameA( p+5, NULL, 0 ); - if (len) drop_len += len + 1; - } - if (next) { - *next = '\n'; - p = next + 1; - next = strchr(p, '\n'); - } else { - p = NULL; - } - } - - if( drop_len && drop_len < 65535 ) { - XQueryPointer( event->display, root_window, &u.w_aux, &u.w_aux, - &x, &y, &u.i, &u.i, &u.u); - pos = root_to_virtual_screen( x, y ); - - drop_len += sizeof(DROPFILES) + 1; - hDrop = GlobalAlloc( GMEM_SHARE, drop_len ); - lpDrop = GlobalLock( hDrop ); + if (!aux_long && p_data) /* don't bother if > 64K */ + { + size_t drop_size; + drop = uri_list_to_drop_files( p_data, get_property_size( format, data_length ), &drop_size );
- if( lpDrop && (win_data = get_win_data( hWnd ))) + if (drop) { - lpDrop->pFiles = sizeof(DROPFILES); - lpDrop->pt = pos; - lpDrop->fNC = - (pos.x < (win_data->client_rect.left - win_data->whole_rect.left) || - pos.y < (win_data->client_rect.top - win_data->whole_rect.top) || - pos.x > (win_data->client_rect.right - win_data->whole_rect.left) || - pos.y > (win_data->client_rect.bottom - win_data->whole_rect.top) ); - lpDrop->fWide = FALSE; - p_drop = (char*)(lpDrop + 1); - release_win_data( win_data ); + XQueryPointer( event->display, root_window, &u.w_aux, &u.w_aux, + &x, &y, &u.i, &u.i, &u.u); + drop->pt = root_to_virtual_screen( x, y ); + + if ((win_data = get_win_data( hWnd ))) + { + drop->fNC = + (drop->pt.x < (win_data->client_rect.left - win_data->whole_rect.left) || + drop->pt.y < (win_data->client_rect.top - win_data->whole_rect.top) || + drop->pt.x > (win_data->client_rect.right - win_data->whole_rect.left) || + drop->pt.y > (win_data->client_rect.bottom - win_data->whole_rect.top) ); + release_win_data( win_data ); + } + + post_drop( hWnd, drop, drop_size ); + free( drop ); } - - /* create message content */ - if (p_drop) { - p = (char*) p_data; - next = strchr(p, '\n'); - while (p) { - if (next) *next=0; - if (strncmp(p,"file:",5) == 0 ) { - INT len = GetShortPathNameA( p+5, p_drop, 65535 ); - if (len) { - TRACE("drop file %s as %s\n", p+5, p_drop); - p_drop += len+1; - } else { - WARN("can't convert file %s to dos name\n", p+5); - } - } else { - WARN("unknown mime type %s\n", p); - } - if (next) { - *next = '\n'; - p = next + 1; - next = strchr(p, '\n'); - } else { - p = NULL; - } - *p_drop = '\0'; - } - - GlobalUnlock(hDrop); - PostMessageA( hWnd, WM_DROPFILES, (WPARAM)hDrop, 0L ); - } - } } - if( p_data ) XFree(p_data); + if (p_data) XFree( p_data ); }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 2ff6bb00eb6..6b224f5426a 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -661,6 +661,7 @@ extern void update_systray_balloon_position(void) DECLSPEC_HIDDEN; extern HWND create_foreign_window( Display *display, Window window ) DECLSPEC_HIDDEN; extern BOOL update_clipboard( HWND hwnd ) DECLSPEC_HIDDEN; extern void init_win_context(void) DECLSPEC_HIDDEN; +extern void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) DECLSPEC_HIDDEN;
static inline void mirror_rect( const RECT *window_rect, RECT *rect ) {
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/clipboard.c | 52 ++++++++++++++++++++++++++++++++++++ dlls/winex11.drv/event.c | 49 ++++++++------------------------- dlls/winex11.drv/x11drv.h | 1 + 3 files changed, 64 insertions(+), 38 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index f2f93c9ee38..4ba36239595 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -1042,6 +1042,58 @@ static void *import_text_html( Atom type, const void *data, size_t size, size_t }
+/************************************************************************** + * file_list_to_drop_files + */ +void *file_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) +{ + size_t buf_size = 4096, path_size; + DROPFILES *drop = NULL; + const char *ptr; + WCHAR *path; + + for (ptr = data; ptr < (const char *)data + size; ptr += strlen( ptr ) + 1) + { + path = get_dos_file_name( ptr ); + + TRACE( "converted URI %s to DOS path %s\n", debugstr_a(ptr), debugstr_w(path) ); + + if (!path) continue; + + if (!drop) + { + if (!(drop = malloc( buf_size ))) return NULL; + drop->pFiles = sizeof(*drop); + drop->pt.x = drop->pt.y = 0; + drop->fNC = FALSE; + drop->fWide = TRUE; + *ret_size = sizeof(*drop); + } + + path_size = (lstrlenW( path ) + 1) * sizeof(WCHAR); + if (*ret_size + path_size > buf_size - sizeof(WCHAR)) + { + void *new_buf; + if (!(new_buf = realloc( drop, buf_size * 2 + path_size ))) + { + free( path ); + continue; + } + buf_size = buf_size * 2 + path_size; + drop = new_buf; + } + + memcpy( (char *)drop + *ret_size, path, path_size ); + *ret_size += path_size; + } + + if (!drop) return NULL; + *(WCHAR *)((char *)drop + *ret_size) = 0; + *ret_size += sizeof(WCHAR); + return drop; +} + + /************************************************************************** * uri_list_to_drop_files */ diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index cb0e91821e4..3bd771fa4fd 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1503,7 +1503,7 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event ) unsigned long aux_long; unsigned char* p_data = NULL; Atom atom_aux; - int x, y, cx, cy, dummy; + int x, y, cx, cy, dummy, format; Window win, w_aux_root, w_aux_child;
if (!(data = get_win_data( hWnd ))) return; @@ -1529,50 +1529,23 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
XGetWindowProperty( event->display, DefaultRootWindow(event->display), x11drv_atom(DndSelection), 0, 65535, FALSE, - AnyPropertyType, &atom_aux, &dummy, + AnyPropertyType, &atom_aux, &format, &data_length, &aux_long, &p_data);
- if( !aux_long && p_data) /* don't bother if > 64K */ + if (!aux_long && p_data) /* don't bother if > 64K */ { - char *p = (char *)p_data; - char *p_drop; + DROPFILES *drop; + size_t drop_size;
- aux_long = 0; - while( *p ) /* calculate buffer size */ + drop = file_list_to_drop_files( p_data, get_property_size( format, data_length ), &drop_size ); + if (drop) { - INT len = GetShortPathNameA( p, NULL, 0 ); - if (len) aux_long += len + 1; - p += strlen(p) + 1; - } - if( aux_long && aux_long < 65535 ) - { - HDROP hDrop; - DROPFILES *lpDrop; - - aux_long += sizeof(DROPFILES) + 1; - hDrop = GlobalAlloc( GMEM_SHARE, aux_long ); - lpDrop = GlobalLock( hDrop ); - - if( lpDrop ) - { - lpDrop->pFiles = sizeof(DROPFILES); - lpDrop->pt = pt; - lpDrop->fNC = FALSE; - lpDrop->fWide = FALSE; - p_drop = (char *)(lpDrop + 1); - p = (char *)p_data; - while(*p) - { - if (GetShortPathNameA( p, p_drop, aux_long - (p_drop - (char *)lpDrop) )) - p_drop += strlen( p_drop ) + 1; - p += strlen(p) + 1; - } - *p_drop = '\0'; - PostMessageA( hWnd, WM_DROPFILES, (WPARAM)hDrop, 0L ); - } + post_drop( hWnd, drop, drop_size ); + free( drop ); } } - if( p_data ) XFree(p_data); + + if (p_data) XFree(p_data); }
/********************************************************************** diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 6b224f5426a..957ef6ea667 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -661,6 +661,7 @@ extern void update_systray_balloon_position(void) DECLSPEC_HIDDEN; extern HWND create_foreign_window( Display *display, Window window ) DECLSPEC_HIDDEN; extern BOOL update_clipboard( HWND hwnd ) DECLSPEC_HIDDEN; extern void init_win_context(void) DECLSPEC_HIDDEN; +extern void *file_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) DECLSPEC_HIDDEN; extern void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) DECLSPEC_HIDDEN;
static inline void mirror_rect( const RECT *window_rect, RECT *rect )
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/win32u/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 64ac48cad19..fd74f63291a 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -443,7 +443,7 @@ ATOM WINAPI NtUserRegisterClassExWOW( const WNDCLASSEXW *wc, UNICODE_STRING *nam class->hCursor = wc->hCursor; class->hbrBackground = wc->hbrBackground; class->winproc = alloc_winproc( wc->lpfnWndProc, ansi ); - class->menu_name = *client_menu_name; + if (client_menu_name) class->menu_name = *client_menu_name; if (wc->hIcon && !wc->hIconSm && user_callbacks) class->hIconSmIntern = user_callbacks->pCopyImage( wc->hIcon, IMAGE_ICON, get_system_metrics( SM_CXSMICON ),
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/event.c | 6 +++--- dlls/winex11.drv/keyboard.c | 6 +++--- dlls/winex11.drv/mouse.c | 10 +++++----- dlls/winex11.drv/vulkan.c | 2 +- dlls/winex11.drv/window.c | 4 ++-- dlls/winex11.drv/x11drv_main.c | 10 +++++----- 6 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 3bd771fa4fd..a6499400283 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -512,7 +512,7 @@ NTSTATUS X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD EVENT_x11_time_to_win32_time(Time time) { static DWORD adjust = 0; - DWORD now = GetTickCount(); + DWORD now = NtGetTickCount(); DWORD ret;
if (! adjust && time != 0) @@ -1365,7 +1365,7 @@ void wait_for_withdrawn_state( HWND hwnd, BOOL set ) { Display *display = thread_display(); struct x11drv_win_data *data; - DWORD end = GetTickCount() + 2000; + DWORD end = NtGetTickCount() + 2000;
TRACE( "waiting for window %p to become %swithdrawn\n", hwnd, set ? "" : "not " );
@@ -1401,7 +1401,7 @@ void wait_for_withdrawn_state( HWND hwnd, BOOL set ) if (!count) { struct pollfd pfd; - int timeout = end - GetTickCount(); + int timeout = end - NtGetTickCount();
pfd.fd = ConnectionNumber(display); pfd.events = POLLIN; diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 9337f8bf6e9..03f5b331e3a 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1525,7 +1525,7 @@ X11DRV_KEYBOARD_DetectLayout( Display *display )
static HKL get_locale_kbd_layout(void) { - ULONG_PTR layout; + LCID layout; LANGID langid;
/* FIXME: @@ -1539,7 +1539,7 @@ static HKL get_locale_kbd_layout(void) * locale id we return the US one. */
- layout = GetUserDefaultLCID(); + NtQueryDefaultLocale( TRUE, &layout );
/* * Microsoft Office expects this value to be something specific @@ -1553,7 +1553,7 @@ static HKL get_locale_kbd_layout(void) else layout |= layout << 16;
- return (HKL)layout; + return (HKL)(UINT_PTR)layout; }
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 1a5230300a3..3d68dc80b3e 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -513,7 +513,7 @@ LRESULT clip_cursor_notify( HWND hwnd, HWND prev_clip_hwnd, HWND new_clip_hwnd ) { TRACE( "clip hwnd reset from %p\n", hwnd ); data->clip_hwnd = 0; - data->clip_reset = GetTickCount(); + data->clip_reset = NtGetTickCount(); disable_xinput2(); NtUserDestroyWindow( hwnd ); } @@ -553,7 +553,7 @@ BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) release_win_data( data ); if (!fullscreen) return FALSE; if (!(thread_data = x11drv_thread_data())) return FALSE; - if (GetTickCount() - thread_data->clip_reset < 1000) return FALSE; + if (NtGetTickCount() - thread_data->clip_reset < 1000) return FALSE; if (!reset && clipping_cursor && thread_data->clip_hwnd) return FALSE; /* already clipping */
monitor = NtUserMonitorFromWindow( hwnd, MONITOR_DEFAULTTONEAREST ); @@ -1472,9 +1472,9 @@ void X11DRV_DestroyCursorIcon( HCURSOR handle ) void X11DRV_SetCursor( HCURSOR handle ) { if (InterlockedExchangePointer( (void **)&last_cursor, handle ) != handle || - GetTickCount() - last_cursor_change > 100) + NtGetTickCount() - last_cursor_change > 100) { - last_cursor_change = GetTickCount(); + last_cursor_change = NtGetTickCount(); if (cursor_window) send_notify_message( cursor_window, WM_X11DRV_SET_CURSOR, 0, (LPARAM)handle ); } } @@ -1667,7 +1667,7 @@ void move_resize_window( HWND hwnd, int dir ) input.u.mi.dy = pos.y; input.u.mi.mouseData = button_up_data[button - 1]; input.u.mi.dwFlags = button_up_flags[button - 1] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; - input.u.mi.time = GetTickCount(); + input.u.mi.time = NtGetTickCount(); input.u.mi.dwExtraInfo = 0; __wine_send_input( hwnd, &input, NULL ); } diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index 29e0b10763a..0f96b6860fd 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -650,7 +650,7 @@ static VkResult X11DRV_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR * static long prev_time, start_time; DWORD time;
- time = GetTickCount(); + time = NtGetTickCount(); frames++; frames_total++; if (time - prev_time > 1500) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 79970f55444..de52023c467 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1861,8 +1861,8 @@ static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp, { case WM_WINE_NOTIFY_ACTIVITY: { - static ULONGLONG last = 0; - ULONGLONG now = GetTickCount64(); + static ULONG last = 0; + ULONG now = NtGetTickCount(); /* calling XResetScreenSaver too often can cause performance * problems, so throttle it */ if (now > last + 5000) diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 6042f2522b5..aa8ddc49385 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -722,7 +722,7 @@ static void set_queue_display_fd( Display *display ) if (wine_server_fd_to_handle( ConnectionNumber(display), GENERIC_READ | SYNCHRONIZE, 0, &handle )) { MESSAGE( "x11drv: Can't allocate handle for display fd\n" ); - ExitProcess(1); + NtTerminateProcess( 0, 1 ); } SERVER_START_REQ( set_queue_fd ) { @@ -733,9 +733,9 @@ static void set_queue_display_fd( Display *display ) if (ret) { MESSAGE( "x11drv: Can't store handle for display fd\n" ); - ExitProcess(1); + NtTerminateProcess( 0, 1 ); } - CloseHandle( handle ); + NtClose( handle ); }
@@ -751,12 +751,12 @@ struct x11drv_thread_data *x11drv_init_thread_data(void) if (!(data = calloc( 1, sizeof(*data) ))) { ERR( "could not create data\n" ); - ExitProcess(1); + NtTerminateProcess( 0, 1 ); } if (!(data->display = XOpenDisplay(NULL))) { ERR_(winediag)( "x11drv: Can't open display: %s. Please ensure that your X server is running and that $DISPLAY is set correctly.\n", XDisplayName(NULL)); - ExitProcess(1); + NtTerminateProcess( 0, 1 ); }
fcntl( ConnectionNumber(data->display), F_SETFD, 1 ); /* set close on exec flag */
Huw Davies (@huw) commented about dlls/winex11.drv/keyboard.c:
if(ret) { TRACE_(key)("Translating char 0x%02x to unicode\n", *(BYTE *)lpChar);
ret = MultiByteToWideChar(CP_UNIXCP, 0, lpChar, ret, bufW, bufW_size);
ret = ntdll_umbstowcs( lpChar, ret, bufW, bufW_size );
It hardly seems worth mentioning, but I will: there's a double space before `lpChar`.