Getting window id for certain process id (for sharing theapplication) - Xwindows

This is a discussion on Getting window id for certain process id (for sharing theapplication) - Xwindows ; Hi all, My question is very very old. Lot of people may know answer for this. Still i could find anything useful for my problem. These are the questions asked by many people but i couldn't find anything useful in ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Getting window id for certain process id (for sharing theapplication)

  1. Getting window id for certain process id (for sharing theapplication)

    Hi all,

    My question is very very old. Lot of people may know answer for this.
    Still i could find anything useful for my problem.

    These are the questions asked by many people but i couldn't find
    anything useful in googling.

    Is there a way to obtain a list of window-IDs that belong to a certain
    process? (ie retrieving window IDs/pointers/whatever by PID numbers).

    Can I know in any way to obtain the window id of the top-level window
    of a running X-application based on its process id.?

    Objective:
    To Collect all the window id's for certain process to share those
    windows across network. The user input will be PID. I need to find out
    the windowid's related to that particular PID.

    Please suggest me.

  2. Re: Getting window id for certain process id (for sharing the application)

    On Tue, 18 Dec 2007 01:55:01 -0800 (PST), selva
    wrote:

    >Hi all,
    >
    >My question is very very old. Lot of people may know answer for this.
    >Still i could find anything useful for my problem.
    >
    >These are the questions asked by many people but i couldn't find
    >anything useful in googling.
    >
    >Is there a way to obtain a list of window-IDs that belong to a certain
    >process? (ie retrieving window IDs/pointers/whatever by PID numbers).
    >
    >Can I know in any way to obtain the window id of the top-level window
    >of a running X-application based on its process id.?
    >
    >Objective:
    > To Collect all the window id's for certain process to share those
    >windows across network. The user input will be PID. I need to find out
    >the windowid's related to that particular PID.
    >
    >Please suggest me.


    Try window manager control:
    http://sweb.cz/tripie/utils/wmctrl/

    There is a Perl module for it too, so you can do some magic
    to relate pids( with Perl's Proc::ProcessTable ) and wmctrl.

    zentara


    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html

  3. Re: Getting window id for certain process id (for sharing the application)

    selva wrote:
    > Hi all,
    >
    > My question is very very old. Lot of people may know answer for this.
    > Still i could find anything useful for my problem.
    >
    > These are the questions asked by many people but i couldn't find
    > anything useful in googling.
    >
    > Is there a way to obtain a list of window-IDs that belong to a certain
    > process? (ie retrieving window IDs/pointers/whatever by PID numbers).


    Unfortunately the only way to do the mapping of Windows/XIDs to a
    process id, is if the client set a property that indicates the pid.
    While this sort of introspection would be useful in some cases, and I
    belive Xaw/Xt implements it as well as some of the FreeDesktop extended
    window manager hints, it is by no means common with all toolkits.

    http://standards.freedesktop.org/wm-...html#id2507760

    Also, what would you do if the networked client is not running on the
    same machine as another client? Hint: the pids could be the same.


    > Can I know in any way to obtain the window id of the top-level window
    > of a running X-application based on its process id.?


    In short, no.

    > Objective:
    > To Collect all the window id's for certain process to share those
    > windows across network. The user input will be PID. I need to find out
    > the windowid's related to that particular PID.
    >
    > Please suggest me.


    Change your design or build a new window system :-)


    George

  4. Re: Getting window id for certain process id (for sharing theapplication)

    On Dec 18, 2:55 am, selva wrote:

    > Is there a way to obtain a list of window-IDs that belong to a certain
    > process? (ie retrieving window IDs/pointers/whatever by PID numbers).
    >
    > Can I know in any way to obtain the window id of the top-level window
    > of a running X-application based on its process id.?


    No. Not in general. What if the application is connecting from over a
    network? It may not be on an operating system which even has PIDs.


    > Objective:
    > To Collect all the window id's for certain process to share those
    > windows across network. The user input will be PID. I need to find out
    > the windowid's related to that particular PID.


    Many programs, especially window managers are well behaved. Try this:

    xlsclients -al

    An example is:

    Window 0x7400001:
    Machine: ********
    Name: acroread
    Icon Name: acroread
    Command: /usr/lib/acroread/Reader/intellinux/bin/acroread --
    display :0.0 -progressPipe 3 -exitPipe 4
    Instance/Class: acroread/Acroread

    $ xprop -id 0x7400001
    WM_CLASS(STRING) = "acroread", "Acroread"
    WM_COMMAND(STRING) = { "/usr/lib/acroread/Reader/intellinux/bin/
    acroread", "--display", ":0.0", "-progressPipe", "3", "-exitPipe",
    "4" }
    WM_CLIENT_LEADER(WINDOW): window id # 0x0
    _NET_WM_PID(CARDINAL) = 13175
    WM_LOCALE_NAME(STRING) = "C"
    WM_CLIENT_MACHINE(STRING) = "bigfrog"
    WM_NORMAL_HINTS(WM_SIZE_HINTS):
    program specified size: 10 by 10
    WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS,
    _NET_WM_PING
    WM_ICON_NAME(STRING) = "acroread"
    _NET_WM_ICON_NAME(UTF8_STRING) = 0x61, 0x63, 0x72, 0x6f, 0x72, 0x65,
    0x61, 0x64
    WM_NAME(STRING) = "acroread"
    _NET_WM_NAME(UTF8_STRING) = 0x61, 0x63, 0x72, 0x6f, 0x72, 0x65, 0x61,
    0x64

    Many applications seem to be good at setting the WM_CLIENT_MACHINE, so
    this works well for remote applications.

    It's not much of a definitive answer, but this may help.

    -Ed
    --
    (You can't go wrong with psycho-rats.) (http://mi.eng.cam.ac.uk/
    ~er258)

    /d{def}def/f{/Times findfont s scalefont setfont}d/s{11}d/r{roll}d f 2/
    m
    {moveto}d -1 r 230 350 m 0 1 179{1 index show 88 rotate 4 mul 0
    rmoveto}
    for /s 12 d f pop 235 420 translate 0 0 moveto 1 2 scale show
    showpage




    Examining this in more detail gives:



+ Reply to Thread