[gtk+/wip/carlosg/event-delivery: 82/104] scrolledwindow: Calculate indicator coords relative to scrolledwindow



commit e54d8a6114a87d0d83c091e9f0f7601c5461c5c3
Author: Timm B├Ąder <mail baedert org>
Date:   Tue May 9 19:26:27 2017 +0200

    scrolledwindow: Calculate indicator coords relative to scrolledwindow
    
    The event coordinates we get are relative to the scrolledwindow
    coordinates.

 gtk/gtkscrolledwindow.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index c3d437d..2eef2bf 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1083,14 +1083,21 @@ event_close_to_indicator (GtkScrolledWindow *sw,
 {
   GtkScrolledWindowPrivate *priv;
   GtkAllocation indicator_alloc;
+  GtkAllocation sw_alloc;
   gdouble x, y;
   gint distance;
 
   priv = sw->priv;
 
+  gtk_widget_get_allocation (GTK_WIDGET (sw), &sw_alloc);
   gtk_widget_get_allocation (indicator->scrollbar, &indicator_alloc);
   gdk_event_get_coords (event, &x, &y);
 
+  /* Make indicator alloc relative to scrolledwindow alloc, which is also
+   * what the event coords are relative to */
+  indicator_alloc.x -= sw_alloc.x;
+  indicator_alloc.y -= sw_alloc.y;
+
   if (indicator->over)
     distance = INDICATOR_FAR_DISTANCE;
   else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]