Merge lp:~alan-griffiths/qtmir/small-refactoring-of-QtEventFeeder into lp:qtmir

Proposed by Alan Griffiths
Status: Work in progress
Proposed branch: lp:~alan-griffiths/qtmir/small-refactoring-of-QtEventFeeder
Merge into: lp:qtmir
Diff against target: 111 lines (+16/-22)
2 files modified
src/platforms/mirserver/qteventfeeder.cpp (+13/-19)
src/platforms/mirserver/qteventfeeder.h (+3/-3)
To merge this branch: bzr merge lp:~alan-griffiths/qtmir/small-refactoring-of-QtEventFeeder
Reviewer Review Type Date Requested Status
Michał Sawicz Needs Fixing
Daniel d'Andrada (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+266381@code.launchpad.net

Commit message

Put the timestamp acquisition in QtEventFeeder::dispatch() instead of repeating it four times in the type-specific dispatch functions.

Description of the change

Put the timestamp acquisition in QtEventFeeder::dispatch() instead of repeating it four times in the type-specific dispatch functions.

(Should obviously not change behaviour.)

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
Daniel d'Andrada (dandrader) wrote :

Code looks good.

review: Approve (codewise)
350. By Alan Griffiths

  Deduplicate timestamp acquisition

351. By Alan Griffiths

  Make timestamps consistently ulong

352. By Alan Griffiths

  Inline single use variable

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Manual tests didn't show any regressions.

review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote :

Text conflict in src/platforms/mirserver/qteventfeeder.cpp
1 conflicts encountered.

review: Needs Fixing

Unmerged revisions

352. By Alan Griffiths

  Inline single use variable

351. By Alan Griffiths

  Make timestamps consistently ulong

350. By Alan Griffiths

  Deduplicate timestamp acquisition

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mirserver/qteventfeeder.cpp'
2--- src/platforms/mirserver/qteventfeeder.cpp 2015-06-24 23:08:44 +0000
3+++ src/platforms/mirserver/qteventfeeder.cpp 2015-08-06 09:01:23 +0000
4@@ -221,20 +221,22 @@
5
6 bool QtEventFeeder::dispatch(MirEvent const& event)
7 {
8- auto type = mir_event_get_type(&event);
9- if (type != mir_event_type_input)
10+ if (mir_event_get_type(&event) != mir_event_type_input)
11 return false;
12- auto iev = mir_event_get_input_event(&event);
13+ auto const iev = mir_event_get_input_event(&event);
14+
15+ // Convert nanoseconds to milliseconds, precision lost but time difference suitable
16+ auto const timestamp = mir_input_event_get_event_time(iev) / 1000000;
17
18 switch (mir_input_event_get_type(iev)) {
19 case mir_input_event_type_key:
20- dispatchKey(iev);
21+ dispatchKey(mir_input_event_get_keyboard_event(iev), timestamp);
22 break;
23 case mir_input_event_type_touch:
24- dispatchTouch(iev);
25+ dispatchTouch(mir_input_event_get_touch_event(iev), timestamp);
26 break;
27 case mir_input_event_type_pointer:
28- dispatchPointer(iev);
29+ dispatchPointer(mir_input_event_get_pointer_event(iev), timestamp);
30 default:
31 break;
32 }
33@@ -279,14 +281,11 @@
34 }
35 }
36
37-void QtEventFeeder::dispatchPointer(MirInputEvent const* ev)
38+void QtEventFeeder::dispatchPointer(MirPointerEvent const* pev, ulong timestamp)
39 {
40 if (!mQtWindowSystem->hasTargetWindow())
41 return;
42
43- auto timestamp = mir_input_event_get_event_time(ev) / 1000000;
44-
45- auto pev = mir_input_event_get_pointer_event(ev);
46 auto modifiers = getQtModifiersFromMir(mir_pointer_event_modifiers(pev));
47 auto buttons = getQtMouseButtonsfromMirPointerEvent(pev);
48
49@@ -297,14 +296,11 @@
50 buttons, modifiers);
51 }
52
53-void QtEventFeeder::dispatchKey(MirInputEvent const* event)
54+void QtEventFeeder::dispatchKey(MirKeyboardEvent const* kev, ulong timestamp)
55 {
56 if (!mQtWindowSystem->hasTargetWindow())
57 return;
58
59- ulong timestamp = mir_input_event_get_event_time(event) / 1000000;
60-
61- auto kev = mir_input_event_get_keyboard_event(event);
62 xkb_keysym_t xk_sym = mir_keyboard_event_key_code(kev);
63
64 // Key modifier and unicode index mapping.
65@@ -354,12 +350,11 @@
66 mir_keyboard_event_modifiers(kev), text, is_auto_rep);
67 }
68
69-void QtEventFeeder::dispatchTouch(MirInputEvent const* event)
70+void QtEventFeeder::dispatchTouch(MirTouchEvent const* tev, ulong timestamp)
71 {
72 if (!mQtWindowSystem->hasTargetWindow())
73 return;
74
75- auto tev = mir_input_event_get_touch_event(event);
76 qCDebug(QTMIR_MIR_INPUT) << "Received" << qPrintable(mirTouchEventToString(tev));
77
78 // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That
79@@ -404,13 +399,12 @@
80
81 // Qt needs a happy, sane stream of touch events. So let's make sure we're not forwarding
82 // any insanity.
83- validateTouches(mir_input_event_get_event_time(event) / 1000000, touchPoints);
84+ validateTouches(timestamp, touchPoints);
85
86 // Touch event propagation.
87 qCDebug(QTMIR_MIR_INPUT) << "Sending to Qt" << qPrintable(touchesToString(touchPoints));
88 mQtWindowSystem->handleTouchEvent(
89- //scales down the nsec_t (int64) to fit a ulong, precision lost but time difference suitable
90- mir_input_event_get_event_time(event) / 1000000,
91+ timestamp,
92 mTouchDevice,
93 touchPoints);
94 }
95
96=== modified file 'src/platforms/mirserver/qteventfeeder.h'
97--- src/platforms/mirserver/qteventfeeder.h 2015-06-24 23:08:44 +0000
98+++ src/platforms/mirserver/qteventfeeder.h 2015-08-06 09:01:23 +0000
99@@ -66,9 +66,9 @@
100 void stop() override;
101
102 private:
103- void dispatchKey(MirInputEvent const* event);
104- void dispatchTouch(MirInputEvent const* event);
105- void dispatchPointer(MirInputEvent const* event);
106+ void dispatchKey(MirKeyboardEvent const* kev, ulong timestamp);
107+ void dispatchTouch(MirTouchEvent const* tev, ulong timestamp);
108+ void dispatchPointer(MirPointerEvent const* pev, ulong timestamp);
109 void validateTouches(ulong timestamp, QList<QWindowSystemInterface::TouchPoint> &touchPoints);
110 bool validateTouch(QWindowSystemInterface::TouchPoint &touchPoint);
111 void sendActiveTouchRelease(ulong timestamp, int id);

Subscribers

People subscribed via source and target branches