winex11: Reimplement EVENT_DropFromOffiX using get_dos_file_name.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
30e172203d
commit
e02c2f82d4
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue