How to get an X11 Window from a Process ID?

后端 未结 8 761
孤街浪徒
孤街浪徒 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:10

    There is no good way. The only real options I see, are:

    1. You could look around in the process's address space to find the connection information and window ID.
    2. You could try to use netstat or lsof or ipcs to map the connections to the Xserver, and then (somehow! you'll need root at least) look at its connection info to find them.
    3. When spawning an instance you can wait until another window is mapped, assume it's the right one, and `move on.

提交回复
热议问题