Commit b7e19e4a authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Implement LR_MONOCHROME for loading cursors.

parent 51fea220
...@@ -559,7 +559,7 @@ static BOOL CURSORICON_GetResIconEntry( LPCVOID dir, DWORD size, int n, ...@@ -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_ ...@@ -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_ ...@@ -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;
} }
......
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