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/ozone_platform.h"
9 #include "ui/platform_window/platform_window.h"
13 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect
& bounds
)
14 : widget_(gfx::kNullAcceleratedWidget
), current_cursor_(ui::kCursorNull
) {
16 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds
);
19 WindowTreeHostOzone::~WindowTreeHostOzone() {
24 gfx::Rect
WindowTreeHostOzone::GetBounds() const {
25 return platform_window_
->GetBounds();
28 void WindowTreeHostOzone::OnBoundsChanged(const gfx::Rect
& new_bounds
) {
29 // TOOD(spang): Should we determine which parts changed?
30 OnHostResized(new_bounds
.size());
31 OnHostMoved(new_bounds
.origin());
34 void WindowTreeHostOzone::OnDamageRect(const gfx::Rect
& damaged_region
) {
37 void WindowTreeHostOzone::DispatchEvent(ui::Event
* event
) {
38 SendEventToProcessor(event
);
41 void WindowTreeHostOzone::OnCloseRequest() {
42 OnHostCloseRequested();
45 void WindowTreeHostOzone::OnClosed() {
48 void WindowTreeHostOzone::OnWindowStateChanged(
49 ui::PlatformWindowState new_state
) {
52 void WindowTreeHostOzone::OnLostCapture() {
55 void WindowTreeHostOzone::OnAcceleratedWidgetAvailable(
56 gfx::AcceleratedWidget widget
) {
58 CreateCompositor(widget_
);
61 void WindowTreeHostOzone::OnActivationChanged(bool active
) {
64 ui::EventSource
* WindowTreeHostOzone::GetEventSource() {
68 gfx::AcceleratedWidget
WindowTreeHostOzone::GetAcceleratedWidget() {
72 void WindowTreeHostOzone::Show() {
73 platform_window_
->Show();
76 void WindowTreeHostOzone::Hide() {
77 platform_window_
->Hide();
80 void WindowTreeHostOzone::SetBounds(const gfx::Rect
& bounds
) {
81 platform_window_
->SetBounds(bounds
);
84 gfx::Point
WindowTreeHostOzone::GetLocationOnNativeScreen() const {
85 return platform_window_
->GetBounds().origin();
88 void WindowTreeHostOzone::SetCapture() {
89 platform_window_
->SetCapture();
92 void WindowTreeHostOzone::ReleaseCapture() {
93 platform_window_
->ReleaseCapture();
96 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor
) {
97 if (cursor
== current_cursor_
)
99 current_cursor_
= cursor
;
100 platform_window_
->SetCursor(cursor
.platform());
103 void WindowTreeHostOzone::MoveCursorToNative(const gfx::Point
& location
) {
104 platform_window_
->MoveCursorTo(location
);
107 void WindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show
) {
110 ui::EventProcessor
* WindowTreeHostOzone::GetEventProcessor() {
115 WindowTreeHost
* WindowTreeHost::Create(const gfx::Rect
& bounds
) {
116 return new WindowTreeHostOzone(bounds
);
120 gfx::Size
WindowTreeHost::GetNativeScreenSize() {