summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authoroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 22:25:26 +0000
committeroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 22:25:26 +0000
commitf03abb555b2265168cc61cc0ca567e1e46d5ea12 (patch)
tree80c97617548c7db8c44a486966561279f14e8dbb /views/controls
parent45a5c7cad23ce17adf6fa5cf89ddb58038d01b95 (diff)
downloadchromium_src-f03abb555b2265168cc61cc0ca567e1e46d5ea12.zip
chromium_src-f03abb555b2265168cc61cc0ca567e1e46d5ea12.tar.gz
chromium_src-f03abb555b2265168cc61cc0ca567e1e46d5ea12.tar.bz2
Moving over to other folder button while opening folder menu should open the folder menu.
It was failing with DCHECK instead. This CL fix this issue by Canceling menu only when the menu has x grab. I also separated grk grab broke and X grab broke because gtk broke require releasing x grab for this case. BUG=chromium-os:13151 TEST=see bug description. Review URL: http://codereview.chromium.org/6676032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/menu/menu_host_gtk.cc38
-rw-r--r--views/controls/menu/menu_host_gtk.h16
2 files changed, 36 insertions, 18 deletions
diff --git a/views/controls/menu/menu_host_gtk.cc b/views/controls/menu/menu_host_gtk.cc
index cc2faeb..8679490 100644
--- a/views/controls/menu/menu_host_gtk.cc
+++ b/views/controls/menu/menu_host_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -130,20 +130,27 @@ void MenuHostGtk::OnDestroy(GtkWidget* object) {
WidgetGtk::OnDestroy(object);
}
-void MenuHostGtk::HandleGrabBroke() {
- did_input_grab_ = false;
- // Grab can be broken by drag & drop, other menu or screen locker.
- if (!destroying_) {
- MenuController* menu_controller =
- submenu_->GetMenuItem()->GetMenuController();
- if (menu_controller && !menu_controller->drag_in_progress())
- menu_controller->CancelAll();
+void MenuHostGtk::HandleXGrabBroke() {
+ // Grab may already be release in ReleaseGrab.
+ if (did_input_grab_ && !destroying_) {
+ did_input_grab_ = false;
+ CancelAllIfNoDrag();
}
+ WidgetGtk::HandleXGrabBroke();
+}
- WidgetGtk::HandleGrabBroke();
+void MenuHostGtk::HandleGtkGrabBroke() {
+ // Grab can be broken by drag & drop, other menu or screen locker.
+ if (did_input_grab_ && !destroying_) {
+ ReleaseNativeCapture();
+ CancelAllIfNoDrag();
+ }
+ WidgetGtk::HandleGtkGrabBroke();
}
void MenuHostGtk::DoCapture() {
+ DCHECK(!did_input_grab_);
+
// Release the current grab.
GtkWidget* current_grab_window = gtk_grab_get_current();
if (current_grab_window)
@@ -168,6 +175,9 @@ void MenuHostGtk::DoCapture() {
did_input_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS &&
keyboard_grab_status == GDK_GRAB_SUCCESS;
+ DCHECK_EQ(GDK_GRAB_SUCCESS, pointer_grab_status);
+ DCHECK_EQ(GDK_GRAB_SUCCESS, keyboard_grab_status);
+
#if defined(HAVE_XINPUT2) && defined(TOUCH_UI)
::Window window = GDK_WINDOW_XID(window_contents()->window);
Display* display = GDK_WINDOW_XDISPLAY(window_contents()->window);
@@ -179,4 +189,12 @@ void MenuHostGtk::DoCapture() {
// need keyboard grab.
}
+void MenuHostGtk::CancelAllIfNoDrag() {
+ MenuController* menu_controller =
+ submenu_->GetMenuItem()->GetMenuController();
+ if (menu_controller &&
+ !menu_controller->drag_in_progress())
+ menu_controller->CancelAll();
+}
+
} // namespace views
diff --git a/views/controls/menu/menu_host_gtk.h b/views/controls/menu/menu_host_gtk.h
index 626433c..468a351 100644
--- a/views/controls/menu/menu_host_gtk.h
+++ b/views/controls/menu/menu_host_gtk.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -34,21 +34,21 @@ class MenuHostGtk : public WidgetGtk, public MenuHost {
virtual gfx::NativeWindow GetMenuHostWindow() OVERRIDE;
protected:
- virtual RootView* CreateRootView();
+ virtual RootView* CreateRootView() OVERRIDE;
- // Overridden to return false, we do NOT want to release capture on mouse
- // release.
+ // WidgetGtk overrides:
virtual bool ReleaseCaptureOnMouseReleased() OVERRIDE;
-
- // Overridden to also release input grab.
virtual void ReleaseNativeCapture() OVERRIDE;
-
virtual void OnDestroy(GtkWidget* object) OVERRIDE;
- virtual void HandleGrabBroke() OVERRIDE;
+ virtual void HandleGtkGrabBroke() OVERRIDE;
+ virtual void HandleXGrabBroke() OVERRIDE;
private:
void DoCapture();
+ // Cancell all menus unless drag is in progress.
+ void CancelAllIfNoDrag();
+
// If true, DestroyMenuHost has been invoked.
bool destroying_;