Merge support for OS and toolkit micro versions
Closes https://github.com/wxWidgets/wxWidgets/pull/234
This commit is contained in:
@@ -139,12 +139,14 @@ wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor,
|
||||
|
||||
m_tkVersionMajor = tkMajor;
|
||||
m_tkVersionMinor = tkMinor;
|
||||
m_tkVersionMicro = -1;
|
||||
m_port = pid;
|
||||
m_usingUniversal = usingUniversal;
|
||||
|
||||
m_os = id;
|
||||
m_osVersionMajor = osMajor;
|
||||
m_osVersionMinor = osMinor;
|
||||
m_osVersionMicro = -1;
|
||||
|
||||
m_endian = endian;
|
||||
m_arch = arch;
|
||||
@@ -154,8 +156,10 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const
|
||||
{
|
||||
return m_tkVersionMajor == t.m_tkVersionMajor &&
|
||||
m_tkVersionMinor == t.m_tkVersionMinor &&
|
||||
m_tkVersionMicro == t.m_tkVersionMicro &&
|
||||
m_osVersionMajor == t.m_osVersionMajor &&
|
||||
m_osVersionMinor == t.m_osVersionMinor &&
|
||||
m_osVersionMicro == t.m_osVersionMicro &&
|
||||
m_os == t.m_os &&
|
||||
m_osDesc == t.m_osDesc &&
|
||||
m_ldi == t.m_ldi &&
|
||||
@@ -179,16 +183,18 @@ void wxPlatformInfo::InitForCurrentPlatform()
|
||||
m_port = wxPORT_UNKNOWN;
|
||||
m_usingUniversal = false;
|
||||
m_tkVersionMajor =
|
||||
m_tkVersionMinor = 0;
|
||||
m_tkVersionMinor =
|
||||
m_tkVersionMicro = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_port = traits->GetToolkitVersion(&m_tkVersionMajor, &m_tkVersionMinor);
|
||||
m_port = traits->GetToolkitVersion(&m_tkVersionMajor, &m_tkVersionMinor,
|
||||
&m_tkVersionMicro);
|
||||
m_usingUniversal = traits->IsUsingUniversalWidgets();
|
||||
m_desktopEnv = traits->GetDesktopEnvironment();
|
||||
}
|
||||
|
||||
m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor);
|
||||
m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor, &m_osVersionMicro);
|
||||
m_osDesc = wxGetOsDescription();
|
||||
m_endian = wxIsPlatformLittleEndian() ? wxENDIAN_LITTLE : wxENDIAN_BIG;
|
||||
m_arch = wxIsPlatform64Bit() ? wxARCH_64 : wxARCH_32;
|
||||
@@ -298,18 +304,20 @@ wxString wxPlatformInfo::GetEndiannessName(wxEndianness end)
|
||||
return wxEndiannessNames[end];
|
||||
}
|
||||
|
||||
bool wxPlatformInfo::CheckOSVersion(int major, int minor) const
|
||||
bool wxPlatformInfo::CheckOSVersion(int major, int minor, int micro) const
|
||||
{
|
||||
// If this instance of wxPlatformInfo has been initialized by InitForCurrentPlatform()
|
||||
// this check gets forwarded to the wxCheckOsVersion which might do more than a simple
|
||||
// number check if supported by the platform
|
||||
if (m_initializedForCurrentPlatform)
|
||||
return wxCheckOsVersion(major, minor);
|
||||
return wxCheckOsVersion(major, minor, micro);
|
||||
else
|
||||
return DoCheckVersion(GetOSMajorVersion(),
|
||||
GetOSMinorVersion(),
|
||||
GetOSMicroVersion(),
|
||||
major,
|
||||
minor);
|
||||
minor,
|
||||
micro);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -30,10 +30,13 @@
|
||||
// toolkit info
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj,
|
||||
int *verMin,
|
||||
int *verMicro) const
|
||||
{
|
||||
if ( verMaj ) *verMaj = DIRECTFB_MAJOR_VERSION;
|
||||
if ( verMin ) *verMaj = DIRECTFB_MINOR_VERSION;
|
||||
if ( verMicro ) *verMicro = DIRECTFB_MICRO_VERSION;
|
||||
|
||||
return wxPORT_DFB;
|
||||
}
|
||||
|
||||
@@ -183,12 +183,16 @@ const gchar *wx_pango_version_check (int major, int minor, int micro)
|
||||
// wxPlatformInfo-related
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj,
|
||||
int *verMin,
|
||||
int *verMicro) const
|
||||
{
|
||||
if ( verMaj )
|
||||
*verMaj = gtk_major_version;
|
||||
if ( verMin )
|
||||
*verMin = gtk_minor_version;
|
||||
if ( verMicro )
|
||||
*verMicro = gtk_micro_version;
|
||||
|
||||
return wxPORT_GTK;
|
||||
}
|
||||
|
||||
@@ -136,12 +136,16 @@ wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
|
||||
// wxPlatformInfo-related
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj,
|
||||
int *verMin,
|
||||
int *verMicro) const
|
||||
{
|
||||
if ( verMaj )
|
||||
*verMaj = gtk_major_version;
|
||||
if ( verMin )
|
||||
*verMin = gtk_minor_version;
|
||||
if ( verMicro )
|
||||
*verMicro = gtk_micro_version;
|
||||
|
||||
return wxPORT_GTK;
|
||||
}
|
||||
|
||||
@@ -176,13 +176,17 @@ void wxBell()
|
||||
XBell (wxGlobalDisplay(), 0);
|
||||
}
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj,
|
||||
int *verMin,
|
||||
int *verMicro) const
|
||||
{
|
||||
// XmVERSION and XmREVISION are defined in Xm/Xm.h
|
||||
if ( verMaj )
|
||||
*verMaj = XmVERSION;
|
||||
if ( verMin )
|
||||
*verMin = XmREVISION;
|
||||
if ( verMicro )
|
||||
*verMicro = 0;
|
||||
|
||||
return wxPORT_MOTIF;
|
||||
}
|
||||
|
||||
@@ -238,11 +238,13 @@ WXDWORD wxGUIAppTraits::WaitForThread(WXHANDLE hThread, int flags)
|
||||
}
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer,
|
||||
int *minVer,
|
||||
int *microVer) const
|
||||
{
|
||||
// on Windows, the toolkit version is the same of the OS version
|
||||
// as Windows integrates the OS kernel with the GUI toolkit.
|
||||
wxGetOsVersion(majVer, minVer);
|
||||
wxGetOsVersion(majVer, minVer, microVer);
|
||||
|
||||
return wxPORT_MSW;
|
||||
}
|
||||
|
||||
@@ -1235,7 +1235,7 @@ bool wxIsPlatform64Bit()
|
||||
#endif // Win64/Win32
|
||||
}
|
||||
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro)
|
||||
{
|
||||
static struct
|
||||
{
|
||||
@@ -1244,7 +1244,8 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
wxOperatingSystemId os;
|
||||
|
||||
int verMaj,
|
||||
verMin;
|
||||
verMin,
|
||||
verMicro;
|
||||
} s_version;
|
||||
|
||||
// query the OS info only once as it's not supposed to change
|
||||
@@ -1267,32 +1268,39 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
|
||||
s_version.verMaj = info.dwMajorVersion;
|
||||
s_version.verMin = info.dwMinorVersion;
|
||||
s_version.verMicro = info.dwBuildNumber;
|
||||
}
|
||||
|
||||
if ( verMaj )
|
||||
*verMaj = s_version.verMaj;
|
||||
if ( verMin )
|
||||
*verMin = s_version.verMin;
|
||||
if ( verMicro )
|
||||
*verMicro = s_version.verMicro;
|
||||
|
||||
return s_version.os;
|
||||
}
|
||||
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn)
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn, int microVsn)
|
||||
{
|
||||
OSVERSIONINFOEX osvi;
|
||||
wxZeroMemory(osvi);
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
|
||||
DWORDLONG const dwlConditionMask =
|
||||
::VerSetConditionMask(
|
||||
::VerSetConditionMask(
|
||||
::VerSetConditionMask(
|
||||
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
|
||||
VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||
VER_MINORVERSION, VER_GREATER_EQUAL),
|
||||
VER_BUILDNUMBER, VER_GREATER_EQUAL);
|
||||
|
||||
osvi.dwMajorVersion = majorVsn;
|
||||
osvi.dwMinorVersion = minorVsn;
|
||||
osvi.dwBuildNumber = microVsn;
|
||||
|
||||
return ::VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE;
|
||||
return ::VerifyVersionInfo(&osvi,
|
||||
VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, dwlConditionMask) != FALSE;
|
||||
}
|
||||
|
||||
wxWinVersion wxGetWinVersion()
|
||||
|
||||
@@ -28,18 +28,21 @@
|
||||
#endif
|
||||
|
||||
// our OS version is the same in non GUI and GUI cases
|
||||
wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro)
|
||||
{
|
||||
#ifdef wxHAS_NSPROCESSINFO
|
||||
if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)])
|
||||
{
|
||||
NSOperatingSystemVersion osVer = [NSProcessInfo processInfo].operatingSystemVersion;
|
||||
|
||||
if ( majorVsn != NULL )
|
||||
*majorVsn = osVer.majorVersion;
|
||||
if ( verMaj != NULL )
|
||||
*verMaj = osVer.majorVersion;
|
||||
|
||||
if ( minorVsn != NULL )
|
||||
*minorVsn = osVer.minorVersion;
|
||||
if ( verMin != NULL )
|
||||
*verMin = osVer.minorVersion;
|
||||
|
||||
if ( verMicro != NULL )
|
||||
*verMicro = osVer.patchVersion;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -47,27 +50,32 @@ wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
// On OS X versions prior to 10.10 NSProcessInfo does not provide the OS version
|
||||
// Deprecated Gestalt calls are required instead
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
SInt32 maj, min;
|
||||
SInt32 maj, min, micro;
|
||||
#ifdef __WXOSX_IPHONE__
|
||||
maj = 7;
|
||||
min = 0;
|
||||
micro = 0;
|
||||
#else
|
||||
Gestalt(gestaltSystemVersionMajor, &maj);
|
||||
Gestalt(gestaltSystemVersionMinor, &min);
|
||||
Gestalt(gestaltSystemVersionBugFix, µ);
|
||||
#endif
|
||||
wxGCC_WARNING_RESTORE()
|
||||
|
||||
if ( majorVsn != NULL )
|
||||
*majorVsn = maj;
|
||||
if ( verMaj != NULL )
|
||||
*verMaj = maj;
|
||||
|
||||
if ( minorVsn != NULL )
|
||||
*minorVsn = min;
|
||||
if ( verMin != NULL )
|
||||
*verMin = min;
|
||||
|
||||
if ( verMicro != NULL )
|
||||
*verMicro = micro;
|
||||
}
|
||||
|
||||
return wxOS_MAC_OSX_DARWIN;
|
||||
}
|
||||
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn)
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn, int microVsn)
|
||||
{
|
||||
#ifdef wxHAS_NSPROCESSINFO
|
||||
if ([NSProcessInfo instancesRespondToSelector:@selector(isOperatingSystemAtLeastVersion:)])
|
||||
@@ -75,17 +83,19 @@ bool wxCheckOsVersion(int majorVsn, int minorVsn)
|
||||
NSOperatingSystemVersion osVer;
|
||||
osVer.majorVersion = majorVsn;
|
||||
osVer.minorVersion = minorVsn;
|
||||
osVer.patchVersion = 0;
|
||||
osVer.patchVersion = microVsn;
|
||||
|
||||
return [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:osVer] != NO;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
int majorCur, minorCur;
|
||||
wxGetOsVersion(&majorCur, &minorCur);
|
||||
int majorCur, minorCur, microCur;
|
||||
wxGetOsVersion(&majorCur, &minorCur, µCur);
|
||||
|
||||
return majorCur > majorVsn || (majorCur == majorVsn && minorCur >= minorVsn);
|
||||
return majorCur > majorVsn
|
||||
|| (majorCur == majorVsn && minorCur >= minorVsn)
|
||||
|| (majorCur == majorVsn && minorCur == minorVsn && microCur >= microVsn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,10 +169,12 @@ void wxDisplaySizeMM(int *width, int *height)
|
||||
}
|
||||
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj,
|
||||
int *verMin,
|
||||
int *verMicro) const
|
||||
{
|
||||
// We suppose that toolkit version is the same as OS version under Mac
|
||||
wxGetOsVersion(verMaj, verMin);
|
||||
wxGetOsVersion(verMaj, verMin, verMicro);
|
||||
|
||||
return wxPORT_OSX;
|
||||
}
|
||||
|
||||
@@ -39,12 +39,16 @@ wxTimerImpl *wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
|
||||
|
||||
// #endif
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer,
|
||||
int *minVer,
|
||||
int *microVer) const
|
||||
{
|
||||
if ( majVer )
|
||||
*majVer = QT_VERSION >> 16;
|
||||
if ( minVer )
|
||||
*minVer = (QT_VERSION >> 8) & 0xFF;
|
||||
if ( microVer )
|
||||
*microVer = QT_VERSION & 0xFF;
|
||||
|
||||
return wxPORT_QT;
|
||||
}
|
||||
|
||||
@@ -1114,23 +1114,30 @@ wxLinuxDistributionInfo wxGetLinuxDistributionInfo()
|
||||
// these functions are in src/osx/utilsexc_base.cpp for wxMac
|
||||
#ifndef __DARWIN__
|
||||
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro)
|
||||
{
|
||||
// get OS version
|
||||
int major, minor;
|
||||
int major = -1, minor = -1, micro = -1;
|
||||
wxString release = wxGetCommandOutput(wxT("uname -r"));
|
||||
if ( release.empty() ||
|
||||
wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor) != 2 )
|
||||
if ( !release.empty() )
|
||||
{
|
||||
// failed to get version string or unrecognized format
|
||||
major =
|
||||
minor = -1;
|
||||
if ( wxSscanf(release.c_str(), wxT("%d.%d.%d"), &major, &minor, µ ) != 3 )
|
||||
{
|
||||
micro = 0;
|
||||
if ( wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor ) != 2 )
|
||||
{
|
||||
// failed to get version string or unrecognized format
|
||||
major = minor = micro = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( verMaj )
|
||||
*verMaj = major;
|
||||
if ( verMin )
|
||||
*verMin = minor;
|
||||
if ( verMicro )
|
||||
*verMicro = micro;
|
||||
|
||||
// try to understand which OS are we running
|
||||
wxString kernel = wxGetCommandOutput(wxT("uname -s"));
|
||||
@@ -1148,12 +1155,14 @@ wxString wxGetOsDescription()
|
||||
return wxGetCommandOutput(wxT("uname -s -r -m"));
|
||||
}
|
||||
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn)
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn, int microVsn)
|
||||
{
|
||||
int majorCur, minorCur;
|
||||
wxGetOsVersion(&majorCur, &minorCur);
|
||||
int majorCur, minorCur, microCur;
|
||||
wxGetOsVersion(&majorCur, &minorCur, µCur);
|
||||
|
||||
return majorCur > majorVsn || (majorCur == majorVsn && minorCur >= minorVsn);
|
||||
return majorCur > majorVsn
|
||||
|| (majorCur == majorVsn && minorCur >= minorVsn)
|
||||
|| (majorCur == majorVsn && minorCur == minorVsn && microCur >= microVsn);
|
||||
}
|
||||
|
||||
#endif // !__DARWIN__
|
||||
|
||||
@@ -100,7 +100,9 @@ void wxBell()
|
||||
XBell ((Display*) wxGetDisplay(), 0);
|
||||
}
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj,
|
||||
int *verMin,
|
||||
int *verMicro) const
|
||||
{
|
||||
// get X protocol version
|
||||
Display *display = wxGlobalDisplay();
|
||||
@@ -110,6 +112,8 @@ wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
*verMaj = ProtocolVersion (display);
|
||||
if ( verMin )
|
||||
*verMin = ProtocolRevision (display);
|
||||
if ( verMicro )
|
||||
*verMicro = 0;
|
||||
}
|
||||
|
||||
return wxPORT_X11;
|
||||
|
||||
Reference in New Issue
Block a user