Skip to content

Commit 339c69d

Browse files
Merge pull request livecode#2413 from livecodesebastien/bugfix-14056
[[ Bug 14056 ]] Setting the cursor to none should have an effect - an…
2 parents 970cbf4 + e759cec commit 339c69d

5 files changed

Lines changed: 24 additions & 35 deletions

File tree

docs/notes/bugfix-14056.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Cannot hide cursor on Mac from LiveCode 6.7

engine/src/desktop-dc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,10 @@ void MCScreenDC::platform_boundrect(MCRectangle &rect, Boolean title, Window_mod
316316

317317
////////////////////////////////////////////////////////////////////////////////
318318

319+
// SN-2015-06-16: [[ Bug 14056 ]] PI_NONE should be a valid cursor type
319320
static MCPlatformStandardCursor theme_cursorlist[PI_NCURSORS] =
320321
{
321-
kMCPlatformStandardCursorArrow, kMCPlatformStandardCursorArrow,
322+
kMCPlatformStandardCursorNone, kMCPlatformStandardCursorArrow,
322323
kMCPlatformStandardCursorArrow, kMCPlatformStandardCursorArrow, kMCPlatformStandardCursorArrow, kMCPlatformStandardCursorWatch, kMCPlatformStandardCursorWatch,
323324
kMCPlatformStandardCursorCross, kMCPlatformStandardCursorArrow, kMCPlatformStandardCursorIBeam, kMCPlatformStandardCursorArrow, kMCPlatformStandardCursorArrow,
324325
kMCPlatformStandardCursorArrow, kMCPlatformStandardCursorCross, kMCPlatformStandardCursorWatch, kMCPlatformStandardCursorArrow
@@ -356,10 +357,9 @@ void MCScreenDC::resetcursors()
356357
freecursor(MCcursors[i]);
357358
MCcursors[i] = nil;
358359

360+
// SN-2015-06-16: [[ Bug 14056 ]] PI_NONE should be a valid cursor type
359361
MCImage *im;
360-
if (i == PI_NONE)
361-
MCcursors[i] = nil;
362-
else if ((im = (MCImage *)MCdispatcher->getobjid(CT_IMAGE, i)) != NULL)
362+
if ((im = (MCImage *)MCdispatcher->getobjid(CT_IMAGE, i)) != NULL)
363363
MCcursors[i] = im -> createcursor();
364364
else if (i < PI_BUSY1)
365365
MCPlatformCreateStandardCursor(theme_cursorlist[i], MCcursors[i]);

engine/src/mac-core.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,7 @@ void MCMacPlatformHandleMouseCursorChange(MCPlatformWindowRef p_window)
16771677

16781678
// PM-2014-04-02: [[ Bug 12082 ]] IDE no longer crashes when changing an applied pattern
16791679
if (t_cursor != nil)
1680-
MCPlatformShowCursor(t_cursor);
1680+
MCPlatformSetCursor(t_cursor);
16811681
// SN-2014-10-01: [[ Bug 13516 ]] Hiding a cursor here is not what we want to happen if a cursor hasn't been found
16821682
else
16831683
MCMacPlatformResetCursor();

engine/src/mac-cursor.mm

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
};
4343
};
4444

45-
static MCPlatformCursor *s_hidden_cursor = nil;
46-
static MCPlatformCursor *s_current_cursor = nil;
45+
static bool s_cursor_is_hidden = false;
4746
static NSCursor *s_watch_cursor = nil;
4847

4948
static unsigned char s_watch_cursor_bits[] =
@@ -182,12 +181,23 @@ void MCPlatformReleaseCursor(MCPlatformCursorRef p_cursor)
182181
MCMemoryDelete(p_cursor);
183182
}
184183

185-
void MCPlatformShowCursor(MCPlatformCursorRef p_cursor)
184+
void MCPlatformSetCursor(MCPlatformCursorRef p_cursor)
186185
{
187186
if (p_cursor -> is_standard)
188-
{
187+
{
188+
// By default, we want the cursor to be visible.
189+
if (s_cursor_is_hidden)
190+
{
191+
[NSCursor unhide];
192+
s_cursor_is_hidden = false;
193+
}
189194
switch(p_cursor -> standard)
190195
{
196+
// SN-2015-06-16: [[ Bug 14056 ]] Hidden cursor is part of the cursors
197+
case kMCPlatformStandardCursorNone:
198+
[NSCursor hide];
199+
s_cursor_is_hidden = true;
200+
break;
191201
case kMCPlatformStandardCursorArrow:
192202
[[NSCursor arrowCursor] set];
193203
break;
@@ -216,29 +226,6 @@ void MCPlatformShowCursor(MCPlatformCursorRef p_cursor)
216226
[p_cursor -> custom set];
217227
}
218228

219-
void MCPlatformHideCursor(void)
220-
{
221-
if (s_hidden_cursor == nil)
222-
{
223-
uint32_t t_img_data;
224-
t_img_data = 0;
225-
226-
MCImageBitmap t_image;
227-
t_image . width = 1;
228-
t_image . height = 1;
229-
t_image . stride = 4;
230-
t_image . data = &t_img_data;
231-
232-
MCPoint t_hot_spot;
233-
t_hot_spot . x = 0;
234-
t_hot_spot . y = 0;
235-
MCPlatformCreateCustomCursor(&t_image, t_hot_spot, s_hidden_cursor);
236-
237-
}
238-
239-
MCPlatformShowCursor(s_hidden_cursor);
240-
}
241-
242229
void MCPlatformHideCursorUntilMouseMoves(void)
243230
{
244231
[NSCursor setHiddenUntilMouseMoves: YES];

engine/src/platform.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,12 @@ void MCPlatformGetMenubar(MCPlatformMenuRef menu);
636636

637637
typedef class MCPlatformCursor *MCPlatformCursorRef;
638638

639+
// SN-2015-06-16: [[ Bug 14056 ]] Add hidden cursor as part of the standard ones
639640
enum MCPlatformStandardCursor
640641
{
641642
kMCPlatformStandardCursorUnknown,
642-
643+
644+
kMCPlatformStandardCursorNone,
643645
kMCPlatformStandardCursorArrow,
644646
kMCPlatformStandardCursorWatch,
645647
kMCPlatformStandardCursorCross,
@@ -651,8 +653,7 @@ void MCPlatformCreateCustomCursor(MCImageBitmap *image, MCPoint hot_spot, MCPlat
651653
void MCPlatformRetainCursor(MCPlatformCursorRef cursor);
652654
void MCPlatformReleaseCursor(MCPlatformCursorRef cursor);
653655

654-
void MCPlatformShowCursor(MCPlatformCursorRef cursor);
655-
void MCPlatformHideCursor(void);
656+
void MCPlatformSetCursor(MCPlatformCursorRef cursor);
656657
void MCPlatformHideCursorUntilMouseMoves(void);
657658

658659
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)