ref: fa5c42dc122c8171743b4ac0471571f3e4a49003
parent: e707a058a70c4391bdac7e54bee7be811df79b0e
author: Simon Howard <[email protected]>
date: Sun Jan 8 16:05:15 EST 2017
video: Grab window move events and save display. When we move the game window to a different monitor we want to save that so that next time we start the game on the same monitor. So detect when the window is moved and update the new video_display config variable appropriately. Second part of #734.
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -304,7 +304,7 @@
static void HandleWindowEvent(SDL_WindowEvent *event)
{
- int flags;
+ int i, flags;
switch (event->event)
{
@@ -359,6 +359,19 @@
case SDL_WINDOWEVENT_LEAVE:
case SDL_WINDOWEVENT_FOCUS_LOST:
window_focused = false;
+ break;
+
+ // We want to save the user's preferred monitor to use for running the
+ // game, so that next time we're run we start on the same display. So
+ // every time the window is moved, find which display we're now on and
+ // update the video_display config variable.
+
+ case SDL_WINDOWEVENT_MOVED:
+ i = SDL_GetWindowDisplayIndex(screen);
+ if (i >= 0)
+ {
+ video_display = i;
+ }
break;
default: