From 63ebebcfa46e52812bac1002b2d5a41c53e9706f Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 30 Mar 2015 16:05:16 +0200 Subject: [PATCH] nitpicker: update the 'pointed session' more often Currently, the 'pointed session' gets updated only when an input event occurs, but an update is also needed in other situations, for example when the view under the current mouse position was moved. With this commit, the 'pointed session' gets updated whenever the timer-triggered 'handle_input()' function is called. Fixes #1473 --- repos/os/src/server/nitpicker/input.h | 59 +++++++++++++++------------ repos/os/src/server/nitpicker/main.cc | 3 +- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/repos/os/src/server/nitpicker/input.h b/repos/os/src/server/nitpicker/input.h index 50a396ebd..ad5dfbb56 100644 --- a/repos/os/src/server/nitpicker/input.h +++ b/repos/os/src/server/nitpicker/input.h @@ -65,33 +65,42 @@ static Input::Event merge_motion_events(Input::Event const *ev, unsigned n) static void import_input_events(Input::Event *ev_buf, unsigned num_ev, User_state &user_state) { - /* - * Take events from input event buffer, merge consecutive motion - * events, and pass result to the user state. - */ - for (unsigned src_ev_cnt = 0; src_ev_cnt < num_ev; src_ev_cnt++) { - - Input::Event *e = &ev_buf[src_ev_cnt]; - Input::Event curr = *e; - - if (e->type() == Input::Event::MOTION) { - unsigned n = num_consecutive_events(e, num_ev - src_ev_cnt); - curr = merge_motion_events(e, n); - - /* skip merged events */ - src_ev_cnt += n - 1; - } - + if (num_ev > 0) { /* - * If subsequential relative motion events are merged to - * a zero-motion event, drop it. Otherwise, it would be - * misinterpreted as absolute event pointing to (0, 0). - */ - if (e->is_relative_motion() && curr.rx() == 0 && curr.ry() == 0) - continue; + * Take events from input event buffer, merge consecutive motion + * events, and pass result to the user state. + */ + for (unsigned src_ev_cnt = 0; src_ev_cnt < num_ev; src_ev_cnt++) { - /* pass event to user state */ - user_state.handle_event(curr); + Input::Event *e = &ev_buf[src_ev_cnt]; + Input::Event curr = *e; + + if (e->type() == Input::Event::MOTION) { + unsigned n = num_consecutive_events(e, num_ev - src_ev_cnt); + curr = merge_motion_events(e, n); + + /* skip merged events */ + src_ev_cnt += n - 1; + } + + /* + * If subsequential relative motion events are merged to + * a zero-motion event, drop it. Otherwise, it would be + * misinterpreted as absolute event pointing to (0, 0). + */ + if (e->is_relative_motion() && curr.rx() == 0 && curr.ry() == 0) + continue; + + /* pass event to user state */ + user_state.handle_event(curr); + } + } else { + /* + * Besides handling input events, 'user_state.handle_event()' also + * updates the pointed session, which might have changed by other + * means, for example view movement. + */ + user_state.handle_event(Input::Event()); } } diff --git a/repos/os/src/server/nitpicker/main.cc b/repos/os/src/server/nitpicker/main.cc index 3e612125f..d1ab3d217 100644 --- a/repos/os/src/server/nitpicker/main.cc +++ b/repos/os/src/server/nitpicker/main.cc @@ -1233,8 +1233,7 @@ void Nitpicker::Main::handle_input(unsigned) bool const old_xray_mode = user_state.xray(); /* handle batch of pending events */ - if (input.is_pending()) - import_input_events(ev_buf, input.flush(), user_state); + import_input_events(ev_buf, input.flush(), user_state); Point const new_pointer_pos = user_state.pointer_pos(); ::Session * const new_pointed_session = user_state.pointed_session();