Commit 30ca4624 authored by Anton Tarasov's avatar Anton Tarasov
Browse files

IDEA-164566 [detect JBRE from launcher]

parent a3a3310f
Showing with 13 additions and 6 deletions
+13 -6
No preview for this file type
No preview for this file type
...@@ -555,17 +555,24 @@ bool LoadJVMLibrary() ...@@ -555,17 +555,24 @@ bool LoadJVMLibrary()
return true; return true;
} }
bool IsHiDPIJBRE() // JetBrains RE supporting HiDPI bool IsJBRE()
{ {
if (!env) return false; if (!env) return false;
jclass cls = env->FindClass("sun/java2d/SunGraphicsEnvironment"); jclass cls = env->FindClass("java/lang/System");
if (!cls) return false; if (!cls) return false;
jmethodID method = env->GetMethodID(cls, "isUIScaleOn", "()Z"); jmethodID method = env->GetStaticMethodID(cls, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
if (!method) return false; if (!method) return false;
return true; jstring jvendor = (jstring)env->CallStaticObjectMethod(cls, method, env->NewStringUTF("java.vendor"));
if (!jvendor) return false;
const char *cvendor = env->GetStringUTFChars(jvendor, NULL);
bool isJB = strstr(cvendor, "JetBrains") != NULL;
env->ReleaseStringUTFChars(jvendor, cvendor);
return isJB;
} }
void SetProcessDPIAwareProperty() void SetProcessDPIAwareProperty()
...@@ -612,8 +619,8 @@ bool CreateJVM() ...@@ -612,8 +619,8 @@ bool CreateJVM()
MessageBoxA(NULL, buf.str().c_str(), error.c_str(), MB_OK); MessageBoxA(NULL, buf.str().c_str(), error.c_str(), MB_OK);
} }
// Set DPI-awareness here or let HiDPI JBRE do that. // Set DPI-awareness here or let JBRE do that.
if (!IsHiDPIJBRE()) SetProcessDPIAwareProperty(); if (!IsJBRE()) SetProcessDPIAwareProperty();
return result == JNI_OK; return result == JNI_OK;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment