diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 2996857d937..2404a7114c0 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -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 ); diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 8fd9b2060cb..377e8f4b575 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -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 ); } diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c index e75b5943162..af623ac17ec 100644 --- a/dlls/winex11.drv/graphics.c +++ b/dlls/winex11.drv/graphics.c @@ -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 ); } diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index e03504119ae..6e4f4680df1 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -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; diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c index 25f7413dbcc..c63c868b059 100644 --- a/dlls/winex11.drv/winpos.c +++ b/dlls/winex11.drv/winpos.c @@ -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; } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index ab5ff768c61..b47bdfa7784 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -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; diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index 73674f519b7..14225789c05 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -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();