Upstream version 11.39.252.0
[platform/framework/web/crosswalk.git] / src / ozone / ui / events / remote_event_dispatcher.cc
1 // Copyright 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ozone/ui/events/remote_event_dispatcher.h"
6
7 #include "base/bind.h"
8 #include "ozone/ui/public/messages.h"
9
10 namespace ui {
11
12 RemoteEventDispatcher::RemoteEventDispatcher()
13     : EventConverterOzoneWayland(),
14       sender_(NULL) {
15 }
16
17 RemoteEventDispatcher::~RemoteEventDispatcher() {
18 }
19
20 void RemoteEventDispatcher::ChannelEstablished(IPC::Sender* sender) {
21   loop_ = base::MessageLoop::current();
22   sender_ = sender;
23 }
24
25 void RemoteEventDispatcher::MotionNotify(float x, float y) {
26   Dispatch(new WaylandInput_MotionNotify(x, y));
27 }
28
29 void RemoteEventDispatcher::ButtonNotify(unsigned handle,
30                                          ui::EventType type,
31                                          ui::EventFlags flags,
32                                          float x,
33                                          float y) {
34   Dispatch(new WaylandInput_ButtonNotify(handle, type, flags, x, y));
35 }
36
37 void RemoteEventDispatcher::AxisNotify(float x,
38                                        float y,
39                                        int xoffset,
40                                        int yoffset) {
41   Dispatch(new WaylandInput_AxisNotify(x, y, xoffset, yoffset));
42 }
43
44 void RemoteEventDispatcher::PointerEnter(unsigned handle,
45                                          float x,
46                                          float y) {
47   Dispatch(new WaylandInput_PointerEnter(handle, x, y));
48 }
49
50 void RemoteEventDispatcher::PointerLeave(unsigned handle,
51                                          float x,
52                                          float y) {
53   Dispatch(new WaylandInput_PointerLeave(handle, x, y));
54 }
55
56 void RemoteEventDispatcher::KeyNotify(ui::EventType type,
57                                       unsigned code) {
58   Dispatch(new WaylandInput_KeyNotify(type, code));
59 }
60
61 void RemoteEventDispatcher::VirtualKeyNotify(ui::EventType type,
62                                              uint32_t key,
63                                              uint32_t modifiers) {
64   Dispatch(new WaylandInput_VirtualKeyNotify(type, key, modifiers));
65 }
66
67 void RemoteEventDispatcher::KeyModifiers(uint32_t mods_depressed,
68                                          uint32_t mods_latched,
69                                          uint32_t mods_locked,
70                                          uint32_t group) {
71   Dispatch(new WaylandInput_KeyModifiers(mods_depressed,
72                                          mods_latched,
73                                          mods_locked,
74                                          group));
75 }
76
77 void RemoteEventDispatcher::TouchNotify(ui::EventType type,
78                                         float x,
79                                         float y,
80                                         int32_t touch_id,
81                                         uint32_t time_stamp) {
82   Dispatch(new WaylandInput_TouchNotify(type, x, y, touch_id, time_stamp));
83 }
84
85 void RemoteEventDispatcher::OutputSizeChanged(unsigned width,
86                                               unsigned height) {
87   Dispatch(new WaylandInput_OutputSize(width, height));
88 }
89
90 void RemoteEventDispatcher::WindowResized(unsigned handle,
91                                           unsigned width,
92                                           unsigned height) {
93   Dispatch(new WaylandWindow_Resized(handle, width, height));
94 }
95
96 void RemoteEventDispatcher::WindowUnminimized(unsigned handle) {
97   Dispatch(new WaylandWindow_Unminimized(handle));
98 }
99
100 void RemoteEventDispatcher::CloseWidget(unsigned handle) {
101   Dispatch(new WaylandInput_CloseWidget(handle));
102 }
103
104 void RemoteEventDispatcher::Commit(unsigned handle,
105                                    const std::string& text) {
106   Dispatch(new WaylandInput_Commit(handle, text));
107 }
108
109 void RemoteEventDispatcher::PreeditChanged(unsigned handle,
110                                            const std::string& text,
111                                            const std::string& commit) {
112   Dispatch(new WaylandInput_PreeditChanged(handle, text, commit));
113 }
114
115 void RemoteEventDispatcher::PreeditEnd() {
116   Dispatch(new WaylandInput_PreeditEnd());
117 }
118
119 void RemoteEventDispatcher::PreeditStart() {
120   Dispatch(new WaylandInput_PreeditStart());
121 }
122
123 void RemoteEventDispatcher::InitializeXKB(base::SharedMemoryHandle fd,
124                                           uint32_t size) {
125   Dispatch(new WaylandInput_InitializeXKB(fd, size));
126 }
127
128 void RemoteEventDispatcher::Dispatch(IPC::Message* message) {
129     ui::EventConverterOzoneWayland::PostTaskOnMainLoop(
130           base::Bind(&RemoteEventDispatcher::Send, this, message));
131 }
132
133 void RemoteEventDispatcher::Send(RemoteEventDispatcher* dispatcher,
134                                  IPC::Message* message) {
135   dispatcher->sender_->Send(message);
136 }
137
138 }  // namespace ui