[PATCH] Support for animated cursors

Trent Waddington trent.waddington at gmail.com
Tue Aug 28 08:25:31 CDT 2007


I noticed LoadCursorFromFile() wasn't working, so here's a patch to fix that.

And a patch to fix some memory I was leaking.

Have tested 150+ animated cursors so far, all appear to display correctly.

Trent
-------------- next part --------------
From 969a78da805d267ac5abc6427e017e4f6e3fec18 Mon Sep 17 00:00:00 2001
From: Trent Waddington <trentw at linux.localdomain>
Date: Tue, 28 Aug 2007 22:54:03 +1000
Subject: Handle LoadFromFile for animated cursors.

---
 dlls/user32/cursoricon.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 5ea63fb..22d699c 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -1024,7 +1024,6 @@ HICON WINAPI CreateIconFromResource( LPBYTE bits, UINT cbSize,
     return CreateIconFromResourceEx( bits, cbSize, bIcon, dwVersion, 0,0,0);
 }
 
-
 static HICON CURSORICON_LoadFromFile( LPCWSTR filename,
                              INT width, INT height, INT colors,
                              BOOL fCursor, UINT loadflags)
@@ -1041,6 +1040,12 @@ static HICON CURSORICON_LoadFromFile( LPCWSTR filename,
     if (!bits)
         return hIcon;
 
+    if (isAnimatedCursor(bits))
+    {
+        return CreateIconFromResourceEx( bits, filesize, !fCursor, 0x00030000, 
+                                            0, 0, loadflags );
+    }
+
     dir = (CURSORICONFILEDIR*) bits;
     if ( filesize < sizeof(*dir) )
         goto end;
-- 
1.4.4.3
-------------- next part --------------
From b2eee6e0019ddf39b5a8901bcbdb50f8a43784db Mon Sep 17 00:00:00 2001
From: Trent Waddington <trentw at linux.localdomain>
Date: Tue, 28 Aug 2007 23:17:47 +1000
Subject: Fix some memory I was leaking.

---
 dlls/user32/cursoricon.c |    4 +++-
 dlls/winex11.drv/mouse.c |    1 +
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 22d699c..7ddf413 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -1042,8 +1042,10 @@ static HICON CURSORICON_LoadFromFile( LPCWSTR filename,
 
     if (isAnimatedCursor(bits))
     {
-        return CreateIconFromResourceEx( bits, filesize, !fCursor, 0x00030000, 
+        hIcon = CreateIconFromResourceEx( bits, filesize, !fCursor, 0x00030000, 
                                             0, 0, loadflags );
+        UnmapViewOfFile( bits );
+        return hIcon;
     }
 
     dir = (CURSORICONFILEDIR*) bits;
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index a9991e2..44eb390 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -571,6 +571,7 @@ static Cursor create_xcursor_cursor( Display *display, CURSORICONINFO *ptr )
         if (!image) 
         {
             pXcursorImagesDestroy( images );
+            GlobalUnlock16(hNext);
             return 0;
         }
 
-- 
1.4.4.3


More information about the wine-patches mailing list