Mir

Merge lp:~mir-team/mir/fix-new-input-dispatcher-and-hang-head-in-shame into lp:mir

Proposed by Robert Carr
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2656
Proposed branch: lp:~mir-team/mir/fix-new-input-dispatcher-and-hang-head-in-shame
Merge into: lp:mir
Diff against target: 93 lines (+17/-7)
4 files modified
src/server/input/default_configuration.cpp (+5/-4)
src/server/input/key_repeat_dispatcher.cpp (+9/-2)
src/server/input/key_repeat_dispatcher.h (+2/-0)
tests/unit-tests/input/test_key_repeat_dispatcher.cpp (+1/-1)
To merge this branch: bzr merge lp:~mir-team/mir/fix-new-input-dispatcher-and-hang-head-in-shame
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Alberto Aguirre (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+261773@code.launchpad.net

Commit message

Fix key repeat dispatcher (touch events not working at all)
(LP: #1464174)

Description of the change

Correct: https://bugs.launchpad.net/mir/+bug/1464174

The error is obvious if you look at the key_repeat_dispatcher.cpp diff...it just wasn't forwarding touch events to the next dispatcher! I really did test this at some point but I guess I reverted to an earlier version of the code when rebasing after --overwrite branch catastrophe in Dallas.

It wasn't caught in the tests because the KeyRepeatDispatcher wasn't installed (due to key repeat being disabled to not make the tests timing dependent). I've changed the way key repeat is configured in a way which would have caught this bug. I think the value of this could be argued about though (as the way repeat_enabled is implemented makes it unlikely this would catch future bugs).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM.

Nit:

69 + bool repeat_enabled,

Not aligned

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Yeah wrong indentation in a couple of places.

But more importantly, tested on krillin and bug fixed.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/server/input/default_configuration.cpp'
--- src/server/input/default_configuration.cpp 2015-06-08 17:22:32 +0000
+++ src/server/input/default_configuration.cpp 2015-06-11 18:30:00 +0000
@@ -223,10 +223,11 @@
223 std::chrono::milliseconds const key_repeat_timeout{20};223 std::chrono::milliseconds const key_repeat_timeout{20};
224224
225 auto const options = the_options();225 auto const options = the_options();
226 if (!options->get<bool>(options::enable_key_repeat_opt))226 auto enable_repeat = options->get<bool>(options::enable_key_repeat_opt);
227 return the_event_filter_chain_dispatcher();227
228 else228 return std::make_shared<mi::KeyRepeatDispatcher>(
229 return std::make_shared<mi::KeyRepeatDispatcher>(the_event_filter_chain_dispatcher(), the_main_loop(), key_repeat_timeout);229 the_event_filter_chain_dispatcher(), the_main_loop(), enable_repeat,
230 key_repeat_timeout);
230}231}
231232
232std::shared_ptr<droidinput::EventHubInterface>233std::shared_ptr<droidinput::EventHubInterface>
233234
=== modified file 'src/server/input/key_repeat_dispatcher.cpp'
--- src/server/input/key_repeat_dispatcher.cpp 2015-06-08 20:18:00 +0000
+++ src/server/input/key_repeat_dispatcher.cpp 2015-06-11 18:30:00 +0000
@@ -32,9 +32,11 @@
32mi::KeyRepeatDispatcher::KeyRepeatDispatcher(32mi::KeyRepeatDispatcher::KeyRepeatDispatcher(
33 std::shared_ptr<mi::InputDispatcher> const& next_dispatcher,33 std::shared_ptr<mi::InputDispatcher> const& next_dispatcher,
34 std::shared_ptr<mir::time::AlarmFactory> const& factory,34 std::shared_ptr<mir::time::AlarmFactory> const& factory,
35 bool repeat_enabled,
35 std::chrono::milliseconds repeat_timeout)36 std::chrono::milliseconds repeat_timeout)
36 : next_dispatcher(next_dispatcher),37 : next_dispatcher(next_dispatcher),
37 alarm_factory(factory),38 alarm_factory(factory),
39 repeat_enabled(repeat_enabled),
38 repeat_timeout(repeat_timeout)40 repeat_timeout(repeat_timeout)
39{41{
40}42}
@@ -47,17 +49,22 @@
4749
48bool mi::KeyRepeatDispatcher::dispatch(MirEvent const& event)50bool mi::KeyRepeatDispatcher::dispatch(MirEvent const& event)
49{51{
52 if (!repeat_enabled) // if we made this mutable we'd need a guard
53 {
54 return next_dispatcher->dispatch(event);
55 }
56
50 if (mir_event_get_type(&event) == mir_event_type_input)57 if (mir_event_get_type(&event) == mir_event_type_input)
51 {58 {
52 auto iev = mir_event_get_input_event(&event);59 auto iev = mir_event_get_input_event(&event);
53 if (mir_input_event_get_type(iev) != mir_input_event_type_key)60 if (mir_input_event_get_type(iev) != mir_input_event_type_key)
54 return false;61 return next_dispatcher->dispatch(event);
55 if (!handle_key_input(mir_input_event_get_device_id(iev), mir_input_event_get_keyboard_event(iev)))62 if (!handle_key_input(mir_input_event_get_device_id(iev), mir_input_event_get_keyboard_event(iev)))
56 return next_dispatcher->dispatch(event);63 return next_dispatcher->dispatch(event);
57 else64 else
58 return true;65 return true;
59 }66 }
60 return false;67 return next_dispatcher->dispatch(event);
61}68}
6269
63namespace70namespace
6471
=== modified file 'src/server/input/key_repeat_dispatcher.h'
--- src/server/input/key_repeat_dispatcher.h 2015-06-08 17:28:38 +0000
+++ src/server/input/key_repeat_dispatcher.h 2015-06-11 18:30:00 +0000
@@ -41,6 +41,7 @@
41public:41public:
42 KeyRepeatDispatcher(std::shared_ptr<InputDispatcher> const& next_dispatcher,42 KeyRepeatDispatcher(std::shared_ptr<InputDispatcher> const& next_dispatcher,
43 std::shared_ptr<time::AlarmFactory> const& factory,43 std::shared_ptr<time::AlarmFactory> const& factory,
44 bool repeat_enabled,
44 std::chrono::milliseconds repeat_timeout);45 std::chrono::milliseconds repeat_timeout);
4546
46 // InputDispatcher47 // InputDispatcher
@@ -53,6 +54,7 @@
5354
54 std::shared_ptr<InputDispatcher> const next_dispatcher;55 std::shared_ptr<InputDispatcher> const next_dispatcher;
55 std::shared_ptr<time::AlarmFactory> const alarm_factory;56 std::shared_ptr<time::AlarmFactory> const alarm_factory;
57 bool const repeat_enabled;
56 std::chrono::milliseconds repeat_timeout;58 std::chrono::milliseconds repeat_timeout;
5759
58 struct KeyboardState60 struct KeyboardState
5961
=== modified file 'tests/unit-tests/input/test_key_repeat_dispatcher.cpp'
--- tests/unit-tests/input/test_key_repeat_dispatcher.cpp 2015-06-03 16:34:34 +0000
+++ tests/unit-tests/input/test_key_repeat_dispatcher.cpp 2015-06-11 18:30:00 +0000
@@ -61,7 +61,7 @@
61struct KeyRepeatDispatcher : public testing::Test61struct KeyRepeatDispatcher : public testing::Test
62{62{
63 KeyRepeatDispatcher()63 KeyRepeatDispatcher()
64 : dispatcher(mock_next_dispatcher, mock_alarm_factory, repeat_time)64 : dispatcher(mock_next_dispatcher, mock_alarm_factory, true, repeat_time)
65 {65 {
66 }66 }
67 std::shared_ptr<mtd::MockInputDispatcher> mock_next_dispatcher = std::make_shared<mtd::MockInputDispatcher>();67 std::shared_ptr<mtd::MockInputDispatcher> mock_next_dispatcher = std::make_shared<mtd::MockInputDispatcher>();

Subscribers

People subscribed via source and target branches