]> git.localhorst.tv Git - blank.git/blobdiff - src/standalone/MasterState.cpp
better handling of focus and input
[blank.git] / src / standalone / MasterState.cpp
index 0744a7c52260e36f221e033421957ef1b7a15d45..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();
 }
 
 
@@ -196,7 +207,9 @@ void MasterState::Exit() {
 }
 
 void MasterState::OnLineSubmit(const std::string &line) {
-       hud.PostMessage(line);
+       if (!line.empty()) {
+               hud.PostMessage(line);
+       }
 }
 
 }