ref: 7bb82228db4c9f13f706cde47472619d7044ef85
parent: f27269f7a8a9230c59283cb824ab130226a2101c
author: Fabian Greffrath <fabian@greffrath.com>
date: Tue Mar 28 09:00:38 EDT 2017
video: move video_display check to I_GetWindowPosition() This way make sure that the video_display variable is checked (1) unconditionally and (2) early on in the code before other parts of the video initialization path use it. Formerly, the check was in CenterWindow() which was only called from I_GetWindowPosition() if fullscreen was enabled or the window was centered. Fixes #898 thanks @jmtd
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1082,17 +1082,6 @@
{
SDL_Rect bounds;
- // Check that video_display corresponds to a display that really exists,
- // and if it doesn't, reset it.
- if (video_display < 0 || video_display >= SDL_GetNumVideoDisplays())
- {
- fprintf(stderr,
- "CenterWindow: We were configured to run on display #%d, but "
- "it no longer exists (max %d). Moving to display 0.\n",
- video_display, SDL_GetNumVideoDisplays() - 1);
- video_display = 0;
- }
-
if (SDL_GetDisplayBounds(video_display, &bounds) < 0)
{
fprintf(stderr, "CenterWindow: Failed to read display bounds "
@@ -1106,6 +1095,17 @@
void I_GetWindowPosition(int *x, int *y, int w, int h)
{
+ // Check that video_display corresponds to a display that really exists,
+ // and if it doesn't, reset it.
+ if (video_display < 0 || video_display >= SDL_GetNumVideoDisplays())
+ {
+ fprintf(stderr,
+ "I_GetWindowPosition: We were configured to run on display #%d, "
+ "but it no longer exists (max %d). Moving to display 0.\n",
+ video_display, SDL_GetNumVideoDisplays() - 1);
+ video_display = 0;
+ }
+
// in fullscreen mode, the window "position" still matters, because
// we use it to control which display we run fullscreen on.