mirror of https://github.com/encounter/SDL.git
SDL_windowsmouse.c: Fix WIN_CreateCursor does not scale with system cursor size preference
This commit is contained in:
parent
f61b10dcf1
commit
301819cd1d
|
@ -96,6 +96,7 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||||
const size_t pad = (sizeof (size_t) * 8); /* 32 or 64, or whatever. */
|
const size_t pad = (sizeof (size_t) * 8); /* 32 or 64, or whatever. */
|
||||||
SDL_Cursor *cursor;
|
SDL_Cursor *cursor;
|
||||||
HICON hicon;
|
HICON hicon;
|
||||||
|
HICON hcursor;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
BITMAPV4HEADER bmh;
|
BITMAPV4HEADER bmh;
|
||||||
LPVOID pixels;
|
LPVOID pixels;
|
||||||
|
@ -150,11 +151,20 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The cursor returned by CreateIconIndirect does not respect system cursor size
|
||||||
|
preference, use CopyImage to duplicate the cursor with desired sizes */
|
||||||
|
hcursor = CopyImage(hicon, IMAGE_CURSOR, 0, 0, LR_COPYDELETEORG | LR_DEFAULTSIZE);
|
||||||
|
if (!hcursor) {
|
||||||
|
DestroyIcon(hicon);
|
||||||
|
WIN_SetError("CopyImage()");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
cursor->driverdata = hicon;
|
cursor->driverdata = hcursor;
|
||||||
} else {
|
} else {
|
||||||
DestroyIcon(hicon);
|
DestroyIcon(hcursor);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue