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

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

Issue 301243012: Merge 269819 "views: Terminate the nested message-loop correctly..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1985/src/
Patch Set: Created 6 years, 7 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
Index: ui/views/controls/menu/menu_event_dispatcher_linux.cc
===================================================================
--- ui/views/controls/menu/menu_event_dispatcher_linux.cc (revision 274103)
+++ ui/views/controls/menu/menu_event_dispatcher_linux.cc (working copy)
@@ -25,6 +25,8 @@
}
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.
@@ -43,36 +45,46 @@
}
if (menu_controller_->exit_type() == MenuController::EXIT_ALL ||
- menu_controller_->exit_type() == MenuController::EXIT_DESTROYED)
- return (ui::POST_DISPATCH_QUIT_LOOP | ui::POST_DISPATCH_PERFORM_DEFAULT);
-
- if (should_process_event) {
+ menu_controller_->exit_type() == MenuController::EXIT_DESTROYED) {
+ should_quit = true;
+ } else if (should_process_event) {
switch (ui::EventTypeFromNative(event)) {
case ui::ET_KEY_PRESSED: {
- if (!menu_controller_->OnKeyDown(ui::KeyboardCodeFromNative(event)))
- return ui::POST_DISPATCH_QUIT_LOOP;
+ if (!menu_controller_->OnKeyDown(ui::KeyboardCodeFromNative(event))) {
+ should_quit = true;
+ should_perform_default = false;
+ break;
+ }
// Do not check mnemonics if the Alt or Ctrl modifiers are pressed.
int flags = ui::EventFlagsFromNative(event);
if ((flags & (ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)) == 0) {
char c = ui::GetCharacterFromKeyCode(
ui::KeyboardCodeFromNative(event), flags);
- if (menu_controller_->SelectByChar(c))
- return ui::POST_DISPATCH_QUIT_LOOP;
+ if (menu_controller_->SelectByChar(c)) {
+ should_quit = true;
+ should_perform_default = false;
+ break;
+ }
}
- return ui::POST_DISPATCH_NONE;
+ should_quit = false;
+ should_perform_default = false;
+ break;
}
case ui::ET_KEY_RELEASED:
- return ui::POST_DISPATCH_NONE;
+ should_quit = false;
+ should_perform_default = false;
+ break;
default:
break;
}
}
- return ui::POST_DISPATCH_PERFORM_DEFAULT |
- (menu_controller_->exit_type() == MenuController::EXIT_NONE
- ? ui::POST_DISPATCH_NONE
- : ui::POST_DISPATCH_QUIT_LOOP);
+ 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;
}
} // namespace internal
« no previous file with comments | « ui/views/controls/menu/menu_controller_unittest.cc ('k') | ui/views/controls/menu/menu_message_pump_dispatcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698