May I add a fix to LWJGLPropertiesDialog?

I am currently working with Linux machines that have permissions locked on their displays - there is only one resolution available. This is fairly common on corporate and public terminals as well as kiosks. This locked permissions causes problems with jME .10. I am proposing a fix.



Since LWJGLPropertiesDialog only reports the resolutions available to the desktop, only this allowed one shows up. Meaning that users can't run in windowed modes smaller than the desktop… which is bad.



I fixed LWJGLPropertiesDialog to have a list of common window resolutions and to list those as well, if they are smaller than the current resolution. In these cases it prevents the user from choosing fullscreen if it is not an available display res too.



Once the user has selected their res, if the fullscreen checkbos is not checked, it uses the current bitdepth and refresh rate rather than those assigned.



I am familiar with cvs, but am not sure if jME encourages random additions. So I will post my changes here forreview before commiting.



change to verifyAndSaveCurrent


        int height = Integer.parseInt(display);

         boolean fullscreen = fullscreenBox.isSelected();
        
         //default to current settings
         DisplayMode current = Display.getDisplayMode();
         int depth = current.getBitsPerPixel();
         int freq = current.getFrequency();
        
         if (fullscreen) {
            
             String depthString = (String) colorDepthCombo.getSelectedItem();
             depth = Integer.parseInt(depthString.substring(0, depthString
                     .indexOf(" ")));
            
             String freqString = (String) displayFreqCombo.getSelectedItem();
             freq = Integer.parseInt(freqString.substring(0, freqString
                     .indexOf(" ")));
         }
       
      
        ....
            
                   DisplaySystem disp = DisplaySystem.getDisplaySystem(renderer);
        boolean valid = (disp != null) ? disp.isValidDisplayMode(width, height,
                depth, freq) : false;
        if (! fullscreen) valid = true; //perhaps needs more than just an assumption
       



change to updateDisplayChoices


       DisplaySystem disp = DisplaySystem.getDisplaySystem(renderer);
        boolean valid = (disp != null) ? disp.isValidDisplayMode(width, height,
                depth, freq) : false;
        if (! fullscreen) valid = true; //perhaps needs more than just an assumption
       




all of getResolutions


    private static String[] getResolutions(DisplayMode[] modes) {
        ArrayList<String> resolutions = new ArrayList<String>(modes.length);

        for (int i = 0; i < modes.length; i++) {
            String res = modes[i].getWidth() + " x " + modes[i].getHeight();
            if (!resolutions.contains(res))
                resolutions.add(res);
        }
       
        //any common window sizes that are not listed in the possible display modes
        //this can happen on an system that can limit permissions to change desptop resolution,
        //such as Linux machine, a Kiosk or a Public Terminal.
        int [] [] commonWindowRes = new int [] [] {
            {640,480},
            {800,600},
            {1024,768}

        };
       
        for (int i = 0; i  < commonWindowRes.length; i++ ) {
           if (commonWindowRes[i][0] <= Display.getDisplayMode().getWidth()
           && commonWindowRes[i][1] < Display.getDisplayMode().getHeight() ) {
            String res = commonWindowRes[i][0] + " x " + commonWindowRes[i][1];
            if (!resolutions.contains(res))
                resolutions.add(res);
            }
        }
       
       
        String[] res = new String[resolutions.size()];
        resolutions.toArray(res);
        return res;
    }



new mothod checkFullscreen


    /**
     *checks if resolution is available as fullscreen or windowed only
     */
    private void checkFullscreen(String resolution, DisplayMode[] modes) {
       for (int i = 0; i < modes.length; i++) {
          String res = modes[i].getWidth() + " x " + modes[i].getHeight();
          if (res.equals(resolution) ){
              //turn on the ability to make full screen
              fullscreenBox.setEnabled(true);
              return;
          }
       }
       //turn off ability to make fullscreen
       fullscreenBox.setSelected(false);
       fullscreenBox.setEnabled(false);
    }



[EDIT]
I just relaised it would be better to have this list of default window reses be sstored and accessibe on theon the class - duh, programming 101. but aside form that, which I will fix, does it look ok? If so, can I just commit it?