aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tarasov <anton.tarasov@jetbrains.com>2017-11-16 16:16:20 +0300
committerAnton Tarasov <anton.tarasov@jetbrains.com>2017-11-16 16:32:37 +0300
commitad74351e807056b87e2ffb06629cd257ffed0e3c (patch)
tree2d0e4afa06da4d34076a4fb6a6a552e84ddc69db
parent9fe5e1b4823df689f165bed8c62b0efb510b16fd (diff)
downloadjdk8u_jdk-ad74351e807056b87e2ffb06629cd257ffed0e3c.tar.gz
JRE-580 [windows] low-res app icon on HiDPI displaysjb8u152-b1056.12
(cherry picked from commit b446cd4)
-rw-r--r--src/windows/classes/sun/awt/windows/WToolkit.java6
-rw-r--r--src/windows/native/sun/windows/awt_Toolkit.cpp56
-rw-r--r--src/windows/native/sun/windows/awt_Toolkit.h2
3 files changed, 62 insertions, 2 deletions
diff --git a/src/windows/classes/sun/awt/windows/WToolkit.java b/src/windows/classes/sun/awt/windows/WToolkit.java
index c6bfff0f04..33518f2043 100644
--- a/src/windows/classes/sun/awt/windows/WToolkit.java
+++ b/src/windows/classes/sun/awt/windows/WToolkit.java
@@ -129,6 +129,12 @@ public final class WToolkit extends SunToolkit implements Runnable {
{
@Override
public Void run() {
+ // By default, java.exe & awt.dll contains standard JDK icon resource.
+ // JBRE supports "jbre.win.app.icon.id" property which identifies
+ // the resource id of the icon packed into the executable launcher
+ // other than java.exe, e.g. idea.exe.
+ System.setProperty("jbre.win.app.icon.supported", "true");
+
String browserProp = System.getProperty("browser");
if (browserProp != null && browserProp.equals("sun.plugin")) {
disableCustomPalette();
diff --git a/src/windows/native/sun/windows/awt_Toolkit.cpp b/src/windows/native/sun/windows/awt_Toolkit.cpp
index afa0f6f1d3..242c403e4a 100644
--- a/src/windows/native/sun/windows/awt_Toolkit.cpp
+++ b/src/windows/native/sun/windows/awt_Toolkit.cpp
@@ -1629,9 +1629,55 @@ AwtObject* AwtToolkit::LookupCmdID(UINT id)
return m_cmdIDs->Lookup(id);
}
+bool AwtToolkit::GetIntegerProperty(LPTSTR prop, int& value)
+{
+ JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+ if (!env) return false;
+
+ static jclass cInteger = env->FindClass("java/lang/Integer");
+ DASSERT(cInteger);
+ static jmethodID mGetInteger = env->GetStaticMethodID(cInteger, "getInteger", "(Ljava/lang/String;)Ljava/lang/Integer;");
+ DASSERT(mGetInteger);
+
+ jstring propStr = JNU_NewStringPlatform(env, prop);
+ jobject jInt = env->CallStaticObjectMethod(cInteger, mGetInteger, propStr);
+ env->DeleteLocalRef(propStr);
+ if (!jInt) return false;
+
+ static jmethodID mIntValue = env->GetMethodID(cInteger, "intValue", "()I");
+ DASSERT(mIntValue);
+
+ value = (int)env->CallIntMethod(jInt, mIntValue);
+ env->DeleteLocalRef(jInt);
+ if (safe_ExceptionOccurred(env)) return false;
+ return true;
+}
+
+static bool GetWinAppIconID(int& id)
+{
+ static CriticalSection lock;
+ CriticalSection::Lock l(lock);
+
+ static bool initialized = false;
+ static int* iconID;
+ if (!initialized) {
+ initialized = true;
+ int v;
+ if (AwtToolkit::GetIntegerProperty(TEXT("jbre.win.app.icon.id"), v)) iconID = new int(v);
+ }
+ if (!iconID) return false;
+ id = *iconID;
+ return true;
+}
+
HICON AwtToolkit::GetAwtIcon()
{
- return ::LoadIcon(GetModuleHandle(), TEXT("AWT_ICON"));
+ int iconID;
+ if (GetWinAppIconID(iconID)) {
+ return ::LoadIcon(::GetModuleHandle(NULL), MAKEINTRESOURCE(iconID));
+ } else {
+ return ::LoadIcon(GetModuleHandle(), TEXT("AWT_ICON"));
+ }
}
HICON AwtToolkit::GetAwtIconSm()
@@ -1645,7 +1691,13 @@ HICON AwtToolkit::GetAwtIconSm()
// Fixed 6364216: LoadImage() may leak memory
if (defaultIconSm == NULL || smx != prevSmx || smy != prevSmy) {
- defaultIconSm = (HICON)LoadImage(GetModuleHandle(), TEXT("AWT_ICON"), IMAGE_ICON, smx, smy, 0);
+ int iconID;
+ if (GetWinAppIconID(iconID)) {
+ // loads the best fitting resolution icon from the resource
+ defaultIconSm = ::LoadIcon(::GetModuleHandle(NULL), MAKEINTRESOURCE(iconID));
+ } else {
+ defaultIconSm = (HICON)LoadImage(GetModuleHandle(), TEXT("AWT_ICON"), IMAGE_ICON, smx, smy, 0);
+ }
prevSmx = smx;
prevSmy = smy;
}
diff --git a/src/windows/native/sun/windows/awt_Toolkit.h b/src/windows/native/sun/windows/awt_Toolkit.h
index 13be45a0cf..65ebca8a36 100644
--- a/src/windows/native/sun/windows/awt_Toolkit.h
+++ b/src/windows/native/sun/windows/awt_Toolkit.h
@@ -375,6 +375,8 @@ public:
static void SetBusy(BOOL busy);
+ static bool GetIntegerProperty(LPTSTR prop, int& value);
+
/* Set and get the default input method Window handler. */
INLINE void SetInputMethodWindow(HWND inputMethodHWnd) { m_inputMethodHWnd = inputMethodHWnd; }
INLINE HWND GetInputMethodWindow() { return m_inputMethodHWnd; }