internal override bool GetText(IntPtr handle, out string text) {
lock (XlibLock) {
IntPtr actual_atom;
int actual_format;
IntPtr nitems;
IntPtr bytes_after;
IntPtr prop = IntPtr.Zero;
XGetWindowProperty(DisplayHandle, handle,
_NET_WM_NAME, IntPtr.Zero, new IntPtr (1), false,
UTF8_STRING, out actual_atom, out actual_format, out nitems, out bytes_after, ref prop);
if ((long)nitems > 0 && prop != IntPtr.Zero) {
text = Marshal.PtrToStringUni (prop, (int)nitems);
XFree (prop);
return true;
}
else {
// fallback on the non-_NET property
IntPtr textptr;
textptr = IntPtr.Zero;
XFetchName(DisplayHandle, Hwnd.ObjectFromHandle(handle).whole_window, ref textptr);
if (textptr != IntPtr.Zero) {
text = Marshal.PtrToStringAnsi(textptr);
XFree(textptr);
return true;
} else {
text = "";
return false;
}
}
}
}