diff options
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/broadway/gdkdisplay-broadway.c | 1 | ||||
-rw-r--r-- | gdk/broadway/gdkprivate-broadway.h | 2 | ||||
-rw-r--r-- | gdk/broadway/gdkselection-broadway.c | 6 | ||||
-rw-r--r-- | gdk/gdkdisplayprivate.h | 2 | ||||
-rw-r--r-- | gdk/gdkproperty.h | 3 | ||||
-rw-r--r-- | gdk/gdkselection.c | 22 | ||||
-rw-r--r-- | gdk/quartz/gdkdisplay-quartz.c | 1 | ||||
-rw-r--r-- | gdk/quartz/gdkdisplay-quartz.h | 2 | ||||
-rw-r--r-- | gdk/quartz/gdkselection-quartz.c | 8 | ||||
-rw-r--r-- | gdk/wayland/gdkdisplay-wayland.c | 1 | ||||
-rw-r--r-- | gdk/wayland/gdkprivate-wayland.h | 2 | ||||
-rw-r--r-- | gdk/wayland/gdkselection-wayland.c | 65 | ||||
-rw-r--r-- | gdk/win32/gdkclipdrop-win32.c | 7 | ||||
-rw-r--r-- | gdk/win32/gdkdisplay-win32.c | 1 | ||||
-rw-r--r-- | gdk/win32/gdkprivate-win32.h | 1 | ||||
-rw-r--r-- | gdk/x11/gdkdisplay-x11.c | 1 | ||||
-rw-r--r-- | gdk/x11/gdkprivate-x11.h | 4 | ||||
-rw-r--r-- | gdk/x11/gdkselection-x11.c | 66 | ||||
-rw-r--r-- | gdk/x11/gdksurface-x11.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdktextlistconverter-x11.c | 59 |
20 files changed, 62 insertions, 194 deletions
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c index ba6dc7a9a7..f35d3f56ef 100644 --- a/gdk/broadway/gdkdisplay-broadway.c +++ b/gdk/broadway/gdkdisplay-broadway.c @@ -429,7 +429,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class) display_class->create_surface = _gdk_broadway_display_create_surface; display_class->get_keymap = _gdk_broadway_display_get_keymap; display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list; - display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target; display_class->get_n_monitors = gdk_broadway_display_get_n_monitors; display_class->get_monitor = gdk_broadway_display_get_monitor; diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h index f414d3d79c..8e8d781333 100644 --- a/gdk/broadway/gdkprivate-broadway.h +++ b/gdk/broadway/gdkprivate-broadway.h @@ -119,8 +119,6 @@ gint _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display, const guchar *text, gint length, gchar ***list); -gchar *_gdk_broadway_display_utf8_to_string_target (GdkDisplay *display, - const gchar *str); GdkKeymap* _gdk_broadway_display_get_keymap (GdkDisplay *display); void _gdk_broadway_display_consume_all_input (GdkDisplay *display); BroadwayInputMsg * _gdk_broadway_display_block_for_input (GdkDisplay *display, diff --git a/gdk/broadway/gdkselection-broadway.c b/gdk/broadway/gdkselection-broadway.c index f9c8b389a2..6eb82f1e5c 100644 --- a/gdk/broadway/gdkselection-broadway.c +++ b/gdk/broadway/gdkselection-broadway.c @@ -135,9 +135,3 @@ _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display, return 0; } -gchar * -_gdk_broadway_display_utf8_to_string_target (GdkDisplay *display, - const gchar *str) -{ - return g_strdup (str); -} diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index 2026daca7a..f20f79855e 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -156,8 +156,6 @@ struct _GdkDisplayClass const guchar *text, gint length, gchar ***list); - gchar * (*utf8_to_string_target) (GdkDisplay *display, - const gchar *text); gboolean (*make_gl_context_current) (GdkDisplay *display, GdkGLContext *context); diff --git a/gdk/gdkproperty.h b/gdk/gdkproperty.h index a54adc2775..0ff5139a03 100644 --- a/gdk/gdkproperty.h +++ b/gdk/gdkproperty.h @@ -43,9 +43,6 @@ gint gdk_text_property_to_utf8_list_for_display (GdkDisplay *display, gint length, gchar ***list); -GDK_AVAILABLE_IN_ALL -gchar *gdk_utf8_to_string_target (const gchar *str); - G_END_DECLS #endif /* __GDK_PROPERTY_H__ */ diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c index 1929b8ed2e..6905110e69 100644 --- a/gdk/gdkselection.c +++ b/gdk/gdkselection.c @@ -61,25 +61,3 @@ gdk_text_property_to_utf8_list_for_display (GdkDisplay *display, ->text_property_to_utf8_list (display, encoding, format, text, length, list); } -/** - * gdk_utf8_to_string_target: - * @str: a UTF-8 string - * - * Converts a UTF-8 string into the best possible representation - * as a STRING. The representation of characters not in STRING - * is not specified; it may be as pseudo-escape sequences - * \x{ABCD}, or it may be in some other form of approximation. - * - * Returns: (nullable): the newly-allocated string, or %NULL if the - * conversion failed. (It should not fail for any properly - * formed UTF-8 string unless system limits like memory or - * file descriptors are exceeded.) - **/ -gchar * -gdk_utf8_to_string_target (const gchar *str) -{ - GdkDisplay *display = gdk_display_get_default (); - - return GDK_DISPLAY_GET_CLASS (display)->utf8_to_string_target (display, str); -} - diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c index 7ab78f09d6..bf165e252c 100644 --- a/gdk/quartz/gdkdisplay-quartz.c +++ b/gdk/quartz/gdkdisplay-quartz.c @@ -231,7 +231,6 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class) display_class->create_surface_impl = _gdk_quartz_display_create_surface_impl; display_class->get_keymap = _gdk_quartz_display_get_keymap; display_class->text_property_to_utf8_list = _gdk_quartz_display_text_property_to_utf8_list; - display_class->utf8_to_string_target = _gdk_quartz_display_utf8_to_string_target; display_class->get_n_monitors = gdk_quartz_display_get_n_monitors; display_class->get_monitor = gdk_quartz_display_get_monitor; display_class->get_setting = gdk_quartz_display_get_setting; diff --git a/gdk/quartz/gdkdisplay-quartz.h b/gdk/quartz/gdkdisplay-quartz.h index 33e1c67ce6..8e5543be4c 100644 --- a/gdk/quartz/gdkdisplay-quartz.h +++ b/gdk/quartz/gdkdisplay-quartz.h @@ -76,8 +76,6 @@ gint _gdk_quartz_display_text_property_to_utf8_list (GdkDisplay *disp const guchar *text, gint length, gchar ***list); -gchar * _gdk_quartz_display_utf8_to_string_target (GdkDisplay *displayt, - const gchar *str); G_END_DECLS diff --git a/gdk/quartz/gdkselection-quartz.c b/gdk/quartz/gdkselection-quartz.c index 6e177fdce0..e79ca91e45 100644 --- a/gdk/quartz/gdkselection-quartz.c +++ b/gdk/quartz/gdkselection-quartz.c @@ -23,14 +23,6 @@ #include "gdkproperty.h" #include "gdkquartz.h" -gchar * -_gdk_quartz_display_utf8_to_string_target (GdkDisplay *display, - const gchar *str) -{ - /* FIXME: Implement */ - return NULL; -} - static gint make_list (const gchar *text, gint length, diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 8ffc2d048e..199468e03e 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -1031,7 +1031,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class) display_class->create_surface = _gdk_wayland_display_create_surface; display_class->get_keymap = _gdk_wayland_display_get_keymap; display_class->text_property_to_utf8_list = _gdk_wayland_display_text_property_to_utf8_list; - display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target; display_class->make_gl_context_current = gdk_wayland_display_make_gl_context_current; diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index 396fa15ad2..830e185029 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -133,8 +133,6 @@ gint _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *disp const guchar *text, gint length, gchar ***list); -gchar * _gdk_wayland_display_utf8_to_string_target (GdkDisplay *display, - const gchar *str); void _gdk_wayland_display_create_seat (GdkWaylandDisplay *display, guint32 id, diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c index 9683a5a8ed..8f02cdd123 100644 --- a/gdk/wayland/gdkselection-wayland.c +++ b/gdk/wayland/gdkselection-wayland.c @@ -73,68 +73,3 @@ _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *display, return nitems; } -/* This function has been copied straight from the x11 backend */ -static gchar * -sanitize_utf8 (const gchar *src, - gboolean return_latin1) -{ - gint len = strlen (src); - GString *result = g_string_sized_new (len); - const gchar *p = src; - - while (*p) - { - if (*p == '\r') - { - p++; - if (*p == '\n') - p++; - - g_string_append_c (result, '\n'); - } - else - { - gunichar ch = g_utf8_get_char (p); - - if (!((ch < 0x20 && ch != '\t' && ch != '\n') || (ch >= 0x7f && ch < 0xa0))) - { - if (return_latin1) - { - if (ch <= 0xff) - g_string_append_c (result, ch); - else - g_string_append_printf (result, - ch < 0x10000 ? "\\u%04x" : "\\U%08x", - ch); - } - else - { - char buf[7]; - gint buflen; - - buflen = g_unichar_to_utf8 (ch, buf); - g_string_append_len (result, buf, buflen); - } - } - - p = g_utf8_next_char (p); - } - } - - return g_string_free (result, FALSE); -} - -gchar * -_gdk_wayland_display_utf8_to_string_target (GdkDisplay *display, - const gchar *str) -{ - /* This is mainly needed when interfacing with old clients through - * Xwayland, the STRING target could be used, and passed as-is - * by the compositor. - * - * There's already some handling of this atom (aka "mimetype" in - * this backend) in common code, so we end up in this vfunc. - */ - return sanitize_utf8 (str, TRUE); -} - diff --git a/gdk/win32/gdkclipdrop-win32.c b/gdk/win32/gdkclipdrop-win32.c index e45fc42e9c..cd40dedaf3 100644 --- a/gdk/win32/gdkclipdrop-win32.c +++ b/gdk/win32/gdkclipdrop-win32.c @@ -2782,13 +2782,6 @@ _gdk_win32_display_text_property_to_utf8_list (GdkDisplay *display, } } -gchar * -_gdk_win32_display_utf8_to_string_target (GdkDisplay *display, - const gchar *str) -{ - return g_strdup (str); -} - gint _gdk_win32_add_contentformat_to_pairs (const gchar *contentformat, GArray *array) diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 8ccefcf539..7f9785b239 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -1119,7 +1119,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass) display_class->get_keymap = _gdk_win32_display_get_keymap; display_class->text_property_to_utf8_list = _gdk_win32_display_text_property_to_utf8_list; - display_class->utf8_to_string_target = _gdk_win32_display_utf8_to_string_target; display_class->make_gl_context_current = _gdk_win32_display_make_gl_context_current; display_class->get_n_monitors = gdk_win32_display_get_n_monitors; diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h index d3377bbf34..e4821d71b1 100644 --- a/gdk/win32/gdkprivate-win32.h +++ b/gdk/win32/gdkprivate-win32.h @@ -401,7 +401,6 @@ gint _gdk_win32_display_text_property_to_utf8_list (GdkDisplay *display, const guchar *text, gint length, gchar ***list); -gchar *_gdk_win32_display_utf8_to_string_target (GdkDisplay *display, const gchar *str); gboolean _gdk_win32_keymap_has_altgr (GdkWin32Keymap *keymap); guint8 _gdk_win32_keymap_get_active_group (GdkWin32Keymap *keymap); diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 5a863f9000..7147ad6a23 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -3053,7 +3053,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) display_class->create_surface = _gdk_x11_display_create_surface; display_class->get_keymap = gdk_x11_display_get_keymap; display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list; - display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target; display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current; diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 69a1248b8a..5bd6bb3e75 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -125,8 +125,8 @@ gint _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display const guchar *text, gint length, gchar ***list); -gchar * _gdk_x11_display_utf8_to_string_target (GdkDisplay *displayt, - const gchar *str); +char * gdk_x11_utf8_to_string_target (const char *utf8_str, + gboolean return_latin1); void _gdk_x11_device_check_extension_events (GdkDevice *device); diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index 7f34dfce84..169ba661fa 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -325,70 +325,6 @@ gdk_x11_display_string_to_compound_text (GdkDisplay *display, return res; } -/* The specifications for COMPOUND_TEXT and STRING specify that C0 and - * C1 are not allowed except for \n and \t, however the X conversions - * routines for COMPOUND_TEXT only enforce this in one direction, - * causing cut-and-paste of \r and \r\n separated text to fail. - * This routine strips out all non-allowed C0 and C1 characters - * from the input string and also canonicalizes \r, and \r\n to \n - */ -static gchar * -sanitize_utf8 (const gchar *src, - gboolean return_latin1) -{ - gint len = strlen (src); - GString *result = g_string_sized_new (len); - const gchar *p = src; - - while (*p) - { - if (*p == '\r') - { - p++; - if (*p == '\n') - p++; - - g_string_append_c (result, '\n'); - } - else - { - gunichar ch = g_utf8_get_char (p); - - if (!((ch < 0x20 && ch != '\t' && ch != '\n') || (ch >= 0x7f && ch < 0xa0))) - { - if (return_latin1) - { - if (ch <= 0xff) - g_string_append_c (result, ch); - else - g_string_append_printf (result, - ch < 0x10000 ? "\\u%04x" : "\\U%08x", - ch); - } - else - { - char buf[7]; - gint buflen; - - buflen = g_unichar_to_utf8 (ch, buf); - g_string_append_len (result, buf, buflen); - } - } - - p = g_utf8_next_char (p); - } - } - - return g_string_free (result, FALSE); -} - -gchar * -_gdk_x11_display_utf8_to_string_target (GdkDisplay *display, - const gchar *str) -{ - return sanitize_utf8 (str, TRUE); -} - /** * gdk_x11_display_utf8_to_compound_text: * @display: (type GdkX11Display): a #GdkDisplay @@ -423,7 +359,7 @@ gdk_x11_display_utf8_to_compound_text (GdkDisplay *display, need_conversion = !g_get_charset (&charset); - tmp_str = sanitize_utf8 (str, FALSE); + tmp_str = gdk_x11_utf8_to_string_target (str, FALSE); if (need_conversion) { diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 699bcf2864..f023e09473 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -2235,7 +2235,7 @@ set_text_property (GdkDisplay *display, if (utf8_is_latin1 (utf8_str)) { prop_type = XA_STRING; - prop_text = _gdk_x11_display_utf8_to_string_target (display, utf8_str); + prop_text = gdk_x11_utf8_to_string_target (utf8_str, TRUE); prop_length = prop_text ? strlen (prop_text) : 0; prop_format = 8; is_compound_text = FALSE; diff --git a/gdk/x11/gdktextlistconverter-x11.c b/gdk/x11/gdktextlistconverter-x11.c index 38c7df9a71..88c4a5310f 100644 --- a/gdk/x11/gdktextlistconverter-x11.c +++ b/gdk/x11/gdktextlistconverter-x11.c @@ -121,6 +121,63 @@ gdk_x11_text_list_converter_decode (GdkX11TextListConverter *conv, } } +/* The specifications for COMPOUND_TEXT and STRING specify that C0 and + * C1 are not allowed except for \n and \t, however the X conversions + * routines for COMPOUND_TEXT only enforce this in one direction, + * causing cut-and-paste of \r and \r\n separated text to fail. + * This routine strips out all non-allowed C0 and C1 characters + * from the input string and also canonicalizes \r, and \r\n to \n + */ +char * +gdk_x11_utf8_to_string_target (const char *utf8_str, + gboolean return_latin1) +{ + gint len = strlen (utf8_str); + GString *result = g_string_sized_new (len); + const gchar *p = utf8_str; + + while (*p) + { + if (*p == '\r') + { + p++; + if (*p == '\n') + p++; + + g_string_append_c (result, '\n'); + } + else + { + gunichar ch = g_utf8_get_char (p); + + if (!((ch < 0x20 && ch != '\t' && ch != '\n') || (ch >= 0x7f && ch < 0xa0))) + { + if (return_latin1) + { + if (ch <= 0xff) + g_string_append_c (result, ch); + else + g_string_append_printf (result, + ch < 0x10000 ? "\\u%04x" : "\\U%08x", + ch); + } + else + { + char buf[7]; + gint buflen; + + buflen = g_unichar_to_utf8 (ch, buf); + g_string_append_len (result, buf, buflen); + } + } + + p = g_utf8_next_char (p); + } + } + + return g_string_free (result, FALSE); +} + static GConverterResult gdk_x11_text_list_converter_encode (GdkX11TextListConverter *conv, const void *inbuf, @@ -146,7 +203,7 @@ gdk_x11_text_list_converter_encode (GdkX11TextListConverter *conv, gchar *tmp, *latin1; tmp = g_strndup (inbuf, inbuf_size); - latin1 = gdk_utf8_to_string_target (tmp); + latin1 = gdk_x11_utf8_to_string_target (tmp, TRUE); g_free (tmp); if (latin1) { |