1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-09-28 11:17:46 +00:00

Merge pull request #92 from familygw/development

Replaced way to detect macOS version and screen configuration.
This commit is contained in:
Fellippe Heitor 2020-12-21 11:25:33 -03:00 committed by GitHub
commit ab241badbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,7 @@
#ifdef QB64_MACOSX
#include <sys/sysctl.h>
#endif
// trigger recompilation = 3
int32 displayorder_screen=1;
@ -530,8 +534,35 @@ void sub__glrender(int32 method){
#ifdef QB64_MACOSX
if (scale_factor==0) {
scale_factor=1;
if ((system("sw_vers -productVersion | grep -E '^(10\.15\.)'") == 0) && ((system("system_profiler SPDisplaysDataType | grep Retina") == 0) || (system("system_profiler SPDisplaysDataType | grep 5K") == 0))) scale_factor=2;
// by default scale_factor should be 1, but in macOS Catalina (10.15.*) scale_factor must be setted in 2
// * in cases where the app is executed on system with Retina Display
scale_factor = 1; // by default
// lookup for retina/5k output from system_profiler (storing all outpun in stream)
bool b_isRetina, b_is5k;
FILE* consoleStream = popen("system_profiler SPDisplaysDataType", "r");
if (consoleStream) {
char buffer[128];
while (!feof(consoleStream)) {
if (fgets(buffer, 128, consoleStream) != NULL) {
string szBuffer(buffer);
if (!b_isRetina) b_isRetina = (szBuffer.rfind("Retina") != ULONG_MAX);
if (!b_is5k) b_is5k = (szBuffer.rfind("5K") != ULONG_MAX);
}
}
}
pclose(consoleStream);
if (b_isRetina || b_is5k) {
// apply only factor = 2 if macOS is Catalina (11.15.* // kern.osrelease 19.*)
char str[256];
size_t size = sizeof(str);
int ret = sysctlbyname("kern.osrelease", str, &size, NULL, 0);
string sz_osrelease(str);
if (sz_osrelease.rfind("19.") == 0) scale_factor=2;
}
}
#else
scale_factor=1;