[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] get_wm_info on linux



Well, I managed to get it to work by hacking pygame src/display.c :)
It is actually a string it is looking for, and I'm not totally sure
how the conversion works (not totally clear on what a void * really is
etc), but here is my addition to display.c that made the value usable:

get_wm_info (PyObject_* self )
{
//In the glx section
....
tmp = PyInt_FromLong (info.info.x11.display);
PyDict_SetItemString (dict, "a_of_display", tmp);
Py_DECREF (tmp);
....
}

So now the info dictionary has a new value, "a_of_display" which I
assume is some kind of address.

In my python-ogre code, I call it like so:

self.screen = pygame.display.set_mode([opts["width"],opts["height"]])
settings = ogre.NameValuePairList()
inf = pygame.display.get_wm_info()
d1 = inf['a_of_display']
w2 = inf['window']
settings["parentWindowHandle"]=str(d1)+":0:"+str(w2)
self.renderWindow = self.root.createRenderWindow(
       name,opts["width"],opts["height"],opts["fs"],settings)

Surprisingly it works.  It seems like it should be possible to get the
long from the PyCObject (info['display']) just as well as it was done
from the c code (PyInt_FromLong) but what do I know.  At least I have
it working.  Thanks for pointing out that file Rene.