Hello,

XQueryTree is a function from xlib:

extern Status XQueryTree(
    Display*        /* display */,
    Window        /* w */,
    Window*        /* root_return */,
    Window*        /* parent_return */,
    Window**        /* children_return */,
    unsigned int*    /* nchildren_return */
);

This is how I'm pulling it into Chicken (using a 'c-function' macro I'm using for cross-Scheme compatability):

(c-function Status XQueryTree
  (Display*
   Window
   u32vector
   u32vector
   (c-pointer (c-pointer unsigned-long))
   u32vector))

The tricky parameter is the 'Window**' one.

I can allocate enough storage for a pointer via:

    (define children-return (allocate sizeof:c-pointer))

The trouble is, how do I portably extract the address? If I assume a 32-bit pointer size, it's easy:

  (pointer-u32-ref children-return)

on a 64-bit machine, that should be:

  (pointer-u64-ref children-return)

but, there is no 'pointer-u64-ref'. :-)

Once I have the address, the rest is easy; convert it to a pointer with address->pointer, and extract individual windows with pointer-u32-ref.

For reference, Ypsilon has this procedure that I use in this sort of case:

    bytevector-c-void*-ref

Larceny has:

    %get-pointer

Thanks for any suggestions!

Ed


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to