From eddffff7809dfc4cff2280ac774e8fda939b7a94 Mon Sep 17 00:00:00 2001 From: Erich Hoover Date: Wed, 9 Mar 2011 22:56:50 -0700 Subject: [PATCH] winex11: Add support for retrieving multi-rate animated cursor data. --- dlls/winex11.drv/mouse.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 63786413d24..ab500eff428 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -294,7 +294,7 @@ static XcursorImage *create_xcursor_frame( HDC hdc, const ICONINFOEXW *iinfo, HA int width, int height, int istep ) { XcursorImage *image, *ret = NULL; - DWORD delay_jiffies, is_static; + DWORD delay_jiffies, num_steps; int x, y, i, has_alpha; XcursorPixel *ptr; @@ -310,12 +310,11 @@ static XcursorImage *create_xcursor_frame( HDC hdc, const ICONINFOEXW *iinfo, HA image->xhot = iinfo->xHotspot; image->yhot = iinfo->yHotspot; - /* TODO: Handle animated cursors that use multiple rates */ image->delay = 100; /* fallback delay, 100 ms */ - if (GetCursorFrameInfo(icon, 0x0 /* unknown parameter */, 0 /* obtain first rate */, &delay_jiffies, &is_static) != 0) + if (GetCursorFrameInfo(icon, 0x0 /* unknown parameter */, istep, &delay_jiffies, &num_steps) != 0) image->delay = (100 * delay_jiffies) / 6; /* convert jiffies (1/60s) to milliseconds */ else - WARN("Failed to retrieve animated cursor framerate.\n"); + WARN("Failed to retrieve animated cursor frame-rate for frame %d.\n", istep); /* draw the cursor frame to a temporary buffer then copy it into the XcursorImage */ memset( color_bits, 0x00, color_size ); @@ -366,14 +365,16 @@ static Cursor create_xcursor_cursor( HDC hdc, const ICONINFOEXW *iinfo, HANDLE i { unsigned char *color_bits, *mask_bits; HBITMAP hbmColor = 0, hbmMask = 0; - XcursorImage **imgs, *image; + DWORD nFrames, delay_jiffies, i; int color_size, mask_size; BITMAPINFO *info = NULL; XcursorImages *images; + XcursorImage **imgs; Cursor cursor = 0; - int nFrames = 0; - if (!(imgs = HeapAlloc( GetProcessHeap(), 0, sizeof(XcursorImage*) ))) return 0; + /* Retrieve the number of frames to render */ + if (!GetCursorFrameInfo(icon, 0x0 /* unknown parameter */, 0, &delay_jiffies, &nFrames)) return 0; + if (!(imgs = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(XcursorImage*)*nFrames ))) return 0; /* Allocate all of the resources necessary to obtain a cursor frame */ if (!(info = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) goto cleanup; @@ -406,19 +407,13 @@ static Cursor create_xcursor_cursor( HDC hdc, const ICONINFOEXW *iinfo, HANDLE i } /* Create an XcursorImage for each frame of the cursor */ - while (1) + for (i=0; i= 0; nFrames--) - pXcursorImageDestroy( imgs[nFrames] ); + for (i=0; i