user32: Implement LR_MONOCHROME for loading cursors.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-07-10 11:41:22 +02:00
parent 51fea2208e
commit b7e19e4a1a
1 changed files with 20 additions and 15 deletions

View File

@ -559,7 +559,7 @@ static BOOL CURSORICON_GetResIconEntry( LPCVOID dir, DWORD size, int n,
static int CURSORICON_FindBestCursor( LPCVOID dir, DWORD size, fnGetCIEntry get_entry, static int CURSORICON_FindBestCursor( LPCVOID dir, DWORD size, fnGetCIEntry get_entry,
int width, int height, int depth, UINT loadflags ) int width, int height, int depth, UINT loadflags )
{ {
int i, maxwidth, maxheight, cx, cy, bits, bestEntry = -1; int i, maxwidth, maxheight, maxbits, cx, cy, bits, bestEntry = -1;
if (loadflags & LR_DEFAULTSIZE) if (loadflags & LR_DEFAULTSIZE)
{ {
@ -573,22 +573,22 @@ static int CURSORICON_FindBestCursor( LPCVOID dir, DWORD size, fnGetCIEntry get_
return 0; return 0;
} }
/* Double height to account for AND and XOR masks */
height *= 2;
/* First find the largest one smaller than or equal to the requested size*/ /* First find the largest one smaller than or equal to the requested size*/
maxwidth = maxheight = 0; maxwidth = maxheight = maxbits = 0;
for ( i = 0; get_entry( dir, size, i, &cx, &cy, &bits ); i++ ) for ( i = 0; get_entry( dir, size, i, &cx, &cy, &bits ); i++ )
{ {
if ((cx <= width) && (cy <= height) && if (cx > width || cy > height) continue;
(cx > maxwidth) && (cy > maxheight)) if (cx < maxwidth || cy < maxheight) continue;
if (loadflags & LR_MONOCHROME)
{ {
bestEntry = i; if (maxbits && bits >= maxbits) continue;
maxwidth = cx;
maxheight = cy;
} }
else if (bits <= maxbits) continue;
bestEntry = i;
maxwidth = cx;
maxheight = cy;
maxbits = bits;
} }
if (bestEntry != -1) return bestEntry; if (bestEntry != -1) return bestEntry;
@ -597,13 +597,18 @@ static int CURSORICON_FindBestCursor( LPCVOID dir, DWORD size, fnGetCIEntry get_
maxwidth = maxheight = 255; maxwidth = maxheight = 255;
for ( i = 0; get_entry( dir, size, i, &cx, &cy, &bits ); i++ ) for ( i = 0; get_entry( dir, size, i, &cx, &cy, &bits ); i++ )
{ {
if (((cx < maxwidth) && (cy < maxheight)) || (bestEntry == -1)) if (cx > maxwidth || cy > maxheight) continue;
if (loadflags & LR_MONOCHROME)
{ {
bestEntry = i; if (maxbits && bits >= maxbits) continue;
maxwidth = cx;
maxheight = cy;
} }
else if (bits <= maxbits) continue;
bestEntry = i;
maxwidth = cx;
maxheight = cy;
maxbits = bits;
} }
if (bestEntry == -1) bestEntry = 0;
return bestEntry; return bestEntry;
} }