changeset 47229:7d4896d180e7

8156042: Modifiers of swing ActionEvent does not work when "-Djavafx.embed.singleThread=true" Reviewed-by: azvegint
author psadhukhan
date Thu, 21 Sep 2017 16:17:37 +0530
parents eda0a1f0e83e
children 9712e5af1645
files src/java.desktop/share/classes/java/awt/EventQueue.java
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/share/classes/java/awt/EventQueue.java	Thu Sep 21 14:37:47 2017 +0530
+++ b/src/java.desktop/share/classes/java/awt/EventQueue.java	Thu Sep 21 16:17:37 2017 +0530
@@ -191,6 +191,8 @@
         return eventLog;
     }
 
+    private static boolean fxAppThreadIsDispatchThread;
+
     static {
         AWTAccessor.setEventQueueAccessor(
             new AWTAccessor.EventQueueAccessor() {
@@ -227,6 +229,13 @@
                     return eventQueue.getMostRecentEventTimeImpl();
                 }
             });
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
+            public Object run() {
+                fxAppThreadIsDispatchThread =
+                        "true".equals(System.getProperty("javafx.embed.singleThread"));
+                return null;
+            }
+        });
     }
 
     /**
@@ -854,9 +863,15 @@
     private AWTEvent getCurrentEventImpl() {
         pushPopLock.lock();
         try {
+            if (fxAppThreadIsDispatchThread) {
+                return (currentEvent != null)
+                        ? currentEvent.get()
+                        : null;
+            } else {
                 return (Thread.currentThread() == dispatchThread)
-                ? currentEvent.get()
-                : null;
+                        ? currentEvent.get()
+                        : null;
+            }
         } finally {
             pushPopLock.unlock();
         }
@@ -1247,7 +1262,7 @@
     private void setCurrentEventAndMostRecentTimeImpl(AWTEvent e) {
         pushPopLock.lock();
         try {
-            if (Thread.currentThread() != dispatchThread) {
+            if (!fxAppThreadIsDispatchThread && Thread.currentThread() != dispatchThread) {
                 return;
             }