Skip to content

Commit

Permalink
Merge pull request scp-fs2open#5920 from MjnMixael/properly_check_win…
Browse files Browse the repository at this point in the history
…dowed

Properly check if we're running in a windowed mode
  • Loading branch information
JohnAFernandez committed Jan 25, 2024
2 parents 248cec7 + 2660799 commit 7d94561
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
40 changes: 27 additions & 13 deletions code/graphics/2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1754,17 +1754,6 @@ bool gr_init(std::unique_ptr<os::GraphicsOperations>&& 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)
{
Expand All @@ -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);
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -2968,3 +2957,28 @@ void gr_get_post_process_effect_names(SCP_vector<SCP_string>& 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;
}
2 changes: 2 additions & 0 deletions code/graphics/2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,8 @@ void gr_set_gamma(float gamma);

void gr_get_post_process_effect_names(SCP_vector<SCP_string> &names);

bool gr_is_viewport_window();

// Include this last to make the 2D rendering function available everywhere
#include "graphics/render.h"

Expand Down
2 changes: 1 addition & 1 deletion code/osapi/dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
Expand Down

0 comments on commit 7d94561

Please sign in to comment.