|
@@ -226,6 +226,10 @@ HL_PRIM void HL_NAME(win_destroy)(dx_window *win) {
|
|
|
HL_PRIM bool HL_NAME(win_get_next_event)( dx_window *win, dx_event *e ) {
|
|
|
dx_events *buf = (dx_events*)GetWindowLongPtr(win,GWL_USERDATA);
|
|
|
hl_type *save;
|
|
|
+ if( !buf ) {
|
|
|
+ e->type = Quit;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
if( buf->next_event == buf->event_count ) {
|
|
|
buf->next_event = buf->event_count = 0;
|
|
|
return false;
|
|
@@ -264,46 +268,46 @@ HL_PRIM dx_cursor HL_NAME(load_cursor)( int res ) {
|
|
|
}
|
|
|
|
|
|
HL_PRIM dx_cursor HL_NAME(create_cursor)( int width, int height, vbyte *data, int hotX, int hotY ) {
|
|
|
- int pad = sizeof(void*) << 3;
|
|
|
- HICON hicon;
|
|
|
- HDC hdc = GetDC(NULL);
|
|
|
- BITMAPV4HEADER bmh;
|
|
|
- void *pixels;
|
|
|
- void *maskbits;
|
|
|
- int maskbitslen;
|
|
|
- ICONINFO ii;
|
|
|
-
|
|
|
- ZeroMemory(&bmh,sizeof(bmh));
|
|
|
- bmh.bV4Size = sizeof(bmh);
|
|
|
- bmh.bV4Width = width;
|
|
|
- bmh.bV4Height = -height;
|
|
|
- bmh.bV4Planes = 1;
|
|
|
- bmh.bV4BitCount = 32;
|
|
|
- bmh.bV4V4Compression = BI_BITFIELDS;
|
|
|
- bmh.bV4AlphaMask = 0xFF000000;
|
|
|
- bmh.bV4RedMask = 0x00FF0000;
|
|
|
- bmh.bV4GreenMask = 0x0000FF00;
|
|
|
- bmh.bV4BlueMask = 0x000000FF;
|
|
|
-
|
|
|
- maskbitslen = ((width + (-width)%pad) >> 3) * height;
|
|
|
- maskbits = malloc(maskbitslen);
|
|
|
- if( maskbits == NULL )
|
|
|
- return NULL;
|
|
|
- memset(maskbits,0xFF,maskbitslen);
|
|
|
-
|
|
|
- memset(&ii,0,sizeof(ii));
|
|
|
- ii.fIcon = FALSE;
|
|
|
- ii.xHotspot = (DWORD)hotX;
|
|
|
- ii.yHotspot = (DWORD)hotY;
|
|
|
- ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO*)&bmh, DIB_RGB_COLORS, &pixels, NULL, 0);
|
|
|
- ii.hbmMask = CreateBitmap(width, height, 1, 1, maskbits);
|
|
|
- ReleaseDC(NULL, hdc);
|
|
|
- free(maskbits);
|
|
|
-
|
|
|
- memcpy(pixels, data, height * width * 4);
|
|
|
- hicon = CreateIconIndirect(&ii);
|
|
|
-
|
|
|
- DeleteObject(ii.hbmColor);
|
|
|
+ int pad = sizeof(void*) << 3;
|
|
|
+ HICON hicon;
|
|
|
+ HDC hdc = GetDC(NULL);
|
|
|
+ BITMAPV4HEADER bmh;
|
|
|
+ void *pixels;
|
|
|
+ void *maskbits;
|
|
|
+ int maskbitslen;
|
|
|
+ ICONINFO ii;
|
|
|
+
|
|
|
+ ZeroMemory(&bmh,sizeof(bmh));
|
|
|
+ bmh.bV4Size = sizeof(bmh);
|
|
|
+ bmh.bV4Width = width;
|
|
|
+ bmh.bV4Height = -height;
|
|
|
+ bmh.bV4Planes = 1;
|
|
|
+ bmh.bV4BitCount = 32;
|
|
|
+ bmh.bV4V4Compression = BI_BITFIELDS;
|
|
|
+ bmh.bV4AlphaMask = 0xFF000000;
|
|
|
+ bmh.bV4RedMask = 0x00FF0000;
|
|
|
+ bmh.bV4GreenMask = 0x0000FF00;
|
|
|
+ bmh.bV4BlueMask = 0x000000FF;
|
|
|
+
|
|
|
+ maskbitslen = ((width + (-width)%pad) >> 3) * height;
|
|
|
+ maskbits = malloc(maskbitslen);
|
|
|
+ if( maskbits == NULL )
|
|
|
+ return NULL;
|
|
|
+ memset(maskbits,0xFF,maskbitslen);
|
|
|
+
|
|
|
+ memset(&ii,0,sizeof(ii));
|
|
|
+ ii.fIcon = FALSE;
|
|
|
+ ii.xHotspot = (DWORD)hotX;
|
|
|
+ ii.yHotspot = (DWORD)hotY;
|
|
|
+ ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO*)&bmh, DIB_RGB_COLORS, &pixels, NULL, 0);
|
|
|
+ ii.hbmMask = CreateBitmap(width, height, 1, 1, maskbits);
|
|
|
+ ReleaseDC(NULL, hdc);
|
|
|
+ free(maskbits);
|
|
|
+
|
|
|
+ memcpy(pixels, data, height * width * 4);
|
|
|
+ hicon = CreateIconIndirect(&ii);
|
|
|
+
|
|
|
+ DeleteObject(ii.hbmColor);
|
|
|
DeleteObject(ii.hbmMask);
|
|
|
return hicon;
|
|
|
}
|