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

Unified Diff: ui/views/corewm/focus_controller.cc

Issue 75933005: Makes FocusdController honor focus change if no previously active window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | « no previous file | ui/views/corewm/focus_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/corewm/focus_controller.cc
diff --git a/ui/views/corewm/focus_controller.cc b/ui/views/corewm/focus_controller.cc
index 8c05ac26f324454016ad66d05224304424f5c2c8..e9aa101d20d9a83ceac285e2618eae4052dff679 100644
--- a/ui/views/corewm/focus_controller.cc
+++ b/ui/views/corewm/focus_controller.cc
@@ -153,13 +153,21 @@ void FocusController::FocusWindow(aura::Window* window) {
// Activation change observers may change the focused window. If this happens
// we must not adjust the focus below since this will clobber that change.
aura::Window* last_focused_window = focused_window_;
+ aura::Window* last_active_window = active_window_;
if (!updating_activation_)
SetActiveWindow(window, activatable);
// If the window's ActivationChangeObserver shifted focus to a valid window,
// we don't want to focus the window we thought would be focused by default.
+ //
+ // Allow the request through if there was previously no active window. When
+ // there is no active window and an attempt is made to activate a window views
+ // may try to restore focus to the view (and thereby window) that previously
+ // had focus. In this case we want to focus the window passed to this function
+ // and not the previously focused window.
bool activation_changed_focus = last_focused_window != focused_window_;
- if (!updating_focus_ && (!activation_changed_focus || !focused_window_)) {
+ if (!updating_focus_ && (!activation_changed_focus || !focused_window_ ||
+ !last_active_window)) {
if (active_window_ && focusable)
DCHECK(active_window_->Contains(focusable));
SetFocusedWindow(focusable);
« no previous file with comments | « no previous file | ui/views/corewm/focus_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698