diff options
author | Ernestas Kulik <ernestask@gnome.org> | 2018-04-14 16:14:19 +0300 |
---|---|---|
committer | Ernestas Kulik <ernestask@gnome.org> | 2018-04-14 16:18:21 +0300 |
commit | 7ca2197ae3f0df527e27cf58188b1f83216e3cdb (patch) | |
tree | 8090a7053c322ff7c8b2fb005e89d14e4e0f2fc4 /src/nautilus-notebook.c | |
parent | babfed249c0fbfdf5a4cf8de477d3f445aeed2b6 (diff) | |
download | nautilus-7ca2197ae3f0df527e27cf58188b1f83216e3cdb.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
Diffstat (limited to 'src/nautilus-notebook.c')
-rw-r--r-- | src/nautilus-notebook.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c index 43dda4dc2..e86b15a8a 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 |