Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get "parent" window of newly created window

Tags:

x11

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?

like image 237
df_df Avatar asked Nov 27 '25 05:11

df_df


1 Answers

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;
}
like image 72
Jerry Epas Avatar answered Nov 30 '25 00:11

Jerry Epas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!