diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 81de210a39..8ffa7b7b3b 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -4662,13 +4662,22 @@ gtk_dataview_button_press_callback( GtkWidget *WXUNUSED(widget), { if ((gdk_event->button == 3) && (gdk_event->type == GDK_BUTTON_PRESS)) { + GtkTreeView* const treeview = GTK_TREE_VIEW(dv->GtkGetTreeView()); + + // Surprisingly, we can get the events not only from the "bin" window, + // containing the items, but also from the window containing the column + // headers, and we're not interested in them here, we already generate + // wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK for them, so just ignore. + if (gdk_event->window != gtk_tree_view_get_bin_window(treeview)) + return FALSE; + wxGtkTreePath path; GtkTreeViewColumn *column = NULL; gint cell_x = 0; gint cell_y = 0; gtk_tree_view_get_path_at_pos ( - GTK_TREE_VIEW(dv->GtkGetTreeView()), + treeview, (int) gdk_event->x, (int) gdk_event->y, path.ByRef(), &column, @@ -4681,7 +4690,7 @@ gtk_dataview_button_press_callback( GtkWidget *WXUNUSED(widget), // because it could be a part of multi-item selection. if ( path ) { - GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dv->GtkGetTreeView())); + GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); if ( !gtk_tree_selection_path_is_selected(selection, path) ) { gtk_tree_selection_unselect_all(selection);