diff --git a/code/graphics/2d.cpp b/code/graphics/2d.cpp index d19505a9062..89be2871a40 100644 --- a/code/graphics/2d.cpp +++ b/code/graphics/2d.cpp @@ -1754,17 +1754,6 @@ bool gr_init(std::unique_ptr&& graphicsOps, int d_mode, return true; } -void gr_force_windowed() -{ - if ( !Gr_inited ) { - return; - } - - if ( Os_debugger_running ) { - os_sleep(1000); - } -} - int gr_activated = 0; void gr_activate(int active) { @@ -1779,7 +1768,7 @@ void gr_activate(int active) } if (active) { - if (Cmdline_fullscreen_window || Cmdline_window) { + if (gr_is_viewport_window()) { os::getMainViewport()->restore(); } else { os::getMainViewport()->setState(os::ViewportState::Fullscreen); @@ -1789,7 +1778,7 @@ void gr_activate(int active) } if (active) { - if (!Cmdline_fullscreen_window && !Cmdline_window) { + if (!gr_is_viewport_window()) { gr_set_gamma(Gr_gamma); } } @@ -2968,3 +2957,28 @@ void gr_get_post_process_effect_names(SCP_vector& names) names.push_back(eff.name); } } + +bool gr_is_viewport_window() +{ + if (Fred_running) { + return true; + } + + if (Using_in_game_options) { + switch (Gr_configured_window_state) + { + case os::ViewportState::Windowed: + case os::ViewportState::Borderless: + return true; + break; + default: + break; + } + } else { + if (Cmdline_window || Cmdline_fullscreen_window) { + return true; + } + } + + return false; +} diff --git a/code/graphics/2d.h b/code/graphics/2d.h index c4ae5269830..8c8f5680241 100644 --- a/code/graphics/2d.h +++ b/code/graphics/2d.h @@ -1428,6 +1428,8 @@ void gr_set_gamma(float gamma); void gr_get_post_process_effect_names(SCP_vector &names); +bool gr_is_viewport_window(); + // Include this last to make the 2D rendering function available everywhere #include "graphics/render.h" diff --git a/code/osapi/dialogs.cpp b/code/osapi/dialogs.cpp index 7e7ab862de5..bcd54987fc6 100644 --- a/code/osapi/dialogs.cpp +++ b/code/osapi/dialogs.cpp @@ -100,7 +100,7 @@ namespace os //buttons not clickable. So as a hotfix, the dialog has no blocking parent in that case and //is instead rendered as it's own window SDL_Window* getDialogParent() { - return !(Cmdline_fullscreen_window || Cmdline_window) ? NULL : os::getSDLMainWindow(); + return !(gr_is_viewport_window()) ? NULL : os::getSDLMainWindow(); } void AssertMessage(const char * text, const char * filename, int linenum, const char * format, ...)