Skip to content

Commit

Permalink
ScreenMode/X11: Use common defaults in case of undefined values. X11:…
Browse files Browse the repository at this point in the history
… Tolerate invalid refresh rate and use default.
  • Loading branch information
sgothel committed Feb 27, 2012
1 parent fc5b20c commit f519190
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 11 additions & 5 deletions src/newt/classes/jogamp/newt/ScreenImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 6 additions & 4 deletions src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ public int[] run(long dpy) {
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];

Expand All @@ -137,7 +139,7 @@ public int[] run(long dpy) {
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f519190

Please sign in to comment.