| Index: ui/views/controls/menu/menu_event_dispatcher_linux.cc
|
| diff --git a/ui/views/controls/menu/menu_event_dispatcher_linux.cc b/ui/views/controls/menu/menu_event_dispatcher_linux.cc
|
| index 51990fd07f00f50abadf05859a6d6c33a67208e2..a2a036c988398122b485940f25708cf6c1903b20 100644
|
| --- a/ui/views/controls/menu/menu_event_dispatcher_linux.cc
|
| +++ b/ui/views/controls/menu/menu_event_dispatcher_linux.cc
|
| @@ -7,8 +7,6 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/events/event_utils.h"
|
| -#include "ui/events/keycodes/keyboard_code_conversion.h"
|
| -#include "ui/events/keycodes/keyboard_codes.h"
|
| #include "ui/views/controls/menu/menu_controller.h"
|
| #include "ui/views/widget/widget.h"
|
|
|
| @@ -25,66 +23,28 @@ bool MenuEventDispatcher::CanDispatchEvent(const ui::PlatformEvent& event) {
|
| }
|
|
|
| uint32_t MenuEventDispatcher::DispatchEvent(const ui::PlatformEvent& event) {
|
| - bool should_quit = false;
|
| - bool should_perform_default = true;
|
| - bool should_process_event = true;
|
| -
|
| // Check if the event should be handled.
|
| scoped_ptr<ui::Event> ui_event(ui::EventFromNative(event));
|
| + aura::Window* target_window = nullptr;
|
| if (ui_event && menu_controller_->owner()) {
|
| aura::Window* menu_window = menu_controller_->owner()->GetNativeWindow();
|
| - aura::Window* target_window = static_cast<aura::Window*>(
|
| - static_cast<ui::EventTarget*>(menu_window->GetRootWindow())->
|
| - GetEventTargeter()->FindTargetForEvent(menu_window,
|
| - ui_event.get()));
|
| - // TODO(flackr): The event shouldn't be handled if target_window is not
|
| - // menu_window, however the event targeter does not properly target the
|
| - // open menu. For now, we allow targeters to prevent handling by the menu.
|
| - if (!target_window)
|
| - should_process_event = false;
|
| + target_window = static_cast<aura::Window*>(
|
| + static_cast<ui::EventTarget*>(menu_window->GetRootWindow())
|
| + ->GetEventTargeter()
|
| + ->FindTargetForEvent(menu_window, ui_event.get()));
|
| }
|
|
|
| - if (menu_controller_->exit_type() == MenuController::EXIT_ALL ||
|
| - menu_controller_->exit_type() == MenuController::EXIT_DESTROYED) {
|
| - should_quit = true;
|
| - } else if (ui_event && should_process_event) {
|
| - switch (ui_event->type()) {
|
| - case ui::ET_KEY_PRESSED: {
|
| - ui::KeyEvent* key_event = static_cast<ui::KeyEvent*>(ui_event.get());
|
| - if (!menu_controller_->OnKeyDown(key_event->key_code())) {
|
| - should_quit = true;
|
| - should_perform_default = false;
|
| - break;
|
| - }
|
| -
|
| - // Do not check mnemonics if the Alt or Ctrl modifiers are pressed.
|
| - int flags = key_event->flags();
|
| - if ((flags & (ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)) == 0) {
|
| - char c = ui::GetCharacterFromKeyCode(key_event->key_code(), flags);
|
| - if (menu_controller_->SelectByChar(c)) {
|
| - should_quit = true;
|
| - should_perform_default = false;
|
| - break;
|
| - }
|
| - }
|
| - should_quit = false;
|
| - should_perform_default = false;
|
| - break;
|
| - }
|
| - case ui::ET_KEY_RELEASED:
|
| - should_quit = false;
|
| - should_perform_default = false;
|
| - break;
|
| - default:
|
| - break;
|
| - }
|
| + // TODO(flackr): The event shouldn't be handled if target_window is not
|
| + // menu_window, however the event targeter does not properly target the
|
| + // open menu. For now, we allow targeters to prevent handling by the menu.
|
| + if (!target_window) {
|
| + if (menu_controller_->exit_type() != MenuController::EXIT_NONE)
|
| + menu_controller_->TerminateNestedMessageLoop();
|
| + return ui::POST_DISPATCH_PERFORM_DEFAULT;
|
| }
|
|
|
| - if (should_quit || menu_controller_->exit_type() != MenuController::EXIT_NONE)
|
| - menu_controller_->TerminateNestedMessageLoop();
|
| -
|
| - return should_perform_default ? ui::POST_DISPATCH_PERFORM_DEFAULT
|
| - : ui::POST_DISPATCH_NONE;
|
| + DCHECK(ui_event);
|
| + return menu_controller_->OnWillDispatchEvent(*ui_event.get());
|
| }
|
|
|
| } // namespace internal
|
|
|