From 8dc2b45827f482cf5211a2639f886d3f03f86da9 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 8 Sep 2024 22:11:15 +1000 Subject: [PATCH] Fix mouse getting centred when clicking on classic controls menu --- src/Gui.c | 9 +++++---- src/Gui.h | 3 --- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Gui.c b/src/Gui.c index 958d72083..99597b265 100644 --- a/src/Gui.c +++ b/src/Gui.c @@ -224,9 +224,9 @@ static int IndexOfScreen(struct Screen* s) { return -1; } -void Gui_RemoveCore(struct Screen* s) { +static cc_bool Gui_RemoveCore(struct Screen* s) { int i = IndexOfScreen(s); - if (i == -1) return; + if (i == -1) return false; for (; i < Gui.ScreensCount - 1; i++) { @@ -237,6 +237,7 @@ void Gui_RemoveCore(struct Screen* s) { s->VTABLE->ContextLost(s); s->VTABLE->Free(s); + return true; } CC_NOINLINE static void Gui_OnScreensChanged(void) { @@ -245,8 +246,8 @@ CC_NOINLINE static void Gui_OnScreensChanged(void) { } void Gui_Remove(struct Screen* s) { - Gui_RemoveCore(s); - Gui_OnScreensChanged(); + cc_bool removed = Gui_RemoveCore(s); + if (removed) Gui_OnScreensChanged(); } void Gui_Add(struct Screen* s, int priority) { diff --git a/src/Gui.h b/src/Gui.h index c06aad9f9..986601944 100644 --- a/src/Gui.h +++ b/src/Gui.h @@ -263,9 +263,6 @@ void Gui_ShowDefault(void); void Gui_SetTouchUI(cc_bool enabled); #endif -/* (internal) Removes the screen from the screens list. */ -/* NOTE: This does NOT perform the usual 'screens changed' behaviour. */ -void Gui_RemoveCore(struct Screen* s); /* Removes the screen from the screens list. */ CC_API void Gui_Remove(struct Screen* screen); /* Inserts a screen into the screen lists with the given priority. */