aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java22
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java82
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java22
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java12
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java53
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Display.java5
-rw-r--r--src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java6
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java7
-rw-r--r--src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java56
-rw-r--r--src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java55
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java11
11 files changed, 185 insertions, 146 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java
index 8f21fef42..418d31503 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/GLXUtil.java
@@ -40,17 +40,27 @@ import com.sun.nativewindow.impl.x11.*;
public class GLXUtil {
public static boolean isMultisampleAvailable(long display) {
- String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
- if (exts != null) {
- return (exts.indexOf("GLX_ARB_multisample") >= 0);
+ try {
+ X11Lib.XLockDisplay(display);
+ String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
+ if (exts != null) {
+ return (exts.indexOf("GLX_ARB_multisample") >= 0);
+ }
+ return false;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
}
- return false;
}
/** Workaround for apparent issue with ATI's proprietary drivers
where direct contexts still send GLX tokens for GL calls */
public static boolean isVendorATI(long display) {
- String vendor = GLX.glXGetClientString(display, GLX.GLX_VENDOR);
- return vendor != null && vendor.startsWith("ATI") ;
+ try {
+ X11Lib.XLockDisplay(display);
+ String vendor = GLX.glXGetClientString(display, GLX.GLX_VENDOR);
+ return vendor != null && vendor.startsWith("ATI") ;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index ebf650ae4..09bea723f 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -181,17 +181,22 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
return gammaRampLength;
}
- int[] size = new int[1];
long display = X11Util.getThreadLocalDefaultDisplay();
- boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
- X11Lib.DefaultScreen(display),
- size, 0);
- if (!res) {
- return 0;
+ try {
+ X11Lib.XLockDisplay(display);
+ int[] size = new int[1];
+ boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
+ X11Lib.DefaultScreen(display),
+ size, 0);
+ if (!res) {
+ return 0;
+ }
+ gotGammaRampLength = true;
+ gammaRampLength = size[0];
+ return gammaRampLength;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
}
- gotGammaRampLength = true;
- gammaRampLength = size[0];
- return gammaRampLength;
}
protected boolean setGammaRamp(float[] ramp) {
@@ -202,13 +207,18 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
}
long display = X11Util.getThreadLocalDefaultDisplay();
- boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- rampData.length,
- rampData, 0,
- rampData, 0,
- rampData, 0);
- return res;
+ try {
+ X11Lib.XLockDisplay(display);
+ boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ rampData.length,
+ rampData, 0,
+ rampData, 0,
+ rampData, 0);
+ return res;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
+ }
}
protected Buffer getGammaRamp() {
@@ -224,16 +234,21 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = X11Util.getThreadLocalDefaultDisplay();
- boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- if (!res) {
- return null;
+ try {
+ X11Lib.XLockDisplay(display);
+ boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ if (!res) {
+ return null;
+ }
+ return rampData;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
}
- return rampData;
}
protected void resetGammaRamp(Buffer originalGammaRamp) {
@@ -255,11 +270,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
long display = X11Util.getThreadLocalDefaultDisplay();
- X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
+ try {
+ X11Lib.XLockDisplay(display);
+ X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ } finally {
+ X11Lib.XUnlockDisplay(display);
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 0d19d2063..908d12aa1 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -79,9 +79,10 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
// Utilizing FBConfig
//
GLCapabilities capsFB = null;
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ long display = x11Screen.getDevice().getHandle();
try {
- long display = x11Screen.getDevice().getHandle();
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ X11Lib.XLockDisplay(display);
int screen = x11Screen.getIndex();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
@@ -106,6 +107,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
} catch (Throwable t) {
} finally {
+ X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
@@ -183,11 +185,12 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
// Utilizing FBConfig
//
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ AbstractGraphicsDevice absDevice = x11Screen.getDevice();
+ long display = absDevice.getHandle();
try {
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ X11Lib.XLockDisplay(display);
int screen = x11Screen.getIndex();
- AbstractGraphicsDevice absDevice = x11Screen.getDevice();
- long display = absDevice.getHandle();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, true, isMultisampleAvailable, display, screen);
int[] count = { -1 };
@@ -247,6 +250,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
}
} finally {
+ X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
@@ -271,11 +275,12 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
XVisualInfo retXVisualInfo = null;
int chosen=-1;
- NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ AbstractGraphicsDevice absDevice = x11Screen.getDevice();
+ long display = absDevice.getHandle();
try {
+ NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
+ X11Lib.XLockDisplay(display);
int screen = x11Screen.getIndex();
- AbstractGraphicsDevice absDevice = x11Screen.getDevice();
- long display = absDevice.getHandle();
boolean isMultisampleAvailable = GLXUtil.isMultisampleAvailable(display);
int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capabilities, false, isMultisampleAvailable, display, screen);
XVisualInfo[] infos = null;
@@ -326,6 +331,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
retXVisualInfo = XVisualInfo.create(infos[chosen]);
} finally {
+ X11Lib.XUnlockDisplay(display);
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, 0, -1);
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
index c8b8851f8..e02df3cc6 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OffscreenGLXDrawable.java
@@ -76,6 +76,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
getFactoryImpl().lockToolkit();
try {
+ X11Lib.XLockDisplay(dpy);
pixmap = X11Lib.XCreatePixmap(dpy, (int) X11Lib.RootWindow(dpy, screen),
component.getWidth(), component.getHeight(), bitsPerPixel);
if (pixmap == 0) {
@@ -94,15 +95,20 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
", display " + toHexString(dpy));
}
} finally {
+ X11Lib.XUnlockDisplay(dpy);
getFactoryImpl().unlockToolkit();
}
}
public void destroy() {
if (pixmap == 0) return;
+
+ NativeWindow nw = getNativeWindow();
+ long display = nw.getDisplayHandle();
try {
- NativeWindow nw = getNativeWindow();
- long display = nw.getDisplayHandle();
+ getFactoryImpl().lockToolkit();
+ X11Lib.XLockDisplay(display);
+
long drawable = nw.getSurfaceHandle();
if (DEBUG) {
System.err.println("Destroying pixmap " + toHexString(pixmap) +
@@ -111,7 +117,6 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
}
// Must destroy pixmap and GLXPixmap
- getFactoryImpl().lockToolkit();
if (DEBUG) {
long cur = GLX.glXGetCurrentContext();
@@ -133,6 +138,7 @@ public class X11OffscreenGLXDrawable extends X11GLXDrawable {
display = 0;
((SurfaceChangeable)nw).setSurfaceHandle(0);
} finally {
+ X11Lib.XUnlockDisplay(display);
getFactoryImpl().unlockToolkit();
}
}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
index 890f017ab..d6abf291f 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
@@ -56,14 +56,21 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
xvi_temp.visualid(visualID);
xvi_temp.screen(screen.getIndex());
int num[] = { -1 };
+ long display = screen.getDevice().getHandle();
- XVisualInfo[] xvis = X11Lib.XGetVisualInfoCopied(screen.getDevice().getHandle(), X11Lib.VisualIDMask|X11Lib.VisualScreenMask, xvi_temp, num, 0);
+ try {
+ X11Lib.XLockDisplay(display);
+ XVisualInfo[] xvis = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualIDMask|X11Lib.VisualScreenMask, xvi_temp, num, 0);
- if(xvis==null || num[0]<1) {
- return null;
+ if(xvis==null || num[0]<1) {
+ return null;
+ }
+
+ return XVisualInfo.create(xvis[0]);
+ } finally {
+ X11Lib.XUnlockDisplay(display);
}
- return XVisualInfo.create(xvis[0]);
}
public static XVisualInfo getXVisualInfo(AbstractGraphicsScreen screen, Capabilities capabilities)
@@ -81,25 +88,31 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
XVisualInfo vinfo_template = XVisualInfo.create();
vinfo_template.screen(screen.getIndex());
vinfo_template.c_class(c_class);
+ long display = screen.getDevice().getHandle();
- XVisualInfo[] vinfos = X11Lib.XGetVisualInfoCopied(screen.getDevice().getHandle(), X11Lib.VisualScreenMask, vinfo_template, num, 0);
- XVisualInfo best=null;
- int rdepth = capabilities.getRedBits() + capabilities.getGreenBits() + capabilities.getBlueBits() + capabilities.getAlphaBits();
- for (int i = 0; vinfos!=null && i < num[0]; i++) {
- if ( best == null ||
- best.depth() < vinfos[i].depth() )
- {
- best = vinfos[i];
- if(rdepth <= best.depth())
- break;
+ try {
+ X11Lib.XLockDisplay(display);
+ XVisualInfo[] vinfos = X11Lib.XGetVisualInfoCopied(display, X11Lib.VisualScreenMask, vinfo_template, num, 0);
+ XVisualInfo best=null;
+ int rdepth = capabilities.getRedBits() + capabilities.getGreenBits() + capabilities.getBlueBits() + capabilities.getAlphaBits();
+ for (int i = 0; vinfos!=null && i < num[0]; i++) {
+ if ( best == null ||
+ best.depth() < vinfos[i].depth() )
+ {
+ best = vinfos[i];
+ if(rdepth <= best.depth())
+ break;
+ }
}
- }
- if ( null!=best && ( rdepth <= best.depth() || 24 == best.depth()) ) {
- ret = XVisualInfo.create(best);
- }
- best = null;
+ if ( null!=best && ( rdepth <= best.depth() || 24 == best.depth()) ) {
+ ret = XVisualInfo.create(best);
+ }
+ best = null;
- return ret;
+ return ret;
+ } finally {
+ X11Lib.XUnlockDisplay(display);
+ }
}
}
diff --git a/src/newt/classes/com/sun/javafx/newt/Display.java b/src/newt/classes/com/sun/javafx/newt/Display.java
index 97d5465c9..a4b7a4f51 100755
--- a/src/newt/classes/com/sun/javafx/newt/Display.java
+++ b/src/newt/classes/com/sun/javafx/newt/Display.java
@@ -203,20 +203,21 @@ public abstract class Display {
}
if(null!=eventDispatchThread) {
final Display f_dpy = this;
+ final EventDispatchThread f_edt = eventDispatchThread;
eventDispatchThread.invokeAndWait(new Runnable() {
public void run() {
f_dpy.closeNative();
+ f_edt.stop();
}
} );
} else {
closeNative();
}
- aDevice = null;
if(null!=eventDispatchThread) {
- eventDispatchThread.stop();
eventDispatchThread.waitUntilStopped();
eventDispatchThread=null;
}
+ aDevice = null;
} else {
if(DEBUG) {
System.err.println("Display.destroy("+name+") KEEP: refCount "+refCount+", "+this+" "+Thread.currentThread());
diff --git a/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java b/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java
index b5efc03e8..11ce8e6c7 100644
--- a/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/OffscreenWindow.java
@@ -68,15 +68,11 @@ public class OffscreenWindow extends Window implements SurfaceChangeable {
public void invalidate() {
super.invalidate();
- disposeSurfaceHandle();
- }
-
- public void disposeSurfaceHandle() {
surfaceHandle = 0;
}
public synchronized void destroy() {
- disposeSurfaceHandle();
+ surfaceHandle = 0;
}
public void setSurfaceHandle(long handle) {
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index 8260b1a16..58bd251d2 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -411,13 +411,6 @@ public abstract class Window implements NativeWindow
return windowHandle; // default: return window handle
}
- /** Special method to dispose a surface handle,
- in case of a device change _and_ where there
- is a different semantics of window handle and surface handle.
- This is currently only true for Windows. */
- public void disposeSurfaceHandle() {
- }
-
public AbstractGraphicsConfiguration getGraphicsConfiguration() {
return config;
}
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 aebf8f9dd..e809d2cdc 100644
--- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
@@ -54,14 +54,14 @@ import java.util.*;
public class GLWindow extends Window implements GLAutoDrawable {
private static List/*GLWindow*/ glwindows = new ArrayList();
- private boolean ownerOfDisplayAndScreen;
+ private boolean ownerOfWinScrDpy;
private Window window;
private boolean runPumpMessages;
/** Constructor. Do not call this directly -- use {@link
create()} instead. */
- protected GLWindow(Window window, boolean ownerOfDisplayAndScreen) {
- this.ownerOfDisplayAndScreen = ownerOfDisplayAndScreen;
+ protected GLWindow(Window window, boolean ownerOfWinScrDpy) {
+ this.ownerOfWinScrDpy = ownerOfWinScrDpy;
this.window = window;
this.window.setAutoDrawableClient(true);
this.runPumpMessages = ( null == getScreen().getDisplay().getEDT() ) ;
@@ -118,18 +118,18 @@ public class GLWindow extends Window implements GLAutoDrawable {
GLCapabilities caps,
boolean undecorated) {
Display display;
- boolean ownerOfDisplayAndScreen=false;
+ boolean ownerOfWinScrDpy=false;
if (window == null) {
if (caps == null) {
caps = new GLCapabilities(null); // default ..
}
- ownerOfDisplayAndScreen = true;
+ ownerOfWinScrDpy = true;
display = NewtFactory.createDisplay(null); // local display
Screen screen = NewtFactory.createScreen(display, 0); // screen 0
window = NewtFactory.createWindow(screen, caps, undecorated);
}
- return new GLWindow(window, ownerOfDisplayAndScreen);
+ return new GLWindow(window, ownerOfWinScrDpy);
}
/**
@@ -165,13 +165,15 @@ public class GLWindow extends Window implements GLAutoDrawable {
shouldNotCallThis();
}
- protected void dispose(boolean regenerate) {
+ protected void dispose(boolean regenerate, boolean sendEvent) {
if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- Exception e1 = new Exception("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", 1: "+this);
+ Exception e1 = new Exception("GLWindow.dispose("+regenerate+") "+Thread.currentThread()+", 1");
e1.printStackTrace();
}
- sendDisposeEvent();
+ if(sendEvent) {
+ sendDisposeEvent();
+ }
if (context != null) {
context.destroy();
@@ -180,10 +182,6 @@ public class GLWindow extends Window implements GLAutoDrawable {
drawable.setRealized(false);
}
- if(null!=window) {
- window.disposeSurfaceHandle();
- }
-
if(regenerate) {
if(null==window) {
throw new GLException("GLWindow.dispose(true): null window");
@@ -208,10 +206,11 @@ public class GLWindow extends Window implements GLAutoDrawable {
}
public synchronized void destroy() {
- destroy(false);
+ destroy(true);
}
- public synchronized void destroy(boolean deep) {
+ /** @param sendDisposeEvent should be false in a [time,reliable] critical shutdown */
+ public synchronized void destroy(boolean sendDisposeEvent) {
if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
Exception e1 = new Exception("GLWindow.destroy "+Thread.currentThread()+", 1: "+this);
e1.printStackTrace();
@@ -221,34 +220,21 @@ public class GLWindow extends Window implements GLAutoDrawable {
newglw.remove(this);
glwindows=newglw;
- dispose(false);
+ dispose(false, sendDisposeEvent);
- Screen _screen = null;
- Display _device = null;
if(null!=window) {
- if(!deep && ownerOfDisplayAndScreen) {
- _screen = getScreen();
- if(null != _screen) {
- _device = _screen.getDisplay();
- }
+ if(ownerOfWinScrDpy) {
+ window.destroy(true);
}
- window.destroy(deep);
- }
-
- if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
- System.out.println("GLWindow.destroy "+Thread.currentThread()+", fin: "+this);
}
drawable = null;
context = null;
+ window = null;
- if(null != _screen) {
- _screen.destroy();
- }
- if(null != _device) {
- _device.destroy();
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println("GLWindow.destroy "+Thread.currentThread()+", fin: "+this);
}
- window = null;
}
public boolean getPerfLogEnabled() { return perfLog; }
@@ -453,7 +439,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
window.getScreen().getDisplay().pumpMessages();
}
if(window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED) {
- dispose(true);
+ dispose(true, true);
}
if (sendDestroy) {
destroy();
diff --git a/src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java b/src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java
index e5a98cc55..a98ebab93 100644
--- a/src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java
+++ b/src/newt/classes/com/sun/javafx/newt/util/EventDispatchThread.java
@@ -55,7 +55,7 @@ public class EventDispatchThread {
public EventDispatchThread(Display display, ThreadGroup tg, String name) {
this.display = display;
this.threadGroup = tg;
- this.name=new String("EDT-"+name);
+ this.name=new String("EDT-Display_"+display.getName()+"-"+name);
}
public String getName() { return name; }
@@ -101,8 +101,12 @@ public class EventDispatchThread {
}
}
- public boolean isEDTThread(Thread thread) {
- return taskWorker == thread;
+ public boolean isThreadEDT(Thread thread) {
+ return null!=taskWorker && taskWorker == thread;
+ }
+
+ public boolean isCurrentThreadEDT() {
+ return null!=taskWorker && taskWorker == Thread.currentThread();
}
public boolean isRunning() {
@@ -114,8 +118,13 @@ public class EventDispatchThread {
return;
}
synchronized(taskWorkerLock) {
- tasks.add(task);
- taskWorkerLock.notifyAll();
+ if(null!=taskWorker && taskWorker.isRunning() && taskWorker != Thread.currentThread() ) {
+ tasks.add(task);
+ taskWorkerLock.notifyAll();
+ } else {
+ // if !running or isEDTThread, do it right away
+ task.run();
+ }
}
}
@@ -173,29 +182,39 @@ public class EventDispatchThread {
}
}
+ /**
+ * Utilizing taskWorkerLock only for local resources and task execution,
+ * not for event dispatching.
+ */
public void run() {
if(DEBUG) {
System.out.println(Thread.currentThread()+": EDT run() START");
}
while(!shouldStop) {
try {
- // wait for something todo ..
- synchronized(taskWorkerLock) {
- while(!shouldStop && tasks.size()==0) {
- try {
- display.pumpMessages(); // event dispatch
- taskWorkerLock.wait(edtPollGranularity);
- } catch (InterruptedException e) {
- e.printStackTrace();
+ // wait for something todo
+ while(!shouldStop && tasks.size()==0) {
+ synchronized(taskWorkerLock) {
+ if(!shouldStop && tasks.size()==0) {
+ try {
+ taskWorkerLock.wait(edtPollGranularity);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
}
}
- if(tasks.size()>0) {
- Runnable task = (Runnable) tasks.remove(0);
- task.run();
- taskWorkerLock.notifyAll();
+ display.pumpMessages(); // event dispatch
+ }
+ if(!shouldStop && tasks.size()>0) {
+ synchronized(taskWorkerLock) {
+ if(!shouldStop && tasks.size()>0) {
+ Runnable task = (Runnable) tasks.remove(0);
+ task.run();
+ taskWorkerLock.notifyAll();
+ }
}
+ display.pumpMessages(); // event dispatch
}
- display.pumpMessages(); // event dispatch
} catch (Throwable t) {
// handle errors ..
t.printStackTrace();
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 5749039aa..1b5bf80cf 100755
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -106,17 +106,6 @@ public class WindowsWindow extends Window {
return false;
}
- public void disposeSurfaceHandle() {
- if (0!=hdc && 0!=windowHandle) {
- ReleaseDC(windowHandle, hdc);
- hdc=0;
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- Exception e = new Exception("!!! Window surface handle disposed "+Thread.currentThread().getName()+", "+Thread.currentThread());
- e.printStackTrace();
- }
- }
- }
-
protected void createNative(long parentWindowHandle, Capabilities caps) {
WindowsScreen screen = (WindowsScreen) getScreen();
WindowsDisplay display = (WindowsDisplay) screen.getDisplay();