~canonical-dx-team/ubuntu/maverick/gtk+2.0/menuproxy

« back to all changes in this revision

Viewing changes to gdk/directfb/gdkproperty-directfb.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-05-04 12:24:25 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20070504122425-0m8midgzrp40y8w2
Tags: 2.10.12-1ubuntu1
* Sync with Debian
* New upstream version:
  Fixed bugs:
  - 379414 file chooser warnings when changing path in the entry
  - 418585 GtkFileChooserDefault sizing code is not DPI independent
  - 419568 Crash in search if start with special letter
  - 435062 build dies with icon cache validation
  - 379399 Segfault to call gtk_print_operation_run twice.
  - 387889 cups backend has problems when there are too many printers
  - 418531 invalid read to gtkicontheme.c gtk_icon_theme_lookup_icon...
  - 423916 crash in color scheme code
  - 424042 Segmentation fault while quickly pressing Alt+arrows
  - 415260 Protect against negative indices when setting values in G...
  - 419171 XGetVisualInfo() may not set nxvisuals
  - 128852 Gdk cursors don't look good on win32
  - 344657 Ctrl-H doesn't toggle "Show Hidden Files" setting
  - 345345 PrintOperation::paginate is not emitted for class handler
  - 347567 GtkPrintOperation::end-print is not emitted if it's cance...
  - 369112 gtk_ui_manager_add_ui should accept unnamed separator
  - 392015 Selected menu item invisible on Windows Vista
  - 399253 MS-Windows Theme Bottom Tab placement rendering glitches
  - 399425 gtk_input_dialog_fill_axes() adds child to gtkscrolledwin...
  - 403251 [patch] little memory leak in GtkPrintJob
  - 403267 [patch] memory leak in GtkPageSetupUnixDialog
  - 403470 MS-Windows Theme tab placement other than on top leaks a ...
  - 404506 Windows system fonts that have multi-byte font names cann...
  - 405089 Incorrect window placement for GtkEventBox private window
  - 405515 Minor leak in gtkfilesystemmodel.c
  - 405539 gdk_pixbuf_save() for PNG saver can return FALSE without ...
  - 415681 gdk_window_clear_area includes an extra line and column o...
  - 418219 GtkRecentChooser should apply filter before sorting and c...
  - 418403 Scroll to printer after selecting it from settings
  - 421985 _gtk_print_operation_platform_backend_launch_preview
  - 421990 gtk_print_job_get_surface
  - 421993 gtk_print_operation_init
  - 423064 Conditional jump or move depends on uninitialised value(s...
  - 423722 Fix printing header in gtk-demo
  - 424168 gtk_print_operation_run on async preview
  - 425655 Don't install gtk+-unix-print-2.0.pc on non-UNIX platforms
  - 425786 GDK segfaults if XineramaQueryScreens fails
  - 428665 Lpr Backend gets stuck in infinite loop during gtk_enumer...
  - 429902 GtkPrintOperation leaks cairo contextes
  - 431997 First delay of GdkPixbufAnimationIter is wrong
  - 433242 Inconsistent scroll arrow position calculations
  - 433972 Placing gtk.Expander inside a gtk.TextView() changes gtk....
  - 434261 _gtk_toolbar_elide_underscores incorrectly handles some s...
  - 383354 ctrl-L should make 'Location' entry disappear
  - 418673 gtk_recent_manager_add_item
  - 429732 gtk_accel_group_finalize accesses invalid memory
  - 435028 WM_CLIENT_LEADER is wrong on the leader_window
  - 431067 Background of the header window is not updated
  - 338843 add recent files support inside the ui manager
  - 148535 add drop shadow to menus, tooltips, etc. under Windows XP
* debian/control.in:
  - Conflicts on ubuntulooks (<= 0.9.11-1)
* debian/patches/15_default-fallback-icon-theme.patch:
  - patch from Debian, fallback on gnome icon theme

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GDK - The GIMP Drawing Kit
 
2
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
18
 */
 
19
 
 
20
/*
 
21
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
 
22
 * file for a list of people on the GTK+ Team.
 
23
 */
 
24
 
 
25
/*
 
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>
 
31
 */
 
32
 
 
33
#include <config.h>
 
34
#include "gdk.h"
 
35
 
 
36
#include <string.h>
 
37
 
 
38
#include "gdkproperty.h"
 
39
 
 
40
#include "gdkdirectfb.h"
 
41
#include "gdkprivate-directfb.h"
 
42
 
 
43
#include "gdkinternals.h"
 
44
 
 
45
#include "gdkalias.h"
 
46
 
 
47
static GHashTable *names_to_atoms;
 
48
static GPtrArray *atoms_to_names;
 
49
 
 
50
static const gchar xatoms_string[] = 
 
51
  /* These are all the standard predefined X atoms */
 
52
  "NONE\0"
 
53
  "PRIMARY\0"
 
54
  "SECONDARY\0"
 
55
  "ARC\0"
 
56
  "ATOM\0"
 
57
  "BITMAP\0"
 
58
  "CARDINAL\0"
 
59
  "COLORMAP\0"
 
60
  "CURSOR\0"
 
61
  "CUT_BUFFER0\0"
 
62
  "CUT_BUFFER1\0"
 
63
  "CUT_BUFFER2\0"
 
64
  "CUT_BUFFER3\0"
 
65
  "CUT_BUFFER4\0"
 
66
  "CUT_BUFFER5\0"
 
67
  "CUT_BUFFER6\0"
 
68
  "CUT_BUFFER7\0"
 
69
  "DRAWABLE\0"
 
70
  "FONT\0"
 
71
  "INTEGER\0"
 
72
  "PIXMAP\0"
 
73
  "POINT\0"
 
74
  "RECTANGLE\0"
 
75
  "RESOURCE_MANAGER\0"
 
76
  "RGB_COLOR_MAP\0"
 
77
  "RGB_BEST_MAP\0"
 
78
  "RGB_BLUE_MAP\0"
 
79
  "RGB_DEFAULT_MAP\0"
 
80
  "RGB_GRAY_MAP\0"
 
81
  "RGB_GREEN_MAP\0"
 
82
  "RGB_RED_MAP\0"
 
83
  "STRING\0"
 
84
  "VISUALID\0"
 
85
  "WINDOW\0"
 
86
  "WM_COMMAND\0"
 
87
  "WM_HINTS\0"
 
88
  "WM_CLIENT_MACHINE\0"
 
89
  "WM_ICON_NAME\0"
 
90
  "WM_ICON_SIZE\0"
 
91
  "WM_NAME\0"
 
92
  "WM_NORMAL_HINTS\0"
 
93
  "WM_SIZE_HINTS\0"
 
94
  "WM_ZOOM_HINTS\0"
 
95
  "MIN_SPACE\0"
 
96
  "NORM_SPACE\0"
 
97
  "MAX_SPACE\0"
 
98
  "END_SPACE\0"
 
99
  "SUPERSCRIPT_X\0"
 
100
  "SUPERSCRIPT_Y\0"
 
101
  "SUBSCRIPT_X\0"
 
102
  "SUBSCRIPT_Y\0"
 
103
  "UNDERLINE_POSITION\0"
 
104
  "UNDERLINE_THICKNESS\0"
 
105
  "STRIKEOUT_ASCENT\0"
 
106
  "STRIKEOUT_DESCENT\0"
 
107
  "ITALIC_ANGLE\0"
 
108
  "X_HEIGHT\0"
 
109
  "QUAD_WIDTH\0"
 
110
  "WEIGHT\0"
 
111
  "POINT_SIZE\0"
 
112
  "RESOLUTION\0"
 
113
  "COPYRIGHT\0"
 
114
  "NOTICE\0"
 
115
  "FONT_NAME\0"
 
116
  "FAMILY_NAME\0"
 
117
  "FULL_NAME\0"
 
118
  "CAP_HEIGHT\0"
 
119
  "WM_CLASS\0"
 
120
  "WM_TRANSIENT_FOR\0"
 
121
;
 
122
 
 
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
 
130
};
 
131
 
 
132
#define N_CUSTOM_PREDEFINED 1
 
133
 
 
134
static void
 
135
ensure_atom_tables (void)
 
136
{
 
137
  int i;
 
138
  
 
139
  if (names_to_atoms)
 
140
    return;
 
141
 
 
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));
 
144
 
 
145
  for (i = 0; i < G_N_ELEMENTS (xatoms_offset); i++)
 
146
    {
 
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]);
 
149
    }
 
150
}
 
151
 
 
152
static GdkAtom
 
153
intern_atom_internal (const gchar *atom_name, gboolean allocate)
 
154
{
 
155
  gpointer result;
 
156
  gchar *name;
 
157
  g_return_val_if_fail (atom_name != NULL, GDK_NONE);
 
158
 
 
159
  ensure_atom_tables ();
 
160
  
 
161
  if (g_hash_table_lookup_extended (names_to_atoms, atom_name, NULL, &result))
 
162
    return result;
 
163
  
 
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);
 
168
  
 
169
  return result;  
 
170
}
 
171
 
 
172
GdkAtom
 
173
gdk_atom_intern (const gchar *atom_name,
 
174
                 gboolean     only_if_exists)
 
175
{
 
176
  return intern_atom_internal (atom_name, TRUE);
 
177
}
 
178
 
 
179
GdkAtom
 
180
gdk_atom_intern_static_string (const gchar *atom_name)
 
181
{
 
182
  return intern_atom_internal (atom_name, FALSE);
 
183
}
 
184
 
 
185
 
 
186
gchar *
 
187
gdk_atom_name (GdkAtom atom)
 
188
{
 
189
  if (!atoms_to_names)
 
190
    return NULL;
 
191
    
 
192
  if (GPOINTER_TO_INT (atom) >= atoms_to_names->len)
 
193
    return NULL;
 
194
    
 
195
  return g_ptr_array_index (atoms_to_names, GPOINTER_TO_INT (atom));
 
196
}
 
197
 
 
198
 
 
199
static void
 
200
gdk_property_delete_2 (GdkWindow         *window,
 
201
                       GdkAtom            property,
 
202
                       GdkWindowProperty *prop)
 
203
{
 
204
  GdkWindowImplDirectFB *impl;
 
205
  GdkEvent              *event;
 
206
  GdkWindow             *event_window;
 
207
 
 
208
  impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
 
209
 
 
210
  g_hash_table_remove (impl->properties, GUINT_TO_POINTER (property));
 
211
  g_free (prop);
 
212
 
 
213
  event_window = gdk_directfb_other_event_window (window, GDK_PROPERTY_NOTIFY);
 
214
 
 
215
  if (event_window)
 
216
    {
 
217
      event = gdk_directfb_event_make (event_window, GDK_PROPERTY_NOTIFY);
 
218
      event->property.atom  = property;
 
219
      event->property.state = GDK_PROPERTY_DELETE;
 
220
    }
 
221
}
 
222
 
 
223
void
 
224
gdk_property_delete (GdkWindow *window,
 
225
                     GdkAtom    property)
 
226
{
 
227
  GdkWindowImplDirectFB *impl;
 
228
  GdkWindowProperty     *prop;
 
229
 
 
230
  g_return_if_fail (GDK_IS_WINDOW (window));
 
231
 
 
232
  impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
 
233
 
 
234
  if (!impl->properties)
 
235
    return;
 
236
 
 
237
  prop = g_hash_table_lookup (impl->properties, GUINT_TO_POINTER (property));
 
238
  if (!prop)
 
239
    return;
 
240
 
 
241
  gdk_property_delete_2 (window, property, prop);
 
242
}
 
243
 
 
244
gboolean
 
245
gdk_property_get (GdkWindow   *window,
 
246
                  GdkAtom      property,
 
247
                  GdkAtom      type,
 
248
                  gulong       offset,
 
249
                  gulong       length,
 
250
                  gint         pdelete,
 
251
                  GdkAtom     *actual_property_type,
 
252
                  gint        *actual_format_type,
 
253
                  gint        *actual_length,
 
254
                  guchar     **data)
 
255
{
 
256
  GdkWindowImplDirectFB *impl;
 
257
  GdkWindowProperty     *prop;
 
258
  gint                   nbytes = 0;
 
259
 
 
260
  g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), FALSE);
 
261
  g_return_val_if_fail (data != NULL, FALSE);
 
262
 
 
263
  if (!window)
 
264
    window = _gdk_parent_root;
 
265
 
 
266
  if (GDK_WINDOW_DESTROYED (window))
 
267
    return FALSE;
 
268
 
 
269
  impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
 
270
 
 
271
  if (!impl->properties)
 
272
    return FALSE;
 
273
 
 
274
  prop = g_hash_table_lookup (impl->properties, GUINT_TO_POINTER (property));
 
275
  if (!prop)
 
276
    {
 
277
      if (actual_property_type)
 
278
        *actual_property_type = GDK_NONE;
 
279
      return FALSE;
 
280
    }
 
281
 
 
282
  nbytes = CLAMP (length, 0, prop->length - offset * 4);
 
283
 
 
284
  if (nbytes > 0 &&
 
285
      (prop->type == 0 /* AnyPropertyType */ || prop->type == type))
 
286
    {
 
287
      *data = g_malloc (nbytes + 1);
 
288
      memcpy (*data, prop->data + offset, nbytes);
 
289
      (*data)[nbytes] = 0;
 
290
    }
 
291
  else
 
292
    {
 
293
      *data = NULL;
 
294
    }
 
295
 
 
296
  if (actual_length)
 
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;
 
302
 
 
303
  /* only delete the property if it was completely retrieved */
 
304
  if (pdelete && length >= *actual_length && *data != NULL)
 
305
    {
 
306
      gdk_property_delete_2 (window, property, prop);
 
307
    }
 
308
 
 
309
  return TRUE;
 
310
}
 
311
 
 
312
void
 
313
gdk_property_change (GdkWindow    *window,
 
314
                     GdkAtom       property,
 
315
                     GdkAtom       type,
 
316
                     gint          format,
 
317
                     GdkPropMode   mode,
 
318
                     const guchar *data,
 
319
                     gint          nelements)
 
320
{
 
321
  GdkWindowImplDirectFB *impl;
 
322
  GdkWindowProperty     *prop;
 
323
  GdkWindowProperty     *new_prop;
 
324
  gint                   new_size = 0;
 
325
  GdkEvent              *event;
 
326
  GdkWindow             *event_window;
 
327
 
 
328
  g_return_if_fail (window == NULL || GDK_IS_WINDOW (window));
 
329
 
 
330
  if (!window)
 
331
    window = _gdk_parent_root;
 
332
 
 
333
  if (GDK_WINDOW_DESTROYED (window))
 
334
    return;
 
335
 
 
336
  impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
 
337
 
 
338
  if (!impl->properties)
 
339
    impl->properties = g_hash_table_new (NULL, NULL);
 
340
 
 
341
  prop = g_hash_table_lookup (impl->properties, GUINT_TO_POINTER (property));
 
342
 
 
343
  switch (mode)
 
344
    {
 
345
    case GDK_PROP_MODE_REPLACE:
 
346
      new_size = nelements * (format >> 3);
 
347
      break;
 
348
 
 
349
    case GDK_PROP_MODE_PREPEND:
 
350
    case GDK_PROP_MODE_APPEND:
 
351
      new_size = nelements * (format >> 3);
 
352
      if (prop)
 
353
        {
 
354
          if (type != prop->type || format != prop->format)
 
355
            return;
 
356
          new_size += prop->length;
 
357
        }
 
358
      break;
 
359
    }
 
360
 
 
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;
 
365
 
 
366
  switch (mode)
 
367
    {
 
368
    case GDK_PROP_MODE_REPLACE:
 
369
      memcpy (new_prop->data, data, new_size);
 
370
      break;
 
371
 
 
372
    case GDK_PROP_MODE_APPEND:
 
373
      if (prop)
 
374
        memcpy (new_prop->data, prop->data, prop->length);
 
375
      memcpy (new_prop->data + new_prop->length,
 
376
              data, (nelements * (format >> 3)));
 
377
      break;
 
378
 
 
379
    case GDK_PROP_MODE_PREPEND:
 
380
      memcpy (new_prop->data, data, (nelements * (format >> 3)));
 
381
      if (prop)
 
382
        memcpy (new_prop->data + (nelements * (format >> 3)),
 
383
                prop->data, prop->length);
 
384
      break;
 
385
    }
 
386
 
 
387
  g_hash_table_insert (impl->properties,
 
388
                       GUINT_TO_POINTER (property), new_prop);
 
389
  g_free (prop);
 
390
 
 
391
  event_window = gdk_directfb_other_event_window (window, GDK_PROPERTY_NOTIFY);
 
392
 
 
393
  if (event_window)
 
394
    {
 
395
      event = gdk_directfb_event_make (event_window, GDK_PROPERTY_NOTIFY);
 
396
      event->property.atom  = property;
 
397
      event->property.state = GDK_PROPERTY_NEW_VALUE;
 
398
    }
 
399
}
 
400
#define __GDK_PROPERTY_X11_C__
 
401
#include "gdkaliasdef.c"