[gtk+] gdk: Make atoms handled generically
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdk: Make atoms handled generically
- Date: Mon, 15 Apr 2013 13:45:27 +0000 (UTC)
commit aa9e974c866e32c5573da3d364c72dd5e016d47a
Author: Benjamin Otte <otte redhat com>
Date: Mon Apr 15 15:40:55 2013 +0200
gdk: Make atoms handled generically
This is another step towards making GdkDisplayManager backend-agnostic.
Most of the backends profit from this as their atom implementations
where generic anyway - x11 needed that to allow multiple X displays and
broadway, quartz and wayland don't have the concept of displays.
The X11 backend still did things, so I only #if 0'd some code but did
not actually update anything.
gdk/Makefile.am | 1 +
gdk/broadway/gdkdisplaymanager-broadway.c | 2 -
gdk/broadway/gdkprivate-broadway.h | 9 --
gdk/broadway/gdkproperty-broadway.c | 28 ----
gdk/gdkdisplaymanager.c | 66 ---------
gdk/gdkdisplaymanagerprivate.h | 5 -
gdk/gdkprivate.h | 2 +
gdk/gdkproperty.c | 220 ++++++++++++++++++++++++++++++
gdk/wayland/gdkdisplaymanager-wayland.c | 88 ------------
gdk/win32/gdkdisplaymanager-win32.c | 2 +
gdk/x11/gdkdisplaymanager-x11.c | 2 -
gdk/x11/gdkproperty-x11.c | 78 +----------
12 files changed, 230 insertions(+), 273 deletions(-)
---
diff --git a/gdk/Makefile.am b/gdk/Makefile.am
index 2cd9353..a32c6b5 100644
--- a/gdk/Makefile.am
+++ b/gdk/Makefile.am
@@ -134,6 +134,7 @@ gdk_c_sources = \
gdkframeclockidle.c \
gdkpango.c \
gdkpixbuf-drawable.c \
+ gdkproperty.c \
gdkrectangle.c \
gdkrgba.c \
gdkscreen.c \
diff --git a/gdk/broadway/gdkdisplaymanager-broadway.c b/gdk/broadway/gdkdisplaymanager-broadway.c
index 468d4fc..0cefe07 100644
--- a/gdk/broadway/gdkdisplaymanager-broadway.c
+++ b/gdk/broadway/gdkdisplaymanager-broadway.c
@@ -127,8 +127,6 @@ gdk_broadway_display_manager_class_init (GdkBroadwayDisplayManagerClass *class)
object_class->finalize = gdk_broadway_display_manager_finalize;
manager_class->open_display = gdk_broadway_display_manager_open_display;
- manager_class->atom_intern = _gdk_broadway_display_manager_atom_intern;
- manager_class->get_atom_name = _gdk_broadway_display_manager_get_atom_name;
manager_class->lookup_keyval = gdk_broadway_display_manager_lookup_keyval;
manager_class->get_keyval_name = gdk_broadway_display_manager_get_keyval_name;
}
diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h
index b631e04..89997e3 100644
--- a/gdk/broadway/gdkprivate-broadway.h
+++ b/gdk/broadway/gdkprivate-broadway.h
@@ -42,15 +42,6 @@
void _gdk_broadway_resync_windows (void);
void _gdk_broadway_windowing_init (void);
-gchar * _gdk_broadway_display_manager_get_atom_name (GdkDisplayManager *manager,
- GdkAtom atom);
-GdkAtom _gdk_broadway_display_manager_atom_intern_static_string (GdkDisplayManager *manager,
- const gchar *atom_name);
-GdkAtom _gdk_broadway_display_manager_atom_intern (GdkDisplayManager *manager,
- const gchar *atom_name,
- gboolean only_if_exists);
-
-
void _gdk_broadway_window_register_dnd (GdkWindow *window);
GdkDragContext * _gdk_broadway_window_drag_begin (GdkWindow *window,
GdkDevice *device,
diff --git a/gdk/broadway/gdkproperty-broadway.c b/gdk/broadway/gdkproperty-broadway.c
index 3e8b62b..85bb8be 100644
--- a/gdk/broadway/gdkproperty-broadway.c
+++ b/gdk/broadway/gdkproperty-broadway.c
@@ -35,34 +35,6 @@
#include <string.h>
-GdkAtom
-_gdk_broadway_display_manager_atom_intern (GdkDisplayManager *manager,
- const gchar *atom_name,
- gboolean only_if_exists)
-{
- return _GDK_MAKE_ATOM (g_quark_from_string (atom_name));
-}
-
-GdkAtom
-_gdk_broadway_display_manager_atom_intern_static_string (GdkDisplayManager *manager,
- const gchar *atom_name)
-{
- return _GDK_MAKE_ATOM (g_quark_from_static_string (atom_name));
-}
-
-static const char *
-get_atom_name (GdkAtom atom)
-{
- return g_quark_to_string (GPOINTER_TO_UINT(atom));
-}
-
-gchar *
-_gdk_broadway_display_manager_get_atom_name (GdkDisplayManager *manager,
- GdkAtom atom)
-{
- return g_strdup (get_atom_name (atom));
-}
-
gboolean
_gdk_broadway_window_get_property (GdkWindow *window,
GdkAtom property,
diff --git a/gdk/gdkdisplaymanager.c b/gdk/gdkdisplaymanager.c
index 0442ae0..cfbd15e 100644
--- a/gdk/gdkdisplaymanager.c
+++ b/gdk/gdkdisplaymanager.c
@@ -524,72 +524,6 @@ gdk_display_manager_open_display (GdkDisplayManager *manager,
return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->open_display (manager, name);
}
-/**
- * gdk_atom_intern:
- * @atom_name: a string.
- * @only_if_exists: if %TRUE, GDK is allowed to not create a new atom, but
- * just return %GDK_NONE if the requested atom doesn't already
- * exists. Currently, the flag is ignored, since checking the
- * existance of an atom is as expensive as creating it.
- *
- * Finds or creates an atom corresponding to a given string.
- *
- * Returns: (transfer none): the atom corresponding to @atom_name.
- */
-GdkAtom
-gdk_atom_intern (const gchar *atom_name,
- gboolean only_if_exists)
-{
- GdkDisplayManager *manager = gdk_display_manager_get ();
-
- return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->atom_intern (manager, atom_name, TRUE);
-}
-
-/**
- * gdk_atom_intern_static_string:
- * @atom_name: a static string
- *
- * Finds or creates an atom corresponding to a given string.
- *
- * Note that this function is identical to gdk_atom_intern() except
- * that if a new #GdkAtom is created the string itself is used rather
- * than a copy. This saves memory, but can only be used if the string
- * will <emphasis>always</emphasis> exist. It can be used with statically
- * allocated strings in the main program, but not with statically
- * allocated memory in dynamically loaded modules, if you expect to
- * ever unload the module again (e.g. do not use this function in
- * GTK+ theme engines).
- *
- * Returns: (transfer none): the atom corresponding to @atom_name
- *
- * Since: 2.10
- */
-GdkAtom
-gdk_atom_intern_static_string (const gchar *atom_name)
-{
- GdkDisplayManager *manager = gdk_display_manager_get ();
-
- return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->atom_intern (manager, atom_name, FALSE);
-}
-
-/**
- * gdk_atom_name:
- * @atom: a #GdkAtom.
- *
- * Determines the string corresponding to an atom.
- *
- * Returns: a newly-allocated string containing the string
- * corresponding to @atom. When you are done with the
- * return value, you should free it using g_free().
- */
-gchar *
-gdk_atom_name (GdkAtom atom)
-{
- GdkDisplayManager *manager = gdk_display_manager_get ();
-
- return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->get_atom_name (manager, atom);
-}
-
void
_gdk_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display)
diff --git a/gdk/gdkdisplaymanagerprivate.h b/gdk/gdkdisplaymanagerprivate.h
index 4794b7e..a8885a3 100644
--- a/gdk/gdkdisplaymanagerprivate.h
+++ b/gdk/gdkdisplaymanagerprivate.h
@@ -45,11 +45,6 @@ struct _GdkDisplayManagerClass
const gchar *name);
/* FIXME the following should really be frontend-only, not vfuncs */
- GdkAtom (*atom_intern) (GdkDisplayManager *manager,
- const gchar *atom_name,
- gboolean copy_name);
- gchar * (*get_atom_name) (GdkDisplayManager *manager,
- GdkAtom atom);
guint (*lookup_keyval) (GdkDisplayManager *manager,
const gchar *name);
gchar * (*get_keyval_name) (GdkDisplayManager *manager,
diff --git a/gdk/gdkprivate.h b/gdk/gdkprivate.h
index 7cf006a..c2902b8 100644
--- a/gdk/gdkprivate.h
+++ b/gdk/gdkprivate.h
@@ -29,6 +29,8 @@
G_BEGIN_DECLS
+const char * _gdk_atom_name_const (GdkAtom atom);
+
void gdk_window_destroy_notify (GdkWindow *window);
void gdk_synthesize_window_state (GdkWindow *window,
diff --git a/gdk/gdkproperty.c b/gdk/gdkproperty.c
new file mode 100644
index 0000000..7ba0f83
--- /dev/null
+++ b/gdk/gdkproperty.c
@@ -0,0 +1,220 @@
+/* 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 "gdkprivate.h"
+
+static GHashTable *names_to_atoms;
+static GPtrArray *atoms_to_names;
+
+static const gchar xatoms_string[] =
+ /* These are all the standard predefined X atoms */
+ "NONE\0"
+ "PRIMARY\0"
+ "SECONDARY\0"
+ "ARC\0"
+ "ATOM\0"
+ "BITMAP\0"
+ "CARDINAL\0"
+ "COLORMAP\0"
+ "CURSOR\0"
+ "CUT_BUFFER0\0"
+ "CUT_BUFFER1\0"
+ "CUT_BUFFER2\0"
+ "CUT_BUFFER3\0"
+ "CUT_BUFFER4\0"
+ "CUT_BUFFER5\0"
+ "CUT_BUFFER6\0"
+ "CUT_BUFFER7\0"
+ "DRAWABLE\0"
+ "FONT\0"
+ "INTEGER\0"
+ "PIXMAP\0"
+ "POINT\0"
+ "RECTANGLE\0"
+ "RESOURCE_MANAGER\0"
+ "RGB_COLOR_MAP\0"
+ "RGB_BEST_MAP\0"
+ "RGB_BLUE_MAP\0"
+ "RGB_DEFAULT_MAP\0"
+ "RGB_GRAY_MAP\0"
+ "RGB_GREEN_MAP\0"
+ "RGB_RED_MAP\0"
+ "STRING\0"
+ "VISUALID\0"
+ "WINDOW\0"
+ "WM_COMMAND\0"
+ "WM_HINTS\0"
+ "WM_CLIENT_MACHINE\0"
+ "WM_ICON_NAME\0"
+ "WM_ICON_SIZE\0"
+ "WM_NAME\0"
+ "WM_NORMAL_HINTS\0"
+ "WM_SIZE_HINTS\0"
+ "WM_ZOOM_HINTS\0"
+ "MIN_SPACE\0"
+ "NORM_SPACE\0"
+ "MAX_SPACE\0"
+ "END_SPACE\0"
+ "SUPERSCRIPT_X\0"
+ "SUPERSCRIPT_Y\0"
+ "SUBSCRIPT_X\0"
+ "SUBSCRIPT_Y\0"
+ "UNDERLINE_POSITION\0"
+ "UNDERLINE_THICKNESS\0"
+ "STRIKEOUT_ASCENT\0"
+ "STRIKEOUT_DESCENT\0"
+ "ITALIC_ANGLE\0"
+ "X_HEIGHT\0"
+ "QUAD_WIDTH\0"
+ "WEIGHT\0"
+ "POINT_SIZE\0"
+ "RESOLUTION\0"
+ "COPYRIGHT\0"
+ "NOTICE\0"
+ "FONT_NAME\0"
+ "FAMILY_NAME\0"
+ "FULL_NAME\0"
+ "CAP_HEIGHT\0"
+ "WM_CLASS\0"
+ "WM_TRANSIENT_FOR\0"
+ "CLIPBOARD\0" /* = 69 */;
+
+static const gint xatoms_offset[] = {
+ 0, 5, 13, 23, 27, 32, 39, 48, 57, 64, 76, 88,
+ 100, 112, 124, 136, 148, 160, 169, 174, 182, 189, 195, 205,
+ 222, 236, 249, 262, 278, 291, 305, 317, 324, 333, 340, 351,
+ 360, 378, 391, 404, 412, 428, 442, 456, 466, 477, 487, 497,
+ 511, 525, 537, 549, 568, 588, 605, 623, 636, 645, 656, 663,
+ 674, 685, 695, 702, 712, 724, 734, 745, 754, 771
+};
+
+static void
+ensure_atom_tables (void)
+{
+ int i;
+
+ if (names_to_atoms)
+ return;
+
+ names_to_atoms = g_hash_table_new (g_str_hash, g_str_equal);
+ atoms_to_names = g_ptr_array_sized_new (G_N_ELEMENTS (xatoms_offset));
+
+ for (i = 0; i < G_N_ELEMENTS (xatoms_offset); i++)
+ {
+ g_hash_table_insert(names_to_atoms, (gchar *)xatoms_string + xatoms_offset[i], GINT_TO_POINTER (i));
+ g_ptr_array_add(atoms_to_names, (gchar *)xatoms_string + xatoms_offset[i]);
+ }
+}
+
+static GdkAtom
+intern_atom_internal (const gchar *atom_name, gboolean allocate)
+{
+ gpointer result;
+ gchar *name;
+
+ ensure_atom_tables ();
+
+ if (g_hash_table_lookup_extended (names_to_atoms, atom_name, NULL, &result))
+ return result;
+
+ result = GINT_TO_POINTER (atoms_to_names->len);
+ name = allocate ? g_strdup (atom_name) : (gchar *)atom_name;
+ g_hash_table_insert(names_to_atoms, name, result);
+ g_ptr_array_add(atoms_to_names, name);
+
+ return result;
+}
+
+/**
+ * gdk_atom_intern:
+ * @atom_name: a string.
+ * @only_if_exists: if %TRUE, GDK is allowed to not create a new atom, but
+ * just return %GDK_NONE if the requested atom doesn't already
+ * exists. Currently, the flag is ignored, since checking the
+ * existance of an atom is as expensive as creating it.
+ *
+ * Finds or creates an atom corresponding to a given string.
+ *
+ * Returns: (transfer none): the atom corresponding to @atom_name.
+ */
+GdkAtom
+gdk_atom_intern (const gchar *atom_name,
+ gboolean only_if_exists)
+{
+ g_return_val_if_fail (atom_name != NULL, GDK_NONE);
+
+ return intern_atom_internal (atom_name, TRUE);
+}
+
+/**
+ * gdk_atom_intern_static_string:
+ * @atom_name: a static string
+ *
+ * Finds or creates an atom corresponding to a given string.
+ *
+ * Note that this function is identical to gdk_atom_intern() except
+ * that if a new #GdkAtom is created the string itself is used rather
+ * than a copy. This saves memory, but can only be used if the string
+ * will <emphasis>always</emphasis> exist. It can be used with statically
+ * allocated strings in the main program, but not with statically
+ * allocated memory in dynamically loaded modules, if you expect to
+ * ever unload the module again (e.g. do not use this function in
+ * GTK+ theme engines).
+ *
+ * Returns: (transfer none): the atom corresponding to @atom_name
+ *
+ * Since: 2.10
+ */
+GdkAtom
+gdk_atom_intern_static_string (const gchar *atom_name)
+{
+ g_return_val_if_fail (atom_name != NULL, GDK_NONE);
+
+ return intern_atom_internal (atom_name, FALSE);
+}
+
+/**
+ * gdk_atom_name:
+ * @atom: a #GdkAtom.
+ *
+ * Determines the string corresponding to an atom.
+ *
+ * Returns: a newly-allocated string containing the string
+ * corresponding to @atom. When you are done with the
+ * return value, you should free it using g_free().
+ */
+gchar *
+gdk_atom_name (GdkAtom atom)
+{
+ return g_strdup (_gdk_atom_name_const (atom));
+}
+
+const gchar *
+_gdk_atom_name_const (GdkAtom atom)
+{
+ ensure_atom_tables ();
+
+ if (GPOINTER_TO_INT (atom) >= atoms_to_names->len)
+ return NULL;
+
+ return g_ptr_array_index (atoms_to_names, GPOINTER_TO_INT (atom));
+}
diff --git a/gdk/wayland/gdkdisplaymanager-wayland.c b/gdk/wayland/gdkdisplaymanager-wayland.c
index 17160fb..4b8ded5 100644
--- a/gdk/wayland/gdkdisplaymanager-wayland.c
+++ b/gdk/wayland/gdkdisplaymanager-wayland.c
@@ -35,9 +35,6 @@ struct _GdkWaylandDisplayManager
GSList *displays;
- GHashTable *name_to_atoms;
- guint next_atom;
-
gboolean init_failed;
};
@@ -100,54 +97,6 @@ gdk_wayland_display_manager_open_display (GdkDisplayManager *manager,
return _gdk_wayland_display_open (name);
}
-static GdkAtom
-gdk_wayland_display_manager_atom_intern (GdkDisplayManager *manager_in,
- const gchar *atom_name,
- gboolean dup)
-{
- GdkWaylandDisplayManager *manager = GDK_WAYLAND_DISPLAY_MANAGER (manager_in);
- GdkAtom atom;
- gpointer data;
- const gchar *atom_name_intern;
-
- atom_name_intern = g_intern_string (atom_name);
- data = g_hash_table_lookup (manager->name_to_atoms, atom_name_intern);
-
- if (data)
- {
- atom = GDK_POINTER_TO_ATOM (data);
- return atom;
- }
-
- atom = _GDK_MAKE_ATOM (manager->next_atom);
-
- g_hash_table_insert (manager->name_to_atoms,
- (gchar *)atom_name_intern,
- GDK_ATOM_TO_POINTER (atom));
- manager->next_atom++;
-
- return atom;
-}
-
-static gchar *
-gdk_wayland_display_manager_get_atom_name (GdkDisplayManager *manager_in,
- GdkAtom atom)
-{
- GdkWaylandDisplayManager *manager = GDK_WAYLAND_DISPLAY_MANAGER (manager_in);
- GHashTableIter iter;
- gpointer key, value;
-
- g_hash_table_iter_init (&iter, manager->name_to_atoms);
-
- while (g_hash_table_iter_next (&iter, &key, &value))
- {
- if (GDK_POINTER_TO_ATOM (value) == atom)
- return g_strdup (key);
- }
-
- return NULL;
-}
-
static guint
gdk_wayland_display_manager_lookup_keyval (GdkDisplayManager *manager,
const gchar *keyval_name)
@@ -191,50 +140,13 @@ gdk_wayland_display_manager_class_init (GdkWaylandDisplayManagerClass *class)
object_class->finalize = gdk_wayland_display_manager_finalize;
manager_class->open_display = gdk_wayland_display_manager_open_display;
- manager_class->atom_intern = gdk_wayland_display_manager_atom_intern;
- manager_class->get_atom_name = gdk_wayland_display_manager_get_atom_name;
manager_class->lookup_keyval = gdk_wayland_display_manager_lookup_keyval;
manager_class->get_keyval_name = gdk_wayland_display_manager_get_keyval_name;
}
-static struct {
- const gchar *name;
- guint atom_id;
-} predefined_atoms[] = {
- { "NONE", 0 },
- { "PRIMARY", 1 },
- { "SECONDARY", 2 },
- { "ATOM", 4 },
- { "BITMAP", 5 },
- { "COLORMAP", 7 },
- { "DRAWABLE", 17 },
- { "INTEGER", 19 },
- { "PIXMAP", 20 },
- { "STRING", 31 },
- { "WINDOW", 33 },
- { "CLIPBOARD", 69 },
-};
-
static void
gdk_wayland_display_manager_init (GdkWaylandDisplayManager *manager)
{
- gint i;
-
- manager->name_to_atoms = g_hash_table_new (NULL, NULL);
-
- for (i = 0; i < G_N_ELEMENTS (predefined_atoms); i++)
- {
- GdkAtom atom;
- const gchar *atom_name = predefined_atoms[i].name;
-
- atom = _GDK_MAKE_ATOM (predefined_atoms[i].atom_id);
- g_hash_table_insert (manager->name_to_atoms,
- (gchar *)g_intern_static_string (atom_name),
- GDK_ATOM_TO_POINTER (atom));
- }
-
- manager->next_atom =
- predefined_atoms[G_N_ELEMENTS (predefined_atoms) - 1].atom_id + 1;
}
void
diff --git a/gdk/win32/gdkdisplaymanager-win32.c b/gdk/win32/gdkdisplaymanager-win32.c
index a968f8e..127386b 100644
--- a/gdk/win32/gdkdisplaymanager-win32.c
+++ b/gdk/win32/gdkdisplaymanager-win32.c
@@ -90,8 +90,10 @@ gdk_win32_display_manager_class_init (GdkWin32DisplayManagerClass *class)
object_class->finalize = gdk_win32_display_manager_finalize;
manager_class->open_display = gdk_win32_display_manager_open_display;
+#if 0
manager_class->atom_intern = _gdk_win32_display_manager_atom_intern;
manager_class->get_atom_name = _gdk_win32_display_manager_get_atom_name;
+#endif
manager_class->lookup_keyval = gdk_win32_display_manager_lookup_keyval;
manager_class->get_keyval_name = gdk_win32_display_manager_get_keyval_name;
}
diff --git a/gdk/x11/gdkdisplaymanager-x11.c b/gdk/x11/gdkdisplaymanager-x11.c
index afe5e94..adf3d15 100644
--- a/gdk/x11/gdkdisplaymanager-x11.c
+++ b/gdk/x11/gdkdisplaymanager-x11.c
@@ -113,8 +113,6 @@ gdk_x11_display_manager_class_init (GdkX11DisplayManagerClass *class)
object_class->finalize = gdk_x11_display_manager_finalize;
manager_class->open_display = gdk_x11_display_manager_open_display;
- manager_class->atom_intern = _gdk_x11_display_manager_atom_intern;
- manager_class->get_atom_name = _gdk_x11_display_manager_get_atom_name;
manager_class->lookup_keyval = _gdk_x11_display_manager_lookup_keyval;
manager_class->get_keyval_name = _gdk_x11_display_manager_get_keyval_name;
manager_class->keyval_convert_case = _gdk_x11_display_manager_keyval_convert_case;
diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c
index 2318a2e..0e5a641 100644
--- a/gdk/x11/gdkproperty-x11.c
+++ b/gdk/x11/gdkproperty-x11.c
@@ -72,10 +72,6 @@
* data commonly stored in X window properties.
*/
-
-static GPtrArray *virtual_atom_array;
-static GHashTable *virtual_atom_hash;
-
static const gchar xatoms_string[] =
/* These are all the standard predefined X atoms */
"\0" /* leave a space for None, even though it is not a predefined atom */
@@ -235,14 +231,12 @@ gdk_x11_atom_to_xatom_for_display (GdkDisplay *display,
if (!xatom)
{
- char *name;
-
- g_return_val_if_fail (ATOM_TO_INDEX (atom) < virtual_atom_array->len, None);
-
- name = g_ptr_array_index (virtual_atom_array, ATOM_TO_INDEX (atom));
+ char *name = gdk_atom_name (atom);
xatom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), name, FALSE);
insert_atom_pair (display, atom, xatom);
+
+ g_free (name);
}
return xatom;
@@ -377,68 +371,6 @@ gdk_x11_xatom_to_atom (Atom xatom)
return gdk_x11_xatom_to_atom_for_display (gdk_display_get_default (), xatom);
}
-static void
-virtual_atom_check_init (void)
-{
- if (!virtual_atom_hash)
- {
- gint i;
-
- virtual_atom_hash = g_hash_table_new (g_str_hash, g_str_equal);
- virtual_atom_array = g_ptr_array_new ();
-
- for (i = 0; i < G_N_ELEMENTS (xatoms_offset); i++)
- {
- g_ptr_array_add (virtual_atom_array, (gchar *)(xatoms_string + xatoms_offset[i]));
- g_hash_table_insert (virtual_atom_hash, (gchar *)(xatoms_string + xatoms_offset[i]),
- GUINT_TO_POINTER (i));
- }
- }
-}
-
-GdkAtom
-_gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager,
- const gchar *atom_name,
- gboolean dup)
-{
- GdkAtom result;
-
- virtual_atom_check_init ();
-
- result = GDK_POINTER_TO_ATOM (g_hash_table_lookup (virtual_atom_hash, atom_name));
- if (!result)
- {
- result = INDEX_TO_ATOM (virtual_atom_array->len);
-
- g_ptr_array_add (virtual_atom_array, dup ? g_strdup (atom_name) : (gchar *)atom_name);
- g_hash_table_insert (virtual_atom_hash,
- g_ptr_array_index (virtual_atom_array,
- ATOM_TO_INDEX (result)),
- GDK_ATOM_TO_POINTER (result));
- }
-
- return result;
-}
-
-static const gchar *
-get_atom_name (GdkAtom atom)
-{
- virtual_atom_check_init ();
-
- if (ATOM_TO_INDEX (atom) < virtual_atom_array->len)
- return g_ptr_array_index (virtual_atom_array, ATOM_TO_INDEX (atom));
- else
- return NULL;
-}
-
-
-gchar *
-_gdk_x11_display_manager_get_atom_name (GdkDisplayManager *manager,
- GdkAtom atom)
-{
- return g_strdup (get_atom_name (atom));
-}
-
/**
* gdk_x11_get_xatom_by_name_for_display:
* @display: a #GdkDisplay
@@ -519,7 +451,7 @@ gdk_x11_get_xatom_name_for_display (GdkDisplay *display,
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
- return get_atom_name (gdk_x11_xatom_to_atom_for_display (display, xatom));
+ return _gdk_atom_name_const (gdk_x11_xatom_to_atom_for_display (display, xatom));
}
/**
@@ -538,7 +470,7 @@ gdk_x11_get_xatom_name_for_display (GdkDisplay *display,
const gchar *
gdk_x11_get_xatom_name (Atom xatom)
{
- return get_atom_name (gdk_x11_xatom_to_atom (xatom));
+ return _gdk_atom_name_const (gdk_x11_xatom_to_atom (xatom));
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]