diff options
-rw-r--r-- | ash/focus_cycler.cc | 4 | ||||
-rw-r--r-- | ash/focus_cycler.h | 7 | ||||
-rw-r--r-- | ash/launcher/app_launcher_button.cc | 2 | ||||
-rw-r--r-- | ash/launcher/launcher.cc | 20 | ||||
-rw-r--r-- | ash/launcher/launcher.h | 7 | ||||
-rw-r--r-- | ash/launcher/launcher_view.cc | 2 | ||||
-rw-r--r-- | ash/launcher/launcher_view.h | 4 | ||||
-rw-r--r-- | ash/launcher/tabbed_launcher_button.cc | 2 | ||||
-rw-r--r-- | ash/shell.cc | 1 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 2 |
10 files changed, 43 insertions, 8 deletions
diff --git a/ash/focus_cycler.cc b/ash/focus_cycler.cc index 25f74f3..eccb992 100644 --- a/ash/focus_cycler.cc +++ b/ash/focus_cycler.cc @@ -17,7 +17,7 @@ namespace ash { namespace internal { -FocusCycler::FocusCycler() { +FocusCycler::FocusCycler() : widget_activating_(NULL) { } FocusCycler::~FocusCycler() { @@ -71,7 +71,9 @@ void FocusCycler::RotateFocus(Direction direction) { views::AccessiblePaneView* view = static_cast<views::AccessiblePaneView*>(widget->GetContentsView()); if (view->SetPaneFocusAndFocusDefault()) { + widget_activating_ = widget; widget->Activate(); + widget_activating_ = NULL; if (widget->IsActive()) break; } diff --git a/ash/focus_cycler.h b/ash/focus_cycler.h index dfdf7e5..c084a98 100644 --- a/ash/focus_cycler.h +++ b/ash/focus_cycler.h @@ -31,6 +31,10 @@ class FocusCycler : public ui::AcceleratorTarget { FocusCycler(); virtual ~FocusCycler(); + // Returns the widget the FocusCycler is attempting to activate or NULL if + // FocusCycler is not activating any widgets. + const views::Widget* widget_activating() const { return widget_activating_; } + // Add a widget to the focus cycle and set up accelerators. The widget needs // to have an AccessiblePaneView as the content view. void AddWidget(views::Widget* widget); @@ -45,6 +49,9 @@ class FocusCycler : public ui::AcceleratorTarget { private: std::vector<views::Widget*> widgets_; + // See description above getter. + views::Widget* widget_activating_; + DISALLOW_COPY_AND_ASSIGN(FocusCycler); }; diff --git a/ash/launcher/app_launcher_button.cc b/ash/launcher/app_launcher_button.cc index cc73255..8bcac90 100644 --- a/ash/launcher/app_launcher_button.cc +++ b/ash/launcher/app_launcher_button.cc @@ -22,7 +22,7 @@ AppLauncherButton::AppLauncherButton(views::ButtonListener* listener, host_(host) { SetImageAlignment(views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); - set_focusable(true); + set_accessibility_focusable(true); } AppLauncherButton::~AppLauncherButton() { diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc index 8bcb15d..f0fe253 100644 --- a/ash/launcher/launcher.cc +++ b/ash/launcher/launcher.cc @@ -4,6 +4,7 @@ #include "ash/launcher/launcher.h" +#include "ash/focus_cycler.h" #include "ash/launcher/launcher_delegate.h" #include "ash/launcher/launcher_model.h" #include "ash/launcher/launcher_view.h" @@ -19,6 +20,7 @@ #include "ui/views/accessible_pane_view.h" #include "ui/views/painter.h" #include "ui/views/widget/widget.h" +#include "ui/views/widget/widget_delegate.h" namespace ash { @@ -56,6 +58,10 @@ class Launcher::DelegateView : public views::WidgetDelegate, void SetStatusWidth(int width); int status_width() const { return status_width_; } + void set_focus_cycler(const internal::FocusCycler* focus_cycler) { + focus_cycler_ = focus_cycler; + } + // views::View overrides virtual gfx::Size GetPreferredSize() OVERRIDE; virtual void Layout() OVERRIDE; @@ -68,15 +74,23 @@ class Launcher::DelegateView : public views::WidgetDelegate, return View::GetWidget(); } + // views::WidgetDelegateView overrides: + 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(); + } private: int status_width_; + const internal::FocusCycler* focus_cycler_; DISALLOW_COPY_AND_ASSIGN(DelegateView); }; Launcher::DelegateView::DelegateView() - : status_width_(0) { + : status_width_(0), + focus_cycler_(NULL) { set_background( views::Background::CreateBackgroundPainter(true, new ShelfPainter())); } @@ -84,6 +98,10 @@ Launcher::DelegateView::DelegateView() Launcher::DelegateView::~DelegateView() { } +void Launcher::SetFocusCycler(const internal::FocusCycler* focus_cycler) { + delegate_view_->set_focus_cycler(focus_cycler); +} + void Launcher::DelegateView::SetStatusWidth(int width) { if (status_width_ == width) return; diff --git a/ash/launcher/launcher.h b/ash/launcher/launcher.h index f910367..9404d2b 100644 --- a/ash/launcher/launcher.h +++ b/ash/launcher/launcher.h @@ -20,6 +20,10 @@ class Widget; namespace ash { +namespace internal { +class FocusCycler; +} + class LauncherDelegate; class LauncherModel; @@ -28,6 +32,9 @@ class ASH_EXPORT Launcher { explicit Launcher(aura::Window* window_container); ~Launcher(); + // Sets the focus cycler. + void SetFocusCycler(const internal::FocusCycler* focus_cycler); + // Sets the width of the status area. void SetStatusWidth(int width); int GetStatusWidth(); diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index b95fcd8..061a560 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -214,7 +214,7 @@ void LauncherView::Init() { } overflow_button_ = new views::ImageButton(this); - overflow_button_->set_focusable(true); + overflow_button_->set_accessibility_focusable(true); overflow_button_->SetImage( views::CustomButton::BS_NORMAL, rb.GetImageNamed(IDR_AURA_LAUNCHER_OVERFLOW).ToSkBitmap()); diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h index f4173b5..d505d0e 100644 --- a/ash/launcher/launcher_view.h +++ b/ash/launcher/launcher_view.h @@ -11,7 +11,7 @@ #include "ash/launcher/launcher_button_host.h" #include "ash/launcher/launcher_model_observer.h" #include "ui/views/controls/button/button.h" -#include "ui/views/widget/widget_delegate.h" +#include "ui/views/view.h" namespace views { class BoundsAnimator; @@ -29,7 +29,7 @@ class ViewModel; namespace internal { -class LauncherView : public views::WidgetDelegateView, +class LauncherView : public views::View, public LauncherModelObserver, public views::ButtonListener, public LauncherButtonHost { diff --git a/ash/launcher/tabbed_launcher_button.cc b/ash/launcher/tabbed_launcher_button.cc index 84d061e..c947144 100644 --- a/ash/launcher/tabbed_launcher_button.cc +++ b/ash/launcher/tabbed_launcher_button.cc @@ -65,7 +65,7 @@ TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener, } SetImageAlignment(views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); - set_focusable(true); + set_accessibility_focusable(true); } TabbedLauncherButton::~TabbedLauncherButton() { diff --git a/ash/shell.cc b/ash/shell.cc index bae8b8f..5be7eec 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -353,6 +353,7 @@ void Shell::Init() { focus_cycler_.reset(new internal::FocusCycler()); focus_cycler_->AddWidget(status_widget_); focus_cycler_->AddWidget(launcher_->widget()); + launcher_->SetFocusCycler(focus_cycler_.get()); // Force a layout. root_window->layout_manager()->OnWindowResized(); diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index c01a2bd..1fadafd 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -765,7 +765,7 @@ void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { // NativeWidgetAura, aura::ActivationDelegate implementation: bool NativeWidgetAura::ShouldActivate(aura::Event* event) { - return can_activate_; + return can_activate_ && delegate_->CanActivate(); } void NativeWidgetAura::OnActivated() { |