private long[] getWindowProperty(long winId, final long propertyAtom) {
CLongPointer type = bridge.createCLongPointer(1, false);
Int32Pointer formatPtr = bridge.createInt32Pointer(1, false);
CLongPointer nItemsPtr = bridge.createCLongPointer(1, false);
CLongPointer bytesRemaining = bridge.createCLongPointer(1, false);
PointerPointer data = bridge.createPointerPointer(1, false);
final int anyType = X11Defs.AnyPropertyType;
x11.XGetWindowProperty(display, winId, propertyAtom, 0, 1,
anyType, X11Defs.False, type,
formatPtr, nItemsPtr,
bytesRemaining, data);
VoidPointer dataPtr = data.get(0);
if (dataPtr == null) {
return null;
}
x11.XFree(dataPtr);
long nBytes = bytesRemaining.get(0);
long typeAtom = type.get(0);
if (typeAtom == X11Defs.None) {
// the property doesn't exist
return null;
}
int bitFormat = formatPtr.get(0);
long nItems = (nBytes + 4) * 8 / bitFormat;
long n32bitItems = nItems / (32 / bitFormat);
x11.XGetWindowProperty(display, winId, propertyAtom, 0,
n32bitItems, anyType, X11Defs.False,
type, formatPtr, nItemsPtr,
bytesRemaining, data);
nBytes = bytesRemaining.get(0);
assert nBytes == 0;
//read the data:
int itemSize = bitFormat / 8;
CLongPointer dataArray = bridge.createCLongPointer(data.get(0));
long[] props = new long [(int)nItems];
for (int i = 0; i < nItems; i++) {
int item = 0;
if (itemSize == 4) {
item = (int)dataArray.get(i);