summaryrefslogtreecommitdiffstats
path: root/ash/launcher/launcher.cc
diff options
context:
space:
mode:
authormtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-17 04:30:56 +0000
committermtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-17 04:30:56 +0000
commit6b58b286091525e14c29f79a00c2682b2f71462f (patch)
treed1dcbcd599be4d3eec49d526e66c4ee840826910 /ash/launcher/launcher.cc
parentf30e3dac09ae32a4d985b6018ef4f0a71257b776 (diff)
downloadchromium_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/launcher/launcher.cc')
-rw-r--r--ash/launcher/launcher.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc
index 8668879..a73f402 100644
--- a/ash/launcher/launcher.cc
+++ b/ash/launcher/launcher.cc
@@ -19,6 +19,7 @@
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "grit/ash_resources.h"
+#include "ui/aura/client/activation_client.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
@@ -68,9 +69,14 @@ class Launcher::DelegateView : public views::WidgetDelegate,
return View::GetWidget();
}
virtual bool CanActivate() const OVERRIDE {
- // We don't want mouse clicks to activate us, but we need to allow
- // activation when the user is using the keyboard (FocusCycler).
- return focus_cycler_ && focus_cycler_->widget_activating() == GetWidget();
+ // Allow to activate as fallback.
+ if (launcher_->activating_as_fallback_)
+ return true;
+ // Allow to activate from the focus cycler.
+ if (focus_cycler_ && focus_cycler_->widget_activating() == GetWidget())
+ return true;
+ // Disallow activating in other cases, especially when using mouse.
+ return false;
}
// BackgroundAnimatorDelegate overrides:
@@ -209,7 +215,8 @@ Launcher::Launcher(LauncherModel* launcher_model,
launcher_view_(NULL),
alignment_(SHELF_ALIGNMENT_BOTTOM),
delegate_(launcher_delegate),
- background_animator_(delegate_view_, 0, kLauncherBackgroundAlpha) {
+ background_animator_(delegate_view_, 0, kLauncherBackgroundAlpha),
+ activating_as_fallback_(false) {
widget_.reset(new views::Widget);
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
@@ -236,9 +243,12 @@ Launcher::Launcher(LauncherModel* launcher_model,
gfx::Size pref =
static_cast<views::View*>(launcher_view_)->GetPreferredSize();
widget_->SetBounds(gfx::Rect(pref));
+
+ widget_->AddObserver(this);
}
Launcher::~Launcher() {
+ widget_->RemoveObserver(this);
}
// static
@@ -406,6 +416,15 @@ void Launcher::SwitchToWindow(int window_index) {
}
}
+void Launcher::OnWidgetActivationChanged(views::Widget* widget, bool active) {
+ activating_as_fallback_ = false;
+ if (active) {
+ delegate_view_->SetPaneFocusAndFocusDefault();
+ } else {
+ delegate_view_->GetFocusManager()->ClearFocus();
+ }
+}
+
internal::LauncherView* Launcher::GetLauncherViewForTest() {
return launcher_view_;
}