wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

getprop.c (593B)


      1 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
      2  * See LICENSE file for license details.
      3  */
      4 #include "../x11.h"
      5 
      6 ulong
      7 getprop(Window *w, const char *prop, const char *type, Atom *actual, int *format,
      8 	ulong offset, uchar **ret, ulong length) {
      9 	Atom typea;
     10 	ulong n, extra;
     11 	int status;
     12 
     13 	typea = (type ? xatom(type) : 0L);
     14 
     15 	status = XGetWindowProperty(display, w->xid,
     16 		xatom(prop), offset, length, false /* delete */,
     17 		typea, actual, format, &n, &extra, ret);
     18 
     19 	if(status != Success) {
     20 		*ret = nil;
     21 		return 0;
     22 	}
     23 	if(n == 0) {
     24 		free(*ret);
     25 		*ret = nil;
     26 	}
     27 	return n;
     28 }