diff --git a/include/Mw/LowLevel/GDI.h b/include/Mw/LowLevel/GDI.h index 9c343b5..9fee9ac 100644 --- a/include/Mw/LowLevel/GDI.h +++ b/include/Mw/LowLevel/GDI.h @@ -38,6 +38,7 @@ struct _MwLLGDIPixmap { HBITMAP hMask2; }; -MWDECL int MwLLGDICallInit(void); +MWDECL int MwLLGDICallInit(void); +MWDECL HCURSOR MwLLGDICreateCursor(MwCursor* image, MwCursor* mask); #endif diff --git a/include/Mw/LowLevel/X11.h b/include/Mw/LowLevel/X11.h index 9bd13fd..ab9c43d 100644 --- a/include/Mw/LowLevel/X11.h +++ b/include/Mw/LowLevel/X11.h @@ -69,6 +69,6 @@ struct _MwLLX11Pixmap { }; MWDECL int MwLLX11CallInit(void); -MWDECL Cursor MwLLX11CreateCursor(); +MWDECL Cursor MwLLX11CreateCursor(Display* display, MwCursor* image, MwCursor* mask); #endif diff --git a/src/backend/gdi.c b/src/backend/gdi.c index 13a3473..6cc557d 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -520,7 +520,7 @@ static void MwLLForceRenderImpl(MwLL handle) { } } -static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { +HCURSOR MwLLGDICreateCursor(MwCursor* image, MwCursor* mask) { HCURSOR cursor; BYTE* dmask = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight); BYTE* dimage = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight); @@ -561,12 +561,18 @@ static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { cursor = CreateCursor(GetModuleHandle(NULL), xs, ys, MwCursorDataHeight, MwCursorDataHeight, dmask, dimage); + free(dimage); + free(dmask); + + return cursor; +} + +static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { + HCURSOR cursor = MwLLGDICreateCursor(image, mask); + if(handle->gdi.cursor != NULL) DestroyCursor(handle->gdi.cursor); if(handle->gdi.icon != NULL) DestroyIcon(handle->gdi.icon); handle->gdi.cursor = cursor; - - free(dimage); - free(dmask); } static void MwLLDetachImpl(MwLL handle, MwPoint* point) {