From d938899f5c3b65e97b1d3d00f0e75af12c91b49a Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Mon, 30 May 2011 18:56:49 +0200 Subject: [PATCH] Window::SetCursorPosition now triggers MouseMoved events --- include/SFML/Window/Window.hpp | 2 -- src/SFML/Window/Window.cpp | 28 +++------------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp index 99750317d..18fc11890 100644 --- a/include/SFML/Window/Window.hpp +++ b/include/SFML/Window/Window.hpp @@ -497,8 +497,6 @@ private : Clock myClock; ///< Clock for measuring the elapsed time between frames Uint32 myLastFrameTime; ///< Time elapsed since last frame unsigned int myFramerateLimit; ///< Current framerate limit - int mySetCursorPosX; ///< X coordinate passed to the last call to SetCursorPosition - int mySetCursorPosY; ///< Y coordinate passed to the last call to SetCursorPosition }; } // namespace sf diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 21421b599..dd78927a8 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -48,9 +48,7 @@ Window::Window() : myWindow (NULL), myContext (NULL), myLastFrameTime (0), -myFramerateLimit(0), -mySetCursorPosX (0xFFFF), -mySetCursorPosY (0xFFFF) +myFramerateLimit(0) { } @@ -61,9 +59,7 @@ Window::Window(VideoMode mode, const std::string& title, unsigned long style, co myWindow (NULL), myContext (NULL), myLastFrameTime (0), -myFramerateLimit(0), -mySetCursorPosX (0xFFFF), -mySetCursorPosY (0xFFFF) +myFramerateLimit(0) { Create(mode, title, style, settings); } @@ -74,9 +70,7 @@ Window::Window(WindowHandle handle, const ContextSettings& settings) : myWindow (NULL), myContext (NULL), myLastFrameTime (0), -myFramerateLimit(0), -mySetCursorPosX (0xFFFF), -mySetCursorPosY (0xFFFF) +myFramerateLimit(0) { Create(handle, settings); } @@ -251,13 +245,7 @@ void Window::ShowMouseCursor(bool show) void Window::SetCursorPosition(unsigned int x, unsigned int y) { if (myWindow) - { - // Keep coordinates for later checking (to reject the generated MouseMoved event) - mySetCursorPosX = x; - mySetCursorPosY = y; - myWindow->SetCursorPosition(x, y); - } } @@ -412,16 +400,6 @@ bool Window::FilterEvent(const Event& event) if (event.Type == Event::Resized) OnResize(); - // Don't forward to the user MouseMove events generated by SetCursorPosition - if ((event.Type == Event::MouseMoved) && - (event.MouseMove.X == mySetCursorPosX) && - (event.MouseMove.Y == mySetCursorPosY)) - { - mySetCursorPosX = 0xFFFF; - mySetCursorPosY = 0xFFFF; - return false; - } - return true; }