Roll WebRTC 9189:9205, Libjingle 9186:9198
[chromium-blink-merge.git] / ui / aura / window_tree_host_ozone.cc
blob1559c243e0b03696dd9da653b945d31c6b7ab332
1 // Copyright 2013 The Chromium Authors. 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 "ui/aura/window_tree_host_ozone.h"
7 #include "base/trace_event/trace_event.h"
8 #include "ui/aura/window_event_dispatcher.h"
9 #include "ui/ozone/public/ozone_platform.h"
10 #include "ui/platform_window/platform_window.h"
12 namespace aura {
14 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds)
15 : widget_(gfx::kNullAcceleratedWidget), current_cursor_(ui::kCursorNull) {
16 platform_window_ =
17 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds);
20 WindowTreeHostOzone::~WindowTreeHostOzone() {
21 DestroyCompositor();
22 DestroyDispatcher();
25 ui::EventSource* WindowTreeHostOzone::GetEventSource() {
26 return this;
29 gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() {
30 return widget_;
33 void WindowTreeHostOzone::Show() {
34 platform_window_->Show();
37 void WindowTreeHostOzone::Hide() {
38 platform_window_->Hide();
41 gfx::Rect WindowTreeHostOzone::GetBounds() const {
42 return platform_window_->GetBounds();
45 void WindowTreeHostOzone::SetBounds(const gfx::Rect& bounds) {
46 platform_window_->SetBounds(bounds);
49 gfx::Point WindowTreeHostOzone::GetLocationOnNativeScreen() const {
50 return platform_window_->GetBounds().origin();
53 void WindowTreeHostOzone::SetCapture() {
54 platform_window_->SetCapture();
57 void WindowTreeHostOzone::ReleaseCapture() {
58 platform_window_->ReleaseCapture();
61 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) {
62 if (cursor == current_cursor_)
63 return;
64 current_cursor_ = cursor;
65 platform_window_->SetCursor(cursor.platform());
68 void WindowTreeHostOzone::MoveCursorToNative(const gfx::Point& location) {
69 platform_window_->MoveCursorTo(location);
72 void WindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show) {
75 void WindowTreeHostOzone::OnBoundsChanged(const gfx::Rect& new_bounds) {
76 // TOOD(spang): Should we determine which parts changed?
77 OnHostResized(new_bounds.size());
78 OnHostMoved(new_bounds.origin());
81 void WindowTreeHostOzone::OnDamageRect(const gfx::Rect& damaged_region) {
84 void WindowTreeHostOzone::DispatchEvent(ui::Event* event) {
85 TRACE_EVENT0("input", "WindowTreeHostOzone::DispatchEvent");
86 SendEventToProcessor(event);
89 void WindowTreeHostOzone::OnCloseRequest() {
90 OnHostCloseRequested();
93 void WindowTreeHostOzone::OnClosed() {
96 void WindowTreeHostOzone::OnWindowStateChanged(
97 ui::PlatformWindowState new_state) {
100 void WindowTreeHostOzone::OnLostCapture() {
103 void WindowTreeHostOzone::OnAcceleratedWidgetAvailable(
104 gfx::AcceleratedWidget widget) {
105 widget_ = widget;
106 CreateCompositor(widget_);
109 void WindowTreeHostOzone::OnActivationChanged(bool active) {
112 ui::EventProcessor* WindowTreeHostOzone::GetEventProcessor() {
113 return dispatcher();
116 // static
117 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
118 return new WindowTreeHostOzone(bounds);
121 // static
122 gfx::Size WindowTreeHost::GetNativeScreenSize() {
123 NOTIMPLEMENTED();
124 return gfx::Size();
127 } // namespace aura