window.c
// retrieve a text property from a window
// technically we could use window_get_prop(), but this is better for character set support
retrieve a text property from a window
technically we could use window_get_prop(), but this is better for character set support
retrieve a text property from a window technically we could use window_get_prop () but this is better for character set support
char* window_get_text_prop(Window w, Atom atom)
{
	XTextProperty prop; char *res = NULL;
	char **list = NULL; int count;
	if (XGetTextProperty(display, w, &prop, atom) && prop.value && prop.nitems)
	{
		if (prop.encoding == XA_STRING)
		{
			res = allocate(strlen((char*)prop.value)+1);
			strcpy(res, (char*)prop.value);
		}
		else
		if (XmbTextPropertyToTextList(display, &prop, &list, &count) >= Success && count > 0 && *list)
		{
			res = allocate(strlen(*list)+1);
			strcpy(res, *list);
			XFreeStringList(list);
		}
	}
	if (prop.value) XFree(prop.value);
	return res;
}
char * window_get_text_prop ( Window w , Atom atom ) { XTextProperty prop ; char * res = NULL ; char * * list = NULL ; int count ; if ( XGetTextProperty ( display , w , & prop , atom ) && prop . value && prop . nitems ) { if ( prop . encoding == XA_STRING ) { res = allocate ( strlen ( ( char * ) prop . value ) + 1 ) ; strcpy ( res , ( char * ) prop . value ) ; } else if ( XmbTextPropertyToTextList ( display , & prop , & list , & count ) >= Success && count > 0 && * list ) { res = allocate ( strlen ( * list ) + 1 ) ; strcpy ( res , * list ) ; XFreeStringList ( list ) ; } } if ( prop . value ) XFree ( prop . value ) ; return res ; }
retrieve a text property from a window
technically we could use window_get_prop(), but this is better for character set support
retrieve a text property from a window technically we could use window_get_prop () but this is better for character set support