| 2749 | #endif |
| 2750 | |
| 2751 | std::optional<WindowInfo> MainWindow::acquireRenderWindow(bool recreate_window, bool fullscreen, bool render_to_main, bool surfaceless) |
| 2752 | { |
| 2753 | DevCon.WriteLn("acquireRenderWindow() recreate=%s fullscreen=%s render_to_main=%s surfaceless=%s", recreate_window ? "true" : "false", |
| 2754 | fullscreen ? "true" : "false", render_to_main ? "true" : "false", surfaceless ? "true" : "false"); |
| 2755 | |
| 2756 | const bool is_fullscreen = isRenderingFullscreen(); |
| 2757 | const bool is_rendering_to_main = isRenderingToMain(); |
| 2758 | const bool changing_surfaceless = (!m_display_surface != surfaceless); |
| 2759 | if (m_display_created && !recreate_window && fullscreen == is_fullscreen && is_rendering_to_main == render_to_main && |
| 2760 | !changing_surfaceless) |
| 2761 | { |
| 2762 | return m_display_surface ? m_display_surface->getWindowInfo() : WindowInfo(); |
| 2763 | } |
| 2764 | |
| 2765 | // Skip recreating the surface if we're just transitioning between fullscreen and windowed with render-to-main off. |
| 2766 | if (m_display_created && !recreate_window && !is_rendering_to_main && !render_to_main && !changing_surfaceless) |
| 2767 | { |
| 2768 | DevCon.WriteLn("Toggling to %s without recreating surface", (fullscreen ? "fullscreen" : "windowed")); |
| 2769 | |
| 2770 | // since we don't destroy the display widget, we need to save it here |
| 2771 | if (!is_fullscreen && !is_rendering_to_main) |
| 2772 | saveDisplayWindowGeometryToConfig(); |
| 2773 | |
| 2774 | #ifdef DISPLAY_SURFACE_WINDOW |
| 2775 | auto* displayWindow = m_display_surface; |
| 2776 | #else |
| 2777 | auto* displayWindow = m_display_container; |
| 2778 | #endif |
| 2779 | if (fullscreen) |
| 2780 | displayWindow->showFullScreen(); |
| 2781 | else |
| 2782 | { |
| 2783 | // Needs to exit fullscreen before resizing |
| 2784 | displayWindow->showNormal(); |
| 2785 | if (m_is_temporarily_windowed && g_emu_thread->shouldRenderToMain()) |
| 2786 | displayWindow->setGeometry(geometry()); |
| 2787 | else |
| 2788 | restoreDisplayWindowGeometryFromConfig(); |
| 2789 | } |
| 2790 | |
| 2791 | updateDisplayWidgetCursor(); |
| 2792 | m_display_surface->setFocus(); |
| 2793 | updateWindowState(); |
| 2794 | |
| 2795 | QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
| 2796 | return m_display_surface->getWindowInfo(); |
| 2797 | } |
| 2798 | |
| 2799 | destroyDisplayWidget(surfaceless); |
| 2800 | m_display_created = true; |
| 2801 | |
| 2802 | // if we're going to surfaceless, we're done here |
| 2803 | if (surfaceless) |
| 2804 | return WindowInfo(); |
| 2805 | |
| 2806 | // very low-chance race here, if the user starts the fullscreen UI, and immediately closes the window. |
| 2807 | if (m_is_closing) |
| 2808 | { |
nothing calls this directly
no test coverage detected