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

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: reduced 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
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 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver,
sky 2013/04/23 21:36:42 I think it's only worth invoking this when request
sschmitz 2013/04/24 01:23:43 Done.
289 activation_observers_,
290 OnAttemptToReactivateWindow(requested_window,
291 active_window_));
292 return;
293 }
294
286 DCHECK(rules_->CanActivateWindow(window)); 295 DCHECK(rules_->CanActivateWindow(window));
287 if (window) 296 if (window)
288 DCHECK_EQ(window, rules_->GetActivatableWindow(window)); 297 DCHECK_EQ(window, rules_->GetActivatableWindow(window));
289 298
290 base::AutoReset<bool> updating_activation(&updating_activation_, true); 299 base::AutoReset<bool> updating_activation(&updating_activation_, true);
291 aura::Window* lost_activation = active_window_; 300 aura::Window* lost_activation = active_window_;
292 if (active_window_ && observer_manager_.IsObserving(active_window_) && 301 if (active_window_ && observer_manager_.IsObserving(active_window_) &&
293 focused_window_ != active_window_) { 302 focused_window_ != active_window_) {
294 observer_manager_.Remove(active_window_); 303 observer_manager_.Remove(active_window_);
295 } 304 }
(...skipping 23 matching lines...) Expand all
319 // A window's modality state will interfere with focus restoration during its 328 // A window's modality state will interfere with focus restoration during its
320 // destruction. 329 // destruction.
321 window->ClearProperty(aura::client::kModalKey); 330 window->ClearProperty(aura::client::kModalKey);
322 // TODO(beng): See if this function can be replaced by a call to 331 // TODO(beng): See if this function can be replaced by a call to
323 // FocusWindow(). 332 // FocusWindow().
324 // Activation adjustments are handled first in the event of a disposition 333 // 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 334 // 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. 335 // that process so there's no point in updating focus independently.
327 if (window == active_window_) { 336 if (window == active_window_) {
328 aura::Window* next_activatable = rules_->GetNextActivatableWindow(window); 337 aura::Window* next_activatable = rules_->GetNextActivatableWindow(window);
329 SetActiveWindow(next_activatable); 338 SetActiveWindow(NULL, next_activatable);
330 if (!(active_window_ && active_window_->Contains(focused_window_))) 339 if (!(active_window_ && active_window_->Contains(focused_window_)))
331 SetFocusedWindow(next_activatable); 340 SetFocusedWindow(next_activatable);
332 } else if (window->Contains(focused_window_)) { 341 } else if (window->Contains(focused_window_)) {
333 // Active window isn't changing, but focused window might be. 342 // Active window isn't changing, but focused window might be.
334 SetFocusedWindow(rules_->GetFocusableWindow(next)); 343 SetFocusedWindow(rules_->GetFocusableWindow(next));
335 } 344 }
336 } 345 }
337 346
338 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { 347 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) {
339 // Only focus |window| if it or any of its parents can be focused. Otherwise 348 // 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 349 // FocusWindow() will focus the topmost window, which may not be the
341 // currently focused one. 350 // currently focused one.
342 if (rules_->CanFocusWindow(GetToplevelWindow(window))) 351 if (rules_->CanFocusWindow(GetToplevelWindow(window)))
343 FocusWindow(window); 352 FocusWindow(window);
344 } 353 }
345 354
346 } // namespace corewm 355 } // namespace corewm
347 } // namespace views 356 } // namespace views
OLDNEW
« ui/views/corewm/focus_controller.h ('K') | « ui/views/corewm/focus_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698