diff options
author | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 09:13:34 +0000 |
---|---|---|
committer | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 09:13:34 +0000 |
commit | 2d5115433d38fa4f1e70cb7f3164cdb4d26624e2 (patch) | |
tree | 6e4ef250b395c77066db1dc83c47b081f5abb0b7 | |
parent | 44540c2bf35120dd3486898ea43ce5cc9fc6089f (diff) | |
download | chromium_src-2d5115433d38fa4f1e70cb7f3164cdb4d26624e2.zip chromium_src-2d5115433d38fa4f1e70cb7f3164cdb4d26624e2.tar.gz chromium_src-2d5115433d38fa4f1e70cb7f3164cdb4d26624e2.tar.bz2 |
Activate the status area only when it's focused using the keyboard.
ash/status_area/status_area_view.cc:
chrome/browser/chromeos/status/status_area_view.cc:
Override views::WidgetDelegate::CanActivate. Return false unless the area is focused using the keyboard.
ash/system/tray/system_tray.cc:
Handle a mouse event correctly.
ash/wm/activation_controller.cc:
Change the order of kWindowContainerIds[] so that a browser window gets focused when a window in SettingBubbleContainer is closed.
This fix is similar to http://crrev.com/122459 (by sky).
BUG=115815
TEST=aura_shell_unittests
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=125323
Review URL: https://chromiumcodereview.appspot.com/9570013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125368 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/focus_cycler_unittest.cc | 9 | ||||
-rw-r--r-- | ash/shell.h | 3 | ||||
-rw-r--r-- | ash/status_area/status_area_view.cc | 16 | ||||
-rw-r--r-- | ash/status_area/status_area_view.h | 9 | ||||
-rw-r--r-- | ash/system/tray/system_tray.cc | 2 | ||||
-rw-r--r-- | ash/wm/activation_controller.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/status/status_area_view.cc | 25 | ||||
-rw-r--r-- | chrome/browser/chromeos/status/status_area_view.h | 11 | ||||
-rw-r--r-- | chrome/browser/ui/views/ash/status_area_host_aura.cc | 1 |
9 files changed, 71 insertions, 7 deletions
diff --git a/ash/focus_cycler_unittest.cc b/ash/focus_cycler_unittest.cc index 39c53a1..7380463 100644 --- a/ash/focus_cycler_unittest.cc +++ b/ash/focus_cycler_unittest.cc @@ -7,6 +7,7 @@ #include "ash/launcher/launcher.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" +#include "ash/status_area/status_area_view.h" #include "ash/wm/window_util.h" #include "ash/test/ash_test_base.h" #include "ash/shell_factory.h" @@ -47,6 +48,8 @@ TEST_F(FocusCyclerTest, CycleFocusForward) { views::Widget* status_widget = internal::CreateStatusArea(NULL); ASSERT_TRUE(status_widget); focus_cycler->AddWidget(status_widget); + static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())-> + SetFocusCyclerForTesting(focus_cycler.get()); // Add a mock button to the status area. status_widget->GetContentsView()->AddChildView( @@ -88,6 +91,8 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) { views::Widget* status_widget = internal::CreateStatusArea(NULL); ASSERT_TRUE(status_widget); focus_cycler->AddWidget(status_widget); + static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())-> + SetFocusCyclerForTesting(focus_cycler.get()); // Add a mock button to the status area. status_widget->GetContentsView()->AddChildView( @@ -160,6 +165,8 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) { views::Widget* status_widget = internal::CreateStatusArea(NULL); ASSERT_TRUE(status_widget); focus_cycler->AddWidget(status_widget); + static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())-> + SetFocusCyclerForTesting(focus_cycler.get()); // Add a mock button to the status area. status_widget->GetContentsView()->AddChildView( @@ -197,6 +204,8 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) { views::Widget* status_widget = internal::CreateStatusArea(NULL); ASSERT_TRUE(status_widget); focus_cycler->AddWidget(status_widget); + static_cast<internal::StatusAreaView*>(status_widget->GetContentsView())-> + SetFocusCyclerForTesting(focus_cycler.get()); // Add a mock button to the status area. status_widget->GetContentsView()->AddChildView( diff --git a/ash/shell.h b/ash/shell.h index 239df7d..0d27747 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -195,6 +195,9 @@ class ASH_EXPORT Shell { WindowCycleController* window_cycle_controller() { return window_cycle_controller_.get(); } + internal::FocusCycler* focus_cycler() { + return focus_cycler_.get(); + } AudioController* audio_controller() const { return audio_controller_; } diff --git a/ash/status_area/status_area_view.cc b/ash/status_area/status_area_view.cc index fc4a8e0..62b327b 100644 --- a/ash/status_area/status_area_view.cc +++ b/ash/status_area/status_area_view.cc @@ -5,6 +5,7 @@ #include "ash/status_area/status_area_view.h" #include "ash/ash_export.h" +#include "ash/focus_cycler.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "base/utf_string_conversions.h" @@ -20,11 +21,16 @@ namespace internal { StatusAreaView::StatusAreaView() : status_mock_(*ui::ResourceBundle::GetSharedInstance().GetImageNamed( - IDR_AURA_STATUS_MOCK).ToSkBitmap()) { + IDR_AURA_STATUS_MOCK).ToSkBitmap()), + focus_cycler_for_testing_(NULL) { } StatusAreaView::~StatusAreaView() { } +void StatusAreaView::SetFocusCyclerForTesting(const FocusCycler* focus_cycler) { + focus_cycler_for_testing_ = focus_cycler; +} + gfx::Size StatusAreaView::GetPreferredSize() { return gfx::Size(status_mock_.width(), status_mock_.height()); } @@ -37,6 +43,14 @@ const views::Widget* StatusAreaView::GetWidget() const { return View::GetWidget(); } +bool StatusAreaView::CanActivate() const { + // We don't want mouse clicks to activate us, but we need to allow + // activation when the user is using the keyboard (FocusCycler). + const FocusCycler* focus_cycler = focus_cycler_for_testing_ ? + focus_cycler_for_testing_ : Shell::GetInstance()->focus_cycler(); + return focus_cycler->widget_activating() == GetWidget(); +} + void StatusAreaView::OnPaint(gfx::Canvas* canvas) { canvas->DrawBitmapInt(status_mock_, 0, 0); } diff --git a/ash/status_area/status_area_view.h b/ash/status_area/status_area_view.h index 32d9f37..808508f 100644 --- a/ash/status_area/status_area_view.h +++ b/ash/status_area/status_area_view.h @@ -13,21 +13,30 @@ namespace ash { namespace internal { +class FocusCycler; + class StatusAreaView : public views::WidgetDelegate, public views::AccessiblePaneView { public: StatusAreaView(); virtual ~StatusAreaView(); + // Sets the focus cycler. + void SetFocusCyclerForTesting(const FocusCycler* focus_cycler); + // Overridden from views::View: virtual gfx::Size GetPreferredSize() OVERRIDE; virtual views::Widget* GetWidget() OVERRIDE; virtual const views::Widget* GetWidget() const OVERRIDE; + // views::WidgetDelegate overrides: + virtual bool CanActivate() const OVERRIDE; + private: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; SkBitmap status_mock_; + const FocusCycler* focus_cycler_for_testing_; DISALLOW_COPY_AND_ASSIGN(StatusAreaView); }; diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index 192062c..d45b9bd 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -348,7 +348,7 @@ void SystemTray::ShowItems(std::vector<SystemTrayItem*>& items, bool detailed) { bool SystemTray::OnMousePressed(const views::MouseEvent& event) { if (popup_) - popup_->Show(); + popup_->Hide(); else ShowItems(items_, false); return true; diff --git a/ash/wm/activation_controller.cc b/ash/wm/activation_controller.cc index c618436..75fa135 100644 --- a/ash/wm/activation_controller.cc +++ b/ash/wm/activation_controller.cc @@ -28,6 +28,7 @@ const int kWindowContainerIds[] = { kShellWindowId_LockScreenContainer, kShellWindowId_SystemModalContainer, kShellWindowId_AlwaysOnTopContainer, + kShellWindowId_SettingBubbleContainer, kShellWindowId_DefaultContainer, // Panel, launcher and status are intentionally checked after other @@ -36,7 +37,6 @@ const int kWindowContainerIds[] = { kShellWindowId_PanelContainer, kShellWindowId_LauncherContainer, kShellWindowId_StatusContainer, - kShellWindowId_SettingBubbleContainer, }; aura::Window* GetContainer(int id) { diff --git a/chrome/browser/chromeos/status/status_area_view.cc b/chrome/browser/chromeos/status/status_area_view.cc index 98d8f05..def986a 100644 --- a/chrome/browser/chromeos/status/status_area_view.cc +++ b/chrome/browser/chromeos/status/status_area_view.cc @@ -13,8 +13,9 @@ #include "ui/gfx/canvas.h" #include "ui/views/border.h" -#if defined(USE_AURA) -#include "ui/views/widget/widget.h" +#if defined(USE_ASH) +#include "ash/focus_cycler.h" +#include "ash/shell.h" #endif // Number of pixels to separate each icon. @@ -103,6 +104,26 @@ void StatusAreaView::ChildPreferredSizeChanged(View* child) { PreferredSizeChanged(); } +bool StatusAreaView::CanActivate() const { +#if defined(USE_ASH) + // We don't want mouse clicks to activate us, but we need to allow + // activation when the user is using the keyboard (FocusCycler). + ash::internal::FocusCycler* focus_cycler = + ash::Shell::GetInstance()->focus_cycler(); + return focus_cycler->widget_activating() == GetWidget(); +#else + return false; +#endif +} + +views::Widget* StatusAreaView::GetWidget() { + return View::GetWidget(); +} + +const views::Widget* StatusAreaView::GetWidget() const { + return View::GetWidget(); +} + void StatusAreaView::MakeButtonsActive(bool active) { for (std::list<StatusAreaButton*>::iterator iter = buttons_.begin(); iter != buttons_.end(); ++iter) { diff --git a/chrome/browser/chromeos/status/status_area_view.h b/chrome/browser/chromeos/status/status_area_view.h index 72d54ab..196800a 100644 --- a/chrome/browser/chromeos/status/status_area_view.h +++ b/chrome/browser/chromeos/status/status_area_view.h @@ -14,19 +14,21 @@ #include "ui/views/accessible_pane_view.h" #include "ui/views/view.h" #include "ui/views/widget/widget.h" +#include "ui/views/widget/widget_delegate.h" // This class is used to wrap the small informative widgets in the upper-right // of the window title bar. It is used on ChromeOS only. class StatusAreaView : public views::AccessiblePaneView, public views::Widget::Observer, - public base::SupportsWeakPtr<StatusAreaView> { + public base::SupportsWeakPtr<StatusAreaView>, + public views::WidgetDelegate { public: enum ButtonBorder { NO_BORDER, HAS_BORDER }; - explicit StatusAreaView(); + StatusAreaView(); virtual ~StatusAreaView(); void AddButton(StatusAreaButton* button, ButtonBorder border); @@ -51,6 +53,11 @@ class StatusAreaView : public views::AccessiblePaneView, virtual void PreferredSizeChanged() OVERRIDE; virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; + // views::WidgetDelegate overrides: + virtual bool CanActivate() const OVERRIDE; + virtual views::Widget* GetWidget() OVERRIDE; + virtual const views::Widget* GetWidget() const OVERRIDE; + private: // Overridden from views::FocusChangeListener: virtual void OnDidChangeFocus(views::View* focused_before, diff --git a/chrome/browser/ui/views/ash/status_area_host_aura.cc b/chrome/browser/ui/views/ash/status_area_host_aura.cc index e02f3be..a9728ba 100644 --- a/chrome/browser/ui/views/ash/status_area_host_aura.cc +++ b/chrome/browser/ui/views/ash/status_area_host_aura.cc @@ -105,6 +105,7 @@ views::Widget* StatusAreaHostAura::CreateStatusArea() { views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); gfx::Size ps = status_area_view_->GetPreferredSize(); params.bounds = gfx::Rect(0, 0, ps.width(), ps.height()); + params.delegate = status_area_view_; params.parent = status_window; params.transparent = true; status_area_widget_->Init(params); |