winex11: Load a monochrome cursor instead of converting a color one when possible.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-07-10 11:42:08 +02:00
parent b7e19e4a1a
commit 2e0a1cfd83
1 changed files with 38 additions and 0 deletions

View File

@ -1159,6 +1159,43 @@ done:
return cursor;
}
/***********************************************************************
* create_xlib_load_mono_cursor
*
* Create a monochrome X cursor from a color Windows one by trying to load the monochrome resource.
*/
static Cursor create_xlib_load_mono_cursor( HDC hdc, HANDLE handle, int width, int height )
{
Cursor cursor = None;
HANDLE mono;
ICONINFOEXW info;
BITMAP bm;
if (!(mono = CopyImage( handle, IMAGE_CURSOR, width, height, LR_MONOCHROME | LR_COPYFROMRESOURCE )))
return None;
info.cbSize = sizeof(info);
if (GetIconInfoExW( mono, &info ))
{
if (!info.hbmColor)
{
GetObjectW( info.hbmMask, sizeof(bm), &bm );
bm.bmHeight = max( 1, bm.bmHeight / 2 );
/* make sure hotspot is valid */
if (info.xHotspot >= bm.bmWidth || info.yHotspot >= bm.bmHeight)
{
info.xHotspot = bm.bmWidth / 2;
info.yHotspot = bm.bmHeight / 2;
}
cursor = create_xlib_monochrome_cursor( hdc, &info, bm.bmWidth, bm.bmHeight );
}
else DeleteObject( info.hbmColor );
DeleteObject( info.hbmMask );
}
DestroyCursor( mono );
return cursor;
}
/***********************************************************************
* create_xlib_color_cursor
*
@ -1334,6 +1371,7 @@ static Cursor create_cursor( HANDLE handle )
if (pXcursorImagesLoadCursor)
cursor = create_xcursor_cursor( hdc, &info, handle, bm.bmWidth, bm.bmHeight );
#endif
if (!cursor) cursor = create_xlib_load_mono_cursor( hdc, handle, bm.bmWidth, bm.bmHeight );
if (!cursor) cursor = create_xlib_color_cursor( hdc, &info, bm.bmWidth, bm.bmHeight );
DeleteObject( info.hbmColor );
}