Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: ui/views/controls/menu/menu_controller.cc

Issue 9224001: Fixes issue with accelerators when a menu is open (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nicer diff Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_controller.cc
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index 43a37b661ebed2649aa689f2893193d2f53a22eb..d87c09953b8012eb5c977d67c84acceb87d1ef8b 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -8,6 +8,7 @@
#include "base/i18n/rtl.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
+#include "ui/base/accelerators/accelerator.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/events.h"
#include "ui/base/keycodes/keyboard_codes.h"
@@ -19,12 +20,16 @@
#include "ui/views/controls/menu/menu_scroll_view_container.h"
#include "ui/views/controls/menu/submenu_view.h"
#include "ui/views/drag_utils.h"
+#include "ui/views/focus/focus_manager.h"
#include "ui/views/view_constants.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/widget.h"
#if defined(USE_AURA)
+#include "ash/accelerators/accelerator_controller.h"
+#include "ash/shell.h"
+#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
#elif defined(TOOLKIT_USES_GTK)
#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
@@ -886,9 +891,13 @@ base::MessagePumpDispatcher::DispatchStatus
aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(xev);
return base::MessagePumpDispatcher::EVENT_QUIT;
}
+
+ ui::KeyboardCode key_code = ui::KeyboardCodeFromNative(xev);
+ int flags = ui::EventFlagsFromNative(xev);
+
switch (ui::EventTypeFromNative(xev)) {
case ui::ET_KEY_PRESSED:
- if (!OnKeyDown(ui::KeyboardCodeFromNative(xev)))
+ if (!OnKeyDown(key_code))
return base::MessagePumpDispatcher::EVENT_QUIT;
// OnKeyDown may have set exit_type_.
@@ -898,9 +907,27 @@ base::MessagePumpDispatcher::DispatchStatus
if (exit_type_ != EXIT_NONE)
return base::MessagePumpDispatcher::EVENT_QUIT;
- return SelectByChar(ui::KeyboardCodeFromNative(xev)) ?
- base::MessagePumpDispatcher::EVENT_QUIT :
- base::MessagePumpDispatcher::EVENT_PROCESSED;
+ if (SelectByChar(key_code))
+ return base::MessagePumpDispatcher::EVENT_QUIT;
+
+ {
+ const int kModifierFlagMask = (ui::EF_SHIFT_DOWN |
+ ui::EF_CONTROL_DOWN |
+ ui::EF_ALT_DOWN);
+
+ ui::Accelerator accelerator = ui::Accelerator(key_code,
+ flags & kModifierFlagMask);
oshima 2012/01/19 18:29:48 just accelerator(key_code, flags & kModifierFlagMa
+ FocusManager* focus_manager = menu_button_->GetWidget()->
+ GetFocusManager();
oshima 2012/01/19 18:29:48 menu_button_->GetFocusManager()
+ ash::AcceleratorController* accelerator_controller =
+ ash::Shell::GetInstance()->accelerator_controller();
oshima 2012/01/19 18:29:48 have you looked into handling this on aura/ash sid
+ if (focus_manager && focus_manager->ProcessAccelerator(accelerator))
+ return base::MessagePumpDispatcher::EVENT_QUIT;
oshima 2012/01/19 18:29:48 You're executing accelerator inside nested loop wh
+ else if (accelerator_controller && accelerator_controller->
+ Process(accelerator))
+ return base::MessagePumpDispatcher::EVENT_QUIT;
+ }
+ return base::MessagePumpDispatcher::EVENT_PROCESSED;
case ui::ET_KEY_RELEASED:
return base::MessagePumpDispatcher::EVENT_PROCESSED;
default:
@@ -919,7 +946,7 @@ base::MessagePumpDispatcher::DispatchStatus
#else
bool MenuController::Dispatch(GdkEvent* event) {
if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) {
- gtk_main_do_event(event);
+ gtk_main_do_eSvent(event);
oshima 2012/01/19 18:29:48 revert this change?
return false;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698