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 "ui/aura/window_event_dispatcher.h"
8 #include "ui/ozone/public/cursor_factory_ozone.h"
9 #include "ui/ozone/public/ozone_platform.h"
10 #include "ui/platform_window/platform_window.h"
14 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect
& bounds
)
15 : widget_(gfx::kNullAcceleratedWidget
) {
17 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds
);
20 WindowTreeHostOzone::~WindowTreeHostOzone() {
25 void WindowTreeHostOzone::OnBoundsChanged(const gfx::Rect
& new_bounds
) {
26 // TOOD(spang): Should we determine which parts changed?
27 OnHostResized(new_bounds
.size());
28 OnHostMoved(new_bounds
.origin());
31 void WindowTreeHostOzone::OnDamageRect(const gfx::Rect
& damaged_region
) {
34 void WindowTreeHostOzone::DispatchEvent(ui::Event
* event
) {
35 SendEventToProcessor(event
);
38 void WindowTreeHostOzone::OnCloseRequest() {
39 OnHostCloseRequested();
42 void WindowTreeHostOzone::OnClosed() {
45 void WindowTreeHostOzone::OnWindowStateChanged(
46 ui::PlatformWindowState new_state
) {
49 void WindowTreeHostOzone::OnLostCapture() {
52 void WindowTreeHostOzone::OnAcceleratedWidgetAvailable(
53 gfx::AcceleratedWidget widget
) {
55 CreateCompositor(widget_
);
58 void WindowTreeHostOzone::OnActivationChanged(bool active
) {
61 ui::EventSource
* WindowTreeHostOzone::GetEventSource() {
65 gfx::AcceleratedWidget
WindowTreeHostOzone::GetAcceleratedWidget() {
69 void WindowTreeHostOzone::Show() {
70 platform_window_
->Show();
73 void WindowTreeHostOzone::Hide() {
74 platform_window_
->Hide();
77 gfx::Rect
WindowTreeHostOzone::GetBounds() const {
78 return platform_window_
->GetBounds();
81 void WindowTreeHostOzone::SetBounds(const gfx::Rect
& bounds
) {
82 platform_window_
->SetBounds(bounds
);
85 gfx::Point
WindowTreeHostOzone::GetLocationOnNativeScreen() const {
86 return platform_window_
->GetBounds().origin();
89 void WindowTreeHostOzone::SetCapture() {
90 platform_window_
->SetCapture();
93 void WindowTreeHostOzone::ReleaseCapture() {
94 platform_window_
->ReleaseCapture();
97 void WindowTreeHostOzone::PostNativeEvent(
98 const base::NativeEvent
& native_event
) {
99 SendEventToProcessor(static_cast<ui::Event
*>(native_event
));
102 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor
) {
103 platform_window_
->SetCursor(cursor
.platform());
106 void WindowTreeHostOzone::MoveCursorToNative(const gfx::Point
& location
) {
107 platform_window_
->MoveCursorTo(location
);
110 void WindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show
) {
114 ui::EventProcessor
* WindowTreeHostOzone::GetEventProcessor() {
119 WindowTreeHost
* WindowTreeHost::Create(const gfx::Rect
& bounds
) {
120 return new WindowTreeHostOzone(bounds
);
124 gfx::Size
WindowTreeHost::GetNativeScreenSize() {