Prepare xdnd.c to be in PE file and use ntdll interface for Unicode conversion.
From: Jacek Caban jacek@codeweavers.com
In preparation for xdnd.c being in PE file. --- dlls/winex11.drv/event.c | 76 +++++++++++++++++++++++++++++++++- dlls/winex11.drv/x11drv.h | 3 +- dlls/winex11.drv/xdnd.c | 86 ++------------------------------------- 3 files changed, 80 insertions(+), 85 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index e1bcd70d35a..c8cd3fd5ef1 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -49,6 +49,7 @@ #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(event); +WINE_DECLARE_DEBUG_CHANNEL(xdnd);
extern BOOL ximInComposeMode;
@@ -1752,6 +1753,79 @@ static void handle_dnd_protocol( HWND hwnd, XClientMessageEvent *event ) }
+/************************************************************************** + * handle_xdnd_enter_event + * + * Handle an XdndEnter event. + */ +static void handle_xdnd_enter_event( HWND hWnd, XClientMessageEvent *event ) +{ + struct format_entry *data; + unsigned long count = 0; + Atom *xdndtypes; + size_t size; + int version; + + version = (event->data.l[1] & 0xFF000000) >> 24; + + TRACE( "ver(%d) check-XdndTypeList(%ld) data=%ld,%ld,%ld,%ld,%ld\n", + version, (event->data.l[1] & 1), + event->data.l[0], event->data.l[1], event->data.l[2], + event->data.l[3], event->data.l[4] ); + + if (version > WINE_XDND_VERSION) + { + ERR("ignoring unsupported XDND version %d\n", version); + return; + } + + /* If the source supports more than 3 data types we retrieve + * the entire list. */ + if (event->data.l[1] & 1) + { + Atom acttype; + int actfmt; + unsigned long bytesret; + + /* Request supported formats from source window */ + XGetWindowProperty( event->display, event->data.l[0], x11drv_atom(XdndTypeList), + 0, 65535, FALSE, AnyPropertyType, &acttype, &actfmt, &count, + &bytesret, (unsigned char **)&xdndtypes ); + } + else + { + count = 3; + xdndtypes = (Atom *)&event->data.l[2]; + } + + if (TRACE_ON(xdnd)) + { + unsigned int i; + + for (i = 0; i < count; i++) + { + if (xdndtypes[i] != 0) + { + char * pn = XGetAtomName( event->display, xdndtypes[i] ); + TRACE( "XDNDEnterAtom %ld: %s\n", xdndtypes[i], pn ); + XFree( pn ); + } + } + } + + data = import_xdnd_selection( event->display, event->window, x11drv_atom(XdndSelection), + xdndtypes, count, &size ); + if (data) + { + handle_dnd_enter_event( data, size ); + free( data ); + } + + if (event->data.l[1] & 1) + XFree(xdndtypes); +} + + struct client_message_handler { int atom; /* protocol atom */ @@ -1764,7 +1838,7 @@ static const struct client_message_handler client_messages[] = { XATOM_WM_PROTOCOLS, handle_wm_protocols }, { XATOM__XEMBED, handle_xembed_protocol }, { XATOM_DndProtocol, handle_dnd_protocol }, - { XATOM_XdndEnter, X11DRV_XDND_EnterEvent }, + { XATOM_XdndEnter, handle_xdnd_enter_event }, { XATOM_XdndPosition, X11DRV_XDND_PositionEvent }, { XATOM_XdndDrop, X11DRV_XDND_DropEvent }, { XATOM_XdndLeave, X11DRV_XDND_LeaveEvent } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index f6d28122fc3..9339c1c08e6 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -293,7 +293,6 @@ extern BOOL IME_SetCompositionString(DWORD dwIndex, LPCVOID lpComp, DWORD dwReadLen) DECLSPEC_HIDDEN; extern void IME_SetResultString(LPWSTR lpResult, DWORD dwResultlen) DECLSPEC_HIDDEN;
-extern void X11DRV_XDND_EnterEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN; extern void X11DRV_XDND_PositionEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN; extern void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN; extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN; @@ -305,6 +304,8 @@ struct format_entry char data[1]; };
+extern void handle_dnd_enter_event( struct format_entry *formats, ULONG size ) DECLSPEC_HIDDEN; + extern struct format_entry *import_xdnd_selection( Display *display, Window win, Atom selection, Atom *targets, UINT count, size_t *size ) DECLSPEC_HIDDEN; diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index 34cb2a47081..e56fc964ada 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -55,8 +55,6 @@ static HWND XDNDLastTargetWnd; /* might be an ancestor of XDNDLastTargetWnd */ static HWND XDNDLastDropTargetWnd;
-static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm, - Atom *types, unsigned long count); static BOOL X11DRV_XDND_HasHDROP(void); static HRESULT X11DRV_XDND_SendDropFiles(HWND hwnd); static void X11DRV_XDND_FreeDragDropOp(void); @@ -180,73 +178,6 @@ static long X11DRV_XDND_DROPEFFECTToXdndAction(DWORD effect) return x11drv_atom(XdndActionCopy); }
-/************************************************************************** - * X11DRV_XDND_EnterEvent - * - * Handle an XdndEnter event. - */ -void X11DRV_XDND_EnterEvent( HWND hWnd, XClientMessageEvent *event ) -{ - int version; - Atom *xdndtypes; - unsigned long count = 0; - - version = (event->data.l[1] & 0xFF000000) >> 24; - TRACE("ver(%d) check-XdndTypeList(%ld) data=%ld,%ld,%ld,%ld,%ld\n", - version, (event->data.l[1] & 1), - event->data.l[0], event->data.l[1], event->data.l[2], - event->data.l[3], event->data.l[4]); - - if (version > WINE_XDND_VERSION) - { - ERR("ignoring unsupported XDND version %d\n", version); - return; - } - - XDNDAccepted = FALSE; - - /* If the source supports more than 3 data types we retrieve - * the entire list. */ - if (event->data.l[1] & 1) - { - Atom acttype; - int actfmt; - unsigned long bytesret; - - /* Request supported formats from source window */ - XGetWindowProperty(event->display, event->data.l[0], x11drv_atom(XdndTypeList), - 0, 65535, FALSE, AnyPropertyType, &acttype, &actfmt, &count, - &bytesret, (unsigned char**)&xdndtypes); - } - else - { - count = 3; - xdndtypes = (Atom*) &event->data.l[2]; - } - - if (TRACE_ON(xdnd)) - { - unsigned int i; - - for (i = 0; i < count; i++) - { - if (xdndtypes[i] != 0) - { - char * pn = XGetAtomName(event->display, xdndtypes[i]); - TRACE("XDNDEnterAtom %ld: %s\n", xdndtypes[i], pn); - XFree(pn); - } - } - } - - /* Do a one-time data read and cache results */ - X11DRV_XDND_ResolveProperty(event->display, event->window, - event->data.l[1], xdndtypes, count); - - if (event->data.l[1] & 1) - XFree(xdndtypes); -} - /* Recursively searches for a window on given coordinates in a drag&drop specific manner. * * Don't use WindowFromPoint instead, because it omits the STATIC and transparent @@ -514,29 +445,18 @@ void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event )
/************************************************************************** - * X11DRV_XDND_ResolveProperty - * - * Resolve all MIME types to windows clipboard formats. All data is cached. + * handle_dnd_enter_event */ -static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm, - Atom *types, unsigned long count) +void handle_dnd_enter_event( struct format_entry *formats, ULONG size ) { - struct format_entry *formats; - size_t size; - - TRACE("count(%ld)\n", count); - + XDNDAccepted = FALSE; X11DRV_XDND_FreeDragDropOp(); /* Clear previously cached data */
- formats = import_xdnd_selection( display, xwin, x11drv_atom(XdndSelection), types, count, &size ); - if (!formats) return; - if ((xdnd_formats = HeapAlloc( GetProcessHeap(), 0, size ))) { memcpy( xdnd_formats, formats, size ); xdnd_formats_end = (struct format_entry *)((char *)xdnd_formats + size); } - free( formats ); }
From: Jacek Caban jacek@codeweavers.com
--- dlls/winex11.drv/event.c | 72 +++++++++++++++++++++++++++++++++++++- dlls/winex11.drv/unixlib.h | 43 +++++++++++++++++++++++ dlls/winex11.drv/x11drv.h | 10 ++---- dlls/winex11.drv/xdnd.c | 70 ++++++++++-------------------------- 4 files changed, 135 insertions(+), 60 deletions(-) create mode 100644 dlls/winex11.drv/unixlib.h
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index c8cd3fd5ef1..2bfcd3211ae 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1826,6 +1826,76 @@ static void handle_xdnd_enter_event( HWND hWnd, XClientMessageEvent *event ) }
+static DWORD xdnd_action_to_drop_effect( long action ) +{ + /* In Windows, nothing but the given effects is allowed. + * In X the given action is just a hint, and you can always + * XdndActionCopy and XdndActionPrivate, so be more permissive. */ + if (action == x11drv_atom(XdndActionCopy)) + return DROPEFFECT_COPY; + else if (action == x11drv_atom(XdndActionMove)) + return DROPEFFECT_MOVE | DROPEFFECT_COPY; + else if (action == x11drv_atom(XdndActionLink)) + return DROPEFFECT_LINK | DROPEFFECT_COPY; + else if (action == x11drv_atom(XdndActionAsk)) + /* FIXME: should we somehow ask the user what to do here? */ + return DROPEFFECT_COPY | DROPEFFECT_MOVE | DROPEFFECT_LINK; + + FIXME( "unknown action %ld, assuming DROPEFFECT_COPY\n", action ); + return DROPEFFECT_COPY; +} + + +static long drop_effect_to_xdnd_action( DWORD effect ) +{ + if (effect == DROPEFFECT_COPY) + return x11drv_atom(XdndActionCopy); + else if (effect == DROPEFFECT_MOVE) + return x11drv_atom(XdndActionMove); + else if (effect == DROPEFFECT_LINK) + return x11drv_atom(XdndActionLink); + else if (effect == DROPEFFECT_NONE) + return None; + + FIXME( "unknown drop effect %u, assuming XdndActionCopy\n", effect ); + return x11drv_atom(XdndActionCopy); +} + + +static void handle_xdnd_position_event( HWND hwnd, XClientMessageEvent *event ) +{ + struct dnd_position_event_params params; + XClientMessageEvent e; + DWORD effect; + + params.type = DND_POSITION_EVENT; + params.hwnd = hwnd; + params.point = root_to_virtual_screen( event->data.l[2] >> 16, event->data.l[2] & 0xFFFF ); + params.effect = effect = xdnd_action_to_drop_effect( event->data.l[4] ); + + effect = handle_dnd_event( ¶ms ); + + TRACE( "actionRequested(%ld) chosen(0x%x) at x(%d),y(%d)\n", + event->data.l[4], effect, params.point.x, params.point.y ); + + /* + * Let source know if we're accepting the drop by + * sending a status message. + */ + e.type = ClientMessage; + e.display = event->display; + e.window = event->data.l[0]; + e.message_type = x11drv_atom(XdndStatus); + e.format = 32; + e.data.l[0] = event->window; + e.data.l[1] = !!effect; + e.data.l[2] = 0; /* Empty Rect */ + e.data.l[3] = 0; /* Empty Rect */ + e.data.l[4] = drop_effect_to_xdnd_action( effect ); + XSendEvent( event->display, event->data.l[0], False, NoEventMask, (XEvent *)&e ); +} + + struct client_message_handler { int atom; /* protocol atom */ @@ -1839,7 +1909,7 @@ static const struct client_message_handler client_messages[] = { XATOM__XEMBED, handle_xembed_protocol }, { XATOM_DndProtocol, handle_dnd_protocol }, { XATOM_XdndEnter, handle_xdnd_enter_event }, - { XATOM_XdndPosition, X11DRV_XDND_PositionEvent }, + { XATOM_XdndPosition, handle_xdnd_position_event }, { XATOM_XdndDrop, X11DRV_XDND_DropEvent }, { XATOM_XdndLeave, X11DRV_XDND_LeaveEvent } }; diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h new file mode 100644 index 00000000000..7f8ec28b7cf --- /dev/null +++ b/dlls/winex11.drv/unixlib.h @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "ntuser.h" +#include "wine/unixlib.h" + +/* DnD support */ + +struct format_entry +{ + UINT format; + UINT size; + char data[1]; +}; + +enum dnd_event_type +{ + DND_POSITION_EVENT, +}; + +/* DND_POSITION_EVENT params */ +struct dnd_position_event_params +{ + UINT type; + HWND hwnd; + POINT point; + DWORD effect; +}; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 9339c1c08e6..d49643a890b 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -61,6 +61,7 @@ typedef int Status; #include "winbase.h" #include "ntgdi.h" #include "wine/gdi_driver.h" +#include "unixlib.h" #include "wine/list.h"
#define MAX_DASHLEN 16 @@ -293,18 +294,11 @@ extern BOOL IME_SetCompositionString(DWORD dwIndex, LPCVOID lpComp, DWORD dwReadLen) DECLSPEC_HIDDEN; extern void IME_SetResultString(LPWSTR lpResult, DWORD dwResultlen) DECLSPEC_HIDDEN;
-extern void X11DRV_XDND_PositionEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN; extern void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN; extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
-struct format_entry -{ - UINT format; - UINT size; - char data[1]; -}; - extern void handle_dnd_enter_event( struct format_entry *formats, ULONG size ) DECLSPEC_HIDDEN; +extern UINT handle_dnd_event( void *params ) DECLSPEC_HIDDEN;
extern struct format_entry *import_xdnd_selection( Display *display, Window win, Atom selection, Atom *targets, UINT count, diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index e56fc964ada..7633738917f 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -142,27 +142,6 @@ static IDropTarget* get_droptarget_pointer(HWND hwnd) return droptarget; }
-/************************************************************************** - * X11DRV_XDND_XdndActionToDROPEFFECT - */ -static DWORD X11DRV_XDND_XdndActionToDROPEFFECT(long action) -{ - /* In Windows, nothing but the given effects is allowed. - * In X the given action is just a hint, and you can always - * XdndActionCopy and XdndActionPrivate, so be more permissive. */ - if (action == x11drv_atom(XdndActionCopy)) - return DROPEFFECT_COPY; - else if (action == x11drv_atom(XdndActionMove)) - return DROPEFFECT_MOVE | DROPEFFECT_COPY; - else if (action == x11drv_atom(XdndActionLink)) - return DROPEFFECT_LINK | DROPEFFECT_COPY; - else if (action == x11drv_atom(XdndActionAsk)) - /* FIXME: should we somehow ask the user what to do here? */ - return DROPEFFECT_COPY | DROPEFFECT_MOVE | DROPEFFECT_LINK; - FIXME("unknown action %ld, assuming DROPEFFECT_COPY\n", action); - return DROPEFFECT_COPY; -} - /************************************************************************** * X11DRV_XDND_DROPEFFECTToXdndAction */ @@ -215,22 +194,17 @@ static HWND window_accepting_files(HWND hwnd) * * Handle an XdndPosition event. */ -void X11DRV_XDND_PositionEvent( HWND hWnd, XClientMessageEvent *event ) +static BOOL handle_position_event( struct dnd_position_event_params *params ) { - XClientMessageEvent e; int accept = 0; /* Assume we're not accepting */ IDropTarget *dropTarget = NULL; - DWORD effect; + DWORD effect = params->effect; POINTL pointl; HWND targetWindow; HRESULT hr;
- XDNDxy = root_to_virtual_screen( event->data.l[2] >> 16, event->data.l[2] & 0xFFFF ); - targetWindow = window_from_point_dnd(hWnd, XDNDxy); - - pointl.x = XDNDxy.x; - pointl.y = XDNDxy.y; - effect = X11DRV_XDND_XdndActionToDROPEFFECT(event->data.l[4]); + XDNDxy = params->point; + targetWindow = window_from_point_dnd( params->hwnd, XDNDxy );
if (!XDNDAccepted || XDNDLastTargetWnd != targetWindow) { @@ -301,27 +275,7 @@ void X11DRV_XDND_PositionEvent( HWND hWnd, XClientMessageEvent *event ) } }
- TRACE("actionRequested(%ld) accept(%d) chosen(0x%x) at x(%d),y(%d)\n", - event->data.l[4], accept, effect, XDNDxy.x, XDNDxy.y); - - /* - * Let source know if we're accepting the drop by - * sending a status message. - */ - e.type = ClientMessage; - e.display = event->display; - e.window = event->data.l[0]; - e.message_type = x11drv_atom(XdndStatus); - e.format = 32; - e.data.l[0] = event->window; - e.data.l[1] = accept; - e.data.l[2] = 0; /* Empty Rect */ - e.data.l[3] = 0; /* Empty Rect */ - if (accept) - e.data.l[4] = X11DRV_XDND_DROPEFFECTToXdndAction(effect); - else - e.data.l[4] = None; - XSendEvent(event->display, event->data.l[0], False, NoEventMask, (XEvent*)&e); + return accept ? effect : 0; }
/************************************************************************** @@ -806,3 +760,17 @@ static IDataObjectVtbl xdndDataObjectVtbl = };
static IDataObject XDNDDataObject = { &xdndDataObjectVtbl }; + +UINT handle_dnd_event( void *params ) +{ + + switch (*(UINT *)params) + { + case DND_POSITION_EVENT: + return handle_position_event( params ); + + default: + ERR( "invalid event\n" ); + return 0; + } +}
From: Jacek Caban jacek@codeweavers.com
--- dlls/winex11.drv/event.c | 26 ++++++++++++++++++++++- dlls/winex11.drv/unixlib.h | 8 ++++++++ dlls/winex11.drv/x11drv.h | 1 - dlls/winex11.drv/xdnd.c | 42 ++++++-------------------------------- 4 files changed, 39 insertions(+), 38 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 2bfcd3211ae..a02f0340010 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1896,6 +1896,30 @@ static void handle_xdnd_position_event( HWND hwnd, XClientMessageEvent *event ) }
+static void handle_xdnd_drop_event( HWND hwnd, XClientMessageEvent *event ) +{ + struct dnd_drop_event_params params; + XClientMessageEvent e; + DWORD effect; + + params.type = DND_DROP_EVENT; + params.hwnd = hwnd; + effect = handle_dnd_event( ¶ms ); + + /* Tell the target we are finished. */ + memset( &e, 0, sizeof(e) ); + e.type = ClientMessage; + e.display = event->display; + e.window = event->data.l[0]; + e.message_type = x11drv_atom(XdndFinished); + e.format = 32; + e.data.l[0] = event->window; + e.data.l[1] = !!effect; + e.data.l[2] = drop_effect_to_xdnd_action( effect ); + XSendEvent( event->display, event->data.l[0], False, NoEventMask, (XEvent *)&e ); +} + + struct client_message_handler { int atom; /* protocol atom */ @@ -1910,7 +1934,7 @@ static const struct client_message_handler client_messages[] = { XATOM_DndProtocol, handle_dnd_protocol }, { XATOM_XdndEnter, handle_xdnd_enter_event }, { XATOM_XdndPosition, handle_xdnd_position_event }, - { XATOM_XdndDrop, X11DRV_XDND_DropEvent }, + { XATOM_XdndDrop, handle_xdnd_drop_event }, { XATOM_XdndLeave, X11DRV_XDND_LeaveEvent } };
diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index 7f8ec28b7cf..41120385e60 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -30,9 +30,17 @@ struct format_entry
enum dnd_event_type { + DND_DROP_EVENT, DND_POSITION_EVENT, };
+/* DND_DROP_EVENT params */ +struct dnd_drop_event_params +{ + UINT type; + HWND hwnd; +}; + /* DND_POSITION_EVENT params */ struct dnd_position_event_params { diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index d49643a890b..c17dc45594c 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -294,7 +294,6 @@ extern BOOL IME_SetCompositionString(DWORD dwIndex, LPCVOID lpComp, DWORD dwReadLen) DECLSPEC_HIDDEN; extern void IME_SetResultString(LPWSTR lpResult, DWORD dwResultlen) DECLSPEC_HIDDEN;
-extern void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN; extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
extern void handle_dnd_enter_event( struct format_entry *formats, ULONG size ) DECLSPEC_HIDDEN; diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index 7633738917f..9de0b60d0cd 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -142,20 +142,6 @@ static IDropTarget* get_droptarget_pointer(HWND hwnd) return droptarget; }
-/************************************************************************** - * X11DRV_XDND_DROPEFFECTToXdndAction - */ -static long X11DRV_XDND_DROPEFFECTToXdndAction(DWORD effect) -{ - if (effect == DROPEFFECT_COPY) - return x11drv_atom(XdndActionCopy); - else if (effect == DROPEFFECT_MOVE) - return x11drv_atom(XdndActionMove); - else if (effect == DROPEFFECT_LINK) - return x11drv_atom(XdndActionLink); - FIXME("unknown drop effect %u, assuming XdndActionCopy\n", effect); - return x11drv_atom(XdndActionCopy); -}
/* Recursively searches for a window on given coordinates in a drag&drop specific manner. * @@ -278,14 +264,8 @@ static BOOL handle_position_event( struct dnd_position_event_params *params ) return accept ? effect : 0; }
-/************************************************************************** - * X11DRV_XDND_DropEvent - * - * Handle an XdndDrop event. - */ -void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) +static DWORD handle_drop_event( struct dnd_drop_event_params *params ) { - XClientMessageEvent e; IDropTarget *dropTarget; DWORD effect = XDNDDropEffect; int accept = 0; /* Assume we're not accepting */ @@ -338,7 +318,7 @@ void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) /* Only send WM_DROPFILES if Drop didn't succeed or DROPEFFECT_NONE was set. * Doing both causes winamp to duplicate the dropped files (#29081) */
- HWND hwnd_drop = window_accepting_files(window_from_point_dnd(hWnd, XDNDxy)); + HWND hwnd_drop = window_accepting_files(window_from_point_dnd( params->hwnd, XDNDxy ));
if (hwnd_drop && X11DRV_XDND_HasHDROP()) { @@ -354,20 +334,7 @@ void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) TRACE("effectRequested(0x%x) accept(%d) performed(0x%x) at x(%d),y(%d)\n", XDNDDropEffect, accept, effect, XDNDxy.x, XDNDxy.y);
- /* Tell the target we are finished. */ - memset(&e, 0, sizeof(e)); - e.type = ClientMessage; - e.display = event->display; - e.window = event->data.l[0]; - e.message_type = x11drv_atom(XdndFinished); - e.format = 32; - e.data.l[0] = event->window; - e.data.l[1] = accept; - if (accept) - e.data.l[2] = X11DRV_XDND_DROPEFFECTToXdndAction(effect); - else - e.data.l[2] = None; - XSendEvent(event->display, event->data.l[0], False, NoEventMask, (XEvent*)&e); + return accept ? effect : 0; }
/************************************************************************** @@ -766,6 +733,9 @@ UINT handle_dnd_event( void *params )
switch (*(UINT *)params) { + case DND_DROP_EVENT: + return handle_drop_event( params ); + case DND_POSITION_EVENT: return handle_position_event( params );
From: Jacek Caban jacek@codeweavers.com
--- dlls/winex11.drv/event.c | 9 ++++++++- dlls/winex11.drv/unixlib.h | 1 + dlls/winex11.drv/x11drv.h | 1 - dlls/winex11.drv/xdnd.c | 6 +++++- 4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index a02f0340010..729a0a7eab6 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1920,6 +1920,13 @@ static void handle_xdnd_drop_event( HWND hwnd, XClientMessageEvent *event ) }
+static void handle_xdnd_leave_event( HWND hwnd, XClientMessageEvent *event ) +{ + UINT type = DND_LEAVE_EVENT; + handle_dnd_event( &type ); +} + + struct client_message_handler { int atom; /* protocol atom */ @@ -1935,7 +1942,7 @@ static const struct client_message_handler client_messages[] = { XATOM_XdndEnter, handle_xdnd_enter_event }, { XATOM_XdndPosition, handle_xdnd_position_event }, { XATOM_XdndDrop, handle_xdnd_drop_event }, - { XATOM_XdndLeave, X11DRV_XDND_LeaveEvent } + { XATOM_XdndLeave, handle_xdnd_leave_event } };
diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index 41120385e60..537a8e0326a 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -31,6 +31,7 @@ struct format_entry enum dnd_event_type { DND_DROP_EVENT, + DND_LEAVE_EVENT, DND_POSITION_EVENT, };
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index c17dc45594c..69aa69404f4 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -294,7 +294,6 @@ extern BOOL IME_SetCompositionString(DWORD dwIndex, LPCVOID lpComp, DWORD dwReadLen) DECLSPEC_HIDDEN; extern void IME_SetResultString(LPWSTR lpResult, DWORD dwResultlen) DECLSPEC_HIDDEN;
-extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
extern void handle_dnd_enter_event( struct format_entry *formats, ULONG size ) DECLSPEC_HIDDEN; extern UINT handle_dnd_event( void *params ) DECLSPEC_HIDDEN; diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index 9de0b60d0cd..8240bbbf5d6 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -342,7 +342,7 @@ static DWORD handle_drop_event( struct dnd_drop_event_params *params ) * * Handle an XdndLeave event. */ -void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) +static NTSTATUS handle_leave_event(void) { IDropTarget *dropTarget;
@@ -362,6 +362,7 @@ void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) }
X11DRV_XDND_FreeDragDropOp(); + return 0; }
@@ -736,6 +737,9 @@ UINT handle_dnd_event( void *params ) case DND_DROP_EVENT: return handle_drop_event( params );
+ case DND_LEAVE_EVENT: + return handle_leave_event(); + case DND_POSITION_EVENT: return handle_position_event( params );
From: Jacek Caban jacek@codeweavers.com
--- dlls/winex11.drv/bitblt.c | 2 +- dlls/winex11.drv/display.c | 4 ++-- dlls/winex11.drv/init.c | 2 +- dlls/winex11.drv/settings.c | 2 +- dlls/winex11.drv/window.c | 4 ++-- dlls/winex11.drv/x11drv.h | 9 +++++++++ 6 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 550c5f06f37..e21f975ef4a 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1912,7 +1912,7 @@ static void x11drv_surface_flush( struct window_surface *window_surface ) coords.width = surface->header.rect.right - surface->header.rect.left; coords.height = surface->header.rect.bottom - surface->header.rect.top; SetRect( &coords.visrect, 0, 0, coords.width, coords.height ); - if (IntersectRect( &coords.visrect, &coords.visrect, &surface->bounds )) + if (intersect_rect( &coords.visrect, &coords.visrect, &surface->bounds )) { TRACE( "flushing %p %dx%d bounds %s bits %p\n", surface, coords.width, coords.height, diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index f90cc455c36..aef4ed0b5b0 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -124,7 +124,7 @@ RECT get_work_area(const RECT *monitor_rect) work_rect.right = work_rect.left + work_area[i * 4 + 2]; work_rect.bottom = work_rect.top + work_area[i * 4 + 3];
- if (IntersectRect(&work_rect, &work_rect, monitor_rect)) + if (intersect_rect( &work_rect, &work_rect, monitor_rect )) { TRACE("work_rect:%s.\n", wine_dbgstr_rect(&work_rect)); XFree(work_area); @@ -146,7 +146,7 @@ RECT get_work_area(const RECT *monitor_rect) SetRect(&work_rect, work_area[0], work_area[1], work_area[0] + work_area[2], work_area[1] + work_area[3]);
- if (IntersectRect(&work_rect, &work_rect, monitor_rect)) + if (intersect_rect( &work_rect, &work_rect, monitor_rect )) { TRACE("work_rect:%s.\n", wine_dbgstr_rect(&work_rect)); XFree(work_area); diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index 9c5c394581b..27e070ef9b4 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -147,7 +147,7 @@ void add_device_bounds( X11DRV_PDEVICE *dev, const RECT *rect ) if (!dev->bounds) return; if (dev->region && NtGdiGetRgnBox( dev->region, &rc )) { - if (IntersectRect( &rc, &rc, rect )) add_bounds_rect( dev->bounds, &rc ); + if (intersect_rect( &rc, &rc, rect )) add_bounds_rect( dev->bounds, &rc ); } else add_bounds_rect( dev->bounds, rect ); } diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c index 652dedce601..44c61776b4b 100644 --- a/dlls/winex11.drv/settings.c +++ b/dlls/winex11.drv/settings.c @@ -709,7 +709,7 @@ static BOOL overlap_placed_displays(const RECT *rect, const struct x11drv_displa for (display_idx = 0; display_idx < display_count; ++display_idx) { if (displays[display_idx].placed && - IntersectRect(&intersect, &displays[display_idx].new_rect, rect)) + intersect_rect(&intersect, &displays[display_idx].new_rect, rect)) return TRUE; } return FALSE; diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 6771368671a..d7027032465 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2309,7 +2309,7 @@ static inline BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rec { *surface_rect = NtUserGetVirtualScreenRect();
- if (!IntersectRect( surface_rect, surface_rect, visible_rect )) return FALSE; + if (!intersect_rect( surface_rect, surface_rect, visible_rect )) return FALSE; OffsetRect( surface_rect, -visible_rect->left, -visible_rect->top ); surface_rect->left &= ~31; surface_rect->top &= ~31; @@ -2761,7 +2761,7 @@ BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
if (info->prcDirty) { - IntersectRect( &rect, &rect, info->prcDirty ); + intersect_rect( &rect, &rect, info->prcDirty ); memcpy( src_bits, dst_bits, bmi->bmiHeader.biSizeImage ); NtGdiPatBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, BLACKNESS ); } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 69aa69404f4..4576564fda3 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -885,6 +885,15 @@ static inline HWND get_active_window(void) return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndActive : 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;
From: Jacek Caban jacek@codeweavers.com
--- dlls/winex11.drv/clipboard.c | 45 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 18 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 6baa87c5ce1..ce936f9012e 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -687,25 +687,19 @@ static WCHAR* uri_to_dos(char *encodedURI) * * Convert a string in the specified encoding to CF_UNICODETEXT format. */ -static WCHAR *unicode_text_from_string( UINT codepage, const void *data, size_t size, size_t *ret_size ) +static void *unicode_text_from_string( WCHAR *ret, const WCHAR *string, DWORD count, size_t *size ) { - DWORD i, j, count; - WCHAR *strW; + DWORD i, j;
- count = MultiByteToWideChar( codepage, 0, data, size, NULL, 0); - - if (!(strW = malloc( (count * 2 + 1) * sizeof(WCHAR) ))) return 0; - - MultiByteToWideChar( codepage, 0, data, size, strW + count, count ); for (i = j = 0; i < count; i++) { - if (strW[i + count] == '\n' && (!i || strW[i + count - 1] != '\r')) strW[j++] = '\r'; - strW[j++] = strW[i + count]; + if (string[i] == '\n' && (!i || string[i - 1] != '\r')) ret[j++] = '\r'; + ret[j++] = string[i]; } - strW[j++] = 0; - *ret_size = j * sizeof(WCHAR); - TRACE( "returning %s\n", debugstr_wn( strW, j - 1 )); - return strW; + ret[j++] = 0; + *size = j * sizeof(WCHAR); + TRACE( "returning %s\n", debugstr_wn( ret, j - 1 )); + return ret; }
@@ -716,7 +710,12 @@ static WCHAR *unicode_text_from_string( UINT codepage, const void *data, size_t */ static void *import_string( Atom type, const void *data, size_t size, size_t *ret_size ) { - return unicode_text_from_string( 28591, data, size, ret_size ); + DWORD str_size; + 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 ); }
@@ -727,7 +726,12 @@ static void *import_string( Atom type, const void *data, size_t size, size_t *re */ static void *import_utf8_string( Atom type, const void *data, size_t size, size_t *ret_size ) { - return unicode_text_from_string( CP_UTF8, data, size, ret_size ); + DWORD str_size; + WCHAR *ret; + + if (!(ret = malloc( (size * 2 + 1) * sizeof(WCHAR) ))) return NULL; + RtlUTF8ToUnicodeN( ret + size, size * sizeof(WCHAR), &str_size, data, size ); + return unicode_text_from_string( ret, ret + size, str_size / sizeof(WCHAR), ret_size ); }
@@ -741,7 +745,8 @@ static void *import_compound_text( Atom type, const void *data, size_t size, siz char** srcstr; int count; XTextProperty txtprop; - void *ret; + DWORD len; + WCHAR *ret;
txtprop.value = (BYTE *)data; txtprop.nitems = size; @@ -750,7 +755,11 @@ static void *import_compound_text( Atom type, const void *data, size_t size, siz if (XmbTextPropertyToTextList( thread_display(), &txtprop, &srcstr, &count ) != Success) return 0; if (!count) return 0;
- ret = unicode_text_from_string( CP_UNIXCP, srcstr[0], strlen(srcstr[0]) + 1, ret_size ); + 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 ); + ret = unicode_text_from_string( ret, ret + len, count, ret_size ); + XFreeStringList(srcstr); return ret; }
From: Jacek Caban jacek@codeweavers.com
--- dlls/winex11.drv/clipboard.c | 68 +++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 32 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index ce936f9012e..1dcd5362c8c 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -729,9 +729,11 @@ static void *import_utf8_string( Atom type, const void *data, size_t size, size_ DWORD str_size; WCHAR *ret;
- if (!(ret = malloc( (size * 2 + 1) * sizeof(WCHAR) ))) return NULL; - RtlUTF8ToUnicodeN( ret + size, size * sizeof(WCHAR), &str_size, data, size ); - return unicode_text_from_string( ret, ret + size, str_size / sizeof(WCHAR), ret_size ); + RtlUTF8ToUnicodeN( NULL, 0, &str_size, data, size ); + if (!(ret = malloc( str_size * 2 + sizeof(WCHAR) ))) return NULL; + RtlUTF8ToUnicodeN( ret + str_size / sizeof(WCHAR), str_size, &str_size, data, size ); + return unicode_text_from_string( ret, ret + str_size / sizeof(WCHAR), + str_size / sizeof(WCHAR), ret_size ); }
@@ -1198,31 +1200,19 @@ static BOOL export_data( Display *display, Window win, Atom prop, Atom target, v * * Convert CF_UNICODETEXT data to a string in the specified codepage. */ -static char *string_from_unicode_text( UINT codepage, const WCHAR *string, size_t string_size, size_t *size ) +static void string_from_unicode_text( char *str, size_t len, DWORD *size ) { - UINT i, j; - char *str; - UINT lenW = string_size / sizeof(WCHAR); - DWORD len; - - if (!string_size) return NULL; + DWORD i, j;
- len = WideCharToMultiByte( codepage, 0, string, lenW, NULL, 0, NULL, NULL ); - if ((str = malloc( len ))) + /* remove carriage returns */ + for (i = j = 0; i < len; i++) { - WideCharToMultiByte( codepage, 0, string, lenW, str, len, NULL, NULL); - - /* remove carriage returns */ - for (i = j = 0; i < len; i++) - { - if (str[i] == '\r' && (i == len - 1 || str[i + 1] == '\n')) continue; - str[j++] = str[i]; - } - while (j && !str[j - 1]) j--; /* remove trailing nulls */ - *size = j; - TRACE( "returning %s\n", debugstr_an( str, j )); + if (str[i] == '\r' && (i == len - 1 || str[i + 1] == '\n')) continue; + str[j++] = str[i]; } - return str; + while (j && !str[j - 1]) j--; /* remove trailing nulls */ + TRACE( "returning %s\n", debugstr_an( str, j )); + *size = j; }
@@ -1233,10 +1223,14 @@ static char *string_from_unicode_text( UINT codepage, const WCHAR *string, size_ */ static BOOL export_string( Display *display, Window win, Atom prop, Atom target, void *data, size_t size ) { - char *text = string_from_unicode_text( 28591, data, size, &size ); + DWORD len; + char *text; + + if (!(text = malloc( size ))) return FALSE; + len = WideCharToMultiByte( 28591, 0, data, size / sizeof(WCHAR), text, size, NULL, NULL ); + string_from_unicode_text( text, len, &len );
- if (!text) return FALSE; - put_property( display, win, prop, target, 8, text, size ); + put_property( display, win, prop, target, 8, text, len ); free( text ); return TRUE; } @@ -1250,10 +1244,14 @@ static BOOL export_string( Display *display, Window win, Atom prop, Atom target, static BOOL export_utf8_string( Display *display, Window win, Atom prop, Atom target, void *data, size_t size ) { - char *text = string_from_unicode_text( CP_UTF8, data, size, &size ); + DWORD len; + char *text; + + if (!(text = malloc( size / sizeof(WCHAR) * 3 ))) return FALSE; + RtlUnicodeToUTF8N( text, size / sizeof(WCHAR) * 3, &len, data, size ); + string_from_unicode_text( text, len, &len );
- if (!text) return FALSE; - put_property( display, win, prop, target, 8, text, size ); + put_property( display, win, prop, target, 8, text, len ); free( text ); return TRUE; } @@ -1280,9 +1278,15 @@ static BOOL export_compound_text( Display *display, Window win, Atom prop, Atom { XTextProperty textprop; XICCEncodingStyle style; - char *text = string_from_unicode_text( CP_UNIXCP, data, size, &size ); + DWORD len; + char *text; + + + 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 ); + string_from_unicode_text( text, len, &len );
- if (!text) return FALSE; if (target == x11drv_atom(COMPOUND_TEXT)) style = XCompoundTextStyle; else
From: Jacek Caban jacek@codeweavers.com
--- dlls/winex11.drv/clipboard.c | 11 +++++------ dlls/winex11.drv/window.c | 7 ++++--- dlls/winex11.drv/xrandr.c | 8 ++++++-- 3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 1dcd5362c8c..f9e6764fc0a 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -914,12 +914,11 @@ static void *import_text_html( Atom type, const void *data, size_t size, size_t /* Firefox uses UTF-16LE with byte order mark. Convert to UTF-8 without the BOM. */ if (size >= sizeof(WCHAR) && ((const WCHAR *)data)[0] == 0xfeff) { - len = WideCharToMultiByte( CP_UTF8, 0, (const WCHAR *)data + 1, size / sizeof(WCHAR) - 1, - NULL, 0, NULL, NULL ); - if (!(text = malloc( len ))) return 0; - WideCharToMultiByte( CP_UTF8, 0, (const WCHAR *)data + 1, size / sizeof(WCHAR) - 1, - text, len, NULL, NULL ); - size = len; + DWORD str_len; + RtlUnicodeToUTF8N( NULL, 0, &str_len, (const WCHAR *)data + 1, size - sizeof(WCHAR) ); + if (!(text = malloc( str_len ))) return NULL; + RtlUnicodeToUTF8N( text, str_len, &str_len, (const WCHAR *)data + 1, size - sizeof(WCHAR) ); + size = str_len; data = text; }
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index d7027032465..3b0ccd8d22a 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -437,22 +437,23 @@ static void sync_window_opacity( Display *display, Window win, */ static void sync_window_text( Display *display, Window win, const WCHAR *text ) { - UINT count; + DWORD count, len; char *buffer, *utf8_buffer; XTextProperty prop;
/* allocate new buffer for window text */ + len = lstrlenW( text ); count = WideCharToMultiByte(CP_UNIXCP, 0, text, -1, NULL, 0, NULL, NULL); if (!(buffer = malloc( count ))) return; WideCharToMultiByte(CP_UNIXCP, 0, text, -1, buffer, count, NULL, NULL);
- count = WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), NULL, 0, NULL, NULL); + RtlUnicodeToUTF8N( NULL, 0, &count, text, len * sizeof(WCHAR) ); if (!(utf8_buffer = malloc( count ))) { free( buffer ); return; } - WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), utf8_buffer, count, NULL, NULL); + RtlUnicodeToUTF8N( utf8_buffer, count, &count, text, len * sizeof(WCHAR) );
if (XmbTextListToTextProperty( display, &buffer, 1, XStdICCTextStyle, &prop ) == Success) { diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index b0619c0abcd..6ede776d76b 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -652,6 +652,7 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid VkPhysicalDeviceIDProperties id; VkInstance vk_instance = NULL; VkDisplayKHR vk_display; + DWORD len; BOOL ret = FALSE; VkResult vr;
@@ -723,7 +724,8 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid gpu->vendor_id = properties2.properties.vendorID; gpu->device_id = properties2.properties.deviceID; } - MultiByteToWideChar( CP_UTF8, 0, properties2.properties.deviceName, -1, gpu->name, ARRAY_SIZE(gpu->name) ); + RtlUTF8ToUnicodeN( gpu->name, sizeof(gpu->name), &len, properties2.properties.deviceName, + strlen( properties2.properties.deviceName ) + 1 ); ret = TRUE; goto done; } @@ -749,6 +751,7 @@ static BOOL xrandr14_get_gpus2( struct gdi_gpu **new_gpus, int *count, BOOL get_ INT primary_provider = -1; RECT primary_rect; BOOL ret = FALSE; + DWORD len; INT i, j;
screen_resources = xrandr_get_screen_resources(); @@ -803,7 +806,8 @@ static BOOL xrandr14_get_gpus2( struct gdi_gpu **new_gpus, int *count, BOOL get_ if (get_properties) { if (!get_gpu_properties_from_vulkan( &gpus[i], provider_info )) - MultiByteToWideChar( CP_UTF8, 0, provider_info->name, -1, gpus[i].name, ARRAY_SIZE(gpus[i].name) ); + RtlUTF8ToUnicodeN( gpus[i].name, sizeof(gpus[i].name), &len, provider_info->name, + strlen( provider_info->name ) + 1 ); /* FIXME: Add an alternate method of getting PCI IDs, for systems that don't support Vulkan */ } pXRRFreeProviderInfo( provider_info );
These are missing your SoB (assuming we still care).