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());
25 event_converter_->SetIMEChangeObserver(
26 event_factory->GetIMEChangeObserver());
29 OzoneChannelHost::~OzoneChannelHost() {
30 delete state_handler_;
33 void OzoneChannelHost::DeleteRemoteStateChangeHandler() {
34 delete state_handler_;
35 state_handler_ = NULL;
38 void OzoneChannelHost::OnChannelEstablished(int host_id, IPC::Sender* sender) {
40 state_handler_->ChannelEstablished(sender);
43 void OzoneChannelHost::OnChannelDestroyed(int host_id) {
45 state_handler_->ChannelDestroyed();
48 bool OzoneChannelHost::OnMessageReceived(const IPC::Message& message) {
50 IPC_BEGIN_MESSAGE_MAP(OzoneChannelHost, message)
51 IPC_MESSAGE_HANDLER(WaylandInput_MotionNotify, OnMotionNotify)
52 IPC_MESSAGE_HANDLER(WaylandInput_ButtonNotify, OnButtonNotify)
53 IPC_MESSAGE_HANDLER(WaylandInput_TouchNotify, OnTouchNotify)
54 IPC_MESSAGE_HANDLER(WaylandInput_AxisNotify, OnAxisNotify)
55 IPC_MESSAGE_HANDLER(WaylandInput_PointerEnter, OnPointerEnter)
56 IPC_MESSAGE_HANDLER(WaylandInput_PointerLeave, OnPointerLeave)
57 IPC_MESSAGE_HANDLER(WaylandInput_KeyNotify, OnKeyNotify)
58 IPC_MESSAGE_HANDLER(WaylandInput_VirtualKeyNotify, OnVirtualKeyNotify)
59 IPC_MESSAGE_HANDLER(WaylandInput_KeyModifiers, OnKeyModifiers)
60 IPC_MESSAGE_HANDLER(WaylandInput_OutputSize, OnOutputSizeChanged)
61 IPC_MESSAGE_HANDLER(WaylandInput_CloseWidget, OnCloseWidget)
62 IPC_MESSAGE_HANDLER(WaylandWindow_Resized, OnWindowResized)
63 IPC_MESSAGE_HANDLER(WaylandWindow_Activated, OnWindowActivated)
64 IPC_MESSAGE_HANDLER(WaylandWindow_DeActivated, OnWindowDeActivated)
65 IPC_MESSAGE_HANDLER(WaylandWindow_Unminimized, OnWindowUnminimized)
66 IPC_MESSAGE_HANDLER(WaylandInput_Commit, OnCommit)
67 IPC_MESSAGE_HANDLER(WaylandInput_PreeditChanged, OnPreeditChanged)
68 IPC_MESSAGE_HANDLER(WaylandInput_PreeditEnd, OnPreeditEnd)
69 IPC_MESSAGE_HANDLER(WaylandInput_PreeditStart, OnPreeditStart)
70 IPC_MESSAGE_HANDLER(WaylandInput_InitializeXKB, OnInitializeXKB)
71 IPC_MESSAGE_UNHANDLED(handled = false)
77 void OzoneChannelHost::OnMotionNotify(float x, float y) {
78 event_converter_->MotionNotify(x, y);
81 void OzoneChannelHost::OnButtonNotify(unsigned handle,
86 event_converter_->ButtonNotify(handle, type, flags, x, y);
89 void OzoneChannelHost::OnTouchNotify(ui::EventType type,
93 uint32_t time_stamp) {
94 event_converter_->TouchNotify(type, x, y, touch_id, time_stamp);
97 void OzoneChannelHost::OnAxisNotify(float x,
101 event_converter_->AxisNotify(x, y, xoffset, yoffset);
104 void OzoneChannelHost::OnPointerEnter(unsigned handle,
107 event_converter_->PointerEnter(handle, x, y);
110 void OzoneChannelHost::OnPointerLeave(unsigned handle,
113 event_converter_->PointerLeave(handle, x, y);
116 void OzoneChannelHost::OnKeyNotify(ui::EventType type,
118 event_converter_->KeyNotify(type, code);
121 void OzoneChannelHost::OnVirtualKeyNotify(ui::EventType type,
123 uint32_t modifiers) {
124 event_converter_->VirtualKeyNotify(type, key, modifiers);
127 void OzoneChannelHost::OnKeyModifiers(uint32_t mods_depressed,
128 uint32_t mods_latched,
129 uint32_t mods_locked,
131 event_converter_->KeyModifiers(mods_depressed,
137 void OzoneChannelHost::OnOutputSizeChanged(unsigned width,
139 event_converter_->OutputSizeChanged(width, height);
142 void OzoneChannelHost::OnCloseWidget(unsigned handle) {
143 event_converter_->CloseWidget(handle);
146 void OzoneChannelHost::OnWindowResized(unsigned handle,
149 event_converter_->WindowResized(handle, width, height);
152 void OzoneChannelHost::OnWindowUnminimized(unsigned handle) {
153 event_converter_->WindowUnminimized(handle);
156 void OzoneChannelHost::OnWindowActivated(unsigned handle) {
157 event_converter_->WindowActivated(handle);
160 void OzoneChannelHost::OnWindowDeActivated(unsigned handle) {
161 event_converter_->WindowDeActivated(handle);
164 void OzoneChannelHost::OnCommit(unsigned handle, std::string text) {
165 event_converter_->Commit(handle, text);
168 void OzoneChannelHost::OnPreeditChanged(unsigned handle, std::string text,
169 std::string commit) {
170 event_converter_->PreeditChanged(handle, text, commit);
173 void OzoneChannelHost::OnPreeditEnd() {
176 void OzoneChannelHost::OnPreeditStart() {
179 void OzoneChannelHost::OnInitializeXKB(base::SharedMemoryHandle fd,
181 event_converter_->InitializeXKB(fd, size);