From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/clipboard.c | 4 ++-- dlls/winex11.drv/event.c | 21 ++++++++++++--------- dlls/winex11.drv/unixlib.h | 10 ++++++++++ dlls/winex11.drv/x11drv.h | 4 ++-- dlls/winex11.drv/xdnd.c | 8 +++++--- 5 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 087e0aab79b..46a48605a20 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -1048,7 +1048,7 @@ 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 ) +DROPFILES *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; @@ -1100,7 +1100,7 @@ void *file_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) /************************************************************************** * uri_list_to_drop_files */ -void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) +DROPFILES *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ) { const char *uriList = data; char *uri; diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index c0fe82b97eb..3797e638c75 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -40,7 +40,6 @@ #include <string.h>
#include "x11drv.h" -#include "shlobj.h" /* DROPFILES */ #include "shellapi.h"
#include "wine/server.h" @@ -1428,8 +1427,12 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt )
static void post_drop( HWND hwnd, DROPFILES *drop, ULONG size ) { - drop->fWide = HandleToUlong( hwnd ); /* abuse fWide to pass window handle */ - x11drv_client_func( client_func_dnd_post_drop, drop, size ); + struct dnd_post_drop_params *params; + if (!(params = malloc( sizeof(*params) + size - sizeof(*drop) ))) return; + memcpy( ¶ms->drop, drop, size ); + params->drop.fWide = HandleToUlong( hwnd ); /* abuse fWide to pass window handle */ + x11drv_client_func( client_func_dnd_post_drop, params, size ); + free( params ); }
/********************************************************************** @@ -1476,11 +1479,10 @@ static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
if (!aux_long && p_data) /* don't bother if > 64K */ { - DROPFILES *drop; size_t drop_size; + DROPFILES *drop;
- drop = file_list_to_drop_files( p_data, get_property_size( format, data_length ), &drop_size ); - if (drop) + if ((drop = file_list_to_drop_files( p_data, get_property_size( format, data_length ), &drop_size ))) { post_drop( hWnd, drop, drop_size ); free( drop ); @@ -1505,7 +1507,6 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event ) unsigned long aux_long; unsigned char *p_data = NULL; /* property data */ int x, y; - DROPFILES *drop; int format; union { Atom atom_aux; @@ -1527,9 +1528,9 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event ) 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 ); + DROPFILES *drop;
- if (drop) + if ((drop = uri_list_to_drop_files( p_data, get_property_size( format, data_length ), &drop_size ))) { XQueryPointer( event->display, root_window, &u.w_aux, &u.w_aux, &x, &y, &u.i, &u.i, &u.u); @@ -1548,6 +1549,8 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event ) post_drop( hWnd, drop, drop_size ); free( drop ); } + + free( drop ); } if (p_data) XFree( p_data ); } diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index 30a6a618391..701868f2722 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -17,6 +17,7 @@ */
#include "ntuser.h" +#include "shlobj.h" #include "wine/unixlib.h"
enum x11drv_funcs @@ -95,3 +96,12 @@ struct dnd_drop_event_params { ULONG hwnd; }; + +/* x11drv_dnd_post_drop params */ +struct dnd_post_drop_params +{ + DROPFILES drop; + char data[]; +}; + +C_ASSERT(sizeof(struct dnd_post_drop_params) == offsetof(struct dnd_post_drop_params, data[0])); diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 9c47a7462ba..d81b679431d 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -645,8 +645,8 @@ extern void change_systray_owner( Display *display, Window systray_window ); extern HWND create_foreign_window( Display *display, Window window ); extern BOOL update_clipboard( HWND hwnd ); extern void init_win_context(void); -extern void *file_list_to_drop_files( const void *data, size_t size, size_t *ret_size ); -extern void *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size ); +extern DROPFILES *file_list_to_drop_files( const void *data, size_t size, size_t *ret_size ); +extern DROPFILES *uri_list_to_drop_files( const void *data, size_t size, size_t *ret_size );
static inline void mirror_rect( const RECT *window_rect, RECT *rect ) { diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index 2d78e859748..edf47d9be2e 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -723,15 +723,17 @@ static IDataObjectVtbl xdndDataObjectVtbl =
static IDataObject XDNDDataObject = { &xdndDataObjectVtbl };
-NTSTATUS WINAPI x11drv_dnd_post_drop( void *data, ULONG size ) +NTSTATUS WINAPI x11drv_dnd_post_drop( void *args, ULONG size ) { + UINT drop_size = size - offsetof(struct dnd_post_drop_params, drop); + struct dnd_post_drop_params *params = args; HDROP handle;
- if ((handle = GlobalAlloc( GMEM_SHARE, size ))) + if ((handle = GlobalAlloc( GMEM_SHARE, drop_size ))) { DROPFILES *ptr = GlobalLock( handle ); HWND hwnd; - memcpy( ptr, data, size ); + memcpy( ptr, ¶ms->drop, drop_size ); hwnd = UlongToHandle( ptr->fWide ); ptr->fWide = TRUE; GlobalUnlock( handle );