4

I use PyGObject/PyGI and GStreamer to show a video in my GUI. The video is shown in a Gtk.DrawingArea and therefore I need to get it's window-handle in the realize-signal-handler. On Linux I can simply use drawing_area.get_property('window').get_xid() and on Windows I have to access the C-API (like described here):

drawingarea_window = drawingarea.get_property('window')
ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object]
drawingarea_gpointer = ctypes.pythonapi.PyCapsule_GetPointer(drawingarea_window.__gpointer__, None)
gdkdll = ctypes.CDLL ('libgdk-3-0.dll')
self._drawingarea_handle = gdkdll.gdk_win32_window_get_handle(drawingarea_gpointer)

Now I want the same on MacOS. Since it is not using X11, but Quartz, I tried to use the C-API again. But this time to call gdk_quartz_window_get_nswindow instead of gdk_win32_window_get_handle (see gdkwindow-quartz.c):

// ... same lines as in Windows-example
gdkdll = ctypes.CDLL ('libgdk-3.0.dylib')
self._drawingarea_handle = gdkdll.gdk_quartz_window_get_nswindow(drawingarea_gpointer)

But this leads just to a Segmentation fault: 11.
Any ideas on how to get the handle on MacOS?

Community
  • 1
  • 1
Biggie
  • 6,647
  • 10
  • 30
  • 39
  • I did some research into this, the only big difference I can find between your code and other code that uses `gdk_quartz_window_get_nswindow` is that in other examples (in C#) pass a window handle to this function. Like here: https://github.com/mono/monodevelop/blob/master/main/src/addins/MacPlatform/MacInterop/GtkQuartz.cs#L56 – B8vrede May 31 '16 at 07:12
  • But the window handle is what I want to retrieve. So I cannot pass it to the function ;) The source-file you linked uses `GdkWindow.Handle`. In my example `drawingarea_window` is of type `GdkWindow`. However this object does not contain a `handle`/`Handle` property/attribute. – Biggie May 31 '16 at 17:54
  • @Biggie Did you get an answer for this??? – Gabrielle Aug 14 '17 at 21:22
  • Unfortunately not :( – Biggie Dec 23 '17 at 12:00

0 Answers0