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

Side by Side Diff: components/mus/ws/window_tree_host_impl.cc

Issue 1465143004: Converts focusmanager from delegate to observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years 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 | « components/mus/ws/window_tree_host_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "components/mus/ws/window_tree_host_impl.h" 5 #include "components/mus/ws/window_tree_host_impl.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "components/mus/common/types.h" 8 #include "components/mus/common/types.h"
9 #include "components/mus/ws/connection_manager.h" 9 #include "components/mus/ws/connection_manager.h"
10 #include "components/mus/ws/display_manager.h" 10 #include "components/mus/ws/display_manager.h"
(...skipping 12 matching lines...) Expand all
23 mojo::ApplicationImpl* app_impl, 23 mojo::ApplicationImpl* app_impl,
24 const scoped_refptr<GpuState>& gpu_state, 24 const scoped_refptr<GpuState>& gpu_state,
25 const scoped_refptr<SurfacesState>& surfaces_state, 25 const scoped_refptr<SurfacesState>& surfaces_state,
26 mojom::WindowManagerPtr window_manager) 26 mojom::WindowManagerPtr window_manager)
27 : delegate_(nullptr), 27 : delegate_(nullptr),
28 connection_manager_(connection_manager), 28 connection_manager_(connection_manager),
29 client_(client.Pass()), 29 client_(client.Pass()),
30 event_dispatcher_(this), 30 event_dispatcher_(this),
31 display_manager_( 31 display_manager_(
32 DisplayManager::Create(app_impl, gpu_state, surfaces_state)), 32 DisplayManager::Create(app_impl, gpu_state, surfaces_state)),
33 focus_controller_(new FocusController(this)), 33 focus_controller_(new FocusController),
34 window_manager_(window_manager.Pass()) { 34 window_manager_(window_manager.Pass()) {
35 focus_controller_->AddObserver(this);
35 display_manager_->Init(this); 36 display_manager_->Init(this);
36 if (client_) { 37 if (client_) {
37 client_.set_connection_error_handler(base::Bind( 38 client_.set_connection_error_handler(base::Bind(
38 &WindowTreeHostImpl::OnClientClosed, base::Unretained(this))); 39 &WindowTreeHostImpl::OnClientClosed, base::Unretained(this)));
39 } 40 }
40 } 41 }
41 42
42 WindowTreeHostImpl::~WindowTreeHostImpl() { 43 WindowTreeHostImpl::~WindowTreeHostImpl() {
44 DestroyFocusController();
43 for (ServerWindow* window : windows_needing_frame_destruction_) 45 for (ServerWindow* window : windows_needing_frame_destruction_)
44 window->RemoveObserver(this); 46 window->RemoveObserver(this);
45 } 47 }
46 48
47 void WindowTreeHostImpl::Init(WindowTreeHostDelegate* delegate) { 49 void WindowTreeHostImpl::Init(WindowTreeHostDelegate* delegate) {
48 delegate_ = delegate; 50 delegate_ = delegate;
49 if (delegate_ && root_) 51 if (delegate_ && root_)
50 delegate_->OnDisplayInitialized(); 52 delegate_->OnDisplayInitialized();
51 } 53 }
52 54
(...skipping 29 matching lines...) Expand all
82 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { 84 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const {
83 return display_manager_->GetViewportMetrics(); 85 return display_manager_->GetViewportMetrics();
84 } 86 }
85 87
86 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { 88 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) {
87 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); 89 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow();
88 if (old_focused_window == new_focused_window) 90 if (old_focused_window == new_focused_window)
89 return; 91 return;
90 DCHECK(root_window()->Contains(new_focused_window)); 92 DCHECK(root_window()->Contains(new_focused_window));
91 focus_controller_->SetFocusedWindow(new_focused_window); 93 focus_controller_->SetFocusedWindow(new_focused_window);
92 // TODO(beng): have the FocusController notify us via FocusControllerDelegate.
93 OnFocusChanged(old_focused_window, new_focused_window);
94 } 94 }
95 95
96 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() { 96 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() {
97 return focus_controller_->GetFocusedWindow(); 97 return focus_controller_->GetFocusedWindow();
98 } 98 }
99 99
100 void WindowTreeHostImpl::DestroyFocusController() { 100 void WindowTreeHostImpl::DestroyFocusController() {
101 if (!focus_controller_)
102 return;
103
104 focus_controller_->RemoveObserver(this);
101 focus_controller_.reset(); 105 focus_controller_.reset();
102 } 106 }
103 107
104 void WindowTreeHostImpl::UpdateTextInputState(ServerWindow* window, 108 void WindowTreeHostImpl::UpdateTextInputState(ServerWindow* window,
105 const ui::TextInputState& state) { 109 const ui::TextInputState& state) {
106 // Do not need to update text input for unfocused windows. 110 // Do not need to update text input for unfocused windows.
107 if (!display_manager_ || focus_controller_->GetFocusedWindow() != window) 111 if (!display_manager_ || focus_controller_->GetFocusedWindow() != window)
108 return; 112 return;
109 display_manager_->UpdateTextInputState(state); 113 display_manager_->UpdateTextInputState(state);
110 } 114 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 182
179 void WindowTreeHostImpl::OnCompositorFrameDrawn() { 183 void WindowTreeHostImpl::OnCompositorFrameDrawn() {
180 std::set<ServerWindow*> windows; 184 std::set<ServerWindow*> windows;
181 windows.swap(windows_needing_frame_destruction_); 185 windows.swap(windows_needing_frame_destruction_);
182 for (ServerWindow* window : windows) { 186 for (ServerWindow* window : windows) {
183 window->RemoveObserver(this); 187 window->RemoveObserver(this);
184 window->DestroySurfacesScheduledForDestruction(); 188 window->DestroySurfacesScheduledForDestruction();
185 } 189 }
186 } 190 }
187 191
188 void WindowTreeHostImpl::OnFocusChanged(ServerWindow* old_focused_window, 192 void WindowTreeHostImpl::OnFocusChanged(
189 ServerWindow* new_focused_window) { 193 FocusControllerChangeSource change_source,
194 ServerWindow* old_focused_window,
195 ServerWindow* new_focused_window) {
190 // There are up to four connections that need to be notified: 196 // There are up to four connections that need to be notified:
191 // . the connection containing |old_focused_window|. 197 // . the connection containing |old_focused_window|.
192 // . the connection with |old_focused_window| as its root. 198 // . the connection with |old_focused_window| as its root.
193 // . the connection containing |new_focused_window|. 199 // . the connection containing |new_focused_window|.
194 // . the connection with |new_focused_window| as its root. 200 // . the connection with |new_focused_window| as its root.
195 // Some of these connections may be the same. The following takes care to 201 // Some of these connections may be the same. The following takes care to
196 // notify each only once. 202 // notify each only once.
197 WindowTreeImpl* owning_connection_old = nullptr; 203 WindowTreeImpl* owning_connection_old = nullptr;
198 WindowTreeImpl* embedded_connection_old = nullptr; 204 WindowTreeImpl* embedded_connection_old = nullptr;
199 205
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 base::Bind(&base::DoNothing)); 286 base::Bind(&base::DoNothing));
281 } 287 }
282 288
283 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { 289 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) {
284 windows_needing_frame_destruction_.erase(window); 290 windows_needing_frame_destruction_.erase(window);
285 window->RemoveObserver(this); 291 window->RemoveObserver(this);
286 } 292 }
287 293
288 } // namespace ws 294 } // namespace ws
289 } // namespace mus 295 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698