From f81ca7897a4d4dfa3c9d9ed42681db333a1d1676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Mon, 4 Nov 2019 23:48:09 +0100 Subject: [PATCH] double-buffer cursor mask this prevents clicks being wrongfully ignored during mask recalculation --- BasiliskII/src/SDL/video_rootless.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/BasiliskII/src/SDL/video_rootless.cpp b/BasiliskII/src/SDL/video_rootless.cpp index dd2a7a28..35572474 100644 --- a/BasiliskII/src/SDL/video_rootless.cpp +++ b/BasiliskII/src/SDL/video_rootless.cpp @@ -78,9 +78,11 @@ int16 InstallRootlessProc() { static struct { uint8_t *pixels; + uint8_t *cursorMask; int w,h; } display_mask = { .pixels = NULL, + .cursorMask = NULL, .w = 0, .h = 0 }; @@ -268,7 +270,7 @@ bool cursor_point_opaque() { } int32 my = ReadMacInt16(0x0828); int32 mx = ReadMacInt16(0x082a); - return display_mask.pixels[mx + my * display_mask.w]; + return display_mask.cursorMask[mx + my * display_mask.w]; } static SDL_Rect MaskCursor() { @@ -342,6 +344,7 @@ void update_display_mask(SDL_Window *window, int w, int h) { // new mask free(display_mask.pixels); display_mask.pixels = (uint8_t*)calloc(1, w*h*2); + display_mask.cursorMask = &display_mask.pixels[display_mask.w * display_mask.h]; display_mask.w = w; display_mask.h = h; } @@ -393,6 +396,9 @@ void update_display_mask(SDL_Window *window, int w, int h) { // Menu Bar mask_rects.push_back(MaskMenuBar()); + // Copy over cursor mask + memcpy(display_mask.cursorMask, display_mask.pixels, display_mask.w * display_mask.h); + // Cursor if (cursor_point_opaque()) { SDL_ShowCursor(SDL_DISABLE);