diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp index 044b5e587..aabbc62d2 100644 --- a/src/interface/Engine.cpp +++ b/src/interface/Engine.cpp @@ -22,6 +22,7 @@ Engine::Engine(): mouseyp_(0), FpsLimit(60.0f), windows(stack()), + mousePositions(stack()), lastBuffer(NULL), prevBuffers(stack()), windowTargetPosition(0, 0), @@ -98,6 +99,7 @@ void Engine::ShowWindow(Window * window) #endif windows.push(state_); + mousePositions.push(ui::Point(mousex_, mousey_)); } if(state_) state_->DoBlur(); @@ -125,6 +127,17 @@ void Engine::CloseWindow() if(state_) state_->DoFocus(); + + ui::Point mouseState = mousePositions.top(); + mousePositions.pop(); + if(state_) + { + mousexp_ = mouseState.X; + mouseyp_ = mouseState.Y; + state_->DoMouseMove(mousex_, mousey_, mousex_ - mousexp_, mousey_ - mouseyp_); + mousexp_ = mousex_; + mouseyp_ = mousey_; + } } else {