winex11: Fix handling of property sizes for 64-bit platforms.

This commit is contained in:
Alexandre Julliard 2008-04-07 11:41:54 +02:00
parent 6d80f099f7
commit 3bfa90eeda
7 changed files with 15 additions and 8 deletions

View File

@ -1902,8 +1902,8 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
* The TARGETS property should have returned us a list of atoms
* corresponding to each selection target format supported.
*/
if (atype == XA_ATOM || atype == x11drv_atom(TARGETS))
X11DRV_CLIPBOARD_InsertSelectionProperties(display, targetList, (cSelectionTargets * aformat / (8 * sizeof(Atom))));
if (aformat == 32 && (atype == XA_ATOM || atype == x11drv_atom(TARGETS)))
X11DRV_CLIPBOARD_InsertSelectionProperties(display, targetList, cSelectionTargets);
/* Free the list of targets */
wine_tsx11_lock();
@ -2027,7 +2027,7 @@ static BOOL X11DRV_CLIPBOARD_ReadProperty(Window w, Atom prop,
return FALSE;
}
count = nitems * (aformat / 8);
count = get_property_size( aformat, nitems );
if (!val) *data = HeapAlloc( GetProcessHeap(), 0, pos * sizeof(int) + count + 1 );
else *data = HeapReAlloc( GetProcessHeap(), 0, val, pos * sizeof(int) + count + 1 );

View File

@ -677,7 +677,7 @@ int get_window_wm_state( Display *display, struct x11drv_win_data *data )
sizeof(*state)/sizeof(CARD32), False, x11drv_atom(WM_STATE),
&type, &format, &count, &remaining, (unsigned char **)&state ))
{
if (type == x11drv_atom(WM_STATE) && format && count >= sizeof(*state)/(format/8))
if (type == x11drv_atom(WM_STATE) && get_property_size( format, count ) >= sizeof(*state))
ret = state->state;
XFree( state );
}

View File

@ -1394,7 +1394,7 @@ static unsigned char *get_icm_profile( unsigned long *size )
&type, &format, &count, &remaining, &profile );
if (format && count)
{
*size = count * (format / 8);
*size = get_property_size( format, count );
if ((ret = HeapAlloc( GetProcessHeap(), 0, *size ))) memcpy( ret, profile, *size );
XFree( profile );
}

View File

@ -866,7 +866,7 @@ static char *get_process_name(void)
*/
static void set_initial_wm_hints( Display *display, struct x11drv_win_data *data )
{
int i;
long i;
Atom protocols[3];
Atom dndVersion = 4;
XClassHint *class_hints;

View File

@ -618,7 +618,7 @@ static BOOL is_netwm_supported( Display *display, Atom atom )
if (!XGetWindowProperty( display, DefaultRootWindow(display), x11drv_atom(_NET_SUPPORTED), 0,
~0UL, False, XA_ATOM, &type, &format, &count,
&remaining, (unsigned char **)&net_supported ))
net_supported_count = count * (format / 8) / sizeof(Atom);
net_supported_count = get_property_size( format, count ) / sizeof(Atom);
else
net_supported_count = 0;
}

View File

@ -520,6 +520,13 @@ static inline struct x11drv_thread_data *x11drv_thread_data(void)
static inline Display *thread_display(void) { return x11drv_thread_data()->display; }
static inline size_t get_property_size( int format, unsigned long count )
{
/* format==32 means long, which can be 64 bits... */
if (format == 32) return count * sizeof(long);
return count * (format / 8);
}
extern Visual *visual;
extern Window root_window;
extern unsigned int screen_width;

View File

@ -286,7 +286,7 @@ static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
AnyPropertyType, &acttype, &actfmt, &icount, &bytesret, &data);
wine_tsx11_unlock();
entries += X11DRV_XDND_MapFormat(types[i], data, icount * (actfmt / 8));
entries += X11DRV_XDND_MapFormat(types[i], data, get_property_size( actfmt, icount ));
wine_tsx11_lock();
XFree(data);
wine_tsx11_unlock();