forked from AuroraMiddleware/gtk
Merge branch 'cursor-aspect-ratio' into 'master'
Add a cursor-aspect-ratio setting See merge request GNOME/gtk!1597
This commit is contained in:
commit
63c6af8d13
@ -144,6 +144,7 @@ enum {
|
||||
PROP_CURSOR_BLINK_TIME,
|
||||
PROP_CURSOR_BLINK_TIMEOUT,
|
||||
PROP_SPLIT_CURSOR,
|
||||
PROP_CURSOR_ASPECT_RATIO,
|
||||
PROP_THEME_NAME,
|
||||
PROP_ICON_THEME_NAME,
|
||||
PROP_DND_DRAG_THRESHOLD,
|
||||
@ -383,6 +384,15 @@ gtk_settings_class_init (GtkSettingsClass *class)
|
||||
TRUE,
|
||||
GTK_PARAM_READWRITE));
|
||||
g_assert (result == PROP_SPLIT_CURSOR);
|
||||
|
||||
result = settings_install_property_parser (class,
|
||||
g_param_spec_float ("gtk-cursor-aspect-ratio",
|
||||
P_("Cursor Aspect Ratio"),
|
||||
P_("The aspect ratio of the text caret"),
|
||||
0.0, 1.0, 0.04,
|
||||
GTK_PARAM_READWRITE));
|
||||
g_assert (result == PROP_CURSOR_ASPECT_RATIO);
|
||||
|
||||
result = settings_install_property_parser (class,
|
||||
g_param_spec_string ("gtk-theme-name",
|
||||
P_("Theme Name"),
|
||||
|
@ -1084,6 +1084,7 @@ draw_insertion_cursor (GtkStyleContext *context,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble height,
|
||||
float aspect_ratio,
|
||||
gboolean is_primary,
|
||||
PangoDirection direction,
|
||||
gboolean draw_arrow)
|
||||
@ -1099,7 +1100,7 @@ draw_insertion_cursor (GtkStyleContext *context,
|
||||
_gtk_style_context_get_cursor_color (context, &primary_color, &secondary_color);
|
||||
gdk_cairo_set_source_rgba (cr, is_primary ? &primary_color : &secondary_color);
|
||||
|
||||
stem_width = height * CURSOR_ASPECT_RATIO + 1;
|
||||
stem_width = height * aspect_ratio + 1;
|
||||
|
||||
/* put (stem_width % 2) on the proper side of the cursor */
|
||||
if (direction == PANGO_DIRECTION_LTR)
|
||||
@ -1146,6 +1147,7 @@ draw_insertion_cursor (GtkStyleContext *context,
|
||||
|
||||
static void
|
||||
get_insertion_cursor_bounds (gdouble height,
|
||||
float aspect_ratio,
|
||||
PangoDirection direction,
|
||||
gboolean draw_arrow,
|
||||
graphene_rect_t *bounds)
|
||||
@ -1153,7 +1155,7 @@ get_insertion_cursor_bounds (gdouble height,
|
||||
gint stem_width;
|
||||
gint offset;
|
||||
|
||||
stem_width = height * CURSOR_ASPECT_RATIO + 1;
|
||||
stem_width = height * aspect_ratio + 1;
|
||||
if (direction == PANGO_DIRECTION_LTR)
|
||||
offset = stem_width / 2;
|
||||
else
|
||||
@ -1186,6 +1188,7 @@ static void
|
||||
snapshot_insertion_cursor (GtkSnapshot *snapshot,
|
||||
GtkStyleContext *context,
|
||||
gdouble height,
|
||||
float aspect_ratio,
|
||||
gboolean is_primary,
|
||||
PangoDirection direction,
|
||||
gboolean draw_arrow)
|
||||
@ -1195,10 +1198,10 @@ snapshot_insertion_cursor (GtkSnapshot *snapshot,
|
||||
cairo_t *cr;
|
||||
graphene_rect_t bounds;
|
||||
|
||||
get_insertion_cursor_bounds (height, direction, draw_arrow, &bounds);
|
||||
get_insertion_cursor_bounds (height, aspect_ratio, direction, draw_arrow, &bounds);
|
||||
cr = gtk_snapshot_append_cairo (snapshot, &bounds);
|
||||
|
||||
draw_insertion_cursor (context, cr, 0, 0, height, is_primary, direction, draw_arrow);
|
||||
draw_insertion_cursor (context, cr, 0, 0, height, aspect_ratio, is_primary, direction, draw_arrow);
|
||||
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
@ -1211,7 +1214,7 @@ snapshot_insertion_cursor (GtkSnapshot *snapshot,
|
||||
|
||||
_gtk_style_context_get_cursor_color (context, &primary_color, &secondary_color);
|
||||
|
||||
stem_width = height * CURSOR_ASPECT_RATIO + 1;
|
||||
stem_width = height * aspect_ratio + 1;
|
||||
|
||||
/* put (stem_width % 2) on the proper side of the cursor */
|
||||
if (direction == PANGO_DIRECTION_LTR)
|
||||
@ -1291,6 +1294,7 @@ gtk_render_insertion_cursor (GtkStyleContext *context,
|
||||
x + PANGO_PIXELS (cursor1->x),
|
||||
y + PANGO_PIXELS (cursor1->y),
|
||||
PANGO_PIXELS (cursor1->height),
|
||||
0.04,
|
||||
TRUE,
|
||||
direction,
|
||||
direction2 != PANGO_DIRECTION_NEUTRAL);
|
||||
@ -1302,6 +1306,7 @@ gtk_render_insertion_cursor (GtkStyleContext *context,
|
||||
x + PANGO_PIXELS (cursor2->x),
|
||||
y + PANGO_PIXELS (cursor2->y),
|
||||
PANGO_PIXELS (cursor2->height),
|
||||
0.04,
|
||||
FALSE,
|
||||
direction2,
|
||||
TRUE);
|
||||
@ -1331,6 +1336,7 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot,
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
gboolean split_cursor;
|
||||
float aspect_ratio;
|
||||
PangoRectangle strong_pos, weak_pos;
|
||||
PangoRectangle *cursor1, *cursor2;
|
||||
PangoDirection keymap_direction;
|
||||
@ -1343,6 +1349,7 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot,
|
||||
|
||||
g_object_get (gtk_settings_get_for_display (priv->display),
|
||||
"gtk-split-cursor", &split_cursor,
|
||||
"gtk-cursor-aspect-ratio", &aspect_ratio,
|
||||
NULL);
|
||||
|
||||
keymap_direction = gdk_keymap_get_direction (gdk_display_get_keymap (priv->display));
|
||||
@ -1374,6 +1381,7 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot,
|
||||
snapshot_insertion_cursor (snapshot,
|
||||
context,
|
||||
PANGO_PIXELS (cursor1->height),
|
||||
aspect_ratio,
|
||||
TRUE,
|
||||
direction,
|
||||
direction2 != PANGO_DIRECTION_NEUTRAL);
|
||||
@ -1386,6 +1394,7 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot,
|
||||
snapshot_insertion_cursor (snapshot,
|
||||
context,
|
||||
PANGO_PIXELS (cursor2->height),
|
||||
aspect_ratio,
|
||||
FALSE,
|
||||
direction2,
|
||||
TRUE);
|
||||
|
@ -10,7 +10,7 @@ echo "1..1"
|
||||
name=gtk-query-settings
|
||||
result=$TEST_RESULT_DIR/$name.out
|
||||
$GTK_QUERY_SETTINGS 2>/dev/null >$result
|
||||
if [ $(wc -l $result | cut -f1 -d' ') -eq 48 ]; then
|
||||
if [ $(wc -l $result | cut -f1 -d' ') -eq 49 ]; then
|
||||
echo "ok 1 $name"
|
||||
else
|
||||
echo "not ok 1 $name"
|
||||
|
Loading…
Reference in New Issue
Block a user