mirror of
https://github.com/mpv-player/mpv
synced 2024-12-17 20:34:58 +00:00
cocoa: fix uninitialization while in fullscreen
This is only needed for switching video track with `_`, since Cocoa automatically handles cleaning up the application's presentation options when quitting the process. Fixes #1399
This commit is contained in:
parent
39548ad9e9
commit
64b6b2ea45
@ -21,5 +21,6 @@
|
||||
@interface MpvEventsView : NSView <NSDraggingDestination>
|
||||
@property(nonatomic, retain) MpvCocoaAdapter *adapter;
|
||||
- (void)setFullScreen:(BOOL)willBeFullscreen;
|
||||
- (void)clear;
|
||||
- (BOOL)canHideCursor;
|
||||
@end
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "events_view.h"
|
||||
|
||||
@interface MpvEventsView()
|
||||
@property(nonatomic, assign) BOOL clearing;
|
||||
@property(nonatomic, assign) BOOL hasMouseDown;
|
||||
@property(nonatomic, retain) NSTrackingArea *tracker;
|
||||
- (void)signalMousePosition;
|
||||
@ -36,6 +37,7 @@
|
||||
@end
|
||||
|
||||
@implementation MpvEventsView
|
||||
@synthesize clearing = _clearing;
|
||||
@synthesize adapter = _adapter;
|
||||
@synthesize tracker = _tracker;
|
||||
@synthesize hasMouseDown = _mouse_down;
|
||||
@ -90,6 +92,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clear
|
||||
{
|
||||
self.clearing = YES;
|
||||
[self exitFullScreenModeWithOptions:nil];
|
||||
}
|
||||
|
||||
// mpv uses flipped coordinates, because X11 uses those. So let's just use them
|
||||
// as well without having to do any coordinate conversion of mouse positions.
|
||||
- (BOOL)isFlipped { return YES; }
|
||||
@ -177,6 +185,10 @@
|
||||
- (void)setFrameSize:(NSSize)size
|
||||
{
|
||||
[super setFrameSize:size];
|
||||
|
||||
if (self.clearing)
|
||||
return;
|
||||
|
||||
[self signalMousePosition];
|
||||
}
|
||||
|
||||
|
@ -189,12 +189,24 @@ void vo_cocoa_register_resize_callback(struct vo *vo,
|
||||
|
||||
void vo_cocoa_uninit(struct vo *vo)
|
||||
{
|
||||
with_cocoa_lock(vo, ^{
|
||||
struct vo_cocoa_state *s = vo->cocoa;
|
||||
struct vo_cocoa_state *s = vo->cocoa;
|
||||
NSView *ev = s->view;
|
||||
|
||||
// keep the event view around for later in order to call -clear
|
||||
if (!s->embedded) {
|
||||
[ev retain];
|
||||
}
|
||||
|
||||
with_cocoa_lock_on_main_thread(vo, ^{
|
||||
enable_power_management(vo);
|
||||
cocoa_rm_fs_screen_profile_observer(vo);
|
||||
|
||||
[s->gl_ctx release];
|
||||
|
||||
// needed to stop resize events triggered by the event's view -clear
|
||||
// causing many uses after free
|
||||
[s->video removeFromSuperview];
|
||||
|
||||
[s->view removeFromSuperview];
|
||||
[s->view release];
|
||||
|
||||
@ -202,6 +214,15 @@ void vo_cocoa_uninit(struct vo *vo)
|
||||
if (s->window)
|
||||
[s->window release];
|
||||
});
|
||||
|
||||
// don't use the mutex, because at that point it could have been destroyed
|
||||
// and no one is accessing the events view anyway
|
||||
if (!s->embedded) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[(MpvEventsView *)ev clear];
|
||||
[ev release];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static int get_screen_handle(struct vo *vo, int identifier, NSWindow *window,
|
||||
|
Loading…
Reference in New Issue
Block a user