mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
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/6103>
This commit is contained in:
parent
a3c474acf4
commit
2f4e8d14cf
2 changed files with 18 additions and 9 deletions
|
@ -236,6 +236,8 @@ gst_gl_window_cocoa_create_window (GstGLWindowCocoa *window_cocoa)
|
||||||
gst_gl_window_cocoa_set_window_handle (window,
|
gst_gl_window_cocoa_set_window_handle (window,
|
||||||
(guintptr) priv->external_view);
|
(guintptr) priv->external_view);
|
||||||
|
|
||||||
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,6 @@ static void
|
||||||
gst_osx_video_sink_call_from_main_thread(GstOSXVideoSink *osxvideosink,
|
gst_osx_video_sink_call_from_main_thread(GstOSXVideoSink *osxvideosink,
|
||||||
NSObject * object, SEL function, NSObject *data, BOOL waitUntilDone)
|
NSObject * object, SEL function, NSObject *data, BOOL waitUntilDone)
|
||||||
{
|
{
|
||||||
|
|
||||||
NSThread *thread;
|
NSThread *thread;
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
@ -276,15 +275,19 @@ gst_osx_video_sink_osxwindow_create (GstOSXVideoSink * osxvideosink, gint width,
|
||||||
* from the main thread
|
* from the main thread
|
||||||
*/
|
*/
|
||||||
GST_INFO_OBJECT (osxvideosink, "we have a superview, adding our view to it");
|
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);
|
@selector(addToSuperview:), osxvideosink->superview, NO);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
gst_osx_video_sink_call_from_main_thread(osxvideosink,
|
gst_osx_video_sink_call_from_main_thread (osxvideosink,
|
||||||
osxvideosink->osxvideosinkobject,
|
osxvideosink->osxvideosinkobject,
|
||||||
@selector(createInternalWindow), nil, YES);
|
@selector(createInternalWindow), nil, YES);
|
||||||
GST_INFO_OBJECT (osxvideosink, "No superview, creating an internal window.");
|
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)];
|
[osxwindow->gstview setNavigation: GST_NAVIGATION(osxvideosink)];
|
||||||
[osxvideosink->osxwindow->gstview setKeepAspectRatio: osxvideosink->keep_par];
|
[osxvideosink->osxwindow->gstview setKeepAspectRatio: osxvideosink->keep_par];
|
||||||
|
|
||||||
|
@ -301,7 +304,7 @@ gst_osx_video_sink_osxwindow_destroy (GstOSXVideoSink * osxvideosink)
|
||||||
g_return_if_fail (GST_IS_OSX_VIDEO_SINK (osxvideosink));
|
g_return_if_fail (GST_IS_OSX_VIDEO_SINK (osxvideosink));
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
gst_osx_video_sink_call_from_main_thread(osxvideosink,
|
gst_osx_video_sink_call_from_main_thread (osxvideosink,
|
||||||
osxvideosink->osxvideosinkobject,
|
osxvideosink->osxvideosinkobject,
|
||||||
@selector(destroy), (id) nil, YES);
|
@selector(destroy), (id) nil, YES);
|
||||||
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
#ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
|
||||||
|
@ -432,7 +435,7 @@ gst_osx_video_sink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
|
||||||
|
|
||||||
GST_DEBUG ("show_frame");
|
GST_DEBUG ("show_frame");
|
||||||
bufferobject = [[GstBufferObject alloc] initWithBuffer:buf];
|
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,
|
osxvideosink->osxvideosinkobject,
|
||||||
@selector(showFrame:), bufferobject, NO);
|
@selector(showFrame:), bufferobject, NO);
|
||||||
[pool release];
|
[pool release];
|
||||||
|
@ -656,7 +659,7 @@ gst_osx_video_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle
|
||||||
GstOSXVideoSink *osxvideosink = GST_OSX_VIDEO_SINK (overlay);
|
GstOSXVideoSink *osxvideosink = GST_OSX_VIDEO_SINK (overlay);
|
||||||
NSView *view = (NSView *) handle_id;
|
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,
|
osxvideosink->osxvideosinkobject,
|
||||||
@selector(setView:), view, YES);
|
@selector(setView:), view, YES);
|
||||||
}
|
}
|
||||||
|
@ -739,7 +742,7 @@ gst_osx_video_sink_get_type (void)
|
||||||
if (!osxvideosink->osxwindow->closed) {
|
if (!osxvideosink->osxwindow->closed) {
|
||||||
osxvideosink->osxwindow->closed = TRUE;
|
osxvideosink->osxwindow->closed = TRUE;
|
||||||
GST_ELEMENT_ERROR (osxvideosink, RESOURCE, NOT_FOUND, ("Output window was closed"), (NULL));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,6 +803,11 @@ gst_osx_video_sink_get_type (void)
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setActivationPolicy
|
||||||
|
{
|
||||||
|
[NSApp setActivationPolicy: NSApplicationActivationPolicyRegular];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setView: (NSView*)view
|
- (void) setView: (NSView*)view
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
@ -931,7 +939,7 @@ no_texture_buffer:
|
||||||
g_free (osxwindow);
|
g_free (osxwindow);
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (osxvideosink);
|
GST_OBJECT_UNLOCK (osxvideosink);
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -994,7 +1002,6 @@ no_texture_buffer:
|
||||||
static gboolean
|
static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!gst_element_register (plugin, "osxvideosink",
|
if (!gst_element_register (plugin, "osxvideosink",
|
||||||
GST_RANK_MARGINAL, GST_TYPE_OSX_VIDEO_SINK))
|
GST_RANK_MARGINAL, GST_TYPE_OSX_VIDEO_SINK))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in a new issue