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..023d04cabb9c39baded081b7a7dfe1c9c5bb1c43 100644 |
--- a/components/mus/ws/window_tree_host_impl.cc |
+++ b/components/mus/ws/window_tree_host_impl.cc |
@@ -90,6 +90,11 @@ void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { |
DCHECK(root_window()->Contains(new_focused_window)); |
focus_controller_->SetFocusedWindow(new_focused_window); |
// TODO(beng): have the FocusController notify us via FocusControllerDelegate. |
+ // It is possible that FocusController set the focus to a different window. So |
+ // take that into account before calling into OnFocusChanged(). |
+ new_focused_window = focus_controller_->GetFocusedWindow(); |
+ if (new_focused_window == old_focused_window) |
+ return; |
OnFocusChanged(old_focused_window, new_focused_window); |
} |
@@ -133,6 +138,30 @@ void WindowTreeHostImpl::RemoveAccelerator(uint32_t id) { |
event_dispatcher_.RemoveAccelerator(id); |
} |
+void WindowTreeHostImpl::SetActivationParent(uint32_t window_id, bool enable) { |
+ ServerWindow* window = |
+ connection_manager_->GetWindow(WindowIdFromTransportId(window_id)); |
+ bool wm_misbehaving = false; |
Ben Goodger (Google)
2015/11/19 07:26:24
what's this for?
sadrul
2015/11/19 19:33:34
I would normally do a DCHECK(window) here, but a m
|
+ if (window) { |
+ if (enable) { |
+ auto it = activation_parents_.insert(window->id()); |
+ if (!it.second) |
+ wm_misbehaving = true; |
+ } else { |
+ size_t count = activation_parents_.erase(window->id()); |
+ if (!count) |
+ wm_misbehaving = true; |
+ } |
+ } else { |
+ wm_misbehaving = true; |
+ } |
+ |
+ if (wm_misbehaving) { |
+ // TODO: kill the WM? |
+ NOTREACHED(); |
+ } |
+} |
+ |
void WindowTreeHostImpl::OnClientClosed() { |
// |display_manager_.reset()| destroys the display-manager first, and then |
// sets |display_manager_| to nullptr. However, destroying |display_manager_| |
@@ -185,6 +214,20 @@ void WindowTreeHostImpl::OnCompositorFrameDrawn() { |
} |
} |
+bool WindowTreeHostImpl::CanHaveActiveChildren(ServerWindow* window) const { |
+ return window && activation_parents_.count(window->id()) > 0; |
+} |
+ |
+void WindowTreeHostImpl::OnActivationChanged(ServerWindow* old_active_window, |
+ ServerWindow* new_active_window) { |
+ DCHECK_NE(new_active_window, old_active_window); |
+ if (new_active_window && new_active_window->parent()) { |
+ // Raise the new active window. |
+ // TODO(sad): Let the WM dictate whether to raise the window or not? |
+ new_active_window->parent()->StackChildAtTop(new_active_window); |
Ben Goodger (Google)
2015/11/19 07:26:25
does this account for transients?
sadrul
2015/11/19 19:33:34
StackChildAtTop() etc. account for transients, yep
|
+ } |
+} |
+ |
void WindowTreeHostImpl::OnFocusChanged(ServerWindow* old_focused_window, |
ServerWindow* new_focused_window) { |
// There are up to four connections that need to be notified: |