Mir

Merge lp:~robertcarr/mir/add-event-action-defines into lp:~mir-team/mir/trunk

Proposed by Robert Carr
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 625
Proposed branch: lp:~robertcarr/mir/add-event-action-defines
Merge into: lp:~mir-team/mir/trunk
Diff against target: 84 lines (+25/-5)
5 files modified
examples/eglapp.c (+1/-1)
include/shared/mir_toolkit/event.h (+20/-0)
src/client/input/android_input_receiver.cpp (+1/-1)
tests/acceptance-tests/test_client_input.cpp (+1/-1)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+2/-2)
To merge this branch: bzr merge lp:~robertcarr/mir/add-event-action-defines
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Robert Ancell Approve
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Review via email: mp+160224@code.launchpad.net

Commit message

Add definition for Motion and Key event actions.

Description of the change

Add definitions for event action defines so toolkit porters (i.e. bschaefer working working on porting SDL :)) do not have to guess.

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

well, seems more orderly, I'll +1.

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

1. Missed a spot :)
src/client/input/android_input_receiver.cpp: if (ev.key.action == 1)

2. Trying to avoid identifiers getting too long, can we change:
   mir_key_event_action_*
   mir_motion_event_action_*
to
   mir_key_action_*
   mir_motion_action_*
?

3. Can we use typedefs instead of anonymous enums? That would allow us to change:
   int32_t action;
to:
   MirKeyAction action;
   MirMotionAction action;
etc.

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

Thanks for review!

>> 1. Missed a spot :)
>> src/client/input/android_input_receiver.cpp: if (ev.key.action == 1)

Good catch. Fixed

>>2. Trying to avoid identifiers getting too long, can we change:
>> mir_key_event_action_*
>> mir_motion_event_action_*
>>to
>> mir_key_action_*
>> mir_motion_action_*
>>?

Yeah!

>> 3. Can we use typedefs instead of anonymous enums? That would allow us to change:
>> int32_t action;
>> to:
>> MirKeyAction action;
>> MirMotionAction action;
>> etc.

I don't have a strong opinion. As it stands though each field is chosen to be the same as the platform-api event struct, there is a bit of a mess there (currently they are out of sync requiring expensive marshalling in the platform-API). Anyway the moral is that I'd like to discuss redesigning and solidifying the event struct next week and delay any changes until then.

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

+1 on using a typedef, otherwise good.

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

Looks good.

The typedefs can come gradually later. It's an evolution.

Also, I don't understand what this is: "mir_key_action_multiple", but don't really care.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/eglapp.c'
2--- examples/eglapp.c 2013-04-22 08:20:31 +0000
3+++ examples/eglapp.c 2013-04-23 17:17:30 +0000
4@@ -90,7 +90,7 @@
5 {
6 (void) surface;
7 (void) context;
8- if (ev->key.key_code == XKB_KEY_q)
9+ if (ev->key.key_code == XKB_KEY_q && ev->key.action == mir_key_action_up)
10 running = 0;
11 }
12
13
14=== modified file 'include/shared/mir_toolkit/event.h'
15--- include/shared/mir_toolkit/event.h 2013-04-11 22:47:09 +0000
16+++ include/shared/mir_toolkit/event.h 2013-04-23 17:17:30 +0000
17@@ -40,6 +40,26 @@
18 mir_event_type_motion
19 } MirEventType;
20
21+enum {
22+ mir_key_action_down = 0,
23+ mir_key_action_up = 1,
24+ mir_key_action_multiple = 2
25+};
26+
27+enum {
28+ mir_motion_action_down = 0,
29+ mir_motion_action_up = 1,
30+ mir_motion_action_move = 2,
31+ mir_motion_action_cancel = 3,
32+ mir_motion_action_outside = 4,
33+ mir_motion_action_pointer_down = 5,
34+ mir_motion_action_pointer_up = 6,
35+ mir_motion_action_hover_move = 7,
36+ mir_motion_action_scroll = 8,
37+ mir_motion_action_hover_enter = 9,
38+ mir_motion_action_hover_exit = 10
39+};
40+
41 typedef struct
42 {
43 MirEventType type;
44
45=== modified file 'src/client/input/android_input_receiver.cpp'
46--- src/client/input/android_input_receiver.cpp 2013-04-16 09:27:00 +0000
47+++ src/client/input/android_input_receiver.cpp 2013-04-23 17:17:30 +0000
48@@ -66,7 +66,7 @@
49 if (ev.type != mir_event_type_key)
50 return;
51
52- if (ev.key.action == 1)
53+ if (ev.key.action == mir_key_action_up)
54 ev.key.key_code = xkb_mapper->release_and_map_key(ev.key.scan_code);
55 else
56 ev.key.key_code = xkb_mapper->press_and_map_key(ev.key.scan_code);
57
58=== modified file 'tests/acceptance-tests/test_client_input.cpp'
59--- tests/acceptance-tests/test_client_input.cpp 2013-04-18 17:22:34 +0000
60+++ tests/acceptance-tests/test_client_input.cpp 2013-04-23 17:17:30 +0000
61@@ -200,7 +200,7 @@
62 static void handle_input(MirSurface* /* surface */, MirEvent const* ev, void* context)
63 {
64 auto client = static_cast<InputReceivingClient *>(context);
65- if (ev->key.action == 0)
66+ if (ev->key.action == mir_key_action_down)
67 {
68 client->handler->handle_key_down(ev);
69 client->event_received[client->events_received].wake_up_everyone();
70
71=== modified file 'tests/unit-tests/client/input/test_android_input_receiver.cpp'
72--- tests/unit-tests/client/input/test_android_input_receiver.cpp 2013-04-11 19:40:14 +0000
73+++ tests/unit-tests/client/input/test_android_input_receiver.cpp 2013-04-23 17:17:30 +0000
74@@ -104,8 +104,8 @@
75 // Some default values
76 // device_id must be > 0 or input publisher will reject
77 static const int32_t filler_device_id = 1;
78- // AMOTION_EVENT_ACTION_MOVE is necessary to engage batching behavior
79- static const int32_t motion_event_action_flags = AMOTION_EVENT_ACTION_MOVE;
80+ // event_action_move is necessary to engage batching behavior
81+ static const int32_t motion_event_action_flags = mir_motion_action_move;
82 // We have to have at least 1 pointer or the publisher will fail to marshal a motion event
83 static const int32_t default_pointer_count = 1;
84 };

Subscribers

People subscribed via source and target branches