Re: mapping pid to window handle

From: Kip Rugger (kbr_at_pangea.ca)
Date: 03/09/04

  • Next message: Wayne Throop: "Re: remote X session"
    Date: 9 Mar 2004 12:02:03 -0600
    
    

    Xin Li <xinli1@illinoisalumni.org> wrote:
    >Hi,
    >
    >I need to find some way to map a given process id to a window handle,
    >assuming the PID is responsible for launching a window. The larger
    >picture is that, I am writing a launcher where the user can specify a
    >program to run. Once the program is launched, the launcher needs to
    >return the window handle associated with the primary window of the
    >application.
    >
    >So far, I'm trying to use the _NET_WM_PID atom to grab the PID
    >associated with a particular window handle. However, not all
    >applications set the _NET_WM_PID property. Mozilla is one such
    >example. I feel like there should be some fairly straight forward way
    >of getting the window handle associated with a pid, or the pid
    >associated with a window handle reliably.
    >
    >Any help would be greatly appreciated.
    >
    >TIA
    >Xin Li

    So if I understand you correctly, you are forking off the app -- thus
    you know the pid -- and then you are searching the windows for the
    property. And it doesn't work.

    The way to do this type of thing is to use the XC-APPGROUP extension
    (you can check if you have it with xdpyinfo). The extension allows
    you to flag an application at launch time as belonging to an appgroup,
    and you can get events and make queries based on this. In your case,
    you want to get events when the app creates top-level windows.

    I recently posted sample code to allow you to embed one application in
    another. You actually want the non-embeded case (or so it sounds),
    but it is very similar. The code is at

    http://groups.google.com/groups?q=appgroup+group:comp.windows.x.*&hl=en&
    lr=&ie=UTF-8&group=comp.windows.x.*&selm=buhtoo%24fu%241%40rugger.nodomain.
    ca&rnum=3


  • Next message: Wayne Throop: "Re: remote X session"

    Relevant Pages

    • Re: Register an App with windows
      ... My mini application simply has Sleep ... Did you just launch the process and use Spy++ to see what its window class ... Why doesn't FindWindow find my App? ... the mini launcher app just closes. ...
      (microsoft.public.vc.mfc)
    • Re: The Dock through the years
      ... Simple Finder interface in OS X. ... operate in a similar way to Launcher. ... most things got covered up by whatever front window ... trying to get by with some jack-of-all-trades like the Dock. ...
      (uk.comp.sys.mac)
    • Re: The Dock through the years
      ... if you were like me there'd be a corner of the Launcher window ... thing's buried so you can just go straight to it without any bother. ... But you'll move your actual hands to the keyboard from the mouse rather ... Slide the window, uncovered, no brain work, hardly any hand movement, ...
      (uk.comp.sys.mac)
    • mapping pid to window handle
      ... I need to find some way to map a given process id to a window handle, ... the launcher needs to ... I'm trying to use the _NET_WM_PID atom to grab the PID ...
      (comp.os.linux.x)
    • Re: Window -> PID
      ... the X server knows the pid for each client in order to do the ... |I am familiar with the most kernel structures (actually i am digging ... |pid> and moving mouse over that window produce a massive ... no way to get it out other than via poking in the X server process ...
      (comp.unix.solaris)