sdlterm/src/sdlterm.cc
changeset 73 85a282b5e4fc
parent 72 6e0656600754
equal deleted inserted replaced
72:6e0656600754 73:85a282b5e4fc
   498             _mousemove_last_x = event.mouse.x;
   498             _mousemove_last_x = event.mouse.x;
   499             _mousemove_last_y = event.mouse.y;
   499             _mousemove_last_y = event.mouse.y;
   500             return true;
   500             return true;
   501 
   501 
   502         case SDL_MOUSEMOTION:
   502         case SDL_MOUSEMOTION:
   503             if (sdl_event.motion.state == 0 || _mousemove_last_x == -1)
       
   504             {
       
   505                 // do not report move events when no button is pressed
       
   506                 return false;
       
   507             }
       
   508             event.type = Event::MOUSEMOVE;
       
   509             event.mouse.x = sdl_event.motion.x / _screen.get_cell_width();
   503             event.mouse.x = sdl_event.motion.x / _screen.get_cell_width();
   510             event.mouse.y = sdl_event.motion.y / _screen.get_cell_height();
   504             event.mouse.y = sdl_event.motion.y / _screen.get_cell_height();
   511             if (_mousemove_last_x != event.mouse.x ||
   505             if (_mousemove_last_x == event.mouse.x &&
   512                 _mousemove_last_y != event.mouse.y)
   506                 _mousemove_last_y == event.mouse.y)
   513             {
   507             {
       
   508                 // mouse position did not change
       
   509                 return false;
       
   510             }
       
   511             if (sdl_event.motion.state == 0 || _mousemove_last_x == -1)
       
   512             {
       
   513                 // no button is pressed or last pos not initialized
       
   514                 event.type = Event::MOUSEHOVER;
       
   515             }
       
   516             else
       
   517             {
       
   518                 // some button pressed
       
   519                 event.type = Event::MOUSEMOVE;
   514                 event.mouse.relx = event.mouse.x - _mousemove_last_x;
   520                 event.mouse.relx = event.mouse.x - _mousemove_last_x;
   515                 event.mouse.rely = event.mouse.y - _mousemove_last_y;
   521                 event.mouse.rely = event.mouse.y - _mousemove_last_y;
   516                 _mousemove_last_x = event.mouse.x;
   522             }
   517                 _mousemove_last_y = event.mouse.y;
   523             _mousemove_last_x = event.mouse.x;
   518                 return true;
   524             _mousemove_last_y = event.mouse.y;
   519             }
   525             return true;
   520             // mouse position did not change
       
   521             return false;
       
   522 
   526 
   523         default:
   527         default:
   524             // unknown event
   528             // unknown event
   525             return false;
   529             return false;
   526     }
   530     }