Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 593d151

Browse files
committed
[[ Bug 16566 ]] Ensure smoothness of resizing on El Capitan
In order to prevent the SPOD in long running loops, the engine 'tickles' the event queue periodically (every 0.25s) to ensure the OS does not think the engine has hung. The tickling of the event queue can cause redraws to occur, which is inappropriate whilst a resizeStack handler is running. To fix this, the event checking is now turned off for the duration of the handling of a resize event meaning that a redraw will only occur at the end of its operation.
1 parent 6727e00 commit 593d151

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

engine/src/mac-core.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,21 +668,21 @@ static void runloop_observer(CFRunLoopObserverRef observer, CFRunLoopActivity ac
668668
MCPlatformBreakWait();
669669
}
670670

671-
static bool s_event_checking_enabled = true;
671+
static uindex_t s_event_checking_enabled = 0;
672672

673673
void MCMacPlatformEnableEventChecking(void)
674674
{
675-
s_event_checking_enabled = true;
675+
s_event_checking_enabled += 1;
676676
}
677677

678678
void MCMacPlatformDisableEventChecking(void)
679679
{
680-
s_event_checking_enabled = false;
680+
s_event_checking_enabled -= 1;
681681
}
682682

683683
bool MCMacPlatformIsEventCheckingEnabled(void)
684684
{
685-
return s_event_checking_enabled;
685+
return s_event_checking_enabled == 0;
686686
}
687687

688688
bool MCPlatformWaitForEvent(double p_duration, bool p_blocking)

engine/src/mac-window.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,8 +1710,15 @@ - (void)setFrameSize: (NSSize)size
17101710
MCRectangle t_content;
17111711
MCMacPlatformMapScreenNSRectToMCRectangle(t_new_cocoa_content, t_content);
17121712

1713+
// Make sure we don't tickle the event queue whilst resizing, otherwise
1714+
// redraws can be done by the OS during the process resulting in tearing
1715+
// as the window resizes.
1716+
MCMacPlatformDisableEventChecking();
1717+
17131718
// And get the super class to deal with it.
17141719
HandleReshape(t_content);
1720+
1721+
MCMacPlatformEnableEventChecking();
17151722
}
17161723

17171724
void MCMacPlatformWindow::ProcessDidResize(void)

0 commit comments

Comments
 (0)