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 Library 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include <X11/Xatom.h>
22 #include "gdkprivate.h"
26 gdk_atom_intern (const gchar *atom_name,
29 return XInternAtom (gdk_display, atom_name, only_if_exists);
33 gdk_atom_name (GdkAtom atom)
38 /* If this atom doesn't exist, we'll die with an X error unless
39 we take precautions */
41 gdk_error_warnings = 0;
42 t = XGetAtomName (gdk_display, atom);
43 gdk_error_warnings = 1;
45 if (gdk_error_code == -1)
59 gdk_property_get (GdkWindow *window,
65 GdkAtom *actual_property_type,
66 gint *actual_format_type,
70 GdkWindowPrivate *private;
76 gulong ret_bytes_after;
82 private = (GdkWindowPrivate*) window;
83 xdisplay = private->xdisplay;
84 xwindow = private->xwindow;
88 xdisplay = gdk_display;
89 xwindow = gdk_root_window;
92 XGetWindowProperty (xdisplay, xwindow, property,
93 offset, (length + 3) / 4, pdelete,
94 type, &ret_prop_type, &ret_format,
95 &ret_nitems, &ret_bytes_after,
98 if ((ret_prop_type == None) && (ret_format == 0))
101 if (actual_property_type)
102 *actual_property_type = ret_prop_type;
103 if (actual_format_type)
104 *actual_format_type = ret_format;
106 if (ret_prop_type != property)
112 /* FIXME: ignoring bytes_after could have very bad effects */
119 ret_length = ret_nitems;
122 ret_length = 2 * ret_nitems;
125 ret_length = 4 * ret_nitems;
128 g_warning ("unknown property return format: %d", ret_format);
133 *data = g_new (guchar, ret_length);
134 memcpy (*data, ret_data, ret_length);
136 *actual_length = ret_length;
145 gdk_property_change (GdkWindow *window,
153 GdkWindowPrivate *private;
159 private = (GdkWindowPrivate*) window;
160 xdisplay = private->xdisplay;
161 xwindow = private->xwindow;
165 xdisplay = gdk_display;
166 xwindow = gdk_root_window;
169 XChangeProperty (xdisplay, xwindow, property, type,
170 format, mode, data, nelements);
174 gdk_property_delete (GdkWindow *window,
177 GdkWindowPrivate *private;
183 private = (GdkWindowPrivate*) window;
184 xdisplay = private->xdisplay;
185 xwindow = private->xwindow;
189 xdisplay = gdk_display;
190 xwindow = gdk_root_window;
193 XDeleteProperty (xdisplay, xwindow, property);