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/gfx/ozone/surface_factory_ozone.h"
9 #include "ui/ozone/ozone_platform.h"
13 RootWindowHostOzone::RootWindowHostOzone(const gfx::Rect& bounds)
14 : delegate_(NULL), widget_(0), bounds_(bounds) {
15 ui::OzonePlatform::Initialize();
16 factory_.reset(ui::EventFactoryOzone::GetInstance());
17 factory_->StartProcessingEvents();
18 gfx::SurfaceFactoryOzone* surface_factory =
19 gfx::SurfaceFactoryOzone::GetInstance();
20 widget_ = surface_factory->GetAcceleratedWidget();
22 surface_factory->AttemptToResizeAcceleratedWidget(widget_, bounds_);
24 base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this);
27 RootWindowHostOzone::~RootWindowHostOzone() {
28 base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0);
31 bool RootWindowHostOzone::Dispatch(const base::NativeEvent& ne) {
32 ui::Event* event = static_cast<ui::Event*>(ne);
33 if (event->IsTouchEvent()) {
34 ui::TouchEvent* touchev = static_cast<ui::TouchEvent*>(ne);
35 delegate_->OnHostTouchEvent(touchev);
36 } else if (event->IsKeyEvent()) {
37 ui::KeyEvent* keyev = static_cast<ui::KeyEvent*>(ne);
38 delegate_->OnHostKeyEvent(keyev);
39 } else if (event->IsMouseEvent()) {
40 ui::MouseEvent* mouseev = static_cast<ui::MouseEvent*>(ne);
41 delegate_->OnHostMouseEvent(mouseev);
46 void RootWindowHostOzone::SetDelegate(RootWindowHostDelegate* delegate) {
50 RootWindow* RootWindowHostOzone::GetRootWindow() {
51 return delegate_->AsRootWindow();
54 gfx::AcceleratedWidget RootWindowHostOzone::GetAcceleratedWidget() {
58 void RootWindowHostOzone::Show() { NOTIMPLEMENTED(); }
60 void RootWindowHostOzone::Hide() { NOTIMPLEMENTED(); }
62 void RootWindowHostOzone::ToggleFullScreen() { NOTIMPLEMENTED(); }
64 gfx::Rect RootWindowHostOzone::GetBounds() const { return bounds_; }
66 void RootWindowHostOzone::SetBounds(const gfx::Rect& bounds) {
70 gfx::Insets RootWindowHostOzone::GetInsets() const { return gfx::Insets(); }
72 void RootWindowHostOzone::SetInsets(const gfx::Insets& insets) {
76 gfx::Point RootWindowHostOzone::GetLocationOnNativeScreen() const {
77 return bounds_.origin();
80 void RootWindowHostOzone::SetCapture() { NOTIMPLEMENTED(); }
82 void RootWindowHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); }
84 void RootWindowHostOzone::SetCursor(gfx::NativeCursor cursor) {
88 bool RootWindowHostOzone::QueryMouseLocation(gfx::Point* location_return) {
93 bool RootWindowHostOzone::ConfineCursorToRootWindow() {
98 void RootWindowHostOzone::UnConfineCursor() { NOTIMPLEMENTED(); }
100 void RootWindowHostOzone::OnCursorVisibilityChanged(bool show) {
104 void RootWindowHostOzone::MoveCursorTo(const gfx::Point& location) {
108 void RootWindowHostOzone::SetFocusWhenShown(bool focus_when_shown) {
112 void RootWindowHostOzone::PostNativeEvent(
113 const base::NativeEvent& native_event) {
117 void RootWindowHostOzone::OnDeviceScaleFactorChanged(
118 float device_scale_factor) {
122 void RootWindowHostOzone::PrepareForShutdown() { NOTIMPLEMENTED(); }
125 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
126 return new RootWindowHostOzone(bounds);
130 gfx::Size RootWindowHost::GetNativeScreenSize() {