How to get an X11 Window from a Process ID?

后端 未结 8 719
孤街浪徒
孤街浪徒 2020-11-27 11:30

Under Linux, my C++ application is using fork() and execv() to launch multiple instances of OpenOffice so as to view some powerpoint slide shows. This part works.

Ne

8条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 12:32

    The only way I know to do this is to traverse the tree of windows until you find what you're looking for. Traversing isn't hard (just see what xwininfo -root -tree does by looking at xwininfo.c if you need an example).

    But how do you identify the window you are looking for? Some applications set a window property called _NET_WM_PID.

    I believe that OpenOffice is one of the applications that sets that property (as do most Gnome apps), so you're in luck.

提交回复
热议问题