Compare commits

...

8 Commits

Author SHA1 Message Date
Matthias Clasen
79ba8a5f8e Document new CSS properties
Add caret-animation, caret-shape and the caret shorthand to the docs.
2016-01-11 00:09:34 -05:00
Matthias Clasen
7061fe1c6a text view: Resepct caret-shape CSS property
When drawing the text cursor, consult the caret-shape property
to determine what kind of cursor to draw. To implement this, we
had to slightly change the way GtkTextLineDisplay is used.
Previously, GtkTextLayout would either fill in the block_cursor
rectangle or the cursors array, depending on what cursor shape
is needed. Now, we fill them both in and decide at render time
which one to use.
2016-01-10 23:56:22 -05:00
Matthias Clasen
465a844bad text view: Respect caret-animation CSS property
When deciding whether to blink the caret in an entry, consult
the caret-animation property.
2016-01-10 22:50:21 -05:00
Matthias Clasen
e76dafbc90 Implement the caret shorthand property
Implement the caret shorthand property as defined in
http://www.w3.org/TR/css-ui-4/

This allows to set color-shape, caret-animation and caret-color
at the same time. We always set -gtk-secondary-caret-color to
the same color as caret-color.
2016-01-10 22:41:59 -05:00
Matthias Clasen
6c97f43858 entry: Respect caret-animation CSS property
When deciding whether to blink the caret in an entry, consult
the caret-animation property.
2016-01-10 19:01:33 -05:00
Matthias Clasen
fe2b16afda Add the caret-animation CSS property
This allows to override the caret blinking from the theme.
The default value, auto, means to do things as we always have.
2016-01-10 18:53:47 -05:00
Matthias Clasen
1283f42bac entry: Respect caret-shape CSS property
When drawing the text cursor, consult the caret-shape property
to determine what kind of cursor to draw.
2016-01-10 18:27:49 -05:00
Matthias Clasen
016e510f9b Add the caret-shape CSS property
This allows to override the text caret shape (I-beam or block) from
the theme. The default value, auto, means to do things as we always have.
2016-01-10 18:26:42 -05:00
10 changed files with 379 additions and 35 deletions

View File

@@ -257,10 +257,64 @@ We use <literallayout> for syntax productions, and each line is put in a <code>
<entry></entry>
<entry>Used for the secondary caret in bidirectional text</entry>
</row>
<row>
<entry>caret-animation</entry>
<entry><code>〈caret animation〉</code></entry>
<entry><code>auto</code></entry>
<entry></entry>
<entry></entry>
<entry><ulink url="http://www.w3.org/TR/css-ui-4/#caret-animation">CSS4</ulink></entry>
<entry>CSS allows a fade value</entry>
</row>
<row>
<entry>caret-shape</entry>
<entry><code>〈caret shape〉</code></entry>
<entry><code>auto</code></entry>
<entry></entry>
<entry></entry>
<entry><ulink url="http://www.w3.org/TR/css-ui-4/#caret-shape">CSS4</ulink></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
<tgroup cols="5">
<thead>
<row><entry>Shorthand</entry><entry>Value</entry><entry>Initial</entry><entry>Reference</entry><entry>Notes</entry></row>
</thead>
<tbody>
<row>
<entry>caret</entry>
<entry><code>〈caret-color〉 || 〈caret-animation〉 || 〈caret-shape〉</code></entry>
<entry>see individual properties</entry>
<entry><ulink url="http://www.w3.org/TR/css-ui-4/#caret">CSS4</ulink></entry>
<entry>-gtk-secondary-caret-color is set to the same value as caret-color</entry>
</row>
</tbody>
</tgroup>
</table>
<literallayout><code>〈caret animation〉 = auto | blink | none</code>
<code>〈caret shape〉 = auto | bar | block | underscore</code>
</literallayout>
<para>
The text decoration properties determine whether to apply extra decorations
when rendering text.
</para>
<table pgwide="1">
<title>Icon Properties</title>
<tgroup cols="7">
<colspec colnum="4" align="center"/>
<colspec colnum="5" align="center"/>
<thead>
<row><entry>Name</entry><entry>Value</entry><entry>Initial</entry><entry>Inh.</entry><entry>Ani.</entry><entry>Reference</entry><entry>Notes</entry></row>
</thead>
<tbody>
<row>
<entry>gtkiconsource</entry>
<entry><code>builtin | 〈image〉 | none</code></entry>
<entry><code>builtin</code></entry>
<para>
The caret properties provide a way to change the appearance of the insertion
caret in editable text.

View File

@@ -1009,3 +1009,112 @@ _gtk_css_icon_style_value_get (const GtkCssValue *value)
return value->value;
}
/* GtkCssCaretShape */
static const GtkCssValueClass GTK_CSS_VALUE_CARET_SHAPE = {
gtk_css_value_enum_free,
gtk_css_value_enum_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
};
static GtkCssValue caret_shape_values[] = {
{ &GTK_CSS_VALUE_CARET_SHAPE, 1, GTK_CSS_CARET_SHAPE_AUTO, "auto" },
{ &GTK_CSS_VALUE_CARET_SHAPE, 1, GTK_CSS_CARET_SHAPE_BAR, "bar" },
{ &GTK_CSS_VALUE_CARET_SHAPE, 1, GTK_CSS_CARET_SHAPE_BLOCK, "block" },
{ &GTK_CSS_VALUE_CARET_SHAPE, 1, GTK_CSS_CARET_SHAPE_UNDERSCORE, "underscore" },
};
GtkCssValue *
_gtk_css_caret_shape_value_new (GtkCssCaretShape caret_shape)
{
guint i;
for (i = 0; i < G_N_ELEMENTS (caret_shape_values); i++)
{
if (caret_shape_values[i].value == caret_shape)
return _gtk_css_value_ref (&caret_shape_values[i]);
}
g_return_val_if_reached (NULL);
}
GtkCssValue *
_gtk_css_caret_shape_value_try_parse (GtkCssParser *parser)
{
guint i;
g_return_val_if_fail (parser != NULL, NULL);
for (i = 0; i < G_N_ELEMENTS (caret_shape_values); i++)
{
if (_gtk_css_parser_try (parser, caret_shape_values[i].name, TRUE))
return _gtk_css_value_ref (&caret_shape_values[i]);
}
return NULL;
}
GtkCssCaretShape
_gtk_css_caret_shape_value_get (const GtkCssValue *value)
{
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_CARET_SHAPE, GTK_CSS_CARET_SHAPE_AUTO);
return value->value;
}
/* GtkCssCaretAnimation */
static const GtkCssValueClass GTK_CSS_VALUE_CARET_ANIMATION = {
gtk_css_value_enum_free,
gtk_css_value_enum_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
};
static GtkCssValue caret_animation_values[] = {
{ &GTK_CSS_VALUE_CARET_ANIMATION, 1, GTK_CSS_CARET_ANIMATION_AUTO, "auto" },
{ &GTK_CSS_VALUE_CARET_ANIMATION, 1, GTK_CSS_CARET_ANIMATION_BLINK, "blink" },
{ &GTK_CSS_VALUE_CARET_ANIMATION, 1, GTK_CSS_CARET_ANIMATION_NONE, "none" },
};
GtkCssValue *
_gtk_css_caret_animation_value_new (GtkCssCaretAnimation caret_animation)
{
guint i;
for (i = 0; i < G_N_ELEMENTS (caret_animation_values); i++)
{
if (caret_animation_values[i].value == caret_animation)
return _gtk_css_value_ref (&caret_animation_values[i]);
}
g_return_val_if_reached (NULL);
}
GtkCssValue *
_gtk_css_caret_animation_value_try_parse (GtkCssParser *parser)
{
guint i;
g_return_val_if_fail (parser != NULL, NULL);
for (i = 0; i < G_N_ELEMENTS (caret_animation_values); i++)
{
if (_gtk_css_parser_try (parser, caret_animation_values[i].name, TRUE))
return _gtk_css_value_ref (&caret_animation_values[i]);
}
return NULL;
}
GtkCssCaretAnimation
_gtk_css_caret_animation_value_get (const GtkCssValue *value)
{
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_CARET_ANIMATION, GTK_CSS_CARET_ANIMATION_AUTO);
return value->value;
}

View File

@@ -86,6 +86,14 @@ GtkCssValue * _gtk_css_icon_style_value_new (GtkCssIconStyle icon_s
GtkCssValue * _gtk_css_icon_style_value_try_parse (GtkCssParser *parser);
GtkCssIconStyle _gtk_css_icon_style_value_get (const GtkCssValue *value);
GtkCssValue * _gtk_css_caret_shape_value_new (GtkCssCaretShape caret_shape);
GtkCssValue * _gtk_css_caret_shape_value_try_parse (GtkCssParser *parser);
GtkCssCaretShape _gtk_css_caret_shape_value_get (const GtkCssValue *value);
GtkCssValue * _gtk_css_caret_animation_value_new (GtkCssCaretAnimation caret_animation);
GtkCssValue * _gtk_css_caret_animation_value_try_parse (GtkCssParser *parser);
GtkCssCaretAnimation _gtk_css_caret_animation_value_get (const GtkCssValue *value);
G_END_DECLS
#endif /* __GTK_CSS_ENUM_VALUE_PRIVATE_H__ */

View File

@@ -868,6 +868,47 @@ parse_text_decoration (GtkCssShorthandProperty *shorthand,
return TRUE;
}
static gboolean
parse_caret (GtkCssShorthandProperty *shorthand,
GtkCssValue **values,
GtkCssParser *parser)
{
do
{
if (values[0] == NULL &&
(values[0] = _gtk_css_caret_shape_value_try_parse (parser)))
{
if (values[0] == NULL)
return FALSE;
}
else if (values[1] == NULL &&
(values[1] = _gtk_css_caret_animation_value_try_parse (parser)))
{
if (values[1] == NULL)
return FALSE;
}
else if (values[2] == NULL)
{
values[2] = _gtk_css_color_value_parse (parser);
if (values[2] == NULL)
return FALSE;
values[3] = _gtk_css_value_ref (values[2]);
}
else
{
/* We parsed and there's still stuff left?
* Pretend we didn't notice and let the normal code produce
* a 'junk at end of value' error
*/
break;
}
}
while (!value_is_done_parsing (parser));
return TRUE;
}
static gboolean
parse_all (GtkCssShorthandProperty *shorthand,
GtkCssValue **values,
@@ -1216,6 +1257,7 @@ _gtk_css_shorthand_property_init_properties (void)
const char *animation_subproperties[] = { "animation-name", "animation-iteration-count", "animation-duration", "animation-delay",
"animation-timing-function", "animation-direction", "animation-fill-mode", NULL };
const char *text_decoration_subproperties[] = { "text-decoration-line", "text-decoration-style", "text-decoration-color", NULL };
const char *caret_subproperties[] = { "caret-shape", "caret-animation", "caret-color", "-gtk-secondary-caret-color", NULL };
const char **all_subproperties;
@@ -1334,6 +1376,12 @@ _gtk_css_shorthand_property_init_properties (void)
parse_text_decoration,
NULL,
NULL);
_gtk_css_shorthand_property_register ("caret",
G_TYPE_NONE,
caret_subproperties,
parse_caret,
NULL,
NULL);
all_subproperties = get_all_subproperties ();
_gtk_css_shorthand_property_register ("all",

View File

@@ -1007,6 +1007,30 @@ icon_theme_value_parse (GtkCssStyleProperty *property,
return gtk_css_icon_theme_value_parse (parser);
}
static GtkCssValue *
caret_shape_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
GtkCssValue *value = _gtk_css_caret_shape_value_try_parse (parser);
if (value == NULL)
_gtk_css_parser_error (parser, "unknown value for property");
return value;
}
static GtkCssValue *
caret_animation_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
GtkCssValue *value = _gtk_css_caret_animation_value_try_parse (parser);
if (value == NULL)
_gtk_css_parser_error (parser, "unknown value for property");
return value;
}
/*** REGISTRATION ***/
void
@@ -1820,4 +1844,22 @@ G_GNUC_END_IGNORE_DEPRECATIONS
color_query,
color_assign,
_gtk_css_color_value_new_current_color ());
gtk_css_style_property_register ("caret-shape",
GTK_CSS_PROPERTY_CARET_SHAPE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_TEXT,
caret_shape_parse,
NULL,
NULL,
_gtk_css_caret_shape_value_new (GTK_CSS_CARET_SHAPE_AUTO));
gtk_css_style_property_register ("caret-animation",
GTK_CSS_PROPERTY_CARET_ANIMATION,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_TEXT,
caret_animation_parse,
NULL,
NULL,
_gtk_css_caret_animation_value_new (GTK_CSS_CARET_ANIMATION_AUTO));
}

View File

@@ -224,6 +224,8 @@ enum { /*< skip >*/
GTK_CSS_PROPERTY_GTK_KEY_BINDINGS,
GTK_CSS_PROPERTY_CARET_COLOR,
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
GTK_CSS_PROPERTY_CARET_SHAPE,
GTK_CSS_PROPERTY_CARET_ANIMATION,
/* add more */
GTK_CSS_PROPERTY_N_PROPERTIES
};
@@ -363,6 +365,19 @@ typedef enum /*< skip >*/ {
GTK_CSS_MS,
} GtkCssUnit;
typedef enum /*< skip >*/ {
GTK_CSS_CARET_SHAPE_AUTO,
GTK_CSS_CARET_SHAPE_BAR,
GTK_CSS_CARET_SHAPE_BLOCK,
GTK_CSS_CARET_SHAPE_UNDERSCORE
} GtkCssCaretShape;
typedef enum /*< skip >*/ {
GTK_CSS_CARET_ANIMATION_AUTO,
GTK_CSS_CARET_ANIMATION_BLINK,
GTK_CSS_CARET_ANIMATION_NONE
} GtkCssCaretAnimation;
GtkCssChange _gtk_css_change_for_sibling (GtkCssChange match);
GtkCssChange _gtk_css_change_for_child (GtkCssChange match);

View File

@@ -71,6 +71,7 @@
#include "gtkmagnifierprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcsscustomgadgetprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "a11y/gtkentryaccessible.h"
@@ -6634,6 +6635,8 @@ gtk_entry_draw_cursor (GtkEntry *entry,
PangoLayout *layout;
const char *text;
gint x, y;
GtkCssValue *value;
GtkCssCaretShape shape;
context = gtk_widget_get_style_context (widget);
@@ -6646,19 +6649,32 @@ gtk_entry_draw_cursor (GtkEntry *entry,
else
cursor_index = g_utf8_offset_to_pointer (text, priv->current_pos + priv->preedit_cursor) - text;
if (!priv->overwrite_mode)
block = FALSE;
else
block = _gtk_text_util_get_block_cursor_location (layout,
cursor_index, &cursor_rect, &block_at_line_end);
block = _gtk_text_util_get_block_cursor_location (layout,
cursor_index, &cursor_rect, &block_at_line_end);
if (!block)
shape = GTK_CSS_CARET_SHAPE_BAR;
else
{
value = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_CARET_SHAPE);
shape = _gtk_css_caret_shape_value_get (value);
if (shape == GTK_CSS_CARET_SHAPE_AUTO)
{
if (priv->overwrite_mode)
shape = GTK_CSS_CARET_SHAPE_BLOCK;
else
shape = GTK_CSS_CARET_SHAPE_BAR;
}
}
if (shape == GTK_CSS_CARET_SHAPE_BAR)
{
gtk_render_insertion_cursor (context, cr,
x, y,
layout, cursor_index, priv->resolved_dir);
}
else /* overwrite_mode */
else
{
GdkRGBA cursor_color;
GdkRectangle rect;
@@ -6670,6 +6686,12 @@ gtk_entry_draw_cursor (GtkEntry *entry,
rect.width = PANGO_PIXELS (cursor_rect.width);
rect.height = PANGO_PIXELS (cursor_rect.height);
if (shape == GTK_CSS_CARET_SHAPE_UNDERSCORE)
{
rect.y = rect.y + rect.height - 1;
rect.height = 1;
}
_gtk_style_context_get_cursor_color (context, &cursor_color, NULL);
gdk_cairo_set_source_rgba (cr, &cursor_color);
gdk_cairo_rectangle (cr, &rect);
@@ -10323,11 +10345,25 @@ cursor_blinks (GtkEntry *entry)
priv->editable &&
priv->selection_bound == priv->current_pos)
{
GtkSettings *settings;
gboolean blink;
GtkStyleContext *context;
GtkCssValue *value;
GtkCssCaretAnimation anim;
settings = gtk_widget_get_settings (GTK_WIDGET (entry));
g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
context = gtk_widget_get_style_context (GTK_WIDGET (entry));
value = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_CARET_ANIMATION);
anim = _gtk_css_caret_animation_value_get (value);
if (anim == GTK_CSS_CARET_ANIMATION_AUTO)
{
GtkSettings *settings;
settings = gtk_widget_get_settings (GTK_WIDGET (entry));
g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
}
else if (anim == GTK_CSS_CARET_ANIMATION_BLINK)
blink = TRUE;
else
blink = FALSE;
return blink;
}

View File

@@ -80,6 +80,7 @@
#include "gtkwidgetprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkintl.h"
#include "gtkcssenumvalueprivate.h"
/* DO NOT go putting private headers in here. This file should only
* use the semi-public headers, as with gtktextview.c.
@@ -592,7 +593,7 @@ get_selected_clip (GtkTextRenderer *text_renderer,
rect.y = y;
rect.width = PANGO_PIXELS (ranges[2*i + 1]) - PANGO_PIXELS (ranges[2*i]);
rect.height = height;
cairo_region_union_rectangle (clip_region, &rect);
}
@@ -604,7 +605,8 @@ static void
render_para (GtkTextRenderer *text_renderer,
GtkTextLineDisplay *line_display,
int selection_start_index,
int selection_end_index)
int selection_end_index,
GtkCssCaretShape shape)
{
GtkStyleContext *context;
PangoLayout *layout = line_display->layout;
@@ -621,7 +623,7 @@ render_para (GtkTextRenderer *text_renderer,
pango_layout_iter_get_layout_extents (iter, NULL, &layout_logical);
/* Adjust for margins */
layout_logical.x += line_display->x_offset * PANGO_SCALE;
layout_logical.y += line_display->top_margin * PANGO_SCALE;
@@ -635,7 +637,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &selection);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_style_context_restore (context);
gtk_style_context_restore (context);
do
{
@@ -645,11 +647,11 @@ G_GNUC_END_IGNORE_DEPRECATIONS
PangoRectangle line_rect;
int baseline;
gboolean at_last_line;
pango_layout_iter_get_line_extents (iter, NULL, &line_rect);
baseline = pango_layout_iter_get_baseline (iter);
pango_layout_iter_get_line_yrange (iter, &first_y, &last_y);
/* Adjust for margins */
line_rect.x += line_display->x_offset * PANGO_SCALE;
@@ -671,7 +673,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
at_last_line = pango_layout_iter_at_last_line (iter);
if (at_last_line)
selection_height += line_display->bottom_margin;
first = FALSE;
if (selection_start_index < byte_offset &&
@@ -681,7 +683,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cairo_save (cr);
gdk_cairo_set_source_rgba (cr, &selection);
cairo_rectangle (cr,
cairo_rectangle (cr,
line_display->left_margin, selection_y,
screen_width, selection_height);
cairo_fill (cr);
@@ -795,6 +797,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
}
}
else if (line_display->has_block_cursor &&
shape != GTK_CSS_CARET_SHAPE_BAR &&
gtk_widget_has_focus (text_renderer->widget) &&
byte_offset <= line_display->insert_index &&
(line_display->insert_index < byte_offset + line->length ||
@@ -805,7 +808,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cairo_t *cr = text_renderer->cr;
/* we draw text using base color on filled cursor rectangle of cursor color
* (normally white on black) */
* (normally white on black)
*/
_gtk_style_context_get_cursor_color (context, &cursor_color, NULL);
cursor_rect.x = line_display->x_offset + line_display->block_cursor.x;
@@ -813,6 +817,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS
cursor_rect.width = line_display->block_cursor.width;
cursor_rect.height = line_display->block_cursor.height;
if (shape == GTK_CSS_CARET_SHAPE_UNDERSCORE)
{
cursor_rect.y = cursor_rect.y + cursor_rect.height - 1;
cursor_rect.height = 1;
}
cairo_save (cr);
gdk_cairo_rectangle (cr, &cursor_rect);
@@ -877,6 +887,8 @@ gtk_text_layout_draw (GtkTextLayout *layout,
GSList *tmp_list;
GList *tmp_widgets;
GdkRectangle clip;
GtkCssValue *value;
GtkCssCaretShape shape;
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
g_return_if_fail (layout->default_style != NULL);
@@ -887,6 +899,15 @@ gtk_text_layout_draw (GtkTextLayout *layout,
return;
context = gtk_widget_get_style_context (widget);
value = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_CARET_SHAPE);
shape = _gtk_css_caret_shape_value_get (value);
if (shape == GTK_CSS_CARET_SHAPE_AUTO)
{
if (layout->overwrite_mode)
shape = GTK_CSS_CARET_SHAPE_BLOCK;
else
shape = GTK_CSS_CARET_SHAPE_BAR;
}
line_list = gtk_text_layout_get_lines (layout, clip.y, clip.y + clip.height, &offset_y);
@@ -949,12 +970,14 @@ gtk_text_layout_draw (GtkTextLayout *layout,
}
render_para (text_renderer, line_display,
selection_start_index, selection_end_index);
selection_start_index, selection_end_index,
shape);
/* We paint the cursors last, because they overlap another chunk
* and need to appear on top.
*/
if (line_display->cursors != NULL)
if (line_display->cursors != NULL &&
shape == GTK_CSS_CARET_SHAPE_BAR)
{
int i;

View File

@@ -1799,9 +1799,7 @@ get_block_cursor (GtkTextLayout *layout,
{
PangoRectangle pango_pos;
if (layout->overwrite_mode &&
gtk_text_iter_editable (insert_iter, TRUE) &&
_gtk_text_util_get_block_cursor_location (display->layout,
if (_gtk_text_util_get_block_cursor_location (display->layout,
insert_index,
&pango_pos,
cursor_at_line_end))
@@ -1835,8 +1833,7 @@ add_cursor (GtkTextLayout *layout,
gtk_text_buffer_get_selection_bounds (layout->buffer, NULL, NULL)))
return;
if (layout->overwrite_mode &&
_gtk_text_btree_mark_is_insert (_gtk_text_buffer_get_btree (layout->buffer),
if (_gtk_text_btree_mark_is_insert (_gtk_text_buffer_get_btree (layout->buffer),
seg->body.mark.obj))
{
GtkTextIter iter;
@@ -1851,7 +1848,6 @@ add_cursor (GtkTextLayout *layout,
{
display->has_block_cursor = TRUE;
display->cursor_at_line_end = cursor_at_line_end;
return;
}
}

View File

@@ -57,6 +57,7 @@
#include "gtktoolbar.h"
#include "gtkpixelcacheprivate.h"
#include "gtkmagnifierprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "a11y/gtktextviewaccessibleprivate.h"
@@ -6094,8 +6095,10 @@ gtk_text_view_forall (GtkContainer *container,
static gboolean
cursor_blinks (GtkTextView *text_view)
{
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (text_view));
gboolean blink;
GtkStyleContext *context;
GtkCssValue *value;
GtkCssCaretAnimation anim;
#ifdef DEBUG_VALIDATION_AND_SCROLLING
return FALSE;
@@ -6105,7 +6108,21 @@ cursor_blinks (GtkTextView *text_view)
return FALSE;
#endif
g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
value = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_CARET_ANIMATION);
anim = _gtk_css_caret_animation_value_get (value);
if (anim == GTK_CSS_CARET_ANIMATION_AUTO)
{
GtkSettings *settings;
settings = gtk_widget_get_settings (GTK_WIDGET (text_view));
g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
}
else if (anim == GTK_CSS_CARET_ANIMATION_BLINK)
blink = TRUE;
else
blink = FALSE;
if (!blink)
return FALSE;
@@ -10120,13 +10137,9 @@ text_window_invalidate_cursors (GtkTextWindow *win)
gtk_text_buffer_get_insert (priv->buffer));
if (_gtk_text_layout_get_block_cursor (priv->layout, &strong))
{
text_window_invalidate_rect (win, &strong);
return;
}
text_window_invalidate_rect (win, &strong);
gtk_text_layout_get_cursor_locations (priv->layout, &iter,
&strong, &weak);
gtk_text_layout_get_cursor_locations (priv->layout, &iter, &strong, &weak);
/* cursor width calculation as in gtkstylecontext.c:draw_insertion_cursor(),
* ignoring the text direction be exposing both sides of the cursor
@@ -10137,7 +10150,7 @@ text_window_invalidate_cursors (GtkTextWindow *win)
gtk_widget_style_get (win->widget,
"cursor-aspect-ratio", &cursor_aspect_ratio,
NULL);
stem_width = strong.height * cursor_aspect_ratio + 1;
arrow_width = stem_width + 1;