summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2022-01-10 11:51:46 +0000
committerAntónio Fernandes <antoniojpfernandes@gmail.com>2022-02-12 16:49:04 +0000
commit7ec35dd46b76db31515fa23c78f5211c14bbeec0 (patch)
tree91082ec983936856062cea474d6317f522e77d68
parent6753140c0d84b2f4e3467aee72f1bd5d4b999df1 (diff)
downloadnautilus-7ec35dd46b76db31515fa23c78f5211c14bbeec0.tar.gz
notebook: Translate coordinates to find clicked tab
In GTK3, the tab label allocation was given in coordinates which were relative to the parent widget's allocation. In GTK4 the allocation is for the widget's own coordinates instead. Translate the event coordinates accordingly to make this logic work again. Also, test for the lower limit in addition to the upper limit.
-rw-r--r--src/nautilus-notebook.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
index 96a8ca97b..5767d22a9 100644
--- a/src/nautilus-notebook.c
+++ b/src/nautilus-notebook.c
@@ -49,7 +49,7 @@ find_tab_num_at_pos (GtkNotebook *notebook,
while ((page = gtk_notebook_get_nth_page (notebook, page_num)))
{
GtkWidget *tab;
- gint max_x, max_y;
+ gdouble tab_x, tab_y;
tab = gtk_notebook_get_tab_label (notebook, page);
g_return_val_if_fail (tab != NULL, -1);
@@ -61,11 +61,11 @@ find_tab_num_at_pos (GtkNotebook *notebook,
}
gtk_widget_get_allocation (tab, &allocation);
+ gtk_widget_translate_coordinates (GTK_WIDGET (notebook), tab,
+ abs_x, abs_y, &tab_x, &tab_y);
- max_x = allocation.x + allocation.width;
- max_y = allocation.y + allocation.height;
-
- if (abs_x <= max_x && abs_y <= max_y)
+ if (tab_x >= allocation.x && tab_x <= allocation.x + allocation.width &&
+ tab_y >= allocation.y && tab_y <= allocation.y + allocation.height)
{
return page_num;
}