TextView: Fix gesture coords with :border-width >0
authorDaniel Boles <dboles@src.gnome.org>
Mon, 28 Aug 2017 20:56:06 +0000 (21:56 +0100)
committerDaniel Boles <dboles@src.gnome.org>
Mon, 28 Aug 2017 21:28:49 +0000 (22:28 +0100)
Container:border-width caused the x/y coords converted to iters to be
offset inwards by that width, breaking positioning/selecting by gesture.

So, subtract :border-width in widget_to_text_window_coords(). This fixes
gesture positions, & plays fine with :margin & CSS margin/border/padding

N.B.: This is not to endorse :border-width. It’s gone in GTK+ 4 & weird
on a TextView: it’d be more intuitive to – if you must! – set it on the
TV parent. Really, please just use CSS instead. Still, it’s easy to fix.

https://bugzilla.gnome.org/show_bug.cgi?id=759725

gtk/gtktextview.c

index c40ac2e67cb04886b03e931a9aa99295af7f5b16..f267c6c02dd83b5595bb3fa625cdfb6894ff4e17 100644 (file)
@@ -5083,6 +5083,10 @@ _widget_to_text_window_coords (GtkTextView *text_view,
                                gint        *y)
 {
   GtkTextViewPrivate *priv = text_view->priv;
+  gint border_width = gtk_container_get_border_width (GTK_CONTAINER (text_view));
+
+  *x -= border_width;
+  *y -= border_width;
 
   if (priv->top_window)
     (*y) -= priv->top_window->requisition.height;