forked from Mirrors/wine-wine
user32: Call the cursor/icon handle allocation functions through the WoW handlers table.
parent
0280f058f9
commit
b36ca48608
|
@ -99,6 +99,10 @@ struct wow_handlers16
|
||||||
HWND (*create_window)(CREATESTRUCTW*,LPCWSTR,HINSTANCE,UINT);
|
HWND (*create_window)(CREATESTRUCTW*,LPCWSTR,HINSTANCE,UINT);
|
||||||
LRESULT (*call_window_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*);
|
LRESULT (*call_window_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*);
|
||||||
LRESULT (*call_dialog_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*);
|
LRESULT (*call_dialog_proc)(HWND,UINT,WPARAM,LPARAM,LRESULT*,void*);
|
||||||
|
HICON (*alloc_icon_handle)(UINT);
|
||||||
|
struct tagCURSORICONINFO *(*get_icon_ptr)(HICON);
|
||||||
|
void (*release_icon_ptr)(HICON,struct tagCURSORICONINFO*);
|
||||||
|
int (*free_icon_handle)(HICON);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wow_handlers32
|
struct wow_handlers32
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include "wine/winuser16.h"
|
#include "wine/winuser16.h"
|
||||||
#include "wine/exception.h"
|
#include "wine/exception.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
#include "controls.h"
|
||||||
#include "user_private.h"
|
#include "user_private.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(cursor);
|
WINE_DEFAULT_DEBUG_CHANNEL(cursor);
|
||||||
|
@ -90,28 +91,6 @@ static HDC screen_dc;
|
||||||
|
|
||||||
static const WCHAR DISPLAYW[] = {'D','I','S','P','L','A','Y',0};
|
static const WCHAR DISPLAYW[] = {'D','I','S','P','L','A','Y',0};
|
||||||
|
|
||||||
static HICON alloc_icon_handle( unsigned int size )
|
|
||||||
{
|
|
||||||
HGLOBAL16 handle = GlobalAlloc16( GMEM_MOVEABLE, size );
|
|
||||||
FarSetOwner16( handle, 0 );
|
|
||||||
return HICON_32( handle );
|
|
||||||
}
|
|
||||||
|
|
||||||
static CURSORICONINFO *get_icon_ptr( HICON handle )
|
|
||||||
{
|
|
||||||
return GlobalLock16( HICON_16(handle) );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void release_icon_ptr( HICON handle, CURSORICONINFO *ptr )
|
|
||||||
{
|
|
||||||
GlobalUnlock16( HICON_16(handle) );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int free_icon_handle( HICON handle )
|
|
||||||
{
|
|
||||||
return GlobalFree16( HICON_16(handle) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* ICONCACHE for cursors/icons loaded with LR_SHARED.
|
* ICONCACHE for cursors/icons loaded with LR_SHARED.
|
||||||
|
@ -472,10 +451,10 @@ BOOL get_icon_size( HICON handle, SIZE *size )
|
||||||
{
|
{
|
||||||
CURSORICONINFO *info;
|
CURSORICONINFO *info;
|
||||||
|
|
||||||
if (!(info = get_icon_ptr( handle ))) return FALSE;
|
if (!(info = wow_handlers.get_icon_ptr( handle ))) return FALSE;
|
||||||
size->cx = info->nWidth;
|
size->cx = info->nWidth;
|
||||||
size->cy = info->nHeight;
|
size->cy = info->nHeight;
|
||||||
release_icon_ptr( handle, info );
|
wow_handlers.release_icon_ptr( handle, info );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -852,10 +831,10 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
|
||||||
sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes;
|
sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes;
|
||||||
sizeAnd = bmpAnd.bmHeight * bmpAnd.bmWidthBytes;
|
sizeAnd = bmpAnd.bmHeight * bmpAnd.bmWidthBytes;
|
||||||
|
|
||||||
hObj = alloc_icon_handle( sizeof(CURSORICONINFO) + sizeXor + sizeAnd );
|
hObj = wow_handlers.alloc_icon_handle( sizeof(CURSORICONINFO) + sizeXor + sizeAnd );
|
||||||
if (hObj)
|
if (hObj)
|
||||||
{
|
{
|
||||||
CURSORICONINFO *info = get_icon_ptr( hObj );
|
CURSORICONINFO *info = wow_handlers.get_icon_ptr( hObj );
|
||||||
|
|
||||||
info->ptHotSpot.x = hotspot.x;
|
info->ptHotSpot.x = hotspot.x;
|
||||||
info->ptHotSpot.y = hotspot.y;
|
info->ptHotSpot.y = hotspot.y;
|
||||||
|
@ -869,7 +848,7 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
|
||||||
|
|
||||||
GetBitmapBits( hAndBits, sizeAnd, info + 1 );
|
GetBitmapBits( hAndBits, sizeAnd, info + 1 );
|
||||||
GetBitmapBits( hXorBits, sizeXor, (char *)(info + 1) + sizeAnd );
|
GetBitmapBits( hXorBits, sizeXor, (char *)(info + 1) + sizeAnd );
|
||||||
release_icon_ptr( hObj, info );
|
wow_handlers.release_icon_ptr( hObj, info );
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteObject( hAndBits );
|
DeleteObject( hAndBits );
|
||||||
|
@ -1475,13 +1454,13 @@ HICON WINAPI CopyIcon( HICON hIcon )
|
||||||
HICON16 hOld = HICON_16(hIcon);
|
HICON16 hOld = HICON_16(hIcon);
|
||||||
HICON hNew;
|
HICON hNew;
|
||||||
|
|
||||||
if (!(ptrOld = get_icon_ptr( hIcon ))) return 0;
|
if (!(ptrOld = wow_handlers.get_icon_ptr( hIcon ))) return 0;
|
||||||
size = GlobalSize16( hOld );
|
size = GlobalSize16( hOld );
|
||||||
hNew = alloc_icon_handle( size );
|
hNew = wow_handlers.alloc_icon_handle( size );
|
||||||
ptrNew = get_icon_ptr( hNew );
|
ptrNew = wow_handlers.get_icon_ptr( hNew );
|
||||||
memcpy( ptrNew, ptrOld, size );
|
memcpy( ptrNew, ptrOld, size );
|
||||||
release_icon_ptr( hIcon, ptrOld );
|
wow_handlers.release_icon_ptr( hIcon, ptrOld );
|
||||||
release_icon_ptr( hNew, ptrNew );
|
wow_handlers.release_icon_ptr( hNew, ptrNew );
|
||||||
return hNew;
|
return hNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1494,7 +1473,7 @@ BOOL WINAPI DestroyIcon( HICON hIcon )
|
||||||
TRACE_(icon)("%p\n", hIcon );
|
TRACE_(icon)("%p\n", hIcon );
|
||||||
|
|
||||||
if (CURSORICON_DelSharedIcon( hIcon ) == -1)
|
if (CURSORICON_DelSharedIcon( hIcon ) == -1)
|
||||||
free_icon_handle( hIcon );
|
wow_handlers.free_icon_handle( hIcon );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1594,10 +1573,10 @@ BOOL WINAPI DrawIcon( HDC hdc, INT x, INT y, HICON hIcon )
|
||||||
|
|
||||||
TRACE("%p, (%d,%d), %p\n", hdc, x, y, hIcon);
|
TRACE("%p, (%d,%d), %p\n", hdc, x, y, hIcon);
|
||||||
|
|
||||||
if (!(ptr = get_icon_ptr( hIcon ))) return FALSE;
|
if (!(ptr = wow_handlers.get_icon_ptr( hIcon ))) return FALSE;
|
||||||
if (!(hMemDC = CreateCompatibleDC( hdc )))
|
if (!(hMemDC = CreateCompatibleDC( hdc )))
|
||||||
{
|
{
|
||||||
release_icon_ptr( hIcon, ptr );
|
wow_handlers.release_icon_ptr( hIcon, ptr );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1663,7 +1642,7 @@ BOOL WINAPI DrawIcon( HDC hdc, INT x, INT y, HICON hIcon )
|
||||||
DeleteDC( hMemDC );
|
DeleteDC( hMemDC );
|
||||||
if (hXorBits) DeleteObject( hXorBits );
|
if (hXorBits) DeleteObject( hXorBits );
|
||||||
if (hAndBits) DeleteObject( hAndBits );
|
if (hAndBits) DeleteObject( hAndBits );
|
||||||
release_icon_ptr( hIcon, ptr );
|
wow_handlers.release_icon_ptr( hIcon, ptr );
|
||||||
SetTextColor( hdc, oldFg );
|
SetTextColor( hdc, oldFg );
|
||||||
SetBkColor( hdc, oldBg );
|
SetBkColor( hdc, oldBg );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1689,9 +1668,9 @@ HCURSOR WINAPI DECLSPEC_HOTPATCH SetCursor( HCURSOR hCursor /* [in] Handle of cu
|
||||||
/* Change the cursor shape only if it is visible */
|
/* Change the cursor shape only if it is visible */
|
||||||
if (thread_info->cursor_count >= 0)
|
if (thread_info->cursor_count >= 0)
|
||||||
{
|
{
|
||||||
CURSORICONINFO *info = get_icon_ptr( hCursor );
|
CURSORICONINFO *info = wow_handlers.get_icon_ptr( hCursor );
|
||||||
/* release before calling driver (FIXME) */
|
/* release before calling driver (FIXME) */
|
||||||
if (info) release_icon_ptr( hCursor, info );
|
if (info) wow_handlers.release_icon_ptr( hCursor, info );
|
||||||
USER_Driver->pSetCursor( info );
|
USER_Driver->pSetCursor( info );
|
||||||
}
|
}
|
||||||
return hOldCursor;
|
return hOldCursor;
|
||||||
|
@ -1710,9 +1689,9 @@ INT WINAPI DECLSPEC_HOTPATCH ShowCursor( BOOL bShow )
|
||||||
{
|
{
|
||||||
if (++thread_info->cursor_count == 0) /* Show it */
|
if (++thread_info->cursor_count == 0) /* Show it */
|
||||||
{
|
{
|
||||||
CURSORICONINFO *info = get_icon_ptr( thread_info->cursor );
|
CURSORICONINFO *info = wow_handlers.get_icon_ptr( thread_info->cursor );
|
||||||
/* release before calling driver (FIXME) */
|
/* release before calling driver (FIXME) */
|
||||||
if (info) release_icon_ptr( thread_info->cursor, info );
|
if (info) wow_handlers.release_icon_ptr( thread_info->cursor, info );
|
||||||
USER_Driver->pSetCursor( info );
|
USER_Driver->pSetCursor( info );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1895,7 +1874,7 @@ BOOL WINAPI GetIconInfo(HICON hIcon, PICONINFO iconinfo)
|
||||||
CURSORICONINFO *ciconinfo;
|
CURSORICONINFO *ciconinfo;
|
||||||
INT height;
|
INT height;
|
||||||
|
|
||||||
if (!(ciconinfo = get_icon_ptr( hIcon ))) return FALSE;
|
if (!(ciconinfo = wow_handlers.get_icon_ptr( hIcon ))) return FALSE;
|
||||||
|
|
||||||
TRACE("%p => %dx%d, %d bpp\n", hIcon,
|
TRACE("%p => %dx%d, %d bpp\n", hIcon,
|
||||||
ciconinfo->nWidth, ciconinfo->nHeight, ciconinfo->bBitsPerPixel);
|
ciconinfo->nWidth, ciconinfo->nHeight, ciconinfo->bBitsPerPixel);
|
||||||
|
@ -1932,7 +1911,7 @@ BOOL WINAPI GetIconInfo(HICON hIcon, PICONINFO iconinfo)
|
||||||
|
|
||||||
iconinfo->hbmMask = CreateBitmap ( ciconinfo->nWidth, height,
|
iconinfo->hbmMask = CreateBitmap ( ciconinfo->nWidth, height,
|
||||||
1, 1, ciconinfo + 1);
|
1, 1, ciconinfo + 1);
|
||||||
release_icon_ptr( hIcon, ciconinfo );
|
wow_handlers.release_icon_ptr( hIcon, ciconinfo );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1973,10 +1952,10 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
|
||||||
|
|
||||||
sizeAnd = bmpAnd.bmHeight * get_bitmap_width_bytes(bmpAnd.bmWidth, 1);
|
sizeAnd = bmpAnd.bmHeight * get_bitmap_width_bytes(bmpAnd.bmWidth, 1);
|
||||||
|
|
||||||
hObj = alloc_icon_handle( sizeof(CURSORICONINFO) + sizeXor + sizeAnd );
|
hObj = wow_handlers.alloc_icon_handle( sizeof(CURSORICONINFO) + sizeXor + sizeAnd );
|
||||||
if (hObj)
|
if (hObj)
|
||||||
{
|
{
|
||||||
CURSORICONINFO *info = get_icon_ptr( hObj );
|
CURSORICONINFO *info = wow_handlers.get_icon_ptr( hObj );
|
||||||
|
|
||||||
/* If we are creating an icon, the hotspot is unused */
|
/* If we are creating an icon, the hotspot is unused */
|
||||||
if (iconinfo->fIcon)
|
if (iconinfo->fIcon)
|
||||||
|
@ -2085,7 +2064,7 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
|
||||||
dst_bits, &bminfo, DIB_RGB_COLORS );
|
dst_bits, &bminfo, DIB_RGB_COLORS );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
release_icon_ptr( hObj, info );
|
wow_handlers.release_icon_ptr( hObj, info );
|
||||||
}
|
}
|
||||||
return hObj;
|
return hObj;
|
||||||
}
|
}
|
||||||
|
@ -2126,10 +2105,10 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
|
||||||
TRACE_(icon)("(hdc=%p,pos=%d.%d,hicon=%p,extend=%d.%d,istep=%d,br=%p,flags=0x%08x)\n",
|
TRACE_(icon)("(hdc=%p,pos=%d.%d,hicon=%p,extend=%d.%d,istep=%d,br=%p,flags=0x%08x)\n",
|
||||||
hdc,x0,y0,hIcon,cxWidth,cyWidth,istep,hbr,flags );
|
hdc,x0,y0,hIcon,cxWidth,cyWidth,istep,hbr,flags );
|
||||||
|
|
||||||
if (!(ptr = get_icon_ptr( hIcon ))) return FALSE;
|
if (!(ptr = wow_handlers.get_icon_ptr( hIcon ))) return FALSE;
|
||||||
if (!(hMemDC = CreateCompatibleDC( hdc )))
|
if (!(hMemDC = CreateCompatibleDC( hdc )))
|
||||||
{
|
{
|
||||||
release_icon_ptr( hIcon, ptr );
|
wow_handlers.release_icon_ptr( hIcon, ptr );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2277,7 +2256,7 @@ BOOL WINAPI DrawIconEx( HDC hdc, INT x0, INT y0, HICON hIcon,
|
||||||
if (hMemDC) DeleteDC( hMemDC );
|
if (hMemDC) DeleteDC( hMemDC );
|
||||||
if (hDC_off) DeleteDC(hDC_off);
|
if (hDC_off) DeleteDC(hDC_off);
|
||||||
if (hB_off) DeleteObject(hB_off);
|
if (hB_off) DeleteObject(hB_off);
|
||||||
release_icon_ptr( hIcon, ptr );
|
wow_handlers.release_icon_ptr( hIcon, ptr );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2614,6 +2614,33 @@ HWND create_window16( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE instance,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* cursor/icon handles
|
||||||
|
*/
|
||||||
|
|
||||||
|
static HICON alloc_icon_handle( unsigned int size )
|
||||||
|
{
|
||||||
|
HGLOBAL16 handle = GlobalAlloc16( GMEM_MOVEABLE, size );
|
||||||
|
FarSetOwner16( handle, 0 );
|
||||||
|
return HICON_32( handle );
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct tagCURSORICONINFO *get_icon_ptr( HICON handle )
|
||||||
|
{
|
||||||
|
return GlobalLock16( HICON_16(handle) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void release_icon_ptr( HICON handle, struct tagCURSORICONINFO *ptr )
|
||||||
|
{
|
||||||
|
GlobalUnlock16( HICON_16(handle) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int free_icon_handle( HICON handle )
|
||||||
|
{
|
||||||
|
return GlobalFree16( HICON_16(handle) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void register_wow_handlers(void)
|
void register_wow_handlers(void)
|
||||||
{
|
{
|
||||||
static const struct wow_handlers16 handlers16 =
|
static const struct wow_handlers16 handlers16 =
|
||||||
|
@ -2627,7 +2654,11 @@ void register_wow_handlers(void)
|
||||||
static_proc16,
|
static_proc16,
|
||||||
create_window16,
|
create_window16,
|
||||||
call_window_proc_Ato16,
|
call_window_proc_Ato16,
|
||||||
call_dialog_proc_Ato16
|
call_dialog_proc_Ato16,
|
||||||
|
alloc_icon_handle,
|
||||||
|
get_icon_ptr,
|
||||||
|
release_icon_ptr,
|
||||||
|
free_icon_handle
|
||||||
};
|
};
|
||||||
|
|
||||||
UserRegisterWowHandlers( &handlers16, &wow_handlers32 );
|
UserRegisterWowHandlers( &handlers16, &wow_handlers32 );
|
||||||
|
|
|
@ -1121,6 +1121,28 @@ static LRESULT WINAPI StaticWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
||||||
return wow_handlers.static_proc( hwnd, msg, wParam, lParam, TRUE );
|
return wow_handlers.static_proc( hwnd, msg, wParam, lParam, TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HICON alloc_icon_handle( unsigned int size )
|
||||||
|
{
|
||||||
|
HGLOBAL16 handle = GlobalAlloc16( GMEM_MOVEABLE, size );
|
||||||
|
FarSetOwner16( handle, 0 );
|
||||||
|
return HICON_32( handle );
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct tagCURSORICONINFO *get_icon_ptr( HICON handle )
|
||||||
|
{
|
||||||
|
return GlobalLock16( HICON_16(handle) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void release_icon_ptr( HICON handle, struct tagCURSORICONINFO *ptr )
|
||||||
|
{
|
||||||
|
GlobalUnlock16( HICON_16(handle) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int free_icon_handle( HICON handle )
|
||||||
|
{
|
||||||
|
return GlobalFree16( HICON_16(handle) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* UserRegisterWowHandlers (USER32.@)
|
* UserRegisterWowHandlers (USER32.@)
|
||||||
|
@ -1154,5 +1176,9 @@ struct wow_handlers16 wow_handlers =
|
||||||
StaticWndProc_common,
|
StaticWndProc_common,
|
||||||
WIN_CreateWindowEx,
|
WIN_CreateWindowEx,
|
||||||
NULL, /* call_window_proc */
|
NULL, /* call_window_proc */
|
||||||
NULL /* call_dialog_proc */
|
NULL, /* call_dialog_proc */
|
||||||
|
alloc_icon_handle,
|
||||||
|
get_icon_ptr,
|
||||||
|
release_icon_ptr,
|
||||||
|
free_icon_handle
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue