Permalink
Browse files

ScreenMode/X11: Use common defaults in case of undefined values. X11:…

… Tolerate invalid refresh rate and use default.
  • Loading branch information...
sgothel committed Feb 27, 2012
1 parent fc5b20c commit f519190f0cf97eb6b3fda61f4eb8c1f55de43b51
@@ -62,6 +62,12 @@
public abstract class ScreenImpl extends Screen implements ScreenModeListener {
protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true);
protected static final int default_sm_bpp = 32;
protected static final int default_sm_widthmm = 519;
protected static final int default_sm_heightmm = 324;
protected static final int default_sm_rate = 60;
protected static final int default_sm_rotation = 0;
protected DisplayImpl display;
protected int screen_idx;
protected String fqname;
@@ -501,11 +507,11 @@ protected ScreenMode getCurrentScreenModeIntern() {
props[i++] = 0; // set later for verification of iterator
props[i++] = getWidth(); // width
props[i++] = getHeight(); // height
props[i++] = 32; // bpp
props[i++] = 519; // widthmm
props[i++] = 324; // heightmm
props[i++] = 60; // rate
props[i++] = 0; // rot
props[i++] = default_sm_bpp;
props[i++] = default_sm_widthmm;
props[i++] = default_sm_heightmm;
props[i++] = default_sm_rate;
props[i++] = default_sm_rotation;
props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count
res = ScreenModeUtil.streamIn(props, 0);
}
@@ -124,10 +124,12 @@ protected void closeNativeImpl() {
if(0>=res[0] || 0>=res[1]) {
throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number);
}
int bpp = 32; // FIXME
int rate = nrates[nrate_index];
if(0>=rate) {
throw new InternalError("invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length);
rate = default_sm_rate;
if(DEBUG) {
System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+default_sm_rate);
}
}
int rotation = nrotations[nrotation_index];
@@ -137,7 +139,7 @@ protected void closeNativeImpl() {
props[i++] = 0; // set later for verification of iterator
props[i++] = res[0]; // width
props[i++] = res[1]; // height
props[i++] = bpp; // bpp
props[i++] = default_sm_bpp; // FIXME
props[i++] = res[2]; // widthmm
props[i++] = res[3]; // heightmm
props[i++] = rate; // rate
@@ -217,7 +219,7 @@ public ScreenMode run(long dpy) {
props[i++] = 0; // set later for verification of iterator
props[i++] = res[0]; // width
props[i++] = res[1]; // height
props[i++] = 32; // FIXME: bpp
props[i++] = default_sm_bpp; // FIXME
props[i++] = res[2]; // widthmm
props[i++] = res[3]; // heightmm
props[i++] = rate; // rate

0 comments on commit f519190

Please sign in to comment.