United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6395346 Need to make Java process High-DPI-aware on Windows Vista
6395346 : Need to make Java process High-DPI-aware on Windows Vista

Details
Type:
Bug
Submit Date:
2006-03-08
Status:
Resolved
Updated Date:
2008-02-06
Project Name:
JDK
Resolved Date:
2006-05-26
Component:
client-libs
OS:
windows_vista
Sub-Component:
2d
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
6

Related Reports
Backport:
Backport:
Duplicate:
Relates:
Relates:

Sub Tasks

Description
Running Mustang on Windows Vista (current build 5308) with non-default dpi
setting will cause Java applications to be scaled by the window display manager,
making the contents of Java-created windows blurry. The OS also reports the dpi of 96 to
the unaware apps.

Java process needs to signal to the OS that it's high-dpi aware to prevent this
from happening.

Here are some relevant screenshots:
  http://j2se.sfbay.sun.com/web/bin/view/Java2D/MicrosoftVista

                                    

Comments
EVALUATION

More clarifications on the fix:
On Windows Vista we need to signal to the OS that our application is High-DPI aware by calling a Win32 function ::SetProcessDPIAware().
 
But since calling this method changes the "high dpi-awareness" property of the
process we need to be careful when we can safely call it without
inadvertenly changing parent's process status.
 
We have determined that we could only call it when a java process is started
from one of our known launchers (java, javaw, javaws, etc), and not
in case of java plugin, or other embedded scenarios.

We've also added the following public property for controlling 
dpi-awareness:
Property usage:
  -Dsun.java2d.dpiaware=[true|false]
 
This property flag overrides the default behavior in regards
to marking Java process High DPI aware on Windows Vista. By default
the process is only marked as High DPI aware if it is started from one
of the standard launchers (java.exe, javaw.exe, jconsole.exe, etc).
 
If the property is set to "true", the java process will be marked as DPI aware
regardless of the way it was launched.
If the property is set to "false", the java process will not be marked as
DPI aware.
 
Note that High DPI-awareness is inherited from the parent process,
so the java process started by the java plugin will inherit it from the
browser. This means that there is no need for changing the default
for plugin using the property.
 
This property is ignored on any OS other than Windows Vista.
                                     
2006-05-26
SUGGESTED FIX

http://javaweb.sfbay/jcg/1.6.0-mustang/2D/6395346/
                                     
2006-05-02
SUGGESTED FIX

old suggested fix removed
                                     
2006-03-08
EVALUATION

There's a not well-documented call Win32 API call SetProcessDPIAware() which
signals that the process should not be scaled by the window manager.

Calling this function makes java applications look much better, especially in
Windows look and feel where we scale the font size according to the os-reported
DPI.
                                     
2006-03-08



Hardware and Software, Engineered to Work Together