From 8a66defd3c2c96b05c8868d5edb604e3564ff66d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 21 Mar 2019 00:58:39 +0100 Subject: NewtCanvasJFX: Utilize JFXEDTUtil per default, supporting the Windows Platform On [GNU/Linux] X11 JFXEDTUtil is not required, since X11 can handle multi-threaded native parenting, however, the Windows platform does require JFXEDTUtil. Currently the default is to use JFXEDTUtil, which operates solely on the JavaFX thread for windowing lifecycle and even-dispatch operations. This behavior can be toggled via the boolean property 'jogamp.newt.javafx.UseJFXEDT', which currently defaults to 'true' This behavior might be analyzed in more detail for a fine grained EDTUtil decision. --- .../classes/com/jogamp/newt/javafx/NewtCanvasJFX.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/newt') diff --git a/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java b/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java index 7efde273a..e04ed326d 100644 --- a/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java +++ b/src/newt/classes/com/jogamp/newt/javafx/NewtCanvasJFX.java @@ -28,6 +28,7 @@ package com.jogamp.newt.javafx; +import com.jogamp.common.util.PropertyAccess; import com.jogamp.nativewindow.AbstractGraphicsConfiguration; import com.jogamp.nativewindow.AbstractGraphicsScreen; import com.jogamp.nativewindow.Capabilities; @@ -80,6 +81,7 @@ import com.jogamp.newt.util.EDTUtil; */ public class NewtCanvasJFX extends Canvas implements NativeWindowHolder, WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); + private static final boolean USE_JFX_EDT = PropertyAccess.getBooleanProperty("jogamp.newt.javafx.UseJFXEDT", true, true); private volatile javafx.stage.Window parentWindow = null; private volatile AbstractGraphicsScreen screen = null; @@ -414,12 +416,18 @@ public class NewtCanvasJFX extends Canvas implements NativeWindowHolder, WindowC final int w = clientArea.getWidth(); final int h = clientArea.getHeight(); - // set JFX EDT and start it - if(false) { + if(USE_JFX_EDT) { + // setup JFX EDT and start it final Display newtDisplay = newtChild.getScreen().getDisplay(); - final EDTUtil edtUtil = new JFXEDTUtil(newtDisplay); - edtUtil.start(); - newtDisplay.setEDTUtil( edtUtil ); + final EDTUtil oldEDTUtil = newtDisplay.getEDTUtil(); + if( ! ( oldEDTUtil instanceof JFXEDTUtil ) ) { + final EDTUtil newEDTUtil = new JFXEDTUtil(newtDisplay); + if(DEBUG) { + System.err.println("NewtCanvasJFX.reparentWindow.1: replacing EDTUtil "+oldEDTUtil+" -> "+newEDTUtil); + } + newEDTUtil.start(); + newtDisplay.setEDTUtil( newEDTUtil ); + } } newtChild.setSize(w, h); -- cgit v1.2.3