diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-02-23 01:50:52 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-02-23 01:50:52 +0000 |
commit | 9036d49bea182a80bff4f29f936b419eb66eb59e (patch) | |
tree | 700699a0c949156fdd4292b66a1dfc4849c0a3f8 | |
parent | 8d5cece080b77a277adea95d0cf18932fe646596 (diff) | |
parent | cc7c1fe1084bf80779cf8f0dc0b083e479ab72c7 (diff) | |
download | gtk+-9036d49bea182a80bff4f29f936b419eb66eb59e.tar.gz |
Merge branch 'wip/otte/dnd' into 'master'
Get rid of GdkAtom
See merge request GNOME/gtk!1465
78 files changed, 287 insertions, 2940 deletions
diff --git a/docs/reference/gdk/gdk4-docs.xml b/docs/reference/gdk/gdk4-docs.xml index 31dd72f96c..74fe5df718 100644 --- a/docs/reference/gdk/gdk4-docs.xml +++ b/docs/reference/gdk/gdk4-docs.xml @@ -44,7 +44,6 @@ <xi:include href="xml/gdkcontentprovider.xml" /> <xi:include href="xml/gdkcontentserializer.xml" /> <xi:include href="xml/gdkcontentdeserializer.xml" /> - <xi:include href="xml/properties.xml" /> <xi:include href="xml/gdkapplaunchcontext.xml" /> <xi:include href="xml/pixbufs.xml" /> <xi:include href="xml/pango_interaction.xml" /> diff --git a/docs/reference/gdk/gdk4-overrides.txt b/docs/reference/gdk/gdk4-overrides.txt index 77dd4d07be..4123476674 100644 --- a/docs/reference/gdk/gdk4-overrides.txt +++ b/docs/reference/gdk/gdk4-overrides.txt @@ -1,10 +1,4 @@ -# GdkAtom is an opaque typedef -<TYPEDEF> -<NAME>GdkAtom</NAME> -typedef struct _GdkAtom *GdkAtom; -</TYPEDEF> - <MACRO> <NAME>GDK_WINDOWING_X11</NAME> #define GDK_WINDOWING_X11 diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index b6f297238b..7a065041db 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -348,14 +348,6 @@ gdk_content_formats_builder_get_type </SECTION> <SECTION> -<TITLE>Properties and Atoms</TITLE> -<FILE>properties</FILE> -GdkAtom -gdk_text_property_to_utf8_list_for_display -gdk_utf8_to_string_target -</SECTION> - -<SECTION> <TITLE>Pango Interaction</TITLE> <FILE>pango_interaction</FILE> gdk_pango_layout_get_clip_region @@ -479,7 +471,7 @@ gdk_device_get_history gdk_device_free_history GdkTimeCoord gdk_device_get_axis -gdk_device_list_axes +gdk_device_get_axis_names gdk_device_get_axis_value gdk_device_get_last_event_surface @@ -850,8 +842,6 @@ gdk_x11_surface_set_frame_sync_enabled gdk_x11_keymap_get_group_for_state gdk_x11_keymap_key_is_modifier gdk_x11_visual_get_xvisual -gdk_x11_atom_to_xatom_for_display -gdk_x11_xatom_to_atom_for_display gdk_x11_get_xatom_by_name_for_display gdk_x11_get_xatom_name_for_display gdk_x11_set_sm_client_id diff --git a/docs/reference/gtk/gtk4-docs.xml b/docs/reference/gtk/gtk4-docs.xml index 1f6eddd057..732173b671 100644 --- a/docs/reference/gtk/gtk4-docs.xml +++ b/docs/reference/gtk/gtk4-docs.xml @@ -356,7 +356,6 @@ <xi:include href="xml/gtksettings.xml" /> <xi:include href="xml/gtkbindings.xml" /> <xi:include href="xml/gtkenums.xml" /> - <xi:include href="xml/gtkselection.xml" /> <xi:include href="xml/gtktesting.xml" /> <xi:include href="xml/filesystem.xml" /> </part> diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 654044f16a..548c4921d1 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -4673,41 +4673,6 @@ gtk_css_section_get_type </SECTION> <SECTION> -<FILE>gtkselection</FILE> -<TITLE>Selections</TITLE> -GtkSelectionData -gtk_selection_data_set -gtk_selection_data_set_text -gtk_selection_data_get_text -gtk_selection_data_set_pixbuf -gtk_selection_data_get_pixbuf -gtk_selection_data_set_texture -gtk_selection_data_get_texture -gtk_selection_data_set_uris -gtk_selection_data_get_uris -gtk_selection_data_get_targets -gtk_selection_data_targets_include_image -gtk_selection_data_targets_include_text -gtk_selection_data_targets_include_uri -gtk_selection_data_get_data -gtk_selection_data_get_length -gtk_selection_data_get_data_with_length -gtk_selection_data_get_data_type -gtk_selection_data_get_display -gtk_selection_data_get_format -gtk_selection_data_get_target -gtk_targets_include_image -gtk_targets_include_text -gtk_targets_include_uri -gtk_selection_data_copy -gtk_selection_data_free -<SUBSECTION Standard> -GTK_TYPE_SELECTION_DATA -<SUBSECTION Private> -gtk_selection_data_get_type -</SECTION> - -<SECTION> <FILE>gtkbindings</FILE> <TITLE>Bindings</TITLE> GtkBindingSet @@ -6893,8 +6858,6 @@ gtk_drop_target_set_actions gtk_drop_target_get_actions gtk_drop_target_get_drop gtk_drop_target_find_mimetype -gtk_drop_target_read_selection -gtk_drop_target_read_selection_finish gtk_drag_highlight gtk_drag_unhighlight diff --git a/docs/reference/gtk/meson.build b/docs/reference/gtk/meson.build index 0f01d83117..5e0361046c 100644 --- a/docs/reference/gtk/meson.build +++ b/docs/reference/gtk/meson.build @@ -158,7 +158,6 @@ private_headers = [ 'gtkroundedboxprivate.h', 'gtkscalerprivate.h', 'gtksearchentryprivate.h', - 'gtkselectionprivate.h', 'gtksettingsprivate.h', 'gtkshortcutsshortcutprivate.h', 'gtkshortcutswindowprivate.h', diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c index 69a2d1085e..f5b3d4145b 100644 --- a/gdk/broadway/gdkdisplay-broadway.c +++ b/gdk/broadway/gdkdisplay-broadway.c @@ -171,8 +171,6 @@ _gdk_broadway_display_open (const gchar *display_name) gdk_event_init (display); - _gdk_broadway_display_init_dnd (display); - if (display_name == NULL) display_name = g_getenv ("BROADWAY_DISPLAY"); @@ -430,8 +428,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class) display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete; 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/gdkdnd-broadway.c b/gdk/broadway/gdkdnd-broadway.c index a001cc31ae..04db887b26 100644 --- a/gdk/broadway/gdkdnd-broadway.c +++ b/gdk/broadway/gdkdnd-broadway.c @@ -27,7 +27,6 @@ #include "gdkdragprivate.h" #include "gdksurfaceprivate.h" -#include "gdkproperty.h" #include "gdkprivate-broadway.h" #include "gdkinternals.h" #include "gdkdisplay-broadway.h" @@ -104,16 +103,6 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface, return new_context; } -void -_gdk_broadway_surface_register_dnd (GdkSurface *surface) -{ -} - -void -_gdk_broadway_display_init_dnd (GdkDisplay *display) -{ -} - static void gdk_broadway_drag_class_init (GdkBroadwayDragClass *klass) { diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h index c001978fc0..f4f19cd534 100644 --- a/gdk/broadway/gdkprivate-broadway.h +++ b/gdk/broadway/gdkprivate-broadway.h @@ -47,7 +47,6 @@ void gdk_broadway_surface_set_nodes (GdkSurface *surface, GArray *nodes, GPtrArray *node_textures); -void _gdk_broadway_surface_register_dnd (GdkSurface *surface); GdkDrag * _gdk_broadway_surface_drag_begin (GdkSurface *surface, GdkDevice *device, GdkContentProvider *content, @@ -91,7 +90,6 @@ void _gdk_broadway_events_got_input (GdkDisplay *display, BroadwayInputMsg *message); void _gdk_broadway_display_init_root_window (GdkDisplay *display); -void _gdk_broadway_display_init_dnd (GdkDisplay *display); GdkDisplay * _gdk_broadway_display_open (const gchar *display_name); void _gdk_broadway_display_queue_events (GdkDisplay *display); GdkCursor*_gdk_broadway_display_get_cursor_for_name (GdkDisplay *display, @@ -115,14 +113,6 @@ GdkSurface * _gdk_broadway_display_create_surface (GdkDisplay *display, int y, int width, int height); -gint _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, - gint format, - 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 deleted file mode 100644 index f9c8b389a2..0000000000 --- a/gdk/broadway/gdkselection-broadway.c +++ /dev/null @@ -1,143 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include "gdkproperty.h" -#include "gdkprivate-broadway.h" -#include "gdkdisplay-broadway.h" - -#include <string.h> - - -static gint -make_list (const gchar *text, - gint length, - gboolean latin1, - gchar ***list) -{ - GSList *strings = NULL; - gint n_strings = 0; - gint i; - const gchar *p = text; - const gchar *q; - GSList *tmp_list; - GError *error = NULL; - - while (p < text + length) - { - gchar *str; - - q = p; - while (*q && q < text + length) - q++; - - if (latin1) - { - str = g_convert (p, q - p, - "UTF-8", "ISO-8859-1", - NULL, NULL, &error); - - if (!str) - { - g_warning ("Error converting selection from STRING: %s", - error->message); - g_error_free (error); - } - } - else - { - str = g_strndup (p, q - p); - if (!g_utf8_validate (str, -1, NULL)) - { - g_warning ("Error converting selection from UTF8_STRING"); - g_free (str); - str = NULL; - } - } - - if (str) - { - strings = g_slist_prepend (strings, str); - n_strings++; - } - - p = q + 1; - } - - if (list) - { - *list = g_new (gchar *, n_strings + 1); - (*list)[n_strings] = NULL; - } - - i = n_strings; - tmp_list = strings; - while (tmp_list) - { - if (list) - (*list)[--i] = tmp_list->data; - else - g_free (tmp_list->data); - - tmp_list = tmp_list->next; - } - - g_slist_free (strings); - - return n_strings; -} - -gint -_gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, - gint format, - const guchar *text, - gint length, - gchar ***list) -{ - g_return_val_if_fail (text != NULL, 0); - g_return_val_if_fail (length >= 0, 0); - g_return_val_if_fail (GDK_IS_DISPLAY (display), 0); - - if (encoding == g_intern_static_string ("STRING")) - { - return make_list ((gchar *)text, length, TRUE, list); - } - else if (encoding == g_intern_static_string ("UTF8_STRING")) - { - return make_list ((gchar *)text, length, FALSE, list); - } - - if (list) - *list = NULL; - return 0; -} - -gchar * -_gdk_broadway_display_utf8_to_string_target (GdkDisplay *display, - const gchar *str) -{ - return g_strdup (str); -} diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c index af946eef71..b8a4a57019 100644 --- a/gdk/broadway/gdksurface-broadway.c +++ b/gdk/broadway/gdksurface-broadway.c @@ -1462,6 +1462,5 @@ gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *klass) impl_class->begin_move_drag = gdk_broadway_surface_begin_move_drag; impl_class->set_opacity = gdk_broadway_surface_set_opacity; impl_class->destroy_notify = gdk_broadway_surface_destroy_notify; - impl_class->register_dnd = _gdk_broadway_surface_register_dnd; impl_class->drag_begin = _gdk_broadway_surface_drag_begin; } diff --git a/gdk/broadway/meson.build b/gdk/broadway/meson.build index c9aa9314f0..57bff27cae 100644 --- a/gdk/broadway/meson.build +++ b/gdk/broadway/meson.build @@ -13,7 +13,6 @@ gdk_broadway_sources = files([ 'gdkglobals-broadway.c', 'gdkkeys-broadway.c', 'gdkmonitor-broadway.c', - 'gdkselection-broadway.c', 'gdksurface-broadway.c', ]) @@ -60,7 +60,6 @@ #include <gdk/gdkpaintable.h> #include <gdk/gdkpango.h> #include <gdk/gdkpixbuf.h> -#include <gdk/gdkproperty.h> #include <gdk/gdkrectangle.h> #include <gdk/gdkrgba.h> #include <gdk/gdkseat.h> diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c index 186738cf04..b9d0e47bfe 100644 --- a/gdk/gdkdevice.c +++ b/gdk/gdkdevice.c @@ -1081,33 +1081,41 @@ gdk_device_get_n_axes (GdkDevice *device) } /** - * gdk_device_list_axes: - * @device: a pointer #GdkDevice + * gdk_device_get_axis_names: + * @device: a #GdkDevice * - * Returns a #GList of #GdkAtoms, containing the labels for + * Returns a null-terminated array of strings, containing the labels for * the axes that @device currently has. + * If the device has no axes, %NULL is returned. * - * Returns: (transfer container) (element-type GdkAtom): - * A #GList of strings, free with g_list_free(). + * Returns: (nullable) (transfer full): A null-terminated string array, + * free with g_strfreev(). **/ -GList * -gdk_device_list_axes (GdkDevice *device) +char ** +gdk_device_get_axis_names (GdkDevice *device) { - GList *axes = NULL; + GPtrArray *axes; gint i; g_return_val_if_fail (GDK_IS_DEVICE (device), NULL); g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL); + if (device->axes->len == 0) + return NULL; + + axes = g_ptr_array_new (); + for (i = 0; i < device->axes->len; i++) { GdkAxisInfo axis_info; axis_info = g_array_index (device->axes, GdkAxisInfo, i); - axes = g_list_prepend (axes, axis_info.label); + g_ptr_array_add (axes, g_strdup (axis_info.label)); } - return g_list_reverse (axes); + g_ptr_array_add (axes, NULL); + + return (char **) g_ptr_array_free (axes, FALSE); } /** @@ -1119,7 +1127,7 @@ gdk_device_list_axes (GdkDevice *device) * * Interprets an array of double as axis values for a given device, * and locates the value in the array for a given axis label, as returned - * by gdk_device_list_axes() + * by gdk_device_get_axes() * * Returns: %TRUE if the given axis use was found, otherwise %FALSE. **/ diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h index 0179ee04dc..9a2cc758bf 100644 --- a/gdk/gdkdevice.h +++ b/gdk/gdkdevice.h @@ -184,11 +184,11 @@ void gdk_device_free_history (GdkTimeCoord **events, GDK_AVAILABLE_IN_ALL gint gdk_device_get_n_axes (GdkDevice *device); GDK_AVAILABLE_IN_ALL -GList * gdk_device_list_axes (GdkDevice *device); +char ** gdk_device_get_axis_names (GdkDevice *device); GDK_AVAILABLE_IN_ALL gboolean gdk_device_get_axis_value (GdkDevice *device, gdouble *axes, - GdkAtom axis_label, + const char *axis_label, gdouble *value); GDK_AVAILABLE_IN_ALL diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h index 70c29b7e85..29a9dc6de5 100644 --- a/gdk/gdkdeviceprivate.h +++ b/gdk/gdkdeviceprivate.h @@ -116,14 +116,14 @@ void _gdk_device_set_associated_device (GdkDevice *device, void _gdk_device_reset_axes (GdkDevice *device); guint _gdk_device_add_axis (GdkDevice *device, - GdkAtom label_atom, + const char *label_atom, GdkAxisUse use, gdouble min_value, gdouble max_value, gdouble resolution); void _gdk_device_get_axis_info (GdkDevice *device, guint index, - GdkAtom *label_atom, + const char**label_atom, GdkAxisUse *use, gdouble *min_value, gdouble *max_value, diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index 2026daca7a..433f699f40 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -150,15 +150,6 @@ struct _GdkDisplayClass GdkKeymap * (*get_keymap) (GdkDisplay *display); - gint (*text_property_to_utf8_list) (GdkDisplay *display, - GdkAtom encoding, - gint format, - 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.c b/gdk/gdkproperty.c deleted file mode 100644 index c43f13e590..0000000000 --- a/gdk/gdkproperty.c +++ /dev/null @@ -1,57 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 2000 Red Hat, Inc. - * 2005 Imendio AB - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" - -#include "gdkproperty.h" - -#include "gdkinternals.h" - -/** - * SECTION:properties - * @Short_description: Functions to manipulate properties on windows - * @Title: Properties and Atoms - * - * Each window under X can have any number of associated - * “properties” attached to it. - * Properties are arbitrary chunks of data identified by - * “atom”s. (An “atom” - * is a numeric index into a string table on the X server. They are used - * to transfer strings efficiently between clients without - * having to transfer the entire string.) A property - * has an associated type, which is also identified - * using an atom. - * - * A property has an associated “format”, - * an integer describing how many bits are in each unit - * of data inside the property. It must be 8, 16, or 32. - * When data is transferred between the server and client, - * if they are of different endianesses it will be byteswapped - * as necessary according to the format of the property. - * Note that on the client side, properties of format 32 - * will be stored with one unit per long, - * even if a long integer has more than 32 bits on the platform. - * (This decision was apparently made for Xlib to maintain - * compatibility with programs that assumed longs were 32 - * bits, at the expense of programs that knew better.) - * - * The functions in this section are used to add, remove - * and change properties on windows, to convert atoms - * to and from strings and to manipulate some types of - * data commonly stored in X window properties. - */ diff --git a/gdk/gdkproperty.h b/gdk/gdkproperty.h deleted file mode 100644 index a54adc2775..0000000000 --- a/gdk/gdkproperty.h +++ /dev/null @@ -1,51 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GDK_PROPERTY_H__ -#define __GDK_PROPERTY_H__ - -#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only <gdk/gdk.h> can be included directly." -#endif - -#include <gdk/gdktypes.h> -#include <gdk/gdkversionmacros.h> - -G_BEGIN_DECLS - - -GDK_AVAILABLE_IN_ALL -gint gdk_text_property_to_utf8_list_for_display (GdkDisplay *display, - GdkAtom encoding, - gint format, - const guchar *text, - 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 deleted file mode 100644 index 1929b8ed2e..0000000000 --- a/gdk/gdkselection.c +++ /dev/null @@ -1,85 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include "config.h" - -#include "gdkproperty.h" - -#include "gdkdisplayprivate.h" - - -/** - * gdk_text_property_to_utf8_list_for_display: - * @display: a #GdkDisplay - * @encoding: an atom representing the encoding of the text - * @format: the format of the property - * @text: (array length=length): the text to convert - * @length: the length of @text, in bytes - * @list: (out) (array zero-terminated=1): location to store the list - * of strings or %NULL. The list should be freed with - * g_strfreev(). - * - * Converts a text property in the given encoding to - * a list of UTF-8 strings. - * - * Returns: the number of strings in the resulting list - */ -gint -gdk_text_property_to_utf8_list_for_display (GdkDisplay *display, - GdkAtom encoding, - gint format, - const guchar *text, - gint length, - gchar ***list) -{ - g_return_val_if_fail (text != NULL, 0); - g_return_val_if_fail (length >= 0, 0); - g_return_val_if_fail (GDK_IS_DISPLAY (display), 0); - - return GDK_DISPLAY_GET_CLASS (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/gdksurface.c b/gdk/gdksurface.c index 13b0dec48d..0717106aee 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -3561,18 +3561,6 @@ gdk_surface_destroy_notify (GdkSurface *surface) } /** - * gdk_surface_register_dnd: - * @surface: a #GdkSurface. - * - * Registers a surface as a potential drop destination. - */ -void -gdk_surface_register_dnd (GdkSurface *surface) -{ - GDK_SURFACE_GET_CLASS (surface)->register_dnd (surface); -} - -/** * gdk_drag_begin: * @surface: the source surface for this drag * @device: the device that controls this drag diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h index 1bf8b24eca..52141b1c26 100644 --- a/gdk/gdksurface.h +++ b/gdk/gdksurface.h @@ -532,8 +532,6 @@ void gdk_surface_set_keep_below (GdkSurface *surface, GDK_AVAILABLE_IN_ALL void gdk_surface_set_opacity (GdkSurface *surface, gdouble opacity); -GDK_AVAILABLE_IN_ALL -void gdk_surface_register_dnd (GdkSurface *surface); GDK_AVAILABLE_IN_ALL void gdk_surface_begin_resize_drag (GdkSurface *surface, diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h index fa9674451d..e1e1f3687c 100644 --- a/gdk/gdksurfaceprivate.h +++ b/gdk/gdksurfaceprivate.h @@ -225,7 +225,6 @@ struct _GdkSurfaceClass void (* set_opacity) (GdkSurface *surface, gdouble opacity); void (* destroy_notify) (GdkSurface *surface); - void (* register_dnd) (GdkSurface *surface); GdkDrag * (*drag_begin) (GdkSurface *surface, GdkDevice *device, GdkContentProvider*content, diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h index fefb6c62c4..5b0f6be7cc 100644 --- a/gdk/gdktypes.h +++ b/gdk/gdktypes.h @@ -108,14 +108,6 @@ typedef struct _GdkRectangle GdkRectangle; typedef cairo_rectangle_int_t GdkRectangle; #endif -/** - * GdkAtom: - * - * An opaque type representing a string as an index into a table - * of strings on the X server. - */ -typedef const char *GdkAtom; - /* Forward declarations of commonly used types */ typedef struct _GdkRGBA GdkRGBA; typedef struct _GdkContentFormats GdkContentFormats; diff --git a/gdk/meson.build b/gdk/meson.build index af04354d88..1df3b60e74 100644 --- a/gdk/meson.build +++ b/gdk/meson.build @@ -35,12 +35,10 @@ gdk_public_sources = files([ 'gdkpango.c', 'gdkpixbuf-drawable.c', 'gdkpipeiostream.c', - 'gdkproperty.c', 'gdkrectangle.c', 'gdkrgba.c', 'gdkseat.c', 'gdkseatdefault.c', - 'gdkselection.c', 'gdksnapshot.c', 'gdktexture.c', 'gdkvulkancontext.c', @@ -82,7 +80,6 @@ gdk_public_headers = files([ 'gdkpaintable.h', 'gdkpango.h', 'gdkpixbuf.h', - 'gdkproperty.h', 'gdkrectangle.h', 'gdkrgba.h', 'gdkseat.h', diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c index 7ab78f09d6..300d9d8481 100644 --- a/gdk/quartz/gdkdisplay-quartz.c +++ b/gdk/quartz/gdkdisplay-quartz.c @@ -230,8 +230,6 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class) display_class->event_data_free = _gdk_quartz_display_event_data_free; 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..7d6923738b 100644 --- a/gdk/quartz/gdkdisplay-quartz.h +++ b/gdk/quartz/gdkdisplay-quartz.h @@ -70,14 +70,6 @@ void _gdk_quartz_display_create_surface_impl (GdkDisplay *display, /* Display methods - keymap */ GdkKeymap * _gdk_quartz_display_get_keymap (GdkDisplay *display); -gint _gdk_quartz_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, - gint format, - 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/gdkdnd-quartz.c b/gdk/quartz/gdkdnd-quartz.c index 4dd9cb8916..20430a4fcf 100644 --- a/gdk/quartz/gdkdnd-quartz.c +++ b/gdk/quartz/gdkdnd-quartz.c @@ -69,12 +69,6 @@ gdk_quartz_drag_context_drag_abort (GdkDragContext *context, /* FIXME: Implement */ } -void -_gdk_quartz_surface_register_dnd (GdkSurface *window) -{ - /* FIXME: Implement */ -} - id gdk_quartz_drag_context_get_dragging_info_libgtk_only (GdkDragContext *context) { diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h index 24b9db564d..08c86fd42e 100644 --- a/gdk/quartz/gdkprivate-quartz.h +++ b/gdk/quartz/gdkprivate-quartz.h @@ -76,7 +76,6 @@ gboolean _gdk_quartz_keys_is_modifier (guint keycode); void _gdk_quartz_synthesize_null_key_event (GdkSurface *window); /* Drag and Drop */ -void _gdk_quartz_surface_register_dnd (GdkSurface *window); GdkDragContext * _gdk_quartz_surface_drag_begin (GdkSurface *window, GdkDevice *device, GList *targets, diff --git a/gdk/quartz/gdkselection-quartz.c b/gdk/quartz/gdkselection-quartz.c index 6e177fdce0..3f69d03100 100644 --- a/gdk/quartz/gdkselection-quartz.c +++ b/gdk/quartz/gdkselection-quartz.c @@ -20,114 +20,8 @@ #include "config.h" -#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, - gboolean latin1, - gchar ***list) -{ - GSList *strings = NULL; - gint n_strings = 0; - gint i; - const gchar *p = text; - const gchar *q; - GSList *tmp_list; - GError *error = NULL; - - while (p < text + length) - { - gchar *str; - - q = p; - while (*q && q < text + length) - q++; - - if (latin1) - { - str = g_convert (p, q - p, - "UTF-8", "ISO-8859-1", - NULL, NULL, &error); - - if (!str) - { - g_warning ("Error converting selection from STRING: %s", - error->message); - g_error_free (error); - } - } - else - str = g_strndup (p, q - p); - - if (str) - { - strings = g_slist_prepend (strings, str); - n_strings++; - } - - p = q + 1; - } - - if (list) - *list = g_new0 (gchar *, n_strings + 1); - - i = n_strings; - tmp_list = strings; - while (tmp_list) - { - if (list) - (*list)[--i] = tmp_list->data; - else - g_free (tmp_list->data); - - tmp_list = tmp_list->next; - } - - g_slist_free (strings); - - return n_strings; -} - -gint -_gdk_quartz_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, - gint format, - const guchar *text, - gint length, - gchar ***list) -{ - g_return_val_if_fail (text != NULL, 0); - g_return_val_if_fail (length >= 0, 0); - - if (encoding == g_intern_static_string ("STRING")) - { - return make_list ((gchar *)text, length, TRUE, list); - } - else if (encoding == g_intern_static_string ("UTF8_STRING")) - { - return make_list ((gchar *)text, length, FALSE, list); - } - else - { - g_warning ("gdk_text_property_to_utf8_list_for_display: encoding %s not handled", (const char *)encoding); - - if (list) - *list = NULL; - - return 0; - } -} - GdkAtom gdk_quartz_pasteboard_type_to_atom_libgtk_only (NSString *type) { diff --git a/gdk/quartz/gdksurface-quartz.c b/gdk/quartz/gdksurface-quartz.c index ae259e7d42..cc21dedf23 100644 --- a/gdk/quartz/gdksurface-quartz.c +++ b/gdk/quartz/gdksurface-quartz.c @@ -2747,7 +2747,6 @@ gdk_surface_impl_quartz_class_init (GdkSurfaceImplQuartzClass *klass) impl_class->set_opacity = gdk_quartz_surface_set_opacity; impl_class->set_shadow_width = gdk_quartz_surface_set_shadow_width; impl_class->destroy_notify = gdk_quartz_surface_destroy_notify; - impl_class->register_dnd = _gdk_quartz_surface_register_dnd; impl_class->drag_begin = _gdk_quartz_surface_drag_begin; impl_class->process_updates_recurse = _gdk_quartz_surface_process_updates_recurse; diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 26c99684d6..26f9b142c5 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -3347,7 +3347,7 @@ gdk_wayland_mimic_device_axes (GdkDevice *master, GdkDevice *slave) { gdouble axis_min, axis_max, axis_resolution; - GdkAtom axis_label; + const char *axis_label; GdkAxisUse axis_use; gint axis_count; gint i; diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 8ffc2d048e..ef7b32b95e 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -1030,8 +1030,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class) display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete; 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/gdkdrag-wayland.c b/gdk/wayland/gdkdrag-wayland.c index f7c2925c60..b0430b025d 100644 --- a/gdk/wayland/gdkdrag-wayland.c +++ b/gdk/wayland/gdkdrag-wayland.c @@ -20,7 +20,6 @@ #include "gdkdragprivate.h" #include "gdkinternals.h" -#include "gdkproperty.h" #include "gdkprivate-wayland.h" #include "gdkcontentformats.h" #include "gdkdisplay-wayland.h" @@ -198,11 +197,6 @@ gdk_wayland_drag_class_init (GdkWaylandDragClass *klass) drag_class->cancel = gdk_wayland_drag_cancel; } -void -_gdk_wayland_surface_register_dnd (GdkSurface *surface) -{ -} - static GdkSurface * create_dnd_surface (GdkDisplay *display) { diff --git a/gdk/wayland/gdkdrop-wayland.c b/gdk/wayland/gdkdrop-wayland.c index f9ed7de123..2af4379077 100644 --- a/gdk/wayland/gdkdrop-wayland.c +++ b/gdk/wayland/gdkdrop-wayland.c @@ -20,7 +20,6 @@ #include "gdkdropprivate.h" #include "gdkinternals.h" -#include "gdkproperty.h" #include "gdkprivate-wayland.h" #include "gdkcontentformats.h" #include "gdkdisplay-wayland.h" diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index 64d761dfd7..f472bf7759 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -99,7 +99,6 @@ void gdk_wayland_surface_attach_image (GdkSurface cairo_surface_t *cairo_surface, const cairo_region_t *damage); -void _gdk_wayland_surface_register_dnd (GdkSurface *surface); GdkDrag *_gdk_wayland_surface_drag_begin (GdkSurface *surface, GdkDevice *device, GdkContentProvider *content, @@ -128,15 +127,6 @@ GdkSurface * _gdk_wayland_display_create_surface (GdkDisplay *display, int width, int height); -gint _gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, - gint format, - 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, struct wl_seat *seat); diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c deleted file mode 100644 index 9683a5a8ed..0000000000 --- a/gdk/wayland/gdkselection-wayland.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" - -#include <fcntl.h> -#include <unistd.h> - -#include <gio/gunixinputstream.h> -#include <gio/gunixoutputstream.h> -#include <glib-unix.h> - -#include "gdkwayland.h" -#include "gdkprivate-wayland.h" -#include "gdkdisplay-wayland.h" -#include "gdkcontentformatsprivate.h" -#include "gdkproperty.h" - -#include <string.h> - -gint -_gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, - gint format, - const guchar *text, - gint length, - gchar ***list) -{ - GPtrArray *array; - const gchar *ptr; - gsize chunk_len; - gchar *copy; - guint nitems; - - ptr = (const gchar *) text; - array = g_ptr_array_new (); - - while (ptr < (const gchar *) &text[length]) - { - chunk_len = strlen (ptr); - - if (g_utf8_validate (ptr, chunk_len, NULL)) - { - copy = g_strndup (ptr, chunk_len); - g_ptr_array_add (array, copy); - } - - ptr = &ptr[chunk_len + 1]; - } - - nitems = array->len; - g_ptr_array_add (array, NULL); - - if (list) - *list = (gchar **) g_ptr_array_free (array, FALSE); - else - g_ptr_array_free (array, TRUE); - - 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/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index ca81ce2e50..6b59f43c9e 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -3933,7 +3933,6 @@ gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass) impl_class->begin_move_drag = gdk_wayland_surface_begin_move_drag; impl_class->set_opacity = gdk_wayland_surface_set_opacity; impl_class->destroy_notify = gdk_wayland_surface_destroy_notify; - impl_class->register_dnd = _gdk_wayland_surface_register_dnd; impl_class->drag_begin = _gdk_wayland_surface_drag_begin; impl_class->get_scale_factor = gdk_wayland_surface_get_scale_factor; impl_class->set_opaque_region = gdk_wayland_surface_set_opaque_region; diff --git a/gdk/wayland/meson.build b/gdk/wayland/meson.build index a6fe2a88c5..b6592064fb 100644 --- a/gdk/wayland/meson.build +++ b/gdk/wayland/meson.build @@ -14,7 +14,6 @@ gdk_wayland_sources = files([ 'gdkkeys-wayland.c', 'gdkmonitor-wayland.c', 'gdkprimary-wayland.c', - 'gdkselection-wayland.c', 'gdkvulkancontext-wayland.c', 'gdksurface-wayland.c', 'wm-button-layout-translation.c', diff --git a/gdk/win32/gdkclipdrop-win32.c b/gdk/win32/gdkclipdrop-win32.c index e45fc42e9c..d274f5a6b1 100644 --- a/gdk/win32/gdkclipdrop-win32.c +++ b/gdk/win32/gdkclipdrop-win32.c @@ -273,7 +273,6 @@ Otherwise it's similar to how the clipboard works. Only the DnD server /* for CIDA */ #include <shlobj.h> -#include "gdkproperty.h" #include "gdkdisplay.h" #include "gdkprivate-win32.h" #include "gdkclipboardprivate.h" @@ -1540,7 +1539,7 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop) win32_clipdrop->GetUpdatedClipboardFormats = GetProcAddress (user32, "GetUpdatedClipboardFormats"); FreeLibrary (user32); - atoms = g_array_sized_new (FALSE, TRUE, sizeof (GdkAtom), GDK_WIN32_ATOM_INDEX_LAST); + atoms = g_array_sized_new (FALSE, TRUE, sizeof (const char *), GDK_WIN32_ATOM_INDEX_LAST); g_array_set_size (atoms, GDK_WIN32_ATOM_INDEX_LAST); cfs = g_array_sized_new (FALSE, TRUE, sizeof (UINT), GDK_WIN32_CF_INDEX_LAST); g_array_set_size (cfs, GDK_WIN32_CF_INDEX_LAST); @@ -2681,117 +2680,9 @@ _gdk_win32_transmute_contentformat (const gchar *from_contentformat, return TRUE; } -static gint -make_list (const gchar *text, - gint length, - gboolean latin1, - gchar ***list) -{ - GSList *strings = NULL; - gint n_strings = 0; - gint i; - const gchar *p = text; - const gchar *q; - GSList *tmp_list; - GError *error = NULL; - - while (p < text + length) - { - gchar *str; - - q = p; - while (*q && q < text + length) - q++; - - if (latin1) - { - str = g_convert (p, q - p, - "UTF-8", "ISO-8859-1", - NULL, NULL, &error); - - if (!str) - { - g_warning ("Error converting selection from STRING: %s", - error->message); - g_error_free (error); - } - } - else - str = g_strndup (p, q - p); - - if (str) - { - strings = g_slist_prepend (strings, str); - n_strings++; - } - - p = q + 1; - } - - if (list) - *list = g_new (gchar *, n_strings + 1); - - (*list)[n_strings] = NULL; - - i = n_strings; - tmp_list = strings; - while (tmp_list) - { - if (list) - (*list)[--i] = tmp_list->data; - else - g_free (tmp_list->data); - - tmp_list = tmp_list->next; - } - - g_slist_free (strings); - - return n_strings; -} - -gint -_gdk_win32_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, - gint format, - const guchar *text, - gint length, - gchar ***list) -{ - g_return_val_if_fail (text != NULL, 0); - g_return_val_if_fail (length >= 0, 0); - - if (encoding == g_intern_static_string ("STRING")) - { - return make_list ((gchar *)text, length, TRUE, list); - } - else if (encoding == _gdk_win32_clipdrop_atom (GDK_WIN32_ATOM_INDEX_TEXT_PLAIN_UTF8)) - { - return make_list ((gchar *)text, length, FALSE, list); - } - else - { - const char *enc_name = (const char *)encoding; - - g_warning ("gdk_text_property_to_utf8_list_for_display: encoding %s not handled\n", enc_name); - - if (list) - *list = NULL; - - return 0; - } -} - -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) +_gdk_win32_add_contentformat_to_pairs (const char *contentformat, + GArray *array) { gint added_count = 0; wchar_t *contentformat_w; diff --git a/gdk/win32/gdkclipdrop-win32.h b/gdk/win32/gdkclipdrop-win32.h index d7b88c6061..418d52c36e 100644 --- a/gdk/win32/gdkclipdrop-win32.h +++ b/gdk/win32/gdkclipdrop-win32.h @@ -24,7 +24,7 @@ G_BEGIN_DECLS #define _gdk_win32_clipdrop_get() (_win32_clipdrop) -#define _gdk_atom_array_index(a, i) (g_array_index (a, GdkAtom, i)) +#define _gdk_atom_array_index(a, i) (g_array_index (a, const char *, i)) #define _gdk_win32_clipdrop_atom(i) (_gdk_atom_array_index (_gdk_win32_clipdrop_get ()->known_atoms, i)) #define _gdk_cf_array_index(a, i) (g_array_index (a, UINT, i)) #define _gdk_win32_clipdrop_cf(i) (_gdk_cf_array_index (_gdk_win32_clipdrop_get ()->known_clipboard_formats, i)) @@ -53,7 +53,7 @@ typedef enum { enum _GdkWin32AtomIndex { -/* GdkAtoms: properties, targets and types */ +/* atoms: properties, targets and types */ GDK_WIN32_ATOM_INDEX_GDK_SELECTION = 0, GDK_WIN32_ATOM_INDEX_CLIPBOARD_MANAGER, GDK_WIN32_ATOM_INDEX_WM_TRANSIENT_FOR, @@ -243,7 +243,7 @@ gchar * _gdk_win32_get_clipboard_format_name (UINT void _gdk_win32_add_w32format_to_pairs (UINT format, GArray *array, GdkContentFormatsBuilder *builder); -gint _gdk_win32_add_contentformat_to_pairs (GdkAtom target, +gint _gdk_win32_add_contentformat_to_pairs (const char *target, GArray *array); void _gdk_win32_clipboard_default_output_done (GObject *clipboard, diff --git a/gdk/win32/gdkdevice-virtual.c b/gdk/win32/gdkdevice-virtual.c index d15a4bc477..d876e2608b 100644 --- a/gdk/win32/gdkdevice-virtual.c +++ b/gdk/win32/gdkdevice-virtual.c @@ -36,7 +36,7 @@ _gdk_device_virtual_set_active (GdkDevice *device, { GdkDeviceVirtual *virtual = GDK_DEVICE_VIRTUAL (device); int n_axes, i; - GdkAtom label_atom; + const char *label_atom; GdkAxisUse use; gdouble min_value, max_value, resolution; diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 8ccefcf539..ffda794ec7 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -1118,8 +1118,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass) display_class->create_surface = _gdk_win32_display_create_surface; 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/gdkdrag-win32.c b/gdk/win32/gdkdrag-win32.c index 24df191d05..619beaca33 100644 --- a/gdk/win32/gdkdrag-win32.c +++ b/gdk/win32/gdkdrag-win32.c @@ -197,7 +197,6 @@ #define COBJMACROS #include "gdkdrag.h" -#include "gdkproperty.h" #include "gdkinternals.h" #include "gdkprivate-win32.h" #include "gdkwin32.h" diff --git a/gdk/win32/gdkdrop-win32.c b/gdk/win32/gdkdrop-win32.c index 3bcb92b89b..f7244f8f2e 100644 --- a/gdk/win32/gdkdrop-win32.c +++ b/gdk/win32/gdkdrop-win32.c @@ -42,7 +42,6 @@ #include "gdkdropprivate.h" #include "gdkdrag.h" -#include "gdkproperty.h" #include "gdkinternals.h" #include "gdkprivate-win32.h" #include "gdkwin32.h" diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h index d3377bbf34..28b371f80d 100644 --- a/gdk/win32/gdkprivate-win32.h +++ b/gdk/win32/gdkprivate-win32.h @@ -294,10 +294,6 @@ GdkWin32Clipdrop *_win32_clipdrop; GThread *_win32_main_thread; void _gdk_win32_dnd_do_dragdrop (void); -void _gdk_win32_ole2_dnd_property_change (GdkAtom type, - gint format, - const guchar *data, - gint nelements); typedef enum { GDK_WIN32_MODAL_OP_NONE = 0x0, @@ -374,35 +370,6 @@ GList *_gdk_win32_display_list_devices (GdkDisplay *dpy); gboolean _gdk_win32_display_has_pending (GdkDisplay *display); void _gdk_win32_display_queue_events (GdkDisplay *display); -gboolean _gdk_win32_selection_owner_set_for_display (GdkDisplay *display, - GdkSurface *owner, - GdkAtom selection, - guint32 time, - gboolean send_event); -void _gdk_win32_display_send_selection_notify (GdkDisplay *display, - GdkSurface *requestor, - GdkAtom selection, - GdkAtom target, - GdkAtom property, - guint32 time); -gint _gdk_win32_display_get_selection_property (GdkDisplay *display, - GdkSurface *requestor, - guchar **data, - GdkAtom *ret_type, - gint *ret_format); -void _gdk_win32_display_convert_selection (GdkDisplay *display, - GdkSurface *requestor, - GdkAtom selection, - GdkAtom target, - guint32 time); -gint _gdk_win32_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, - gint format, - 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); guint8 _gdk_win32_keymap_get_rshift_scancode (GdkWin32Keymap *keymap); diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c index d0bc65ff59..7fbf644b5e 100644 --- a/gdk/win32/gdkproperty-win32.c +++ b/gdk/win32/gdkproperty-win32.c @@ -29,7 +29,6 @@ #include <glib/gprintf.h> #include <pango/pangowin32.h> -#include "gdkproperty.h" #include "gdkdisplayprivate.h" #include "gdkprivate-win32.h" #include "gdkwin32.h" diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index c69df8f7b5..8e877ed3d7 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -650,6 +650,7 @@ _gdk_win32_display_create_surface (GdkDisplay *display, } _gdk_win32_surface_enable_transparency (surface); + _gdk_win32_surface_register_dnd (surface); g_signal_connect (frame_clock, "after-paint", @@ -5236,7 +5237,6 @@ gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass) impl_class->begin_move_drag = gdk_win32_surface_begin_move_drag; impl_class->set_opacity = gdk_win32_surface_set_opacity; impl_class->destroy_notify = gdk_win32_surface_destroy_notify; - impl_class->register_dnd = _gdk_win32_surface_register_dnd; impl_class->drag_begin = _gdk_win32_surface_drag_begin; impl_class->create_gl_context = _gdk_win32_surface_create_gl_context; impl_class->get_scale_factor = _gdk_win32_surface_get_scale_factor; diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c index 0132f11d15..e22dbfd3eb 100644 --- a/gdk/x11/gdkdevicemanager-xi2.c +++ b/gdk/x11/gdkdevicemanager-xi2.c @@ -210,7 +210,7 @@ translate_valuator_class (GdkDisplay *display, static gboolean initialized = FALSE; static Atom label_atoms [GDK_AXIS_LAST] = { 0 }; GdkAxisUse use = GDK_AXIS_IGNORE; - GdkAtom label; + const char *label; gint i; if (!initialized) @@ -234,12 +234,12 @@ translate_valuator_class (GdkDisplay *display, } if (valuator_label != None) - label = gdk_x11_xatom_to_atom_for_display (display, valuator_label); + label = gdk_x11_get_xatom_name_for_display (display, valuator_label); else label = NULL; _gdk_device_add_axis (device, label, use, min, max, resolution); - GDK_DISPLAY_NOTE (display, INPUT, g_message ("\n\taxis: %s %s", (const char *)label, use == GDK_AXIS_IGNORE ? "(ignored)" : "(used)")); + GDK_DISPLAY_NOTE (display, INPUT, g_message ("\n\taxis: %s %s", label, use == GDK_AXIS_IGNORE ? "(ignored)" : "(used)")); } static void diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index a4c37c11ab..be8ddb214a 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -138,6 +138,7 @@ static const char *const precache_atoms[] = { "WM_PROTOCOLS", "WM_TAKE_FOCUS", "WM_WINDOW_ROLE", + "WM_STATE", "_NET_ACTIVE_WINDOW", "_NET_CURRENT_DESKTOP", "_NET_FRAME_EXTENTS", @@ -177,7 +178,23 @@ static const char *const precache_atoms[] = { "_NET_VIRTUAL_ROOTS", "GDK_SELECTION", "_NET_WM_STATE_FOCUSED", - "GDK_VISUALS" + "GDK_VISUALS", + "XdndAware", + "XdndProxy", + "XdndActionAsk", + "XdndActionCopy", + "XdndActionLink", + "XdndActionList", + "XdndActionMove", + "XdndActionPrivate", + "XdndDrop", + "XdndEnter", + "XdndFinished", + "XdndLeave", + "XdndPosition", + "XdndSelection", + "XdndStatus", + "XdndTypeList" }; static char *gdk_sm_client_id; @@ -588,12 +605,6 @@ gdk_check_edge_constraints_changed (GdkSurface *surface) do_net_wm_state_changes (surface); } -static Atom -get_cm_atom (GdkDisplay *display) -{ - return _gdk_x11_get_xatom_for_display_printf (display, "_NET_WM_CM_S%d", DefaultScreen (GDK_DISPLAY_XDISPLAY (display))); -} - static Window get_event_xwindow (const XEvent *xevent) { @@ -1400,10 +1411,10 @@ gdk_x11_display_open (const gchar *display_name) GdkX11Display *display_x11; gint argc; gchar *argv[1]; - XClassHint *class_hint; gint ignore; gint maj, min; + char *cm_name; XInitThreads (); @@ -1646,10 +1657,12 @@ gdk_x11_display_open (const gchar *display_name) * notification, and then setup the initial state of * is_composited to avoid a race condition here. */ - gdk_x11_display_request_selection_notification (display, - gdk_x11_xatom_to_atom_for_display (display, get_cm_atom (display))); + cm_name = g_strdup_printf ("_NET_WM_CM_S%d", DefaultScreen (GDK_DISPLAY_XDISPLAY (display))); + gdk_x11_display_request_selection_notification (display, cm_name); gdk_display_set_composited (GDK_DISPLAY (display), - XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), get_cm_atom (display)) != None); + XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), + gdk_x11_get_xatom_by_name_for_display (display, cm_name)) != None); + g_free (cm_name); gdk_display_emit_opened (display); @@ -1944,8 +1957,8 @@ gdk_x11_display_finalize (GObject *object) g_slist_free_full (display_x11->streams, g_object_unref); /* Atom Hashtable */ - g_hash_table_destroy (display_x11->atom_from_virtual); - g_hash_table_destroy (display_x11->atom_to_virtual); + g_hash_table_destroy (display_x11->atom_from_string); + g_hash_table_destroy (display_x11->atom_to_string); /* Leader Window */ XDestroyWindow (display_x11->xdisplay, display_x11->leader_window); @@ -3035,8 +3048,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete; 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/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h index 5949123270..fa688f0aca 100644 --- a/gdk/x11/gdkdisplay-x11.h +++ b/gdk/x11/gdkdisplay-x11.h @@ -90,8 +90,8 @@ struct _GdkX11Display GdkDrop *current_drop; /* Mapping to/from virtual atoms */ - GHashTable *atom_from_virtual; - GHashTable *atom_to_virtual; + GHashTable *atom_from_string; + GHashTable *atom_to_string; /* Session Management leader window see ICCCM */ char *program_class; @@ -124,9 +124,6 @@ struct _GdkX11Display gulong user_time; /* Sets of atoms for DND */ - guint base_dnd_atoms_precached : 1; - guint xdnd_atoms_precached : 1; - guint motif_atoms_precached : 1; guint use_sync : 1; guint have_shapes : 1; diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c index 04fa753fa3..b946cb255f 100644 --- a/gdk/x11/gdkdrag-x11.c +++ b/gdk/x11/gdkdrag-x11.c @@ -36,7 +36,6 @@ #include "gdksurfaceprivate.h" #include "gdkinternals.h" #include "gdkintl.h" -#include "gdkproperty.h" #include "gdkprivate-x11.h" #include "gdkscreen-x11.h" #include "gdkselectioninputstream-x11.h" @@ -1056,8 +1055,8 @@ xdnd_send_enter (GdkX11Drag *drag_x11) GdkDrag *drag = GDK_DRAG (drag_x11); GdkDisplay *display = gdk_drag_get_display (drag); GdkContentFormats *formats; - const char * const *atoms; - gsize i, n_atoms; + const char * const *mime_types; + gsize i, n_mime_types; XEvent xev; xev.xclient.type = ClientMessage; @@ -1078,9 +1077,9 @@ xdnd_send_enter (GdkX11Drag *drag_x11) formats = gdk_content_formats_ref (gdk_drag_get_formats (drag)); formats = gdk_content_formats_union_serialize_mime_types (formats); - atoms = gdk_content_formats_get_mime_types (formats, &n_atoms); + mime_types = gdk_content_formats_get_mime_types (formats, &n_mime_types); - if (n_atoms > 3) + if (n_mime_types > 3) { if (!drag_x11->xdnd_targets_set) xdnd_set_targets (drag_x11); @@ -1088,9 +1087,9 @@ xdnd_send_enter (GdkX11Drag *drag_x11) } else { - for (i = 0; i < n_atoms; i++) + for (i = 0; i < n_mime_types; i++) { - xev.xclient.data.l[i + 2] = gdk_x11_atom_to_xatom_for_display (display, atoms[i]); + xev.xclient.data.l[i + 2] = gdk_x11_get_xatom_by_name_for_display (display, mime_types[i]); } } @@ -1242,59 +1241,6 @@ xdnd_check_dest (GdkDisplay *display, return retval ? (proxy ? proxy : win) : None; } -/* Target side */ - -static void -base_precache_atoms (GdkDisplay *display) -{ - GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); - - if (!display_x11->base_dnd_atoms_precached) - { - static const char *const precache_atoms[] = { - "WM_STATE", - "XdndAware", - "XdndProxy" - }; - - _gdk_x11_precache_atoms (display, - precache_atoms, G_N_ELEMENTS (precache_atoms)); - - display_x11->base_dnd_atoms_precached = TRUE; - } -} - -static void -xdnd_precache_atoms (GdkDisplay *display) -{ - GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); - - if (!display_x11->xdnd_atoms_precached) - { - static const gchar *const precache_atoms[] = { - "XdndActionAsk", - "XdndActionCopy", - "XdndActionLink", - "XdndActionList", - "XdndActionMove", - "XdndActionPrivate", - "XdndDrop", - "XdndEnter", - "XdndFinished", - "XdndLeave", - "XdndPosition", - "XdndSelection", - "XdndStatus", - "XdndTypeList" - }; - - _gdk_x11_precache_atoms (display, - precache_atoms, G_N_ELEMENTS (precache_atoms)); - - display_x11->xdnd_atoms_precached = TRUE; - } -} - /* Source side */ static void @@ -1339,8 +1285,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display, GdkSurface *surface; Window retval; - base_precache_atoms (display); - /* Check for a local drag */ surface = gdk_x11_surface_lookup_for_display (display, xid); if (surface) @@ -1349,7 +1293,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display, { *protocol = GDK_DRAG_PROTO_XDND; *version = 5; - xdnd_precache_atoms (display); GDK_DISPLAY_NOTE (display, DND, g_message ("Entering local Xdnd window %#x\n", (guint) xid)); return xid; } @@ -1363,7 +1306,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display, else if ((retval = xdnd_check_dest (display, xid, version))) { *protocol = GDK_DRAG_PROTO_XDND; - xdnd_precache_atoms (display); GDK_DISPLAY_NOTE (display, DND, g_message ("Entering Xdnd window %#x\n", (guint) xid)); return retval; } @@ -1639,8 +1581,6 @@ _gdk_x11_surface_register_dnd (GdkSurface *surface) g_return_if_fail (surface != NULL); - base_precache_atoms (display); - if (g_object_get_data (G_OBJECT (surface), "gdk-dnd-registered") != NULL) return; else diff --git a/gdk/x11/gdkdrop-x11.c b/gdk/x11/gdkdrop-x11.c index c85c17be0f..d5cce6a6e1 100644 --- a/gdk/x11/gdkdrop-x11.c +++ b/gdk/x11/gdkdrop-x11.c @@ -35,7 +35,6 @@ #include "gdkdragprivate.h" #include "gdkinternals.h" #include "gdkintl.h" -#include "gdkproperty.h" #include "gdkprivate-x11.h" #include "gdkscreen-x11.h" #include "gdkselectioninputstream-x11.h" @@ -430,37 +429,6 @@ xdnd_source_surface_filter (GdkDisplay *display, return FALSE; } -static void -xdnd_precache_atoms (GdkDisplay *display) -{ - GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); - - if (!display_x11->xdnd_atoms_precached) - { - static const gchar *const precache_atoms[] = { - "XdndActionAsk", - "XdndActionCopy", - "XdndActionLink", - "XdndActionList", - "XdndActionMove", - "XdndActionPrivate", - "XdndDrop", - "XdndEnter", - "XdndFinished", - "XdndLeave", - "XdndPosition", - "XdndSelection", - "XdndStatus", - "XdndTypeList" - }; - - _gdk_x11_precache_atoms (display, - precache_atoms, G_N_ELEMENTS (precache_atoms)); - - display_x11->xdnd_atoms_precached = TRUE; - } -} - static gboolean xdnd_enter_filter (GdkSurface *surface, const XEvent *xevent) @@ -490,8 +458,6 @@ xdnd_enter_filter (GdkSurface *surface, display = gdk_surface_get_display (surface); display_x11 = GDK_X11_DISPLAY (display); - xdnd_precache_atoms (display); - GDK_DISPLAY_NOTE (display, DND, g_message ("XdndEnter: source_window: %#lx, version: %#x", source_window, version)); @@ -608,8 +574,6 @@ xdnd_leave_filter (GdkSurface *surface, g_message ("XdndLeave: source_window: %#lx", source_window)); - xdnd_precache_atoms (display); - if ((display_x11->current_drop != NULL) && (GDK_X11_DROP (display_x11->current_drop)->source_window == source_window)) { @@ -644,8 +608,6 @@ xdnd_position_filter (GdkSurface *surface, g_message ("XdndPosition: source_window: %#lx position: (%d, %d) time: %d action: %ld", source_window, x_root, y_root, time, action)); - xdnd_precache_atoms (display); - drop = display_x11->current_drop; drop_x11 = GDK_X11_DROP (drop); @@ -693,8 +655,6 @@ xdnd_drop_filter (GdkSurface *surface, g_message ("XdndDrop: source_window: %#lx time: %d", source_window, time)); - xdnd_precache_atoms (display); - drop = display_x11->current_drop; drop_x11 = GDK_X11_DROP (drop); diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 69a1248b8a..36cdea1d1c 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -120,13 +120,13 @@ void _gdk_x11_display_queue_events (GdkDisplay *display); GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display); gint _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, + const char *encoding, gint format, 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); @@ -162,12 +162,6 @@ void gdk_x11_device_xi2_store_axes (GdkX11DeviceXI2 *device, gdouble *axes, gint n_axes); -GdkAtom _gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager, - const gchar *atom_name, - gboolean copy_name); -gchar * _gdk_x11_display_manager_get_atom_name (GdkDisplayManager *manager, - GdkAtom atom); - gboolean _gdk_x11_display_supports_cursor_alpha (GdkDisplay *display); gboolean _gdk_x11_display_supports_cursor_color (GdkDisplay *display); void _gdk_x11_display_get_default_cursor_size (GdkDisplay *display, diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c index 5579e6a4b4..b93b7fdbf4 100644 --- a/gdk/x11/gdkproperty-x11.c +++ b/gdk/x11/gdkproperty-x11.c @@ -24,7 +24,6 @@ #include "config.h" -#include "gdkproperty.h" #include "gdkinternals.h" #include "gdkprivate-x11.h" #include "gdkdisplay-x11.h" @@ -36,68 +35,66 @@ static void insert_atom_pair (GdkDisplay *display, - GdkAtom virtual_atom, + const char *string, Atom xatom) { GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); + char *s; - if (!display_x11->atom_from_virtual) + if (!display_x11->atom_from_string) { - display_x11->atom_from_virtual = g_hash_table_new (g_direct_hash, NULL); - display_x11->atom_to_virtual = g_hash_table_new (g_direct_hash, NULL); + display_x11->atom_from_string = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + display_x11->atom_to_string = g_hash_table_new (NULL, NULL); } - g_hash_table_insert (display_x11->atom_from_virtual, (gpointer)virtual_atom, - GUINT_TO_POINTER (xatom)); - g_hash_table_insert (display_x11->atom_to_virtual, - GUINT_TO_POINTER (xatom), (gpointer)virtual_atom); + s = g_strdup (string); + g_hash_table_insert (display_x11->atom_from_string, s, GUINT_TO_POINTER (xatom)); + g_hash_table_insert (display_x11->atom_to_string, GUINT_TO_POINTER (xatom), s); } static Atom lookup_cached_xatom (GdkDisplay *display, - GdkAtom atom) + const char *string) { GdkX11Display *display_x11 = GDK_X11_DISPLAY (display); - if (display_x11->atom_from_virtual) - return GPOINTER_TO_UINT (g_hash_table_lookup (display_x11->atom_from_virtual, atom)); + if (display_x11->atom_from_string) + return GPOINTER_TO_UINT (g_hash_table_lookup (display_x11->atom_from_string, string)); return None; } /** - * gdk_x11_atom_to_xatom_for_display: - * @display: (type GdkX11Display): A #GdkDisplay - * @atom: A #GdkAtom, or %NULL - * - * Converts from a #GdkAtom to the X atom for a #GdkDisplay - * with the same string value. The special value %NULL - * is converted to %None. - * - * Returns: the X atom corresponding to @atom, or %None + * gdk_x11_get_xatom_by_name_for_display: + * @display: (type GdkX11Display): a #GdkDisplay + * @atom_name: a string + * + * Returns the X atom for a #GdkDisplay corresponding to @atom_name. + * This function caches the result, so if called repeatedly it is much + * faster than XInternAtom(), which is a round trip to the server each time. + * + * Returns: a X atom for a #GdkDisplay **/ Atom -gdk_x11_atom_to_xatom_for_display (GdkDisplay *display, - GdkAtom atom) +gdk_x11_get_xatom_by_name_for_display (GdkDisplay *display, + const gchar *atom_name) { Atom xatom = None; g_return_val_if_fail (GDK_IS_DISPLAY (display), None); - if (atom == NULL) + if (atom_name == NULL) return None; if (gdk_display_is_closed (display)) return None; - xatom = lookup_cached_xatom (display, atom); + xatom = lookup_cached_xatom (display, atom_name); if (!xatom) { - const char *name = (const char *)atom; - - xatom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), name, FALSE); - insert_atom_pair (display, atom, xatom); + xatom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), atom_name, FALSE); + insert_atom_pair (display, atom_name, xatom); } return xatom; @@ -109,22 +106,18 @@ _gdk_x11_precache_atoms (GdkDisplay *display, gint n_atoms) { Atom *xatoms; - GdkAtom *atoms; - const gchar **xatom_names; + const char **xatom_names; gint n_xatoms; gint i; xatoms = g_new (Atom, n_atoms); - xatom_names = g_new (const gchar *, n_atoms); - atoms = g_new (GdkAtom, n_atoms); + xatom_names = g_new (const char *, n_atoms); n_xatoms = 0; for (i = 0; i < n_atoms; i++) { - GdkAtom atom = g_intern_static_string (atom_names[i]); - if (lookup_cached_xatom (display, atom) == None) + if (lookup_cached_xatom (display, atom_names[i]) == None) { - atoms[n_xatoms] = atom; xatom_names[n_xatoms] = atom_names[i]; n_xatoms++; } @@ -132,32 +125,35 @@ _gdk_x11_precache_atoms (GdkDisplay *display, if (n_xatoms) XInternAtoms (GDK_DISPLAY_XDISPLAY (display), - (char **)xatom_names, n_xatoms, False, xatoms); + (char **) xatom_names, n_xatoms, False, xatoms); for (i = 0; i < n_xatoms; i++) - insert_atom_pair (display, atoms[i], xatoms[i]); + insert_atom_pair (display, xatom_names[i], xatoms[i]); g_free (xatoms); g_free (xatom_names); - g_free (atoms); } /** - * gdk_x11_xatom_to_atom_for_display: - * @display: (type GdkX11Display): A #GdkDisplay + * gdk_x11_get_xatom_name_for_display: + * @display: (type GdkX11Display): the #GdkDisplay where @xatom is defined * @xatom: an X atom * - * Convert from an X atom for a #GdkDisplay to the corresponding - * #GdkAtom. - * - * Returns: (transfer none): the corresponding #GdkAtom. + * Returns the name of an X atom for its display. This + * function is meant mainly for debugging, so for convenience, unlike + * XAtomName() and the result doesn’t need to + * be freed. + * + * Returns: name of the X atom; this string is owned by GDK, + * so it shouldn’t be modifed or freed. **/ -GdkAtom -gdk_x11_xatom_to_atom_for_display (GdkDisplay *display, - Atom xatom) +const gchar * +gdk_x11_get_xatom_name_for_display (GdkDisplay *display, + Atom xatom) + { GdkX11Display *display_x11; - GdkAtom virtual_atom = NULL; + const char *string; g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); @@ -169,11 +165,13 @@ gdk_x11_xatom_to_atom_for_display (GdkDisplay *display, display_x11 = GDK_X11_DISPLAY (display); - if (display_x11->atom_to_virtual) - virtual_atom = g_hash_table_lookup (display_x11->atom_to_virtual, - GUINT_TO_POINTER (xatom)); + if (display_x11->atom_to_string) + string = g_hash_table_lookup (display_x11->atom_to_string, + GUINT_TO_POINTER (xatom)); + else + string = NULL; - if (!virtual_atom) + if (!string) { /* If this atom doesn't exist, we'll die with an X error unless * we take precautions @@ -187,33 +185,14 @@ gdk_x11_xatom_to_atom_for_display (GdkDisplay *display, } else { - virtual_atom = g_intern_string (name); + insert_atom_pair (display, name, xatom); XFree (name); - - insert_atom_pair (display, virtual_atom, xatom); + string = g_hash_table_lookup (display_x11->atom_to_string, + GUINT_TO_POINTER (xatom)); } } - return virtual_atom; -} - -/** - * gdk_x11_get_xatom_by_name_for_display: - * @display: (type GdkX11Display): a #GdkDisplay - * @atom_name: a string - * - * Returns the X atom for a #GdkDisplay corresponding to @atom_name. - * This function caches the result, so if called repeatedly it is much - * faster than XInternAtom(), which is a round trip to the server each time. - * - * Returns: a X atom for a #GdkDisplay - **/ -Atom -gdk_x11_get_xatom_by_name_for_display (GdkDisplay *display, - const gchar *atom_name) -{ - g_return_val_if_fail (GDK_IS_DISPLAY (display), None); - return gdk_x11_atom_to_xatom_for_display (display, g_intern_string (atom_name)); + return string; } Atom @@ -236,25 +215,3 @@ _gdk_x11_get_xatom_for_display_printf (GdkDisplay *display, return atom; } -/** - * gdk_x11_get_xatom_name_for_display: - * @display: (type GdkX11Display): the #GdkDisplay where @xatom is defined - * @xatom: an X atom - * - * Returns the name of an X atom for its display. This - * function is meant mainly for debugging, so for convenience, unlike - * XAtomName() and the result doesn’t need to - * be freed. - * - * Returns: name of the X atom; this string is owned by GDK, - * so it shouldn’t be modifed or freed. - **/ -const gchar * -gdk_x11_get_xatom_name_for_display (GdkDisplay *display, - Atom xatom) -{ - g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); - - return (const char *)gdk_x11_xatom_to_atom_for_display (display, xatom); -} - diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c index b99972a029..5419c72bb2 100644 --- a/gdk/x11/gdkscreen-x11.c +++ b/gdk/x11/gdkscreen-x11.c @@ -1208,7 +1208,7 @@ fetch_net_wm_check_window (GdkX11Screen *x11_screen) /** * gdk_x11_screen_supports_net_wm_hint: * @screen: the relevant #GdkX11Screen. - * @property: a property atom. + * @property_name: name of the WM property * * This function is specific to the X11 backend of GDK, and indicates * whether the window manager supports a certain hint from the @@ -1227,7 +1227,7 @@ fetch_net_wm_check_window (GdkX11Screen *x11_screen) **/ gboolean gdk_x11_screen_supports_net_wm_hint (GdkX11Screen *x11_screen, - GdkAtom property) + const char *property_name) { gulong i; NetWmSupportedAtoms *supported_atoms; @@ -1281,7 +1281,7 @@ gdk_x11_screen_supports_net_wm_hint (GdkX11Screen *x11_screen, if (supported_atoms->atoms == NULL) return FALSE; - atom = gdk_x11_atom_to_xatom_for_display (display, property); + atom = gdk_x11_get_xatom_by_name_for_display (display, property_name); for (i = 0; i < supported_atoms->n_atoms; i++) { @@ -1382,7 +1382,6 @@ static guint32 get_netwm_cardinal_property (GdkX11Screen *x11_screen, const gchar *name) { - GdkAtom atom; guint32 prop = 0; Atom type; gint format; @@ -1390,9 +1389,7 @@ get_netwm_cardinal_property (GdkX11Screen *x11_screen, gulong bytes_after; guchar *data; - atom = g_intern_static_string (name); - - if (!gdk_x11_screen_supports_net_wm_hint (x11_screen, atom)) + if (!gdk_x11_screen_supports_net_wm_hint (x11_screen, name)) return 0; XGetWindowProperty (x11_screen->xdisplay, diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index 7f34dfce84..544d0875dc 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -24,7 +24,6 @@ #include "config.h" -#include "gdkproperty.h" #include "gdkprivate-x11.h" #include "gdkdisplay-x11.h" @@ -36,8 +35,8 @@ /** * gdk_x11_display_text_property_to_text_list: * @display: (type GdkX11Display): The #GdkDisplay where the encoding is defined - * @encoding: an atom representing the encoding. The most - * common values for this are STRING, or COMPOUND_TEXT. + * @encoding: a string representing the encoding. The most + * common values for this are "STRING", or "COMPOUND_TEXT". * This is value used as the type for the property * @format: the format of the property * @text: The text data @@ -56,7 +55,7 @@ */ gint gdk_x11_display_text_property_to_text_list (GdkDisplay *display, - GdkAtom encoding, + const char *encoding, gint format, const guchar *text, gint length, @@ -75,7 +74,7 @@ gdk_x11_display_text_property_to_text_list (GdkDisplay *display, return 0; property.value = (guchar *)text; - property.encoding = gdk_x11_atom_to_xatom_for_display (display, encoding); + property.encoding = gdk_x11_get_xatom_by_name_for_display (display, encoding); property.format = format; property.nitems = length; res = XmbTextPropertyToTextList (GDK_DISPLAY_XDISPLAY (display), &property, @@ -189,17 +188,17 @@ make_list (const gchar *text, gint _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display, - GdkAtom encoding, + const char *encoding, gint format, const guchar *text, gint length, gchar ***list) { - if (encoding == g_intern_static_string ("STRING")) + if (g_str_equal (encoding, "STRING")) { return make_list ((gchar *)text, length, TRUE, list); } - else if (encoding == g_intern_static_string ("UTF8_STRING")) + else if (g_str_equal (encoding, "UTF8_STRING")) { return make_list ((gchar *)text, length, FALSE, list); } @@ -274,7 +273,7 @@ _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display, * gdk_x11_display_string_to_compound_text: * @display: (type GdkX11Display): the #GdkDisplay where the encoding is defined * @str: a nul-terminated string - * @encoding: (out) (transfer none): location to store the encoding atom + * @encoding: (out) (transfer none): location to store the encoding * (to be used as the type for the property) * @format: (out): location to store the format of the property * @ctext: (out) (array length=length): location to store newly @@ -288,8 +287,8 @@ _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display, */ gint gdk_x11_display_string_to_compound_text (GdkDisplay *display, - const gchar *str, - GdkAtom *encoding, + const char *str, + const char **encoding, gint *format, guchar **ctext, gint *length) @@ -314,7 +313,7 @@ gdk_x11_display_string_to_compound_text (GdkDisplay *display, } if (encoding) - *encoding = gdk_x11_xatom_to_atom_for_display (display, property.encoding); + *encoding = gdk_x11_get_xatom_name_for_display (display, property.encoding); if (format) *format = property.format; if (ctext) @@ -325,75 +324,11 @@ 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 * @str: a UTF-8 string - * @encoding: (out): location to store resulting encoding + * @encoding: (out) (transfer none): location to store resulting encoding * @format: (out): location to store format of the result * @ctext: (out) (array length=length): location to store the data of the result * @length: location to store the length of the data @@ -406,8 +341,8 @@ _gdk_x11_display_utf8_to_string_target (GdkDisplay *display, */ gboolean gdk_x11_display_utf8_to_compound_text (GdkDisplay *display, - const gchar *str, - GdkAtom *encoding, + const char *str, + const char **encoding, gint *format, guchar **ctext, gint *length) @@ -423,7 +358,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) { @@ -442,7 +377,7 @@ gdk_x11_display_utf8_to_compound_text (GdkDisplay *display, g_error_free (error); if (encoding) - *encoding = None; + *encoding = NULL; if (format) *format = None; if (ctext) diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 8d052e9d3d..4a5c52f19c 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -923,6 +923,8 @@ _gdk_x11_display_create_surface (GdkDisplay *display, GDK_SURFACE_XID (surface), GDK_ALL_EVENTS_MASK, StructureNotifyMask | PropertyChangeMask); + _gdk_x11_surface_register_dnd (surface); + connect_frame_clock (surface); gdk_surface_freeze_updates (surface); @@ -1624,7 +1626,6 @@ get_netwm_cardinal_property (GdkSurface *surface, const gchar *name) { GdkX11Screen *x11_screen = GDK_SURFACE_SCREEN (surface); - GdkAtom atom; guint32 prop = 0; Atom type; gint format; @@ -1632,9 +1633,7 @@ get_netwm_cardinal_property (GdkSurface *surface, gulong bytes_after; guchar *data; - atom = g_intern_static_string (name); - - if (!gdk_x11_screen_supports_net_wm_hint (x11_screen, atom)) + if (!gdk_x11_screen_supports_net_wm_hint (x11_screen, name)) return 0; XGetWindowProperty (x11_screen->xdisplay, @@ -1681,13 +1680,12 @@ void gdk_x11_surface_move_to_desktop (GdkSurface *surface, guint32 desktop) { - GdkAtom atom; + const char *atom_name = "_NET_WM_DESKTOP"; XClientMessageEvent xclient; g_return_if_fail (GDK_IS_SURFACE (surface)); - atom = g_intern_static_string ("_NET_WM_DESKTOP"); - if (!gdk_x11_screen_supports_net_wm_hint (GDK_SURFACE_SCREEN (surface), atom)) + if (!gdk_x11_screen_supports_net_wm_hint (GDK_SURFACE_SCREEN (surface), atom_name)) return; memset (&xclient, 0, sizeof (xclient)); @@ -1695,7 +1693,7 @@ gdk_x11_surface_move_to_desktop (GdkSurface *surface, xclient.serial = 0; xclient.send_event = True; xclient.window = GDK_SURFACE_XID (surface); - xclient.message_type = gdk_x11_atom_to_xatom_for_display (GDK_SURFACE_DISPLAY (surface), atom); + xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_SURFACE_DISPLAY (surface), atom_name); xclient.format = 32; xclient.data.l[0] = desktop; @@ -1895,10 +1893,10 @@ gdk_x11_surface_get_type_hint (GdkSurface *surface) } static void -gdk_wmspec_change_state (gboolean add, +gdk_wmspec_change_state (gboolean add, GdkSurface *surface, - GdkAtom state1, - GdkAtom state2) + const char *state1, + const char *state2) { GdkDisplay *display = GDK_SURFACE_DISPLAY (surface); XClientMessageEvent xclient; @@ -1913,8 +1911,8 @@ gdk_wmspec_change_state (gboolean add, xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"); xclient.format = 32; xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; - xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1); - xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2); + xclient.data.l[1] = gdk_x11_get_xatom_by_name_for_display (display, state1); + xclient.data.l[2] = gdk_x11_get_xatom_by_name_for_display (display, state2); xclient.data.l[3] = 1; /* source indication */ xclient.data.l[4] = 0; @@ -1934,7 +1932,7 @@ gdk_x11_surface_set_modal_hint (GdkSurface *surface, if (GDK_SURFACE_IS_MAPPED (surface)) gdk_wmspec_change_state (modal, surface, - g_intern_static_string ("_NET_WM_STATE_MODAL"), + "_NET_WM_STATE_MODAL", NULL); } @@ -1960,7 +1958,7 @@ gdk_x11_surface_set_skip_taskbar_hint (GdkSurface *surface, if (GDK_SURFACE_IS_MAPPED (surface)) gdk_wmspec_change_state (skips_taskbar, surface, - g_intern_static_string ("_NET_WM_STATE_SKIP_TASKBAR"), + "_NET_WM_STATE_SKIP_TASKBAR", NULL); } @@ -1986,7 +1984,7 @@ gdk_x11_surface_set_skip_pager_hint (GdkSurface *surface, if (GDK_SURFACE_IS_MAPPED (surface)) gdk_wmspec_change_state (skips_pager, surface, - g_intern_static_string ("_NET_WM_STATE_SKIP_PAGER"), + "_NET_WM_STATE_SKIP_PAGER", NULL); } @@ -2233,19 +2231,19 @@ 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; } else { - GdkAtom gdk_type; + const char *gdk_type; gdk_x11_display_utf8_to_compound_text (display, utf8_str, &gdk_type, &prop_format, (guchar **)&prop_text, &prop_length); - prop_type = gdk_x11_atom_to_xatom_for_display (display, gdk_type); + prop_type = gdk_x11_get_xatom_by_name_for_display (display, gdk_type); is_compound_text = TRUE; } @@ -3089,7 +3087,7 @@ gdk_x11_surface_minimize (GdkSurface *surface) /* Flip our client side flag, the real work happens on map. */ gdk_synthesize_surface_state (surface, 0, GDK_SURFACE_STATE_MINIMIZED); gdk_wmspec_change_state (TRUE, surface, - g_intern_static_string ("_NET_WM_STATE_HIDDEN"), + "_NET_WM_STATE_HIDDEN", NULL); } } @@ -3104,7 +3102,7 @@ gdk_x11_surface_unminimize (GdkSurface *surface) { gdk_surface_show (surface); gdk_wmspec_change_state (FALSE, surface, - g_intern_static_string ("_NET_WM_STATE_HIDDEN"), + "_NET_WM_STATE_HIDDEN", NULL); } else @@ -3112,7 +3110,7 @@ gdk_x11_surface_unminimize (GdkSurface *surface) /* Flip our client side flag, the real work happens on map. */ gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_MINIMIZED, 0); gdk_wmspec_change_state (FALSE, surface, - g_intern_static_string ("_NET_WM_STATE_HIDDEN"), + "_NET_WM_STATE_HIDDEN", NULL); } } @@ -3133,7 +3131,7 @@ gdk_x11_surface_stick (GdkSurface *surface) /* Request stick during viewport scroll */ gdk_wmspec_change_state (TRUE, surface, - g_intern_static_string ("_NET_WM_STATE_STICKY"), + "_NET_WM_STATE_STICKY", NULL); /* Request desktop 0xFFFFFFFF */ @@ -3174,7 +3172,7 @@ gdk_x11_surface_unstick (GdkSurface *surface) { /* Request unstick from viewport */ gdk_wmspec_change_state (FALSE, surface, - g_intern_static_string ("_NET_WM_STATE_STICKY"), + "_NET_WM_STATE_STICKY", NULL); move_to_current_desktop (surface); @@ -3197,8 +3195,8 @@ gdk_x11_surface_maximize (GdkSurface *surface) if (GDK_SURFACE_IS_MAPPED (surface)) gdk_wmspec_change_state (TRUE, surface, - g_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"), - g_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ")); + "_NET_WM_STATE_MAXIMIZED_VERT", + "_NET_WM_STATE_MAXIMIZED_HORZ"); else gdk_synthesize_surface_state (surface, 0, @@ -3213,8 +3211,8 @@ gdk_x11_surface_unmaximize (GdkSurface *surface) if (GDK_SURFACE_IS_MAPPED (surface)) gdk_wmspec_change_state (FALSE, surface, - g_intern_static_string ("_NET_WM_STATE_MAXIMIZED_VERT"), - g_intern_static_string ("_NET_WM_STATE_MAXIMIZED_HORZ")); + "_NET_WM_STATE_MAXIMIZED_VERT", + "_NET_WM_STATE_MAXIMIZED_HORZ"); else gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_MAXIMIZED, @@ -3321,7 +3319,7 @@ gdk_x11_surface_fullscreen (GdkSurface *surface) if (GDK_SURFACE_IS_MAPPED (surface)) { gdk_wmspec_change_state (TRUE, surface, - g_intern_static_string ("_NET_WM_STATE_FULLSCREEN"), + "_NET_WM_STATE_FULLSCREEN", NULL); /* Actual XRandR layout may have change since we computed the fullscreen * monitors in GDK_FULLSCREEN_ON_ALL_MONITORS mode. @@ -3359,7 +3357,7 @@ gdk_x11_surface_unfullscreen (GdkSurface *surface) if (GDK_SURFACE_IS_MAPPED (surface)) gdk_wmspec_change_state (FALSE, surface, - g_intern_static_string ("_NET_WM_STATE_FULLSCREEN"), + "_NET_WM_STATE_FULLSCREEN", NULL); else @@ -3381,10 +3379,10 @@ gdk_x11_surface_set_keep_above (GdkSurface *surface, { if (setting) gdk_wmspec_change_state (FALSE, surface, - g_intern_static_string ("_NET_WM_STATE_BELOW"), + "_NET_WM_STATE_BELOW", NULL); gdk_wmspec_change_state (setting, surface, - g_intern_static_string ("_NET_WM_STATE_ABOVE"), + "_NET_WM_STATE_ABOVE", NULL); } else @@ -3405,10 +3403,10 @@ gdk_x11_surface_set_keep_below (GdkSurface *surface, gboolean setting) { if (setting) gdk_wmspec_change_state (FALSE, surface, - g_intern_static_string ("_NET_WM_STATE_ABOVE"), + "_NET_WM_STATE_ABOVE", NULL); gdk_wmspec_change_state (setting, surface, - g_intern_static_string ("_NET_WM_STATE_BELOW"), + "_NET_WM_STATE_BELOW", NULL); } else @@ -4730,7 +4728,6 @@ gdk_x11_surface_class_init (GdkX11SurfaceClass *klass) impl_class->begin_move_drag = gdk_x11_surface_begin_move_drag; impl_class->set_opacity = gdk_x11_surface_set_opacity; impl_class->destroy_notify = gdk_x11_surface_destroy_notify; - impl_class->register_dnd = _gdk_x11_surface_register_dnd; impl_class->drag_begin = _gdk_x11_surface_drag_begin; impl_class->get_scale_factor = gdk_x11_surface_get_scale_factor; impl_class->set_opaque_region = gdk_x11_surface_set_opaque_region; diff --git a/gdk/x11/gdktextlistconverter-x11.c b/gdk/x11/gdktextlistconverter-x11.c index 38c7df9a71..0e6999e7e4 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) { @@ -165,7 +222,7 @@ gdk_x11_text_list_converter_encode (GdkX11TextListConverter *conv, { GConverterResult result; guchar *text; - GdkAtom encoding; + const char *encoding; gint format; gint new_length; char *tmp; @@ -174,7 +231,7 @@ gdk_x11_text_list_converter_encode (GdkX11TextListConverter *conv, if (gdk_x11_display_utf8_to_compound_text (conv->display, tmp, &encoding, &format, &text, &new_length)) { - if (encoding == g_intern_string (conv->encoding) && + if (g_str_equal (encoding, conv->encoding) && format == conv->format) { result = write_output (outbuf, outbuf_size, bytes_written, text, new_length, error); diff --git a/gdk/x11/gdkx11property.h b/gdk/x11/gdkx11property.h index 7bdc137216..5275c61214 100644 --- a/gdk/x11/gdkx11property.h +++ b/gdk/x11/gdkx11property.h @@ -36,13 +36,6 @@ G_BEGIN_DECLS -/* Functions to get the X Atom equivalent to the GdkAtom */ -GDK_AVAILABLE_IN_ALL -Atom gdk_x11_atom_to_xatom_for_display (GdkDisplay *display, - GdkAtom atom); -GDK_AVAILABLE_IN_ALL -GdkAtom gdk_x11_xatom_to_atom_for_display (GdkDisplay *display, - Atom xatom); GDK_AVAILABLE_IN_ALL Atom gdk_x11_get_xatom_by_name_for_display (GdkDisplay *display, const gchar *atom_name); diff --git a/gdk/x11/gdkx11screen.h b/gdk/x11/gdkx11screen.h index 61b965d992..b0a047d30f 100644 --- a/gdk/x11/gdkx11screen.h +++ b/gdk/x11/gdkx11screen.h @@ -59,7 +59,7 @@ const char* gdk_x11_screen_get_window_manager_name (GdkX11Screen *screen); GDK_AVAILABLE_IN_ALL gboolean gdk_x11_screen_supports_net_wm_hint (GdkX11Screen *screen, - GdkAtom property); + const char *property_name); GDK_AVAILABLE_IN_ALL XID gdk_x11_screen_get_monitor_output (GdkX11Screen *screen, diff --git a/gdk/x11/gdkx11selection.h b/gdk/x11/gdkx11selection.h index 2c7d8e2d9b..3a078ffc68 100644 --- a/gdk/x11/gdkx11selection.h +++ b/gdk/x11/gdkx11selection.h @@ -38,7 +38,7 @@ G_BEGIN_DECLS GDK_AVAILABLE_IN_ALL gint gdk_x11_display_text_property_to_text_list (GdkDisplay *display, - GdkAtom encoding, + const char *encoding, gint format, const guchar *text, gint length, @@ -47,15 +47,15 @@ GDK_AVAILABLE_IN_ALL void gdk_x11_free_text_list (gchar **list); GDK_AVAILABLE_IN_ALL gint gdk_x11_display_string_to_compound_text (GdkDisplay *display, - const gchar *str, - GdkAtom *encoding, + const char *str, + const char **encoding, gint *format, guchar **ctext, gint *length); GDK_AVAILABLE_IN_ALL gboolean gdk_x11_display_utf8_to_compound_text (GdkDisplay *display, - const gchar *str, - GdkAtom *encoding, + const char *str, + const char **encoding, gint *format, guchar **ctext, gint *length); diff --git a/gtk/gtk-autocleanups.h b/gtk/gtk-autocleanups.h index bc8671893f..59474fc967 100644 --- a/gtk/gtk-autocleanups.h +++ b/gtk/gtk-autocleanups.h @@ -165,7 +165,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkVolumeButton, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkPaperSize, gtk_paper_size_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentInfo, gtk_recent_info_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSelectionData, gtk_selection_data_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTextIter, gtk_text_iter_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreeIter, gtk_tree_iter_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreePath, gtk_tree_path_free) @@ -194,7 +194,6 @@ #include <gtk/gtkscrolledwindow.h> #include <gtk/gtksearchbar.h> #include <gtk/gtksearchentry.h> -#include <gtk/gtkselection.h> #include <gtk/gtkselectionmodel.h> #include <gtk/gtkseparator.h> #include <gtk/gtksettings.h> diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index 4ef0721072..eb63b38db0 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -1514,7 +1514,7 @@ gtk_calendar_drag_accept (GtkDropTarget *dest, GdkDrop *drop, GtkCalendar *calendar) { - GdkAtom target; + const char *target; target = gtk_drop_target_find_mimetype (dest); if (!target || gdk_drop_get_actions (drop) == 0) @@ -1537,7 +1537,7 @@ gtk_calendar_drag_drop (GtkDropTarget *dest, int y, GtkCalendar *calendar) { - GdkAtom target; + const char *target; target = gtk_drop_target_find_mimetype (dest); if (target != NULL) diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c index 8742dc6e8a..7f80e5a5f4 100644 --- a/gtk/gtkdragdest.c +++ b/gtk/gtkdragdest.c @@ -32,7 +32,6 @@ #include "gtktypebuiltins.h" #include "gtkeventcontrollerprivate.h" #include "gtkmarshalers.h" -#include "gtkselectionprivate.h" /** @@ -122,9 +121,6 @@ static gboolean gtk_drop_target_handle_event (GtkEventController *controller, double y); static gboolean gtk_drop_target_filter_event (GtkEventController *controller, GdkEvent *event); -static void gtk_drop_target_set_widget (GtkEventController *controller, - GtkWidget *widget); -static void gtk_drop_target_unset_widget (GtkEventController *controller); static gboolean gtk_drop_target_get_contains (GtkDropTarget *dest); static void gtk_drop_target_set_contains (GtkDropTarget *dest, @@ -221,8 +217,6 @@ gtk_drop_target_class_init (GtkDropTargetClass *class) controller_class->handle_event = gtk_drop_target_handle_event; controller_class->filter_event = gtk_drop_target_filter_event; - controller_class->set_widget = gtk_drop_target_set_widget; - controller_class->unset_widget = gtk_drop_target_unset_widget; class->accept = gtk_drop_target_accept; @@ -370,7 +364,7 @@ gtk_drop_target_class_init (GtkDropTargetClass *class) * * To receive the data, use one of the read functions provides by #GtkDrop * and #GtkDragDest: gdk_drop_read_async(), gdk_drop_read_value_async(), - * gdk_drop_read_text_async(), gtk_drop_target_read_selection(). + * gdk_drop_read_text_async(). * * You can use gtk_drop_target_get_drop() to obtain the #GtkDrop object * for the ongoing operation in your signal handler. If you call one of the @@ -499,25 +493,6 @@ gtk_drop_target_get_actions (GtkDropTarget *dest) return dest->actions; } -static void -gtk_drag_dest_realized (GtkWidget *widget) -{ - GtkNative *native = gtk_widget_get_native (widget); - - gdk_surface_register_dnd (gtk_native_get_surface (native)); -} - -static void -gtk_drag_dest_hierarchy_changed (GtkWidget *widget, - GParamSpec *pspec, - gpointer data) -{ - GtkNative *native = gtk_widget_get_native (widget); - - if (native && gtk_widget_get_realized (GTK_WIDGET (native))) - gdk_surface_register_dnd (gtk_native_get_surface (native)); -} - /** * gtk_drop_target_get_drop: * @dest: a #GtkDropTarget @@ -838,177 +813,6 @@ gtk_drag_dest_handle_event (GtkWidget *toplevel, } } -static void -gtk_drop_target_set_widget (GtkEventController *controller, - GtkWidget *widget) -{ - GtkDropTarget *dest = GTK_DROP_TARGET (controller); - - GTK_EVENT_CONTROLLER_CLASS (gtk_drop_target_parent_class)->set_widget (controller, widget); - - if (gtk_widget_get_realized (widget)) - gtk_drag_dest_realized (widget); - - g_signal_connect (widget, "realize", G_CALLBACK (gtk_drag_dest_realized), dest); - g_signal_connect (widget, "notify::root", G_CALLBACK (gtk_drag_dest_hierarchy_changed), dest); -} - -static void -gtk_drop_target_unset_widget (GtkEventController *controller) -{ - GtkWidget *widget; - - widget = gtk_event_controller_get_widget (controller); - - g_signal_handlers_disconnect_by_func (widget, gtk_drag_dest_realized, controller); - g_signal_handlers_disconnect_by_func (widget, gtk_drag_dest_hierarchy_changed, controller); - - GTK_EVENT_CONTROLLER_CLASS (gtk_drop_target_parent_class)->unset_widget (controller); -} - -static void -gtk_drag_get_data_got_data (GObject *source, - GAsyncResult *result, - gpointer data) -{ - GTask *task = data; - gssize written; - GError *error = NULL; - guchar *bytes; - gsize size; - GtkSelectionData *sdata; - GtkDropTarget *dest; - GdkDrop *drop; - GdkDisplay *display; - - written = g_output_stream_splice_finish (G_OUTPUT_STREAM (source), result, &error); - if (written < 0) - { - g_task_return_error (task, error); - g_object_unref (task); - return; - } - - bytes = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (source)); - size = g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (source)); - - dest = GTK_DROP_TARGET (g_task_get_source_object (task)); - drop = GDK_DROP (g_object_get_data (G_OBJECT (task), "drop")); - display = GDK_DISPLAY (g_object_get_data (G_OBJECT (task), "display")); - - sdata = g_slice_new0 (GtkSelectionData); - sdata->target = g_task_get_task_data (task); - sdata->type = g_task_get_task_data (task); - sdata->format = 8; - sdata->length = size; - sdata->data = bytes ? bytes : (guchar *)g_strdup (""); - sdata->display = display; - - set_drop (dest, drop); - g_task_return_pointer (task, sdata, NULL); - set_drop (dest, NULL); - - g_object_unref (task); -} - -static void -gtk_drag_get_data_got_stream (GObject *source, - GAsyncResult *result, - gpointer data) -{ - GTask *task = data; - GInputStream *input_stream; - GOutputStream *output_stream; - GError *error = NULL; - const char *mime_type; - - input_stream = gdk_drop_read_finish (GDK_DROP (source), result, &mime_type, &error); - if (input_stream == NULL) - { - g_task_return_error (task, error); - g_object_unref (task); - return; - } - - g_task_set_task_data (task, (gpointer)g_intern_string (mime_type), NULL); - - output_stream = g_memory_output_stream_new_resizable (); - g_output_stream_splice_async (output_stream, - input_stream, - G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, - G_PRIORITY_DEFAULT, - NULL, - gtk_drag_get_data_got_data, - task); - g_object_unref (output_stream); - g_object_unref (input_stream); -} - -/** - * gtk_drop_target_read_selection: - * @dest: a #GtkDropTarget - * @target: the data format to read - * @cancellable: (nullable): a cancellable - * @callback: callback to call on completion - * @user_data: data to pass to @callback - * - * Asynchronously reads the dropped data from an ongoing - * drag on a #GtkDropTarget, and returns the data in a - * #GtkSelectionData object. - * - * This function is meant for cases where a #GtkSelectionData - * object is needed, such as when using the #GtkTreeModel DND - * support. In most other cases, the #GdkDrop async read - * APIs that return in input stream or #GValue are more - * convenient and should be preferred. - */ -void -gtk_drop_target_read_selection (GtkDropTarget *dest, - GdkAtom target, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GTask *task; - GtkWidget *widget; - - g_return_if_fail (GTK_IS_DROP_TARGET (dest)); - - task = g_task_new (dest, NULL, callback, user_data); - g_object_set_data_full (G_OBJECT (task), "drop", g_object_ref (dest->drop), g_object_unref); - - widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest)); - if (widget) - g_object_set_data (G_OBJECT (task), "display", gtk_widget_get_display (widget)); - - gdk_drop_read_async (dest->drop, - (const char *[2]) { target, NULL }, - G_PRIORITY_DEFAULT, - NULL, - gtk_drag_get_data_got_stream, - task); -} - -/** - * gtk_drop_target_read_selection_finish: - * @dest: a #GtkDropTarget - * @result: a #GAsyncResult - * @error: (allow-none): location to store error information on failure, or %NULL - * - * Finishes an async drop read operation, see gtk_drop_target_read_selection(). - * - * Returns: (nullable) (transfer full): the #GtkSelectionData, or %NULL - */ -GtkSelectionData * -gtk_drop_target_read_selection_finish (GtkDropTarget *dest, - GAsyncResult *result, - GError **error) -{ - g_return_val_if_fail (GTK_IS_DROP_TARGET (dest), NULL); - - return g_task_propagate_pointer (G_TASK (result), error); -} - static GtkDropStatus gtk_drop_target_get_drop_status (GtkDropTarget *dest, GdkDrop *drop) diff --git a/gtk/gtkdragdest.h b/gtk/gtkdragdest.h index ceb2963c1d..6ebec76107 100644 --- a/gtk/gtkdragdest.h +++ b/gtk/gtkdragdest.h @@ -31,7 +31,6 @@ #error "Only <gtk/gtk.h> can be included directly." #endif -#include <gtk/gtkselection.h> #include <gtk/gtkwidget.h> @@ -75,18 +74,6 @@ GDK_AVAILABLE_IN_ALL const char *gtk_drop_target_find_mimetype (GtkDropTarget *dest); GDK_AVAILABLE_IN_ALL -void gtk_drop_target_read_selection (GtkDropTarget *dest, - GdkAtom target, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -GDK_AVAILABLE_IN_ALL -GtkSelectionData *gtk_drop_target_read_selection_finish - (GtkDropTarget *dest, - GAsyncResult *result, - GError **error); - -GDK_AVAILABLE_IN_ALL void gtk_drop_target_deny_drop (GtkDropTarget *dest, GdkDrop *drop); diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 265f5de88d..532ae64e3a 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -1854,35 +1854,28 @@ error_selecting_dragged_file_dialog (GtkFileChooserWidget *impl, } static void -file_list_drag_data_select_uris (GtkFileChooserWidget *impl, - gchar **uris) +file_list_drag_data_select_files (GtkFileChooserWidget *impl, + GSList *files) { - int i; - char *uri; GtkFileChooser *chooser = GTK_FILE_CHOOSER (impl); + GSList *l; - for (i = 1; uris[i]; i++) + for (l = files; l; l = l->next) { - GFile *file; + GFile *file = l->data; GError *error = NULL; - uri = uris[i]; - file = g_file_new_for_uri (uri); - gtk_file_chooser_widget_select_file (chooser, file, &error); if (error) error_selecting_dragged_file_dialog (impl, file, error); - - g_object_unref (file); } } -struct FileListDragData +typedef struct { GtkFileChooserWidget *impl; - gchar **uris; - GFile *file; -}; + GSList *files; +} FileListDragData; static void file_list_drag_data_received_get_info_cb (GCancellable *cancellable, @@ -1891,7 +1884,7 @@ file_list_drag_data_received_get_info_cb (GCancellable *cancellable, gpointer user_data) { gboolean cancelled = g_cancellable_is_cancelled (cancellable); - struct FileListDragData *data = user_data; + FileListDragData *data = user_data; GtkFileChooser *chooser = GTK_FILE_CHOOSER (data->impl); GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (data->impl); @@ -1905,27 +1898,26 @@ file_list_drag_data_received_get_info_cb (GCancellable *cancellable, if ((priv->action == GTK_FILE_CHOOSER_ACTION_OPEN || priv->action == GTK_FILE_CHOOSER_ACTION_SAVE) && - data->uris[1] == 0 && !error && _gtk_file_info_consider_as_directory (info)) - change_folder_and_display_error (data->impl, data->file, FALSE); + data->files->next == NULL && !error && _gtk_file_info_consider_as_directory (info)) + change_folder_and_display_error (data->impl, data->files->data, FALSE); else { GError *local_error = NULL; gtk_file_chooser_widget_unselect_all (chooser); - gtk_file_chooser_widget_select_file (chooser, data->file, &local_error); + gtk_file_chooser_widget_select_file (chooser, data->files->data, &local_error); if (local_error) - error_selecting_dragged_file_dialog (data->impl, data->file, local_error); + error_selecting_dragged_file_dialog (data->impl, data->files->data, local_error); else browse_files_center_selected_row (data->impl); } if (priv->select_multiple) - file_list_drag_data_select_uris (data->impl, data->uris); + file_list_drag_data_select_files (data->impl, data->files->next); out: g_object_unref (data->impl); - g_strfreev (data->uris); - g_object_unref (data->file); + g_slist_free_full (data->files, g_object_unref); g_free (data); g_object_unref (cancellable); @@ -1938,44 +1930,34 @@ file_list_drag_data_received_cb (GObject *source, { GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (user_data); GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl); - GtkDropTarget *dest = GTK_DROP_TARGET (source); - GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest)); - GdkDrop *drop = gtk_drop_target_get_drop (dest); - GdkDrag *drag = gdk_drop_get_drag (drop); - gchar **uris; - char *uri; - GFile *file; - GtkSelectionData *selection_data; - - selection_data = gtk_drop_target_read_selection_finish (dest, result, NULL); - - /* Allow only drags from other widgets; see bug #533891. */ - if (drag && gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (drag)) == widget) - return; + GdkDrop *drop = GDK_DROP (source); + GSList *files; + const GValue *value; + FileListDragData *data; - /* Parse the text/uri-list string, navigate to the first one */ - uris = gtk_selection_data_get_uris (selection_data); - if (uris && uris[0]) + value = gdk_drop_read_value_finish (drop, result, NULL); + if (value == NULL) { - struct FileListDragData *data; + gdk_drop_finish (drop, 0); + return; + } - uri = uris[0]; - file = g_file_new_for_uri (uri); + files = g_value_get_boxed (value); - data = g_new0 (struct FileListDragData, 1); - data->impl = g_object_ref (impl); - data->uris = uris; - data->file = file; + data = g_new0 (FileListDragData, 1); + data->impl = g_object_ref (impl); + data->files = g_slist_copy_deep (files, (GCopyFunc) g_object_ref, NULL); - if (priv->file_list_drag_data_received_cancellable) - g_cancellable_cancel (priv->file_list_drag_data_received_cancellable); + if (priv->file_list_drag_data_received_cancellable) + g_cancellable_cancel (priv->file_list_drag_data_received_cancellable); - priv->file_list_drag_data_received_cancellable = - _gtk_file_system_get_info (priv->file_system, file, - "standard::type", - file_list_drag_data_received_get_info_cb, + priv->file_list_drag_data_received_cancellable = + _gtk_file_system_get_info (priv->file_system, data->files->data, + "standard::type", + file_list_drag_data_received_get_info_cb, data); - } + + gdk_drop_finish (drop, gdk_drop_get_actions (drop)); } /* Don't do anything with the drag_drop signal */ @@ -1986,9 +1968,7 @@ file_list_drag_drop_cb (GtkDropTarget *dest, int y, GtkFileChooserWidget *impl) { - const char *target = g_intern_static_string ("text/uri-list"); - - gtk_drop_target_read_selection (dest, target, NULL, file_list_drag_data_received_cb, impl); + gdk_drop_read_value_async (drop, GDK_TYPE_FILE_LIST, G_PRIORITY_DEFAULT, NULL, file_list_drag_data_received_cb, impl); return TRUE; } diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 4ed5f5d3fd..4d89d6766e 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -54,7 +54,6 @@ #include "gtkwidgetprivate.h" #include "gtkdragsource.h" #include "gtkwidgetpaintable.h" -#include "gtkselectionprivate.h" #include "gtknative.h" #include "a11y/gtknotebookaccessible.h" diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 7961772854..eaf8fc8e2e 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -50,7 +50,6 @@ #include "gtklabel.h" #include "gtkbutton.h" #include "gtklistbox.h" -#include "gtkselection.h" #include "gtkdragdest.h" #include "gtkseparator.h" #include "gtkentry.h" @@ -65,7 +64,6 @@ #include "gtkdragsource.h" #include "gtkdragicon.h" #include "gtkwidgetpaintable.h" -#include "gtkselectionprivate.h" #include "gtkstylecontext.h" /*< private > diff --git a/gtk/gtkquartz.c b/gtk/gtkquartz.c index 301b3f94d2..dfe3cc1ab7 100644 --- a/gtk/gtkquartz.c +++ b/gtk/gtkquartz.c @@ -19,7 +19,6 @@ #include "config.h" #include "gtkquartz.h" -#include "gtkselectionprivate.h" #include <gdk/quartz/gdkquartz.h> diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c deleted file mode 100644 index e5b520eba2..0000000000 --- a/gtk/gtkselection.c +++ /dev/null @@ -1,1204 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - -/* This file implements most of the work of the ICCCM selection protocol. - * The code was written after an intensive study of the equivalent part - * of John Ousterhout’s Tk toolkit, and does many things in much the - * same way. - * - * The one thing in the ICCCM that isn’t fully supported here (or in Tk) - * is side effects targets. For these to be handled properly, MULTIPLE - * targets need to be done in the order specified. This cannot be - * guaranteed with the way we do things, since if we are doing INCR - * transfers, the order will depend on the timing of the requestor. - * - * By Owen Taylor <owt1@cornell.edu> 8/16/97 - */ - -/* Terminology note: when not otherwise specified, the term "incr" below - * refers to the _sending_ part of the INCR protocol. The receiving - * portion is referred to just as “retrieval”. (Terminology borrowed - * from Tk, because there is no good opposite to “retrieval” in English. - * “send” can’t be made into a noun gracefully and we’re already using - * “emission” for something else ....) - */ - -/* The MOTIF entry widget seems to ask for the TARGETS target, then - (regardless of the reply) ask for the TEXT target. It's slightly - possible though that it somehow thinks we are responding negatively - to the TARGETS request, though I don't really think so ... */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -/** - * SECTION:gtkselection - * @Title: Selections - * @Short_description: Functions for handling inter-process communication - * via selections - * @See_also: #GtkWidget - Much of the operation of selections happens via - * signals for #GtkWidget. In particular, if you are using the functions - * in this section, you may need to pay attention to - * #GtkWidget::selection-get, #GtkWidget::selection-received and - * #GtkWidget::selection-clear-event signals - * - * The selection mechanism provides the basis for different types - * of communication between processes. In particular, drag and drop and - * #GtkClipboard work via selections. You will very seldom or - * never need to use most of the functions in this section directly; - * #GtkClipboard provides a nicer interface to the same functionality. - * - * Some of the datatypes defined this section are used in - * the #GtkClipboard and drag-and-drop API’s as well. The - * #GdkContentFormats object represents - * lists of data types that are supported when sending or - * receiving data. The #GtkSelectionData object is used to - * store a chunk of data along with the data type and other - * associated information. - */ - -#include "config.h" - -#include "gtkselection.h" -#include "gtkselectionprivate.h" - -#include <stdarg.h> -#include <string.h> -#include "gdk.h" - -#include "gtkmain.h" -#include "gtkdebug.h" -#include "gtkintl.h" -#include "gdk-pixbuf/gdk-pixbuf.h" - -#include "gdk/gdkcontentformatsprivate.h" -#include "gdk/gdktextureprivate.h" - -#ifdef GDK_WINDOWING_X11 -#include "x11/gdkx.h" -#endif - -#ifdef GDK_WINDOWING_WIN32 -#include "win32/gdkwin32.h" -#endif - -#ifdef GDK_WINDOWING_WAYLAND -#include <gdk/wayland/gdkwayland.h> -#endif - -/**************** - * Target Lists * - ****************/ - -/* - * Target lists - */ - - -static GdkAtom utf8_atom; -static GdkAtom text_atom; -static GdkAtom ctext_atom; -static GdkAtom text_plain_atom; -static GdkAtom text_plain_utf8_atom; -static GdkAtom text_plain_locale_atom; -static GdkAtom text_uri_list_atom; - -static void -init_atoms (void) -{ - gchar *tmp; - const gchar *charset; - - if (!utf8_atom) - { - utf8_atom = g_intern_static_string ("UTF8_STRING"); - text_atom = g_intern_static_string ("TEXT"); - ctext_atom = g_intern_static_string ("COMPOUND_TEXT"); - text_plain_atom = g_intern_static_string ("text/plain"); - text_plain_utf8_atom = g_intern_static_string ("text/plain;charset=utf-8"); - g_get_charset (&charset); - tmp = g_strdup_printf ("text/plain;charset=%s", charset); - text_plain_locale_atom = g_intern_string (tmp); - g_free (tmp); - - text_uri_list_atom = g_intern_static_string ("text/uri-list"); - } -} - -/** - * gtk_selection_data_get_target: - * @selection_data: a pointer to a #GtkSelectionData-struct. - * - * Retrieves the target of the selection. - * - * Returns: (transfer none): the target of the selection. - **/ -GdkAtom -gtk_selection_data_get_target (const GtkSelectionData *selection_data) -{ - g_return_val_if_fail (selection_data != NULL, 0); - - return selection_data->target; -} - -/** - * gtk_selection_data_get_data_type: - * @selection_data: a pointer to a #GtkSelectionData-struct. - * - * Retrieves the data type of the selection. - * - * Returns: (transfer none): the data type of the selection. - **/ -GdkAtom -gtk_selection_data_get_data_type (const GtkSelectionData *selection_data) -{ - g_return_val_if_fail (selection_data != NULL, 0); - - return selection_data->type; -} - -/** - * gtk_selection_data_get_format: - * @selection_data: a pointer to a #GtkSelectionData-struct. - * - * Retrieves the format of the selection. - * - * Returns: the format of the selection. - **/ -gint -gtk_selection_data_get_format (const GtkSelectionData *selection_data) -{ - g_return_val_if_fail (selection_data != NULL, 0); - - return selection_data->format; -} - -/** - * gtk_selection_data_get_data: (skip) - * @selection_data: a pointer to a - * #GtkSelectionData-struct. - * - * Retrieves the raw data of the selection. - * - * Returns: (array) (element-type guint8): the raw data of the selection. - **/ -const guchar* -gtk_selection_data_get_data (const GtkSelectionData *selection_data) -{ - g_return_val_if_fail (selection_data != NULL, NULL); - - return selection_data->data; -} - -/** - * gtk_selection_data_get_length: - * @selection_data: a pointer to a #GtkSelectionData-struct. - * - * Retrieves the length of the raw data of the selection. - * - * Returns: the length of the data of the selection. - */ -gint -gtk_selection_data_get_length (const GtkSelectionData *selection_data) -{ - g_return_val_if_fail (selection_data != NULL, -1); - - return selection_data->length; -} - -/** - * gtk_selection_data_get_data_with_length: (rename-to gtk_selection_data_get_data) - * @selection_data: a pointer to a #GtkSelectionData-struct. - * @length: (out): return location for length of the data segment - * - * Retrieves the raw data of the selection along with its length. - * - * Returns: (array length=length): the raw data of the selection - */ -const guchar* -gtk_selection_data_get_data_with_length (const GtkSelectionData *selection_data, - gint *length) -{ - g_return_val_if_fail (selection_data != NULL, NULL); - - *length = selection_data->length; - - return selection_data->data; -} - -/** - * gtk_selection_data_get_display: - * @selection_data: a pointer to a #GtkSelectionData-struct. - * - * Retrieves the display of the selection. - * - * Returns: (transfer none): the display of the selection. - **/ -GdkDisplay * -gtk_selection_data_get_display (const GtkSelectionData *selection_data) -{ - g_return_val_if_fail (selection_data != NULL, NULL); - - return selection_data->display; -} - -/** - * gtk_selection_data_set: - * @selection_data: a pointer to a #GtkSelectionData-struct. - * @type: the type of selection data - * @format: format (number of bits in a unit) - * @data: (array length=length): pointer to the data (will be copied) - * @length: length of the data - * - * Stores new data into a #GtkSelectionData object. Should - * only be called from a selection handler callback. - * Zero-terminates the stored data. - **/ -void -gtk_selection_data_set (GtkSelectionData *selection_data, - GdkAtom type, - gint format, - const guchar *data, - gint length) -{ - g_return_if_fail (selection_data != NULL); - - g_free (selection_data->data); - - selection_data->type = type; - selection_data->format = format; - - if (data) - { - selection_data->data = g_new (guchar, length+1); - memcpy (selection_data->data, data, length); - selection_data->data[length] = 0; - } - else - { - g_return_if_fail (length <= 0); - - if (length < 0) - selection_data->data = NULL; - else - selection_data->data = (guchar *) g_strdup (""); - } - - selection_data->length = length; -} - -static gboolean -selection_set_string (GtkSelectionData *selection_data, - const gchar *str, - gint len) -{ - gchar *tmp = g_strndup (str, len); - gchar *latin1 = gdk_utf8_to_string_target (tmp); - g_free (tmp); - - if (latin1) - { - gtk_selection_data_set (selection_data, - g_intern_static_string ("STRING"), - 8, (guchar *) latin1, strlen (latin1)); - g_free (latin1); - - return TRUE; - } - else - return FALSE; -} - -static gboolean -selection_set_compound_text (GtkSelectionData *selection_data, - const gchar *str, - gint len) -{ - gboolean result = FALSE; - -#ifdef GDK_WINDOWING_X11 - gchar *tmp; - guchar *text; - GdkAtom encoding; - gint format; - gint new_length; - - if (GDK_IS_X11_DISPLAY (selection_data->display)) - { - tmp = g_strndup (str, len); - if (gdk_x11_display_utf8_to_compound_text (selection_data->display, tmp, - &encoding, &format, &text, &new_length)) - { - gtk_selection_data_set (selection_data, encoding, format, text, new_length); - gdk_x11_free_compound_text (text); - - result = TRUE; - } - g_free (tmp); - } -#endif - - return result; -} - -/* Normalize \r and \n into \r\n - */ -static gchar * -normalize_to_crlf (const gchar *str, - gint len) -{ - GString *result = g_string_sized_new (len); - const gchar *p = str; - const gchar *end = str + len; - - while (p < end) - { - if (*p == '\n') - g_string_append_c (result, '\r'); - - if (*p == '\r') - { - g_string_append_c (result, *p); - p++; - if (p == end || *p != '\n') - g_string_append_c (result, '\n'); - if (p == end) - break; - } - - g_string_append_c (result, *p); - p++; - } - - return g_string_free (result, FALSE); -} - -/* Normalize \r and \r\n into \n - */ -static gchar * -normalize_to_lf (gchar *str, - gint len) -{ - GString *result = g_string_sized_new (len); - const gchar *p = str; - - while (1) - { - if (*p == '\r') - { - p++; - if (*p != '\n') - g_string_append_c (result, '\n'); - } - - if (*p == '\0') - break; - - g_string_append_c (result, *p); - p++; - } - - return g_string_free (result, FALSE); -} - -static gboolean -selection_set_text_plain (GtkSelectionData *selection_data, - const gchar *str, - gint len) -{ - const gchar *charset = NULL; - gchar *result; - GError *error = NULL; - - result = normalize_to_crlf (str, len); - if (selection_data->target == text_plain_atom) - charset = "ASCII"; - else if (selection_data->target == text_plain_locale_atom) - g_get_charset (&charset); - - if (charset) - { - gchar *tmp = result; - result = g_convert_with_fallback (tmp, -1, - charset, "UTF-8", - NULL, NULL, NULL, &error); - g_free (tmp); - } - - if (!result) - { - g_warning ("Error converting from %s to %s: %s", - "UTF-8", charset, error->message); - g_error_free (error); - - return FALSE; - } - - gtk_selection_data_set (selection_data, - selection_data->target, - 8, (guchar *) result, strlen (result)); - g_free (result); - - return TRUE; -} - -static guchar * -selection_get_text_plain (const GtkSelectionData *selection_data) -{ - const gchar *charset = NULL; - gchar *str, *result; - gsize len; - GError *error = NULL; - - str = g_strdup ((const gchar *) selection_data->data); - len = selection_data->length; - - if (selection_data->type == text_plain_atom) - charset = "ISO-8859-1"; - else if (selection_data->type == text_plain_locale_atom) - g_get_charset (&charset); - - if (charset) - { - gchar *tmp = str; - str = g_convert_with_fallback (tmp, len, - "UTF-8", charset, - NULL, NULL, &len, &error); - g_free (tmp); - - if (!str) - { - g_warning ("Error converting from %s to %s: %s", - charset, "UTF-8", error->message); - g_error_free (error); - - return NULL; - } - } - else if (!g_utf8_validate (str, -1, NULL)) - { - g_warning ("Error converting from %s to %s: %s", - "text/plain;charset=utf-8", "UTF-8", "invalid UTF-8"); - g_free (str); - - return NULL; - } - - result = normalize_to_lf (str, len); - g_free (str); - - return (guchar *) result; -} - -/** - * gtk_selection_data_set_text: - * @selection_data: a #GtkSelectionData - * @str: a UTF-8 string - * @len: the length of @str, or -1 if @str is nul-terminated. - * - * Sets the contents of the selection from a UTF-8 encoded string. - * The string is converted to the form determined by - * @selection_data->target. - * - * Returns: %TRUE if the selection was successfully set, - * otherwise %FALSE. - **/ -gboolean -gtk_selection_data_set_text (GtkSelectionData *selection_data, - const gchar *str, - gint len) -{ - g_return_val_if_fail (selection_data != NULL, FALSE); - - if (len < 0) - len = strlen (str); - - init_atoms (); - - if (selection_data->target == utf8_atom) - { - gtk_selection_data_set (selection_data, - utf8_atom, - 8, (guchar *)str, len); - return TRUE; - } - else if (selection_data->target == g_intern_static_string ("STRING")) - { - return selection_set_string (selection_data, str, len); - } - else if (selection_data->target == ctext_atom || - selection_data->target == text_atom) - { - if (selection_set_compound_text (selection_data, str, len)) - return TRUE; - else if (selection_data->target == text_atom) - return selection_set_string (selection_data, str, len); - } - else if (selection_data->target == text_plain_atom || - selection_data->target == text_plain_utf8_atom || - selection_data->target == text_plain_locale_atom) - { - return selection_set_text_plain (selection_data, str, len); - } - - return FALSE; -} - -/** - * gtk_selection_data_get_text: - * @selection_data: a #GtkSelectionData - * - * Gets the contents of the selection data as a UTF-8 string. - * - * Returns: (type utf8) (nullable) (transfer full): if the selection data contained a - * recognized text type and it could be converted to UTF-8, a newly - * allocated string containing the converted text, otherwise %NULL. - * If the result is non-%NULL it must be freed with g_free(). - **/ -guchar * -gtk_selection_data_get_text (const GtkSelectionData *selection_data) -{ - guchar *result = NULL; - - g_return_val_if_fail (selection_data != NULL, NULL); - - init_atoms (); - - if (selection_data->length >= 0 && - (selection_data->type == g_intern_static_string ("STRING") || - selection_data->type == ctext_atom || - selection_data->type == utf8_atom)) - { - gchar **list; - gint i; - gint count = gdk_text_property_to_utf8_list_for_display (selection_data->display, - selection_data->type, - selection_data->format, - selection_data->data, - selection_data->length, - &list); - if (count > 0) - result = (guchar *) list[0]; - - for (i = 1; i < count; i++) - g_free (list[i]); - g_free (list); - } - else if (selection_data->length >= 0 && - (selection_data->type == text_plain_atom || - selection_data->type == text_plain_utf8_atom || - selection_data->type == text_plain_locale_atom)) - { - result = selection_get_text_plain (selection_data); - } - - return result; -} - -/** - * gtk_selection_data_set_pixbuf: - * @selection_data: a #GtkSelectionData - * @pixbuf: a #GdkPixbuf - * - * Sets the contents of the selection from a #GdkPixbuf - * The pixbuf is converted to the form determined by - * @selection_data->target. - * - * Returns: %TRUE if the selection was successfully set, - * otherwise %FALSE. - **/ -gboolean -gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data, - GdkPixbuf *pixbuf) -{ - GSList *formats, *f; - gchar **mimes, **m; - GdkAtom atom; - gboolean result; - gchar *str, *type; - gsize len; - - g_return_val_if_fail (selection_data != NULL, FALSE); - g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE); - - formats = gdk_pixbuf_get_formats (); - - for (f = formats; f; f = f->next) - { - GdkPixbufFormat *fmt = f->data; - - mimes = gdk_pixbuf_format_get_mime_types (fmt); - for (m = mimes; *m; m++) - { - atom = g_intern_string (*m); - if (selection_data->target == atom) - { - str = NULL; - type = gdk_pixbuf_format_get_name (fmt); - result = gdk_pixbuf_save_to_buffer (pixbuf, &str, &len, - type, NULL, - ((strcmp (type, "png") == 0) ? - "compression" : NULL), "2", - NULL); - if (result) - gtk_selection_data_set (selection_data, - atom, 8, (guchar *)str, len); - g_free (type); - g_free (str); - g_strfreev (mimes); - g_slist_free (formats); - - return result; - } - } - - g_strfreev (mimes); - } - - g_slist_free (formats); - - return FALSE; -} - -static gboolean -gtk_selection_data_set_surface (GtkSelectionData *selection_data, - cairo_surface_t *surface) -{ - GdkPixbuf *pixbuf; - gboolean retval; - - pixbuf = gdk_pixbuf_get_from_surface (surface, - 0, 0, - cairo_image_surface_get_width (surface), - cairo_image_surface_get_height (surface)); - retval = gtk_selection_data_set_pixbuf (selection_data, pixbuf); - g_object_unref (pixbuf); - - return retval; -} - -/** - * gtk_selection_data_get_pixbuf: - * @selection_data: a #GtkSelectionData - * - * Gets the contents of the selection data as a #GdkPixbuf. - * - * Returns: (nullable) (transfer full): if the selection data - * contained a recognized image type and it could be converted to a - * #GdkPixbuf, a newly allocated pixbuf is returned, otherwise - * %NULL. If the result is non-%NULL it must be freed with - * g_object_unref(). - **/ -GdkPixbuf * -gtk_selection_data_get_pixbuf (const GtkSelectionData *selection_data) -{ - GdkPixbufLoader *loader; - GdkPixbuf *result = NULL; - - g_return_val_if_fail (selection_data != NULL, NULL); - - if (selection_data->length > 0) - { - loader = gdk_pixbuf_loader_new (); - - gdk_pixbuf_loader_write (loader, - selection_data->data, - selection_data->length, - NULL); - gdk_pixbuf_loader_close (loader, NULL); - result = gdk_pixbuf_loader_get_pixbuf (loader); - - if (result) - g_object_ref (result); - - g_object_unref (loader); - } - - return result; -} - -/** - * gtk_selection_data_set_texture: - * @selection_data: a #GtkSelectionData - * @texture: a #GdkTexture - * - * Sets the contents of the selection from a #GdkTexture. - * The surface is converted to the form determined by - * @selection_data->target. - * - * Returns: %TRUE if the selection was successfully set, - * otherwise %FALSE. - **/ -gboolean -gtk_selection_data_set_texture (GtkSelectionData *selection_data, - GdkTexture *texture) -{ - cairo_surface_t *surface; - gboolean retval; - - g_return_val_if_fail (selection_data != NULL, FALSE); - g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE); - - surface = gdk_texture_download_surface (texture); - retval = gtk_selection_data_set_surface (selection_data, surface); - cairo_surface_destroy (surface); - - return retval; -} - -/** - * gtk_selection_data_get_texture: - * @selection_data: a #GtkSelectionData - * - * Gets the contents of the selection data as a #GdkPixbuf. - * - * Returns: (nullable) (transfer full): if the selection data - * contained a recognized image type and it could be converted to a - * #GdkTexture, a newly allocated texture is returned, otherwise - * %NULL. If the result is non-%NULL it must be freed with - * g_object_unref(). - **/ -GdkTexture * -gtk_selection_data_get_texture (const GtkSelectionData *selection_data) -{ - GdkTexture *texture; - GdkPixbuf *pixbuf; - - g_return_val_if_fail (selection_data != NULL, NULL); - - pixbuf = gtk_selection_data_get_pixbuf (selection_data); - if (pixbuf == NULL) - return NULL; - - texture = gdk_texture_new_for_pixbuf (pixbuf); - g_object_unref (pixbuf); - - return texture; -} - -/** - * gtk_selection_data_set_uris: - * @selection_data: a #GtkSelectionData - * @uris: (array zero-terminated=1): a %NULL-terminated array of - * strings holding URIs - * - * Sets the contents of the selection from a list of URIs. - * The string is converted to the form determined by - * @selection_data->target. - * - * Returns: %TRUE if the selection was successfully set, - * otherwise %FALSE. - **/ -gboolean -gtk_selection_data_set_uris (GtkSelectionData *selection_data, - gchar **uris) -{ - g_return_val_if_fail (selection_data != NULL, FALSE); - g_return_val_if_fail (uris != NULL, FALSE); - - init_atoms (); - - if (selection_data->target == text_uri_list_atom) - { - GString *list; - gint i; - gchar *result; - gsize length; - - list = g_string_new (NULL); - for (i = 0; uris[i]; i++) - { - g_string_append (list, uris[i]); - g_string_append (list, "\r\n"); - } - - result = g_convert (list->str, list->len, - "ASCII", "UTF-8", - NULL, &length, NULL); - g_string_free (list, TRUE); - - if (result) - { - gtk_selection_data_set (selection_data, - text_uri_list_atom, - 8, (guchar *)result, length); - - g_free (result); - - return TRUE; - } - } - - return FALSE; -} - -/** - * gtk_selection_data_get_uris: - * @selection_data: a #GtkSelectionData - * - * Gets the contents of the selection data as array of URIs. - * - * Returns: (array zero-terminated=1) (element-type utf8) (transfer full): if - * the selection data contains a list of - * URIs, a newly allocated %NULL-terminated string array - * containing the URIs, otherwise %NULL. If the result is - * non-%NULL it must be freed with g_strfreev(). - **/ -gchar ** -gtk_selection_data_get_uris (const GtkSelectionData *selection_data) -{ - gchar **result = NULL; - - g_return_val_if_fail (selection_data != NULL, NULL); - - init_atoms (); - - if (selection_data->length >= 0 && - selection_data->type == text_uri_list_atom) - { - gchar **list; - gint count = gdk_text_property_to_utf8_list_for_display (selection_data->display, - utf8_atom, - selection_data->format, - selection_data->data, - selection_data->length, - &list); - if (count > 0) - result = g_uri_list_extract_uris (list[0]); - - g_strfreev (list); - } - - return result; -} - - -/** - * gtk_selection_data_get_targets: - * @selection_data: a #GtkSelectionData object - * @targets: (out) (array length=n_atoms) (transfer container): - * location to store an array of targets. The result stored - * here must be freed with g_free(). - * @n_atoms: location to store number of items in @targets. - * - * Gets the contents of @selection_data as an array of targets. - * This can be used to interpret the results of getting - * the standard TARGETS target that is always supplied for - * any selection. - * - * Returns: %TRUE if @selection_data contains a valid - * array of targets, otherwise %FALSE. - **/ -gboolean -gtk_selection_data_get_targets (const GtkSelectionData *selection_data, - GdkAtom **targets, - gint *n_atoms) -{ - g_return_val_if_fail (selection_data != NULL, FALSE); - - if (selection_data->length >= 0 && - selection_data->format == 32 && - selection_data->type == g_intern_static_string ("ATOM")) - { - if (targets) - *targets = g_memdup (selection_data->data, selection_data->length); - if (n_atoms) - *n_atoms = selection_data->length / sizeof (GdkAtom); - - return TRUE; - } - else - { - if (targets) - *targets = NULL; - if (n_atoms) - *n_atoms = -1; - - return FALSE; - } -} - -/** - * gtk_targets_include_text: - * @targets: (array length=n_targets): an array of #GdkAtoms - * @n_targets: the length of @targets - * - * Determines if any of the targets in @targets can be used to - * provide text. - * - * Returns: %TRUE if @targets include a suitable target for text, - * otherwise %FALSE. - **/ -gboolean -gtk_targets_include_text (GdkAtom *targets, - gint n_targets) -{ - gint i; - gboolean result = FALSE; - - g_return_val_if_fail (targets != NULL || n_targets == 0, FALSE); - - /* Keep in sync with gdk_content_formats_add_text_targets() - */ - - init_atoms (); - - for (i = 0; i < n_targets; i++) - { - if (targets[i] == utf8_atom || - targets[i] == text_atom || - targets[i] == g_intern_static_string ("STRING") || - targets[i] == ctext_atom || - targets[i] == text_plain_atom || - targets[i] == text_plain_utf8_atom || - targets[i] == text_plain_locale_atom) - { - result = TRUE; - break; - } - } - - return result; -} - -/** - * gtk_selection_data_targets_include_text: - * @selection_data: a #GtkSelectionData object - * - * Given a #GtkSelectionData object holding a list of targets, - * determines if any of the targets in @targets can be used to - * provide text. - * - * Returns: %TRUE if @selection_data holds a list of targets, - * and a suitable target for text is included, otherwise %FALSE. - **/ -gboolean -gtk_selection_data_targets_include_text (const GtkSelectionData *selection_data) -{ - GdkAtom *targets; - gint n_targets; - gboolean result = FALSE; - - g_return_val_if_fail (selection_data != NULL, FALSE); - - init_atoms (); - - if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets)) - { - result = gtk_targets_include_text (targets, n_targets); - g_free (targets); - } - - return result; -} - -/** - * gtk_targets_include_image: - * @targets: (array length=n_targets): an array of #GdkAtoms - * @n_targets: the length of @targets - * @writable: whether to accept only targets for which GTK+ knows - * how to convert a pixbuf into the format - * - * Determines if any of the targets in @targets can be used to - * provide a #GdkPixbuf. - * - * Returns: %TRUE if @targets include a suitable target for images, - * otherwise %FALSE. - **/ -gboolean -gtk_targets_include_image (GdkAtom *targets, - gint n_targets, - gboolean writable) -{ - GdkContentFormats *list; - gint i; - gboolean result = FALSE; - - g_return_val_if_fail (targets != NULL || n_targets == 0, FALSE); - - list = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE); - if (writable) - list = gdk_content_formats_union_serialize_mime_types (list); - else - list = gdk_content_formats_union_deserialize_mime_types (list); - for (i = 0; i < n_targets && !result; i++) - { - if (gdk_content_formats_contain_mime_type (list, targets[i])) - { - result = TRUE; - break; - } - } - gdk_content_formats_unref (list); - - return result; -} - -/** - * gtk_selection_data_targets_include_image: - * @selection_data: a #GtkSelectionData object - * @writable: whether to accept only targets for which GTK+ knows - * how to convert a pixbuf into the format - * - * Given a #GtkSelectionData object holding a list of targets, - * determines if any of the targets in @targets can be used to - * provide a #GdkPixbuf. - * - * Returns: %TRUE if @selection_data holds a list of targets, - * and a suitable target for images is included, otherwise %FALSE. - **/ -gboolean -gtk_selection_data_targets_include_image (const GtkSelectionData *selection_data, - gboolean writable) -{ - GdkAtom *targets; - gint n_targets; - gboolean result = FALSE; - - g_return_val_if_fail (selection_data != NULL, FALSE); - - init_atoms (); - - if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets)) - { - result = gtk_targets_include_image (targets, n_targets, writable); - g_free (targets); - } - - return result; -} - -/** - * gtk_targets_include_uri: - * @targets: (array length=n_targets): an array of #GdkAtoms - * @n_targets: the length of @targets - * - * Determines if any of the targets in @targets can be used to - * provide an uri list. - * - * Returns: %TRUE if @targets include a suitable target for uri lists, - * otherwise %FALSE. - **/ -gboolean -gtk_targets_include_uri (GdkAtom *targets, - gint n_targets) -{ - gint i; - gboolean result = FALSE; - - g_return_val_if_fail (targets != NULL || n_targets == 0, FALSE); - - /* Keep in sync with gdk_content_formats_add_uri_targets() - */ - - init_atoms (); - - for (i = 0; i < n_targets; i++) - { - if (targets[i] == text_uri_list_atom) - { - result = TRUE; - break; - } - } - - return result; -} - -/** - * gtk_selection_data_targets_include_uri: - * @selection_data: a #GtkSelectionData object - * - * Given a #GtkSelectionData object holding a list of targets, - * determines if any of the targets in @targets can be used to - * provide a list or URIs. - * - * Returns: %TRUE if @selection_data holds a list of targets, - * and a suitable target for URI lists is included, otherwise %FALSE. - **/ -gboolean -gtk_selection_data_targets_include_uri (const GtkSelectionData *selection_data) -{ - GdkAtom *targets; - gint n_targets; - gboolean result = FALSE; - - g_return_val_if_fail (selection_data != NULL, FALSE); - - init_atoms (); - - if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets)) - { - result = gtk_targets_include_uri (targets, n_targets); - g_free (targets); - } - - return result; -} - -/** - * gtk_selection_data_copy: - * @data: a pointer to a #GtkSelectionData-struct. - * - * Makes a copy of a #GtkSelectionData-struct and its data. - * - * Returns: a pointer to a copy of @data. - **/ -GtkSelectionData* -gtk_selection_data_copy (const GtkSelectionData *data) -{ - GtkSelectionData *new_data; - - g_return_val_if_fail (data != NULL, NULL); - - new_data = g_slice_new (GtkSelectionData); - *new_data = *data; - - if (data->data) - { - new_data->data = g_malloc (data->length + 1); - memcpy (new_data->data, data->data, data->length + 1); - } - - return new_data; -} - -/** - * gtk_selection_data_free: - * @data: a pointer to a #GtkSelectionData-struct. - * - * Frees a #GtkSelectionData-struct returned from - * gtk_selection_data_copy(). - **/ -void -gtk_selection_data_free (GtkSelectionData *data) -{ - g_return_if_fail (data != NULL); - - g_free (data->data); - - g_slice_free (GtkSelectionData, data); -} - -G_DEFINE_BOXED_TYPE (GtkSelectionData, gtk_selection_data, - gtk_selection_data_copy, - gtk_selection_data_free) - diff --git a/gtk/gtkselection.h b/gtk/gtkselection.h deleted file mode 100644 index 983a0b398d..0000000000 --- a/gtk/gtkselection.h +++ /dev/null @@ -1,118 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GTK_SELECTION_H__ -#define __GTK_SELECTION_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only <gtk/gtk.h> can be included directly." -#endif - -#include <gtk/gtkwidget.h> -#include <gtk/gtktextiter.h> - -G_BEGIN_DECLS - -#define GTK_TYPE_SELECTION_DATA (gtk_selection_data_get_type ()) - - -GDK_AVAILABLE_IN_ALL -GdkAtom gtk_selection_data_get_target (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -GdkAtom gtk_selection_data_get_data_type (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -gint gtk_selection_data_get_format (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -const guchar *gtk_selection_data_get_data (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -gint gtk_selection_data_get_length (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -const guchar *gtk_selection_data_get_data_with_length - (const GtkSelectionData *selection_data, - gint *length); - -GDK_AVAILABLE_IN_ALL -GdkDisplay *gtk_selection_data_get_display (const GtkSelectionData *selection_data); - -GDK_AVAILABLE_IN_ALL -void gtk_selection_data_set (GtkSelectionData *selection_data, - GdkAtom type, - gint format, - const guchar *data, - gint length); -GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_data_set_text (GtkSelectionData *selection_data, - const gchar *str, - gint len); -GDK_AVAILABLE_IN_ALL -guchar * gtk_selection_data_get_text (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data, - GdkPixbuf *pixbuf); -GDK_AVAILABLE_IN_ALL -GdkPixbuf *gtk_selection_data_get_pixbuf (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_data_set_texture (GtkSelectionData *selection_data, - GdkTexture *texture); -GDK_AVAILABLE_IN_ALL -GdkTexture *gtk_selection_data_get_texture (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data, - gchar **uris); -GDK_AVAILABLE_IN_ALL -gchar **gtk_selection_data_get_uris (const GtkSelectionData *selection_data); - -GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_data_get_targets (const GtkSelectionData *selection_data, - GdkAtom **targets, - gint *n_atoms); -GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_data_targets_include_text (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_data_targets_include_image (const GtkSelectionData *selection_data, - gboolean writable); -GDK_AVAILABLE_IN_ALL -gboolean gtk_selection_data_targets_include_uri (const GtkSelectionData *selection_data); -GDK_AVAILABLE_IN_ALL -gboolean gtk_targets_include_text (GdkAtom *targets, - gint n_targets); -GDK_AVAILABLE_IN_ALL -gboolean gtk_targets_include_image (GdkAtom *targets, - gint n_targets, - gboolean writable); -GDK_AVAILABLE_IN_ALL -gboolean gtk_targets_include_uri (GdkAtom *targets, - gint n_targets); - - -GDK_AVAILABLE_IN_ALL -GType gtk_selection_data_get_type (void) G_GNUC_CONST; -GDK_AVAILABLE_IN_ALL -GtkSelectionData *gtk_selection_data_copy (const GtkSelectionData *data); -GDK_AVAILABLE_IN_ALL -void gtk_selection_data_free (GtkSelectionData *data); - -G_END_DECLS - -#endif /* __GTK_SELECTION_H__ */ diff --git a/gtk/gtkselectionprivate.h b/gtk/gtkselectionprivate.h deleted file mode 100644 index f31b646685..0000000000 --- a/gtk/gtkselectionprivate.h +++ /dev/null @@ -1,51 +0,0 @@ -/* GTK - The GIMP Toolkit - * - * Copyright (C) 2010 Javier Jardón - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - - -/* The contents of a selection are returned in a GtkSelectionData - * structure. selection/target identify the request. type specifies - * the type of the return; if length < 0, and the data should be - * ignored. This structure has object semantics - no fields should be - * modified directly, they should not be created directly, and - * pointers to them should not be stored beyond the duration of a - * callback. (If the last is changed, we’ll need to add reference - * counting.) The time field gives the timestamp at which the data was - * sent. - */ - -#ifndef __GTK_SELECTION_PRIVATE_H__ -#define __GTK_SELECTION_PRIVATE_H__ - -#include "gtkselection.h" - -G_BEGIN_DECLS - -struct _GtkSelectionData -{ - /*< private >*/ - GdkAtom target; - GdkAtom type; - gint format; - guchar *data; - gint length; - GdkDisplay *display; -}; - -G_END_DECLS - -#endif /* __GTK_SELECTION_PRIVATE_H__ */ diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index b1537eeea0..9790d91bcd 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -65,7 +65,6 @@ #include "gtkwindowgroup.h" #include "gtknative.h" #include "gtkpopover.h" -#include "gtkselectionprivate.h" #include "a11y/gtktreeviewaccessibleprivate.h" diff --git a/gtk/gtktypes.h b/gtk/gtktypes.h index 777a120746..a5ad190720 100644 --- a/gtk/gtktypes.h +++ b/gtk/gtktypes.h @@ -44,7 +44,6 @@ typedef struct _GtkLayoutManager GtkLayoutManager; typedef struct _GtkNative GtkNative; typedef struct _GtkRequisition GtkRequisition; typedef struct _GtkRoot GtkRoot; -typedef struct _GtkSelectionData GtkSelectionData; typedef struct _GtkSettings GtkSettings; typedef GdkSnapshot GtkSnapshot; typedef struct _GtkStyleContext GtkStyleContext; diff --git a/gtk/meson.build b/gtk/meson.build index 6851816f2c..ca72c02101 100644 --- a/gtk/meson.build +++ b/gtk/meson.build @@ -326,7 +326,6 @@ gtk_public_sources = files([ 'gtkscrolledwindow.c', 'gtksearchbar.c', 'gtksearchentry.c', - 'gtkselection.c', 'gtkselectionmodel.c', 'gtkseparator.c', 'gtksettings.c', @@ -562,7 +561,6 @@ gtk_public_headers = files([ 'gtkscrolledwindow.h', 'gtksearchbar.h', 'gtksearchentry.h', - 'gtkselection.h', 'gtkselectionmodel.h', 'gtkseparator.h', 'gtksettings.h', diff --git a/testsuite/gdk/encoding.c b/testsuite/gdk/encoding.c index 1e1a62dca6..0666e26218 100644 --- a/testsuite/gdk/encoding.c +++ b/testsuite/gdk/encoding.c @@ -13,7 +13,7 @@ test_to_text_list (void) if (GDK_IS_X11_DISPLAY (display)) { - GdkAtom encoding; + const char *encoding; gint format; const guchar *text; gint length; |