JDK-8022810 : Cannot list all the available display modes on Ubuntu linux in case of two screen devices
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2013-08-12
  • Updated: 2017-04-20
  • Resolved: 2016-07-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b127Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Please use the following simple test program to reproduce:

import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;
import java.awt.DisplayMode;

public class Test {

     public static void main(String[] args) {

         GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();

         GraphicsDevice devices[] = env.getScreenDevices();
         for (int d = 0; d < devices.length; ++d) {
             GraphicsDevice dev = devices[d];
             System.out.println("Device: " + dev.toString());
             DisplayMode modes[] = dev.getDisplayModes();
             System.out.println("Resolutions:");
             for (int m = 0; m < modes.length; ++m) {
                 System.out.println(modes[m].getHeight() + "x" + modes[m].getWidth());
             }
         }
     }
}


Compile and run it on a system with two displays. Here is output when both display are switched on (note: only current resolutions are listed):
Device: X11GraphicsDevice[screen=0]
Resolutions:
966x1280
Device: X11GraphicsDevice[screen=1]
Resolutions:
920x1280

Here is a responding xrandr output:
Screen 0: minimum 64 x 64, current 2560 x 966, maximum 32000 x 32000
VBOX0 connected 1280x966+0+0 0mm x 0mm
   1280x966       60.0*+
   1280x960       60.0  
   1024x768       60.0  
   800x600        60.0  
   640x480        60.0  
VBOX1 connected 1280x920+1280+0 0mm x 0mm
   1280x920       60.0*+
   1280x960       60.0  
   1024x768       60.0  
   800x600        60.0  
   640x480        60.0  

Then try to switch one of the displays (e.g., System Settings->Displays etc.) off and run the test again. The test output looks like:
Device: X11GraphicsDevice[screen=0]
Resolutions:
966x1280
960x1280
768x1024
600x800
480x640

JDK used: 8 b101
OS version: Ubuntu 12.04; VirtualBox was used, but on my colleague's non-virtual machine (Ubuntu) the issue is reproducible too.

On Windows this test works as expected (two full resolution lists obtained).
Comments
It seems also that JDK-7045370 is still reproducible in case of several displays. Here is part of GE output (see GE.java attached to JDK-7045370) ... Graphics Device = X11GraphicsDevice[screen=0] Display Mode = java.awt.DisplayMode[width=1280, height=966, bitDepth=-1, refreshRate=0] ... Graphics Device = X11GraphicsDevice[screen=1] Display Mode = java.awt.DisplayMode[width=1280, height=920, bitDepth=-1, refreshRate=0] and corresponding xrandr output: Screen 0: minimum 64 x 64, current 2560 x 966, maximum 32000 x 32000 VBOX0 connected 1280x966+0+0 0mm x 0mm 1280x966 60.0*+ 1280x960 60.0 1024x768 60.0 800x600 60.0 640x480 60.0 VBOX1 connected 1280x920+1280+0 0mm x 0mm 1280x920 60.0*+ 1280x960 60.0 1024x768 60.0 800x600 60.0 640x480 60.0 after resolution change for the 1st display (1280x966 -> 1024x768): ... Graphics Device = X11GraphicsDevice[screen=0] Display Mode = java.awt.DisplayMode[width=1280, height=966, bitDepth=-1, refreshRate=0] ... Graphics Device = X11GraphicsDevice[screen=1] Display Mode = java.awt.DisplayMode[width=1280, height=920, bitDepth=-1, refreshRate=0] ... xrandr: Screen 0: minimum 64 x 64, current 2304 x 920, maximum 32000 x 32000 VBOX0 connected 1024x768+0+0 0mm x 0mm 1280x966 60.0 + 1280x960 60.0 1024x768 60.0* 800x600 60.0 640x480 60.0 VBOX1 connected 1280x920+1024+0 0mm x 0mm 1280x920 60.0*+ 1280x960 60.0 1024x768 60.0 800x600 60.0 640x480 60.0
12-08-2013