From 51f1c2a73c26416afdc6a88413b0cf03565805a3 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Thu, 29 Nov 2001 00:43:24 +0000 Subject: [PATCH] Convert atoms to and from atoms for properties of type XA_ATOM. (#65555, Wed Nov 28 19:34:15 2001 Owen Taylor * 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) --- ChangeLog | 6 +++ ChangeLog.pre-2-0 | 6 +++ ChangeLog.pre-2-10 | 6 +++ ChangeLog.pre-2-2 | 6 +++ ChangeLog.pre-2-4 | 6 +++ ChangeLog.pre-2-6 | 6 +++ ChangeLog.pre-2-8 | 6 +++ gdk/x11/gdkproperty-x11.c | 79 ++++++++++++++++++++++++++++----------- 8 files changed, 100 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3269cab8e..f83857f45b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Nov 28 19:34:15 2001 Owen Taylor + + * 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) + Wed Nov 28 18:37:04 2001 Owen Taylor * gtk/gtksocket.[ch] (gtk_socket_add_id): Rename 'id' parameter diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index b3269cab8e..f83857f45b 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +Wed Nov 28 19:34:15 2001 Owen Taylor + + * 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) + Wed Nov 28 18:37:04 2001 Owen Taylor * gtk/gtksocket.[ch] (gtk_socket_add_id): Rename 'id' parameter diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b3269cab8e..f83857f45b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Wed Nov 28 19:34:15 2001 Owen Taylor + + * 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) + Wed Nov 28 18:37:04 2001 Owen Taylor * gtk/gtksocket.[ch] (gtk_socket_add_id): Rename 'id' parameter diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index b3269cab8e..f83857f45b 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +Wed Nov 28 19:34:15 2001 Owen Taylor + + * 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) + Wed Nov 28 18:37:04 2001 Owen Taylor * gtk/gtksocket.[ch] (gtk_socket_add_id): Rename 'id' parameter diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index b3269cab8e..f83857f45b 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Wed Nov 28 19:34:15 2001 Owen Taylor + + * 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) + Wed Nov 28 18:37:04 2001 Owen Taylor * gtk/gtksocket.[ch] (gtk_socket_add_id): Rename 'id' parameter diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index b3269cab8e..f83857f45b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Wed Nov 28 19:34:15 2001 Owen Taylor + + * 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) + Wed Nov 28 18:37:04 2001 Owen Taylor * gtk/gtksocket.[ch] (gtk_socket_add_id): Rename 'id' parameter diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index b3269cab8e..f83857f45b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Wed Nov 28 19:34:15 2001 Owen Taylor + + * 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) + Wed Nov 28 18:37:04 2001 Owen Taylor * gtk/gtksocket.[ch] (gtk_socket_add_id): Rename 'id' parameter diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c index c2cdaf7341..8eab3f4153 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 = g_new (guchar, ret_length); - memcpy (*data, ret_data, ret_length); - if (actual_length) - *actual_length = ret_length; + 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; + } } 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