[banshee] GStreamerSharp: better window handle retrieval on OSX (bgo#749841)



commit ce777f1d97d022ef0d10cd5fa803648a3c6a36cf
Author: Stephan Sundermann <stephansundermann gmail com>
Date:   Fri May 29 11:28:04 2015 +0200

    GStreamerSharp: better window handle retrieval on OSX (bgo#749841)
    
    On OSX, gdk can either be used with the quartz backend or the x11 one.
    There is no function in gdk which returns which backend is currently used.
    Therefore try to get the handle from the quartz backend first (which is more
    common). A failure to find that function will result in an
    EntryPointNotFoundException.
    
    The bockbuild package always builds the quartz backend so this will always
    works for a bockbuild build. The fallback is used when someone is still
    using XQuartz and did compile all the dependencies and stuff on their own.
    
    Signed-off-by: Andrés G. Aragoneses <knocte gmail com>

 .../Banshee.GStreamerSharp/VideoManager.cs         |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs 
b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
index e15e0d2..53b21b4 100644
--- a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
+++ b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
@@ -296,6 +296,22 @@ namespace Banshee.GStreamerSharp
         {
             if (PlatformDetection.IsWindows) {
                 video_window_xid = gdk_win32_drawable_get_handle (window);
+            } else if (PlatformDetection.IsMac) {
+                // On OSX, gdk can either be used with the quartz backend or the x11 one.
+                // There is no function in gdk which returns which backend is currently used.
+                // Therefore try to get the handle from the quartz backend first (which is more common)
+                // A failure to find that function will result in a EntryPointNotFoundException
+                try {
+                    video_window_xid = gdk_quartz_window_get_nsview (window);
+                } catch (EntryPointNotFoundException ex) {
+                    // The bockbuild package always builds the quartz backend so this exception
+                    // would never happen for a bockbuild build. The fallback is used when someone is still
+                    // using XQuartz and did compile all the dependencies and stuff on their own.
+
+                    Hyena.Log.Warning (ex);
+
+                    video_window_xid = gdk_x11_window_get_xid (window);
+                }
             } else if (PlatformDetection.IsUnix) {
                     //FIXME: we should maybe stop relying on x11 
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstvideooverlay.html#GstVideoOverlay
                 video_window_xid = gdk_x11_window_get_xid (window);
@@ -303,6 +319,9 @@ namespace Banshee.GStreamerSharp
         }
 
         [DllImport ("libgdk-3-0.dll")]
+        private static extern IntPtr gdk_quartz_window_get_nsview (IntPtr drawable);
+
+        [DllImport ("libgdk-3-0.dll")]
         private static extern IntPtr gdk_x11_window_get_xid (IntPtr drawable);
 
         [DllImport ("libgdk-3-0.dll")]


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