summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/menu_gtk.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/gtk/menu_gtk.cc')
-rw-r--r--chrome/browser/gtk/menu_gtk.cc30
1 files changed, 24 insertions, 6 deletions
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index 421cfb3..862039e 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -103,7 +103,7 @@ void MenuGtk::Popup(GtkWidget* widget, GdkEvent* event) {
void MenuGtk::Popup(GtkWidget* widget, gint button_type, guint32 timestamp) {
gtk_menu_popup(GTK_MENU(menu_.get()), NULL, NULL,
- MenuPositionFunc,
+ WidgetMenuPositionFunc,
widget,
button_type, timestamp);
}
@@ -114,6 +114,11 @@ void MenuGtk::PopupAsContext(guint32 event_time) {
gtk_menu_popup(GTK_MENU(menu_.get()), NULL, NULL, NULL, NULL, 3, event_time);
}
+void MenuGtk::PopupAsContextAt(guint32 event_time, gfx::Point point) {
+ gtk_menu_popup(GTK_MENU(menu_.get()), NULL, NULL,
+ PointMenuPositionFunc, &point, 3, event_time);
+}
+
void MenuGtk::PopupAsFromKeyEvent(GtkWidget* widget) {
Popup(widget, 0, gtk_get_current_event_time());
gtk_menu_shell_select_first(GTK_MENU_SHELL(menu_.get()), FALSE);
@@ -264,11 +269,11 @@ void MenuGtk::OnMenuItemActivated(GtkMenuItem* menuitem, MenuGtk* menu) {
}
// static
-void MenuGtk::MenuPositionFunc(GtkMenu* menu,
- int* x,
- int* y,
- gboolean* push_in,
- void* void_widget) {
+void MenuGtk::WidgetMenuPositionFunc(GtkMenu* menu,
+ int* x,
+ int* y,
+ gboolean* push_in,
+ void* void_widget) {
GtkWidget* widget = GTK_WIDGET(void_widget);
GtkRequisition menu_req;
@@ -306,6 +311,19 @@ void MenuGtk::MenuPositionFunc(GtkMenu* menu,
*push_in = FALSE;
}
+// static
+void MenuGtk::PointMenuPositionFunc(GtkMenu* menu,
+ int* x,
+ int* y,
+ gboolean* push_in,
+ gpointer userdata) {
+ *push_in = TRUE;
+
+ gfx::Point* point = reinterpret_cast<gfx::Point*>(userdata);
+ *x = point->x();
+ *y = point->y();
+}
+
void MenuGtk::UpdateMenu() {
gtk_container_foreach(GTK_CONTAINER(menu_.get()), SetMenuItemInfo, this);
}