diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2017-03-31 18:07:22 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2017-05-25 16:25:58 +0200 |
commit | 99e200aa98c498adf7628d0f07f04b5fa3d0eb8e (patch) | |
tree | 6e3b7705b6550c7b5e0243f537809f528345e217 /gtk/gtknotebook.c | |
parent | b01a9a64402753565ae8e355b225c7887a2e90d2 (diff) | |
download | gtk+-99e200aa98c498adf7628d0f07f04b5fa3d0eb8e.tar.gz |
gtknotebook: Fix coordinate translation to happen on widget-relative coordinates
This makes notebooks happy again after changing event coordinates to always come in
the widget coordinate system.
Diffstat (limited to 'gtk/gtknotebook.c')
-rw-r--r-- | gtk/gtknotebook.c | 48 |
1 files changed, 8 insertions, 40 deletions
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 88bf788a3a..7bb5890c97 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -2514,40 +2514,6 @@ gtk_notebook_arrow_button_press (GtkNotebook *notebook, } static gboolean -get_widget_coordinates (GtkWidget *widget, - const GdkEvent *event, - gdouble *x, - gdouble *y) -{ - GdkWindow *window = ((GdkEventAny *)event)->window; - gdouble tx, ty; - - if (!gdk_event_get_coords (event, &tx, &ty)) - return FALSE; - - while (window && window != gtk_widget_get_window (widget)) - { - gint window_x, window_y; - - gdk_window_get_position (window, &window_x, &window_y); - tx += window_x; - ty += window_y; - - window = gdk_window_get_parent (window); - } - - if (window) - { - *x = tx; - *y = ty; - - return TRUE; - } - else - return FALSE; -} - -static gboolean gtk_notebook_page_tab_label_is_visible (GtkNotebookPage *page) { return page->tab_label @@ -2562,9 +2528,11 @@ get_tab_at_pos (GtkNotebook *notebook, { GtkNotebookPrivate *priv = notebook->priv; GtkNotebookPage *page; - GtkAllocation allocation; + GtkAllocation notebook_allocation, allocation; GList *children; + gtk_widget_get_allocation (GTK_WIDGET (notebook), ¬ebook_allocation); + for (children = priv->children; children; children = children->next) { page = children->data; @@ -2573,6 +2541,9 @@ get_tab_at_pos (GtkNotebook *notebook, continue; gtk_css_gadget_get_border_allocation (page->gadget, &allocation, NULL); + allocation.x -= notebook_allocation.x; + allocation.y -= notebook_allocation.y; + if ((x >= allocation.x) && (y >= allocation.y) && (x <= (allocation.x + allocation.width)) && @@ -2607,9 +2578,6 @@ gtk_notebook_gesture_pressed (GtkGestureMultiPress *gesture, if (event->type != GDK_BUTTON_PRESS || !priv->children) return; - if (!get_widget_coordinates (widget, event, &x, &y)) - return ; - arrow = gtk_notebook_get_arrow (notebook, x, y); if (arrow != ARROW_NONE) { @@ -2980,7 +2948,7 @@ tab_prelight (GtkNotebook *notebook, GList *tab; gdouble x, y; - if (get_widget_coordinates (GTK_WIDGET (notebook), (const GdkEvent *)event, &x, &y)) + if (gdk_event_get_coords (event, &x, &y)) { tab = get_tab_at_pos (notebook, x, y); update_prelight_tab (notebook, tab == NULL ? NULL : tab->data); @@ -3006,7 +2974,7 @@ gtk_notebook_leave_notify (GtkWidget *widget, GtkNotebookPrivate *priv = notebook->priv; gdouble x, y; - if (get_widget_coordinates (widget, (const GdkEvent *)event, &x, &y)) + if (gdk_event_get_coords ((GdkEvent *) event, &x, &y)) { if (priv->prelight_tab != NULL) { |