diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index ce0770ffc..bcec22e4e 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -406,11 +406,11 @@ void EventProcess(SDL_Event event) // if mouse hasn't moved yet, sdl will send 0,0. We don't want that if (hasMouseMoved) { - mousex = event.motion.x; - mousey = event.motion.y; + mousex = event.button.x; + mousey = event.button.y; } mouseButton = event.button.button; - engine->onMouseClick(event.motion.x, event.motion.y, mouseButton); + engine->onMouseClick(mousex, mousey, mouseButton); mouseDown = true; #if !defined(NDEBUG) && !defined(DEBUG) @@ -421,8 +421,8 @@ void EventProcess(SDL_Event event) // if mouse hasn't moved yet, sdl will send 0,0. We don't want that if (hasMouseMoved) { - mousex = event.motion.x; - mousey = event.motion.y; + mousex = event.button.x; + mousey = event.button.y; } mouseButton = event.button.button; engine->onMouseUnclick(mousex, mousey, mouseButton); @@ -441,6 +441,7 @@ void EventProcess(SDL_Event event) { //initial mouse coords, sdl won't tell us this if mouse hasn't moved CalculateMousePosition(&mousex, &mousey); + engine->initialMouse(mousex, mousey); engine->onMouseMove(mousex, mousey); calculatedInitialMouse = true; } diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp index 9217dd28f..1d92fb937 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -276,6 +276,12 @@ void Engine::onMouseUnclick(int x, int y, unsigned button) state_->DoMouseUp(x, y, button); } +void Engine::initialMouse(int x, int y) +{ + mousexp_ = x; + mouseyp_ = y; +} + void Engine::onMouseMove(int x, int y) { mousex_ = x; diff --git a/src/gui/interface/Engine.h b/src/gui/interface/Engine.h index 9ddf9e2b6..28e14052b 100644 --- a/src/gui/interface/Engine.h +++ b/src/gui/interface/Engine.h @@ -25,6 +25,7 @@ namespace ui void ShowWindow(Window * window); int CloseWindow(); + void initialMouse(int x, int y); void onMouseMove(int x, int y); void onMouseClick(int x, int y, unsigned button); void onMouseUnclick(int x, int y, unsigned button);