All pastes #227630 Raw Edit

Someone

public cpp v1 · immutable
#227630 ·published 2006-10-29 12:17 UTC
rendered paste body
Window *find_window(Display *display, Window start, const char *name){    Window *children = 0;    Window root;    Window parent;    unsigned int childrenCount = 0;    XQueryTree(display, start, &root, &parent, &children, &childrenCount);        char *window_name = 0;    for(int i=0; i<childrenCount; ++i) {        if(XFetchName(display, children[i], &window_name) == 1) {            if(strcmp(name, window_name) == 0) {                XFree(window_name);                return children[i];            }            XFree(window_name);        }    }    for(int i=0; i<childrenCount; ++i) {        Window *window = find_window(display, children[i], name);        if(window != 0) {            XFree(children);            return window;        }    }    if(children != 0)        XFree(children);        return 0;}