Mir

Merge lp:~vanvugt/mir/fix-1413139 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2246
Proposed branch: lp:~vanvugt/mir/fix-1413139
Merge into: lp:mir
Diff against target: 90 lines (+54/-14)
1 file modified
examples/fingerpaint.c (+54/-14)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1413139
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alberto Aguirre (community) Needs Fixing
Alan Griffiths Approve
Review via email: mp+247118@code.launchpad.net

Commit message

Restore lost support for fingerpainting with a mouse (LP: #1413139)

Description of the change

Haven't re-tested touch yet. Out of time today.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Does what it claims (not tested touch either)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

"/tmp/buildd/mir-0.11.0bzr2242pkg0vivid925+autopilot0/examples/fingerpaint.c:258:21: error: 'radius' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                 int radius;
                     ^
"

Looks good otherwise.

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

Fixed the above error and retested on touch too. Works on desktop and touch again.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/fingerpaint.c'
2--- examples/fingerpaint.c 2015-01-16 02:57:31 +0000
3+++ examples/fingerpaint.c 2015-01-22 03:41:03 +0000
4@@ -212,18 +212,38 @@
5 static float max_pressure = 1.0f;
6
7 MirInputEvent const* input_event = mir_event_get_input_event(event);
8- if (mir_input_event_get_type(input_event) != mir_input_event_type_touch)
9- return;
10- MirTouchInputEvent const* tev = mir_input_event_get_touch_input_event(input_event);
11- unsigned touch_count = mir_touch_input_event_get_touch_count(tev);
12-
13- if (touch_count == 1 && mir_touch_input_event_get_touch_action(tev, 0) == mir_touch_input_event_action_up)
14+ MirTouchInputEvent const* tev = NULL;
15+ MirPointerInputEvent const* pev = NULL;
16+ unsigned touch_count = 0;
17+ bool ended = false;
18+ MirInputEventType type = mir_input_event_get_type(input_event);
19+
20+ switch (type)
21+ {
22+ case mir_input_event_type_touch:
23+ tev = mir_input_event_get_touch_input_event(input_event);
24+ touch_count = mir_touch_input_event_get_touch_count(tev);
25+ ended = touch_count == 1 &&
26+ (mir_touch_input_event_get_touch_action(tev, 0) ==
27+ mir_touch_input_event_action_up);
28+ break;
29+ case mir_input_event_type_pointer:
30+ pev = mir_input_event_get_pointer_input_event(input_event);
31+ ended = mir_pointer_input_event_get_action(pev) ==
32+ mir_pointer_input_event_action_button_up;
33+ touch_count = mir_pointer_input_event_get_button_state(pev,
34+ mir_pointer_input_button_primary) ? 1 : 0;
35+ default:
36+ break;
37+ }
38+
39+ if (ended)
40 {
41 base_color = (base_color + max_fingers) %
42 (sizeof(color)/sizeof(color[0]));
43 max_fingers = 0;
44 }
45- else
46+ else if (touch_count)
47 {
48 size_t p;
49
50@@ -232,13 +252,33 @@
51
52 for (p = 0; p < touch_count; p++)
53 {
54- int x = mir_touch_input_event_get_touch_axis_value(tev, p, mir_touch_input_axis_x);
55- int y = mir_touch_input_event_get_touch_axis_value(tev, p, mir_touch_input_axis_y);
56- float size = mir_touch_input_event_get_touch_axis_value(tev, p, mir_touch_input_axis_size);
57- float pressure = mir_touch_input_event_get_touch_axis_value(tev, p, mir_touch_input_axis_pressure);
58-
59- int radius = size * 50.0f
60- + 1.0f;
61+ int x = 0;
62+ int y = 0;
63+ int radius = 1;
64+ float pressure = 1.0f;
65+
66+ if (tev != NULL)
67+ {
68+ x = mir_touch_input_event_get_touch_axis_value(tev, p,
69+ mir_touch_input_axis_x);
70+ y = mir_touch_input_event_get_touch_axis_value(tev, p,
71+ mir_touch_input_axis_y);
72+ float size = mir_touch_input_event_get_touch_axis_value(
73+ tev, p, mir_touch_input_axis_size);
74+ pressure = mir_touch_input_event_get_touch_axis_value(tev,
75+ p, mir_touch_input_axis_pressure);
76+ radius = size * 50.0f + 1.0f;
77+ }
78+ else if (pev != NULL)
79+ {
80+ x = mir_pointer_input_event_get_axis_value(pev,
81+ mir_pointer_input_axis_x);
82+ y = mir_pointer_input_event_get_axis_value(pev,
83+ mir_pointer_input_axis_y);
84+ pressure = 0.5f;
85+ radius = 5;
86+ }
87+
88 size_t c = (base_color + p) %
89 (sizeof(color)/sizeof(color[0]));
90 Color tone = color[c];

Subscribers

People subscribed via source and target branches