[ros-diffs] [gschneider] 42291: user32: - Restructure and simplify CreateCursorFromData - Call CreateIconFromResourceEx properly allowing it to create colored icons (although it doesn't care about that yet) - Fix some comment typos win32k: - Don't just copy the pointer to an XLATEOBJ, copy instead. The caller will free it, EngSetPointerShape will do so too (causing either double-frees or memory write errors)

gschneider at svn.reactos.org gschneider at svn.reactos.org
Wed Jul 29 20:28:11 CEST 2009


Author: gschneider
Date: Wed Jul 29 20:28:11 2009
New Revision: 42291

URL: http://svn.reactos.org/svn/reactos?rev=42291&view=rev
Log:
user32:
- Restructure and simplify CreateCursorFromData
- Call CreateIconFromResourceEx properly allowing it to create colored icons (although it doesn't care about that yet)
- Fix some comment typos
win32k:
- Don't just copy the pointer to an XLATEOBJ, copy instead. The caller will free it, EngSetPointerShape will do so too (causing either double-frees or memory write errors)

Modified:
    trunk/reactos/dll/win32/user32/windows/bitmap.c
    trunk/reactos/dll/win32/user32/windows/icon.c
    trunk/reactos/subsystems/win32/win32k/eng/mouse.c

Modified: trunk/reactos/dll/win32/user32/windows/bitmap.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/bitmap.c?rev=42291&r1=42290&r2=42291&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/bitmap.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/bitmap.c [iso-8859-1] Wed Jul 29 20:28:11 2009
@@ -56,7 +56,7 @@
 
 #include "poppack.h"
 
-/* forward declerations... actually in user32\windows\icon.c but usful here */
+/* forward declarations... actually in user32\windows\icon.c but useful here */
 HICON ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot);
 CURSORICONDIRENTRY *CURSORICON_FindBestIcon( CURSORICONDIR *dir, int width, int height, int colors);
 CURSORICONDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir, int width, int height, int colors);
@@ -265,7 +265,7 @@
       hIcon = CreateIconFromResourceEx((PBYTE)ResIcon,
                                        SizeofResource(hinst, hResInfo),
                                        Icon, 0x00030000, width, height,
-                                       fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
+                                       (fuLoad & (LR_DEFAULTSIZE | LR_SHARED)) | LR_DEFAULTCOLOR);
 
       if (hIcon && 0 != (fuLoad & LR_SHARED))
       {

Modified: trunk/reactos/dll/win32/user32/windows/icon.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/icon.c?rev=42291&r1=42290&r2=42291&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/icon.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/icon.c [iso-8859-1] Wed Jul 29 20:28:11 2009
@@ -98,13 +98,25 @@
    BITMAPINFO *bwBIH = (BITMAPINFO *)BitmapInfoBuffer;
    BITMAPINFO *orgBIH = (BITMAPINFO *)IconImage;
    ICONINFO IconInfo;
-   PVOID XORImageData = ImageData;
 
    IconInfo.fIcon = FALSE;
    IconInfo.xHotspot = xHotspot;
    IconInfo.yHotspot = yHotspot;
 
-   /* Create a BITMAPINFO header for the monochrome part of the icon */
+   /* Handle the color part of the cursor */
+   if (IconImage->icHeader.biBitCount == 1)
+   {
+      IconInfo.hbmColor = (HBITMAP)0;
+   }
+   else
+   {
+       FIXME("loading %d bpp color cursor\n", IconImage->icHeader.biBitCount);
+       IconInfo.hbmColor = CreateDIBitmap(hDC, &IconImage->icHeader, CBM_INIT,
+                                          ImageData, (BITMAPINFO*)IconImage,
+                                          DIB_RGB_COLORS);
+   }
+
+   /* Create a BITMAPINFO header for the monochrome part of the cursor */
    bwBIH->bmiHeader.biBitCount = 1;
    bwBIH->bmiHeader.biWidth = IconImage->icHeader.biWidth;
    bwBIH->bmiHeader.biHeight = IconImage->icHeader.biHeight;
@@ -127,29 +139,13 @@
    bwBIH->bmiColors[1].rgbRed = 0xff;
    bwBIH->bmiColors[1].rgbReserved = 0;
 
-   /* Load the AND bitmap */
+   /* Load the monochrome bitmap */
    IconInfo.hbmMask = CreateDIBitmap(hDC, &bwBIH->bmiHeader, 0,
-                                     XORImageData, bwBIH, DIB_RGB_COLORS);
+                                     ImageData, bwBIH, DIB_RGB_COLORS);
    if (IconInfo.hbmMask)
    {
       SetDIBits(hDC, IconInfo.hbmMask, 0, IconImage->icHeader.biHeight,
-                XORImageData, orgBIH, DIB_RGB_COLORS);
-   }
-
-   if (IconImage->icHeader.biBitCount == 1)
-   {
-      IconInfo.hbmColor = (HBITMAP)0;
-   }
-   else
-   {
-      /* Create the color part of the icon */
-      IconInfo.hbmColor = CreateDIBitmap(hDC, &IconImage->icHeader, 0,
-                                          XORImageData, orgBIH, DIB_RGB_COLORS);
-      if (IconInfo.hbmColor)
-      {
-         SetDIBits(hDC, IconInfo.hbmColor, 0, IconImage->icHeader.biHeight,
-                   XORImageData, orgBIH, DIB_RGB_COLORS);
-      }
+                ImageData, orgBIH, DIB_RGB_COLORS);
    }
 
    /* Create the icon based on everything we have so far */

Modified: trunk/reactos/subsystems/win32/win32k/eng/mouse.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng/mouse.c?rev=42291&r1=42290&r2=42291&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/mouse.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/mouse.c [iso-8859-1] Wed Jul 29 20:28:11 2009
@@ -426,7 +426,8 @@
     }
     else
     {
-        pgp->XlateObject = pxlo;
+        pgp->XlateObject = EngAllocMem(0, sizeof(XLATEOBJ), TAG_XLATEOBJ);
+        memcpy(pgp->XlateObject, pxlo, sizeof(XLATEOBJ));
     }
 
     /* Create surface for saving the pixels under the cursor. */




More information about the Ros-diffs mailing list