]> git.localhorst.tv Git - blank.git/blobdiff - src/client/client.cpp
better handling of focus and input
[blank.git] / src / client / client.cpp
index 8b532633ab0cd85dc2926f2dbda72eb3ed7762e3..f0a3f35c7b984825d2dcffbc4c529a8c0d9815cb 100644 (file)
@@ -80,8 +80,24 @@ InteractiveState::InteractiveState(MasterState &master, uint32_t player_id)
        }
 }
 
-void InteractiveState::OnEnter() {
-       master.GetEnv().window.GrabMouse();
+void InteractiveState::OnResume() {
+       OnFocus();
+}
+
+void InteractiveState::OnPause() {
+       OnBlur();
+}
+
+void InteractiveState::OnFocus() {
+       if (master.GetConfig().input.mouse) {
+               master.GetEnv().window.GrabMouse();
+       }
+       interface.Unlock();
+}
+
+void InteractiveState::OnBlur() {
+       master.GetEnv().window.ReleaseMouse();
+       interface.Lock();
 }
 
 void InteractiveState::Handle(const SDL_Event &event) {