From d3bd716f11873cb4c00b585cc4c66ebbf16be636 Mon Sep 17 00:00:00 2001 From: Benjamin Heiniger Date: Mon, 8 Nov 2021 20:30:19 +0000 Subject: caja-places-sidebar: fix right-click menu height - prevent error and right-click menu from appearing when clicking empty area --- src/caja-places-sidebar.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index e8251748..ca3b39c2 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -2884,16 +2884,16 @@ bookmarks_button_release_event_cb (GtkWidget *widget, } tree_view = GTK_TREE_VIEW (widget); - model = gtk_tree_view_get_model (tree_view); if (event->button == 1) { - if (event->window != gtk_tree_view_get_bin_window (tree_view)) { return FALSE; } + model = gtk_tree_view_get_model (tree_view); + gtk_tree_view_get_path_at_pos (tree_view, (int) event->x, (int) event->y, &path, NULL, NULL, NULL); @@ -2901,6 +2901,21 @@ bookmarks_button_release_event_cb (GtkWidget *widget, gtk_tree_path_free (path); } + else if (event->button == 3) + { + gtk_tree_view_get_path_at_pos (tree_view, (int) event->x, (int) event->y, + &path, NULL, NULL, NULL); + + if (path != NULL) + { + gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE); + gtk_tree_path_free (path); + + bookmarks_popup_menu (sidebar, event); + + return TRUE; + } + } return FALSE; } @@ -3016,11 +3031,7 @@ bookmarks_button_press_event_cb (GtkWidget *widget, return TRUE; } - if (event->button == 3) - { - bookmarks_popup_menu (sidebar, event); - } - else if (event->button == 2) + if (event->button == 2) { GtkTreeModel *model; GtkTreePath *path; -- cgit v1.2.1