Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8022810

Cannot list all the available display modes on Ubuntu linux in case of two screen devices

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8, 9
    • client-libs
    • b127
    • generic
    • linux

      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).

            ssadetsky Semyon Sadetsky (Inactive)
            avstepan Alexander Stepanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: