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

Side by Side Diff: ash/host/ash_window_tree_host_unified.cc

Issue 1107733006: Unified Desktop: hook up ash to allow unified desktop mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AshWindowTreeHostUnified Created 5 years, 8 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
« no previous file with comments | « ash/host/ash_window_tree_host_unified.h ('k') | ash/host/ash_window_tree_host_x11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 "ash/host/ash_window_tree_host_unified.h"
6 #include "ash/host/root_window_transformer.h"
7 #include "base/logging.h"
8 #include "ui/aura/window.h"
9 #include "ui/aura/window_event_dispatcher.h"
10 #include "ui/aura/window_targeter.h"
11 #include "ui/compositor/compositor.h"
12 #include "ui/events/event_processor.h"
13 #include "ui/gfx/geometry/insets.h"
14
15 namespace ash {
16
17 class UnifiedEventTargeter : public aura::WindowTargeter {
18 public:
19 UnifiedEventTargeter(aura::Window* src_root, aura::Window* dst_root)
20 : src_root_(src_root), dst_root_(dst_root) {}
21
22 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root,
23 ui::Event* event) override {
24 if (root == src_root_ && !event->target()) {
25 if (event->IsLocatedEvent()) {
26 ui::LocatedEvent* located_event = static_cast<ui::LocatedEvent*>(event);
27 located_event->ConvertLocationToTarget(
28 static_cast<aura::Window*>(nullptr), dst_root_);
29 located_event->UpdateForRootTransform(
30 dst_root_->GetHost()->GetRootTransform());
31 }
32 ignore_result(
33 dst_root_->GetHost()->event_processor()->OnEventFromSource(event));
34 return nullptr;
35 } else {
36 LOG(ERROR) << "Handling Event:" << event->type();
37 return aura::WindowTargeter::FindTargetForEvent(root, event);
38 }
39 }
40
41 aura::Window* src_root_;
42 aura::Window* dst_root_;
43
44 DISALLOW_COPY_AND_ASSIGN(UnifiedEventTargeter);
45 };
46
47 AshWindowTreeHostUnified::AshWindowTreeHostUnified(
48 const gfx::Rect& initial_bounds)
49 : bounds_(gfx::Rect(initial_bounds.size())) {
50 CreateCompositor(GetAcceleratedWidget());
51 }
52
53 AshWindowTreeHostUnified::~AshWindowTreeHostUnified() {
54 DestroyCompositor();
55 DestroyDispatcher();
56 }
57
58 void AshWindowTreeHostUnified::PrepareForShutdown() {
59 for (auto host : mirroring_hosts_)
60 host->PrepareForShutdown();
61 }
62
63 void AshWindowTreeHostUnified::RegisterMirroringHost(
64 AshWindowTreeHost* mirroring_ash_host) {
65 aura::Window* src_root = mirroring_ash_host->AsWindowTreeHost()->window();
66 src_root->SetEventTargeter(
67 make_scoped_ptr(new UnifiedEventTargeter(src_root, window())));
68 DCHECK(std::find(mirroring_hosts_.begin(), mirroring_hosts_.end(),
69 mirroring_ash_host) == mirroring_hosts_.end());
70 mirroring_hosts_.push_back(mirroring_ash_host);
71 mirroring_ash_host->AsWindowTreeHost()->window()->AddObserver(this);
72 }
73
74 void AshWindowTreeHostUnified::ToggleFullScreen() {
75 }
76
77 bool AshWindowTreeHostUnified::ConfineCursorToRootWindow() {
78 return true;
79 }
80
81 void AshWindowTreeHostUnified::UnConfineCursor() {
82 }
83
84 void AshWindowTreeHostUnified::SetRootWindowTransformer(
85 scoped_ptr<RootWindowTransformer> transformer) {
86 // TODO(oshima): Find out if this is neceessary.
87 NOTIMPLEMENTED();
88 }
89
90 gfx::Insets AshWindowTreeHostUnified::GetHostInsets() const {
91 return gfx::Insets();
92 }
93
94 aura::WindowTreeHost* AshWindowTreeHostUnified::AsWindowTreeHost() {
95 return this;
96 }
97
98 ui::EventSource* AshWindowTreeHostUnified::GetEventSource() {
99 return this;
100 }
101
102 gfx::AcceleratedWidget AshWindowTreeHostUnified::GetAcceleratedWidget() {
103 // TODO(oshima): Enable offscreen compositor.
104 return gfx::kNullAcceleratedWidget;
105 }
106
107 void AshWindowTreeHostUnified::Show() {
108 }
109
110 void AshWindowTreeHostUnified::Hide() {
111 }
112
113 gfx::Rect AshWindowTreeHostUnified::GetBounds() const {
114 return bounds_;
115 }
116
117 void AshWindowTreeHostUnified::SetBounds(const gfx::Rect& bounds) {
118 if (bounds_.size() == bounds.size())
119 return;
120 bounds_.set_size(bounds.size());
121 OnHostResized(bounds_.size());
122 }
123
124 void AshWindowTreeHostUnified::SetCapture() {
125 }
126
127 void AshWindowTreeHostUnified::ReleaseCapture() {
128 }
129
130 gfx::Point AshWindowTreeHostUnified::GetLocationOnNativeScreen() const {
131 return gfx::Point();
132 }
133
134 void AshWindowTreeHostUnified::SetCursorNative(gfx::NativeCursor cursor) {
135 for (auto host : mirroring_hosts_)
136 host->AsWindowTreeHost()->SetCursor(cursor);
137 }
138
139 void AshWindowTreeHostUnified::MoveCursorToNative(const gfx::Point& location) {
140 // TODO(oshima): Find out if this is neceessary.
141 NOTIMPLEMENTED();
142 }
143
144 void AshWindowTreeHostUnified::OnCursorVisibilityChangedNative(bool show) {
145 for (auto host : mirroring_hosts_)
146 host->AsWindowTreeHost()->OnCursorVisibilityChanged(show);
147 }
148
149 void AshWindowTreeHostUnified::OnWindowDestroying(aura::Window* window) {
150 auto iter =
151 std::find_if(mirroring_hosts_.begin(), mirroring_hosts_.end(),
152 [window](AshWindowTreeHost* ash_host) {
153 return ash_host->AsWindowTreeHost()->window() == window;
154 });
155 DCHECK(iter != mirroring_hosts_.end());
156 window->RemoveObserver(this);
157 mirroring_hosts_.erase(iter);
158 }
159
160 ui::EventProcessor* AshWindowTreeHostUnified::GetEventProcessor() {
161 return dispatcher();
162 }
163
164 } // namespace ash
OLDNEW
« no previous file with comments | « ash/host/ash_window_tree_host_unified.h ('k') | ash/host/ash_window_tree_host_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698