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.
5 #include "ozone/ui/public/ozone_channel_host.h"
7 #include "ozone/ui/events/event_converter_in_process.h"
8 #include "ozone/ui/events/event_factory_ozone_wayland.h"
9 #include "ozone/ui/events/remote_state_change_handler.h"
10 #include "ozone/ui/public/messages.h"
14 OzoneChannelHost::OzoneChannelHost()
15 : state_handler_(NULL) {
16 event_converter_ = new EventConverterInProcess();
17 ui::EventFactoryOzoneWayland* event_factory =
18 ui::EventFactoryOzoneWayland::GetInstance();
19 event_factory->SetEventConverterOzoneWayland(event_converter_);
20 state_handler_ = new RemoteStateChangeHandler();
21 event_converter_->SetWindowChangeObserver(
22 event_factory->GetWindowChangeObserver());
23 event_converter_->SetOutputChangeObserver(
24 event_factory->GetOutputChangeObserver());
27 OzoneChannelHost::~OzoneChannelHost() {
28 delete state_handler_;
31 void OzoneChannelHost::DeleteRemoteStateChangeHandler() {
32 delete state_handler_;
33 state_handler_ = NULL;
36 void OzoneChannelHost::OnChannelEstablished(int host_id, IPC::Sender* sender) {
38 state_handler_->ChannelEstablished(sender);
41 void OzoneChannelHost::OnChannelDestroyed(int host_id) {
43 state_handler_->ChannelDestroyed();
46 bool OzoneChannelHost::OnMessageReceived(const IPC::Message& message) {
48 IPC_BEGIN_MESSAGE_MAP(OzoneChannelHost, message)
49 IPC_MESSAGE_HANDLER(WaylandInput_MotionNotify, OnMotionNotify)
50 IPC_MESSAGE_HANDLER(WaylandInput_ButtonNotify, OnButtonNotify)
51 IPC_MESSAGE_HANDLER(WaylandInput_TouchNotify, OnTouchNotify)
52 IPC_MESSAGE_HANDLER(WaylandInput_AxisNotify, OnAxisNotify)
53 IPC_MESSAGE_HANDLER(WaylandInput_PointerEnter, OnPointerEnter)
54 IPC_MESSAGE_HANDLER(WaylandInput_PointerLeave, OnPointerLeave)
55 IPC_MESSAGE_HANDLER(WaylandInput_KeyNotify, OnKeyNotify)
56 IPC_MESSAGE_HANDLER(WaylandInput_OutputSize, OnOutputSizeChanged)
57 IPC_MESSAGE_HANDLER(WaylandInput_CloseWidget, OnCloseWidget)
58 IPC_MESSAGE_HANDLER(WaylandWindow_Resized, OnWindowResized)
59 IPC_MESSAGE_HANDLER(WaylandWindow_Unminimized, OnWindowUnminimized)
60 IPC_MESSAGE_HANDLER(WaylandInput_Commit, OnCommit)
61 IPC_MESSAGE_HANDLER(WaylandInput_PreeditChanged, OnPreeditChanged)
62 IPC_MESSAGE_HANDLER(WaylandInput_PreeditEnd, OnPreeditEnd)
63 IPC_MESSAGE_HANDLER(WaylandInput_PreeditStart, OnPreeditStart)
64 IPC_MESSAGE_UNHANDLED(handled = false)
70 void OzoneChannelHost::OnMotionNotify(float x, float y) {
71 event_converter_->MotionNotify(x, y);
74 void OzoneChannelHost::OnButtonNotify(unsigned handle,
79 event_converter_->ButtonNotify(handle, type, flags, x, y);
82 void OzoneChannelHost::OnTouchNotify(ui::EventType type,
86 uint32_t time_stamp) {
87 event_converter_->TouchNotify(type, x, y, touch_id, time_stamp);
90 void OzoneChannelHost::OnAxisNotify(float x,
94 event_converter_->AxisNotify(x, y, xoffset, yoffset);
97 void OzoneChannelHost::OnPointerEnter(unsigned handle,
100 event_converter_->PointerEnter(handle, x, y);
103 void OzoneChannelHost::OnPointerLeave(unsigned handle,
106 event_converter_->PointerLeave(handle, x, y);
109 void OzoneChannelHost::OnKeyNotify(ui::EventType type,
111 unsigned modifiers) {
112 event_converter_->KeyNotify(type, code, modifiers);
115 void OzoneChannelHost::OnOutputSizeChanged(unsigned width,
117 event_converter_->OutputSizeChanged(width, height);
120 void OzoneChannelHost::OnCloseWidget(unsigned handle) {
121 event_converter_->CloseWidget(handle);
124 void OzoneChannelHost::OnWindowResized(unsigned handle,
127 event_converter_->WindowResized(handle, width, height);
130 void OzoneChannelHost::OnWindowUnminimized(unsigned handle) {
131 event_converter_->WindowUnminimized(handle);
134 void OzoneChannelHost::OnCommit(unsigned handle, std::string text) {
135 event_converter_->Commit(handle, text);
138 void OzoneChannelHost::OnPreeditChanged(unsigned handle, std::string text,
139 std::string commit) {
140 event_converter_->PreeditChanged(handle, text, commit);
143 void OzoneChannelHost::OnPreeditEnd() {
146 void OzoneChannelHost::OnPreeditStart() {