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/event_factory_ozone.h"
10 #include "ui/ozone/public/ozone_platform.h"
11 #include "ui/platform_window/platform_window.h"
15 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect
& bounds
)
16 : widget_(gfx::kNullAcceleratedWidget
) {
18 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds
);
21 WindowTreeHostOzone::~WindowTreeHostOzone() {
26 void WindowTreeHostOzone::OnBoundsChanged(const gfx::Rect
& new_bounds
) {
27 // TOOD(spang): Should we determine which parts changed?
28 OnHostResized(new_bounds
.size());
29 OnHostMoved(new_bounds
.origin());
32 void WindowTreeHostOzone::OnDamageRect(const gfx::Rect
& damaged_region
) {
35 void WindowTreeHostOzone::DispatchEvent(ui::Event
* event
) {
36 SendEventToProcessor(event
);
39 void WindowTreeHostOzone::OnCloseRequest() {
40 OnHostCloseRequested();
43 void WindowTreeHostOzone::OnClosed() {
46 void WindowTreeHostOzone::OnWindowStateChanged(
47 ui::PlatformWindowState new_state
) {
50 void WindowTreeHostOzone::OnLostCapture() {
53 void WindowTreeHostOzone::OnAcceleratedWidgetAvailable(
54 gfx::AcceleratedWidget widget
) {
56 CreateCompositor(widget_
);
59 ui::EventSource
* WindowTreeHostOzone::GetEventSource() {
63 gfx::AcceleratedWidget
WindowTreeHostOzone::GetAcceleratedWidget() {
67 void WindowTreeHostOzone::Show() {
68 platform_window_
->Show();
71 void WindowTreeHostOzone::Hide() {
72 platform_window_
->Hide();
75 gfx::Rect
WindowTreeHostOzone::GetBounds() const {
76 return platform_window_
->GetBounds();
79 void WindowTreeHostOzone::SetBounds(const gfx::Rect
& bounds
) {
80 platform_window_
->SetBounds(bounds
);
83 gfx::Point
WindowTreeHostOzone::GetLocationOnNativeScreen() const {
84 return platform_window_
->GetBounds().origin();
87 void WindowTreeHostOzone::SetCapture() {
88 platform_window_
->SetCapture();
91 void WindowTreeHostOzone::ReleaseCapture() {
92 platform_window_
->ReleaseCapture();
95 void WindowTreeHostOzone::PostNativeEvent(
96 const base::NativeEvent
& native_event
) {
100 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor
) {
101 ui::CursorFactoryOzone::GetInstance()->SetCursor(GetAcceleratedWidget(),
105 void WindowTreeHostOzone::MoveCursorToNative(const gfx::Point
& location
) {
106 ui::EventFactoryOzone::GetInstance()->WarpCursorTo(GetAcceleratedWidget(),
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() {