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

Unified Diff: ui/views/controls/menu/menu_message_pump_dispatcher_win.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
« no previous file with comments | « ui/views/controls/menu/menu_event_dispatcher_linux.cc ('k') | ui/views/views.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_message_pump_dispatcher_win.cc
===================================================================
--- ui/views/controls/menu/menu_message_pump_dispatcher_win.cc (revision 274103)
+++ ui/views/controls/menu/menu_message_pump_dispatcher_win.cc (working copy)
@@ -23,61 +23,72 @@
uint32_t MenuMessagePumpDispatcher::Dispatch(const MSG& msg) {
DCHECK(menu_controller_->IsBlockingRun());
+ bool should_quit = false;
+ bool should_perform_default = true;
if (menu_controller_->exit_type() == MenuController::EXIT_ALL ||
- menu_controller_->exit_type() == MenuController::EXIT_DESTROYED)
- return (POST_DISPATCH_QUIT_LOOP | POST_DISPATCH_PERFORM_DEFAULT);
+ menu_controller_->exit_type() == MenuController::EXIT_DESTROYED) {
+ should_quit = true;
+ } else {
+ // NOTE: we don't get WM_ACTIVATE or anything else interesting in here.
+ switch (msg.message) {
+ case WM_CONTEXTMENU: {
+ MenuItemView* item = menu_controller_->pending_state_.item;
+ if (item && item->GetRootMenuItem() != item) {
+ gfx::Point screen_loc(0, item->height());
+ View::ConvertPointToScreen(item, &screen_loc);
+ ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE;
+ if (GET_X_LPARAM(msg.lParam) == -1 && GET_Y_LPARAM(msg.lParam) == -1)
+ source_type = ui::MENU_SOURCE_KEYBOARD;
+ item->GetDelegate()->ShowContextMenu(
+ item, item->GetCommand(), screen_loc, source_type);
+ }
+ should_quit = false;
+ should_perform_default = false;
+ break;
+ }
- // NOTE: we don't get WM_ACTIVATE or anything else interesting in here.
- switch (msg.message) {
- case WM_CONTEXTMENU: {
- MenuItemView* item = menu_controller_->pending_state_.item;
- if (item && item->GetRootMenuItem() != item) {
- gfx::Point screen_loc(0, item->height());
- View::ConvertPointToScreen(item, &screen_loc);
- ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE;
- if (GET_X_LPARAM(msg.lParam) == -1 && GET_Y_LPARAM(msg.lParam) == -1)
- source_type = ui::MENU_SOURCE_KEYBOARD;
- item->GetDelegate()->ShowContextMenu(
- item, item->GetCommand(), screen_loc, source_type);
+ // NOTE: focus wasn't changed when the menu was shown. As such, don't
+ // dispatch key events otherwise the focused window will get the events.
+ case WM_KEYDOWN: {
+ bool result =
+ menu_controller_->OnKeyDown(ui::KeyboardCodeFromNative(msg));
+ TranslateMessage(&msg);
+ should_perform_default = false;
+ should_quit = !result;
+ break;
}
- return POST_DISPATCH_NONE;
- }
+ case WM_CHAR: {
+ should_quit = menu_controller_->SelectByChar(
+ static_cast<base::char16>(msg.wParam));
+ should_perform_default = false;
+ break;
+ }
+ case WM_KEYUP:
+ case WM_SYSKEYUP:
+ // We may have been shown on a system key, as such don't do anything
+ // here. If another system key is pushed we'll get a WM_SYSKEYDOWN and
+ // close the menu.
+ should_quit = false;
+ should_perform_default = false;
+ break;
- // NOTE: focus wasn't changed when the menu was shown. As such, don't
- // dispatch key events otherwise the focused window will get the events.
- case WM_KEYDOWN: {
- bool result =
- menu_controller_->OnKeyDown(ui::KeyboardCodeFromNative(msg));
- TranslateMessage(&msg);
- return result ? POST_DISPATCH_NONE : POST_DISPATCH_QUIT_LOOP;
+ case WM_CANCELMODE:
+ case WM_SYSKEYDOWN:
+ // Exit immediately on system keys.
+ menu_controller_->Cancel(MenuController::EXIT_ALL);
+ should_quit = true;
+ should_perform_default = false;
+ break;
+
+ default:
+ break;
}
- case WM_CHAR: {
- bool should_exit =
- menu_controller_->SelectByChar(static_cast<base::char16>(msg.wParam));
- return should_exit ? POST_DISPATCH_QUIT_LOOP : POST_DISPATCH_NONE;
- }
- case WM_KEYUP:
- return POST_DISPATCH_NONE;
+ }
- case WM_SYSKEYUP:
- // We may have been shown on a system key, as such don't do anything
- // here. If another system key is pushed we'll get a WM_SYSKEYDOWN and
- // close the menu.
- return POST_DISPATCH_NONE;
-
- case WM_CANCELMODE:
- case WM_SYSKEYDOWN:
- // Exit immediately on system keys.
- menu_controller_->Cancel(MenuController::EXIT_ALL);
- return POST_DISPATCH_QUIT_LOOP;
-
- default:
- break;
- }
- return POST_DISPATCH_PERFORM_DEFAULT |
- (menu_controller_->exit_type() == MenuController::EXIT_NONE
- ? POST_DISPATCH_NONE
- : POST_DISPATCH_QUIT_LOOP);
+ if (should_quit || menu_controller_->exit_type() != MenuController::EXIT_NONE)
+ menu_controller_->TerminateNestedMessageLoop();
+ return should_perform_default ? POST_DISPATCH_PERFORM_DEFAULT
+ : POST_DISPATCH_NONE;
}
} // namespace internal
« no previous file with comments | « ui/views/controls/menu/menu_event_dispatcher_linux.cc ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698