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/impl/ipc/gpu_process_dispatcher_delegate.h"
8 #include "content/child/child_process.h"
9 #include "content/child/child_thread.h"
10 #include "ozone/impl/ipc/messages.h"
14 content::ChildThread* GetProcessMainThread() {
15 content::ChildProcess* process = content::ChildProcess::current();
17 DCHECK(process->main_thread());
18 return process ? process->main_thread() : NULL;
23 namespace ozonewayland {
25 GpuProcessDispatcherDelegate::GpuProcessDispatcherDelegate()
26 : WaylandDispatcherDelegate() {
29 GpuProcessDispatcherDelegate::~GpuProcessDispatcherDelegate() {
32 void GpuProcessDispatcherDelegate::MotionNotify(float x, float y) {
33 PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendMotionNotify,
38 void GpuProcessDispatcherDelegate::ButtonNotify(unsigned handle,
43 PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendButtonNotify,
51 void GpuProcessDispatcherDelegate::AxisNotify(float x,
55 PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendAxisNotify,
62 void GpuProcessDispatcherDelegate::PointerEnter(unsigned handle,
65 PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendPointerEnter,
71 void GpuProcessDispatcherDelegate::PointerLeave(unsigned handle,
74 PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendPointerLeave,
80 void GpuProcessDispatcherDelegate::KeyNotify(unsigned state,
83 PostTaskOnMainLoop(base::Bind(&GpuProcessDispatcherDelegate::SendKeyNotify,
89 void GpuProcessDispatcherDelegate::OutputSizeChanged(unsigned width,
91 PostTaskOnMainLoop(base::Bind(
92 &GpuProcessDispatcherDelegate::SendOutputSizeChanged, width, height));
95 void GpuProcessDispatcherDelegate::SendMotionNotify(float x, float y) {
96 content::ChildThread* thread = GetProcessMainThread();
97 thread->Send(new WaylandInput_MotionNotify(x, y));
100 void GpuProcessDispatcherDelegate::SendButtonNotify(unsigned handle,
105 content::ChildThread* thread = GetProcessMainThread();
106 thread->Send(new WaylandInput_ButtonNotify(handle, state, flags, x, y));
109 void GpuProcessDispatcherDelegate::SendAxisNotify(float x,
113 content::ChildThread* thread = GetProcessMainThread();
114 thread->Send(new WaylandInput_AxisNotify(x, y, xoffset, yoffset));
117 void GpuProcessDispatcherDelegate::SendPointerEnter(unsigned handle,
120 content::ChildThread* thread = GetProcessMainThread();
121 thread->Send(new WaylandInput_PointerEnter(handle, x, y));
124 void GpuProcessDispatcherDelegate::SendPointerLeave(unsigned handle,
127 content::ChildThread* thread = GetProcessMainThread();
128 thread->Send(new WaylandInput_PointerLeave(handle, x, y));
131 void GpuProcessDispatcherDelegate::SendKeyNotify(unsigned type,
133 unsigned modifiers) {
134 content::ChildThread* thread = GetProcessMainThread();
135 thread->Send(new WaylandInput_KeyNotify(type, code, modifiers));
138 void GpuProcessDispatcherDelegate::SendOutputSizeChanged(unsigned width,
140 content::ChildThread* thread = GetProcessMainThread();
141 thread->Send(new WaylandInput_OutputSize(width, height));
144 } // namespace ozonewayland