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

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 772963002: Make the second click on the app shelf icon close the window-list bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address the code review comments. Created 6 years 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 unified diff | Download patch
« no previous file with comments | « ash/shelf/shelf_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/menu/menu_controller.h" 5 #include "ui/views/controls/menu/menu_controller.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 903
904 // When this menu is opened through a touch event, a simulated right-click 904 // When this menu is opened through a touch event, a simulated right-click
905 // is sent before the menu appears. Ignore it. 905 // is sent before the menu appears. Ignore it.
906 if ((event.flags() & ui::EF_RIGHT_MOUSE_BUTTON) && 906 if ((event.flags() & ui::EF_RIGHT_MOUSE_BUTTON) &&
907 (event.flags() & ui::EF_FROM_TOUCH)) 907 (event.flags() & ui::EF_FROM_TOUCH))
908 return; 908 return;
909 909
910 if (part.type == MenuPart::NONE || 910 if (part.type == MenuPart::NONE ||
911 (part.type == MenuPart::MENU_ITEM && part.menu && 911 (part.type == MenuPart::MENU_ITEM && part.menu &&
912 part.menu->GetRootMenuItem() != state_.item->GetRootMenuItem())) { 912 part.menu->GetRootMenuItem() != state_.item->GetRootMenuItem())) {
913 // Remember the time when we repost the event. The owner can then use this 913 // Remember the time stamp of the current (press down) event. The owner can
914 // to figure out if this menu was finished with the same click which is 914 // then use this to figure out if this menu was finished with the same click
915 // sent to it thereafter. Note that the time stamp front he event cannot be 915 // which is sent to it thereafter.
916 // used since the reposting will set a new timestamp when the event gets 916 closing_event_time_ = event.time_stamp();
917 // processed. As such it is better to take the current time which will be
918 // closer to the time when it arrives again in the menu handler.
919 closing_event_time_ = ui::EventTimeForNow();
920 917
921 // Mouse wasn't pressed over any menu, or the active menu, cancel. 918 // Mouse wasn't pressed over any menu, or the active menu, cancel.
922 919
923 #if defined(OS_WIN) 920 #if defined(OS_WIN)
924 // We're going to close and we own the mouse capture. We need to repost the 921 // We're going to close and we own the mouse capture. We need to repost the
925 // mouse down, otherwise the window the user clicked on won't get the event. 922 // mouse down, otherwise the window the user clicked on won't get the event.
926 RepostEvent(source, event); 923 RepostEvent(source, event);
927 #endif 924 #endif
928 925
929 // And close. 926 // And close.
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 } 2303 }
2307 } 2304 }
2308 2305
2309 gfx::Screen* MenuController::GetScreen() { 2306 gfx::Screen* MenuController::GetScreen() {
2310 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; 2307 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL;
2311 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) 2308 return root ? gfx::Screen::GetScreenFor(root->GetNativeView())
2312 : gfx::Screen::GetNativeScreen(); 2309 : gfx::Screen::GetNativeScreen();
2313 } 2310 }
2314 2311
2315 } // namespace views 2312 } // namespace views
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698