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

Side by Side Diff: ui/views/corewm/focus_controller.cc

Issue 14222019: Trying to activate a window in a workspace other than the current is ignored while a system modal d… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nits Created 7 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 | « ui/views/corewm/focus_controller.h ('k') | ui/views/corewm/focus_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/corewm/focus_controller.h" 5 #include "ui/views/corewm/focus_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "ui/aura/client/activation_change_observer.h" 8 #include "ui/aura/client/activation_change_observer.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/capture_client.h" 10 #include "ui/aura/client/capture_client.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // focus. "Clearing focus" is inferred by whether or not |window| passed to 144 // focus. "Clearing focus" is inferred by whether or not |window| passed to
145 // this function is non-NULL. 145 // this function is non-NULL.
146 if (window && (!focusable || !activatable)) 146 if (window && (!focusable || !activatable))
147 return; 147 return;
148 DCHECK((focusable && activatable) || !window); 148 DCHECK((focusable && activatable) || !window);
149 149
150 // Activation change observers may change the focused window. If this happens 150 // Activation change observers may change the focused window. If this happens
151 // we must not adjust the focus below since this will clobber that change. 151 // we must not adjust the focus below since this will clobber that change.
152 aura::Window* last_focused_window = focused_window_; 152 aura::Window* last_focused_window = focused_window_;
153 if (!updating_activation_) 153 if (!updating_activation_)
154 SetActiveWindow(activatable); 154 SetActiveWindow(window, activatable);
155 155
156 // If the window's ActivationChangeObserver shifted focus to a valid window, 156 // If the window's ActivationChangeObserver shifted focus to a valid window,
157 // we don't want to focus the window we thought would be focused by default. 157 // we don't want to focus the window we thought would be focused by default.
158 bool activation_changed_focus = last_focused_window != focused_window_; 158 bool activation_changed_focus = last_focused_window != focused_window_;
159 if (!updating_focus_ && (!activation_changed_focus || !focused_window_)) { 159 if (!updating_focus_ && (!activation_changed_focus || !focused_window_)) {
160 if (active_window_ && focusable) 160 if (active_window_ && focusable)
161 DCHECK(active_window_->Contains(focusable)); 161 DCHECK(active_window_->Contains(focusable));
162 SetFocusedWindow(focusable); 162 SetFocusedWindow(focusable);
163 } 163 }
164 } 164 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 OnWindowFocused(focused_window_, lost_focus)); 272 OnWindowFocused(focused_window_, lost_focus));
273 aura::client::FocusChangeObserver* observer = 273 aura::client::FocusChangeObserver* observer =
274 aura::client::GetFocusChangeObserver(lost_focus); 274 aura::client::GetFocusChangeObserver(lost_focus);
275 if (observer) 275 if (observer)
276 observer->OnWindowFocused(focused_window_, lost_focus); 276 observer->OnWindowFocused(focused_window_, lost_focus);
277 observer = aura::client::GetFocusChangeObserver(focused_window_); 277 observer = aura::client::GetFocusChangeObserver(focused_window_);
278 if (observer) 278 if (observer)
279 observer->OnWindowFocused(focused_window_, lost_focus); 279 observer->OnWindowFocused(focused_window_, lost_focus);
280 } 280 }
281 281
282 void FocusController::SetActiveWindow(aura::Window* window) { 282 void FocusController::SetActiveWindow(aura::Window* requested_window,
283 if (updating_activation_ || window == active_window_) 283 aura::Window* window) {
284 if (updating_activation_)
284 return; 285 return;
285 286
287 if (window == active_window_) {
288 if (requested_window) {
289 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver,
290 activation_observers_,
291 OnAttemptToReactivateWindow(requested_window,
292 active_window_));
293 }
294 return;
295 }
296
286 DCHECK(rules_->CanActivateWindow(window)); 297 DCHECK(rules_->CanActivateWindow(window));
287 if (window) 298 if (window)
288 DCHECK_EQ(window, rules_->GetActivatableWindow(window)); 299 DCHECK_EQ(window, rules_->GetActivatableWindow(window));
289 300
290 base::AutoReset<bool> updating_activation(&updating_activation_, true); 301 base::AutoReset<bool> updating_activation(&updating_activation_, true);
291 aura::Window* lost_activation = active_window_; 302 aura::Window* lost_activation = active_window_;
292 if (active_window_ && observer_manager_.IsObserving(active_window_) && 303 if (active_window_ && observer_manager_.IsObserving(active_window_) &&
293 focused_window_ != active_window_) { 304 focused_window_ != active_window_) {
294 observer_manager_.Remove(active_window_); 305 observer_manager_.Remove(active_window_);
295 } 306 }
(...skipping 23 matching lines...) Expand all
319 // A window's modality state will interfere with focus restoration during its 330 // A window's modality state will interfere with focus restoration during its
320 // destruction. 331 // destruction.
321 window->ClearProperty(aura::client::kModalKey); 332 window->ClearProperty(aura::client::kModalKey);
322 // TODO(beng): See if this function can be replaced by a call to 333 // TODO(beng): See if this function can be replaced by a call to
323 // FocusWindow(). 334 // FocusWindow().
324 // Activation adjustments are handled first in the event of a disposition 335 // Activation adjustments are handled first in the event of a disposition
325 // changed. If an activation change is necessary, focus is reset as part of 336 // changed. If an activation change is necessary, focus is reset as part of
326 // that process so there's no point in updating focus independently. 337 // that process so there's no point in updating focus independently.
327 if (window == active_window_) { 338 if (window == active_window_) {
328 aura::Window* next_activatable = rules_->GetNextActivatableWindow(window); 339 aura::Window* next_activatable = rules_->GetNextActivatableWindow(window);
329 SetActiveWindow(next_activatable); 340 SetActiveWindow(NULL, next_activatable);
330 if (!(active_window_ && active_window_->Contains(focused_window_))) 341 if (!(active_window_ && active_window_->Contains(focused_window_)))
331 SetFocusedWindow(next_activatable); 342 SetFocusedWindow(next_activatable);
332 } else if (window->Contains(focused_window_)) { 343 } else if (window->Contains(focused_window_)) {
333 // Active window isn't changing, but focused window might be. 344 // Active window isn't changing, but focused window might be.
334 SetFocusedWindow(rules_->GetFocusableWindow(next)); 345 SetFocusedWindow(rules_->GetFocusableWindow(next));
335 } 346 }
336 } 347 }
337 348
338 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { 349 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) {
339 // Only focus |window| if it or any of its parents can be focused. Otherwise 350 // Only focus |window| if it or any of its parents can be focused. Otherwise
340 // FocusWindow() will focus the topmost window, which may not be the 351 // FocusWindow() will focus the topmost window, which may not be the
341 // currently focused one. 352 // currently focused one.
342 if (rules_->CanFocusWindow(GetToplevelWindow(window))) 353 if (rules_->CanFocusWindow(GetToplevelWindow(window)))
343 FocusWindow(window); 354 FocusWindow(window);
344 } 355 }
345 356
346 } // namespace corewm 357 } // namespace corewm
347 } // namespace views 358 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/focus_controller.h ('k') | ui/views/corewm/focus_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698