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

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

Issue 10668037: Close any open menus on activation changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Observe window activation changes from MenuController. Created 8 years, 6 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_controller.h ('k') | ui/views/widget/widget.cc » ('j') | 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 0ff715be719e98ba7dde29fe2a95e2871f8cfe7a..feda07e9cdf690ac7dcff7948b3f2c26780b90c3 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -27,10 +27,12 @@
#include "ui/views/widget/widget.h"
#if defined(USE_AURA)
+#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/dispatcher_client.h"
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#endif
using base::Time;
@@ -326,8 +328,17 @@ MenuItemView* MenuController::Run(Widget* parent,
DCHECK_LE(message_loop_depth_, 2);
#if defined(USE_AURA)
root_window_ = parent->GetNativeWindow()->GetRootWindow();
+
+ // Observe activation changes to close the window if another window is
+ // activated (crbug.com/131027).
+ if (!nested_menu)
+ aura::client::GetActivationClient(root_window_)->AddObserver(this);
+
aura::client::GetDispatcherClient(root_window_)->
RunWithDispatcher(this, parent->GetNativeWindow(), true);
+
+ if (!nested_menu)
+ aura::client::GetActivationClient(root_window_)->RemoveObserver(this);
#else
{
MessageLoopForUI* loop = MessageLoopForUI::current();
@@ -699,11 +710,6 @@ void MenuController::OnDragExitedScrollButton(SubmenuView* source) {
StopScrolling();
}
-void MenuController::OnWidgetActivationChanged() {
- if (!drag_in_progress_)
- Cancel(EXIT_ALL);
-}
-
void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) {
if (submenu->IsShowing()) {
gfx::Point point = gfx::Screen::GetCursorScreenPoint();
@@ -2124,4 +2130,12 @@ void MenuController::HandleMouseLocation(SubmenuView* source,
}
}
+#if defined(USE_AURA)
+void MenuController::OnWindowActivated(aura::Window* active,
+ aura::Window* old_active) {
+ if (!drag_in_progress_)
+ Cancel(EXIT_ALL);
+}
+#endif
+
} // namespace views
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698