How to identify top-level X11 windows using xlib?

前端 未结 3 681
南旧
南旧 2020-12-05 03:27

I\'m trying to get a list of all top level desktop windows in an X11 session. Basically, I want to get a list of all windows that are shown in the window managers applicatio

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 04:16

    To expand on the previous solution, if you want to then get the window names:

    // get window Id:
    Window w = (Window) array[k];
    
    char* name = '\0';
    status = XFetchName(display, w, &name);
    if (status >= Success)
    {
        if (name == NULL)
            printf("Found: %ul  NULL\n", w);
        else
            printf("Found: %ul  %s\n", w, name);
    }
    XFree(name);
    

提交回复
热议问题