diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-11-29 00:43:24 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-11-29 00:43:24 +0000 |
commit | 51f1c2a73c26416afdc6a88413b0cf03565805a3 (patch) | |
tree | a1e34926510dab788a83d610579eb51dcb048b70 /gdk/x11/gdkproperty-x11.c | |
parent | ab13c8803d226412cd075752615980072d5d31a1 (diff) | |
download | gdk-pixbuf-51f1c2a73c26416afdc6a88413b0cf03565805a3.tar.gz |
Convert atoms to and from atoms for properties of type XA_ATOM. (#65555,
Wed Nov 28 19:34:15 2001 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkproperty-x11.c (gdk_property_change, gdk_property_get):
Convert atoms to and from atoms for properties of type XA_ATOM.
(#65555, patch from Hidetoshi Tajima)
Diffstat (limited to 'gdk/x11/gdkproperty-x11.c')
-rw-r--r-- | gdk/x11/gdkproperty-x11.c | 79 |
1 files changed, 58 insertions, 21 deletions
diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c index c2cdaf734..8eab3f415 100644 --- a/gdk/x11/gdkproperty-x11.c +++ b/gdk/x11/gdkproperty-x11.c @@ -381,27 +381,45 @@ gdk_property_get (GdkWindow *window, if (data) { - switch (ret_format) + if (ret_prop_type == XA_ATOM) { - case 8: - ret_length = ret_nitems; - break; - case 16: - ret_length = sizeof(short) * ret_nitems; - break; - case 32: - ret_length = sizeof(long) * ret_nitems; - break; - default: - g_warning ("unknown property return format: %d", ret_format); - XFree (ret_data); - return FALSE; + /* + * data is an array of X atom, we need to convert it + * to an array of GDK Atoms + */ + gint i; + GdkAtom *ret_atoms = g_new (GdkAtom *, ret_nitems); + Atom *xatoms = (Atom *)ret_data; + + data = (guchar *)ret_atoms; + + for (i = 0; i < ret_nitems; i++) + ret_atoms[i] = gdk_x11_xatom_to_atom (xatoms[i]); + } + else + { + switch (ret_format) + { + case 8: + ret_length = ret_nitems; + break; + case 16: + ret_length = sizeof(short) * ret_nitems; + break; + case 32: + ret_length = sizeof(long) * ret_nitems; + break; + default: + g_warning ("unknown property return format: %d", ret_format); + XFree (ret_data); + return FALSE; + } + + *data = g_new (guchar, ret_length); + memcpy (*data, ret_data, ret_length); + if (actual_length) + *actual_length = ret_length; } - - *data = g_new (guchar, ret_length); - memcpy (*data, ret_data, ret_length); - if (actual_length) - *actual_length = ret_length; } XFree (ret_data); @@ -442,8 +460,27 @@ gdk_property_change (GdkWindow *window, xwindow = _gdk_root_window; } - XChangeProperty (xdisplay, xwindow, xproperty, xtype, - format, mode, (guchar *)data, nelements); + if (xtype == XA_ATOM) + { + /* + * data is an array of GdkAtom, we need to convert it + * to an array of X Atoms + */ + gint i; + GdkAtom *atoms = (GdkAtom*) data; + Atom *xatoms; + + xatoms = g_new (Atom, nelements); + for (i = 0; i < nelements; i++) + xatoms[i] = gdk_x11_atom_to_xatom (atoms[i]); + + XChangeProperty (xdisplay, xwindow, xproperty, xtype, + format, mode, (guchar *)xatoms, nelements); + g_free (xatoms); + } + else + XChangeProperty (xdisplay, xwindow, xproperty, xtype, + format, mode, (guchar *)data, nelements); } void |