From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/xdnd.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index dff9a276a3e..2f3e23aef29 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -601,45 +601,33 @@ static BOOL X11DRV_XDND_HasHDROP(void) */ static HRESULT X11DRV_XDND_SendDropFiles(HWND hwnd) { - struct format_entry *iter; + FORMATETC format = {.cfFormat = CF_HDROP}; + STGMEDIUM medium; HRESULT hr; - BOOL found = FALSE; - HGLOBAL hglobal;
EnterCriticalSection(&xdnd_cs);
- for (iter = xdnd_formats; iter < xdnd_formats_end; iter = next_format( iter )) - { - if (iter->format == CF_HDROP) - { - found = TRUE; - break; - } - } - if (!found) hr = E_FAIL; - else if (!(hglobal = GlobalAlloc( GMEM_FIXED, iter->size ))) hr = HRESULT_FROM_WIN32(GetLastError()); - else + if (!xdnd_formats) hr = E_FAIL; + else if (SUCCEEDED(hr = IDataObject_GetData( &xdnd_data_object, &format, &medium ))) { - DROPFILES *drop = GlobalLock( hglobal ); - void *files; + DROPFILES *drop = GlobalLock( medium.hGlobal ); + void *files = (char *)drop + drop->pFiles; RECT rect;
- memcpy( drop, iter->data, iter->size ); - files = (char *)drop + drop->pFiles; drop->pt.x = XDNDxy.x; drop->pt.y = XDNDxy.y; drop->fNC = !ScreenToClient( hwnd, &drop->pt ) || !GetClientRect( hwnd, &rect ) || !PtInRect( &rect, drop->pt );
TRACE( "Sending WM_DROPFILES: hwnd %p, pt %s, fNC %u, files %p (%s)\n", hwnd, wine_dbgstr_point( &drop->pt), drop->fNC, files, debugstr_w(files) ); - GlobalUnlock( hglobal ); + GlobalUnlock( medium.hGlobal );
- if (PostMessageW( hwnd, WM_DROPFILES, (WPARAM)hglobal, 0 )) + if (PostMessageW( hwnd, WM_DROPFILES, (WPARAM)medium.hGlobal, 0 )) hr = S_OK; else { hr = HRESULT_FROM_WIN32(GetLastError()); - GlobalFree( hglobal ); + GlobalFree( medium.hGlobal ); } }