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/root_window_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 RootWindowHostOzone::RootWindowHostOzone(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);
33 RootWindowHostOzone::~RootWindowHostOzone() {
34 base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0);
37 bool RootWindowHostOzone::Dispatch(const base::NativeEvent
& ne
) {
38 ui::Event
* event
= static_cast<ui::Event
*>(ne
);
39 if (event
->IsTouchEvent()) {
40 ui::TouchEvent
* touchev
= static_cast<ui::TouchEvent
*>(ne
);
41 delegate_
->OnHostTouchEvent(touchev
);
42 } else if (event
->IsKeyEvent()) {
43 ui::KeyEvent
* keyev
= static_cast<ui::KeyEvent
*>(ne
);
44 delegate_
->OnHostKeyEvent(keyev
);
45 } else if (event
->IsMouseEvent()) {
46 ui::MouseEvent
* mouseev
= static_cast<ui::MouseEvent
*>(ne
);
47 delegate_
->OnHostMouseEvent(mouseev
);
52 RootWindow
* RootWindowHostOzone::GetRootWindow() {
53 return delegate_
->AsRootWindow();
56 gfx::AcceleratedWidget
RootWindowHostOzone::GetAcceleratedWidget() {
60 void RootWindowHostOzone::Show() { NOTIMPLEMENTED(); }
62 void RootWindowHostOzone::Hide() { NOTIMPLEMENTED(); }
64 void RootWindowHostOzone::ToggleFullScreen() { NOTIMPLEMENTED(); }
66 gfx::Rect
RootWindowHostOzone::GetBounds() const { return bounds_
; }
68 void RootWindowHostOzone::SetBounds(const gfx::Rect
& bounds
) {
72 gfx::Insets
RootWindowHostOzone::GetInsets() const { return gfx::Insets(); }
74 void RootWindowHostOzone::SetInsets(const gfx::Insets
& insets
) {
78 gfx::Point
RootWindowHostOzone::GetLocationOnNativeScreen() const {
79 return bounds_
.origin();
82 void RootWindowHostOzone::SetCapture() { NOTIMPLEMENTED(); }
84 void RootWindowHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); }
86 void RootWindowHostOzone::SetCursor(gfx::NativeCursor cursor
) {
90 bool RootWindowHostOzone::QueryMouseLocation(gfx::Point
* location_return
) {
95 bool RootWindowHostOzone::ConfineCursorToRootWindow() {
100 void RootWindowHostOzone::UnConfineCursor() { NOTIMPLEMENTED(); }
102 void RootWindowHostOzone::OnCursorVisibilityChanged(bool show
) {
106 void RootWindowHostOzone::MoveCursorTo(const gfx::Point
& location
) {
110 void RootWindowHostOzone::PostNativeEvent(
111 const base::NativeEvent
& native_event
) {
115 void RootWindowHostOzone::OnDeviceScaleFactorChanged(
116 float device_scale_factor
) {
120 void RootWindowHostOzone::PrepareForShutdown() { NOTIMPLEMENTED(); }
123 RootWindowHost
* RootWindowHost::Create(const gfx::Rect
& bounds
) {
124 return new RootWindowHostOzone(bounds
);
128 gfx::Size
RootWindowHost::GetNativeScreenSize() {