| 487 | } |
| 488 | |
| 489 | void WindowManager::waitEvents(double timeout_seconds) { |
| 490 | frame_input_.beginFrame(); |
| 491 | const bool imgui_ready = ImGui::GetCurrentContext() != nullptr; |
| 492 | const SDL_WindowID main_window_id = window_ ? SDL_GetWindowID(window_) : 0; |
| 493 | SDL_Event event; |
| 494 | if (vulkan_context_ && |
| 495 | vulkan_context_->hasPendingSwapchainResize()) { |
| 496 | const double resize_wait = vulkan_context_->secondsUntilPendingSwapchainResizeReady(); |
| 497 | timeout_seconds = std::min(timeout_seconds, |
| 498 | resize_wait > 0.0 |
| 499 | ? std::max(kPendingResizeMinWaitSeconds, resize_wait) |
| 500 | : 0.0); |
| 501 | } |
| 502 | const int timeout_ms = static_cast<int>(timeout_seconds * 1000.0); |
| 503 | if (SDL_WaitEventTimeout(&event, timeout_ms)) { |
| 504 | if (imgui_ready) |
| 505 | ImGui_ImplSDL3_ProcessEvent(&event); |
| 506 | frame_input_.processEvent(event, main_window_id); |
| 507 | processEvent(event); |
| 508 | while (SDL_PollEvent(&event)) { |
| 509 | if (imgui_ready) |
| 510 | ImGui_ImplSDL3_ProcessEvent(&event); |
| 511 | frame_input_.processEvent(event, main_window_id); |
| 512 | processEvent(event); |
| 513 | } |
| 514 | } |
| 515 | finishTitlebarDragIfReleased(); |
| 516 | frame_input_.finalize(window_); |
| 517 | flushPendingTitlebarDoubleClick(); |
| 518 | } |
| 519 | |
| 520 | bool WindowManager::shouldClose() const { |
| 521 | return should_close_; |
no test coverage detected