texthandle: Mind the invisible area when moving the handle

The handle is still centered horizontally, but the extra vertical
space wasn't taken into account, leading to misplacing the dragging
point (and the handle) during motion events.
This commit is contained in:
Carlos Garnacho 2014-05-21 14:58:50 +02:00
parent c9f54aef69
commit ca1510177c

View File

@ -193,14 +193,18 @@ gtk_text_handle_widget_event (GtkWidget *widget,
event->motion.state & GDK_BUTTON1_MASK &&
priv->windows[pos].dragged)
{
gint x, y, width, height;
gint x, y, width, height, handle_height;
GtkAllocation allocation;
_gtk_text_handle_get_size (handle, &width, &height);
gtk_widget_get_allocation (priv->windows[pos].widget, &allocation);
width = allocation.width;
height = allocation.height;
_gtk_text_handle_get_size (handle, NULL, &handle_height);
x = event->motion.x - priv->windows[pos].dx + (width / 2);
y = event->motion.y - priv->windows[pos].dy;
if (pos != GTK_TEXT_HANDLE_POSITION_CURSOR)
y += height;
y += height - handle_height;
y += priv->windows[pos].pointing_to.height / 2;