From c1b2811bbf3898c02de5f0b4b9be70f6a3771b2a Mon Sep 17 00:00:00 2001 From: Mark Kim Date: Sat, 3 Feb 2024 21:45:14 -0500 Subject: [PATCH] Make screen refresh more snappy on macOS --- docs/CHANGES.txt | 6 ++++++ src/macos.h | 11 +++++++++++ src/tuxpaint.c | 12 ++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index c20b9c75b..62a0a5e65 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -6,6 +6,12 @@ Copyright (c) 2002-2024 Various contributors (see below, and AUTHORS.txt) https://tuxpaint.org/ +2024.February.3 (0.9.33) + * Other Improvements: + ------------------- + * Make screen refresh more snappy on macOS. + Mark Kim + 2024.January.29 (0.9.32) * Improvements to Magic tools: ---------------------------- diff --git a/src/macos.h b/src/macos.h index 575fe634a..a30471187 100644 --- a/src/macos.h +++ b/src/macos.h @@ -37,4 +37,15 @@ const char *apple_picturesPath(void); int apple_trash(const char *path); +/* +* It's unclear why we need this on macOS, but the SDL2 library on the Mac +* appears to require an extra flip during a delay without which the flip does +* occur but not until the next click or after much time passes. +*/ +#define SDL_Delay(n) do { \ + SDL_Flip(screen); \ + SDL_Delay(n); \ +} while(0) + + #endif /* __MACOS_H__ */ diff --git a/src/tuxpaint.c b/src/tuxpaint.c index f5d8f00d0..1b1e142a2 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -403,18 +403,18 @@ int iswprint(wchar_t wc) #endif /* WIN32 */ -#if defined(__MACOS__) -#include "macos.h" -#elif defined(__IOS__) -#include "ios.h" -#endif - #include #include #include "SDL2/SDL.h" #include "SDL2/SDL_thread.h" +#if defined(__MACOS__) +#include "macos.h" +#elif defined(__IOS__) +#include "ios.h" +#endif + #if !defined(_SDL_H) && !defined(SDL_h_) #error "---------------------------------------------------" #error "If you installed SDL from a package, be sure to get"