summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-24 00:31:26 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:17 +0300
commit076e2f4655c43e7dc79a01d576551942c7c3c057 (patch)
tree39bce5d299283f2bf00c24bff414331e714d8f21 /src/client.cpp
parentc88734cc2b8a0785c23531ce70bf703887aa0c4b (diff)
downloadmanaverse-076e2f4655c43e7dc79a01d576551942c7c3c057.tar.gz
manaverse-076e2f4655c43e7dc79a01d576551942c7c3c057.tar.bz2
manaverse-076e2f4655c43e7dc79a01d576551942c7c3c057.tar.xz
manaverse-076e2f4655c43e7dc79a01d576551942c7c3c057.zip
show/hide mouse cursor if mouse in/out window.
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 76f12d021..8a197d5aa 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -994,11 +994,12 @@ int Client::gameExec()
#ifdef USE_SDL2
case SDL_WINDOWEVENT:
- {
handleSDL2WindowEvent(event);
break;
- }
#else
+ case SDL_ACTIVEEVENT:
+ handleActive(event);
+ break;
case SDL_VIDEORESIZE:
resizeVideo(event.resize.w, event.resize.h, false);
break;
@@ -2866,7 +2867,7 @@ void Client::applyKeyRepeat()
void Client::setIsMinimized(const bool n)
{
mIsMinimized = n;
- if (!n && client->mNewMessageFlag)
+ if (!n && mNewMessageFlag)
{
mNewMessageFlag = false;
SDL::SetWindowTitle(mainGraphics->getWindow(), mCaption.c_str());
@@ -3119,8 +3120,46 @@ void Client::handleSDL2WindowEvent(const SDL_Event &event)
case SDL_WINDOWEVENT_RESIZED:
resizeVideo(event.window.data1, event.window.data2, false);
break;
+ case SDL_WINDOWEVENT_ENTER:
+ setMouseFocused(true);
+ break;
+ case SDL_WINDOWEVENT_LEAVE:
+ setMouseFocused(false);
+ break;
+ case SDL_WINDOWEVENT_FOCUS_GAINED:
+ setInputFocused(true);
+ break;
+ case SDL_WINDOWEVENT_FOCUS_LOST:
+ setInputFocused(false);
+ break;
default:
break;
}
}
+#else
+void Client::handleActive(const SDL_Event &event)
+{
+ if (event.active.state & SDL_APPACTIVE)
+ {
+ if (event.active.gain)
+ { // window restore
+ setIsMinimized(false);
+ setPriority(true);
+ }
+ else
+ { // window minimization
+#ifdef ANDROID
+ setState(STATE_EXIT);
+#else
+ setIsMinimized(true);
+ setPriority(false);
+#endif
+ }
+ }
+
+ if (event.active.state & SDL_APPINPUTFOCUS)
+ setInputFocused(event.active.gain);
+ if (event.active.state & SDL_APPMOUSEFOCUS)
+ setMouseFocused(event.active.gain);
+}
#endif