diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 21:26:06 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 21:26:06 +0000 |
commit | 0634f5e4af77b4452adf3c82830b316b220b670e (patch) | |
tree | 32ee3a668a6ea5d159719430c0720df28e0e58d2 /ash | |
parent | 687853ca42589575a5f90006deb3cf702bf77ee3 (diff) | |
download | chromium_src-0634f5e4af77b4452adf3c82830b316b220b670e.zip chromium_src-0634f5e4af77b4452adf3c82830b316b220b670e.tar.gz chromium_src-0634f5e4af77b4452adf3c82830b316b220b670e.tar.bz2 |
ash: Focus tray with shift-alt-s
BUG=120177
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9855029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/accelerators/accelerator_controller.cc | 6 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.cc | 1 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.h | 1 | ||||
-rw-r--r-- | ash/focus_cycler.cc | 28 | ||||
-rw-r--r-- | ash/focus_cycler.h | 3 |
5 files changed, 28 insertions, 11 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 45bb164..afaaf9a 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -8,6 +8,7 @@ #include "ash/desktop_background/desktop_background_controller.h" #include "ash/ash_switches.h" #include "ash/caps_lock_delegate.h" +#include "ash/focus_cycler.h" #include "ash/ime_control_delegate.h" #include "ash/launcher/launcher.h" #include "ash/launcher/launcher_model.h" @@ -18,6 +19,7 @@ #include "ash/shell_delegate.h" #include "ash/shell_window_ids.h" #include "ash/system/brightness/brightness_control_delegate.h" +#include "ash/system/tray/system_tray.h" #include "ash/volume_control_delegate.h" #include "ash/wm/window_cycle_controller.h" #include "ash/wm/window_util.h" @@ -382,6 +384,10 @@ bool AcceleratorController::AcceleratorPressed( if (volume_control_delegate_.get()) return volume_control_delegate_->HandleVolumeUp(accelerator); break; + case FOCUS_TRAY: + if (shell->tray()) + return shell->focus_cycler()->FocusWidget(shell->tray()->GetWidget()); + break; case SHOW_OAK: if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshEnableOak)) oak::ShowOakWindow(); diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc index 4cee473..5c9438d 100644 --- a/ash/accelerators/accelerator_table.cc +++ b/ash/accelerators/accelerator_table.cc @@ -70,6 +70,7 @@ const AcceleratorData kAcceleratorData[] = { { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_F10, false, false, false, VOLUME_UP }, { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_VOLUME_UP, false, false, false, VOLUME_UP }, + { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_S, true, false, true, FOCUS_TRAY }, { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_F1, true, true, false, SHOW_OAK }, { ui::ET_TRANSLATED_KEY_PRESS, ui::VKEY_1, false, false, true, SELECT_WIN_0 }, diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h index c009f2e..d28b6fc 100644 --- a/ash/accelerators/accelerator_table.h +++ b/ash/accelerators/accelerator_table.h @@ -31,6 +31,7 @@ enum AcceleratorAction { VOLUME_MUTE, VOLUME_UP, SHOW_OAK, + FOCUS_TRAY, #if defined(OS_CHROMEOS) LOCK_SCREEN, #endif diff --git a/ash/focus_cycler.cc b/ash/focus_cycler.cc index 9c4dab1..242aab4 100644 --- a/ash/focus_cycler.cc +++ b/ash/focus_cycler.cc @@ -6,6 +6,7 @@ #include "ash/shell.h" #include "ash/shell_delegate.h" +#include "ash/system/tray/system_tray.h" #include "ui/views/widget/widget.h" #include "ui/views/focus/focus_search.h" #include "ui/aura/window.h" @@ -71,21 +72,25 @@ void FocusCycler::RotateFocus(Direction direction) { break; } } else { - views::Widget* widget = widgets_[index]; - - views::AccessiblePaneView* view = - static_cast<views::AccessiblePaneView*>(widget->GetContentsView()); - if (view->SetPaneFocusAndFocusDefault()) { - widget_activating_ = widget; - widget->Activate(); - widget_activating_ = NULL; - if (widget->IsActive()) - break; - } + if (FocusWidget(widgets_[index])) + break; } } } +bool FocusCycler::FocusWidget(views::Widget* widget) { + views::AccessiblePaneView* view = + static_cast<views::AccessiblePaneView*>(widget->GetContentsView()); + if (view->SetPaneFocusAndFocusDefault()) { + widget_activating_ = widget; + widget->Activate(); + widget_activating_ = NULL; + if (widget->IsActive()) + return true; + } + return false; +} + bool FocusCycler::AcceleratorPressed(const ui::Accelerator& accelerator) { switch (accelerator.key_code()) { case ui::VKEY_F1: @@ -95,6 +100,7 @@ bool FocusCycler::AcceleratorPressed(const ui::Accelerator& accelerator) { RotateFocus(FORWARD); return true; default: + NOTREACHED(); return false; } } diff --git a/ash/focus_cycler.h b/ash/focus_cycler.h index 0b33082..36ddc68 100644 --- a/ash/focus_cycler.h +++ b/ash/focus_cycler.h @@ -43,6 +43,9 @@ class ASH_EXPORT FocusCycler : public ui::AcceleratorTarget { // Move focus to the next widget. void RotateFocus(Direction direction); + // Moves focus the specified widget. Returns true if the widget was activated. + bool FocusWidget(views::Widget* widget); + // ui::AcceleratorTarget overrides virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; virtual bool CanHandleAccelerators() const OVERRIDE; |