diff options
author | Piotr Brzeziński <piotr@centricular.com> | 2023-05-11 20:01:45 +0200 |
---|---|---|
committer | Piotr Brzeziński <piotr@centricular.com> | 2023-05-12 01:14:44 +0200 |
commit | 5e45a1b1bd0ec4355346c60ef40c14fa91aa9b6c (patch) | |
tree | 57a3c003d9151d5f1a6ce3a1edbecab97c6cf69b | |
parent | 1815061e26db11c5e8cef35e7b5e3e3fb9eb7017 (diff) | |
download | gstreamer-5e45a1b1bd0ec4355346c60ef40c14fa91aa9b6c.tar.gz |
macos: Set activation policy in osxvideosink and glimagesink
Upon creating a window, glimagesink and osxvideosink now set the policy to
NSApplicationActivationPolicyRegular, which lets us show an icon in the Dock
for convenience and appear in the top menu bar like other apps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4573>
-rw-r--r-- | subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m | 2 | ||||
-rw-r--r-- | subprojects/gst-plugins-good/sys/osxvideo/osxvideosink.m | 23 |
2 files changed, 17 insertions, 8 deletions
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m b/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m index 95e8e9170a..3a0371588f 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m @@ -236,6 +236,8 @@ gst_gl_window_cocoa_create_window (GstGLWindowCocoa *window_cocoa) gst_gl_window_cocoa_set_window_handle (window, (guintptr) priv->external_view); + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + return TRUE; } diff --git a/subprojects/gst-plugins-good/sys/osxvideo/osxvideosink.m b/subprojects/gst-plugins-good/sys/osxvideo/osxvideosink.m index 1669b961a3..a654ef8eaf 100644 --- a/subprojects/gst-plugins-good/sys/osxvideo/osxvideosink.m +++ b/subprojects/gst-plugins-good/sys/osxvideo/osxvideosink.m @@ -84,7 +84,6 @@ static void gst_osx_video_sink_call_from_main_thread(GstOSXVideoSink *osxvideosink, NSObject * object, SEL function, NSObject *data, BOOL waitUntilDone) { - NSThread *thread; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -139,15 +138,19 @@ gst_osx_video_sink_osxwindow_create (GstOSXVideoSink * osxvideosink, gint width, * from the main thread */ GST_INFO_OBJECT (osxvideosink, "we have a superview, adding our view to it"); - gst_osx_video_sink_call_from_main_thread(osxvideosink, osxwindow->gstview, + gst_osx_video_sink_call_from_main_thread (osxvideosink, osxwindow->gstview, @selector(addToSuperview:), osxvideosink->superview, NO); } else { - gst_osx_video_sink_call_from_main_thread(osxvideosink, + gst_osx_video_sink_call_from_main_thread (osxvideosink, osxvideosink->osxvideosinkobject, @selector(createInternalWindow), nil, YES); GST_INFO_OBJECT (osxvideosink, "No superview, creating an internal window."); } + + gst_osx_video_sink_call_from_main_thread (osxvideosink, osxvideosink->osxvideosinkobject, + @selector(setActivationPolicy), nil, YES); + [osxwindow->gstview setNavigation: GST_NAVIGATION(osxvideosink)]; [osxvideosink->osxwindow->gstview setKeepAspectRatio: osxvideosink->keep_par]; @@ -164,7 +167,7 @@ gst_osx_video_sink_osxwindow_destroy (GstOSXVideoSink * osxvideosink) g_return_if_fail (GST_IS_OSX_VIDEO_SINK (osxvideosink)); pool = [[NSAutoreleasePool alloc] init]; - gst_osx_video_sink_call_from_main_thread(osxvideosink, + gst_osx_video_sink_call_from_main_thread (osxvideosink, osxvideosink->osxvideosinkobject, @selector(destroy), (id) nil, YES); [pool release]; @@ -292,7 +295,7 @@ gst_osx_video_sink_show_frame (GstBaseSink * bsink, GstBuffer * buf) GST_DEBUG ("show_frame"); bufferobject = [[GstBufferObject alloc] initWithBuffer:buf]; - gst_osx_video_sink_call_from_main_thread(osxvideosink, + gst_osx_video_sink_call_from_main_thread (osxvideosink, osxvideosink->osxvideosinkobject, @selector(showFrame:), bufferobject, NO); [pool release]; @@ -521,7 +524,7 @@ gst_osx_video_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle GstOSXVideoSink *osxvideosink = GST_OSX_VIDEO_SINK (overlay); NSView *view = (NSView *) handle_id; - gst_osx_video_sink_call_from_main_thread(osxvideosink, + gst_osx_video_sink_call_from_main_thread (osxvideosink, osxvideosink->osxvideosinkobject, @selector(setView:), view, YES); } @@ -604,7 +607,7 @@ gst_osx_video_sink_get_type (void) if (!osxvideosink->osxwindow->closed) { osxvideosink->osxwindow->closed = TRUE; GST_ELEMENT_ERROR (osxvideosink, RESOURCE, NOT_FOUND, ("Output window was closed"), (NULL)); - gst_osx_video_sink_osxwindow_destroy(osxvideosink); + gst_osx_video_sink_osxwindow_destroy (osxvideosink); } } @@ -659,6 +662,11 @@ gst_osx_video_sink_get_type (void) } +- (void) setActivationPolicy +{ + [NSApp setActivationPolicy: NSApplicationActivationPolicyRegular]; +} + - (void) setView: (NSView*)view { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -814,7 +822,6 @@ no_texture_buffer: static gboolean plugin_init (GstPlugin * plugin) { - if (!gst_element_register (plugin, "osxvideosink", GST_RANK_MARGINAL, GST_TYPE_OSX_VIDEO_SINK)) return FALSE; |