Commit 3c684222 authored by Paolo Borelli's avatar Paolo Borelli

Use the split-cursor setting for textview cursors

Explicitely check the split-cursor setting when drawing the textview
insertion cursor instead of relying on the cursor_direction set in the
textlayout. This makes the cursor drawin code more uniform with other
widgets in preparation to refactoring the cursor drawing code in a
shared function.

https://bugzilla.gnome.org/show_bug.cgi?id=640317
parent 0bff1af7
......@@ -912,39 +912,56 @@ gtk_text_layout_draw (GtkTextLayout *layout,
{
int index;
PangoRectangle strong_pos, weak_pos;
PangoRectangle *cursor1, *cursor2;
gboolean split_cursor;
GtkTextDirection dir1, dir2;
GdkRectangle cursor_location;
index = g_array_index(line_display->cursors, int, i);
pango_layout_get_cursor_pos (line_display->layout, index, &strong_pos, &weak_pos);
cursor_location.x = line_display->x_offset + PANGO_PIXELS (strong_pos.x);
cursor_location.y = line_display->top_margin + PANGO_PIXELS (strong_pos.y);
cursor_location.width = 0;
cursor_location.height = PANGO_PIXELS (strong_pos.height);
dir1 = line_display->direction;
dir2 = GTK_TEXT_DIR_NONE;
g_object_get (gtk_widget_get_settings (widget),
"gtk-split-cursor", &split_cursor,
NULL);
if (layout->cursor_direction == GTK_TEXT_DIR_NONE ||
line_display->direction == layout->cursor_direction)
if (split_cursor)
{
gtk_draw_insertion_cursor (widget, cr,
&cursor_location, TRUE, line_display->direction,
layout->cursor_direction != GTK_TEXT_DIR_NONE);
cursor1 = &strong_pos;
if (strong_pos.x != weak_pos.x || strong_pos.y != weak_pos.y)
{
dir2 = (line_display->direction == GTK_TEXT_DIR_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
cursor2 = &weak_pos;
}
}
if ((strong_pos.x != weak_pos.x || strong_pos.y != weak_pos.y) &&
(layout->cursor_direction == GTK_TEXT_DIR_NONE ||
line_display->direction != layout->cursor_direction))
else
{
GtkTextDirection dir;
if (layout->keyboard_direction == line_display->direction)
cursor1 = &strong_pos;
else
cursor1 = &weak_pos;
}
cursor_location.x = line_display->x_offset + PANGO_PIXELS (cursor1->x);
cursor_location.y = line_display->top_margin + PANGO_PIXELS (cursor1->y);
cursor_location.width = 0;
cursor_location.height = PANGO_PIXELS (cursor1->height);
dir = (line_display->direction == GTK_TEXT_DIR_RTL) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
gtk_draw_insertion_cursor (widget, cr,
&cursor_location, TRUE, dir1,
dir2 != GTK_TEXT_DIR_NONE);
cursor_location.x = line_display->x_offset + PANGO_PIXELS (weak_pos.x);
cursor_location.y = line_display->top_margin + PANGO_PIXELS (weak_pos.y);
if (dir2 != GTK_TEXT_DIR_NONE)
{
cursor_location.x = line_display->x_offset + PANGO_PIXELS (cursor2->x);
cursor_location.y = line_display->top_margin + PANGO_PIXELS (cursor2->y);
cursor_location.width = 0;
cursor_location.height = PANGO_PIXELS (weak_pos.height);
cursor_location.height = PANGO_PIXELS (cursor2->height);
gtk_draw_insertion_cursor (widget, cr,
&cursor_location, FALSE, dir,
&cursor_location, FALSE, dir2,
TRUE);
}
}
......
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