;; this one prints what appear to be memory addresses ;; (define (window-get-icons display window) (let ((property (xinternatom display "_NET_WM_ICON" 0))) (let-location ((xa_ret_type unsigned-long) (ret_format int) (ret_nitems unsigned-long) (ret_bytes_after unsigned-long) (ret_data (c-pointer unsigned-char))) (let ((status (xgetwindowproperty display window property 0 #x77777777 0 ANYPROPERTYTYPE (location xa_ret_type) (location ret_format) (location ret_nitems) (location ret_bytes_after) (location ret_data)))) (if ret_data ((foreign-lambda* int (((c-pointer unsigned-long) data)) "int width = *(int*)data;" "printf(\"%d\\n\",width);" "C_return(width);") (location ret_data)) -1))))) ;; This one works as expected (prints expected icon widths) ;; (define window-get-icons2 (foreign-lambda* int ((c-pointer disp) (unsigned-long window)) "unsigned long nitems, bytesafter;" "unsigned char *ret;" "int format;" "Atom type;" "Atom net_wm_icon = XInternAtom(disp, \"_NET_WM_ICON\", 0);" "XGetWindowProperty(disp, window, net_wm_icon," " 0, 0x77777777, 0," " 6," " &type, &format, &nitems, &bytesafter, &ret);" "if (!ret) { C_return(-1); }" "int width = *(int*)ret;" "XFree(ret);" "printf(\"%d\\n\",width);" "C_return(width);"))