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/base/cursor/ozone/cursor_factory_ozone.h"
9 #include "ui/events/ozone/event_factory_ozone.h"
10 #include "ui/events/platform/platform_event_source.h"
11 #include "ui/gfx/ozone/surface_factory_ozone.h"
12 #include "ui/ozone/ozone_platform.h"
16 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect
& bounds
)
19 ui::OzonePlatform::Initialize();
21 // EventFactoryOzone creates converters that obtain input events from the
22 // underlying input system and dispatch them as |ui::Event| instances into
24 ui::EventFactoryOzone::GetInstance()->StartProcessingEvents();
26 gfx::SurfaceFactoryOzone
* surface_factory
=
27 gfx::SurfaceFactoryOzone::GetInstance();
28 widget_
= surface_factory
->GetAcceleratedWidget();
30 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
31 CreateCompositor(GetAcceleratedWidget());
34 WindowTreeHostOzone::~WindowTreeHostOzone() {
35 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
40 bool WindowTreeHostOzone::CanDispatchEvent(const ui::PlatformEvent
& ne
) {
42 ui::Event
* event
= static_cast<ui::Event
*>(ne
);
43 if (event
->IsMouseEvent() || event
->IsScrollEvent() || event
->IsTouchEvent())
44 return bounds_
.Contains(static_cast<ui::LocatedEvent
*>(event
)->location());
48 uint32_t WindowTreeHostOzone::DispatchEvent(const ui::PlatformEvent
& ne
) {
49 ui::Event
* event
= static_cast<ui::Event
*>(ne
);
50 ui::EventDispatchDetails details ALLOW_UNUSED
= SendEventToProcessor(event
);
51 return ui::POST_DISPATCH_STOP_PROPAGATION
;
54 gfx::AcceleratedWidget
WindowTreeHostOzone::GetAcceleratedWidget() {
58 void WindowTreeHostOzone::Show() { NOTIMPLEMENTED(); }
60 void WindowTreeHostOzone::Hide() { NOTIMPLEMENTED(); }
62 void WindowTreeHostOzone::ToggleFullScreen() { NOTIMPLEMENTED(); }
64 gfx::Rect
WindowTreeHostOzone::GetBounds() const { return bounds_
; }
66 void WindowTreeHostOzone::SetBounds(const gfx::Rect
& bounds
) {
70 gfx::Insets
WindowTreeHostOzone::GetInsets() const { return gfx::Insets(); }
72 void WindowTreeHostOzone::SetInsets(const gfx::Insets
& insets
) {
76 gfx::Point
WindowTreeHostOzone::GetLocationOnNativeScreen() const {
77 return bounds_
.origin();
80 void WindowTreeHostOzone::SetCapture() { NOTIMPLEMENTED(); }
82 void WindowTreeHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); }
84 bool WindowTreeHostOzone::QueryMouseLocation(gfx::Point
* location_return
) {
89 bool WindowTreeHostOzone::ConfineCursorToRootWindow() {
94 void WindowTreeHostOzone::UnConfineCursor() { NOTIMPLEMENTED(); }
96 void WindowTreeHostOzone::PostNativeEvent(
97 const base::NativeEvent
& native_event
) {
101 void WindowTreeHostOzone::OnDeviceScaleFactorChanged(
102 float device_scale_factor
) {
106 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor
) {
107 ui::CursorFactoryOzone::GetInstance()->SetCursor(GetAcceleratedWidget(),
111 void WindowTreeHostOzone::MoveCursorToNative(const gfx::Point
& location
) {
112 ui::EventFactoryOzone::GetInstance()->WarpCursorTo(GetAcceleratedWidget(),
116 void WindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show
) {
120 ui::EventProcessor
* WindowTreeHostOzone::GetEventProcessor() {
125 WindowTreeHost
* WindowTreeHost::Create(const gfx::Rect
& bounds
) {
126 return new WindowTreeHostOzone(bounds
);
130 gfx::Size
WindowTreeHost::GetNativeScreenSize() {