summaryrefslogtreecommitdiffstats
path: root/views/controls/menu
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 07:14:26 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 07:14:26 +0000
commit2d3a1d8c35f7b1a8611aa97569101cff6f5767ae (patch)
tree395eb1716ef297e524d0810049664d1df7fa6dd8 /views/controls/menu
parent3af2e912567d6b4606da03ecef318a01a1c5ae8e (diff)
downloadchromium_src-2d3a1d8c35f7b1a8611aa97569101cff6f5767ae.zip
chromium_src-2d3a1d8c35f7b1a8611aa97569101cff6f5767ae.tar.gz
chromium_src-2d3a1d8c35f7b1a8611aa97569101cff6f5767ae.tar.bz2
Close menu on grab broke event.
This is necessary for screen locker to grab the input event. Technically, this can happen when another part of chrome tries to grab the input, so this is safer to handle this. BUG=none TEST=none Review URL: http://codereview.chromium.org/1900002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/menu')
-rw-r--r--views/controls/menu/menu_controller.cc5
-rw-r--r--views/controls/menu/menu_controller.h6
-rw-r--r--views/controls/menu/menu_host_gtk.cc8
3 files changed, 17 insertions, 2 deletions
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc
index dfbb5f1..a89aa8c 100644
--- a/views/controls/menu/menu_controller.cc
+++ b/views/controls/menu/menu_controller.cc
@@ -153,6 +153,7 @@ MenuItemView* MenuController::Run(gfx::NativeWindow parent,
int* result_mouse_event_flags) {
exit_type_ = EXIT_NONE;
possible_drag_ = false;
+ drag_in_progress_ = false;
bool nested_menu = showing_;
if (showing_) {
@@ -400,8 +401,11 @@ void MenuController::OnMouseDragged(SubmenuView* source,
&data);
StopScrolling();
int drag_ops = item->GetDelegate()->GetDragOperations(item);
+ drag_in_progress_ = true;
item->GetRootView()->StartDragForViewFromMouseEvent(
NULL, data, drag_ops);
+ drag_in_progress_ = false;
+
if (GetActiveInstance() == this) {
if (showing_) {
// We're still showing, close all menus.
@@ -809,6 +813,7 @@ MenuController::MenuController(bool blocking)
drop_target_(NULL),
owner_(NULL),
possible_drag_(false),
+ drag_in_progress_(false),
valid_drop_coordinates_(false),
showing_submenu_(false),
menu_button_(NULL) {
diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h
index d6518be..734e445 100644
--- a/views/controls/menu/menu_controller.h
+++ b/views/controls/menu/menu_controller.h
@@ -70,6 +70,9 @@ class MenuController : public MessageLoopForUI::Dispatcher {
// Whether or not Run blocks.
bool IsBlockingRun() const { return blocking_run_; }
+ // Whether or not drag operation is in progress.
+ bool drag_in_progress() const { return drag_in_progress_; }
+
// Sets the selection to menu_item, a value of NULL unselects everything.
// If open_submenu is true and menu_item has a submenu, the submenu is shown.
// If update_immediately is true, submenus are opened immediately, otherwise
@@ -389,6 +392,9 @@ class MenuController : public MessageLoopForUI::Dispatcher {
// Indicates a possible drag operation.
bool possible_drag_;
+ // True when drag operation is in progress.
+ bool drag_in_progress_;
+
// Location the mouse was pressed at. Used to detect d&d.
gfx::Point press_pt_;
diff --git a/views/controls/menu/menu_host_gtk.cc b/views/controls/menu/menu_host_gtk.cc
index 95fea7b..5571157 100644
--- a/views/controls/menu/menu_host_gtk.cc
+++ b/views/controls/menu/menu_host_gtk.cc
@@ -112,9 +112,13 @@ void MenuHostGtk::OnDestroy(GtkWidget* object) {
}
gboolean MenuHostGtk::OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) {
- // Grab breaking only happens when drag and drop starts. So, we don't try
- // and ungrab or cancel the menu.
did_pointer_grab_ = false;
+ // Grab can be broken by drag & drop, other menu or screen locker.
+ MenuController* menu_controller =
+ submenu_->GetMenuItem()->GetMenuController();
+ if (!menu_controller->drag_in_progress()) {
+ menu_controller->CancelAll();
+ }
return WidgetGtk::OnGrabBrokeEvent(widget, event);
}