- add sources.
[platform/framework/web/crosswalk.git] / src / ui / aura / root_window_host_ozone.cc
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.
4
5 #include "ui/aura/root_window_host_ozone.h"
6
7 #include "ui/aura/root_window.h"
8 #include "ui/gfx/ozone/surface_factory_ozone.h"
9 #include "ui/ozone/ozone_platform.h"
10
11 namespace aura {
12
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();
21
22   surface_factory->AttemptToResizeAcceleratedWidget(widget_, bounds_);
23
24   base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this);
25 }
26
27 RootWindowHostOzone::~RootWindowHostOzone() {
28   base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0);
29 }
30
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);
42   }
43   return true;
44 }
45
46 void RootWindowHostOzone::SetDelegate(RootWindowHostDelegate* delegate) {
47   delegate_ = delegate;
48 }
49
50 RootWindow* RootWindowHostOzone::GetRootWindow() {
51   return delegate_->AsRootWindow();
52 }
53
54 gfx::AcceleratedWidget RootWindowHostOzone::GetAcceleratedWidget() {
55   return widget_;
56 }
57
58 void RootWindowHostOzone::Show() { NOTIMPLEMENTED(); }
59
60 void RootWindowHostOzone::Hide() { NOTIMPLEMENTED(); }
61
62 void RootWindowHostOzone::ToggleFullScreen() { NOTIMPLEMENTED(); }
63
64 gfx::Rect RootWindowHostOzone::GetBounds() const { return bounds_; }
65
66 void RootWindowHostOzone::SetBounds(const gfx::Rect& bounds) {
67   NOTIMPLEMENTED();
68 }
69
70 gfx::Insets RootWindowHostOzone::GetInsets() const { return gfx::Insets(); }
71
72 void RootWindowHostOzone::SetInsets(const gfx::Insets& insets) {
73   NOTIMPLEMENTED();
74 }
75
76 gfx::Point RootWindowHostOzone::GetLocationOnNativeScreen() const {
77   return bounds_.origin();
78 }
79
80 void RootWindowHostOzone::SetCapture() { NOTIMPLEMENTED(); }
81
82 void RootWindowHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); }
83
84 void RootWindowHostOzone::SetCursor(gfx::NativeCursor cursor) {
85   NOTIMPLEMENTED();
86 }
87
88 bool RootWindowHostOzone::QueryMouseLocation(gfx::Point* location_return) {
89   NOTIMPLEMENTED();
90   return false;
91 }
92
93 bool RootWindowHostOzone::ConfineCursorToRootWindow() {
94   NOTIMPLEMENTED();
95   return false;
96 }
97
98 void RootWindowHostOzone::UnConfineCursor() { NOTIMPLEMENTED(); }
99
100 void RootWindowHostOzone::OnCursorVisibilityChanged(bool show) {
101   NOTIMPLEMENTED();
102 }
103
104 void RootWindowHostOzone::MoveCursorTo(const gfx::Point& location) {
105   NOTIMPLEMENTED();
106 }
107
108 void RootWindowHostOzone::SetFocusWhenShown(bool focus_when_shown) {
109   NOTIMPLEMENTED();
110 }
111
112 void RootWindowHostOzone::PostNativeEvent(
113     const base::NativeEvent& native_event) {
114   NOTIMPLEMENTED();
115 }
116
117 void RootWindowHostOzone::OnDeviceScaleFactorChanged(
118     float device_scale_factor) {
119   NOTIMPLEMENTED();
120 }
121
122 void RootWindowHostOzone::PrepareForShutdown() { NOTIMPLEMENTED(); }
123
124 // static
125 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
126   return new RootWindowHostOzone(bounds);
127 }
128
129 // static
130 gfx::Size RootWindowHost::GetNativeScreenSize() {
131   NOTIMPLEMENTED();
132   return gfx::Size();
133 }
134
135 }  // namespace aura