Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-3592

Workarounds for various JDK Windows LAF bugs on HiDPI screens

    XMLWordPrintableJSON

Details

    Description

      Provide workarounds to three JDK bugs that caused the Windows LAF to be unusable on many HiDPI configurations, typically when an external monitor (or projector) is involved, or is disconnected or connected.

      1. In certain configurations, the GUI font size would be either way too large or way too small. (I can't remember exactly which configurations caused this, but going through the manual test case list below will trigger it several times.)
      2. In multi-monitor configurations that involve one HiDPI screen and one regular screen, the size of controls drawn by the OS, such as checkboxes and outline expansion handles, will be incorrect unless the HiDPI screen was the main display at login. I earlier reported this as a JDK bug at https://bugs.openjdk.java.net/browse/JDK-8211715 . (Note that there are a few icons which cannot be fixed using the UIDefaults approach taken here, e.g. checkmarks in JCheckBoxMenuItem.) In some cases, the LAF would previously end up scaling the control images received from the OS using a poor image scaling interpolation; the supplied patch improves the scaling quality in these cases.
      3. On non-integral scaling levels, e.g. 150%, borders around text components will be of uneven thickness due to rounding error. This patch fixes that. This also happens to JComboBox, but in that case cannot be fixed with a simple patch, since that one does not take its border from UIDefaults.

      I will provide a PR with workarounds.

      Below is a manual test plan that I used to test these patches, on Windows 10. A laptop and one external monitor was used for these tests. After each line in the test plan, the patch is confirmed to work. In most of these cases there is some kind of improvement in behavior from the patch--either a corrected control/font size or at least an improvement in control icon scaling interpolation quality.

      • main display laptop at Windows login (laptop 200%/external 100%)
      • change main display to external monitor while running app
      • restart app
      • change 100% to 150% while running app
      • restart app
      • log out and in again (of Windows--this makes a difference!)
      • change 150% to 100% while running app
      • restart app
      • main display external monitor at login (laptop 200%/external 100%)
      • change main display to laptop while running app
      • restart app
      • change 100% to 150% while running app
      • restart app
      • log out and in again
      • change 150% to 100% while running app
      • restart app
      • change 200% to 150% while running app
      • restart app
      • main display laptop at login (laptop 200%/external 100%), then disconnect external before running app
      • reconnect external while running app
      • restart app
      • log out, disconnect external, log in
      • reconnect external while running app
      • restart app
      • disconnect external while running app
      • main display external monitor at login (laptop 200%/external 100%), then disconnect external while running app
      • reconnect external while running app
      • restart app
      • log out, disconnect external, log in
      • reconnect external while running app
      • restart app
      • main display laptop at login (laptop 200%/external 150%), then disconnect external before running
      • reconnect external while running app
      • log out, disconnect external, log in
      • reconnect external while running app
      • restart app
      • main display external monitor at login (laptop 200%/external 150%), then disconnect external before running
      • reconnect external while running app
      • restart app
      • log out, disconnect external, log in
      • reconnect external while running app
      • restart app
      • main display external at login (laptop 150%, external 100%)
      • change 100% to 150% while running app
      • restart app
      • change main display to laptop (200%), set external display to 100%, log out, disconnect external, log in, run app
      • reconnect external while running app (will be 100%)
      • close laptop lid (will switch to external display)

      Attachments

        1. WindowsSwingMultiMonitorTest.png
          196 kB
          Eirik Bakke
        2. Problem 3, uneven text component borders.png
          224 kB
          Eirik Bakke
        3. Problem 2, OS controls wrong size (after patch).png
          203 kB
          Eirik Bakke
        4. Problem 1, incorrect font size.png
          252 kB
          Eirik Bakke
        5. Problem 2, OS controls wrong size (before patch).png
          212 kB
          Eirik Bakke

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ebakke Eirik Bakke
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h
                  3h