[vlc-devel] [PATCH 2/2] macosx: add a nag screen when executing the Intel binary on ARM-64
Marvin Scholz
epirat07 at gmail.com
Mon Nov 30 17:42:11 CET 2020
On 30 Nov 2020, at 17:20, Felix Paul Kühne wrote:
> From: Felix Paul Kühne <felix at feepk.net>
>
> ---
> modules/gui/macosx/VLCMain.m | 40
> +++++++++++++++++++++++++++++++++++-
> 1 file changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/modules/gui/macosx/VLCMain.m
> b/modules/gui/macosx/VLCMain.m
> index 3e08c48da9..6668ea456d 100644
> --- a/modules/gui/macosx/VLCMain.m
> +++ b/modules/gui/macosx/VLCMain.m
> @@ -1,7 +1,7 @@
> /*****************************************************************************
> * VLCMain.m: MacOS X interface module
> *****************************************************************************
> - * Copyright (C) 2002-2016 VLC authors and VideoLAN
> + * Copyright (C) 2002-2020 VLC authors and VideoLAN
> * $Id$
> *
> * Authors: Derk-Jan Hartman <hartman at videolan.org>
> @@ -35,6 +35,7 @@
>
> #include <stdlib.h> /* malloc(),
> free() */
> #include <string.h>
> +#include <sys/sysctl.h>
> #include <vlc_common.h>
> #include <vlc_atomic.h>
> #include <vlc_actions.h>
> @@ -319,6 +320,43 @@ -
> (void)applicationDidFinishLaunching:(NSNotification *)aNotification
> if (kidsAround && var_GetBool(p_playlist, "playlist-autostart"))
> playlist_Control(p_playlist, PLAYLIST_PLAY, true);
> PL_UNLOCK;
> +
> + /* on macOS 11 and later, check whether the user attempts to
> deploy
> + * the x86_64 binary on ARM-64 - if yes, run a nag screen */
> + if (OSX_BIGSUR_AND_HIGHER) {
> + if ([self processIsTranslated] > 0) {
> + msg_Warn(p_intf, "Process is translated!");
> + [self runNagScreen];
> + }
> + }
I think it makes sense to log it, but I am against adding a nag screen
for this, especially without a way to turn it off.
> +}
> +
> +- (int)processIsTranslated
> +{
> + int ret = 0;
> + size_t size = sizeof(ret);
> + if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0)
> == -1) {
> + if (errno == ENOENT)
> + return 0;
> + return -1;
> + }
> + return ret;
> +}
> +
> +- (void)runNagScreen
> +{
> + NSAlert *alert = [NSAlert alertWithMessageText:_NS("VLC runs in
> translation mode")
> + defaultButton:_NS("Download
> native version")
The button should be titled "Open Website" as that is what it does.
> + alternateButton:_NS("Continue")
> + otherButton:nil
> + informativeTextWithFormat:@"%@", _NS("This
> version of VLC is intended for Intel-based Macs only. For vastly
> improved performance, download VLC for Apple Silicon from our
> website.")];
> + [alert setAlertStyle:NSCriticalAlertStyle];
> +
> + NSInteger returnValue = [alert runModal];
> + if (returnValue == NSAlertDefaultReturn) {
> + NSURL *url = [NSURL URLWithString:
> @"https://www.videolan.org/vlc/download-macosx.html"];
> + [[NSWorkspace sharedWorkspace] openURL: url];
> + }
> }
>
> #pragma mark -
> --
> 2.24.3 (Apple Git-128)
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list