sdlterm/src/sdlterm.cc
changeset 73 85a282b5e4fc
parent 72 6e0656600754
--- a/sdlterm/src/sdlterm.cc	Wed Jan 30 19:44:01 2013 +0100
+++ b/sdlterm/src/sdlterm.cc	Wed Jan 30 20:21:08 2013 +0100
@@ -500,25 +500,29 @@
             return true;
 
         case SDL_MOUSEMOTION:
-            if (sdl_event.motion.state == 0 || _mousemove_last_x == -1)
-            {
-                // do not report move events when no button is pressed
-                return false;
-            }
-            event.type = Event::MOUSEMOVE;
             event.mouse.x = sdl_event.motion.x / _screen.get_cell_width();
             event.mouse.y = sdl_event.motion.y / _screen.get_cell_height();
-            if (_mousemove_last_x != event.mouse.x ||
-                _mousemove_last_y != event.mouse.y)
+            if (_mousemove_last_x == event.mouse.x &&
+                _mousemove_last_y == event.mouse.y)
+            {
+                // mouse position did not change
+                return false;
+            }
+            if (sdl_event.motion.state == 0 || _mousemove_last_x == -1)
             {
+                // no button is pressed or last pos not initialized
+                event.type = Event::MOUSEHOVER;
+            }
+            else
+            {
+                // some button pressed
+                event.type = Event::MOUSEMOVE;
                 event.mouse.relx = event.mouse.x - _mousemove_last_x;
                 event.mouse.rely = event.mouse.y - _mousemove_last_y;
-                _mousemove_last_x = event.mouse.x;
-                _mousemove_last_y = event.mouse.y;
-                return true;
             }
-            // mouse position did not change
-            return false;
+            _mousemove_last_x = event.mouse.x;
+            _mousemove_last_y = event.mouse.y;
+            return true;
 
         default:
             // unknown event