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/root_window.h"
8 #include "ui/events/ozone/event_factory_ozone.h"
9 #include "ui/gfx/ozone/surface_factory_ozone.h"
10 #include "ui/ozone/ozone_platform.h"
14 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds)
17 ui::OzonePlatform::Initialize();
19 // EventFactoryOzone creates converters that obtain input events from the
20 // underlying input system and dispatch them as |ui::Event| instances into
22 ui::EventFactoryOzone::GetInstance()->StartProcessingEvents();
24 gfx::SurfaceFactoryOzone* surface_factory =
25 gfx::SurfaceFactoryOzone::GetInstance();
26 widget_ = surface_factory->GetAcceleratedWidget();
28 surface_factory->AttemptToResizeAcceleratedWidget(widget_, bounds_);
30 base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this);
31 CreateCompositor(GetAcceleratedWidget());
34 WindowTreeHostOzone::~WindowTreeHostOzone() {
35 base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0);
39 uint32_t WindowTreeHostOzone::Dispatch(const base::NativeEvent& ne) {
40 ui::Event* event = static_cast<ui::Event*>(ne);
41 ui::EventDispatchDetails details ALLOW_UNUSED = SendEventToProcessor(event);
42 return POST_DISPATCH_NONE;
45 RootWindow* WindowTreeHostOzone::GetRootWindow() {
46 return delegate_->AsRootWindow();
49 gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() {
53 void WindowTreeHostOzone::Show() { NOTIMPLEMENTED(); }
55 void WindowTreeHostOzone::Hide() { NOTIMPLEMENTED(); }
57 void WindowTreeHostOzone::ToggleFullScreen() { NOTIMPLEMENTED(); }
59 gfx::Rect WindowTreeHostOzone::GetBounds() const { return bounds_; }
61 void WindowTreeHostOzone::SetBounds(const gfx::Rect& bounds) {
65 gfx::Insets WindowTreeHostOzone::GetInsets() const { return gfx::Insets(); }
67 void WindowTreeHostOzone::SetInsets(const gfx::Insets& insets) {
71 gfx::Point WindowTreeHostOzone::GetLocationOnNativeScreen() const {
72 return bounds_.origin();
75 void WindowTreeHostOzone::SetCapture() { NOTIMPLEMENTED(); }
77 void WindowTreeHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); }
79 bool WindowTreeHostOzone::QueryMouseLocation(gfx::Point* location_return) {
84 bool WindowTreeHostOzone::ConfineCursorToRootWindow() {
89 void WindowTreeHostOzone::UnConfineCursor() { NOTIMPLEMENTED(); }
91 void WindowTreeHostOzone::PostNativeEvent(
92 const base::NativeEvent& native_event) {
96 void WindowTreeHostOzone::OnDeviceScaleFactorChanged(
97 float device_scale_factor) {
101 void WindowTreeHostOzone::PrepareForShutdown() { NOTIMPLEMENTED(); }
103 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) {
104 gfx::SurfaceFactoryOzone::GetInstance()->SetCursorImage(*cursor.platform());
107 void WindowTreeHostOzone::MoveCursorToNative(const gfx::Point& location) {
108 gfx::SurfaceFactoryOzone::GetInstance()->MoveCursorTo(location);
111 void WindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show) {
115 ui::EventProcessor* WindowTreeHostOzone::GetEventProcessor() {
116 return delegate_->GetEventProcessor();
120 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
121 return new WindowTreeHostOzone(bounds);
125 gfx::Size WindowTreeHost::GetNativeScreenSize() {