1 /* gdkproperty-quartz.c
3 * Copyright (C) 2005 Imendio AB
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
23 #include "gdkproperty.h"
25 static GHashTable *names_to_atoms;
26 static GPtrArray *atoms_to_names;
28 static const gchar xatoms_string[] =
29 /* These are all the standard predefined X atoms */
81 "UNDERLINE_POSITION\0"
82 "UNDERLINE_THICKNESS\0"
99 /* Below here, these are our additions. Increment N_CUSTOM_PREDEFINED
102 "CLIPBOARD\0" /* = 69 */;
104 static const gint xatoms_offset[] = {
105 0, 5, 13, 23, 27, 32, 39, 48, 57, 64, 76, 88,
106 100, 112, 124, 136, 148, 160, 169, 174, 182, 189, 195, 205,
107 222, 236, 249, 262, 278, 291, 305, 317, 324, 333, 340, 351,
108 360, 378, 391, 404, 412, 428, 442, 456, 466, 477, 487, 497,
109 511, 525, 537, 549, 568, 588, 605, 623, 636, 645, 656, 663,
110 674, 685, 695, 702, 712, 724, 734, 745, 754, 771
113 #define N_CUSTOM_PREDEFINED 1
116 ensure_atom_tables (void)
123 names_to_atoms = g_hash_table_new (g_str_hash, g_str_equal);
124 atoms_to_names = g_ptr_array_sized_new (G_N_ELEMENTS (xatoms_offset));
126 for (i = 0; i < G_N_ELEMENTS (xatoms_offset); i++)
128 g_hash_table_insert(names_to_atoms, (gchar *)xatoms_string + xatoms_offset[i], GINT_TO_POINTER (i));
129 g_ptr_array_add(atoms_to_names, (gchar *)xatoms_string + xatoms_offset[i]);
134 intern_atom_internal (const gchar *atom_name, gboolean allocate)
138 g_return_val_if_fail (atom_name != NULL, GDK_NONE);
140 ensure_atom_tables ();
142 if (g_hash_table_lookup_extended (names_to_atoms, atom_name, NULL, &result))
145 result = GINT_TO_POINTER (atoms_to_names->len);
146 name = allocate ? g_strdup (atom_name) : (gchar *)atom_name;
147 g_hash_table_insert(names_to_atoms, name, result);
148 g_ptr_array_add(atoms_to_names, name);
154 gdk_atom_intern (const gchar *atom_name,
155 gboolean only_if_exists)
157 return intern_atom_internal (atom_name, TRUE);
161 gdk_atom_intern_static_string (const gchar *atom_name)
163 return intern_atom_internal (atom_name, FALSE);
168 gdk_atom_name (GdkAtom atom)
170 ensure_atom_tables ();
172 if (GPOINTER_TO_INT (atom) >= atoms_to_names->len)
175 return g_strdup (g_ptr_array_index (atoms_to_names, GPOINTER_TO_INT (atom)));
179 gdk_property_delete (GdkWindow *window,
182 /* FIXME: Implement */
186 gdk_property_get (GdkWindow *window,
192 GdkAtom *actual_property_type,
193 gint *actual_format_type,
197 /* FIXME: Implement */
202 gdk_property_change (GdkWindow *window,
210 /* FIXME: Implement */