window: Check if a tab was hit on right click

Since we have to handle the event in reverse order (because GtkTreeView
claims the event sequence in the capture phase, meaning that the events
won’t bubble up), the context menu for notebook tabs will open
everywhere, because the event handler is not stopped by those lower in
the hierarchy. A simple check if the cursor is on a tab will prevent
that.
This commit is contained in:
Ernestas Kulik 2018-05-17 16:57:49 +03:00
parent 13a8d3efac
commit 873156cf85
3 changed files with 21 additions and 1 deletions

View file

@ -222,6 +222,14 @@ nautilus_notebook_contains_slot (NautilusNotebook *notebook,
return found;
}
gboolean
nautilus_notebook_content_area_hit (NautilusNotebook *notebook,
gint x,
gint y)
{
return find_tab_num_at_pos (notebook, x, y) == -1;
}
void
nautilus_notebook_sync_loading (NautilusNotebook *notebook,
NautilusWindowSlot *slot)

View file

@ -54,4 +54,8 @@ void nautilus_notebook_next_page (NautilusNotebook *notebook);
gboolean nautilus_notebook_contains_slot (NautilusNotebook *notebook,
NautilusWindowSlot *slot);
G_END_DECLS
gboolean nautilus_notebook_content_area_hit (NautilusNotebook *notebook,
gint x,
gint y);
G_END_DECLS

View file

@ -2027,10 +2027,18 @@ notebook_button_press_cb (GtkGestureMultiPress *gesture,
gpointer user_data)
{
NautilusWindow *window;
NautilusWindowPrivate *priv;
GdkEventSequence *sequence;
const GdkEvent *event;
window = NAUTILUS_WINDOW (user_data);
priv = nautilus_window_get_instance_private (window);
if (nautilus_notebook_content_area_hit (NAUTILUS_NOTEBOOK (priv->notebook), x, y))
{
return;
}
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);