Add remaining functionality to the waiting SDL mainloop

This commit is contained in:
Henrik Rydgård 2023-09-29 19:35:16 +02:00
parent b8baff712b
commit 0b15d7d153

View file

@ -828,13 +828,11 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
case SDL_WINDOWEVENT_MOVED: case SDL_WINDOWEVENT_MOVED:
{ {
int x = event.window.data1;
int y = event.window.data2;
Uint32 window_flags = SDL_GetWindowFlags(window); Uint32 window_flags = SDL_GetWindowFlags(window);
bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN); bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN);
if (!fullscreen) { if (!fullscreen) {
g_Config.iWindowX = x; g_Config.iWindowX = (int)event.window.data1;
g_Config.iWindowY = y; g_Config.iWindowY = (int)event.window.data2;
} }
break; break;
} }
@ -1469,12 +1467,27 @@ int main(int argc, char *argv[]) {
if (!mainThreadIsRender) { if (!mainThreadIsRender) {
// We should only be a message pump // We should only be a message pump
while (true) { while (true) {
inputTracker.TranslateMouseWheel();
SDL_Event event; SDL_Event event;
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
ProcessSDLEvent(window, event, &inputTracker); ProcessSDLEvent(window, event, &inputTracker);
} }
if (g_QuitRequested || g_RestartRequested) if (g_QuitRequested || g_RestartRequested)
break; break;
UpdateSDLCursor();
inputTracker.MouseControl();
inputTracker.MouseCaptureControl();
{
std::lock_guard<std::mutex> guard(g_mutexWindow);
if (g_windowState.update) {
UpdateWindowState(window);
}
}
} }
} else while (true) { } else while (true) {
inputTracker.TranslateMouseWheel(); inputTracker.TranslateMouseWheel();