Improved window grabbing: only when relative mouse mode is active

This commit is contained in:
def 2015-08-25 01:01:38 +02:00
parent 63a4c804de
commit ff2a7272fa
6 changed files with 16 additions and 2 deletions

View file

@ -620,8 +620,6 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int Screen, int *pWidth
SDL_GetWindowSize(m_pWindow, pWidth, pHeight);
SDL_SetWindowGrab(m_pWindow, SDL_TRUE);
m_GLContext = SDL_GL_CreateContext(m_pWindow);
if(m_GLContext == NULL)
@ -700,6 +698,11 @@ int CGraphicsBackend_SDL_OpenGL::WindowOpen()
return SDL_GetWindowFlags(m_pWindow)&SDL_WINDOW_SHOWN;
}
void CGraphicsBackend_SDL_OpenGL::SetWindowGrab(bool Grab)
{
SDL_SetWindowGrab(m_pWindow, Grab ? SDL_TRUE : SDL_FALSE);
}
void CGraphicsBackend_SDL_OpenGL::NotifyWindow()
{
//// get window handle

View file

@ -190,5 +190,6 @@ public:
virtual void Maximize();
virtual int WindowActive();
virtual int WindowOpen();
virtual void SetWindowGrab(bool Grab);
virtual void NotifyWindow();
};

View file

@ -905,6 +905,11 @@ int CGraphics_Threaded::WindowOpen()
return m_pBackend->WindowOpen();
}
void CGraphics_Threaded::SetWindowGrab(bool Grab)
{
return m_pBackend->SetWindowGrab(Grab);
}
void CGraphics_Threaded::NotifyWindow()
{
return m_pBackend->NotifyWindow();

View file

@ -313,6 +313,7 @@ public:
virtual void Maximize() = 0;
virtual int WindowActive() = 0;
virtual int WindowOpen() = 0;
virtual void SetWindowGrab(bool Grab) = 0;
virtual void NotifyWindow() = 0;
virtual void RunBuffer(CCommandBuffer *pBuffer) = 0;
@ -430,6 +431,7 @@ public:
virtual int WindowActive();
virtual int WindowOpen();
virtual void SetWindowGrab(bool Grab);
virtual void NotifyWindow();
virtual int Init();

View file

@ -76,12 +76,14 @@ void CInput::MouseModeAbsolute()
{
m_InputGrabbed = 0;
SDL_SetRelativeMouseMode(SDL_FALSE);
Graphics()->SetWindowGrab(SDL_FALSE);
}
void CInput::MouseModeRelative()
{
m_InputGrabbed = 1;
SDL_SetRelativeMouseMode(SDL_TRUE);
Graphics()->SetWindowGrab(true);
}
int CInput::MouseDoubleClick()

View file

@ -145,6 +145,7 @@ public:
virtual bool IsIdle() = 0;
virtual void WaitForIdle() = 0;
virtual void SetWindowGrab(bool Grab) = 0;
virtual void NotifyWindow() = 0;
};