Re: XGetWindowAttributes: 1x1 pixel for GTK apps?



Owen

Thanks a lot for your tip! I was able to get the window dimension
by using this code:

/*******************************************************/
Window find_real_window_down(Display *display, Window window)
{
    Atom wm_state, type;
    int format;
    unsigned long nitems, after;
    unsigned char* prop;

    Window root, parent, old_parent;
    Window* children;
    unsigned int nchildren;
    Window result;

    wm_state = XInternAtom(display, "WM_STATE", False);

    do {
        old_parent = window;

        /* TODO: check return value of Xlib functions */
        XQueryTree(display, window, &root, &parent, &children,
               &nchildren);

        XGetWindowProperty(display, window, wm_state, 0, 0, False,
                   AnyPropertyType, &type, &format,
                   &nitems, &after, &prop);

        if (prop != NULL)
            XFree(prop);
        prop = NULL;

        if (children != NULL) {
            XFree(children);
            children = NULL;
        }

        window = parent;

    } while (parent != root);

    /* Has no attribute */
    if ((type == None) && (format == 0) && (after == 0))
        result = old_parent;
    else
        result = window;

    return result;
}
/*******************************************************/

Best regards


Adenilson
ps: by the way, is there any reason for GTK+ being different from other
toolkit in this issue?


Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]