Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: ui/aura/window_tree_host_ozone.cc

Issue 375053002: ozone: Port WindowTreeHostOzone on top of PlatformWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase onto sadrul's CL Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/window_tree_host_ozone.h" 5 #include "ui/aura/window_tree_host_ozone.h"
6 6
7 #include "ui/aura/window_event_dispatcher.h" 7 #include "ui/aura/window_event_dispatcher.h"
8 #include "ui/events/platform/platform_event_source.h" 8 #include "ui/events/platform/platform_event_source.h"
9 #include "ui/ozone/public/cursor_factory_ozone.h" 9 #include "ui/ozone/public/cursor_factory_ozone.h"
10 #include "ui/ozone/public/event_factory_ozone.h" 10 #include "ui/ozone/public/event_factory_ozone.h"
11 #include "ui/ozone/public/surface_factory_ozone.h" 11 #include "ui/ozone/public/ozone_platform.h"
12 #include "ui/platform_window/platform_window.h"
12 13
13 namespace aura { 14 namespace aura {
14 15
15 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds) 16 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds)
16 : widget_(0), 17 : widget_(gfx::kNullAcceleratedWidget) {
17 bounds_(bounds) { 18 platform_window_ =
18 ui::SurfaceFactoryOzone* surface_factory = 19 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds);
19 ui::SurfaceFactoryOzone::GetInstance();
20 widget_ = surface_factory->GetAcceleratedWidget();
21
22 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); 20 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
23 CreateCompositor(GetAcceleratedWidget());
24 } 21 }
25 22
26 WindowTreeHostOzone::~WindowTreeHostOzone() { 23 WindowTreeHostOzone::~WindowTreeHostOzone() {
27 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); 24 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
28 DestroyCompositor(); 25 DestroyCompositor();
29 DestroyDispatcher(); 26 DestroyDispatcher();
30 } 27 }
31 28
32 bool WindowTreeHostOzone::CanDispatchEvent(const ui::PlatformEvent& ne) { 29 bool WindowTreeHostOzone::CanDispatchEvent(const ui::PlatformEvent& ne) {
33 CHECK(ne); 30 CHECK(ne);
34 ui::Event* event = static_cast<ui::Event*>(ne); 31 ui::Event* event = static_cast<ui::Event*>(ne);
35 if (event->IsMouseEvent() || event->IsScrollEvent()) 32 if (event->IsMouseEvent() || event->IsScrollEvent())
36 return ui::CursorFactoryOzone::GetInstance()->GetCursorWindow() == widget_; 33 return ui::CursorFactoryOzone::GetInstance()->GetCursorWindow() == widget_;
37 34
38 return true; 35 return true;
39 } 36 }
40 37
41 uint32_t WindowTreeHostOzone::DispatchEvent(const ui::PlatformEvent& ne) { 38 uint32_t WindowTreeHostOzone::DispatchEvent(const ui::PlatformEvent& ne) {
42 ui::Event* event = static_cast<ui::Event*>(ne); 39 ui::Event* event = static_cast<ui::Event*>(ne);
43 ui::EventDispatchDetails details ALLOW_UNUSED = SendEventToProcessor(event); 40 ui::EventDispatchDetails details ALLOW_UNUSED = SendEventToProcessor(event);
44 return ui::POST_DISPATCH_STOP_PROPAGATION; 41 return ui::POST_DISPATCH_STOP_PROPAGATION;
45 } 42 }
46 43
44 void WindowTreeHostOzone::OnBoundsChanged(const gfx::Rect& new_bounds) {
45 // TOOD(spang): Should we determine which parts changed?
46 OnHostResized(new_bounds.size());
47 OnHostMoved(new_bounds.origin());
48 }
49
50 void WindowTreeHostOzone::OnDamageRect(const gfx::Rect& damaged_region) {
51 }
52
53 void WindowTreeHostOzone::DispatchEvent(ui::Event* event) {
54 SendEventToProcessor(event);
55 }
56
57 void WindowTreeHostOzone::OnCloseRequest() {
58 OnHostCloseRequested();
59 }
60
61 void WindowTreeHostOzone::OnClosed() {
62 }
63
64 void WindowTreeHostOzone::OnWindowStateChanged(
65 ui::PlatformWindowState new_state) {
66 }
67
68 void WindowTreeHostOzone::OnLostCapture() {
69 }
70
71 void WindowTreeHostOzone::OnAcceleratedWidgetAvailable(
72 gfx::AcceleratedWidget widget) {
73 widget_ = widget;
74 CreateCompositor(widget_);
75 }
76
47 ui::EventSource* WindowTreeHostOzone::GetEventSource() { 77 ui::EventSource* WindowTreeHostOzone::GetEventSource() {
48 return this; 78 return this;
49 } 79 }
50 80
51 gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() { 81 gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() {
52 return widget_; 82 return widget_;
53 } 83 }
54 84
55 void WindowTreeHostOzone::Show() { NOTIMPLEMENTED(); } 85 void WindowTreeHostOzone::Show() {
86 platform_window_->Show();
87 }
56 88
57 void WindowTreeHostOzone::Hide() { NOTIMPLEMENTED(); } 89 void WindowTreeHostOzone::Hide() {
90 platform_window_->Hide();
91 }
58 92
59 gfx::Rect WindowTreeHostOzone::GetBounds() const { return bounds_; } 93 gfx::Rect WindowTreeHostOzone::GetBounds() const {
94 return platform_window_->GetBounds();
95 }
60 96
61 void WindowTreeHostOzone::SetBounds(const gfx::Rect& bounds) { 97 void WindowTreeHostOzone::SetBounds(const gfx::Rect& bounds) {
62 bool origin_changed = bounds_.origin() != bounds.origin(); 98 platform_window_->SetBounds(bounds);
63 bool size_changed = bounds_.size() != bounds.size();
64 bounds_ = bounds;
65 if (size_changed)
66 OnHostResized(bounds_.size());
67 if (origin_changed)
68 OnHostMoved(bounds_.origin());
69 } 99 }
70 100
71 gfx::Point WindowTreeHostOzone::GetLocationOnNativeScreen() const { 101 gfx::Point WindowTreeHostOzone::GetLocationOnNativeScreen() const {
72 return bounds_.origin(); 102 return platform_window_->GetBounds().origin();
73 } 103 }
74 104
75 void WindowTreeHostOzone::SetCapture() { NOTIMPLEMENTED(); } 105 void WindowTreeHostOzone::SetCapture() {
106 platform_window_->SetCapture();
107 }
76 108
77 void WindowTreeHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); } 109 void WindowTreeHostOzone::ReleaseCapture() {
110 platform_window_->ReleaseCapture();
111 }
78 112
79 void WindowTreeHostOzone::PostNativeEvent( 113 void WindowTreeHostOzone::PostNativeEvent(
80 const base::NativeEvent& native_event) { 114 const base::NativeEvent& native_event) {
81 NOTIMPLEMENTED(); 115 NOTIMPLEMENTED();
82 } 116 }
83 117
84 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) { 118 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) {
85 ui::CursorFactoryOzone::GetInstance()->SetCursor(GetAcceleratedWidget(), 119 ui::CursorFactoryOzone::GetInstance()->SetCursor(GetAcceleratedWidget(),
86 cursor.platform()); 120 cursor.platform());
87 } 121 }
(...skipping 16 matching lines...) Expand all
104 return new WindowTreeHostOzone(bounds); 138 return new WindowTreeHostOzone(bounds);
105 } 139 }
106 140
107 // static 141 // static
108 gfx::Size WindowTreeHost::GetNativeScreenSize() { 142 gfx::Size WindowTreeHost::GetNativeScreenSize() {
109 NOTIMPLEMENTED(); 143 NOTIMPLEMENTED();
110 return gfx::Size(); 144 return gfx::Size();
111 } 145 }
112 146
113 } // namespace aura 147 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698