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"
14 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect
& bounds
)
15 : widget_(gfx::kNullAcceleratedWidget
), current_cursor_(ui::kCursorNull
) {
17 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds
);
20 WindowTreeHostOzone::~WindowTreeHostOzone() {
25 ui::EventSource
* WindowTreeHostOzone::GetEventSource() {
29 gfx::AcceleratedWidget
WindowTreeHostOzone::GetAcceleratedWidget() {
33 void WindowTreeHostOzone::ShowImpl() {
34 platform_window_
->Show();
37 void WindowTreeHostOzone::HideImpl() {
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_
)
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 float device_pixel_ratio
) {
108 WindowTreeHost::OnAcceleratedWidgetAvailable();
111 void WindowTreeHostOzone::OnActivationChanged(bool active
) {
115 WindowTreeHost
* WindowTreeHost::Create(const gfx::Rect
& bounds
) {
116 return new WindowTreeHostOzone(bounds
);
120 gfx::Size
WindowTreeHost::GetNativeScreenSize() {