Skip to content

Commit

Permalink
Merge branch 'gtk-fix-bogus-dvc-context-menu'
Browse files Browse the repository at this point in the history
Fix bogus wxDVC context menu event in wxGTK.

See #2362
  • Loading branch information
vadz committed May 22, 2021
2 parents 0b20b97 + 07459e8 commit 01aebc0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/gtk/dataview.cpp
Expand Up @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit 01aebc0

Please sign in to comment.