Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / aura / window_tree_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/window_tree_host_ozone.h"
6
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"
11
12 namespace aura {
13
14 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds)
15     : widget_(0),
16       bounds_(bounds) {
17   ui::OzonePlatform::Initialize();
18
19   // EventFactoryOzone creates converters that obtain input events from the
20   // underlying input system and dispatch them as |ui::Event| instances into
21   // Aura.
22   ui::EventFactoryOzone::GetInstance()->StartProcessingEvents();
23
24   gfx::SurfaceFactoryOzone* surface_factory =
25       gfx::SurfaceFactoryOzone::GetInstance();
26   widget_ = surface_factory->GetAcceleratedWidget();
27
28   surface_factory->AttemptToResizeAcceleratedWidget(widget_, bounds_);
29
30   base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this);
31   CreateCompositor(GetAcceleratedWidget());
32 }
33
34 WindowTreeHostOzone::~WindowTreeHostOzone() {
35   base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0);
36   DestroyCompositor();
37 }
38
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;
43 }
44
45 RootWindow* WindowTreeHostOzone::GetRootWindow() {
46   return delegate_->AsRootWindow();
47 }
48
49 gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() {
50   return widget_;
51 }
52
53 void WindowTreeHostOzone::Show() { NOTIMPLEMENTED(); }
54
55 void WindowTreeHostOzone::Hide() { NOTIMPLEMENTED(); }
56
57 void WindowTreeHostOzone::ToggleFullScreen() { NOTIMPLEMENTED(); }
58
59 gfx::Rect WindowTreeHostOzone::GetBounds() const { return bounds_; }
60
61 void WindowTreeHostOzone::SetBounds(const gfx::Rect& bounds) {
62   NOTIMPLEMENTED();
63 }
64
65 gfx::Insets WindowTreeHostOzone::GetInsets() const { return gfx::Insets(); }
66
67 void WindowTreeHostOzone::SetInsets(const gfx::Insets& insets) {
68   NOTIMPLEMENTED();
69 }
70
71 gfx::Point WindowTreeHostOzone::GetLocationOnNativeScreen() const {
72   return bounds_.origin();
73 }
74
75 void WindowTreeHostOzone::SetCapture() { NOTIMPLEMENTED(); }
76
77 void WindowTreeHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); }
78
79 bool WindowTreeHostOzone::QueryMouseLocation(gfx::Point* location_return) {
80   NOTIMPLEMENTED();
81   return false;
82 }
83
84 bool WindowTreeHostOzone::ConfineCursorToRootWindow() {
85   NOTIMPLEMENTED();
86   return false;
87 }
88
89 void WindowTreeHostOzone::UnConfineCursor() { NOTIMPLEMENTED(); }
90
91 void WindowTreeHostOzone::PostNativeEvent(
92     const base::NativeEvent& native_event) {
93   NOTIMPLEMENTED();
94 }
95
96 void WindowTreeHostOzone::OnDeviceScaleFactorChanged(
97     float device_scale_factor) {
98   NOTIMPLEMENTED();
99 }
100
101 void WindowTreeHostOzone::PrepareForShutdown() { NOTIMPLEMENTED(); }
102
103 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) {
104   gfx::SurfaceFactoryOzone::GetInstance()->SetCursorImage(*cursor.platform());
105 }
106
107 void WindowTreeHostOzone::MoveCursorToNative(const gfx::Point& location) {
108   gfx::SurfaceFactoryOzone::GetInstance()->MoveCursorTo(location);
109 }
110
111 void WindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show) {
112   NOTIMPLEMENTED();
113 }
114
115 ui::EventProcessor* WindowTreeHostOzone::GetEventProcessor() {
116   return delegate_->GetEventProcessor();
117 }
118
119 // static
120 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
121   return new WindowTreeHostOzone(bounds);
122 }
123
124 // static
125 gfx::Size WindowTreeHost::GetNativeScreenSize() {
126   NOTIMPLEMENTED();
127   return gfx::Size();
128 }
129
130 }  // namespace aura