Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to set X11 _NET_WM_PID property ? [ SOLVED ]  (Read 3538 times)

0 Members and 1 Guest are viewing this topic.

mary2409

  • Newbie
  • *
  • Posts: 6
    • View Profile
How to set X11 _NET_WM_PID property ? [ SOLVED ]
« on: July 03, 2015, 10:37:15 pm »
I need to be able to get the window ID from the PID, and I read that there is a standard X11 property called _NET_WM_PID that windows should set. Does SFML set this property, and if not, is there a way to set it manually ?


EDIT: Solved. I compromised and instead of searching by PID, I search by window name. From the windows name I get its window-ID and can successfully embed it into my QT application. if anyone wants to see the code that does this, you can find it here:

https://gist.github.com/anonymous/6df3c14250833ed40484

warning, it says atomPID but this has nothing to do with pid, it searches for windows by name.
« Last Edit: July 04, 2015, 12:43:07 am by mary2409 »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: How to set X11 _NET_WM_PID property ?
« Reply #1 on: July 03, 2015, 10:44:59 pm »
I need to be able to get the window ID from the PID
Why?

I read that there is a standard X11 property called _NET_WM_PID that windows should set. Does SFML set this property
A quick check of the source code
  $ git grep NET_WM_PID
  src/SFML/Window/Unix/WindowImplX11.cpp:1590:        netWmPid = getAtom("_NET_WM_PID", true);

would seem to suggest that SFML reads it at least - go dig ;).

is there a way to set it manually ?
Through SFML? None that I could find in 2 minutes of looking through the source - but I may be wrong. You could always use xlib directly, but then again; why do you need this?
« Last Edit: July 03, 2015, 10:48:33 pm by Jesper Juhl »

mary2409

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: How to set X11 _NET_WM_PID property ?
« Reply #2 on: July 03, 2015, 11:12:35 pm »
I'm trying to embed an sfml window into a qt5 window. I saw the howto about converting an sfml window into a QT widget, but this will NOT work, because my sfml window creates an opengl context and uses glew to make openGL calls. this basically means you cannot embed the window in QT, as qt has its own openGL subsystem that is NOT compatible with glew. My only hope is to spawn the sfml window into its own process and capture it (using its window ID) and embed it into a widget. The problem is, how do you get the windowID from the PID ? one of the ways if the window sets the _NET_WM_PID property (there was an example on stackoverflow), and this works , but apparently SFML doesn't set the property.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

mary2409

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: How to set X11 _NET_WM_PID property ?
« Reply #4 on: July 04, 2015, 12:32:10 am »
Thanks, but i'm not sure how the system handle will help me. I think I have this figured out, which is to query the xwindow system by the _NET_WM_NAME property, instead of the PID property. Thank you both for trying to help me with this :)