gtk2-ng/gdk/quartz/gdkglobals-quartz.c
Daemonratte 8b7fda063e quartz: map macOS 11 and newer to internal OS versions
Based on part of the MacPorts Big Sur performance patch for GIMP issue 5989.

GTK2 represents macOS 10.x releases by their minor version. Read the major version as well and map macOS 11 and newer into the same sequence so Big Sur and later releases can be detected correctly.
2026-08-04 08:45:38 +02:00

59 lines
1.8 KiB
C

/* gdkglobals-quartz.c
*
* Copyright (C) 2005 Imendio AB
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdktypes.h"
#include "gdkprivate.h"
#include "gdkquartz.h"
GdkDisplay *_gdk_display = NULL;
GdkScreen *_gdk_screen = NULL;
GdkWindow *_gdk_root = NULL;
GdkOSXVersion
gdk_quartz_osx_version (void)
{
static gint32 minor = GDK_OSX_UNSUPPORTED;
if (minor == GDK_OSX_UNSUPPORTED)
{
gint32 major = GDK_OSX_UNSUPPORTED;
OSErr err = Gestalt (gestaltSystemVersionMajor, (SInt32*)&major);
g_return_val_if_fail (err == noErr, GDK_OSX_UNSUPPORTED);
err = Gestalt (gestaltSystemVersionMinor, (SInt32*)&minor);
g_return_val_if_fail (err == noErr, GDK_OSX_UNSUPPORTED);
/* GTK2 encodes macOS 10.x releases by their minor version.
* Map macOS 11+ into the same sequence:
* 11 -> 16, 12 -> 17, 13 -> 18, ...
*/
if (major > 10)
minor = major + 5;
}
if (minor < GDK_OSX_MIN)
return GDK_OSX_UNSUPPORTED;
else if (minor > GDK_OSX_CURRENT)
return GDK_OSX_NEW;
else
return minor;
}