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

Unified Diff: chrome/browser/gtk/bookmark_menu_controller_gtk.cc

Issue 164183: GTK: Make the bookmark bar folder menus dismiss properly.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: don't leak Created 11 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/bookmark_menu_controller_gtk.cc
===================================================================
--- chrome/browser/gtk/bookmark_menu_controller_gtk.cc (revision 22744)
+++ chrome/browser/gtk/bookmark_menu_controller_gtk.cc (working copy)
@@ -48,6 +48,34 @@
return const_cast<BookmarkNode*>(node);
}
+// The context menu has been dismissed, restore the X and application grabs
+// to whichever menu last had them. (Assuming that menu is still showing.)
+// The event mask in this function is taken from gtkmenu.c.
+void OnContextMenuHide(GtkWidget* context_menu, GtkWidget* grab_menu) {
+ guint time = gtk_get_current_event_time();
+
+ if (GTK_WIDGET_VISIBLE(grab_menu)) {
+ if (!gdk_pointer_grab(grab_menu->window, TRUE,
+ GdkEventMask(
+ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+ GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
+ GDK_POINTER_MOTION_MASK), NULL, NULL, time) == 0) {
+ g_object_unref(grab_menu);
+ return;
+ }
+ if (!gdk_keyboard_grab(grab_menu->window, TRUE, time) == 0) {
+ gdk_display_pointer_ungrab(gdk_drawable_get_display(grab_menu->window),
+ time);
+ g_object_unref(grab_menu);
+ return;
+ }
+ gtk_grab_add(grab_menu);
+ }
+
+ // Match the ref we took when connecting this signal.
+ g_object_unref(grab_menu);
+}
+
} // namespace
BookmarkMenuController::BookmarkMenuController(Browser* browser,
@@ -216,6 +244,14 @@
sender, controller->profile_, controller->browser_,
controller->page_navigator_, parent, nodes,
BookmarkContextMenu::BOOKMARK_BAR));
+
+ // Our bookmark folder menu loses the grab to the context menu. When the
+ // context menu is hidden, re-assert our grab.
+ GtkWidget* grabbing_menu = gtk_grab_get_current();
+ g_object_ref(grabbing_menu);
+ g_signal_connect(controller->context_menu_->menu(), "hide",
+ G_CALLBACK(OnContextMenuHide), grabbing_menu);
+
controller->context_menu_->PopupAsContext(event->time);
return TRUE;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698