[gtk+] gdk: Get rid of magic special atoms
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdk: Get rid of magic special atoms
- Date: Wed, 15 Nov 2017 18:22:13 +0000 (UTC)
commit a385a50260be7e55731525fd89c39a7df3e69f86
Author: Benjamin Otte <otte redhat com>
Date: Wed Nov 15 04:42:10 2017 +0100
gdk: Get rid of magic special atoms
gdk/gdkproperty.c | 93 ++--------------------------------------------------
gdk/gdkselection.h | 32 +++++++++---------
gdk/gdktypes.h | 2 +-
3 files changed, 20 insertions(+), 107 deletions(-)
---
diff --git a/gdk/gdkproperty.c b/gdk/gdkproperty.c
index 9d34638..faa4664 100644
--- a/gdk/gdkproperty.c
+++ b/gdk/gdkproperty.c
@@ -59,104 +59,17 @@
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));
+ atoms_to_names = g_ptr_array_new ();
- 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]);
- }
+ g_hash_table_insert (names_to_atoms, (gpointer) "NONE", NULL);
+ g_ptr_array_add (atoms_to_names, (gpointer) "NONE");
}
static GdkAtom
diff --git a/gdk/gdkselection.h b/gdk/gdkselection.h
index 54858f5..a97c745 100644
--- a/gdk/gdkselection.h
+++ b/gdk/gdkselection.h
@@ -42,112 +42,112 @@ G_BEGIN_DECLS
*
* A #GdkAtom representing the `PRIMARY` selection.
*/
-#define GDK_SELECTION_PRIMARY _GDK_MAKE_ATOM (1)
+#define GDK_SELECTION_PRIMARY gdk_atom_intern_static_string ("PRIMARY")
/**
* GDK_SELECTION_SECONDARY:
*
* A #GdkAtom representing the `SECONDARY` selection.
*/
-#define GDK_SELECTION_SECONDARY _GDK_MAKE_ATOM (2)
+#define GDK_SELECTION_SECONDARY gdk_atom_intern_static_string ("SECONDARY")
/**
* GDK_SELECTION_CLIPBOARD:
*
* A #GdkAtom representing the `CLIPBOARD` selection.
*/
-#define GDK_SELECTION_CLIPBOARD _GDK_MAKE_ATOM (69)
+#define GDK_SELECTION_CLIPBOARD gdk_atom_intern_static_string ("CLIPBOARD")
/**
* GDK_TARGET_BITMAP:
*
* A #GdkAtom representing the `BITMAP` selection target.
*/
-#define GDK_TARGET_BITMAP _GDK_MAKE_ATOM (5)
+#define GDK_TARGET_BITMAP gdk_atom_intern_static_string ("BITMAP")
/**
* GDK_TARGET_COLORMAP:
*
* A #GdkAtom representing the `COLORMAP` selection target.
*/
-#define GDK_TARGET_COLORMAP _GDK_MAKE_ATOM (7)
+#define GDK_TARGET_COLORMAP gdk_atom_intern_static_string ("COLORMAP")
/**
* GDK_TARGET_DRAWABLE:
*
* A #GdkAtom representing the `DRAWABLE` selection target.
*/
-#define GDK_TARGET_DRAWABLE _GDK_MAKE_ATOM (17)
+#define GDK_TARGET_DRAWABLE gdk_atom_intern_static_string ("DRAWABLE")
/**
* GDK_TARGET_PIXMAP:
*
* A #GdkAtom representing the `PIXMAP` selection target.
*/
-#define GDK_TARGET_PIXMAP _GDK_MAKE_ATOM (20)
+#define GDK_TARGET_PIXMAP gdk_atom_intern_static_string ("PIXMAP")
/**
* GDK_TARGET_STRING:
*
* A #GdkAtom representing the `STRING` selection target.
*/
-#define GDK_TARGET_STRING _GDK_MAKE_ATOM (31)
+#define GDK_TARGET_STRING gdk_atom_intern_static_string ("STRING")
/**
* GDK_SELECTION_TYPE_ATOM:
*
* A #GdkAtom representing the `ATOM` selection type.
*/
-#define GDK_SELECTION_TYPE_ATOM _GDK_MAKE_ATOM (4)
+#define GDK_SELECTION_TYPE_ATOM gdk_atom_intern_static_string ("ATOM")
/**
* GDK_SELECTION_TYPE_BITMAP:
*
* A #GdkAtom representing the `BITMAP` selection type.
*/
-#define GDK_SELECTION_TYPE_BITMAP _GDK_MAKE_ATOM (5)
+#define GDK_SELECTION_TYPE_BITMAP gdk_atom_intern_static_string ("BITMAP")
/**
* GDK_SELECTION_TYPE_COLORMAP:
*
* A #GdkAtom representing the `COLORMAP` selection type.
*/
-#define GDK_SELECTION_TYPE_COLORMAP _GDK_MAKE_ATOM (7)
+#define GDK_SELECTION_TYPE_COLORMAP gdk_atom_intern_static_string ("COLORMAP")
/**
* GDK_SELECTION_TYPE_DRAWABLE:
*
* A #GdkAtom representing the `DRAWABLE` selection type.
*/
-#define GDK_SELECTION_TYPE_DRAWABLE _GDK_MAKE_ATOM (17)
+#define GDK_SELECTION_TYPE_DRAWABLE gdk_atom_intern_static_string ("DRAWABLE")
/**
* GDK_SELECTION_TYPE_INTEGER:
*
* A #GdkAtom representing the `INTEGER` selection type.
*/
-#define GDK_SELECTION_TYPE_INTEGER _GDK_MAKE_ATOM (19)
+#define GDK_SELECTION_TYPE_INTEGER gdk_atom_intern_static_string ("INTEGER")
/**
* GDK_SELECTION_TYPE_PIXMAP:
*
* A #GdkAtom representing the `PIXMAP` selection type.
*/
-#define GDK_SELECTION_TYPE_PIXMAP _GDK_MAKE_ATOM (20)
+#define GDK_SELECTION_TYPE_PIXMAP gdk_atom_intern_static_string ("PIXMAP")
/**
* GDK_SELECTION_TYPE_WINDOW:
*
* A #GdkAtom representing the `WINDOW` selection type.
*/
-#define GDK_SELECTION_TYPE_WINDOW _GDK_MAKE_ATOM (33)
+#define GDK_SELECTION_TYPE_WINDOW gdk_atom_intern_static_string ("WINDOW")
/**
* GDK_SELECTION_TYPE_STRING:
*
* A #GdkAtom representing the `STRING` selection type.
*/
-#define GDK_SELECTION_TYPE_STRING _GDK_MAKE_ATOM (31)
+#define GDK_SELECTION_TYPE_STRING gdk_atom_intern_static_string ("STRING")
/* Selections
*/
diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h
index ad6248d..0fae1ca 100644
--- a/gdk/gdktypes.h
+++ b/gdk/gdktypes.h
@@ -126,7 +126,7 @@ typedef struct _GdkAtom *GdkAtom;
* A null value for #GdkAtom, used in a similar way as
* `None` in the Xlib API.
*/
-#define GDK_NONE _GDK_MAKE_ATOM (0)
+#define GDK_NONE ((GdkAtom) 0)
/* Forward declarations of commonly used types */
typedef struct _GdkRGBA GdkRGBA;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]