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, see <http://www.gnu.org/licenses/>.
21 #include "gdkproperty.h"
23 static GHashTable *names_to_atoms;
24 static GPtrArray *atoms_to_names;
26 static const gchar xatoms_string[] =
27 /* These are all the standard predefined X atoms */
79 "UNDERLINE_POSITION\0"
80 "UNDERLINE_THICKNESS\0"
97 /* Below here, these are our additions. Increment N_CUSTOM_PREDEFINED
100 "CLIPBOARD\0" /* = 69 */;
102 static const gint xatoms_offset[] = {
103 0, 5, 13, 23, 27, 32, 39, 48, 57, 64, 76, 88,
104 100, 112, 124, 136, 148, 160, 169, 174, 182, 189, 195, 205,
105 222, 236, 249, 262, 278, 291, 305, 317, 324, 333, 340, 351,
106 360, 378, 391, 404, 412, 428, 442, 456, 466, 477, 487, 497,
107 511, 525, 537, 549, 568, 588, 605, 623, 636, 645, 656, 663,
108 674, 685, 695, 702, 712, 724, 734, 745, 754, 771
111 #define N_CUSTOM_PREDEFINED 1
114 ensure_atom_tables (void)
121 names_to_atoms = g_hash_table_new (g_str_hash, g_str_equal);
122 atoms_to_names = g_ptr_array_sized_new (G_N_ELEMENTS (xatoms_offset));
124 for (i = 0; i < G_N_ELEMENTS (xatoms_offset); i++)
126 g_hash_table_insert(names_to_atoms, (gchar *)xatoms_string + xatoms_offset[i], GINT_TO_POINTER (i));
127 g_ptr_array_add(atoms_to_names, (gchar *)xatoms_string + xatoms_offset[i]);
132 intern_atom_internal (const gchar *atom_name, gboolean allocate)
136 g_return_val_if_fail (atom_name != NULL, GDK_NONE);
138 ensure_atom_tables ();
140 if (g_hash_table_lookup_extended (names_to_atoms, atom_name, NULL, &result))
143 result = GINT_TO_POINTER (atoms_to_names->len);
144 name = allocate ? g_strdup (atom_name) : (gchar *)atom_name;
145 g_hash_table_insert(names_to_atoms, name, result);
146 g_ptr_array_add(atoms_to_names, name);
152 _gdk_quartz_display_manager_atom_intern (GdkDisplayManager *manager,
153 const gchar *atom_name,
156 return intern_atom_internal (atom_name, copy_name);
160 _gdk_quartz_display_manager_get_atom_name (GdkDisplayManager *manager,
163 ensure_atom_tables ();
165 if (GPOINTER_TO_INT (atom) >= atoms_to_names->len)
168 return g_strdup (g_ptr_array_index (atoms_to_names, GPOINTER_TO_INT (atom)));
172 _gdk_quartz_window_delete_property (GdkWindow *window,
175 /* FIXME: Implement */
179 _gdk_quartz_window_get_property (GdkWindow *window,
185 GdkAtom *actual_property_type,
186 gint *actual_format_type,
190 /* FIXME: Implement */
195 _gdk_quartz_window_change_property (GdkWindow *window,
203 /* FIXME: Implement */