diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index ee48efd70..53c83e917 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -688,7 +688,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt } // create window - m_pWindow = SDL_CreateWindow(pName, ScreenPos.x, ScreenPos.y, *pWidth, *pHeight, SdlFlags); + m_pWindow = SDL_CreateWindow(pName, ScreenPos.x, ScreenPos.y+10, *pWidth, *pHeight, SdlFlags); if(m_pWindow == NULL) { dbg_msg("gfx", "unable to create window: %s", SDL_GetError()); @@ -798,6 +798,11 @@ bool CGraphicsBackend_SDL_OpenGL::SetWindowScreen(int Index) return false; } +int CGraphicsBackend_SDL_OpenGL::GetWindowScreen() +{ + return SDL_GetWindowDisplayIndex(m_pWindow); +} + int CGraphicsBackend_SDL_OpenGL::WindowActive() { return SDL_GetWindowFlags(m_pWindow)&SDL_WINDOW_INPUT_FOCUS; diff --git a/src/engine/client/backend_sdl.h b/src/engine/client/backend_sdl.h index fdb194f4f..7cf1d43cf 100644 --- a/src/engine/client/backend_sdl.h +++ b/src/engine/client/backend_sdl.h @@ -202,6 +202,7 @@ public: virtual bool Fullscreen(bool State); // on=true/off=false virtual void SetWindowBordered(bool State); // on=true/off=false virtual bool SetWindowScreen(int Index); + virtual int GetWindowScreen(); virtual int WindowActive(); virtual int WindowOpen(); }; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 9fedd8e0c..3e904e2dc 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1862,6 +1862,11 @@ void CClient::Run() { Input()->MouseModeRelative(); m_WindowMustRefocus = 0; + + // update screen in case it got moved + int ActScreen = Graphics()->GetWindowScreen(); + if(ActScreen > 0 && ActScreen != g_Config.m_GfxScreen) + g_Config.m_GfxScreen = ActScreen; } } diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 062ce5921..f922b58a5 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -863,6 +863,11 @@ bool CGraphics_Threaded::SetWindowScreen(int Index) return m_pBackend->SetWindowScreen(Index); } +int CGraphics_Threaded::GetWindowScreen() +{ + return m_pBackend->GetWindowScreen(); +} + int CGraphics_Threaded::WindowActive() { return m_pBackend->WindowActive(); diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 8ed61fc6a..b71ed986b 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -322,6 +322,7 @@ public: virtual bool Fullscreen(bool State) = 0; virtual void SetWindowBordered(bool State) = 0; virtual bool SetWindowScreen(int Index) = 0; + virtual int GetWindowScreen() = 0; virtual int WindowActive() = 0; virtual int WindowOpen() = 0; @@ -442,6 +443,7 @@ public: virtual bool Fullscreen(bool State); virtual void SetWindowBordered(bool State); virtual bool SetWindowScreen(int Index); + virtual int GetWindowScreen(); virtual int WindowActive(); virtual int WindowOpen(); diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 4b1ec5edd..5c593f343 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -202,6 +202,7 @@ public: virtual void SetWindowBordered(bool State) = 0; virtual bool SetWindowScreen(int Index) = 0; virtual bool SetVSync(bool State) = 0; + virtual int GetWindowScreen() = 0; virtual void Minimize() = 0; virtual void Maximize() = 0;