Commit 36930455 authored by Carlos Garnacho's avatar Carlos Garnacho

textview: Mind the lateral windows when setting handles/popovers positions

If a textview had lateral windows that might displace the text window, the
handles and popovers would appear displaced. Those lateral windows aren't
affected by RTL/LTR settings, so just checking for left/top is ok here.
parent 41b73e40
......@@ -4587,6 +4587,32 @@ emit_event_on_tags (GtkWidget *widget,
return retval;
}
static void
_text_window_to_widget_coords (GtkTextView *text_view,
gint *x,
gint *y)
{
GtkTextViewPrivate *priv = text_view->priv;
if (priv->top_window)
(*y) += priv->top_window->requisition.height;
if (priv->left_window)
(*x) += priv->left_window->requisition.width;
}
static void
_widget_to_text_window_coords (GtkTextView *text_view,
gint *x,
gint *y)
{
GtkTextViewPrivate *priv = text_view->priv;
if (priv->top_window)
(*y) -= priv->top_window->requisition.height;
if (priv->left_window)
(*x) -= priv->left_window->requisition.width;
}
static void
gtk_text_view_set_handle_position (GtkTextView *text_view,
GtkTextIter *iter,
......@@ -4617,6 +4643,8 @@ gtk_text_view_set_handle_position (GtkTextView *text_view,
rect.x = CLAMP (x, 0, SCREEN_WIDTH (text_view));
rect.y = CLAMP (y, 0, SCREEN_HEIGHT (text_view));
_text_window_to_widget_coords (text_view, &rect.x, &rect.y);
_gtk_text_handle_set_position (priv->text_handle, pos, &rect);
}
}
......@@ -4639,6 +4667,7 @@ gtk_text_view_show_magnifier (GtkTextView *text_view,
rect.x = x;
rect.y = y;
rect.width = rect.height = 1;
_text_window_to_widget_coords (text_view, &rect.x, &rect.y);
_gtk_magnifier_set_coords (GTK_MAGNIFIER (priv->magnifier), x, y);
gtk_popover_set_pointing_to (GTK_POPOVER (priv->magnifier_popover),
......@@ -4665,6 +4694,8 @@ gtk_text_view_handle_dragged (GtkTextHandle *handle,
buffer = get_buffer (text_view);
mode = _gtk_text_handle_get_mode (handle);
_widget_to_text_window_coords (text_view, &x, &y);
gtk_text_view_selection_bubble_popup_unset (text_view);
gtk_text_layout_get_iter_at_pixel (priv->layout, &iter,
x + priv->xoffset,
......@@ -9008,6 +9039,8 @@ bubble_targets_received (GtkClipboard *clipboard,
rect.x -= priv->xoffset;
rect.y -= priv->yoffset;
_text_window_to_widget_coords (text_view, &rect.x, &rect.y);
gtk_popover_set_pointing_to (GTK_POPOVER (priv->selection_bubble), &rect);
gtk_widget_show (priv->selection_bubble);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment