mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
cocoa: add an option to disable the native macOS fullscreen
Fixes #4014
This commit is contained in:
@@ -2477,6 +2477,10 @@ Window
|
||||
as having the same size as on none-HiDPI resolutions. This is the default OS X
|
||||
behavior.
|
||||
|
||||
``--native-fs``, ``--no-native-fs``
|
||||
(OS X only)
|
||||
Uses the native fullscreen mechanism of the OS (default: yes).
|
||||
|
||||
``--monitorpixelaspect=<ratio>``
|
||||
Set the aspect of a single pixel of your monitor or TV screen (default:
|
||||
1). A value of 1 means square pixels (correct for (almost?) all LCDs). See
|
||||
|
||||
@@ -162,6 +162,7 @@ static const m_option_t mp_vo_opt_list[] = {
|
||||
OPT_FLAG("keepaspect", keepaspect, UPDATE_VIDEOPOS),
|
||||
OPT_FLAG("keepaspect-window", keepaspect_window, 0),
|
||||
OPT_FLAG("hidpi-window-scale", hidpi_window_scale, 0),
|
||||
OPT_FLAG("native-fs", native_fs, 0),
|
||||
#if HAVE_X11
|
||||
OPT_CHOICE("x11-netwm", x11_netwm, 0,
|
||||
({"auto", 0}, {"no", -1}, {"yes", 1})),
|
||||
@@ -196,6 +197,7 @@ const struct m_sub_options vo_sub_opts = {
|
||||
.keepaspect = 1,
|
||||
.keepaspect_window = 1,
|
||||
.hidpi_window_scale = 1,
|
||||
.native_fs = 1,
|
||||
.taskbar_progress = 1,
|
||||
.snap_window = 0,
|
||||
.border = 1,
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef struct mp_vo_opts {
|
||||
int keepaspect;
|
||||
int keepaspect_window;
|
||||
int hidpi_window_scale;
|
||||
int native_fs;
|
||||
|
||||
int64_t WinID;
|
||||
|
||||
|
||||
@@ -28,8 +28,11 @@
|
||||
- (void)didChangeWindowedScreenProfile:(NSNotification *)notification;
|
||||
- (void)performAsyncResize:(NSSize)size;
|
||||
- (void)windowDidChangePhysicalScreen;
|
||||
- (void)windowDidEnterFullScreen;
|
||||
- (void)windowDidExitFullScreen;
|
||||
|
||||
- (BOOL)isInFullScreenMode;
|
||||
- (BOOL)wantsNativeFullscreen;
|
||||
- (BOOL)keyboardEnabled;
|
||||
- (BOOL)mouseEnabled;
|
||||
|
||||
|
||||
@@ -106,7 +106,8 @@
|
||||
[self setFrame:frame display:YES];
|
||||
}
|
||||
|
||||
[super toggleFullScreen:sender];
|
||||
if ([self.adapter wantsNativeFullscreen])
|
||||
[super toggleFullScreen:sender];
|
||||
|
||||
if (![self.adapter isInFullScreenMode]) {
|
||||
[self setToFullScreen];
|
||||
@@ -119,7 +120,16 @@
|
||||
{
|
||||
[self setStyleMask:([self styleMask] | NSWindowStyleMaskFullScreen)];
|
||||
NSRect frame = [[self targetScreen] frame];
|
||||
[self setFrame:frame display:YES];
|
||||
|
||||
if ([self.adapter wantsNativeFullscreen]) {
|
||||
[self setFrame:frame display:YES];
|
||||
} else {
|
||||
[NSApp setPresentationOptions:NSApplicationPresentationAutoHideMenuBar|
|
||||
NSApplicationPresentationAutoHideDock];
|
||||
[self setFrame:frame display:YES];
|
||||
_is_animating = 0;
|
||||
[self.adapter windowDidEnterFullScreen];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setToWindow
|
||||
@@ -127,9 +137,19 @@
|
||||
[self setStyleMask:([self styleMask] & ~NSWindowStyleMaskFullScreen)];
|
||||
NSRect frame = [self calculateWindowPositionForScreen:[self targetScreen]
|
||||
withoutBounds:[[self targetScreen] isEqual:[self screen]]];
|
||||
[self setFrame:frame display:YES];
|
||||
[self setContentAspectRatio:_unfs_content_frame.size];
|
||||
[self setCenteredContentSize:_unfs_content_frame.size];
|
||||
|
||||
if ([self.adapter wantsNativeFullscreen]) {
|
||||
[self setFrame:frame display:YES];
|
||||
[self setContentAspectRatio:_unfs_content_frame.size];
|
||||
[self setCenteredContentSize:_unfs_content_frame.size];
|
||||
} else {
|
||||
[NSApp setPresentationOptions:NSApplicationPresentationDefault];
|
||||
[self setFrame:frame display:YES];
|
||||
[self setContentAspectRatio:_unfs_content_frame.size];
|
||||
[self setCenteredContentSize:_unfs_content_frame.size];
|
||||
_is_animating = 0;
|
||||
[self.adapter windowDidExitFullScreen];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)customWindowsToEnterFullScreenForWindow:(NSWindow *)window
|
||||
@@ -150,13 +170,13 @@
|
||||
- (void)windowDidEnterFullScreen:(NSNotification *)notification
|
||||
{
|
||||
_is_animating = 0;
|
||||
[self.adapter windowDidEnterFullScreen:notification];
|
||||
[self.adapter windowDidEnterFullScreen];
|
||||
}
|
||||
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)notification
|
||||
{
|
||||
_is_animating = 0;
|
||||
[self.adapter windowDidExitFullScreen:notification];
|
||||
[self.adapter windowDidExitFullScreen];
|
||||
}
|
||||
|
||||
- (void)windowWillEnterFullScreen:(NSNotification *)notification
|
||||
@@ -390,7 +410,8 @@
|
||||
if (NSMaxX(nf) < NSMinX(vf))
|
||||
nf.origin.x = NSMinX(vf);
|
||||
|
||||
if (NSHeight(nf) < NSHeight(vf) && NSHeight(of) > NSHeight(vf))
|
||||
if (NSHeight(nf) < NSHeight(vf) && NSHeight(of) > NSHeight(vf) &&
|
||||
![self.adapter isInFullScreenMode])
|
||||
// If the window height is smaller than the visible frame, but it was
|
||||
// bigger previously recenter the smaller window vertically. This is
|
||||
// needed to counter the 'snap to top' behaviour.
|
||||
|
||||
@@ -1014,6 +1014,11 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
|
||||
return self.vout->cocoa->fullscreen;
|
||||
}
|
||||
|
||||
- (BOOL)wantsNativeFullscreen
|
||||
{
|
||||
return self.vout->opts->native_fs;
|
||||
}
|
||||
|
||||
- (NSScreen *)getTargetScreen
|
||||
{
|
||||
struct vo_cocoa_state *s = self.vout->cocoa;
|
||||
@@ -1039,7 +1044,7 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
|
||||
flag_events(self.vout, VO_EVENT_WIN_STATE);
|
||||
}
|
||||
|
||||
- (void)windowDidEnterFullScreen:(NSNotification *)notification
|
||||
- (void)windowDidEnterFullScreen
|
||||
{
|
||||
struct vo_cocoa_state *s = self.vout->cocoa;
|
||||
s->fullscreen = 1;
|
||||
@@ -1047,7 +1052,7 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
|
||||
vo_cocoa_anim_unlock(self.vout);
|
||||
}
|
||||
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)notification
|
||||
- (void)windowDidExitFullScreen
|
||||
{
|
||||
struct vo_cocoa_state *s = self.vout->cocoa;
|
||||
s->fullscreen = 0;
|
||||
|
||||
Reference in New Issue
Block a user