ref: 6adc6726b84557f247559b8c2f2bdfa4bab4f38d
parent: 64ad608320435aaf69026a5745fbcdea9177700f
author: Jonathan Dowland <jon+github@alcopop.org>
date: Mon Jun 27 18:16:29 EDT 2016
hexen: honour window_position during start-up Refactor code so the window created during the Hexen start-up process can honour the window_position variable.
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -100,7 +100,7 @@
// Window position:
-static char *window_position = "center";
+char *window_position = "center";
// SDL display number on which to run.
@@ -1103,7 +1103,7 @@
*y = bounds.y + SDL_max((bounds.h - h) / 2, 0);
}
-static void GetWindowPosition(int *x, int *y, int w, int h)
+void I_GetWindowPosition(int *x, int *y, int w, int h)
{
// in fullscreen mode, the window "position" still matters, because
// we use it to control which display we run fullscreen on.
@@ -1131,7 +1131,7 @@
else if (sscanf(window_position, "%i,%i", x, y) != 2)
{
// invalid format: revert to default
- fprintf(stderr, "GetWindowPosition: invalid window_position setting\n");
+ fprintf(stderr, "I_GetWindowPosition: invalid window_position setting\n");
*x = *y = SDL_WINDOWPOS_UNDEFINED;
}
}
@@ -1172,7 +1172,7 @@
}
}
- GetWindowPosition(&x, &y, w, h);
+ I_GetWindowPosition(&x, &y, w, h);
// Create window and renderer contexts. We set the window title
// later anyway and leave the window position "undefined". If
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -94,4 +94,7 @@
extern int vga_porch_flash;
extern int force_software_renderer;
+extern char *window_position;
+void I_GetWindowPosition(int *x, int *y, int w, int h);
+
#endif
--- a/src/i_videohr.c
+++ b/src/i_videohr.c
@@ -21,6 +21,7 @@
#include "doomtype.h"
#include "i_timer.h"
+#include "i_video.h"
// Palette fade-in takes two seconds
@@ -35,15 +36,18 @@
boolean I_SetVideoModeHR(void)
{
+ int x, y;
+
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
return false;
}
+ I_GetWindowPosition(&x, &y, HR_SCREENWIDTH, HR_SCREENHEIGHT);
+
// Create screen surface at the native desktop pixel depth (bpp=0),
// as we cannot trust true 8-bit to reliably work nowadays.
- hr_screen = SDL_CreateWindow(window_title,
- SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
+ hr_screen = SDL_CreateWindow(window_title, x, y,
HR_SCREENWIDTH, HR_SCREENHEIGHT,
0);