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
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include <X11/Xatom.h>
23 #include "gdkprivate.h"
27 gdk_atom_intern (const gchar *atom_name,
30 return XInternAtom (gdk_display, atom_name, only_if_exists);
34 gdk_atom_name (GdkAtom atom)
39 /* If this atom doesn't exist, we'll die with an X error unless
40 we take precautions */
42 gdk_error_warnings = 0;
44 t = XGetAtomName (gdk_display, atom);
45 gdk_error_warnings = 1;
47 if (gdk_error_code == -1)
65 gdk_property_get (GdkWindow *window,
71 GdkAtom *actual_property_type,
72 gint *actual_format_type,
81 gulong ret_bytes_after;
87 GdkWindowPrivate *private;
89 private = (GdkWindowPrivate*) window;
90 if (private->destroyed)
93 xdisplay = private->xdisplay;
94 xwindow = private->xwindow;
98 xdisplay = gdk_display;
99 xwindow = gdk_root_window;
103 XGetWindowProperty (xdisplay, xwindow, property,
104 offset, (length + 3) / 4, pdelete,
105 type, &ret_prop_type, &ret_format,
106 &ret_nitems, &ret_bytes_after,
109 if ((ret_prop_type == None) && (ret_format == 0)) {
113 if (actual_property_type)
114 *actual_property_type = ret_prop_type;
115 if (actual_format_type)
116 *actual_format_type = ret_format;
118 if (ret_prop_type != type)
123 rn = gdk_atom_name(ret_prop_type);
124 pn = gdk_atom_name(type);
125 g_warning("Couldn't match property type %s to %s\n", rn, pn);
126 g_free(rn); g_free(pn);
130 /* FIXME: ignoring bytes_after could have very bad effects */
137 ret_length = ret_nitems;
140 ret_length = 2 * ret_nitems;
143 ret_length = 4 * ret_nitems;
146 g_warning ("unknown property return format: %d", ret_format);
151 *data = g_new (guchar, ret_length);
152 memcpy (*data, ret_data, ret_length);
154 *actual_length = ret_length;
163 gdk_property_change (GdkWindow *window,
176 GdkWindowPrivate *private;
178 private = (GdkWindowPrivate*) window;
179 if (private->destroyed)
182 xdisplay = private->xdisplay;
183 xwindow = private->xwindow;
187 xdisplay = gdk_display;
188 xwindow = gdk_root_window;
191 XChangeProperty (xdisplay, xwindow, property, type,
192 format, mode, data, nelements);
196 gdk_property_delete (GdkWindow *window,
204 GdkWindowPrivate *private;
206 private = (GdkWindowPrivate*) window;
207 if (private->destroyed)
210 xdisplay = private->xdisplay;
211 xwindow = private->xwindow;
215 xdisplay = gdk_display;
216 xwindow = gdk_root_window;
219 XDeleteProperty (xdisplay, xwindow, property);