[gtk/wip/baedert/transforms6: 1/31] widget: Remove one translate_coordinates copy
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/transforms6: 1/31] widget: Remove one translate_coordinates copy
- Date: Thu, 29 Nov 2018 08:08:29 +0000 (UTC)
commit c17c18f1ae46185d6ca50b2252e1b3e977904810
Author: Timm Bäder <mail baedert org>
Date: Tue Nov 27 07:12:27 2018 +0100
widget: Remove one translate_coordinates copy
Just use the double version in the integer version.
gtk/gtkwidget.c | 59 +++++++++++----------------------------------------------
1 file changed, 11 insertions(+), 48 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 755b7fea2c..da34d57020 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -4398,60 +4398,23 @@ gtk_widget_get_origin_relative_to_parent (GtkWidget *widget,
**/
gboolean
gtk_widget_translate_coordinates (GtkWidget *src_widget,
- GtkWidget *dest_widget,
- gint src_x,
- gint src_y,
- gint *dest_x,
- gint *dest_y)
+ GtkWidget *dest_widget,
+ gint src_x,
+ gint src_y,
+ gint *dest_x,
+ gint *dest_y)
{
- GtkWidget *ancestor;
- GtkWidget *parent;
-
- g_return_val_if_fail (GTK_IS_WIDGET (src_widget), FALSE);
- g_return_val_if_fail (GTK_IS_WIDGET (dest_widget), FALSE);
-
- ancestor = gtk_widget_common_ancestor (src_widget, dest_widget);
- if (!ancestor)
- {
- if (dest_x)
- *dest_x = 0;
- if (dest_y)
- *dest_y = 0;
- return FALSE;
- }
-
-
- parent = src_widget;
- while (parent != ancestor)
- {
- int origin_x, origin_y;
-
- gtk_widget_get_origin_relative_to_parent (parent, &origin_x, &origin_y);
-
- src_x += origin_x;
- src_y += origin_y;
-
- parent = _gtk_widget_get_parent (parent);
- }
-
- parent = dest_widget;
- while (parent != ancestor)
- {
- int origin_x, origin_y;
-
- gtk_widget_get_origin_relative_to_parent (parent, &origin_x, &origin_y);
-
- src_x -= origin_x;
- src_y -= origin_y;
+ double x, y;
- parent = _gtk_widget_get_parent (parent);
- }
+ if (!gtk_widget_translate_coordinatesf (src_widget, dest_widget,
+ src_x, src_y, &x, &y))
+ return FALSE;
if (dest_x)
- *dest_x = src_x;
+ *dest_x =x;
if (dest_y)
- *dest_y = src_y;
+ *dest_y = y;
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]