[gtk/wip/otte/dnd: 27/30] x11: Get rid of GdkAtom and APIs supporting it.
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/dnd: 27/30] x11: Get rid of GdkAtom and APIs supporting it.
- Date: Sun, 23 Feb 2020 01:01:19 +0000 (UTC)
commit 6e935d469a9f93d2b86ddec44216f1685cea92e5
Author: Benjamin Otte <otte redhat com>
Date: Sun Feb 23 01:33:56 2020 +0100
x11: Get rid of GdkAtom and APIs supporting it.
replace all uses with const char * (non-interned).
Also remove a lot fo juggling from atom to GdkAtom to string and back.
The X Atom hash table is now mapping to (again, non-interned) strings.
docs/reference/gdk/gdk4-sections.txt | 2 -
gdk/x11/gdkdevicemanager-xi2.c | 6 +-
gdk/x11/gdkdisplay-x11.c | 20 ++---
gdk/x11/gdkdisplay-x11.h | 4 +-
gdk/x11/gdkdrag-x11.c | 12 +--
gdk/x11/gdkprivate-x11.h | 8 +-
gdk/x11/gdkproperty-x11.c | 152 +++++++++++++----------------------
gdk/x11/gdkscreen-x11.c | 11 +--
gdk/x11/gdkselection-x11.c | 30 +++----
gdk/x11/gdksurface-x11.c | 62 +++++++-------
gdk/x11/gdktextlistconverter-x11.c | 4 +-
gdk/x11/gdkx11property.h | 7 --
gdk/x11/gdkx11screen.h | 2 +-
gdk/x11/gdkx11selection.h | 10 +--
14 files changed, 131 insertions(+), 199 deletions(-)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index bff1aea44c..7a065041db 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -842,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/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 1502666081..be8ddb214a 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -605,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)
{
@@ -1417,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 ();
@@ -1663,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);
@@ -1961,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);
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index 853ca6a032..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;
diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c
index a6c70ef224..b946cb255f 100644
--- a/gdk/x11/gdkdrag-x11.c
+++ b/gdk/x11/gdkdrag-x11.c
@@ -1055,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;
@@ -1077,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);
@@ -1087,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]);
}
}
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 5bd6bb3e75..36cdea1d1c 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -120,7 +120,7 @@ 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,
@@ -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 63c6015393..b93b7fdbf4 100644
--- a/gdk/x11/gdkproperty-x11.c
+++ b/gdk/x11/gdkproperty-x11.c
@@ -35,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;
@@ -108,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++;
}
@@ -131,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);
@@ -168,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
@@ -186,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
@@ -235,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 7bb016aa86..544d0875dc 100644
--- a/gdk/x11/gdkselection-x11.c
+++ b/gdk/x11/gdkselection-x11.c
@@ -35,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
@@ -55,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,
@@ -74,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,
@@ -188,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);
}
@@ -273,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
@@ -287,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)
@@ -313,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)
@@ -328,7 +328,7 @@ gdk_x11_display_string_to_compound_text (GdkDisplay *display,
* 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
@@ -341,8 +341,8 @@ gdk_x11_display_string_to_compound_text (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)
@@ -377,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 f023e09473..4a5c52f19c 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -1626,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;
@@ -1634,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,
@@ -1683,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));
@@ -1697,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;
@@ -1897,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;
@@ -1915,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;
@@ -1936,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);
}
@@ -1962,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);
}
@@ -1988,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);
}
@@ -2242,12 +2238,12 @@ set_text_property (GdkDisplay *display,
}
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;
}
@@ -3091,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);
}
}
@@ -3106,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
@@ -3114,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);
}
}
@@ -3135,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 */
@@ -3176,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);
@@ -3199,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,
@@ -3215,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,
@@ -3323,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.
@@ -3361,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
@@ -3383,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
@@ -3407,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
diff --git a/gdk/x11/gdktextlistconverter-x11.c b/gdk/x11/gdktextlistconverter-x11.c
index 88c4a5310f..0e6999e7e4 100644
--- a/gdk/x11/gdktextlistconverter-x11.c
+++ b/gdk/x11/gdktextlistconverter-x11.c
@@ -222,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;
@@ -231,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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]