diff options
Diffstat (limited to 'src/newt')
22 files changed, 102 insertions, 78 deletions
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 4e6fa1aa5..f551fcc83 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -46,8 +46,6 @@ import jogamp.newt.DisplayImpl; import jogamp.newt.ScreenImpl; import jogamp.newt.WindowImpl; -import com.jogamp.common.os.Platform; - public class NewtFactory { public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window"); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 413dd2fe9..c0d8f97b3 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -44,16 +44,16 @@ import java.util.Set; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.OffscreenLayerOption; import javax.media.nativewindow.WindowClosingProtocol; -import javax.media.nativewindow.awt.AWTWindowClosingProtocol; import javax.swing.MenuSelectionManager; import jogamp.nativewindow.awt.AWTMisc; -import jogamp.nativewindow.jawt.JAWTWindow; import jogamp.newt.Debug; import jogamp.newt.awt.NewtFactoryAWT; import jogamp.newt.awt.event.AWTParentWindowAdapter; import jogamp.newt.driver.DriverClearFocus; +import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; +import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.Display; import com.jogamp.newt.Window; import com.jogamp.newt.event.InputEvent; diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index c0d79a5d4..419ce7f7f 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -421,6 +421,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC } drawable.setRealized(true); context = drawable.createContext(sharedContext); + context.setSynchronized(true); context.setContextCreationFlags(additionalCtxCreationFlags); } if(Window.DEBUG_IMPLEMENTATION) { @@ -555,13 +556,8 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC } if( null != context ) { // TODO: Check memory sync - if( NativeSurface.LOCK_SURFACE_NOT_READY < lockSurface() ) { - try { - helper.invokeGL(drawable, context, displayAction, initAction); - } finally { - unlockSurface(); - } - } + // surface is locked/unlocked implicit by context's makeCurrent/release + helper.invokeGL(drawable, context, displayAction, initAction); } } diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 908a44ea2..f2f35135a 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -54,17 +54,17 @@ public abstract class DisplayImpl extends Display { { Class<?> displayClass = NewtFactory.getCustomClass(type, "Display"); if(null==displayClass) { - if (NativeWindowFactory.TYPE_ANDROID.equals(type)) { + if (NativeWindowFactory.TYPE_ANDROID == type) { displayClass = Class.forName("jogamp.newt.driver.android.AndroidDisplay"); - } else if (NativeWindowFactory.TYPE_EGL.equals(type)) { + } else if (NativeWindowFactory.TYPE_EGL == type) { displayClass = Class.forName("jogamp.newt.driver.kd.KDDisplay"); - } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) { + } else if (NativeWindowFactory.TYPE_WINDOWS == type) { displayClass = Class.forName("jogamp.newt.driver.windows.WindowsDisplay"); - } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { + } else if (NativeWindowFactory.TYPE_MACOSX == type) { displayClass = Class.forName("jogamp.newt.driver.macosx.MacDisplay"); - } else if (NativeWindowFactory.TYPE_X11.equals(type)) { + } else if (NativeWindowFactory.TYPE_X11 == type) { displayClass = Class.forName("jogamp.newt.driver.x11.X11Display"); - } else if (NativeWindowFactory.TYPE_AWT.equals(type)) { + } else if (NativeWindowFactory.TYPE_AWT == type) { displayClass = Class.forName("jogamp.newt.driver.awt.AWTDisplay"); } else { throw new RuntimeException("Unknown display type \"" + type + "\""); diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index ea103025e..d4c6b6ee0 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -96,17 +96,17 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { { Class<?> screenClass = NewtFactory.getCustomClass(type, "Screen"); if(null==screenClass) { - if (NativeWindowFactory.TYPE_ANDROID.equals(type)) { + if (NativeWindowFactory.TYPE_ANDROID == type) { screenClass = Class.forName("jogamp.newt.driver.android.AndroidScreen"); - } else if (NativeWindowFactory.TYPE_EGL.equals(type)) { + } else if (NativeWindowFactory.TYPE_EGL == type) { screenClass = Class.forName("jogamp.newt.driver.kd.KDScreen"); - } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) { + } else if (NativeWindowFactory.TYPE_WINDOWS == type) { screenClass = Class.forName("jogamp.newt.driver.windows.WindowsScreen"); - } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { + } else if (NativeWindowFactory.TYPE_MACOSX == type) { screenClass = Class.forName("jogamp.newt.driver.macosx.MacScreen"); - } else if (NativeWindowFactory.TYPE_X11.equals(type)) { + } else if (NativeWindowFactory.TYPE_X11 == type) { screenClass = Class.forName("jogamp.newt.driver.x11.X11Screen"); - } else if (NativeWindowFactory.TYPE_AWT.equals(type)) { + } else if (NativeWindowFactory.TYPE_AWT == type) { screenClass = Class.forName("jogamp.newt.driver.awt.AWTScreen"); } else { throw new RuntimeException("Unknown window type \"" + type + "\""); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 62e42c185..d7382e0ea 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -158,17 +158,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer { Class<?> windowClass = NewtFactory.getCustomClass(type, "Window"); if(null==windowClass) { - if (NativeWindowFactory.TYPE_ANDROID.equals(type)) { + if (NativeWindowFactory.TYPE_ANDROID == type) { windowClass = Class.forName("jogamp.newt.driver.android.AndroidWindow"); - } else if (NativeWindowFactory.TYPE_EGL.equals(type)) { + } else if (NativeWindowFactory.TYPE_EGL == type) { windowClass = Class.forName("jogamp.newt.driver.kd.KDWindow"); - } else if (NativeWindowFactory.TYPE_WINDOWS.equals(type)) { + } else if (NativeWindowFactory.TYPE_WINDOWS == type) { windowClass = Class.forName("jogamp.newt.driver.windows.WindowsWindow"); - } else if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { + } else if (NativeWindowFactory.TYPE_MACOSX == type) { windowClass = Class.forName("jogamp.newt.driver.macosx.MacWindow"); - } else if (NativeWindowFactory.TYPE_X11.equals(type)) { + } else if (NativeWindowFactory.TYPE_X11 == type) { windowClass = Class.forName("jogamp.newt.driver.x11.X11Window"); - } else if (NativeWindowFactory.TYPE_AWT.equals(type)) { + } else if (NativeWindowFactory.TYPE_AWT == type) { windowClass = Class.forName("jogamp.newt.driver.awt.AWTWindow"); } else { throw new NativeWindowException("Unknown window type \"" + type + "\""); diff --git a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java index 2ca3d2cfd..861a6d6be 100644 --- a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java +++ b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java @@ -33,11 +33,11 @@ import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.awt.AWTGraphicsConfiguration; -import jogamp.nativewindow.jawt.JAWTWindow; import jogamp.newt.Debug; +import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.NewtFactory; public class NewtFactoryAWT extends NewtFactory { @@ -47,7 +47,7 @@ public class NewtFactoryAWT extends NewtFactory { * Wraps an AWT component into a {@link javax.media.nativewindow.NativeWindow} utilizing the {@link javax.media.nativewindow.NativeWindowFactory},<br> * using a configuration agnostic dummy {@link javax.media.nativewindow.DefaultGraphicsConfiguration}.<br> * <p> - * The actual wrapping implementation is {@link jogamp.nativewindow.jawt.JAWTWindow}.<br></p> + * The actual wrapping implementation is {@link com.jogamp.nativewindow.awt.JAWTWindow}.<br></p> * <p> * Purpose of this wrapping is to access the AWT window handle,<br> * not to actually render into it.<br> diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java index be3fbd323..3f360f20f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java @@ -32,9 +32,10 @@ import jogamp.newt.*; import jogamp.opengl.egl.*; import javax.media.nativewindow.*; -import javax.media.nativewindow.egl.*; import javax.media.opengl.GLException; +import com.jogamp.nativewindow.egl.*; + public class AndroidDisplay extends jogamp.newt.DisplayImpl { static { NEWTJNILibLoader.loadNEWT(); @@ -57,8 +58,6 @@ public class AndroidDisplay extends jogamp.newt.DisplayImpl { final long eglDisplay = EGLDisplayUtil.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL.EGL_NO_DISPLAY) { throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError())); - } else if(DEBUG) { - System.err.println("Android Display.createNativeImpl: eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay)); } if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) { throw new GLException("eglInitialize failed eglDisplay 0x"+Long.toHexString(eglDisplay)+", error 0x"+Integer.toHexString(EGL.eglGetError())); diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java index 52c789a4d..5be36fd76 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java @@ -35,13 +35,13 @@ import jogamp.newt.driver.android.event.AndroidNewtEventFactory; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.egl.EGLGraphicsDevice; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import com.jogamp.common.nio.Buffers; +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.newt.event.MouseEvent; import jogamp.opengl.egl.EGL; diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index dd6cdc80d..5a49dd57c 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -46,9 +46,11 @@ import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.awt.AWTGraphicsConfiguration; -import javax.media.nativewindow.awt.AWTGraphicsDevice; -import javax.media.nativewindow.awt.AWTGraphicsScreen; + + +import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; import com.jogamp.newt.Window; public class AWTCanvas extends Canvas { diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java index f22ec6fad..166da5c1c 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java @@ -34,8 +34,9 @@ package jogamp.newt.driver.awt; -import javax.media.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.newt.NewtFactory; + import jogamp.newt.DisplayImpl; public class AWTDisplay extends DisplayImpl { diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java b/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java index 9eed930b6..a3c0281b1 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java @@ -36,11 +36,12 @@ package jogamp.newt.driver.awt; import java.awt.DisplayMode; 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.Point; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; + public class AWTScreen extends ScreenImpl { public AWTScreen() { } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java index 2c921e7b2..2b2fed545 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java @@ -40,11 +40,13 @@ import java.awt.Frame; import java.awt.Insets; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.awt.AWTGraphicsConfiguration; -import javax.media.nativewindow.awt.AWTGraphicsDevice; -import javax.media.nativewindow.awt.AWTGraphicsScreen; import javax.media.nativewindow.util.Point; + import jogamp.newt.WindowImpl; + +import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTMouseAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java index 1ed91c1ac..40d0ad2c6 100644 --- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java +++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java @@ -36,7 +36,8 @@ package jogamp.newt.driver.broadcom.egl; import jogamp.newt.*; import jogamp.opengl.egl.*; import javax.media.nativewindow.*; -import javax.media.nativewindow.egl.*; + +import com.jogamp.nativewindow.egl.*; public class Display extends jogamp.newt.DisplayImpl { diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDDisplay.java b/src/newt/classes/jogamp/newt/driver/kd/KDDisplay.java index bbe67f00f..ed8cb822d 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/KDDisplay.java +++ b/src/newt/classes/jogamp/newt/driver/kd/KDDisplay.java @@ -33,11 +33,12 @@ package jogamp.newt.driver.kd; +import com.jogamp.nativewindow.egl.*; import com.jogamp.newt.*; + import jogamp.newt.*; import jogamp.opengl.egl.*; import javax.media.nativewindow.*; -import javax.media.nativewindow.egl.*; public class KDDisplay extends DisplayImpl { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java b/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java index 2ac98f255..18f8d9538 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java @@ -33,9 +33,13 @@ package jogamp.newt.driver.macosx; -import javax.media.nativewindow.*; -import javax.media.nativewindow.macosx.*; -import jogamp.newt.*; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; + +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; public class MacDisplay extends DisplayImpl { static { diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java index 524d9fc57..225b115e4 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java @@ -40,7 +40,8 @@ import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.windows.WindowsGraphicsDevice; + +import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; public class WindowsDisplay extends DisplayImpl { diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java index d14c47f5a..a30aa133c 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java @@ -53,6 +53,7 @@ public class WindowsWindow extends WindowImpl { private long hmon; private long hdc; + private long hdc_old; private long windowHandleClose; static { @@ -69,7 +70,19 @@ public class WindowsWindow extends WindowImpl { } hdc = GDI.GetDC(getWindowHandle()); hmon = MonitorFromWindow0(getWindowHandle()); - return ( 0 != hdc ) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; + + // return ( 0 == hdc ) ? LOCK_SURFACE_NOT_READY : ( hdc_old != hdc ) ? LOCK_SURFACE_CHANGED : LOCK_SUCCESS ; + if( 0 == hdc ) { + return LOCK_SURFACE_NOT_READY; + } + if( hdc_old == hdc ) { + return LOCK_SUCCESS; + } + if(DEBUG_IMPLEMENTATION) { + System.err.println("WindowsWindow: surface change "+toHexString(hdc_old)+" -> "+toHexString(hdc)); + // Thread.dumpStack(); + } + return LOCK_SURFACE_CHANGED; } @Override @@ -78,6 +91,7 @@ public class WindowsWindow extends WindowImpl { throw new InternalError("surface not acquired"); } GDI.ReleaseDC(getWindowHandle(), hdc); + hdc_old = hdc; hdc=0; } @@ -92,9 +106,9 @@ public class WindowsWindow extends WindowImpl { long _hmon = MonitorFromWindow0(getWindowHandle()); if (hmon != _hmon) { if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Info: Window Device Changed "+Thread.currentThread().getName()+ - ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon)); - e.printStackTrace(); + System.err.println("Info: Window Device Changed "+Thread.currentThread().getName()+ + ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon)); + // Thread.dumpStack(); } hmon = _hmon; return true; @@ -149,6 +163,7 @@ public class WindowsWindow extends WindowImpl { } } hdc = 0; + hdc_old = 0; } if(windowHandleClose != 0) { try { diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java index b3bc6e475..9464b979b 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java @@ -37,7 +37,8 @@ package jogamp.newt.driver.x11; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.x11.X11GraphicsDevice; + +import com.jogamp.nativewindow.x11.X11GraphicsDevice; import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java index b688c6870..93db854ac 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java @@ -33,19 +33,20 @@ */ package jogamp.newt.driver.x11; -import jogamp.nativewindow.x11.X11Lib; +import java.util.List; + +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; -import jogamp.newt.ScreenImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; +import jogamp.newt.ScreenImpl; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; import com.jogamp.newt.ScreenMode; import com.jogamp.newt.util.ScreenModeUtil; -import java.util.List; - -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; -import javax.media.nativewindow.x11.*; public class X11Screen extends ScreenImpl { diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java index c975306b4..703b18272 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java @@ -39,7 +39,7 @@ import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; import jogamp.newt.WindowImpl; import javax.media.nativewindow.*; -import javax.media.nativewindow.x11.*; +import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; @@ -64,7 +64,7 @@ public class X11Window extends WindowImpl { final X11Screen screen = (X11Screen) getScreen(); final X11Display display = (X11Display) screen.getDisplay(); final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()); - final X11GraphicsConfiguration cfg = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration( + final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen()); if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg); @@ -72,8 +72,11 @@ public class X11Window extends WindowImpl { if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } + final int visualID = cfg.getVisualID(VIDType.NATIVE); + if(VisualIDHolder.VID_UNDEFINED == visualID) { + throw new NativeWindowException("Chosen Configuration w/o native visual ID: "+cfg); + } setGraphicsConfiguration(cfg); - final long visualID = cfg.getVisualID(); final int flags = getReconfigureFlags(0, true) & ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; setWindowHandle(CreateWindow0(getParentWindowHandle(), @@ -236,8 +239,8 @@ public class X11Window extends WindowImpl { protected static native boolean initIDs0(); 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, boolean autoPosition, int flags); + int visualID, long javaObjectAtom, long windowDeleteAtom, + 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); diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 6953140c0..6312a9186 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -510,7 +510,7 @@ static void NewtWindows_setPosSize(Display *dpy, Window w, jint x, jint y, jint */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0 (JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index, - jlong visualID, + jint visualID, jlong javaObjectAtom, jlong windowDeleteAtom, jint x, jint y, jint width, jint height, jboolean autoPosition, int flags) { @@ -548,8 +548,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0 if(0==windowParent) { windowParent = root; } - DBG_PRINT( "X11: CreateWindow dpy %p, parent %p, %d/%d %dx%d, undeco %d, alwaysOnTop %d, autoPosition %d\n", - (void*)dpy, (void*)windowParent, x, y, width, height, + DBG_PRINT( "X11: CreateWindow dpy %p, screen %d, visualID 0x%X, parent %p, %d/%d %dx%d, undeco %d, alwaysOnTop %d, autoPosition %d\n", + (void*)dpy, scrn_idx, (int)visualID, (void*)windowParent, x, y, width, height, TST_FLAG_IS_UNDECORATED(flags), TST_FLAG_IS_ALWAYSONTOP(flags), autoPosition); // try given VisualID on screen @@ -557,20 +557,18 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0 visualTemplate.screen = scrn_idx; visualTemplate.visualid = (VisualID)visualID; pVisualQuery = XGetVisualInfo(dpy, VisualIDMask|VisualScreenMask, &visualTemplate,&n); - DUMP_VISUAL_INFO("Given VisualID,ScreenIdx", pVisualQuery); + DUMP_VISUAL_INFO("Given VisualID", pVisualQuery); if(pVisualQuery!=NULL) { visual = pVisualQuery->visual; depth = pVisualQuery->depth; - visualID = (jlong)pVisualQuery->visualid; + visualID = (jint)pVisualQuery->visualid; XFree(pVisualQuery); pVisualQuery=NULL; } - DBG_PRINT( "X11: [CreateWindow] trying given (dpy %p, screen %d, visualID: %d, parent %p) found: %p\n", - dpy, scrn_idx, (int)visualID, (void*)windowParent, visual); + DBG_PRINT( "X11: [CreateWindow] found visual: %p\n", visual); - if (visual==NULL) - { - NewtCommon_throwNewRuntimeException(env, "could not query Visual by given VisualID, bail out!"); + if (visual==NULL) { + NewtCommon_throwNewRuntimeException(env, "could not query Visual by given VisualID 0x%X, bail out!", (int)visualID); return 0; } |