]> git.localhorst.tv Git - blank.git/blobdiff - src/standalone/MasterState.cpp
better handling of focus and input
[blank.git] / src / standalone / MasterState.cpp
index 49ee0fbf9214967d550b526a7fd59469a9646c05..9cc154387e3f6becb55bf756b5df29606514f2fd 100644 (file)
@@ -67,19 +67,30 @@ MasterState::~MasterState() {
 void MasterState::OnResume() {
        if (spawn_index.MissingChunks() > 0) {
                env.state.Push(&preload);
-       }
-       if (config.input.mouse) {
-               env.window.GrabMouse();
+               return;
        }
        if (spawn_player) {
                // TODO: spawn
                spawn_player = false;
        }
        hud.KeepMessages(false);
+       OnFocus();
 }
 
 void MasterState::OnPause() {
+       OnBlur();
+}
+
+void MasterState::OnFocus() {
+       if (config.input.mouse) {
+               env.window.GrabMouse();
+       }
+       interface.Unlock();
+}
+
+void MasterState::OnBlur() {
        env.window.ReleaseMouse();
+       interface.Lock();
 }