From 23696760c302052edec2fc25e6536c898a0f861b Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 6 Apr 2018 15:09:11 +0200 Subject: [PATCH] fb_sdl: drop spurious motion events without motion Relative motion events with a motion vector of (0,0) should not exists. They cause jittery movements of nitpicker's pointer position. This patch filters out such events. --- .../src/drivers/framebuffer/spec/sdl/input.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/repos/os/src/drivers/framebuffer/spec/sdl/input.cc b/repos/os/src/drivers/framebuffer/spec/sdl/input.cc index b0044ff091..786be9d069 100644 --- a/repos/os/src/drivers/framebuffer/spec/sdl/input.cc +++ b/repos/os/src/drivers/framebuffer/spec/sdl/input.cc @@ -146,15 +146,21 @@ static Input::Event wait_for_sdl_event() SDL_Event event; static int mx, my; - static int ox, oy; SDL_WaitEvent(&event); /* query new mouse position */ - ox = mx; oy = my; - if (event.type == SDL_MOUSEMOTION) + if (event.type == SDL_MOUSEMOTION) { + int ox = mx, oy = my; SDL_GetMouseState(&mx, &my); + /* drop superficial events */ + if (ox == mx && oy == my) + return Event(); + + return Event(Event::MOTION, 0, mx, my, mx - ox, my - oy); + } + /* determine keycode */ long keycode = 0; switch (event.type) { @@ -176,11 +182,8 @@ static Input::Event wait_for_sdl_event() } /* determine event type */ - Event::Type type; + Event::Type type = Event::INVALID; switch (event.type) { - case SDL_MOUSEMOTION: - type = Event::MOTION; - break; case SDL_KEYUP: case SDL_MOUSEBUTTONUP: @@ -208,7 +211,7 @@ static Input::Event wait_for_sdl_event() return Event(); } - return Event(type, keycode, mx, my, mx - ox, my - oy); + return Event(type, keycode, 0, 0, 0, 0); }