summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-12-23 00:31:14 +0100
committerSven Gothel <[email protected]>2011-12-23 00:31:14 +0100
commitf3f794fe37a7e33a771a4a702f3f46ead4dc6d03 (patch)
treeb51202da10c96444f7744e4e66864bcf957f2d50 /src/newt/classes/jogamp
parentd225d0a8a16e362ddb14cb93c124eb06cf0ff05e (diff)
NEWT Multi-Monitor 1/2: Allow negative window position; Validate Screen-Index;
- Allow negative window position, using flag 'autoPosition' to mark a custom user position. This impacts Windows and X11 window creation code, which supports native auto positioning. - Screen: Validate Screen-Index. In 'big-desktop' mode the Screen index is always 0. This is true for X11 with Xinerama enabled and MS-Windows in general. Platforms w/o multiple Screen support always use index 0. - X11: Separate X11 Display/Screen/Window native code in their respective C files - Windows test scripts: use '%*' to catch all arguments - Add missing (c)
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java13
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java11
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java5
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java5
-rw-r--r--src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java5
-rw-r--r--src/newt/classes/jogamp/newt/driver/kd/KDScreen.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Screen.java16
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Window.java4
14 files changed, 63 insertions, 24 deletions
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index c520d0d63..3c46814d2 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -100,7 +100,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
return (Class<? extends Screen>)screenClass;
}
- public static Screen create(Display display, final int idx) {
+ public static Screen create(Display display, int idx) {
try {
if(usrWidth<0 || usrHeight<0) {
synchronized (Screen.class) {
@@ -114,18 +114,20 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
}
}
synchronized(screenList) {
+ Class<? extends Screen> screenClass = getScreenClass(display.getType());
+ ScreenImpl screen = (ScreenImpl) screenClass.newInstance();
+ screen.display = (DisplayImpl) display;
+ idx = screen.validateScreenIndex(idx);
{
Screen screen0 = ScreenImpl.getLastScreenOf(display, idx, -1);
if(null != screen0) {
if(DEBUG) {
System.err.println("Screen.create() REUSE: "+screen0+" "+Display.getThreadName());
}
+ screen = null;
return screen0;
}
}
- Class<? extends Screen> screenClass = getScreenClass(display.getType());
- ScreenImpl screen = (ScreenImpl) screenClass.newInstance();
- screen.display = (DisplayImpl) display;
screen.screen_idx = idx;
screen.fqname = (display.getFQName()+idx).intern();
screen.hashCode = screen.fqname.hashCode();
@@ -238,7 +240,8 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
protected abstract void createNativeImpl();
protected abstract void closeNativeImpl();
-
+ protected abstract int validateScreenIndex(int idx);
+
public final String getFQName() {
return fqname;
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index a8e93d428..7c811c66a 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -92,7 +92,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
protected CapabilitiesChooser capabilitiesChooser = null; // default null -> default
protected boolean fullscreen = false, hasFocus = false;
protected int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user
- protected int x = -1, y = -1; // client-area pos w/o insets, default: undefined (allow WM to choose if not set by user)
+ protected int x = 64, y = 64; // client-area pos w/o insets
+ protected boolean autoPosition = true; // default: true (allow WM to choose if not set by user)
protected Insets insets = new Insets(); // insets of decoration (if top-level && decorated)
protected int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets
@@ -276,8 +277,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindow.lockSurface() ) {
throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
}
- if( ( 0>x || 0>y ) && ( isUndecorated() || null != parentWindow ) ) {
- // default child/undecorated window position is 0/0, if not set by user
+ if( ( 0>x || 0>y ) && null != parentWindow ) {
+ // min. child window position is 0/0
x = 0; y = 0;
}
try {
@@ -1643,6 +1644,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
public void setPosition(int x, int y) {
+ autoPosition = false;
runOnEDTIfAvail(true, new SetPositionActionImpl(x, y));
}
@@ -2349,6 +2351,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
/** Triggered by implementation's WM events to update the position. */
protected void positionChanged(boolean defer, int newX, int newY) {
+ autoPosition = false;
if ( x != newX || y != newY ) {
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.positionChanged: ("+getThreadName()+"): (defer: "+defer+") "+x+"/"+y+" -> "+newX+"/"+newY+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
@@ -2414,8 +2417,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
* Triggered by implementation's WM events to update the content
*/
protected void windowRepaint(boolean defer, int x, int y, int width, int height) {
- x = ( 0 > x ) ? this.x : x;
- y = ( 0 > y ) ? this.y : y;
width = ( 0 >= width ) ? this.width : width;
height = ( 0 >= height ) ? this.height : height;
if(DEBUG_IMPLEMENTATION) {
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java b/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java
index ce6a9c594..79bf744fe 100644
--- a/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java
@@ -74,6 +74,10 @@ public class AndroidScreen extends jogamp.newt.ScreenImpl {
return ScreenModeUtil.streamIn(props, 0);
}
+ protected int validateScreenIndex(int idx) {
+ return 0; // FIXME: only one screen available ?
+ }
+
//----------------------------------------------------------------------
// Internals only
//
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java b/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java
index 644c96391..a8aa2844d 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java
@@ -62,4 +62,9 @@ public class AWTScreen extends ScreenImpl {
}
protected void closeNativeImpl() { }
+
+ protected int validateScreenIndex(int idx) {
+ return idx; // FIXME: ???
+ }
+
}
diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
index ca280fa8b..1cd98b068 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java
@@ -188,11 +188,6 @@ public class AWTWindow extends WindowImpl {
container.setVisible(0 != ( FLAG_IS_VISIBLE & flags));
}
- x=(x>=0)?x:AWTWindow.this.x;
- y=(x>=0)?y:AWTWindow.this.y;
- width=(width>0)?width:AWTWindow.this.width;
- height=(height>0)?height:AWTWindow.this.height;
-
container.setLocation(x, y);
Insets insets = container.getInsets();
container.setSize(width + insets.left + insets.right,
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 0a8453701..9d96ac5d6 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java
@@ -52,6 +52,10 @@ public class Screen extends jogamp.newt.ScreenImpl {
protected void closeNativeImpl() { }
+ protected int validateScreenIndex(int idx) {
+ return 0; // only one screen available
+ }
+
//----------------------------------------------------------------------
// Internals only
//
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 26b7120a9..62d9da4ed 100644
--- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java
@@ -53,6 +53,10 @@ public class Screen extends jogamp.newt.ScreenImpl {
protected void closeNativeImpl() { }
+ protected int validateScreenIndex(int idx) {
+ return 0; // only one screen available
+ }
+
//----------------------------------------------------------------------
// Internals only
//
diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java
index 6fc76a12d..873d0a0c1 100644
--- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java
+++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java
@@ -84,11 +84,6 @@ public class Window extends jogamp.newt.WindowImpl {
protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
Screen screen = (Screen) getScreen();
- x=(x>=0)?x:this.x;
- y=(x>=0)?y:this.y;
- width=(width>0)?width:this.width;
- height=(height>0)?height:this.height;
-
if(width>screen.getWidth()) {
width=screen.getWidth();
}
diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java b/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java
index a11b08b5c..0bfe8a622 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java
@@ -54,4 +54,8 @@ public class KDScreen extends ScreenImpl {
protected void setScreenSize(int w, int h) {
super.setScreenSize(w, h);
}
+
+ protected int validateScreenIndex(int idx) {
+ return 0; // only one screen available
+ }
}
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java b/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java
index 7785a5078..1c8128a5a 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java
@@ -106,6 +106,10 @@ public class MacScreen extends ScreenImpl {
return setScreenMode0(screen_idx, nativeModeIdx);
}
+ protected int validateScreenIndex(int idx) {
+ return idx;
+ }
+
private native int[] getScreenMode0(int screen_index, int mode_index);
private native boolean setScreenMode0(int screen_index, int mode_idx);
}
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
index ef06667ce..b1cdc36b2 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java
@@ -101,6 +101,10 @@ public class WindowsScreen extends ScreenImpl {
sm.getRotation());
}
+ protected int validateScreenIndex(int idx) {
+ return 0; // big-desktop, only one screen available
+ }
+
// Native calls
private native int getWidthImpl0(int scrn_idx);
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
index 23206c29d..ca868f4ee 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
@@ -115,7 +115,7 @@ public class WindowsWindow extends WindowImpl {
final int flags = getReconfigureFlags(0, true) &
( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ;
setWindowHandle(CreateWindow0(display.getHInstance(), display.getWindowClassName(), display.getWindowClassName(),
- getParentWindowHandle(), x, y, width, height, flags));
+ getParentWindowHandle(), x, y, width, height, autoPosition, flags));
if (getWindowHandle() == 0) {
throw new NativeWindowException("Error creating window");
}
@@ -287,7 +287,7 @@ public class WindowsWindow extends WindowImpl {
private native long CreateWindow0(long hInstance, String wndClassName, String wndName,
long parentWindowHandle,
- int x, int y, int width, int height, int flags);
+ int x, int y, int width, int height, boolean autoPosition, int flags);
private native long MonitorFromWindow0(long windowHandle);
private native void reconfigureWindow0(long parentWindowHandle, long windowHandle,
int x, int y, int width, int height, int flags);
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
index 463c62eba..1c5388d2c 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
@@ -33,6 +33,7 @@
*/
package jogamp.newt.driver.x11;
+import jogamp.nativewindow.x11.X11Lib;
import jogamp.nativewindow.x11.X11Util;
import jogamp.newt.DisplayImpl;
import jogamp.newt.ScreenImpl;
@@ -254,6 +255,21 @@ public class X11Screen extends ScreenImpl {
return done;
}
+ private class XineramaEnabledQuery implements DisplayImpl.DisplayRunnable<Boolean> {
+ public Boolean run(long dpy) {
+ return new Boolean(X11Lib.XineramaEnabled(dpy));
+ }
+ }
+ private XineramaEnabledQuery xineramaEnabledQuery = new XineramaEnabledQuery();
+
+ protected int validateScreenIndex(final int idx) {
+ if(getDisplay().isNativeValid()) {
+ return runWithLockedDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx;
+ } else {
+ return runWithTempDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx;
+ }
+ }
+
//----------------------------------------------------------------------
// Internals only
//
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
index bfaf53f0d..0bcf45a8d 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
@@ -79,7 +79,7 @@ public class X11Window extends WindowImpl {
setWindowHandle(CreateWindow0(getParentWindowHandle(),
display.getEDTHandle(), screen.getIndex(), visualID,
display.getJavaObjectAtom(), display.getWindowDeleteAtom(),
- x, y, width, height, flags));
+ x, y, width, height, autoPosition, flags));
windowHandleClose = getWindowHandle();
if (0 == windowHandleClose) {
throw new NativeWindowException("Error creating window");
@@ -239,7 +239,7 @@ public class X11Window extends WindowImpl {
private native long CreateWindow0(long parentWindowHandle, long display, int screen_index,
long visualID, long javaObjectAtom, long windowDeleteAtom,
- int x, int y, int width, int height, int flags);
+ int x, int y, int width, int height, boolean autoPosition, int flags);
private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom);
private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle,
int x, int y, int width, int height, int flags);