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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/mus/ws/window_tree_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/window_tree_host_impl.cc
diff --git a/components/mus/ws/window_tree_host_impl.cc b/components/mus/ws/window_tree_host_impl.cc
index 6f84e0e7ce9a551682956f3cc26a1a966f61c071..0f2e33a75667d3d95a6ce773b26d65ee9eb02bca 100644
--- a/components/mus/ws/window_tree_host_impl.cc
+++ b/components/mus/ws/window_tree_host_impl.cc
@@ -30,8 +30,9 @@ WindowTreeHostImpl::WindowTreeHostImpl(
event_dispatcher_(this),
display_manager_(
DisplayManager::Create(app_impl, gpu_state, surfaces_state)),
- focus_controller_(new FocusController(this)),
+ focus_controller_(new FocusController),
window_manager_(window_manager.Pass()) {
+ focus_controller_->AddObserver(this);
display_manager_->Init(this);
if (client_) {
client_.set_connection_error_handler(base::Bind(
@@ -40,6 +41,7 @@ WindowTreeHostImpl::WindowTreeHostImpl(
}
WindowTreeHostImpl::~WindowTreeHostImpl() {
+ DestroyFocusController();
for (ServerWindow* window : windows_needing_frame_destruction_)
window->RemoveObserver(this);
}
@@ -89,8 +91,6 @@ void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) {
return;
DCHECK(root_window()->Contains(new_focused_window));
focus_controller_->SetFocusedWindow(new_focused_window);
- // TODO(beng): have the FocusController notify us via FocusControllerDelegate.
- OnFocusChanged(old_focused_window, new_focused_window);
}
ServerWindow* WindowTreeHostImpl::GetFocusedWindow() {
@@ -98,6 +98,10 @@ ServerWindow* WindowTreeHostImpl::GetFocusedWindow() {
}
void WindowTreeHostImpl::DestroyFocusController() {
+ if (!focus_controller_)
+ return;
+
+ focus_controller_->RemoveObserver(this);
focus_controller_.reset();
}
@@ -185,8 +189,10 @@ void WindowTreeHostImpl::OnCompositorFrameDrawn() {
}
}
-void WindowTreeHostImpl::OnFocusChanged(ServerWindow* old_focused_window,
- ServerWindow* new_focused_window) {
+void WindowTreeHostImpl::OnFocusChanged(
+ FocusControllerChangeSource change_source,
+ ServerWindow* old_focused_window,
+ ServerWindow* new_focused_window) {
// There are up to four connections that need to be notified:
// . the connection containing |old_focused_window|.
// . the connection with |old_focused_window| as its root.
« 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