4719600f48d705606c8e3bd19aa7e9384b7c2a36
[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                                       unsigned modifiers) {
59   Dispatch(new WaylandInput_KeyNotify(type, code, modifiers));
60 }
61
62 void RemoteEventDispatcher::TouchNotify(ui::EventType type,
63                                         float x,
64                                         float y,
65                                         int32_t touch_id,
66                                         uint32_t time_stamp) {
67   Dispatch(new WaylandInput_TouchNotify(type, x, y, touch_id, time_stamp));
68 }
69
70 void RemoteEventDispatcher::OutputSizeChanged(unsigned width,
71                                               unsigned height) {
72   Dispatch(new WaylandInput_OutputSize(width, height));
73 }
74
75 void RemoteEventDispatcher::WindowResized(unsigned handle,
76                                           unsigned width,
77                                           unsigned height) {
78   Dispatch(new WaylandWindow_Resized(handle, width, height));
79 }
80
81 void RemoteEventDispatcher::CloseWidget(unsigned handle) {
82   Dispatch(new WaylandInput_CloseWidget(handle));
83 }
84
85 void RemoteEventDispatcher::Commit(unsigned handle,
86                                    const std::string& text) {
87   Dispatch(new WaylandInput_Commit(handle, text));
88 }
89
90 void RemoteEventDispatcher::PreeditChanged(unsigned handle,
91                                            const std::string& text,
92                                            const std::string& commit) {
93   Dispatch(new WaylandInput_PreeditChanged(handle, text, commit));
94 }
95
96 void RemoteEventDispatcher::PreeditEnd() {
97   Dispatch(new WaylandInput_PreeditEnd());
98 }
99
100 void RemoteEventDispatcher::PreeditStart() {
101   Dispatch(new WaylandInput_PreeditStart());
102 }
103
104 void RemoteEventDispatcher::Dispatch(IPC::Message* message) {
105     ui::EventConverterOzoneWayland::PostTaskOnMainLoop(
106           base::Bind(&RemoteEventDispatcher::Send, this, message));
107 }
108
109 void RemoteEventDispatcher::Send(RemoteEventDispatcher* dispatcher,
110                                  IPC::Message* message) {
111   dispatcher->sender_->Send(message);
112 }
113
114 }  // namespace ui