aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-08-08 21:43:30 +0200
committerMichael Bien <[email protected]>2009-08-08 21:43:30 +0200
commit8ef9d7364a942c19ec5e1f306e08193e83f4fea6 (patch)
tree6dcf95825d2933992199a7062b15e38d3f721c95 /src/newt/classes/com
parent2a8e9876ca4567de3b08813c280d006f9b2c32e6 (diff)
parentfb3e50b4e7e11df911a83ab7966cf8f293c20da2 (diff)
Merge branch 'master' of ssh://[email protected]/jogl~jogl-git
Diffstat (limited to 'src/newt/classes/com')
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Display.java2
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/NewtFactory.java2
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Screen.java2
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java8
-rw-r--r--src/newt/classes/com/sun/javafx/newt/impl/NativeLibLoader.java3
-rw-r--r--src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java17
-rw-r--r--src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java82
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java64
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java154
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java8
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java39
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/x11/X11Window.java6
12 files changed, 363 insertions, 24 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/Display.java b/src/newt/classes/com/sun/javafx/newt/Display.java
index 5032477c9..38d0021ce 100755
--- a/src/newt/classes/com/sun/javafx/newt/Display.java
+++ b/src/newt/classes/com/sun/javafx/newt/Display.java
@@ -54,6 +54,8 @@ public abstract class Display implements Runnable {
displayClass = Class.forName("com.sun.javafx.newt.x11.X11Display");
} else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
displayClass = Class.forName("com.sun.javafx.newt.awt.AWTDisplay");
+ } else if (NewtFactory.TYPE_BROADCOM_EGL.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.opengl.broadcom.BCEGLDisplay");
} else {
throw new RuntimeException("Unknown display type \"" + type + "\"");
}
diff --git a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
index b5a555455..dbae30a4b 100755
--- a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
+++ b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java
@@ -39,6 +39,8 @@ import java.util.Iterator;
import com.sun.nativewindow.impl.jvm.JVMUtil;
public abstract class NewtFactory {
+ public static final String TYPE_BROADCOM_EGL = "BroadcomEGL";
+
// Work-around for initialization order problems on Mac OS X
// between native Newt and (apparently) Fmod
static {
diff --git a/src/newt/classes/com/sun/javafx/newt/Screen.java b/src/newt/classes/com/sun/javafx/newt/Screen.java
index 2566041a8..57ed34211 100755
--- a/src/newt/classes/com/sun/javafx/newt/Screen.java
+++ b/src/newt/classes/com/sun/javafx/newt/Screen.java
@@ -54,6 +54,8 @@ public abstract class Screen {
screenClass = Class.forName("com.sun.javafx.newt.x11.X11Screen");
} else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
screenClass = Class.forName("com.sun.javafx.newt.awt.AWTScreen");
+ } else if (NewtFactory.TYPE_BROADCOM_EGL.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.opengl.broadcom.BCEGLScreen");
} else {
throw new RuntimeException("Unknown window type \"" + type + "\"");
}
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index 36eafd32d..e2903bd62 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -74,6 +74,8 @@ public abstract class Window implements NativeWindow
windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window");
} else if (NativeWindowFactory.TYPE_AWT.equals(type)) {
windowClass = Class.forName("com.sun.javafx.newt.awt.AWTWindow");
+ } else if (NewtFactory.TYPE_BROADCOM_EGL.equals(type)) {
+ windowClass = Class.forName("com.sun.javafx.newt.opengl.broadcom.BCEGLWindow");
} else {
throw new NativeWindowException("Unknown window type \"" + type + "\"");
}
@@ -267,6 +269,12 @@ public abstract class Window implements NativeWindow
y=0;
}
+ public boolean surfaceSwap() {
+ return false;
+ }
+
+ public void surfaceUpdated() {}
+
protected void clearEventMask() {
eventMask=0;
}
diff --git a/src/newt/classes/com/sun/javafx/newt/impl/NativeLibLoader.java b/src/newt/classes/com/sun/javafx/newt/impl/NativeLibLoader.java
index 6316e750f..d96c56f6e 100644
--- a/src/newt/classes/com/sun/javafx/newt/impl/NativeLibLoader.java
+++ b/src/newt/classes/com/sun/javafx/newt/impl/NativeLibLoader.java
@@ -53,8 +53,7 @@ public class NativeLibLoader extends NativeLibLoaderBase {
public static void loadNEWT() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
- String[] preload = { "nativewindow" };
- loadLibrary("newt", preload, true);
+ loadLibrary("newt", null, true);
return null;
}
});
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
index 8ecfe6216..9f4454681 100644
--- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
@@ -441,10 +441,12 @@ public class GLWindow extends Window implements GLAutoDrawable {
return context.getGL();
}
- public void setGL(GL gl) {
+ public GL setGL(GL gl) {
if (context != null) {
context.setGL(gl);
+ return gl;
}
+ return null;
}
public void addGLEventListener(GLEventListener listener) {
@@ -654,6 +656,19 @@ public class GLWindow extends Window implements GLAutoDrawable {
return null;
}
+ public boolean surfaceSwap() {
+ if(null!=drawable) return drawable.getNativeWindow().surfaceSwap();
+ return super.surfaceSwap();
+ }
+
+ public void surfaceUpdated() {
+ if(null!=drawable) {
+ drawable.getNativeWindow().surfaceUpdated();
+ } else {
+ super.surfaceUpdated();
+ }
+ }
+
public long getWindowHandle() {
if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
return super.getWindowHandle();
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java
new file mode 100644
index 000000000..dbe126c91
--- /dev/null
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLDisplay.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.opengl.broadcom;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.impl.*;
+import com.sun.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.egl.*;
+
+public class BCEGLDisplay extends Display {
+
+ static {
+ NativeLibLoader.loadNEWT();
+
+ if (!BCEGLWindow.initIDs()) {
+ throw new NativeWindowException("Failed to initialize BCEGLWindow jmethodIDs");
+ }
+ }
+
+ public static void initSingleton() {
+ // just exist to ensure static init has been run
+ }
+
+
+ public BCEGLDisplay() {
+ }
+
+ protected void createNative() {
+ long handle = CreateDisplay(BCEGLScreen.fixedWidth, BCEGLScreen.fixedHeight);
+ if (handle == EGL.EGL_NO_DISPLAY) {
+ throw new NativeWindowException("BC EGL CreateDisplay failed");
+ }
+ aDevice = new EGLGraphicsDevice(handle);
+ }
+
+ protected void closeNative() {
+ if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) {
+ DestroyDisplay(aDevice.getHandle());
+ }
+ }
+
+ protected void dispatchMessages() {
+ // n/a .. DispatchMessages();
+ }
+
+ private native long CreateDisplay(int width, int height);
+ private native void DestroyDisplay(long dpy);
+ private native void DispatchMessages();
+}
+
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java
new file mode 100755
index 000000000..165081cde
--- /dev/null
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLScreen.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.opengl.broadcom;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.impl.*;
+import javax.media.nativewindow.*;
+
+public class BCEGLScreen extends Screen {
+
+ static {
+ BCEGLDisplay.initSingleton();
+ }
+
+
+ public BCEGLScreen() {
+ }
+
+ protected void createNative(int index) {
+ aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), index);
+ setScreenSize(fixedWidth, fixedHeight);
+ }
+
+ protected void closeNative() { }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ static final int fixedWidth = 1920;
+ static final int fixedHeight = 1080;
+}
+
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java
new file mode 100755
index 000000000..ddee07c49
--- /dev/null
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.opengl.broadcom;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.impl.*;
+import com.sun.opengl.impl.egl.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.media.nativewindow.NativeWindowException;
+
+public class BCEGLWindow extends Window {
+ static {
+ BCEGLDisplay.initSingleton();
+ }
+
+ public BCEGLWindow() {
+ }
+
+ protected void createNative(Capabilities caps) {
+ // query a good configuration .. even thought we drop this one
+ // and reuse the EGLUtil choosen one later.
+ config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
+ if (config == null) {
+ throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
+ }
+ setSizeImpl(getScreen().getWidth(), getScreen().getHeight());
+ }
+
+ protected void closeNative() {
+ if(0!=windowHandleClose) {
+ CloseWindow(getDisplayHandle(), windowHandleClose);
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ if(this.visible!=visible) {
+ this.visible=visible;
+ if ( 0==windowHandle ) {
+ windowHandle = realizeWindow(true, width, height);
+ if (0 == windowHandle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ }
+ clearEventMask();
+ }
+ }
+
+ public void setSize(int width, int height) {
+ System.err.println("setSize "+width+"x"+height+" n/a in BroadcomEGL");
+ }
+
+ void setSizeImpl(int width, int height) {
+ if(0!=windowHandle) {
+ // n/a in BroadcomEGL
+ System.err.println("BCEGLWindow.setSizeImpl n/a in BroadcomEGL with realized window");
+ } else {
+ if(DEBUG_IMPLEMENTATION) {
+ Exception e = new Exception("BCEGLWindow.setSizeImpl() "+this.width+"x"+this.height+" -> "+width+"x"+height);
+ e.printStackTrace();
+ }
+ this.width = width;
+ this.height = height;
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ // n/a in BroadcomEGL
+ System.err.println("setPosition n/a in BroadcomEGL");
+ }
+
+ public boolean setFullscreen(boolean fullscreen) {
+ // n/a in BroadcomEGL
+ System.err.println("setFullscreen n/a in BroadcomEGL");
+ return false;
+ }
+
+ public boolean surfaceSwap() {
+ if ( 0!=windowHandle ) {
+ SwapWindow(getDisplayHandle(), windowHandle);
+ return true;
+ }
+ return false;
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ protected static native boolean initIDs();
+ private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height);
+ private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle);
+ private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle);
+
+
+ private long realizeWindow(boolean chromaKey, int width, int height) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.out.println("BCEGLWindow.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+config);
+ }
+ long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height);
+ if (0 == handle) {
+ throw new NativeWindowException("Error native Window Handle is null");
+ }
+ windowHandleClose = handle;
+ return handle;
+ }
+
+ private void windowCreated(int cfgID, int width, int height) {
+ this.width = width;
+ this.height = height;
+ GLCapabilities capsReq = (GLCapabilities) config.getRequestedCapabilities();
+ config = EGLGraphicsConfiguration.create(capsReq, screen.getGraphicsScreen(), cfgID);
+ if (config == null) {
+ throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this);
+ }
+ if(DEBUG_IMPLEMENTATION) {
+ System.out.println("BCEGLWindow.windowCreated(): 0x"+Integer.toHexString(cfgID)+", "+width+"x"+height+", "+config);
+ }
+ }
+
+ private long windowHandleClose;
+}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
index df0134c8e..1265fa9e2 100755
--- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
@@ -79,7 +79,7 @@ public class KDWindow extends Window {
}
public void setVisible(boolean visible) {
- if(this.visible!=visible) {
+ if(0!=eglWindowHandle && this.visible!=visible) {
this.visible=visible;
setVisible0(eglWindowHandle, visible);
if ( 0==windowHandle ) {
@@ -93,7 +93,9 @@ public class KDWindow extends Window {
}
public void setSize(int width, int height) {
- setSize0(eglWindowHandle, width, height);
+ if(0!=eglWindowHandle) {
+ setSize0(eglWindowHandle, width, height);
+ }
}
public void setPosition(int x, int y) {
@@ -102,7 +104,7 @@ public class KDWindow extends Window {
}
public boolean setFullscreen(boolean fullscreen) {
- if(this.fullscreen!=fullscreen) {
+ if(0!=eglWindowHandle && this.fullscreen!=fullscreen) {
this.fullscreen=fullscreen;
if(this.fullscreen) {
setFullScreen0(eglWindowHandle, true);
diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index c42aaa6d9..18dc7dae3 100755
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -54,12 +54,12 @@ public class WindowsWindow extends Window {
}
public long getSurfaceHandle() {
- if (hdc == 0) {
+ if (hdc == 0 && 0!=windowHandle) {
hdc = GetDC(windowHandle);
hmon = MonitorFromWindow(windowHandle);
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
Exception e = new Exception("!!! Window new surface handle "+Thread.currentThread().getName()+
- ",HDC 0x"+Long.toHexString(hdc)+", HMON 0x"+Long.toHexString(hmon));
+ ", HWND 0x"+Long.toHexString(windowHandle)+", HDC 0x"+Long.toHexString(hdc)+", HMON 0x"+Long.toHexString(hmon));
e.printStackTrace();
}
}
@@ -67,21 +67,23 @@ public class WindowsWindow extends Window {
}
public boolean hasDeviceChanged() {
- long _hmon = MonitorFromWindow(windowHandle);
- if (hmon != _hmon) {
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- Exception e = new Exception("!!! Window Device Changed "+Thread.currentThread().getName()+
- ", HMON 0x"+Long.toHexString(hmon)+" -> 0x"+Long.toHexString(_hmon));
- e.printStackTrace();
+ if(0!=windowHandle) {
+ long _hmon = MonitorFromWindow(windowHandle);
+ if (hmon != _hmon) {
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ Exception e = new Exception("!!! Window Device Changed "+Thread.currentThread().getName()+
+ ", HMON 0x"+Long.toHexString(hmon)+" -> 0x"+Long.toHexString(_hmon));
+ e.printStackTrace();
+ }
+ hmon = _hmon;
+ return true;
}
- hmon = _hmon;
- return true;
}
return false;
}
public void disposeSurfaceHandle() {
- if (hdc != 0) {
+ if (0!=hdc && 0!=windowHandle) {
ReleaseDC(windowHandle, hdc);
hdc=0;
if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
@@ -103,6 +105,11 @@ public class WindowsWindow extends Window {
throw new NativeWindowException("Error creating window");
}
windowHandleClose = windowHandle;
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ Exception e = new Exception("!!! Window new window handle "+Thread.currentThread().getName()+
+ ", HWND 0x"+Long.toHexString(windowHandle));
+ e.printStackTrace();
+ }
}
protected void closeNative() {
@@ -124,7 +131,7 @@ public class WindowsWindow extends Window {
}
public void setVisible(boolean visible) {
- if(this.visible!=visible) {
+ if(this.visible!=visible && 0!=windowHandle) {
this.visible=visible;
setVisible0(windowHandle, visible);
}
@@ -132,7 +139,7 @@ public class WindowsWindow extends Window {
// @Override
public void setSize(int width, int height) {
- if (width != this.width || this.height != height) {
+ if (0!=windowHandle && (width != this.width || this.height != height)) {
if(!fullscreen) {
nfs_width=width;
nfs_height=height;
@@ -145,7 +152,7 @@ public class WindowsWindow extends Window {
//@Override
public void setPosition(int x, int y) {
- if (this.x != x || this.y != y) {
+ if (0!=windowHandle && (this.x != x || this.y != y)) {
if(!fullscreen) {
nfs_x=x;
nfs_y=y;
@@ -157,7 +164,7 @@ public class WindowsWindow extends Window {
}
public boolean setFullscreen(boolean fullscreen) {
- if(this.fullscreen!=fullscreen) {
+ if(0!=windowHandle && (this.fullscreen!=fullscreen)) {
int x,y,w,h;
this.fullscreen=fullscreen;
if(fullscreen) {
@@ -191,7 +198,7 @@ public class WindowsWindow extends Window {
if (title == null) {
title = "";
}
- if (!title.equals(getTitle())) {
+ if (0!=windowHandle && !title.equals(getTitle())) {
super.setTitle(title);
setTitle(windowHandle, title);
}
diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java b/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
index bd6bb42c2..380c968d1 100755
--- a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java
@@ -84,7 +84,7 @@ public class X11Window extends Window {
}
public void setVisible(boolean visible) {
- if(this.visible!=visible) {
+ if(0!=windowHandle && this.visible!=visible) {
this.visible=visible;
setVisible0(getDisplayHandle(), windowHandle, visible);
clearEventMask();
@@ -96,6 +96,7 @@ public class X11Window extends Window {
}
public void setSize(int width, int height) {
+ if(0==windowHandle) return;
if(!fullscreen) {
nfs_width=width;
nfs_height=height;
@@ -104,6 +105,7 @@ public class X11Window extends Window {
}
public void setPosition(int x, int y) {
+ if(0==windowHandle) return;
if(!fullscreen) {
nfs_x=x;
nfs_y=y;
@@ -112,7 +114,7 @@ public class X11Window extends Window {
}
public boolean setFullscreen(boolean fullscreen) {
- if(this.fullscreen!=fullscreen) {
+ if(0!=windowHandle && this.fullscreen!=fullscreen) {
int x,y,w,h;
this.fullscreen=fullscreen;
if(fullscreen) {