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

Side by Side Diff: ash/wm/ash_activation_controller.cc

Issue 11594004: Revert 173417 - Broke on win_aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/ash_activation_controller.h ('k') | ash/wm/ash_activation_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 "ash/wm/ash_activation_controller.h" 5 #include "ash/wm/ash_activation_controller.h"
6 6
7 #include "ash/launcher/launcher.h"
8 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
9 #include "ash/shell.h" 8 #include "ash/shell.h"
10 #include "ash/shell_delegate.h"
11 #include "ash/wm/activation_controller.h" 9 #include "ash/wm/activation_controller.h"
12 #include "ash/wm/property_util.h" 10 #include "ash/wm/property_util.h"
13 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
14 #include "ash/wm/workspace_controller.h" 12 #include "ash/wm/workspace_controller.h"
15 #include "ui/views/corewm/window_modality_controller.h" 13 #include "ui/views/corewm/window_modality_controller.h"
16 #include "ui/views/widget/widget.h"
17 14
18 namespace ash { 15 namespace ash {
19 namespace internal { 16 namespace internal {
20 17
21 //////////////////////////////////////////////////////////////////////////////// 18 ////////////////////////////////////////////////////////////////////////////////
22 // AshActivationController, public: 19 // AshActivationController, public:
23 20
24 AshActivationController::AshActivationController() { 21 AshActivationController::AshActivationController() {
25 } 22 }
26 23
27 AshActivationController::~AshActivationController() { 24 AshActivationController::~AshActivationController() {
28 } 25 }
29 26
30 //////////////////////////////////////////////////////////////////////////////// 27 ////////////////////////////////////////////////////////////////////////////////
31 // AshActivationController, ActivationControllerDelegate implementation: 28 // AshActivationController, ActivationControllerDelegate implementation:
32 29
33 aura::Window* AshActivationController::WillActivateWindow( 30 aura::Window* AshActivationController::WillActivateWindow(
34 aura::Window* window) { 31 aura::Window* window) {
35 aura::Window* window_modal_transient = 32 aura::Window* window_modal_transient =
36 views::corewm::GetModalTransient(window); 33 views::corewm::GetModalTransient(window);
37 if (window_modal_transient) 34 if (window_modal_transient)
38 return window_modal_transient; 35 return window_modal_transient;
39 36
40 // Fallback to launcher
41 if (!window)
42 window = PrepareToActivateLauncher();
43
44 // Make sure the workspace manager switches to the workspace for window. 37 // Make sure the workspace manager switches to the workspace for window.
45 // Without this CanReceiveEvents() below returns false and activation never 38 // Without this CanReceiveEvents() below returns false and activation never
46 // changes. CanReceiveEvents() returns false if |window| isn't in the active 39 // changes. CanReceiveEvents() returns false if |window| isn't in the active
47 // workspace, in which case its parent is not visible. 40 // workspace, in which case its parent is not visible.
48 // TODO(sky): if I instead change the opacity of the parent this isn't an 41 // TODO(sky): if I instead change the opacity of the parent this isn't an
49 // issue, but will make animations trickier... Consider which one is better. 42 // issue, but will make animations trickier... Consider which one is better.
50 if (window) { 43 if (window) {
51 internal::RootWindowController* root_window_controller = 44 internal::RootWindowController* root_window_controller =
52 GetRootWindowController(window->GetRootWindow()); 45 GetRootWindowController(window->GetRootWindow());
53 root_window_controller->workspace_controller()-> 46 root_window_controller->workspace_controller()->
(...skipping 23 matching lines...) Expand all
77 70
78 aura::Window* AshActivationController::WillFocusWindow( 71 aura::Window* AshActivationController::WillFocusWindow(
79 aura::Window* window) { 72 aura::Window* window) {
80 aura::Window* window_modal_transient = 73 aura::Window* window_modal_transient =
81 views::corewm::GetModalTransient(window); 74 views::corewm::GetModalTransient(window);
82 if (window_modal_transient) 75 if (window_modal_transient)
83 return window_modal_transient; 76 return window_modal_transient;
84 return window; 77 return window;
85 } 78 }
86 79
87 aura::Window* AshActivationController::PrepareToActivateLauncher() {
88 // If workspace controller is not available, then it means that the root
89 // window is being destroyed. We can't activate any window then.
90 if (!GetRootWindowController(
91 Shell::GetActiveRootWindow())->workspace_controller()) {
92 return NULL;
93 }
94 // Fallback to a launcher only when Spoken feedback is enabled.
95 if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled())
96 return NULL;
97 Launcher* launcher;
98 if (Shell::IsLauncherPerDisplayEnabled()) {
99 launcher = GetRootWindowController(
100 Shell::GetActiveRootWindow())->launcher();
101 } else {
102 launcher = Launcher::ForPrimaryDisplay();
103 }
104 // Launcher is not always available, eg. not in the login screen.
105 if (!launcher)
106 return NULL;
107 views::Widget* launcher_widget = launcher->widget();
108 // Launcher's window may be already destroyed in shutting down process.
109 if (!launcher_widget)
110 return NULL;
111 aura::Window* launcher_window = launcher_widget->GetNativeWindow();
112 // Notify launcher to allow activation via CanActivate().
113 launcher->WillActivateAsFallback();
114 return launcher_window;
115 }
116
117 } // namespace internal 80 } // namespace internal
118 } // namespace ash 81 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/ash_activation_controller.h ('k') | ash/wm/ash_activation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698