summaryrefslogtreecommitdiff
path: root/gtk/gtktext.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-06-26 22:22:47 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-06-26 22:22:47 -0400
commit0d10982379ed4748137a5738b6eabc297201806f (patch)
treeda90a61b2ccca25a13b5cd4f2d1314ae929aad20 /gtk/gtktext.c
parentc20a966f06256b1e8b8cc7663151a0a9760a0265 (diff)
downloadgtk+-0d10982379ed4748137a5738b6eabc297201806f.tar.gz
text: Support reverse selection
Take ordering of cursor_position and selection_bound into account when copying text to the clipboard, and ensure that both orders work the same. Fixes: #2898
Diffstat (limited to 'gtk/gtktext.c')
-rw-r--r--gtk/gtktext.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 1ba21144c1..3dda4162cd 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -4025,7 +4025,11 @@ gtk_text_copy_clipboard (GtkText *self)
return;
}
- str = gtk_text_get_display_text (self, priv->selection_bound, priv->current_pos);
+ if (priv->selection_bound < priv->current_pos)
+ str = gtk_text_get_display_text (self, priv->selection_bound, priv->current_pos);
+ else
+ str = gtk_text_get_display_text (self, priv->current_pos, priv->selection_bound);
+
gdk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (self)), str);
g_free (str);
}