Commit 064838c5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

user32: Simplify cursor hotspot handling.

parent b86842bb
...@@ -66,6 +66,7 @@ struct cursoricon_frame ...@@ -66,6 +66,7 @@ struct cursoricon_frame
HBITMAP color; /* color bitmap */ HBITMAP color; /* color bitmap */
HBITMAP alpha; /* pre-multiplied alpha bitmap for 32-bpp icons */ HBITMAP alpha; /* pre-multiplied alpha bitmap for 32-bpp icons */
HBITMAP mask; /* mask bitmap (followed by color for 1-bpp icons) */ HBITMAP mask; /* mask bitmap (followed by color for 1-bpp icons) */
POINT hotspot;
}; };
struct cursoricon_object struct cursoricon_object
...@@ -80,7 +81,6 @@ struct cursoricon_object ...@@ -80,7 +81,6 @@ struct cursoricon_object
BOOL is_icon; /* whether icon or cursor */ BOOL is_icon; /* whether icon or cursor */
BOOL is_ani; /* whether this object is a static cursor or an animated cursor */ BOOL is_ani; /* whether this object is a static cursor or an animated cursor */
UINT delay; /* delay between this frame and the next (in jiffies) */ UINT delay; /* delay between this frame and the next (in jiffies) */
POINT hotspot;
union union
{ {
struct cursoricon_frame frame; /* frame-specific icon data */ struct cursoricon_frame frame; /* frame-specific icon data */
...@@ -1184,7 +1184,6 @@ done: ...@@ -1184,7 +1184,6 @@ done:
struct cursoricon_frame *frame; struct cursoricon_frame *frame;
info->is_icon = bIcon; info->is_icon = bIcon;
info->hotspot = hotspot;
frame = get_icon_frame( info, 0 ); frame = get_icon_frame( info, 0 );
frame->delay = ~0; frame->delay = ~0;
frame->width = width; frame->width = width;
...@@ -1192,6 +1191,7 @@ done: ...@@ -1192,6 +1191,7 @@ done:
frame->color = color; frame->color = color;
frame->mask = mask; frame->mask = mask;
frame->alpha = alpha; frame->alpha = alpha;
frame->hotspot = hotspot;
release_icon_frame( info, frame ); release_icon_frame( info, frame );
if (!IS_INTRESOURCE(resname)) if (!IS_INTRESOURCE(resname))
{ {
...@@ -1435,13 +1435,14 @@ static HCURSOR CURSORICON_CreateIconFromANI( const BYTE *bits, DWORD bits_size, ...@@ -1435,13 +1435,14 @@ static HCURSOR CURSORICON_CreateIconFromANI( const BYTE *bits, DWORD bits_size,
const CURSORICONFILEDIRENTRY *entry; const CURSORICONFILEDIRENTRY *entry;
INT frameWidth, frameHeight; INT frameWidth, frameHeight;
const BITMAPINFO *bmi; const BITMAPINFO *bmi;
POINT hotspot;
entry = CURSORICON_FindBestIconFile((const CURSORICONFILEDIR *) icon_data, entry = CURSORICON_FindBestIconFile((const CURSORICONFILEDIR *) icon_data,
bits + bits_size - icon_data, bits + bits_size - icon_data,
width, height, depth, loadflags ); width, height, depth, loadflags );
info->hotspot.x = entry->xHotspot; hotspot.x = entry->xHotspot;
info->hotspot.y = entry->yHotspot; hotspot.y = entry->yHotspot;
if (!header.width || !header.height) if (!header.width || !header.height)
{ {
frameWidth = entry->bWidth; frameWidth = entry->bWidth;
...@@ -1459,7 +1460,7 @@ static HCURSOR CURSORICON_CreateIconFromANI( const BYTE *bits, DWORD bits_size, ...@@ -1459,7 +1460,7 @@ static HCURSOR CURSORICON_CreateIconFromANI( const BYTE *bits, DWORD bits_size,
bmi = (const BITMAPINFO *) (icon_data + entry->dwDIBOffset); bmi = (const BITMAPINFO *) (icon_data + entry->dwDIBOffset);
/* Grab a frame from the animation */ /* Grab a frame from the animation */
frames[i] = create_icon_from_bmi( bmi, bits + bits_size - (const BYTE *)bmi, frames[i] = create_icon_from_bmi( bmi, bits + bits_size - (const BYTE *)bmi,
NULL, NULL, NULL, info->hotspot, NULL, NULL, NULL, hotspot,
is_icon, frameWidth, frameHeight, loadflags ); is_icon, frameWidth, frameHeight, loadflags );
} }
...@@ -2201,8 +2202,8 @@ BOOL WINAPI GetIconInfoExW( HICON icon, ICONINFOEXW *info ) ...@@ -2201,8 +2202,8 @@ BOOL WINAPI GetIconInfoExW( HICON icon, ICONINFOEXW *info )
TRACE("%p => %dx%d\n", icon, frame->width, frame->height); TRACE("%p => %dx%d\n", icon, frame->width, frame->height);
info->fIcon = ptr->is_icon; info->fIcon = ptr->is_icon;
info->xHotspot = ptr->hotspot.x; info->xHotspot = frame->hotspot.x;
info->yHotspot = ptr->hotspot.y; info->yHotspot = frame->hotspot.y;
info->hbmColor = copy_bitmap( frame->color ); info->hbmColor = copy_bitmap( frame->color );
info->hbmMask = copy_bitmap( frame->mask ); info->hbmMask = copy_bitmap( frame->mask );
info->wResID = 0; info->wResID = 0;
...@@ -2330,18 +2331,18 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo) ...@@ -2330,18 +2331,18 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
frame->color = color; frame->color = color;
frame->mask = mask; frame->mask = mask;
frame->alpha = create_alpha_bitmap( iconinfo->hbmColor, NULL, NULL ); frame->alpha = create_alpha_bitmap( iconinfo->hbmColor, NULL, NULL );
release_icon_frame( info, frame );
if (info->is_icon) if (info->is_icon)
{ {
info->hotspot.x = width / 2; frame->hotspot.x = width / 2;
info->hotspot.y = height / 2; frame->hotspot.y = height / 2;
} }
else else
{ {
info->hotspot.x = iconinfo->xHotspot; frame->hotspot.x = iconinfo->xHotspot;
info->hotspot.y = iconinfo->yHotspot; frame->hotspot.y = iconinfo->yHotspot;
} }
release_icon_frame( info, frame );
release_user_handle_ptr( info ); release_user_handle_ptr( info );
} }
return hObj; return hObj;
...@@ -3052,8 +3053,8 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx, ...@@ -3052,8 +3053,8 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx,
} }
info.fIcon = icon->is_icon; info.fIcon = icon->is_icon;
info.xHotspot = icon->hotspot.x; info.xHotspot = frame->hotspot.x;
info.yHotspot = icon->hotspot.y; info.yHotspot = frame->hotspot.y;
if (desiredx == frame->width && desiredy == frame->height) if (desiredx == frame->width && desiredy == frame->height)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment