summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-04-14 16:14:19 +0300
committerErnestas Kulik <ernestas.kulik@gmail.com>2018-04-30 13:55:34 +0000
commit38b2969847f5dd627c8c608f3eca513520a93cda (patch)
treeadd08cbf9330c8b8e0e73d902b8e6969dd5708c4
parent56da51f181f6cf8959a24a2ef6187a074d9f8ada (diff)
downloadnautilus-38b2969847f5dd627c8c608f3eca513520a93cda.tar.gz
notebook: Fix tab lookup by coordinates
The current code only checks one coordinate, depending on the tab orientation. Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/342 (cherry picked from commit 7ca2197ae3f0df527e27cf58188b1f83216e3cdb)
-rw-r--r--src/nautilus-notebook.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
index f2b3fbdf1..6e1db521b 100644
--- a/src/nautilus-notebook.c
+++ b/src/nautilus-notebook.c
@@ -88,14 +88,11 @@ find_tab_num_at_pos (NautilusNotebook *notebook,
gint abs_x,
gint abs_y)
{
- GtkPositionType tab_pos;
int page_num = 0;
GtkNotebook *nb = GTK_NOTEBOOK (notebook);
GtkWidget *page;
GtkAllocation allocation;
- tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook));
-
while ((page = gtk_notebook_get_nth_page (nb, page_num)))
{
GtkWidget *tab;
@@ -118,15 +115,7 @@ find_tab_num_at_pos (NautilusNotebook *notebook,
max_x = x_root + allocation.x + allocation.width;
max_y = y_root + allocation.y + allocation.height;
- if (((tab_pos == GTK_POS_TOP)
- || (tab_pos == GTK_POS_BOTTOM))
- && (abs_x <= max_x))
- {
- return page_num;
- }
- else if (((tab_pos == GTK_POS_LEFT)
- || (tab_pos == GTK_POS_RIGHT))
- && (abs_y <= max_y))
+ if (abs_x <= max_x && abs_y <= max_y)
{
return page_num;
}
@@ -154,7 +143,7 @@ button_press_cb (NautilusNotebook *notebook,
/* consume event, so that we don't pop up the context menu when
* the mouse if not over a tab label
*/
- return TRUE;
+ return GDK_EVENT_STOP;
}
/* switch to the page the mouse is over, but don't consume the event */
@@ -165,11 +154,16 @@ button_press_cb (NautilusNotebook *notebook,
{
GtkWidget *slot;
+ if (tab_clicked == -1)
+ {
+ return GDK_EVENT_PROPAGATE;
+ }
+
slot = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), tab_clicked);
g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, slot);
}
- return FALSE;
+ return GDK_EVENT_PROPAGATE;
}
static void