diff options
author | mtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-17 04:30:56 +0000 |
---|---|---|
committer | mtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-17 04:30:56 +0000 |
commit | 6b58b286091525e14c29f79a00c2682b2f71462f (patch) | |
tree | d1dcbcd599be4d3eec49d526e66c4ee840826910 /ash/wm/ash_activation_controller.cc | |
parent | f30e3dac09ae32a4d985b6018ef4f0a71257b776 (diff) | |
download | chromium_src-6b58b286091525e14c29f79a00c2682b2f71462f.zip chromium_src-6b58b286091525e14c29f79a00c2682b2f71462f.tar.gz chromium_src-6b58b286091525e14c29f79a00c2682b2f71462f.tar.bz2 |
Yet another approach. Not pretty, but simple and works.
BUG=156772
Review URL: https://chromiumcodereview.appspot.com/11451002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/ash_activation_controller.cc')
-rw-r--r-- | ash/wm/ash_activation_controller.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ash/wm/ash_activation_controller.cc b/ash/wm/ash_activation_controller.cc index f9cc006..261bd62 100644 --- a/ash/wm/ash_activation_controller.cc +++ b/ash/wm/ash_activation_controller.cc @@ -4,13 +4,16 @@ #include "ash/wm/ash_activation_controller.h" +#include "ash/launcher/launcher.h" #include "ash/root_window_controller.h" #include "ash/shell.h" +#include "ash/shell_delegate.h" #include "ash/wm/activation_controller.h" #include "ash/wm/property_util.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace_controller.h" #include "ui/views/corewm/window_modality_controller.h" +#include "ui/views/widget/widget.h" namespace ash { namespace internal { @@ -34,6 +37,10 @@ aura::Window* AshActivationController::WillActivateWindow( if (window_modal_transient) return window_modal_transient; + // Fallback to launcher + if (!window) + window = PrepareToActivateLauncher(); + // Make sure the workspace manager switches to the workspace for window. // Without this CanReceiveEvents() below returns false and activation never // changes. CanReceiveEvents() returns false if |window| isn't in the active @@ -77,5 +84,35 @@ aura::Window* AshActivationController::WillFocusWindow( return window; } +aura::Window* AshActivationController::PrepareToActivateLauncher() { + // If workspace controller is not available, then it means that the root + // window is being destroyed. We can't activate any window then. + if (!GetRootWindowController( + Shell::GetActiveRootWindow())->workspace_controller()) { + return NULL; + } + // Fallback to a launcher only when Spoken feedback is enabled. + if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) + return NULL; + Launcher* launcher; + if (Shell::IsLauncherPerDisplayEnabled()) { + launcher = GetRootWindowController( + Shell::GetActiveRootWindow())->launcher(); + } else { + launcher = Launcher::ForPrimaryDisplay(); + } + // Launcher is not always available, eg. not in the login screen. + if (!launcher) + return NULL; + views::Widget* launcher_widget = launcher->widget(); + // Launcher's window may be already destroyed in shutting down process. + if (!launcher_widget) + return NULL; + aura::Window* launcher_window = launcher_widget->GetNativeWindow(); + // Notify launcher to allow activation via CanActivate(). + launcher->WillActivateAsFallback(); + return launcher_window; +} + } // namespace internal } // namespace ash |