Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore] [SDL2] Fix show, hide, focus and unfocus window/flags states #4610

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/platforms/rcore_desktop_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ void PollInputEvents(void)

// Window events are also polled (Minimized, maximized, close...)

#ifndef PLATFORM_DESKTOP_SDL3
#ifndef PLATFORM_DESKTOP_SDL3
// SDL3 states:
// The SDL_WINDOWEVENT_* events have been moved to top level events,
// and SDL_WINDOWEVENT has been removed.
Expand All @@ -1437,7 +1437,7 @@ void PollInputEvents(void)
{
switch (event.window.event)
{
#endif
#endif
case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_SIZE_CHANGED:
{
Expand Down Expand Up @@ -1466,6 +1466,7 @@ void PollInputEvents(void)
}
#endif
} break;

case SDL_WINDOWEVENT_ENTER:
{
CORE.Input.Mouse.cursorOnScreen = true;
Expand All @@ -1474,6 +1475,7 @@ void PollInputEvents(void)
{
CORE.Input.Mouse.cursorOnScreen = false;
} break;

case SDL_WINDOWEVENT_MINIMIZED:
{
if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED;
Expand All @@ -1496,13 +1498,26 @@ void PollInputEvents(void)
}
#endif
} break;

case SDL_WINDOWEVENT_HIDDEN:
case SDL_WINDOWEVENT_FOCUS_LOST:
{
if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) == 0) CORE.Window.flags |= FLAG_WINDOW_HIDDEN;
} break;
case SDL_WINDOWEVENT_SHOWN:
{
if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN;
} break;

case SDL_WINDOWEVENT_FOCUS_GAINED:
#if defined(PLATFORM_DESKTOP_SDL3)
break;
#else
{
if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0) CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED;
} break;
case SDL_WINDOWEVENT_FOCUS_LOST:
{
if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0) CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED;
} break;

#ifndef PLATFORM_DESKTOP_SDL3
default: break;
}
} break;
Expand Down
Loading