mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Improved window grabbing: only when relative mouse mode is active
This commit is contained in:
parent
63a4c804de
commit
ff2a7272fa
|
@ -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
|
||||
|
|
|
@ -190,5 +190,6 @@ public:
|
|||
virtual void Maximize();
|
||||
virtual int WindowActive();
|
||||
virtual int WindowOpen();
|
||||
virtual void SetWindowGrab(bool Grab);
|
||||
virtual void NotifyWindow();
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -145,6 +145,7 @@ public:
|
|||
virtual bool IsIdle() = 0;
|
||||
virtual void WaitForIdle() = 0;
|
||||
|
||||
virtual void SetWindowGrab(bool Grab) = 0;
|
||||
virtual void NotifyWindow() = 0;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue