Upstream version 11.39.252.0
[platform/framework/web/crosswalk.git] / src / ozone / ui / events / remote_event_dispatcher.cc
index dced5e1..8c367a1 100644 (file)
@@ -5,33 +5,25 @@
 #include "ozone/ui/events/remote_event_dispatcher.h"
 
 #include "base/bind.h"
-#include "content/child/child_process.h"
-#include "content/child/child_thread.h"
-#include "ozone/impl/ipc/messages.h"
+#include "ozone/ui/public/messages.h"
 
-namespace {
-
-content::ChildThread* GetProcessMainThread() {
-  content::ChildProcess* process = content::ChildProcess::current();
-  DCHECK(process && process->main_thread());
-  return process ? process->main_thread() : NULL;
-}
-
-}
-
-namespace ozonewayland {
+namespace ui {
 
 RemoteEventDispatcher::RemoteEventDispatcher()
-    : EventConverterOzoneWayland() {
+    : EventConverterOzoneWayland(),
+      sender_(NULL) {
 }
 
 RemoteEventDispatcher::~RemoteEventDispatcher() {
 }
 
+void RemoteEventDispatcher::ChannelEstablished(IPC::Sender* sender) {
+  loop_ = base::MessageLoop::current();
+  sender_ = sender;
+}
+
 void RemoteEventDispatcher::MotionNotify(float x, float y) {
-  PostTaskOnMainLoop(base::Bind(&RemoteEventDispatcher::SendMotionNotify,
-                                x,
-                                y));
+  Dispatch(new WaylandInput_MotionNotify(x, y));
 }
 
 void RemoteEventDispatcher::ButtonNotify(unsigned handle,
@@ -39,125 +31,108 @@ void RemoteEventDispatcher::ButtonNotify(unsigned handle,
                                          ui::EventFlags flags,
                                          float x,
                                          float y) {
-  PostTaskOnMainLoop(base::Bind(&RemoteEventDispatcher::SendButtonNotify,
-                                handle,
-                                type,
-                                flags,
-                                x,
-                                y));
+  Dispatch(new WaylandInput_ButtonNotify(handle, type, flags, x, y));
 }
 
 void RemoteEventDispatcher::AxisNotify(float x,
                                        float y,
                                        int xoffset,
                                        int yoffset) {
-  PostTaskOnMainLoop(base::Bind(&RemoteEventDispatcher::SendAxisNotify,
-                                x,
-                                y,
-                                xoffset,
-                                yoffset));
+  Dispatch(new WaylandInput_AxisNotify(x, y, xoffset, yoffset));
 }
 
 void RemoteEventDispatcher::PointerEnter(unsigned handle,
                                          float x,
                                          float y) {
-  PostTaskOnMainLoop(base::Bind(&RemoteEventDispatcher::SendPointerEnter,
-                                handle,
-                                x,
-                                y));
+  Dispatch(new WaylandInput_PointerEnter(handle, x, y));
 }
 
 void RemoteEventDispatcher::PointerLeave(unsigned handle,
                                          float x,
                                          float y) {
-  PostTaskOnMainLoop(base::Bind(&RemoteEventDispatcher::SendPointerLeave,
-                                handle,
-                                x,
-                                y));
+  Dispatch(new WaylandInput_PointerLeave(handle, x, y));
+}
+
+void RemoteEventDispatcher::KeyNotify(ui::EventType type,
+                                      unsigned code) {
+  Dispatch(new WaylandInput_KeyNotify(type, code));
+}
+
+void RemoteEventDispatcher::VirtualKeyNotify(ui::EventType type,
+                                             uint32_t key,
+                                             uint32_t modifiers) {
+  Dispatch(new WaylandInput_VirtualKeyNotify(type, key, modifiers));
+}
+
+void RemoteEventDispatcher::KeyModifiers(uint32_t mods_depressed,
+                                         uint32_t mods_latched,
+                                         uint32_t mods_locked,
+                                         uint32_t group) {
+  Dispatch(new WaylandInput_KeyModifiers(mods_depressed,
+                                         mods_latched,
+                                         mods_locked,
+                                         group));
 }
 
-void RemoteEventDispatcher::KeyNotify(ui::EventType state,
-                                      unsigned code,
-                                      unsigned modifiers) {
-  PostTaskOnMainLoop(base::Bind(&RemoteEventDispatcher::SendKeyNotify,
-                                state,
-                                code,
-                                modifiers));
+void RemoteEventDispatcher::TouchNotify(ui::EventType type,
+                                        float x,
+                                        float y,
+                                        int32_t touch_id,
+                                        uint32_t time_stamp) {
+  Dispatch(new WaylandInput_TouchNotify(type, x, y, touch_id, time_stamp));
 }
 
 void RemoteEventDispatcher::OutputSizeChanged(unsigned width,
                                               unsigned height) {
-  PostTaskOnMainLoop(base::Bind(
-      &RemoteEventDispatcher::SendOutputSizeChanged, width, height));
+  Dispatch(new WaylandInput_OutputSize(width, height));
 }
 
 void RemoteEventDispatcher::WindowResized(unsigned handle,
                                           unsigned width,
                                           unsigned height) {
-  PostTaskOnMainLoop(base::Bind(
-      &RemoteEventDispatcher::SendWindowResized, handle, width, height));
-}
-
-void RemoteEventDispatcher::CloseWidget(unsigned handle) {
-  PostTaskOnMainLoop(base::Bind(
-      &RemoteEventDispatcher::SendCloseWidget, handle));
-}
-
-void RemoteEventDispatcher::SendMotionNotify(float x, float y) {
-  Send(new WaylandInput_MotionNotify(x, y));
+  Dispatch(new WaylandWindow_Resized(handle, width, height));
 }
 
-void RemoteEventDispatcher::SendButtonNotify(unsigned handle,
-                                             ui::EventType type,
-                                             ui::EventFlags flags,
-                                             float x,
-                                             float y) {
-  Send(new WaylandInput_ButtonNotify(handle, type, flags, x, y));
+void RemoteEventDispatcher::WindowUnminimized(unsigned handle) {
+  Dispatch(new WaylandWindow_Unminimized(handle));
 }
 
-void RemoteEventDispatcher::SendAxisNotify(float x,
-                                           float y,
-                                           int xoffset,
-                                           int yoffset) {
-  Send(new WaylandInput_AxisNotify(x, y, xoffset, yoffset));
+void RemoteEventDispatcher::CloseWidget(unsigned handle) {
+  Dispatch(new WaylandInput_CloseWidget(handle));
 }
 
-void RemoteEventDispatcher::SendPointerEnter(unsigned handle,
-                                             float x,
-                                             float y) {
-  Send(new WaylandInput_PointerEnter(handle, x, y));
+void RemoteEventDispatcher::Commit(unsigned handle,
+                                   const std::string& text) {
+  Dispatch(new WaylandInput_Commit(handle, text));
 }
 
-void RemoteEventDispatcher::SendPointerLeave(unsigned handle,
-                                             float x,
-                                             float y) {
-  Send(new WaylandInput_PointerLeave(handle, x, y));
+void RemoteEventDispatcher::PreeditChanged(unsigned handle,
+                                           const std::string& text,
+                                           const std::string& commit) {
+  Dispatch(new WaylandInput_PreeditChanged(handle, text, commit));
 }
 
-void RemoteEventDispatcher::SendKeyNotify(ui::EventType type,
-                                          unsigned code,
-                                          unsigned modifiers) {
-  Send(new WaylandInput_KeyNotify(type, code, modifiers));
+void RemoteEventDispatcher::PreeditEnd() {
+  Dispatch(new WaylandInput_PreeditEnd());
 }
 
-void RemoteEventDispatcher::SendOutputSizeChanged(unsigned width,
-                                                  unsigned height) {
-  Send(new WaylandInput_OutputSize(width, height));
+void RemoteEventDispatcher::PreeditStart() {
+  Dispatch(new WaylandInput_PreeditStart());
 }
 
-void RemoteEventDispatcher::SendWindowResized(unsigned handle,
-                                              unsigned width,
-                                              unsigned height) {
-  Send(new WaylandWindow_Resized(handle, width, height));
+void RemoteEventDispatcher::InitializeXKB(base::SharedMemoryHandle fd,
+                                          uint32_t size) {
+  Dispatch(new WaylandInput_InitializeXKB(fd, size));
 }
 
-void RemoteEventDispatcher::SendCloseWidget(unsigned handle) {
-  Send(new WaylandInput_CloseWidget(handle));
+void RemoteEventDispatcher::Dispatch(IPC::Message* message) {
+    ui::EventConverterOzoneWayland::PostTaskOnMainLoop(
+          base::Bind(&RemoteEventDispatcher::Send, this, message));
 }
 
-void RemoteEventDispatcher::Send(IPC::Message* message) {
-  content::ChildThread* thread = GetProcessMainThread();
-  thread->Send(message);
+void RemoteEventDispatcher::Send(RemoteEventDispatcher* dispatcher,
+                                 IPC::Message* message) {
+  dispatcher->sender_->Send(message);
 }
 
-}  // namespace ozonewayland
+}  // namespace ui