~thomas-voss/platform-api/add-package-config

« back to all changes in this revision

Viewing changes to src/mircommon/event_helpers_mir.cpp

  • Committer: Thomas Voß
  • Date: 2013-06-20 12:26:40 UTC
  • mfrom: (67.1.1 fix-cmake-setup)
  • Revision ID: thomas.voss@canonical.com-20130620122640-ytzwepxb9qiijzgq
[ Gerry Boland ]
* Add mir suport.
[ Robert Carr ]
* Add mir suport.
[ Ubuntu daily release ]
* Automatic snapshot from revision 69
[ Ricardo Mendoza ]
* Allow remote App Manager to take care of signalling processes.
[ Ubuntu daily release ]
* Automatic snapshot from revision 67

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Robert Carr <robert.carr@canonical.com>
 
17
 */
 
18
 
 
19
#include "event_helpers_mir.h"
 
20
 
 
21
namespace uaum = ubuntu::application::ui::mir;
 
22
 
 
23
// TODO<mir>: This begs the question: Why does MirEvent exist? It's difficult to ensure this function is kept in sync 
 
24
// at the unit test level.
 
25
void
 
26
uaum::event_to_ubuntu_event(MirEvent const* mir_event, Event& ubuntu_ev)
 
27
{
 
28
    switch (mir_event->type)
 
29
    {
 
30
    case mir_event_type_key:
 
31
        ubuntu_ev.type = KEY_EVENT_TYPE;
 
32
        ubuntu_ev.device_id = mir_event->key.device_id;
 
33
        ubuntu_ev.source_id = mir_event->key.source_id;
 
34
        ubuntu_ev.action = mir_event->key.action;
 
35
        ubuntu_ev.flags = mir_event->key.flags;
 
36
        ubuntu_ev.meta_state = mir_event->key.modifiers;
 
37
        ubuntu_ev.details.key.key_code = mir_event->key.key_code;
 
38
        ubuntu_ev.details.key.scan_code = mir_event->key.scan_code;
 
39
        ubuntu_ev.details.key.repeat_count = mir_event->key.repeat_count;
 
40
        ubuntu_ev.details.key.down_time = mir_event->key.down_time;
 
41
        ubuntu_ev.details.key.event_time = mir_event->key.event_time;
 
42
        ubuntu_ev.details.key.is_system_key = mir_event->key.is_system_key;
 
43
        break;
 
44
    case mir_event_type_motion:
 
45
        ubuntu_ev.type = MOTION_EVENT_TYPE;
 
46
        ubuntu_ev.device_id = mir_event->motion.device_id;
 
47
        ubuntu_ev.source_id = mir_event->motion.source_id;
 
48
        ubuntu_ev.action = mir_event->motion.action;
 
49
        ubuntu_ev.flags = mir_event->motion.flags;
 
50
        ubuntu_ev.meta_state = mir_event->motion.modifiers;
 
51
        ubuntu_ev.details.motion.edge_flags = mir_event->motion.edge_flags;
 
52
        ubuntu_ev.details.motion.button_state = mir_event->motion.button_state;
 
53
        ubuntu_ev.details.motion.x_offset = mir_event->motion.x_offset;
 
54
        ubuntu_ev.details.motion.y_offset = mir_event->motion.y_offset;
 
55
        ubuntu_ev.details.motion.x_precision = mir_event->motion.x_precision;
 
56
        ubuntu_ev.details.motion.y_precision = mir_event->motion.y_precision;
 
57
        ubuntu_ev.details.motion.down_time = mir_event->motion.down_time;
 
58
        ubuntu_ev.details.motion.event_time = mir_event->motion.event_time;
 
59
        ubuntu_ev.details.motion.pointer_count = mir_event->motion.pointer_count;
 
60
        for (int i = 0; i < mir_event->motion.pointer_count; i++)
 
61
        {
 
62
            ubuntu_ev.details.motion.pointer_coordinates[i].id = mir_event->motion.pointer_coordinates[i].id;
 
63
            ubuntu_ev.details.motion.pointer_coordinates[i].x = mir_event->motion.pointer_coordinates[i].x;
 
64
            ubuntu_ev.details.motion.pointer_coordinates[i].raw_x = mir_event->motion.pointer_coordinates[i].raw_x;
 
65
            ubuntu_ev.details.motion.pointer_coordinates[i].y = mir_event->motion.pointer_coordinates[i].y;
 
66
            ubuntu_ev.details.motion.pointer_coordinates[i].raw_y = mir_event->motion.pointer_coordinates[i].raw_y;
 
67
            ubuntu_ev.details.motion.pointer_coordinates[i].touch_major = mir_event->motion.pointer_coordinates[i].touch_major;
 
68
            ubuntu_ev.details.motion.pointer_coordinates[i].touch_minor = mir_event->motion.pointer_coordinates[i].touch_minor;
 
69
            ubuntu_ev.details.motion.pointer_coordinates[i].size = mir_event->motion.pointer_coordinates[i].size;
 
70
            ubuntu_ev.details.motion.pointer_coordinates[i].pressure = mir_event->motion.pointer_coordinates[i].pressure;
 
71
            ubuntu_ev.details.motion.pointer_coordinates[i].orientation = mir_event->motion.pointer_coordinates[i].orientation;
 
72
        }
 
73
        break;
 
74
    default:
 
75
        break;
 
76
    }
 
77
}