df_df
df_df

Reputation: 31

get "parent" window of newly created window

I need to get "parent" window of newly created window. For example: I start xterm, type "zenity --info" and I want to set zenity window geometry same as xterm geometry. I looked for XCreateWindowEvent (parent field) but that's not what I want. How I can to do this?

Upvotes: 3

Views: 2947

Answers (1)

Jerry Epas
Jerry Epas

Reputation: 255

Here is the code:

bool getWindowParent(Window & winId, Window & _root) {
    Window root, parent, *children = NULL;
    unsigned int num_children;

    if(!XQueryTree(m_display, winId, &root, &parent, &children, &num_children))
        return false;

    if (children)
        XFree((char *)children);

    winId = parent;
    _root = root;
    return true;
}

Upvotes: 6

Related Questions