summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-24 03:24:29 +0100
committerSven Gothel <[email protected]>2011-12-24 03:24:29 +0100
commit976e47291d052caab4b101d900270a073a3bbb55 (patch)
treefd9694fbbf652475b9ffeec87e325d36c3099d6d /src/newt/classes/jogamp
parent3f5d71f14506da21db29d050e685a482df47b5cc (diff)
NEWT Screen: Add virtual top-left origin getX()/getY() ; WindowsWindow.c: allow negative coordinates
- ScreenImpl: - Use Point & Dimension for holding virtual origin and size - updateScreenSize() -> updateVirtualScreenOriginAndSize() - DimensionImmutable getNativeScreenSizeImpl() -> void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) - WindowImpl setFullscreen(true): Use Screen virtual origin - WindowsWindow.c - For x/y coords use GET_X_LPARAM/GET_Y_LPARAM which casts '(int)(short)' to preserve negative coordinates. - NewtWindow_setVisiblePosSize() allow negative coordinates
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java51
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java14
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java13
-rw-r--r--src/newt/classes/jogamp/newt/driver/kd/KDScreen.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java12
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Screen.java14
11 files changed, 86 insertions, 58 deletions
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index a8e6e68bd..98e851937 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -45,7 +45,9 @@ import com.jogamp.newt.util.MonitorMode;
import com.jogamp.newt.util.ScreenModeUtil;
import javax.media.nativewindow.*;
+import javax.media.nativewindow.util.Dimension;
import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.Point;
import javax.media.nativewindow.util.SurfaceSize;
import java.security.*;
@@ -61,8 +63,10 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
protected int hashCode;
protected AbstractGraphicsScreen aScreen;
protected int refCount; // number of Screen references by Window
- protected int width=-1, height=-1; // detected values: set using setScreenSize
- protected static int usrWidth=-1, usrHeight=-1; // property values: newt.ws.swidth and newt.ws.sheight
+ protected Point vOrigin = new Point(0, 0); // virtual top-left origin
+ protected Dimension vSize = new Dimension(0, 0); // virtual rotated screen size
+ protected static Dimension usrSize = null; // property values: newt.ws.swidth and newt.ws.sheight
+ protected static volatile boolean usrSizeQueried = false;
private static AccessControlContext localACC = AccessController.getContext();
private ArrayList<ScreenModeListener> referencedScreenModeListener = new ArrayList<ScreenModeListener>();
long t0; // creationTime
@@ -102,13 +106,15 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
public static Screen create(Display display, int idx) {
try {
- if(usrWidth<0 || usrHeight<0) {
+ if(!usrSizeQueried) {
synchronized (Screen.class) {
- if(usrWidth<0 || usrHeight<0) {
- usrWidth = Debug.getIntProperty("newt.ws.swidth", true, localACC);
- usrHeight = Debug.getIntProperty("newt.ws.sheight", true, localACC);
- if(usrWidth>0 || usrHeight>0) {
- System.err.println("User screen size "+usrWidth+"x"+usrHeight);
+ if(!usrSizeQueried) {
+ usrSizeQueried = true;
+ final int w = Debug.getIntProperty("newt.ws.swidth", true, localACC);
+ final int h = Debug.getIntProperty("newt.ws.sheight", true, localACC);
+ if(w>0 && h>0) {
+ usrSize = new Dimension(w, h);
+ System.err.println("User screen size "+usrSize);
}
}
}
@@ -178,7 +184,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen");
}
initScreenModeStatus();
- updateScreenSize();
+ updateVirtualScreenOriginAndSize();
if(DEBUG) {
System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+")");
}
@@ -252,13 +258,15 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
protected abstract int validateScreenIndex(int idx);
/**
- * Returns the <b>rotated</b> virtual ScreenSize.
+ * Stores the virtual origin and virtual <b>rotated</b> screen size.
* <p>
* This method is called after the ScreenMode has been set,
* hence you may utilize it.
* </p>
+ * @param virtualOrigin the store for the virtual origin
+ * @param virtualSize the store for the virtual rotated size
*/
- protected abstract DimensionImmutable getNativeScreenSizeImpl();
+ protected abstract void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize);
public final String getFQName() {
return fqname;
@@ -267,10 +275,9 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
/**
* Updates the <b>rotated</b> virtual ScreenSize using the native impl.
*/
- protected void updateScreenSize() {
- final DimensionImmutable dim = getNativeScreenSizeImpl();
- width=dim.getWidth(); height=dim.getHeight();
- System.err.println("Detected screen size "+width+"x"+height);
+ protected void updateVirtualScreenOriginAndSize() {
+ getVirtualScreenOriginAndSize(vOrigin, vSize);
+ System.err.println("Detected screen origin "+vOrigin+", size "+vSize);
}
public final Display getDisplay() {
@@ -289,19 +296,15 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
return null != aScreen;
}
+ public int getX() { return vOrigin.getX(); }
+ public int getY() { return vOrigin.getY(); }
- /**
- * @return the <b>rotated</b> virtual width.
- */
public final int getWidth() {
- return (usrWidth>0) ? usrWidth : (width>0) ? width : 480;
+ return (null != usrSize) ? usrSize.getWidth() : vSize.getWidth();
}
- /**
- * @return the <b>rotated</b> virtual height.
- */
public final int getHeight() {
- return (usrHeight>0) ? usrHeight : (height>0) ? height : 480;
+ return (null != usrSize) ? usrSize.getHeight() : vSize.getHeight();
}
@Override
@@ -403,7 +406,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
public void screenModeChanged(ScreenMode sm, boolean success) {
if(success) {
- updateScreenSize();
+ updateVirtualScreenOriginAndSize();
}
for(int i=0; i<referencedScreenModeListener.size(); i++) {
((ScreenModeListener)referencedScreenModeListener.get(i)).screenModeChanged(sm, success);
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 7c811c66a..f667d7540 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -1677,7 +1677,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
nfs_y = WindowImpl.this.y;
nfs_width = WindowImpl.this.width;
nfs_height = WindowImpl.this.height;
- x = 0; y = 0;
+ x = screen.getX(); y = screen.getY();
w = screen.getWidth();
h = screen.getHeight();
} else {
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java b/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java
index f403bc425..e108ed0bb 100644
--- a/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java
@@ -30,7 +30,7 @@ package jogamp.newt.driver.android;
import javax.media.nativewindow.*;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.Point;
import com.jogamp.newt.ScreenMode;
import com.jogamp.newt.util.ScreenModeUtil;
@@ -80,9 +80,12 @@ public class AndroidScreen extends jogamp.newt.ScreenImpl {
return 0; // FIXME: only one screen available ?
}
- protected DimensionImmutable getNativeScreenSizeImpl() {
+ protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) {
+ virtualOrigin.setX(0);
+ virtualOrigin.setY(0);
final ScreenMode sm = getCurrentScreenMode();
- return new Dimension(sm.getRotatedWidth(), sm.getRotatedHeight());
+ virtualSize.setWidth(sm.getRotatedWidth());
+ virtualSize.setHeight(sm.getRotatedHeight());
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java b/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java
index e2e0105eb..9eed930b6 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java
@@ -39,7 +39,7 @@ import jogamp.newt.ScreenImpl;
import javax.media.nativewindow.awt.AWTGraphicsDevice;
import javax.media.nativewindow.awt.AWTGraphicsScreen;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.Point;
public class AWTScreen extends ScreenImpl {
public AWTScreen() {
@@ -57,8 +57,8 @@ public class AWTScreen extends ScreenImpl {
* Used by AWTWindow ..
*/
@Override
- protected void updateScreenSize() {
- super.updateScreenSize();
+ protected void updateVirtualScreenOriginAndSize() {
+ super.updateVirtualScreenOriginAndSize();
}
protected void closeNativeImpl() { }
@@ -67,12 +67,14 @@ public class AWTScreen extends ScreenImpl {
return idx; // pass through ...
}
- protected DimensionImmutable getNativeScreenSizeImpl() {
+ protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) {
final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode();
if(null != mode) {
- return new Dimension(mode.getWidth(), mode.getHeight());
+ virtualOrigin.setX(0);
+ virtualOrigin.setY(0);
+ virtualSize.setWidth(mode.getWidth());
+ virtualSize.setHeight(mode.getHeight());
}
- return null;
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
index 5b6fcedbe..e9e3ec0ba 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
@@ -156,7 +156,7 @@ public class AWTWindow extends WindowImpl {
((AWTScreen)getScreen()).setAWTGraphicsScreen((AWTGraphicsScreen)cfg.getScreen());
((AWTDisplay)getScreen().getDisplay()).setAWTGraphicsDevice((AWTGraphicsDevice)cfg.getScreen().getDevice());
- ((AWTScreen)getScreen()).updateScreenSize();
+ ((AWTScreen)getScreen()).updateVirtualScreenOriginAndSize();
}
return res;
}
diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java
index 86a27a407..11b8dfcf9 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java
@@ -35,7 +35,7 @@ package jogamp.newt.driver.broadcom.egl;
import javax.media.nativewindow.*;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.Point;
public class Screen extends jogamp.newt.ScreenImpl {
@@ -57,8 +57,11 @@ public class Screen extends jogamp.newt.ScreenImpl {
return 0; // only one screen available
}
- protected DimensionImmutable getNativeScreenSizeImpl() {
- return new Dimension(fixedWidth, fixedHeight); // FIXME
+ protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) {
+ virtualOrigin.setX(0);
+ virtualOrigin.setY(0);
+ virtualSize.setWidth(fixedWidth); // FIXME
+ virtualSize.setHeight(fixedHeight); // FIXME
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java
index 6e156183f..66ad1c691 100644
--- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java
@@ -33,10 +33,10 @@
package jogamp.newt.driver.intel.gdl;
-import jogamp.newt.*;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.Point;
public class Screen extends jogamp.newt.ScreenImpl {
@@ -59,8 +59,11 @@ public class Screen extends jogamp.newt.ScreenImpl {
return 0; // only one screen available
}
- protected DimensionImmutable getNativeScreenSizeImpl() {
- return new Dimension(cachedWidth, cachedHeight);
+ protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) {
+ virtualOrigin.setX(0);
+ virtualOrigin.setY(0);
+ virtualSize.setWidth(cachedWidth);
+ virtualSize.setHeight(cachedHeight);
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java b/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java
index bbfef370c..6b6aecb20 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java
@@ -36,7 +36,7 @@ package jogamp.newt.driver.kd;
import jogamp.newt.ScreenImpl;
import javax.media.nativewindow.*;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.Point;
public class KDScreen extends ScreenImpl {
static {
@@ -56,8 +56,11 @@ public class KDScreen extends ScreenImpl {
return 0; // only one screen available
}
- protected DimensionImmutable getNativeScreenSizeImpl() {
- return new Dimension(cachedWidth, cachedHeight);
+ protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) {
+ virtualOrigin.setX(0);
+ virtualOrigin.setY(0);
+ virtualSize.setWidth(cachedWidth);
+ virtualSize.setHeight(cachedHeight);
}
protected void sizeChanged(int w, int h) {
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java b/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java
index 4954b0569..3204982be 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java
@@ -37,8 +37,8 @@ package jogamp.newt.driver.macosx;
import java.util.List;
import javax.media.nativewindow.DefaultGraphicsScreen;
-import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.Dimension;
+import javax.media.nativewindow.util.Point;
import jogamp.newt.ScreenImpl;
@@ -111,8 +111,11 @@ public class MacScreen extends ScreenImpl {
return idx;
}
- protected DimensionImmutable getNativeScreenSizeImpl() {
- return new Dimension(getWidthImpl0(screen_idx), getHeightImpl0(screen_idx));
+ protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) {
+ virtualOrigin.setX(0);
+ virtualOrigin.setY(0);
+ virtualSize.setWidth(getWidthImpl0(screen_idx));
+ virtualSize.setHeight(getHeightImpl0(screen_idx));
}
private native int[] getScreenMode0(int screen_index, int mode_index);
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
index 7e3e3626c..f8bce9da3 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
@@ -35,7 +35,7 @@ package jogamp.newt.driver.windows;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.Point;
import jogamp.newt.ScreenImpl;
@@ -106,13 +106,17 @@ public class WindowsScreen extends ScreenImpl {
return 0; // big-desktop, only one screen available
}
- protected DimensionImmutable getNativeScreenSizeImpl() {
- return new Dimension(getWidthImpl0(screen_idx), getHeightImpl0(screen_idx));
+ protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) {
+ virtualOrigin.setX(getOriginX0(screen_idx));
+ virtualOrigin.setY(getOriginY0(screen_idx));
+ virtualSize.setWidth(getWidthImpl0(screen_idx));
+ virtualSize.setHeight(getHeightImpl0(screen_idx));
}
// Native calls
+ private native int getOriginX0(int screen_idx);
+ private native int getOriginY0(int screen_idx);
private native int getWidthImpl0(int scrn_idx);
-
private native int getHeightImpl0(int scrn_idx);
private native int[] getScreenMode0(int screen_index, int mode_index);
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
index c52a21220..ed5ebc04e 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
@@ -44,7 +44,7 @@ import com.jogamp.newt.util.ScreenModeUtil;
import java.util.List;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionImmutable;
+import javax.media.nativewindow.util.Point;
import javax.media.nativewindow.x11.*;
public class X11Screen extends ScreenImpl {
@@ -268,10 +268,14 @@ public class X11Screen extends ScreenImpl {
}
}
- protected DimensionImmutable getNativeScreenSizeImpl() {
- return display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<DimensionImmutable>() {
- public DimensionImmutable run(long dpy) {
- return new Dimension(getWidth0(dpy, screen_idx), getHeight0(dpy, screen_idx));
+ protected void getVirtualScreenOriginAndSize(final Point virtualOrigin, final Dimension virtualSize) {
+ display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Object>() {
+ public Object run(long dpy) {
+ virtualOrigin.setX(0);
+ virtualOrigin.setY(0);
+ virtualSize.setWidth(getWidth0(dpy, screen_idx));
+ virtualSize.setHeight(getHeight0(dpy, screen_idx));
+ return null;
} } );
}