1
/* GDK - The GIMP Drawing Kit
2
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
21
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22
* file for a list of people on the GTK+ Team.
26
* GTK+ DirectFB backend
27
* Copyright (C) 2001-2002 convergence integrated media GmbH
28
* Copyright (C) 2002-2004 convergence GmbH
29
* Written by Denis Oliver Kropp <dok@convergence.de> and
30
* Sven Neumann <sven@convergence.de>
38
#include "gdkproperty.h"
40
#include "gdkdirectfb.h"
41
#include "gdkprivate-directfb.h"
43
#include "gdkinternals.h"
47
static GHashTable *names_to_atoms;
48
static GPtrArray *atoms_to_names;
50
static const gchar xatoms_string[] =
51
/* These are all the standard predefined X atoms */
103
"UNDERLINE_POSITION\0"
104
"UNDERLINE_THICKNESS\0"
106
"STRIKEOUT_DESCENT\0"
123
static const gint xatoms_offset[] = {
124
0, 5, 13, 23, 27, 32, 39, 48, 57, 64, 76, 88,
125
100, 112, 124, 136, 148, 160, 169, 174, 182, 189, 195, 205,
126
222, 236, 249, 262, 278, 291, 305, 317, 324, 333, 340, 351,
127
360, 378, 391, 404, 412, 428, 442, 456, 466, 477, 487, 497,
128
511, 525, 537, 549, 568, 588, 605, 623, 636, 645, 656, 663,
129
674, 685, 695, 702, 712, 724, 734, 745, 754
132
#define N_CUSTOM_PREDEFINED 1
135
ensure_atom_tables (void)
142
names_to_atoms = g_hash_table_new (g_str_hash, g_str_equal);
143
atoms_to_names = g_ptr_array_sized_new (G_N_ELEMENTS (xatoms_offset));
145
for (i = 0; i < G_N_ELEMENTS (xatoms_offset); i++)
147
g_hash_table_insert(names_to_atoms, (gchar *)xatoms_string + xatoms_offset[i], GINT_TO_POINTER (i));
148
g_ptr_array_add(atoms_to_names, (gchar *)xatoms_string + xatoms_offset[i]);
153
intern_atom_internal (const gchar *atom_name, gboolean allocate)
157
g_return_val_if_fail (atom_name != NULL, GDK_NONE);
159
ensure_atom_tables ();
161
if (g_hash_table_lookup_extended (names_to_atoms, atom_name, NULL, &result))
164
result = GINT_TO_POINTER (atoms_to_names->len);
165
name = allocate ? g_strdup (atom_name) : (gchar *)atom_name;
166
g_hash_table_insert(names_to_atoms, name, result);
167
g_ptr_array_add(atoms_to_names, name);
173
gdk_atom_intern (const gchar *atom_name,
174
gboolean only_if_exists)
176
return intern_atom_internal (atom_name, TRUE);
180
gdk_atom_intern_static_string (const gchar *atom_name)
182
return intern_atom_internal (atom_name, FALSE);
187
gdk_atom_name (GdkAtom atom)
192
if (GPOINTER_TO_INT (atom) >= atoms_to_names->len)
195
return g_ptr_array_index (atoms_to_names, GPOINTER_TO_INT (atom));
200
gdk_property_delete_2 (GdkWindow *window,
202
GdkWindowProperty *prop)
204
GdkWindowImplDirectFB *impl;
206
GdkWindow *event_window;
208
impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
210
g_hash_table_remove (impl->properties, GUINT_TO_POINTER (property));
213
event_window = gdk_directfb_other_event_window (window, GDK_PROPERTY_NOTIFY);
217
event = gdk_directfb_event_make (event_window, GDK_PROPERTY_NOTIFY);
218
event->property.atom = property;
219
event->property.state = GDK_PROPERTY_DELETE;
224
gdk_property_delete (GdkWindow *window,
227
GdkWindowImplDirectFB *impl;
228
GdkWindowProperty *prop;
230
g_return_if_fail (GDK_IS_WINDOW (window));
232
impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
234
if (!impl->properties)
237
prop = g_hash_table_lookup (impl->properties, GUINT_TO_POINTER (property));
241
gdk_property_delete_2 (window, property, prop);
245
gdk_property_get (GdkWindow *window,
251
GdkAtom *actual_property_type,
252
gint *actual_format_type,
256
GdkWindowImplDirectFB *impl;
257
GdkWindowProperty *prop;
260
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), FALSE);
261
g_return_val_if_fail (data != NULL, FALSE);
264
window = _gdk_parent_root;
266
if (GDK_WINDOW_DESTROYED (window))
269
impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
271
if (!impl->properties)
274
prop = g_hash_table_lookup (impl->properties, GUINT_TO_POINTER (property));
277
if (actual_property_type)
278
*actual_property_type = GDK_NONE;
282
nbytes = CLAMP (length, 0, prop->length - offset * 4);
285
(prop->type == 0 /* AnyPropertyType */ || prop->type == type))
287
*data = g_malloc (nbytes + 1);
288
memcpy (*data, prop->data + offset, nbytes);
297
*actual_length = nbytes;
298
if (actual_property_type)
299
*actual_property_type = prop->type;
300
if (actual_format_type)
301
*actual_format_type = prop->format;
303
/* only delete the property if it was completely retrieved */
304
if (pdelete && length >= *actual_length && *data != NULL)
306
gdk_property_delete_2 (window, property, prop);
313
gdk_property_change (GdkWindow *window,
321
GdkWindowImplDirectFB *impl;
322
GdkWindowProperty *prop;
323
GdkWindowProperty *new_prop;
326
GdkWindow *event_window;
328
g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
331
window = _gdk_parent_root;
333
if (GDK_WINDOW_DESTROYED (window))
336
impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
338
if (!impl->properties)
339
impl->properties = g_hash_table_new (NULL, NULL);
341
prop = g_hash_table_lookup (impl->properties, GUINT_TO_POINTER (property));
345
case GDK_PROP_MODE_REPLACE:
346
new_size = nelements * (format >> 3);
349
case GDK_PROP_MODE_PREPEND:
350
case GDK_PROP_MODE_APPEND:
351
new_size = nelements * (format >> 3);
354
if (type != prop->type || format != prop->format)
356
new_size += prop->length;
361
new_prop = g_malloc (G_STRUCT_OFFSET (GdkWindowProperty, data) + new_size);
362
new_prop->length = new_size;
363
new_prop->type = type;
364
new_prop->format = format;
368
case GDK_PROP_MODE_REPLACE:
369
memcpy (new_prop->data, data, new_size);
372
case GDK_PROP_MODE_APPEND:
374
memcpy (new_prop->data, prop->data, prop->length);
375
memcpy (new_prop->data + new_prop->length,
376
data, (nelements * (format >> 3)));
379
case GDK_PROP_MODE_PREPEND:
380
memcpy (new_prop->data, data, (nelements * (format >> 3)));
382
memcpy (new_prop->data + (nelements * (format >> 3)),
383
prop->data, prop->length);
387
g_hash_table_insert (impl->properties,
388
GUINT_TO_POINTER (property), new_prop);
391
event_window = gdk_directfb_other_event_window (window, GDK_PROPERTY_NOTIFY);
395
event = gdk_directfb_event_make (event_window, GDK_PROPERTY_NOTIFY);
396
event->property.atom = property;
397
event->property.state = GDK_PROPERTY_NEW_VALUE;
400
#define __GDK_PROPERTY_X11_C__
401
#include "gdkaliasdef.c"