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/display_channel.h"
7 #include "content/child/child_process.h"
8 #include "content/child/child_thread.h"
9 #include "ozone/impl/ipc/messages.h"
10 #include "ozone/impl/ozone_display.h"
12 namespace ozonewayland {
13 // GpuChannelManager generates unique routeid for every new
14 // ImageTransportSurface. In Ozone-Wayland, we register a routeid between
15 // DisplayChannel and ChannelHost. Therefore, we hardcore our own routeid with a
16 // unique negitive value to avoid any conflicts from the GpuChannelManager ones.
17 #define WAYLAND_ROUTE_ID -0x1
21 content::ChildThread* GetProcessMainThread() {
22 content::ChildProcess* process = content::ChildProcess::current();
23 DCHECK(process && process->main_thread());
24 return process->main_thread();
29 OzoneDisplayChannel::OzoneDisplayChannel() {
32 OzoneDisplayChannel::~OzoneDisplayChannel() {
33 content::ChildThread* thread = GetProcessMainThread();
35 thread->RemoveRoute(WAYLAND_ROUTE_ID);
38 bool OzoneDisplayChannel::OnMessageReceived(
39 const IPC::Message& message) {
41 IPC_BEGIN_MESSAGE_MAP(OzoneDisplayChannel, message)
42 IPC_MESSAGE_HANDLER(WaylandMsg_DisplayChannelEstablished, OnEstablishChannel)
43 IPC_MESSAGE_HANDLER(WaylandWindow_State, OnWidgetStateChanged)
44 IPC_MESSAGE_HANDLER(WaylandWindow_Attributes, OnWidgetAttributesChanged)
45 IPC_MESSAGE_HANDLER(WaylandWindow_Title, OnWidgetTitleChanged)
46 IPC_MESSAGE_UNHANDLED(handled = false)
52 void OzoneDisplayChannel::OnEstablishChannel() {
53 OzoneDisplay::GetInstance()->OnChannelEstablished();
56 void OzoneDisplayChannel::Register() {
57 content::ChildThread* thread = GetProcessMainThread();
58 thread->AddRoute(WAYLAND_ROUTE_ID, this);
61 void OzoneDisplayChannel::OnWidgetStateChanged(unsigned handleid,
65 OzoneDisplay::GetInstance()->OnWidgetStateChanged(handleid,
71 void OzoneDisplayChannel::OnWidgetTitleChanged(unsigned widget,
73 OzoneDisplay::GetInstance()->OnWidgetTitleChanged(widget, title);
76 void OzoneDisplayChannel::OnWidgetAttributesChanged(unsigned widget,
81 OzoneDisplay::GetInstance()->OnWidgetAttributesChanged(widget,
88 } // namespace ozonewayland