Skip to content

Commit

Permalink
Add remaining functionality to the waiting SDL mainloop
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 29, 2023
1 parent b8baff7 commit 0b15d7d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions SDL/SDLMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,13 +828,11 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta

case SDL_WINDOWEVENT_MOVED:
{
int x = event.window.data1;
int y = event.window.data2;
Uint32 window_flags = SDL_GetWindowFlags(window);
bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN);
if (!fullscreen) {
g_Config.iWindowX = x;
g_Config.iWindowY = y;
g_Config.iWindowX = (int)event.window.data1;
g_Config.iWindowY = (int)event.window.data2;
}
break;
}
Expand Down Expand Up @@ -1469,12 +1467,27 @@ int main(int argc, char *argv[]) {
if (!mainThreadIsRender) {
// We should only be a message pump
while (true) {
inputTracker.TranslateMouseWheel();

SDL_Event event;
while (SDL_PollEvent(&event)) {
ProcessSDLEvent(window, event, &inputTracker);
}
if (g_QuitRequested || g_RestartRequested)
break;

UpdateSDLCursor();

inputTracker.MouseControl();
inputTracker.MouseCaptureControl();


{
std::lock_guard<std::mutex> guard(g_mutexWindow);
if (g_windowState.update) {
UpdateWindowState(window);
}
}
}
} else while (true) {
inputTracker.TranslateMouseWheel();
Expand Down

0 comments on commit 0b15d7d

Please sign in to comment.