2003-05-17 Marko Rauhamaa <marko@pacujo.net> * gdk-1.2.defs (gdk_drag_get_selection, gdk_drag_abort, gdk_drop_reply, gdk_drag_context_new, gdk_drag_drop, gdk_drag_find_window, gdk_drag_begin, gdk_drag_motion, gdk_drop_finish, gdk_drag_get_protocol): New. * gdk-support.c (gdk_selection_property_get_interp): Corrected data type. 2003-05-16 Marko Rauhamaa <marko@pacujo.net> * gdk-1.2.defs (GdkSelectionType, GdkTarget): New (while not really used). * gdk-1.2.defs, guile-gtk.h, gdk-support.c (gdk_selection_owner_set, gdk_selection_owner_get, gdk_selection_convert, gdk_selection_property_get_interp, gdk_selection_send_notify): New. Marko -- Marko Rauhamaa mailto:marko@pacujo.net http://pacujo.net/marko/
Marko Rauhamaa <marko@pacujo.net> writes:
>
> gdk_selection_property_get_interp
>
> return length ? scm_take_str (data, length) : SCM_BOOL_F;
Not sure if length==0 would be valid data, though I don't see a reason
it wouldn't be. It might be nice to return an empty string for that.
data==NULL is supposedly the error indication, perhaps that could give
the #f.
However the 1.2 code looks like it doesn't store anything to data if
the window has been destroyed, so it might be prudent to initialize to
NULL.
It also looks like prop_type and prop_format are not set if the window
has been destroyed, maybe they should get initial values to avoid
problems too. GDK_NONE and 0 might be enough.
Kevin Ryde <user42@zip.com.au>: > Marko Rauhamaa <marko@pacujo.net> writes: > > return length ? scm_take_str (data, length) : SCM_BOOL_F; > > Not sure if length==0 would be valid data, though I don't see a reason > it wouldn't be. It might be nice to return an empty string for that. I misread the code (and the documentation) as though 0 was the error return value, but as you say: > data==NULL is supposedly the error indication, perhaps that could give > the #f. I have fixed it: return data ? scm_take_str (data, length) : SCM_BOOL_F; (but not yet submitted since I'm in the middle of other changes). > However the 1.2 code looks like it doesn't store anything to data if > the window has been destroyed, so it might be prudent to initialize to > NULL. That's where I probably got the idea that 0 is the error return value -- it definitely is a bug in gdk-1.2. I now initialize data with NULL and comment the kludge. > It also looks like prop_type and prop_format are not set if the window > has been destroyed, maybe they should get initial values to avoid > problems too. GDK_NONE and 0 might be enough. Prop_format is an integral value -- a random value is not an issue. Prop_type is sent to sgtk_atom2scm(), which returns SCM_BOOL_F if the atom is garbage. So I don't think those values need to be accounted for. (If I wanted to do it, I wouldn't rely on initializing their values, but I would rather set them to known values after returning from gdk_selection_property_get(). Marko -- Marko Rauhamaa mailto:marko@pacujo.net http://pacujo.net/marko/
Marko Rauhamaa <marko@pacujo.net> writes:
>
> Prop_type is sent to sgtk_atom2scm(), which returns SCM_BOOL_F if the
> atom is garbage.
Though you should bear in mind Xlib will do a round-trip to the server
if it's not in the local cache.
(Not that I imagine property-get is ever going to get much use - too
much like hard work. So it hardly matters really. :-)
Kevin Ryde <user42@zip.com.au>: > Marko Rauhamaa <marko@pacujo.net> writes: > > > > Prop_type is sent to sgtk_atom2scm(), which returns SCM_BOOL_F if > > the atom is garbage. > > Though you should bear in mind Xlib will do a round-trip to the server > if it's not in the local cache. Ok, just to please you I set *prop_type to GDK_NONE and *prop_format to 8 (sic) in case of failure. You should bear in mind that the round-trip happens as a rule. It is now avoided in case of failure. So in case you want to call gdk_selection_property_get in a hit-and-miss loop, your code should be almost twice as fast. Marko -- Marko Rauhamaa mailto:marko@pacujo.net http://pacujo.net/marko/
Marko Rauhamaa <marko@pacujo.net> writes:
>
> You should bear in mind that the round-trip happens as a rule.
Only the first time for each atom, since Xlib caches them. The
standard formats like STRING and BITMAP might even be builtin. :-)
[-- Attachment #1: Type: text/plain, Size: 469 bytes --] Marko Rauhamaa <marko@pacujo.net> writes: > > I set *prop_type to GDK_NONE and *prop_format to > 8 (sic) in case of failure. I think it'd be better as 0 to mean sort of no format at all, * gdk-support.c (gdk_selection_property_get_interp): Tweak to initialize prop_type and prop_format unconditionally, so as not to depend on gdk_selection_property_get at all for this. Use 0 for prop_format not given by gdk_selection_property_get. [-- Attachment #2: gdk-support.c.property-get.diff --] [-- Type: text/plain, Size: 1142 bytes --] --- gdk-support.c.~1.30.~ 2003-08-05 10:32:59.000000000 +1000 +++ gdk-support.c 2003-08-08 15:51:13.000000000 +1000 @@ -30,18 +30,24 @@ gdk_selection_property_get_interp (GdkWindow *requestor, GdkAtom *prop_type, int *prop_format) { - /* We need to initialize data to NULL because the GDK function returns - * a random value in data if requestor has been destroyed. */ - guchar *data = NULL; + guchar *data; int length; + + /* When the requestor window has been destroyed, it looks like + gdk_selection_property_get doesn't store anything in its return + locations. Initialize here to be sure. */ + data = NULL; + *prop_type = GTK_NONE; + *prop_format = 0; + length = gdk_selection_property_get (requestor, &data, prop_type, prop_format); /* Note: While we are returning a string, the data may actually be * anything and contain zeros. */ - if (data) return scm_take_str (data, length); - *prop_type = GDK_NONE; - *prop_format = 8; - return SCM_BOOL_F; + if (data) + return scm_take_str (data, length); + else + return SCM_BOOL_F; } #define FUNCNAME "gdk-property-change"