update screen config in case the window gets moved outside teeworlds

This commit is contained in:
oy 2015-10-23 09:12:59 +02:00
parent aacc0b0eda
commit 989b19a342
6 changed files with 20 additions and 1 deletions

View file

@ -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;

View file

@ -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();
};

View file

@ -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;
}
}

View file

@ -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();

View file

@ -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();

View file

@ -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;