forked from 0ad/0ad
Handle SDL_ACTIVEEVENT which notifies us of mouse focus change. If mouse focus is lost don't render cursor, reverting back to OS style. When focus is regained, render cursor again. Fixes #626
This was SVN commit r8789.
This commit is contained in:
parent
819bacd538
commit
95da3789cd
@ -90,6 +90,18 @@ static InReaction MainInputHandler(const SDL_Event_* ev)
|
||||
{
|
||||
switch(ev->ev.type)
|
||||
{
|
||||
case SDL_ACTIVEEVENT:
|
||||
if (ev->ev.active.state == SDL_APPMOUSEFOCUS)
|
||||
{
|
||||
// Tell renderer not to render cursor if mouse focus is lost
|
||||
// this restores system cursor, until/if focus is regained
|
||||
if (!ev->ev.active.gain)
|
||||
RenderCursor(false);
|
||||
else
|
||||
RenderCursor(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
kill_mainloop();
|
||||
break;
|
||||
|
@ -114,6 +114,7 @@ ERROR_TYPE(System, RequiredExtensionsMissing);
|
||||
|
||||
bool g_DoRenderGui = true;
|
||||
bool g_DoRenderLogger = true;
|
||||
bool g_DoRenderCursor = true;
|
||||
|
||||
static const int SANE_TEX_QUALITY_DEFAULT = 5; // keep in sync with code
|
||||
|
||||
@ -273,15 +274,18 @@ void Render()
|
||||
ogl_WarnIfError();
|
||||
|
||||
// Draw the cursor (or set the Windows cursor, on Windows)
|
||||
CStrW cursorName = g_CursorName;
|
||||
if (cursorName.empty())
|
||||
if (g_DoRenderCursor)
|
||||
{
|
||||
cursor_draw(g_VFS, NULL, g_mouse_x, g_yres-g_mouse_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cursor_draw(g_VFS, cursorName.c_str(), g_mouse_x, g_yres-g_mouse_y) < 0)
|
||||
LOGWARNING(L"Failed to draw cursor '%ls'", cursorName.c_str());
|
||||
CStrW cursorName = g_CursorName;
|
||||
if (cursorName.empty())
|
||||
{
|
||||
cursor_draw(g_VFS, NULL, g_mouse_x, g_yres-g_mouse_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cursor_draw(g_VFS, cursorName.c_str(), g_mouse_x, g_yres-g_mouse_y) < 0)
|
||||
LOGWARNING(L"Failed to draw cursor '%ls'", cursorName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// restore
|
||||
@ -884,6 +888,11 @@ void RenderLogger(bool RenderingState)
|
||||
g_DoRenderLogger = RenderingState;
|
||||
}
|
||||
|
||||
void RenderCursor(bool RenderingState)
|
||||
{
|
||||
g_DoRenderCursor = RenderingState;
|
||||
}
|
||||
|
||||
static bool Autostart(const CmdLineArgs& args)
|
||||
{
|
||||
/*
|
||||
|
@ -51,6 +51,12 @@ enum InitFlags
|
||||
extern void RenderGui(bool RenderingState);
|
||||
extern void RenderLogger(bool RenderingState);
|
||||
|
||||
/**
|
||||
* enable/disable rendering of the cursor - this does not hide cursor, but reverts to OS style
|
||||
*/
|
||||
extern void RenderCursor(bool RenderingState);
|
||||
|
||||
|
||||
class CmdLineArgs;
|
||||
extern void Init(const CmdLineArgs& args, int flags);
|
||||
extern void InitGraphics(const CmdLineArgs& args, int flags);
|
||||
|
Loading…
Reference in New Issue
Block a user