changeset 6973:1a3075ba2181

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8u/master/jfx/rt
author kcr
date Thu, 08 May 2014 16:56:06 -0700
parents 8a32fefcbfca 145baf8cea42
children c6469a243a3c
files
diffstat 87 files changed, 992 insertions(+), 398 deletions(-) [+]
line wrap: on
line diff
--- a/apps/toys/Hello/src/main/java/hello/HelloPagination.java	Wed May 07 07:56:04 2014 -0700
+++ b/apps/toys/Hello/src/main/java/hello/HelloPagination.java	Thu May 08 16:56:06 2014 -0700
@@ -102,6 +102,15 @@
             pagination.setCurrentPageIndex(8);
         });
 
+        Button setStyle = new Button("change style");
+        setStyle.setOnAction(t -> {
+            if (pagination.getStyleClass().contains(Pagination.STYLE_CLASS_BULLET)) {
+                pagination.getStyleClass().remove(Pagination.STYLE_CLASS_BULLET);
+            } else {
+                pagination.getStyleClass().add(Pagination.STYLE_CLASS_BULLET);
+            }
+        });
+
         Button getCurrentPageIndex = new Button("getCurrentPageIndex");
         getCurrentPageIndex.setOnAction(t -> System.out.println("getCurrentPageIndex = " + pagination.getCurrentPageIndex()));
 
@@ -132,7 +141,7 @@
         toolbar.getChildren().addAll(
                 setMaxPageIndicatorCount,
                 setCurrentPageIndex, setCurrentPageIndex2, setCurrentPageIndex3,
-                setOldPageFactory, setNewPageFactory,
+                setOldPageFactory, setNewPageFactory, setStyle,
                 setPageCount, setPageCount2, setPageCount3,
                 getMaxPageIndicatorCount,
                 getCurrentPageIndex);
--- a/build.gradle	Wed May 07 07:56:04 2014 -0700
+++ b/build.gradle	Thu May 08 16:56:06 2014 -0700
@@ -322,6 +322,10 @@
 defineProperty("COMPILE_PARFAIT", "false")
 ext.IS_COMPILE_PARFAIT = Boolean.parseBoolean(COMPILE_PARFAIT)
 
+// COMPILE_JFR specifies whether to build code that logs to JRockit Flight Recorder
+defineProperty("COMPILE_JFR", Boolean.toString(file("$JDK_HOME/jre/lib/jfr.jar").exists()))
+ext.IS_COMPILE_JFR = Boolean.parseBoolean(COMPILE_JFR)
+
 // RETAIN_PACKAGER_TESTS specifies whether the tests in fxpackager should
 // keep generated files instead of attempting to automatically delete them
 defineProperty("RETAIN_PACKAGER_TESTS", "false")
@@ -1215,7 +1219,7 @@
         sourceSets.main.java.srcDirs += "src/main/java7"
     }
 
-    if (file("$JDK_HOME/jre/lib/jfr.jar").exists()) {
+    if (IS_COMPILE_JFR) {
         sourceSets.main.java.srcDirs += "src/main/java-jfr"
     }
 
@@ -1512,6 +1516,16 @@
     classes << {
         // Copy all of the download libraries to the libs directory for the sake of the IDEs
         File libsDir = rootProject.file("build/libs");
+        
+        // In some IDEs (Eclipse for example), touching these libraries cauese a full build
+        // within the IDE.  When gradle is used outside of the IDE, for example to build the
+        // native code, a full rebuild is caused within the IDE.  The fix is to check for the 
+        // lib directory and not copy the files
+        //
+        // This means that in order to update the dependent libraries for the IDE's, a clean
+        // build is required
+        //
+        if (libsDir.exists()) return;
         libsDir.mkdirs();
         for (File f : [configurations.compile.files, configurations.antlr3.files].flatten()) {
             copy {
--- a/buildSrc/x86egl.gradle	Wed May 07 07:56:04 2014 -0700
+++ b/buildSrc/x86egl.gradle	Thu May 08 16:56:06 2014 -0700
@@ -525,8 +525,8 @@
 X86EGL.media.linker = linker
 X86EGL.media.lib = "ar"
 
-X86EG.deploy = [:]
-X86EG.deploy.publicLibraryFilter = [
+X86EGL.deploy = [:]
+X86EGL.deploy.publicLibraryFilter = [
   "fxavcodecplugin-52.so",
   "fxavcodecplugin-53.so",
   "fxplugins.so",
@@ -536,4 +536,4 @@
   "libprism_es2_eglx11.so",
   "libglass_lens_fb.so"
 ]
-X86EG.deploy.compressBigJar=true
+X86EGL.deploy.compressBigJar=true
--- a/gradle.properties.template	Wed May 07 07:56:04 2014 -0700
+++ b/gradle.properties.template	Thu May 08 16:56:06 2014 -0700
@@ -45,6 +45,10 @@
 #COMPILE_WEBKIT = true
 #COMPILE_MEDIA = true
 
+#To disable building support for JRockit Flight Recorder, uncomment the line below
+
+#COMPILE_JFR = false
+
 # The building of JavaDoc takes time. By default we disable the building of JavaDoc
 # so as to speed up the time in incremental builds. Uncomment this flag in order to
 # build all the JavaDoc
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/PaginationSkin.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/PaginationSkin.java	Thu May 08 16:56:06 2014 -0700
@@ -746,16 +746,13 @@
                 minButtonSize = newFont.getSize() * 2;
                 for(Node child: controlBox.getChildren()) {
                     ((Control)child).setMinSize(minButtonSize, minButtonSize);
-                    // RT-33327 : min size is set on the toggle button but the
-                    // pref size does not match as computed by LabeledSkinBase#computePrefHeight
-                    // so setting the prefSize ensures the desired size on the button.
-                    ((Control)child).setPrefSize(minButtonSize, minButtonSize);
                 }
                 // We want to relayout the indicator buttons because the size has changed.
                 requestLayout();
             });
             leftArrowButton.setMinSize(minButtonSize, minButtonSize);
-            leftArrowButton.setPrefSize(minButtonSize, minButtonSize);
+            leftArrowButton.prefWidthProperty().bind(leftArrowButton.minWidthProperty());
+            leftArrowButton.prefHeightProperty().bind(leftArrowButton.minHeightProperty());
             leftArrowButton.getStyleClass().add("left-arrow-button");
             leftArrowButton.setFocusTraversable(false);
             HBox.setMargin(leftArrowButton, new Insets(0, snapSize(arrowButtonGap.get()), 0, 0));
@@ -774,7 +771,8 @@
                 }
             };
             rightArrowButton.setMinSize(minButtonSize, minButtonSize);
-            rightArrowButton.setPrefSize(minButtonSize, minButtonSize);
+            rightArrowButton.prefWidthProperty().bind(rightArrowButton.minWidthProperty());
+            rightArrowButton.prefHeightProperty().bind(rightArrowButton.minHeightProperty());
             rightArrowButton.getStyleClass().add("right-arrow-button");
             rightArrowButton.setFocusTraversable(false);
             HBox.setMargin(rightArrowButton, new Insets(0, 0, 0, snapSize(arrowButtonGap.get())));
@@ -1210,6 +1208,8 @@
             tooltipVisibleProperty().addListener((ov, oldValue, newValue) -> {
                 setTooltipVisible(newValue);
             });
+
+            prefHeightProperty().bind(minHeightProperty());
         }
 
         private void setIndicatorType() {
@@ -1217,10 +1217,16 @@
                 getStyleClass().remove("number-button");
                 getStyleClass().add("bullet-button");
                 setText(null);
+
+                // Bind the width in addition to the height to ensure the region is square
+                prefWidthProperty().bind(minWidthProperty());
             } else {
                 getStyleClass().remove("bullet-button");
                 getStyleClass().add("number-button");
                 setText(Integer.toString(this.pageNumber + 1));
+
+                // Free the width to conform to the text content
+                prefWidthProperty().unbind();
             }
         }
 
--- a/modules/controls/src/main/java/javafx/scene/chart/CategoryAxis.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/controls/src/main/java/javafx/scene/chart/CategoryAxis.java	Thu May 08 16:56:06 2014 -0700
@@ -450,6 +450,10 @@
         allDataCategories.addAll(categoryNames);
     }
 
+    final List<String> getAllDataCategories() {
+        return allDataCategories;
+    }
+
     /**
      * Get the display position along this axis for a given value
      *
--- a/modules/controls/src/main/java/javafx/scene/chart/PieChart.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/controls/src/main/java/javafx/scene/chart/PieChart.java	Thu May 08 16:56:06 2014 -0700
@@ -86,7 +86,6 @@
 
     // -------------- PRIVATE FIELDS -----------------------------------------------------------------------------------
     private static final int MIN_PIE_RADIUS = 25;
-    private int defaultColorIndex = 0;
     private static final double LABEL_TICK_GAP = 6;
     private static final double LABEL_BALL_RADIUS = 2;
     private static int uniqueId = 0;
@@ -144,7 +143,7 @@
         }
         for(int i=c.getFrom(); i<c.getTo(); i++) {
             Data item = getData().get(i);
-            dataItemAdded(item);
+            dataItemAdded(item, i);
         }
         // update legend if any data has changed
         if (isLegendVisible() && (c.getRemoved().size() > 0 || c.getFrom() < c.getTo())) updateLegend();
@@ -358,7 +357,7 @@
         }
     }
 
-    private Node createArcRegion(Data item) {
+    private Node createArcRegion(Data item, int index) {
         Node arcRegion = item.getNode();
         // check if symbol has already been created
         if (arcRegion == null) {
@@ -367,7 +366,7 @@
             item.setNode(arcRegion);
         }
         // Note: not sure if we want to add or check, ie be more careful and efficient here
-        arcRegion.getStyleClass().setAll("chart-pie", "data" + getUniqueId(), item.defaultColorStyleString);
+        arcRegion.getStyleClass().setAll("chart-pie", "data" + getUniqueId(), "default-color"+(index % 8));
         if (item.getPieValue() < 0) {
             arcRegion.getStyleClass().add("negative");
         }
@@ -380,12 +379,10 @@
         return text;
     }
 
-    private void dataItemAdded(final Data item) {
+    private void dataItemAdded(final Data item, int index) {
         // set default color styleClass
-        item.defaultColorStyleString = "default-color"+(defaultColorIndex % 8);
-        defaultColorIndex ++;
         // create shape
-        Node shape = createArcRegion(item);
+        Node shape = createArcRegion(item, index);
         final Text text = createPieLabel(item);
         item.getChart().getChartChildren().add(shape);
         if (shouldAnimate()) {
@@ -794,7 +791,6 @@
          * Next pointer for the next data item : so we can do animation on data delete.
          */
         private Data next = null;
-        private String defaultColorStyleString;
 
         // -------------- PUBLIC PROPERTIES ------------------------------------
 
--- a/modules/controls/src/main/java/javafx/scene/chart/StackedBarChart.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/controls/src/main/java/javafx/scene/chart/StackedBarChart.java	Thu May 08 16:56:06 2014 -0700
@@ -381,69 +381,43 @@
     @Override protected void updateAxisRange() {
         // This override is necessary to update axis range based on cumulative Y value for the
         // Y axis instead of the inherited way where the max value in the data range is used.
-        final Axis<X> xa = getXAxis();
-        final Axis<Y> ya = getYAxis();
-        if (xa.isAutoRanging()) {
-            List xData = new ArrayList<Number>();
-            if (xa instanceof CategoryAxis) {
-                xData.addAll(categoryAxis.getCategories());
-            } else {
-                int catIndex = 0;
-                for (String category : categoryAxis.getCategories()) {
-                    int index = 0;
-                    double totalXN = 0;
-                    double totalXP = 0;
-                    Iterator<Series<X, Y>> seriesIterator = getDisplayedSeriesIterator();
-                    while (seriesIterator.hasNext()) {
-                        Series<X, Y> series = seriesIterator.next();
-                        for (final Data<X, Y> item : getDataItem(series, index, catIndex, category)) {;
-                            if (item != null) {
-                                boolean isNegative = item.getNode().getStyleClass().contains("negative");
-                                if (!isNegative) {
-                                    totalXP += xa.toNumericValue(item.getXValue());
-                                } else {
-                                    totalXN += xa.toNumericValue(item.getXValue());
-                                }
+        boolean categoryIsX = categoryAxis == getXAxis();
+        if (categoryAxis.isAutoRanging()) {
+            List cData = new ArrayList();
+            for (Series<X, Y> series : getData()) {
+                for (Data<X, Y> data : series.getData()) {
+                    if (data != null) cData.add(categoryIsX ? data.getXValue() : data.getYValue());
+                }
+            }
+            categoryAxis.invalidateRange(cData);
+        }
+        if (valueAxis.isAutoRanging()) {
+            List<Number> vData = new ArrayList<>();
+            int catIndex = 0;
+            for (String category : categoryAxis.getAllDataCategories()) {
+                int index = 0;
+                double totalXN = 0;
+                double totalXP = 0;
+                Iterator<Series<X, Y>> seriesIterator = getDisplayedSeriesIterator();
+                while (seriesIterator.hasNext()) {
+                    Series<X, Y> series = seriesIterator.next();
+                    for (final Data<X, Y> item : getDataItem(series, index, catIndex, category)) {;
+                        if (item != null) {
+                            boolean isNegative = item.getNode().getStyleClass().contains("negative");
+                            Number value = (Number) (categoryIsX ? item.getYValue() : item.getXValue());
+                            if (!isNegative) {
+                                totalXP += valueAxis.toNumericValue(value);
+                            } else {
+                                totalXN += valueAxis.toNumericValue(value);
                             }
                         }
                     }
-                    xData.add(totalXP);
-                    xData.add(totalXN);
-                    catIndex++;
                 }
+                vData.add(totalXP);
+                vData.add(totalXN);
+                catIndex++;
             }
-            xa.invalidateRange(xData);
-        }
-        if (ya.isAutoRanging()) {
-            List yData = new ArrayList<Number>();
-            if (ya instanceof CategoryAxis) {
-                yData.addAll(categoryAxis.getCategories());
-            } else {
-                int catIndex = 0;
-                for (String category : categoryAxis.getCategories()) {
-                    int index = 0;
-                    double totalYP = 0;
-                    double totalYN = 0;
-                    Iterator<Series<X, Y>> seriesIterator = getDisplayedSeriesIterator();
-                    while (seriesIterator.hasNext()) {
-                        Series<X, Y> series = seriesIterator.next();
-                        for (final Data<X, Y> item : getDataItem(series, index, catIndex, category)) {;
-                            if(item != null) {
-                                boolean isNegative = item.getNode().getStyleClass().contains("negative");
-                                if (!isNegative) {
-                                    totalYP += ya.toNumericValue(item.getYValue());
-                                } else {
-                                    totalYN += ya.toNumericValue(item.getYValue());
-                                }
-                            }
-                        }
-                    }
-                    yData.add(totalYP);
-                    yData.add(totalYN);
-                    catIndex++;
-                }
-            }
-            ya.invalidateRange(yData);
+            valueAxis.invalidateRange(vData);
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/StandardBundlerParam.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/StandardBundlerParam.java	Thu May 08 16:56:06 2014 -0700
@@ -176,6 +176,12 @@
                     (s, p) -> {
                         File appResourcesRoot = APP_RESOURCES.fetchFrom(p).getBaseDirectory();
                         File f = new File(appResourcesRoot, s);
+                        if (!f.exists()) {
+                            throw new IllegalArgumentException(
+                                new ConfigException(
+                                    MessageFormat.format(I18N.getString("error.main-jar-does-not-exist"), s),
+                                    I18N.getString("error.main-jar-does-not-exist.advice")));
+                        }
                         return new RelativeFileSet(appResourcesRoot, new LinkedHashSet<>(Arrays.asList(f)));
                     }
             );
@@ -468,7 +474,6 @@
             srcdir = rfs.getBaseDirectory();
         }
 
-
         String declaredMainClass = (String) params.get(MAIN_CLASS.getID());
 
         // presume the set iterates in-order
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxAppBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxAppBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -126,7 +126,11 @@
 
             return doValidate(p);
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxDebBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxDebBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -223,7 +223,11 @@
 
             return true;
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxRpmBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/linux/LinuxRpmBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -166,7 +166,11 @@
 
             return true;
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -280,7 +280,11 @@
         try {
             return doValidate(params);
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppStoreBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacAppStoreBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -352,7 +352,11 @@
 
             return true;
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacDaemonBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacDaemonBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -238,7 +238,11 @@
         try {
             return doValidate(params);
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
 
     }
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacDmgBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacDmgBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -499,7 +499,11 @@
 
             return true;
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacPkgBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/mac/MacPkgBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -476,7 +476,11 @@
 
             return true;
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinAppBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinAppBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -174,7 +174,11 @@
 
             return doValidate(params);
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinExeBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinExeBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -286,7 +286,11 @@
 
             return true;
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinMsiBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinMsiBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -319,7 +319,11 @@
 
             return true;
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinServiceBundler.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinServiceBundler.java	Thu May 08 16:56:06 2014 -0700
@@ -97,7 +97,11 @@
 
             return doValidate(params);
         } catch (RuntimeException re) {
-            throw new ConfigException(re);
+            if (re.getCause() instanceof ConfigException) {
+                throw (ConfigException) re.getCause();
+            } else {
+                throw new ConfigException(re);
+            }
         }
     }
 
--- a/modules/fxpackager/src/main/resources/com/oracle/tools/packager/StandardBundlerParam.properties	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/main/resources/com/oracle/tools/packager/StandardBundlerParam.properties	Thu May 08 16:56:06 2014 -0700
@@ -104,6 +104,8 @@
 error.no-main-class-with-classpath.advice=Please specify a applicationClass or ensure that the classpath has a jar containing one in the manifest.
 error.no-main-class=An application class was not specified nor was one found in the supplied application resources
 error.no-main-class.advice=Please specify a applicationClass or ensure that the appResources has a jar containing one in the manifest.
+error.main-jar-does-not-exist=The configured main jar does not exist {0}
+error.main-jar-does-not-exist.advice=The main jar must be specified relative to the app resources (not an absolute path), and must exist within those resources.
 
 message.fx-app-does-not-match-specified-main=The jar {0} has an FX Application class{1} that does not match the declared main {2}
 message.main-class-does-not-match-specified-main=The jar {0} has a main class {1} that does not match the declared main {2}
--- a/modules/fxpackager/src/test/java/com/oracle/tools/packager/BundlersTest.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/fxpackager/src/test/java/com/oracle/tools/packager/BundlersTest.java	Thu May 08 16:56:06 2014 -0700
@@ -25,12 +25,6 @@
 
 package com.oracle.tools.packager;
 
-import com.oracle.tools.packager.Bundler;
-import com.oracle.tools.packager.BundlerParamInfo;
-import com.oracle.tools.packager.Bundlers;
-import com.oracle.tools.packager.StandardBundlerParam;
-import com.oracle.tools.packager.ConfigException;
-import com.oracle.tools.packager.UnsupportedPlatformException;
 import com.oracle.tools.packager.windows.WinExeBundler;
 import com.oracle.tools.packager.windows.WinMsiBundler;
 import org.junit.Test;
@@ -38,7 +32,14 @@
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -237,4 +238,20 @@
         assertTrue(WinMsiBundler.MSI_SYSTEM_WIDE.fetchFrom(params));
         assertTrue(WinExeBundler.EXE_SYSTEM_WIDE.fetchFrom(params));
     }
+
+    @Test
+    public void badMainJar() {
+        try {
+            Map<String, ? super Object> params = new TreeMap<>();
+            params.put(StandardBundlerParam.APP_RESOURCES.getID(), new RelativeFileSet(new File("."), Collections.emptySet()));
+            params.put(StandardBundlerParam.MAIN_JAR.getID(), "this_jar_must_not_exist.jar");
+
+            StandardBundlerParam.MAIN_JAR.fetchFrom(params);
+
+            fail("An exception should have been thrown");
+        } catch (RuntimeException re) {
+            assertTrue("RuntimeException wraps a ConfigException", re.getCause() instanceof ConfigException);
+        }
+    }
+
 }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/Screen.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/Screen.java	Thu May 08 16:56:06 2014 -0700
@@ -76,6 +76,7 @@
     private static EventHandler eventHandler;
     
     private volatile long ptr;
+    private volatile int adapter;
 
     private final int depth;
 
@@ -231,7 +232,15 @@
     private void dispose() {
         this.ptr = 0L;
     }
-    
+
+    public int getAdapterOrdinal() {
+        return this.adapter;
+    }
+
+    public void setAdapterOrdinal(int adapter) {
+        this.adapter = adapter;
+    }
+
     public static void setEventHandler(EventHandler eh) {
         Application.checkEventThread();
         eventHandler = eh;
@@ -240,7 +249,7 @@
     /**
      * Called from native when the Screen definitions change.
      */
-    private static void notifySettingsChanged() {
+    public static void notifySettingsChanged() {
         // Save the old screens in order to dispose them later
         List<Screen> oldScreens = screens;
 
@@ -286,6 +295,7 @@
     @Override public String toString() {
         return  "Screen:"+"\n"+
                 "    ptr:"+getNativeScreen()+"\n"+
+                "    adapter:"+getAdapterOrdinal()+"\n"+
                 "    depth:"+getDepth()+"\n"+
                 "    x:"+getX()+"\n"+
                 "    y:"+getY()+"\n"+
@@ -306,6 +316,7 @@
 
         Screen screen = (Screen) o;
         return ptr == screen.ptr
+                && adapter == screen.adapter
                 && depth == screen.depth
                 && x == screen.x
                 && y == screen.y
@@ -323,6 +334,7 @@
     @Override public int hashCode() {
         int result = 17;
         result = 31 * result + (int) (ptr ^ (ptr >>> 32));
+        result = 31 * result + adapter;
         result = 31 * result + depth;
         result = 31 * result + x;
         result = 31 * result + y;
--- a/modules/graphics/src/main/java/com/sun/glass/ui/lens/LensApplication.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/lens/LensApplication.java	Thu May 08 16:56:06 2014 -0700
@@ -696,6 +696,13 @@
         }
     }
 
+    private class LensScreenEvent extends Event {
+         @Override
+         void dispatch() {
+             Screen.notifySettingsChanged();
+         }
+     }
+
     private final LinkedList<Event> eventList = new LinkedList<Event>();
 
     private void postEvent(Event e) {
@@ -1596,6 +1603,17 @@
 
         postEvent(new LensDeviceEvent(flags, attach));
     }
+    
+    /**
+     * Notify changes in screen settings from native layer
+     * This method is triggered when native code detects a change in e.g. screen orientation
+     */
+    private void notifyScreenSettingsChanged() {
+        if (LensLogger.getLogger().isLoggable(Level.FINE)) {
+            LensLogger.getLogger().fine("Notify screen settings changed");
+        }    
+        postEvent(new LensScreenEvent());
+    }   
 
     //*******************************************************************
 
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/MouseInput.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/MouseInput.java	Thu May 08 16:56:06 2014 -0700
@@ -68,7 +68,8 @@
         // Get the cached window for the old state and compute the window for
         // the new state
         MonocleWindow oldWindow = state.getWindow(false);
-        MonocleWindow window = newState.getWindow(true);
+        boolean recalculateWindow = state.getButtonsPressed().isEmpty();
+        MonocleWindow window = newState.getWindow(recalculateWindow);
         MonocleView view = (window == null) ? null : (MonocleView) window.getView();
         // send exit event
         if (oldWindow != window && oldWindow != null) {
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchInput.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchInput.java	Thu May 08 16:56:06 2014 -0700
@@ -111,7 +111,8 @@
         // Get the cached window for the old state and compute the window for
         // the new state
         MonocleWindow oldWindow = state.getWindow(false, null);
-        MonocleWindow window = newState.getWindow(true, oldWindow);
+        boolean recalculateWindow = state.getPointCount() == 0;
+        MonocleWindow window = newState.getWindow(recalculateWindow, oldWindow);
         View oldView = oldWindow == null ? null : oldWindow.getView();
         View view = window == null ? null : window.getView();
         if (!newState.equalsSorted(state)) {
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchState.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/TouchState.java	Thu May 08 16:56:06 2014 -0700
@@ -62,7 +62,10 @@
      * @param fallback the window to use if no primary ID is available
      */
     MonocleWindow getWindow(boolean recalculateCache, MonocleWindow fallback) {
-        if (window == null || recalculateCache) {
+        if (window == null) {
+            window = fallback;
+        }
+        if (recalculateCache) {
             window = fallback;
             if (primaryID >= 0) {
                 Point p = getPointForID(primaryID);
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/filters/LookaheadTouchFilter.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/filters/LookaheadTouchFilter.java	Thu May 08 16:56:06 2014 -0700
@@ -25,16 +25,34 @@
 
 package com.sun.glass.ui.monocle.input.filters;
 
-import com.sun.glass.ui.monocle.input.TouchInput;
 import com.sun.glass.ui.monocle.input.TouchState;
 
 public class LookaheadTouchFilter implements TouchFilter {
 
-    private TouchInput touch = TouchInput.getInstance();
     private TouchState previousState = new TouchState();
     private TouchState tmpState = new TouchState();
     private boolean assignIDs;
-    private boolean processedFirstEvent;
+
+    private enum FilterState {
+        /** No events processed yet */
+        CLEAN,
+        /**
+         * previousState contains an event that must be sent as is. This will
+         * happen when an event is the first to be processed on this pulse, or
+         * "Substantially different" means that two events differ in the number
+         * of touch points or in the IDs assigned to those points.
+         */
+        PENDING_UNMODIFIABLE,
+        /**
+         * previousState contains an event that we are allowed to change before
+         * sending. An event can be modified if it is substantially different
+         * neither from the event that preceded it nor from the event that
+         * follows it.
+         */
+        PENDING_MODIFIABLE
+    }
+
+    private FilterState filterState = FilterState.CLEAN;
 
     /**
      * Creates a new LookaheadTouchFilter
@@ -48,41 +66,48 @@
 
     @Override
     public boolean filter(TouchState state) {
-        if (!processedFirstEvent) {
-            touch.getState(previousState);
-            if (state.canBeFoldedWith(previousState, assignIDs)) {
-                processedFirstEvent = true;
-            } else {
+        state.sortPointsByID();
+        switch (filterState) {
+            case CLEAN:
                 state.copyTo(previousState);
-                return false; // send state
-            }
-        }
-        if (processedFirstEvent) {
-            // fold together TouchStates that have the same touch point count
-            // and IDs. For Protocol A devices the touch IDs are not initialized
-            // yet, which means the only differentiator will be the number of
-            // points.
-            state.sortPointsByID();
-            if (!state.canBeFoldedWith(previousState, assignIDs)) {
-                // the events are different. Send "previousState".
+                filterState = FilterState.PENDING_UNMODIFIABLE;
+                return true;
+            case PENDING_UNMODIFIABLE:
+                // send the previous state and hold the new state as pending
                 state.copyTo(tmpState);
                 previousState.copyTo(state);
                 tmpState.copyTo(previousState);
+                if (state.canBeFoldedWith(previousState, assignIDs)) {
+                    filterState = FilterState.PENDING_MODIFIABLE;
+                }
                 return false;
-            }
+            case PENDING_MODIFIABLE:
+                if (state.canBeFoldedWith(previousState, assignIDs)) {
+                    state.copyTo(previousState);
+                    return true;
+                } else {
+                    // send the previous state and hold the new state as pending
+                    state.copyTo(tmpState);
+                    previousState.copyTo(state);
+                    tmpState.copyTo(previousState);
+                    filterState = FilterState.PENDING_UNMODIFIABLE;
+                    return false;
+                }
+            default:
+                return false;
         }
-        state.copyTo(previousState);
-        return true;
     }
 
     @Override
     public boolean flush(TouchState state) {
-        if (processedFirstEvent) {
-            previousState.copyTo(state);
-            processedFirstEvent = false;
-            return true;
-        } else {
-            return false;
+        switch (filterState) {
+            case PENDING_MODIFIABLE:
+            case PENDING_UNMODIFIABLE:
+                previousState.copyTo(state);
+                filterState = FilterState.CLEAN;
+                return true;
+            default:
+                return false;
         }
     }
 
@@ -93,7 +118,10 @@
 
     @Override
     public String toString() {
-        return "Lookahead";
+        return "Lookahead[previousState="
+                + previousState
+                + ",filterState=" + filterState
+                + "]";
     }
 
 }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/filters/TouchPipeline.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/monocle/input/filters/TouchPipeline.java	Thu May 08 16:56:06 2014 -0700
@@ -103,7 +103,11 @@
 
     public boolean filter(TouchState state) {
         for (int i = 0; i < filters.size(); i++) {
-            if (filters.get(i).filter(state)) {
+            TouchFilter filter = filters.get(i);
+            if (MonocleSettings.settings.traceEventsVerbose) {
+                MonocleTrace.traceEvent("Applying %s to %s", filter, state);
+            }
+            if (filter.filter(state)) {
                 return true;
             }
         }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java	Thu May 08 16:56:06 2014 -0700
@@ -108,7 +108,7 @@
         if (offset == 0) return true;
         if (offset == text.length()) return true;
         if (offset == BreakIterator.DONE) return true;
-        return bi.isBoundary(offset) && Character.isLetterOrDigit(text.charAt(offset)); 
+        return bi.isBoundary(offset) && Character.isLetterOrDigit(text.charAt(offset));
     }
 
     /***********************************************/
@@ -160,8 +160,13 @@
                     }
                     start = offset != BreakIterator.DONE ? offset : 0;
                 }
-                int offset = bi.following(start); /* Assumes a word end always follows a word start */
-                end = offset != BreakIterator.DONE ? offset : length;
+                if (!isWordStart(bi, text, end)) {
+                    int offset = bi.following(end);
+                    while (!isWordStart(bi, text, offset)) {
+                        offset = bi.next();
+                    }
+                    end = offset != BreakIterator.DONE ? offset : length;
+                }
                 break;
             }
             case TextUnit_Line: {
@@ -330,7 +335,7 @@
         String text = (String)getAttribute(TITLE);
         if (text == null) return null;
         int endOffset = maxLength != -1 ? Math.min(end, start + maxLength) : end;
-        System.out.println("+GetText [" + text.substring(start, endOffset)+"]");
+//        System.out.println("+GetText [" + text.substring(start, endOffset)+"]");
         return text.substring(start, endOffset);
     }
 
@@ -379,9 +384,12 @@
                     } else {
                         start = requestedCount > 0 ? length : 0;
                     }
+                    offset = bi.following(start);
+                    while (!isWordStart(bi, text, offset)) {
+                        offset = bi.next();
+                    }
+                    end = offset != BreakIterator.DONE ? offset : length;
                 }
-                offset = bi.following(start); /* Assumes a word end always follows a word start */
-                end = offset != BreakIterator.DONE ? offset : length;
                 break;
             }
             case TextUnit_Line: {
@@ -436,6 +444,7 @@
     }
 
     int MoveEndpointByUnit(int endpoint, int unit, final int requestedCount) {
+        if (requestedCount == 0) return 0;
         String text = (String)getAttribute(TITLE);
         if (text == null) return 0;
         int length = text.length();
@@ -453,32 +462,23 @@
             case TextUnit_Word: {
                 BreakIterator bi = BreakIterator.getWordInstance();
                 bi.setText(text);
-                if (requestedCount > 0) {
-                    int next = bi.following(offset);
-                    while (next != BreakIterator.DONE && requestedCount != actualCount) {
-                        /* Always keep start offset at a word start, and end offset at a word end */
-                        if (endpoint == TextPatternRangeEndpoint_Start) {
-                            while (next == BreakIterator.DONE && isWordStart(bi, text, next)) next = bi.next();
-                        } else {
-                            while (!isWordStart(bi, text, next)) next = bi.next();
+                while (offset != BreakIterator.DONE && actualCount != requestedCount) {
+                    if (requestedCount > 0) {
+                        offset = bi.following(offset);
+                        while (!isWordStart(bi, text, offset)) {
+                            offset = bi.next();
                         }
                         actualCount++;
-                        next = bi.next();
-                    }
-                    offset = next != BreakIterator.DONE ? next : length;
-                } else {
-                    int prev = bi.preceding(offset);
-                    while (prev != BreakIterator.DONE && requestedCount != actualCount) {
-                        /* Always keep start offset at a word start, and end offset at a word end */
-                        if (endpoint == TextPatternRangeEndpoint_Start) {
-                            while (prev == BreakIterator.DONE && isWordStart(bi, text, prev)) prev = bi.previous();
-                        } else {
-                            while (!isWordStart(bi, text, prev)) prev = bi.previous();
+                    } else {
+                        offset = bi.preceding(offset);
+                        while (!isWordStart(bi, text, offset)) {
+                            offset = bi.previous();
                         }
                         actualCount--;
-                        prev = bi.previous();
                     }
-                    offset = prev != BreakIterator.DONE ? prev : 0;
+                }
+                if (offset == BreakIterator.DONE) {
+                    offset = requestedCount > 0 ? length : 0;
                 }
                 break;
             }
@@ -513,20 +513,17 @@
             case TextUnit_Paragraph: {
                 BreakIterator bi = BreakIterator.getSentenceInstance();
                 bi.setText(text);
-                if (requestedCount > 0) {
-                    int next = bi.following(offset);
-                    while (next != BreakIterator.DONE && requestedCount != actualCount) {
+                while (offset != BreakIterator.DONE && actualCount != requestedCount) {
+                    if (requestedCount > 0) {
+                        offset = bi.following(offset);
                         actualCount++;
-                        next = bi.next();
+                    } else {
+                        offset = bi.preceding(offset);
+                        actualCount--;
                     }
-                    offset = next != BreakIterator.DONE ? next : length;
-                } else {
-                    int prev = bi.preceding(offset);
-                    while (prev != BreakIterator.DONE && requestedCount != actualCount) {
-                        actualCount--;
-                        prev = bi.previous();
-                    }
-                    offset = prev != BreakIterator.DONE ? prev : 0;
+                }
+                if (offset == BreakIterator.DONE) {
+                    offset = requestedCount > 0 ? length : 0;
                 }
                 break;
             }
--- a/modules/graphics/src/main/java/com/sun/javafx/css/StyleManager.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/css/StyleManager.java	Thu May 08 16:56:06 2014 -0700
@@ -168,10 +168,10 @@
     // package for testing
     static final Map<Parent, CacheContainer> cacheContainerMap = new WeakHashMap<>();
 
+    // package for testing
+    CacheContainer getCacheContainer(Styleable styleable, SubScene subScene) {
 
-    private CacheContainer getCacheContainer(Styleable styleable, SubScene subScene) {
-
-        if (styleable == null) return null;
+        if (styleable == null && subScene == null) return null;
 
         Parent root = null;
 
@@ -182,15 +182,17 @@
 
             Node node = (Node)styleable;
             Scene scene = node.getScene();
-            root = scene.getRoot();
+            if (scene != null) root = scene.getRoot();
 
         } else if (styleable instanceof Window) {
             // this catches the PopupWindow case
             Scene scene = ((Window)styleable).getScene();
-            scene.getRoot();
+            if (scene != null) root = scene.getRoot();
         }
         // todo: what other Styleables need to be handled here?
 
+        if (root == null) return null;
+
         CacheContainer container = cacheContainerMap.computeIfAbsent(
                 root,
                 (key) -> {
@@ -1684,7 +1686,8 @@
     private static List<String> cacheMapKey;
 
     // Each Scene has its own cache
-    private static class CacheContainer {
+    // package for testing
+    static class CacheContainer {
 
         private Map<StyleCache.Key,StyleCache> getStyleCache() {
             if (styleCache == null) styleCache = new HashMap<StyleCache.Key, StyleCache>();
--- a/modules/graphics/src/main/java/com/sun/javafx/scene/text/TextLayout.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/scene/text/TextLayout.java	Thu May 08 16:56:06 2014 -0700
@@ -38,11 +38,12 @@
     static final int FLAGS_HAS_BIDI         = 1 << 3;
     static final int FLAGS_HAS_COMPLEX      = 1 << 4;
     static final int FLAGS_HAS_EMBEDDED     = 1 << 5;
-    static final int FLAGS_WRAPPED          = 1 << 6;
-    static final int FLAGS_RTL_BASE         = 1 << 7;
-    static final int FLAGS_CACHED_UNDERLINE      = 1 << 8;
-    static final int FLAGS_CACHED_STRIKETHROUGH  = 1 << 9;
-    static final int FLAGS_LAST             = 1 << 10;
+    static final int FLAGS_HAS_CJK          = 1 << 6;
+    static final int FLAGS_WRAPPED          = 1 << 7;
+    static final int FLAGS_RTL_BASE         = 1 << 8;
+    static final int FLAGS_CACHED_UNDERLINE      = 1 << 9;
+    static final int FLAGS_CACHED_STRIKETHROUGH  = 1 << 10;
+    static final int FLAGS_LAST             = 1 << 11;
 
     static final int ANALYSIS_MASK = FLAGS_LAST - 1;
 
@@ -69,7 +70,7 @@
 
     public static final int TYPE_TEXT           = 1 << 0;
     public static final int TYPE_UNDERLINE      = 1 << 1;
-    public static final int TYPE_STRIKETHROUGH = 1 << 2;
+    public static final int TYPE_STRIKETHROUGH  = 1 << 2;
     public static final int TYPE_BASELINE       = 1 << 3;
     public static final int TYPE_TOP            = 1 << 4;
     public static final int TYPE_BEARINGS       = 1 << 5;
@@ -145,7 +146,7 @@
      * @return the visual bounds
      */
     public BaseBounds getVisualBounds(int type);
-    
+
     /**
      * Returns the lines of text layout.
      * 
@@ -161,7 +162,7 @@
      * @return the runs
      */
     public GlyphList[] getRuns();
-    
+
     /**
      * Returns the shape of the entire text layout relative to the baseline
      * of the first line.
--- a/modules/graphics/src/main/java/com/sun/javafx/text/GlyphLayout.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/text/GlyphLayout.java	Thu May 08 16:56:06 2014 -0700
@@ -61,6 +61,7 @@
 import static com.sun.javafx.scene.text.TextLayout.FLAGS_HAS_COMPLEX;
 import static com.sun.javafx.scene.text.TextLayout.FLAGS_HAS_EMBEDDED;
 import static com.sun.javafx.scene.text.TextLayout.FLAGS_HAS_TABS;
+import static com.sun.javafx.scene.text.TextLayout.FLAGS_HAS_CJK;
 import static com.sun.javafx.scene.text.TextLayout.FLAGS_RTL_BASE;
 
 import java.text.Bidi;
@@ -202,6 +203,11 @@
                             codePoint = Character.toCodePoint(ch, chars[++i]);
                         }
                     }
+
+                    if (Character.isIdeographic(codePoint)) {
+                        flags |= FLAGS_HAS_CJK;
+                    }
+
                     /* Check for script changes */
                     script = ScriptMapper.getScript(codePoint);
                     if (scriptRun > ScriptMapper.INHERITED  &&
--- a/modules/graphics/src/main/java/com/sun/javafx/text/PrismTextLayout.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/text/PrismTextLayout.java	Thu May 08 16:56:06 2014 -0700
@@ -1033,7 +1033,7 @@
 
         BreakIterator boundary = null;
         if (wrapWidth > 0) {
-            if ((flags & (FLAGS_HAS_COMPLEX)) != 0) {
+            if ((flags & (FLAGS_HAS_COMPLEX | FLAGS_HAS_CJK)) != 0) {
                 boundary = BreakIterator.getLineInstance();
                 boundary.setText(new CharArrayIterator(chars));
             }
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java	Thu May 08 16:56:06 2014 -0700
@@ -286,6 +286,8 @@
             user.setContextClassLoader(ccl);
             setFxUserThread(user);
 
+            // Glass screens were inited in Application.run(), assign adapters
+            assignScreensAdapters();
             /*
              *  Glass Application instance is now valid - create the ResourceFactory
              *  on the render thread
@@ -595,7 +597,15 @@
         return screenAccessor;
     }
 
+    private static void assignScreensAdapters() {
+        GraphicsPipeline pipeline = GraphicsPipeline.getPipeline();
+        for (Screen screen : Screen.getScreens()) {
+            screen.setAdapterOrdinal(pipeline.getAdapterOrdinal(screen));
+        }
+    }
+
     private static void notifyScreenListener(TKScreenConfigurationListener listener) {
+        assignScreensAdapters();
         listener.screenConfigurationChanged();
     }
 
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Thu May 08 16:56:06 2014 -0700
@@ -439,7 +439,9 @@
             } else {
                 // Note: This method is required to workaround a glass issue
                 // mentioned in RT-12607
-                if (owner != null && owner instanceof WindowStage) {
+                // If the hiding stage is unfocusable (i.e. it's a PopupStage),
+                // then we don't do this to avoid stealing the focus.
+                if (!isPopupStage && owner != null && owner instanceof WindowStage) {
                     WindowStage ownerStage = (WindowStage)owner;
                     ownerStage.requestToFront();
                 }
--- a/modules/graphics/src/main/java/com/sun/prism/GraphicsPipeline.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/GraphicsPipeline.java	Thu May 08 16:56:06 2014 -0700
@@ -62,6 +62,8 @@
         installedPipeline = null;
     }
 
+    public abstract int getAdapterOrdinal(Screen screen);
+
     /*
      * The following method allows to access several graphics adapters individually.
      * Graphics resources are not sharable between different adapters
@@ -228,6 +230,6 @@
      * @return true if the pipeline uses an uploading painter
      */
     public boolean isUploading() {
-        return false;
+        return PrismSettings.forceUploadingPainter;
     }
 }
--- a/modules/graphics/src/main/java/com/sun/prism/d3d/D3DContext.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/d3d/D3DContext.java	Thu May 08 16:56:06 2014 -0700
@@ -171,7 +171,7 @@
             }
         }
 
-        return hr == D3D_OK;
+        return !FAILED(hr);
     }
 
     /**
@@ -185,7 +185,7 @@
             validate(res);
         }
 
-        return res == D3D_OK;
+        return !FAILED(res);
     }
 
     /**
--- a/modules/graphics/src/main/java/com/sun/prism/d3d/D3DPipeline.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/d3d/D3DPipeline.java	Thu May 08 16:56:06 2014 -0700
@@ -193,13 +193,18 @@
      */
     private static Screen getScreenForAdapter(List<Screen> screens, int adapterOrdinal) {
         for (Screen screen : screens) {
-            if (nGetAdapterOrdinal(screen.getNativeScreen()) == adapterOrdinal) {
+            if (screen.getAdapterOrdinal() == adapterOrdinal) {
                 return screen;
             }
         }
         return Screen.getMainScreen();
     }
 
+    @Override
+    public int getAdapterOrdinal(Screen screen) {
+        return nGetAdapterOrdinal(screen.getNativeScreen());
+    }
+
     private static D3DResourceFactory findDefaultResourceFactory(List<Screen> screens) {
         for (int adapter = 0, n = nGetAdapterCount(); adapter != n; ++adapter) {
             D3DResourceFactory rf =
@@ -230,7 +235,7 @@
     }
 
     public ResourceFactory getResourceFactory(Screen screen) {
-        return getD3DResourceFactory(nGetAdapterOrdinal(screen.getNativeScreen()), screen);
+        return getD3DResourceFactory(screen.getAdapterOrdinal(), screen);
     }
 
     @Override
--- a/modules/graphics/src/main/java/com/sun/prism/es2/ES2Pipeline.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/es2/ES2Pipeline.java	Thu May 08 16:56:06 2014 -0700
@@ -136,13 +136,18 @@
      */
     private static Screen getScreenForAdapter(List<Screen> screens, int adapterOrdinal) {
         for (Screen screen : screens) {
-            if (glFactory.getAdapterOrdinal(screen.getNativeScreen()) == adapterOrdinal) {
+            if (screen.getAdapterOrdinal() == adapterOrdinal) {
                 return screen;
             }
         }
         return Screen.getMainScreen();
     }
 
+    @Override
+    public int getAdapterOrdinal(Screen screen) {
+        return glFactory.getAdapterOrdinal(screen.getNativeScreen());
+    }
+
     private static ES2ResourceFactory findDefaultResourceFactory(List<Screen> screens) {
         for (int adapter = 0, n = glFactory.getAdapterCount(); adapter != n; ++adapter) {
             ES2ResourceFactory rf =
@@ -174,8 +179,7 @@
 
     @Override
     public ResourceFactory getResourceFactory(Screen screen) {
-        return getES2ResourceFactory(
-                glFactory.getAdapterOrdinal(screen.getNativeScreen()), screen);
+        return getES2ResourceFactory(screen.getAdapterOrdinal(), screen);
     }
 
     @Override
--- a/modules/graphics/src/main/java/com/sun/prism/impl/PrismSettings.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/impl/PrismSettings.java	Thu May 08 16:56:06 2014 -0700
@@ -88,6 +88,7 @@
     public static final boolean perfLogFirstPaintExit;
     public static final boolean superShader;
     public static final boolean skipMeshNormalComputation;
+    public static final boolean forceUploadingPainter;
 
     private PrismSettings() {
     }
@@ -320,7 +321,7 @@
                                           "prism.disableRegionCaching",
                                           false);
 
-        disableD3D9Ex = getBoolean(systemProperties, "prism.disableD3D9Ex", true);
+        disableD3D9Ex = getBoolean(systemProperties, "prism.disableD3D9Ex", false);
 
         disableEffects = getBoolean(systemProperties, "prism.disableEffects", false);
 
@@ -339,6 +340,9 @@
         perfLogFirstPaintExit = getBoolean(systemProperties, "sun.perflog.fx.firstpaintexit", false, true);
 
         superShader = getBoolean(systemProperties, "prism.supershader", true);
+
+        // Force uploading painter (e.g., to avoid Linux live-resize jittering)
+        forceUploadingPainter = getBoolean(systemProperties, "prism.forceUploadingPainter", false);
     }
 
     private static int parseInt(String s, int dflt, int trueDflt,
--- a/modules/graphics/src/main/java/com/sun/prism/j2d/J2DPipeline.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/j2d/J2DPipeline.java	Thu May 08 16:56:06 2014 -0700
@@ -55,9 +55,13 @@
             new HashMap<Integer, J2DResourceFactory>(1);
 
     @Override
+    public int getAdapterOrdinal(Screen screen) {
+        return Screen.getScreens().indexOf(screen);
+    }
+
+    @Override
     public ResourceFactory getResourceFactory(Screen screen) {
-        List<Screen> screens = Screen.getScreens();
-        Integer index = new Integer(screens.indexOf(screen));
+        Integer index = new Integer(screen.getAdapterOrdinal());
         J2DResourceFactory factory = factories.get(index);
         if (factory == null) {
             factory = new J2DResourceFactory(screen);
--- a/modules/graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java	Thu May 08 16:56:06 2014 -0700
@@ -70,6 +70,7 @@
 import java.util.ArrayList;
 import java.util.Set;
 import com.sun.glass.ui.Application;
+import com.sun.javafx.PlatformUtil;
 import com.sun.javafx.print.PrintHelper;
 import com.sun.javafx.print.PrinterImpl;
 import com.sun.javafx.print.PrinterJobImpl;
@@ -87,6 +88,7 @@
     
     private JobSettings settings;
     private PrintRequestAttributeSet printReqAttrSet;
+    private volatile Object elo = null;
 
     public J2DPrinterJob(javafx.print.PrinterJob fxJob) {
 
@@ -102,7 +104,12 @@
         printReqAttrSet = new HashPrintRequestAttributeSet();
         // dialog selection is a JDK 1.7 attribute.
         // We expect to run on 1.8 and above so this should be fine.
-        printReqAttrSet.add(DialogTypeSelection.NATIVE);
+        // Don't use on Linux where it has no effect and runs into a JDK bug
+        if (!PlatformUtil.isLinux()) {
+            printReqAttrSet.add(DialogTypeSelection.NATIVE);
+        }
+        j2dPageable = new J2DPageable();
+        pJob2D.setPageable(j2dPageable);
     }
 
     public boolean showPrintDialog(Window owner) {
@@ -694,8 +701,6 @@
 
         if (!jobRunning) {
             checkPermissions();
-            j2dPageable = new J2DPageable();
-            pJob2D.setPageable(j2dPageable);
             syncSettingsToAttributes();
             PrintJobRunnable runnable = new PrintJobRunnable();
             Thread prtThread = new Thread(runnable, "Print Job Thread");
@@ -729,6 +734,13 @@
                 jobError = true;
                 jobDone = true;
             }
+            /*
+             * If the job ends because its reached a page range limit
+             * rather than calling getPage() we need to exit the nested loop.
+             */
+            if (elo != null) {
+                Application.invokeLater(new ExitLoopRunnable(elo, null));
+            }
         }
     }
 
@@ -885,7 +897,7 @@
 
             if (elo != null && currPageInfo != null) {
                 Application.invokeLater(new ExitLoopRunnable(elo, null));
-            }
+	    }
 
             if (currPageInfo != null) {
                 if (Toolkit.getToolkit().isFxUserThread()) {
@@ -964,8 +976,6 @@
             boolean nextPage = false;
             if (pageIndex > currPageIndex) {
                 nextPage = waitForNextPage(pageIndex);
-            } else if (pageIndex < currPageIndex) {
-                System.err.println("PAGE INDEX DECREASED");
             }
             return nextPage;
         }
@@ -1018,9 +1028,6 @@
             return Pageable.UNKNOWN_NUMBER_OF_PAGES;
         }
 
-
-        private volatile Object elo = null;
-
         /*
          * Executed on the application's thread.
          * Messages over to the printing thread.
@@ -1070,7 +1077,9 @@
                     return jobDone;
                 }
             } catch (IllegalStateException e) {
-                System.err.println("Internal Error " + e);
+                if (com.sun.prism.impl.PrismSettings.debug) {
+                    System.err.println("Internal Error " + e);
+                }
             }
         } else {
             return false;
@@ -1090,7 +1099,9 @@
                     monitor.notify();
                 }
             } catch (IllegalStateException e) {
-                System.err.println("Internal Error " + e);
+                if (com.sun.prism.impl.PrismSettings.debug) {
+                    System.err.println("Internal Error " + e);
+                }
             }
         }
     }
--- a/modules/graphics/src/main/java/com/sun/prism/null3d/NULL3DPipeline.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/null3d/NULL3DPipeline.java	Thu May 08 16:56:06 2014 -0700
@@ -63,9 +63,13 @@
             new HashMap<Integer, DummyResourceFactory>(1);
 
     @Override
+    public int getAdapterOrdinal(Screen screen) {
+        return Screen.getScreens().indexOf(screen);
+    }
+    
+    @Override
     public ResourceFactory getResourceFactory(Screen screen) {
-        List<Screen> screens = Screen.getScreens();
-        Integer index = new Integer(screens.indexOf(screen));
+        Integer index = new Integer(screen.getAdapterOrdinal());
         DummyResourceFactory factory = factories.get(index);
         if (factory == null) {
             factory = new DummyResourceFactory(screen);
--- a/modules/graphics/src/main/java/com/sun/prism/sw/SWPipeline.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/sw/SWPipeline.java	Thu May 08 16:56:06 2014 -0700
@@ -63,9 +63,13 @@
     private final HashMap<Integer, SWResourceFactory> factories =
             new HashMap<Integer, SWResourceFactory>(1);
 
+    @Override
+    public int getAdapterOrdinal(Screen screen) {
+        return Screen.getScreens().indexOf(screen);
+    }
+
     @Override public ResourceFactory getResourceFactory(Screen screen) {
-        List<Screen> screens = Screen.getScreens();
-        Integer index = new Integer(screens.indexOf(screen));
+        Integer index = new Integer(screen.getAdapterOrdinal());
         SWResourceFactory factory = factories.get(index);
         if (factory == null) {
             factory = new SWResourceFactory(screen);
--- a/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPSDrawable.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPSDrawable.java	Thu May 08 16:56:06 2014 -0700
@@ -25,9 +25,7 @@
 
 package com.sun.scenario.effect.impl.prism.ps;
 
-import com.sun.glass.ui.Screen;
 import com.sun.prism.RTTexture;
-import com.sun.prism.GraphicsPipeline;
 import com.sun.prism.ResourceFactory;
 import com.sun.prism.Texture.WrapMode;
 import com.sun.prism.ps.ShaderGraphics;
@@ -46,21 +44,15 @@
         return new PPSDrawable(rtt);
     }
 
-    static int getCompatibleWidth(Screen screen, int w) {
-        ResourceFactory factory =
-            GraphicsPipeline.getPipeline().getResourceFactory(screen);
+    static int getCompatibleWidth(ResourceFactory factory, int w) {
         return factory.getRTTWidth(w, WrapMode.CLAMP_TO_ZERO);
     }
 
-    static int getCompatibleHeight(Screen screen, int h) {
-        ResourceFactory factory =
-            GraphicsPipeline.getPipeline().getResourceFactory(screen);
+    static int getCompatibleHeight(ResourceFactory factory, int h) {
         return factory.getRTTHeight(h, WrapMode.CLAMP_TO_ZERO);
     }
 
-    static PPSDrawable create(Screen screen, int width, int height) {
-        ResourceFactory factory =
-            GraphicsPipeline.getPipeline().getResourceFactory(screen);
+    static PPSDrawable create(ResourceFactory factory, int width, int height) {
         // force the wrap mode to CLAMP_TO_ZERO, as that is the mode
         // required by most Decora effects (blurs, etc)
         RTTexture rtt =
--- a/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPSRenderer.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPSRenderer.java	Thu May 08 16:56:06 2014 -0700
@@ -65,7 +65,7 @@
 
 public class PPSRenderer extends PrRenderer {
 
-    private final Screen screen;
+    private final ResourceFactory rf;
     private final ShaderSource shaderSource;
     private RendererState state;
     private boolean needsSWDispMap;
@@ -83,13 +83,11 @@
     };
 
     private PPSRenderer(Screen screen, ShaderSource shaderSource) {
-        this.screen = screen;
         this.shaderSource = shaderSource;
         synchronized (this) {
             state = OK;
         }
-        ResourceFactory rf =
-            GraphicsPipeline.getPipeline().getResourceFactory(screen);
+        rf = GraphicsPipeline.getPipeline().getResourceFactory(screen);
         rf.addFactoryListener(listener);
         needsSWDispMap = !rf.isFormatSupported(PixelFormat.FLOAT_XYZW);
     }
@@ -135,8 +133,7 @@
         synchronized (this) {
             state = DISPOSED;
         }
-        GraphicsPipeline.getPipeline().
-            getResourceFactory(screen).removeFactoryListener(listener);
+        rf.removeFactoryListener(listener);
     }
 
     /**
@@ -152,17 +149,17 @@
 
     @Override
     public int getCompatibleWidth(int w) {
-        return PPSDrawable.getCompatibleWidth(screen, w);
+        return PPSDrawable.getCompatibleWidth(rf, w);
     }
 
     @Override
     public int getCompatibleHeight(int h) {
-        return PPSDrawable.getCompatibleHeight(screen, h);
+        return PPSDrawable.getCompatibleHeight(rf, h);
     }
 
     @Override
     public final PPSDrawable createCompatibleImage(int w, int h) {
-        return PPSDrawable.create(screen, w, h);
+        return PPSDrawable.create(rf, w, h);
     }
 
     @Override
@@ -177,8 +174,7 @@
 
     @Override
     public LockableResource createFloatTexture(int w, int h) {
-        Texture prismTex = GraphicsPipeline.getPipeline().
-            getResourceFactory(screen).createFloatTexture(w, h);
+        Texture prismTex = rf.createFloatTexture(w, h);
         return new PrTexture(prismTex);
     }
 
@@ -199,8 +195,7 @@
     {
         InputStream pscode = shaderSource.loadSource(name);
         int maxTexCoordIndex = samplers.keySet().size()-1;
-        ShaderFactory factory = (ShaderFactory)
-            GraphicsPipeline.getPipeline().getResourceFactory(screen);
+        ShaderFactory factory = (ShaderFactory)rf;
         return factory.createShader(pscode, samplers, params,
                                     maxTexCoordIndex,
                                     isPixcoordUsed, false);
--- a/modules/graphics/src/main/java/javafx/scene/Node.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/java/javafx/scene/Node.java	Thu May 08 16:56:06 2014 -0700
@@ -26,6 +26,7 @@
 package javafx.scene;
 
 
+import javafx.application.Platform;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
 import javafx.beans.binding.BooleanExpression;
@@ -961,7 +962,13 @@
 
                 @Override
                 protected void invalidated() {
-                    impl_reapplyCSS();
+                    // RT-36838 - don't reapply CSS in the middle of an update or reapply
+                    if ((cssFlag == CssFlags.UPDATE) || (cssFlag == CssFlags.REAPPLY)) {
+                        Platform.runLater(()->impl_reapplyCSS());
+                    }
+                    else {
+                        impl_reapplyCSS();
+                    }
                     if (PrismSettings.printRenderGraph) {
                         impl_markDirty(DirtyBits.DEBUG);
                     }
@@ -994,7 +1001,13 @@
     private ObservableList<String> styleClass = new TrackableObservableList<String>() {
         @Override
         protected void onChanged(Change<String> c) {
-            impl_reapplyCSS();
+            // RT-36838 - don't reapply CSS in the middle of an update or reapply
+            if ((cssFlag == CssFlags.UPDATE) || (cssFlag == CssFlags.REAPPLY)) {
+                Platform.runLater(()->impl_reapplyCSS());
+            }
+            else {
+                impl_reapplyCSS();
+            }
         }
 
         @Override
@@ -1079,7 +1092,13 @@
                 protected void invalidated() {
                     // If the style has changed, then styles of this node
                     // and child nodes might be affected.
-                    impl_reapplyCSS();
+                    // RT-36838 - don't reapply CSS in the middle of an update or reapply
+                    if ((cssFlag == CssFlags.UPDATE) || (cssFlag == CssFlags.REAPPLY)) {
+                        Platform.runLater(()->impl_reapplyCSS());
+                    }
+                    else {
+                        impl_reapplyCSS();
+                    }
                 }
 
                 @Override
--- a/modules/graphics/src/main/native-decora/SSEUtils.cc	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-decora/SSEUtils.cc	Thu May 08 16:56:06 2014 -0700
@@ -35,7 +35,8 @@
     (JNIEnv *env, jclass klass)
 {
 #ifdef WIN32 /* WIN32 */
-    return ::IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
+    return ::IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE) ?
+        JNI_TRUE : JNI_FALSE;
 #else
     /* No reports of any other platform generating SSE2 instructions */
     return JNI_TRUE;
--- a/modules/graphics/src/main/native-glass/lens/LensApplication.c	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/lens/LensApplication.c	Thu May 08 16:56:06 2014 -0700
@@ -40,8 +40,12 @@
 #include <signal.h>
 
 #ifdef ANDROID_SDK
+#ifdef DALVIK_VM
+  #include "dalvikInput.h"
+#else
   #include "androidInput.h"
 #endif 
+#endif 
 //********************************************************
 
 // JNI handles ******************************************
@@ -68,6 +72,7 @@
 static jmethodID jLensApplication_notifyWindowEvent;
 static jmethodID jLensApplication_notifyViewEvent;
 static jmethodID jLensApplication_notifyDeviceEvent;
+static jmethodID jLensApplication_notifyScreenSettingsChanged;
 static jmethodID jLensApplication_notifyMenuEvent;
 static jmethodID jLensApplication_reportException;
 
@@ -162,6 +167,11 @@
     jLensApplication_notifyDeviceEvent =
         (*env)->GetMethodID(env, jLensApplicationClass, "notifyDeviceEvent",
                             "(IZ)V");
+
+    jLensApplication_notifyScreenSettingsChanged =
+        (*env)->GetMethodID(env, jLensApplicationClass, "notifyScreenSettingsChanged",
+                            "()V");
+
     jLensApplication_notifyMenuEvent =
         (*env)->GetMethodID(env, jLensApplicationClass, "notifyMenuEvent",
                             "(Lcom/sun/glass/ui/lens/LensView;IIIIZ)V");
@@ -767,6 +777,17 @@
 
 }
 
+void glass_application_notifyScreenSettingsChanged(JNIEnv *env) {
+    if (!pApplication) {
+        return;
+    }
+    GLASS_LOG_FINEST("JNI call notifyScreenSettinngsChanged");
+    (*env)->CallVoidMethod(env, pApplication,
+            jLensApplication_notifyScreenSettingsChanged);
+    (void)glass_application_checkReportException(env);
+}
+
+
 /*
  * Class:     com_sun_glass_events_KeyEvent
  * Method:    _getKeyCodeForChar
--- a/modules/graphics/src/main/native-glass/lens/LensCommon.h	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/lens/LensCommon.h	Thu May 08 16:56:06 2014 -0700
@@ -1530,6 +1530,13 @@
  */
 void glass_cursor_terminate(void);
 
+/**
+ * Called when screen characteristics changed.
+ * @param env
+ */
+void glass_application_notifyScreenSettingsChanged(JNIEnv *env);
+
+
 
 #include "LensLogger.h"
 
--- a/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c	Thu May 08 16:56:06 2014 -0700
@@ -159,6 +159,24 @@
     return LENS_OK;
 }
 
+void lens_wm_repaint_all(JNIEnv *env) {
+    render_lock();
+    glass_window_list_lock();
+    NativeWindow w = glass_window_list_getHead();
+    while (w) {
+        if (w && w->view) {
+            glass_application_notifyViewEvent(env,
+                                              w->view,
+                                              com_sun_glass_events_ViewEvent_REPAINT,
+                                              w->currentBounds.x, w->currentBounds.y,
+                                              w->currentBounds.width, w->currentBounds.height);
+        }
+        w = w->nextWindow;
+    }
+    glass_window_list_unlock();
+    render_unlock();
+}
+
 void lens_wm_repaint(JNIEnv *env, NativeWindow window) {
     render_lock();
 
--- a/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.h	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.h	Thu May 08 16:56:06 2014 -0700
@@ -191,6 +191,13 @@
  */
 void lens_wm_repaint(JNIEnv *env, NativeWindow window);
 
+/**
+ * Repaint all windows
+ *
+ * @param env env
+ */
+void lens_wm_repaint_all(JNIEnv *env);
+
 /// platform specific calls
 void lens_platform_shutdown(JNIEnv *env);
 
--- a/modules/graphics/src/main/native-glass/mac/GlassApplication.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassApplication.m	Thu May 08 16:56:06 2014 -0700
@@ -164,12 +164,14 @@
             if ((*env)->ExceptionCheck(env) == JNI_TRUE)
             {
                 (*env)->ExceptionDescribe(env);
+                (*env)->ExceptionClear(env);
             }
 
             jmethodID runMethod = (*env)->GetMethodID(env, runnableClass, "run", "()V");
             if ((*env)->ExceptionCheck(env) == JNI_TRUE)
             {
                 (*env)->ExceptionDescribe(env);
+                (*env)->ExceptionClear(env);
             }
 
             if ((runnableClass != 0) && (runMethod != 0))
@@ -178,10 +180,11 @@
                 if ((*env)->ExceptionCheck(env) == JNI_TRUE)
                 {
                     (*env)->ExceptionDescribe(env);
+                    (*env)->ExceptionClear(env);
                 }
                 else
                 {
-                    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(GlassApplicationDidChangeScreenParameters) name:NSApplicationDidChangeScreenParametersNotification object:nil];
+                [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(GlassApplicationDidChangeScreenParameters) name:NSApplicationDidChangeScreenParametersNotification object:nil];
                 }
             }
             else if (runnableClass == 0)
@@ -328,12 +331,14 @@
     {
         NSUInteger count = [filenames count];
         jobjectArray files = (*env)->NewObjectArray(env, (jsize)count, [GlassHelper ClassForName:"java.lang.String" withEnv:env], NULL);
+        GLASS_CHECK_EXCEPTION(env);
         for (NSUInteger i=0; i<count; i++)
         {
             NSString *file = [filenames objectAtIndex:i];
             if (file != nil)
             {
                 (*env)->SetObjectArrayElement(env, files, (jsize)i, (*env)->NewStringUTF(env, [file UTF8String]));
+                GLASS_CHECK_EXCEPTION(env);
             }
         }
         (*env)->CallVoidMethod(env, self->jApplication, [GlassHelper ApplicationNotifyOpenFilesMethod], files);
@@ -463,6 +468,7 @@
                 // make the name available to Java side, before Launchable.fnishLaunching callback
                 jstring jname = (*jEnv)->NewStringUTF(jEnv, [appName UTF8String]);
                 jmethodID setNameMethod = (*jEnv)->GetMethodID(jEnv, cls, "setName", "(Ljava/lang/String;)V");
+                GLASS_CHECK_EXCEPTION(jEnv);
                 if (setNameMethod != NULL) {
                     (*jEnv)->CallVoidMethod(jEnv, glassApp->jApplication, setNameMethod, jname);
                 }
@@ -721,19 +727,26 @@
 
     javaIDs.Application.createPixels = (*env)->GetStaticMethodID(
             env, jClass, "createPixels", "(II[IF)Lcom/sun/glass/ui/Pixels;");
+    if ((*env)->ExceptionCheck(env)) return;
 
     javaIDs.Application.getScaleFactor = (*env)->GetStaticMethodID(
             env, jClass, "getScaleFactor", "(IIII)F");
+    if ((*env)->ExceptionCheck(env)) return;
 
     javaIDs.Application.reportException = (*env)->GetStaticMethodID(
             env, jClass, "reportException", "(Ljava/lang/Throwable;)V");
+    if ((*env)->ExceptionCheck(env)) return;
 
     javaIDs.MacApplication.notifyApplicationDidTerminate = (*env)->GetMethodID(
             env, jClass, "notifyApplicationDidTerminate", "()V");
+    if ((*env)->ExceptionCheck(env)) return;
 
     if (jRunnableRun == NULL)
     {
-        jRunnableRun = (*env)->GetMethodID(env, (*env)->FindClass(env, "java/lang/Runnable"), "run", "()V");
+        jclass jcls = (*env)->FindClass(env, "java/lang/Runnable");
+        if ((*env)->ExceptionCheck(env)) return;
+        jRunnableRun = (*env)->GetMethodID(env, jcls, "run", "()V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
 }
 
--- a/modules/graphics/src/main/native-glass/mac/GlassDialogs.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassDialogs.m	Thu May 08 16:56:06 2014 -0700
@@ -140,11 +140,13 @@
 {
     GET_MAIN_JENV;
     DialogDispatcher *dd = self;
+    
+    jobject jobj = (*env)->NewObject(env,
+            [GlassHelper ClassForName:"com.sun.glass.ui.EventLoop" withEnv:env],
+            javaIDs.EventLoop.init);
+    if ((*env)->ExceptionCheck(env)) return;
 
-    dd->eventLoop = (*env)->NewGlobalRef(env, (*env)->NewObject(env,
-            [GlassHelper ClassForName:"com.sun.glass.ui.EventLoop" withEnv:env],
-            javaIDs.EventLoop.init));
-
+    dd->eventLoop = (*env)->NewGlobalRef(env, jobj);
 
     if (owner) {
         [panel beginSheetModalForWindow: owner completionHandler:^(NSInteger result)
@@ -250,9 +252,10 @@
     const jclass MacCommonDialogsCls = [GlassHelper ClassForName:"com.sun.glass.ui.mac.MacCommonDialogs" withEnv:env];
 
     // Performance doesn't matter here, so call the method every time 
-    if ((*env)->CallStaticBooleanMethod(env,
-                MacCommonDialogsCls,
-                javaIDs.MacCommonDialogs.isFileNSURLEnabled))
+    jboolean result = (*env)->CallStaticBooleanMethod(env, MacCommonDialogsCls,
+                javaIDs.MacCommonDialogs.isFileNSURLEnabled);
+    GLASS_CHECK_EXCEPTION(env);
+    if (result)
     {
         [url retain]; //NOTE: an app must call MacFileURL.dispoes() to release it
 
@@ -260,13 +263,17 @@
         ret = (*env)->NewObject(env,
                 MacFileNSURLCls,
                 javaIDs.MacFileNSURL.init, path, ptr_to_jlong(url));
+        GLASS_CHECK_EXCEPTION(env);
         (*env)->DeleteLocalRef(env, MacFileNSURLCls);
     }
     else
     {
+        jclass jcls = (*env)->FindClass(env, "java/io/File");
+        GLASS_CHECK_EXCEPTION(env);
         ret = (*env)->NewObject(env,
-                (*env)->FindClass(env, "java/io/File"),
+                jcls,
                 javaIDs.File.init, path);
+        GLASS_CHECK_EXCEPTION(env);
     }
 
     (*env)->DeleteLocalRef(env, MacCommonDialogsCls);
@@ -424,11 +431,15 @@
 (JNIEnv *env, jclass cls)
 {
     javaIDs.MacCommonDialogs.isFileNSURLEnabled = (*env)->GetStaticMethodID(env, cls, "isFileNSURLEnabled", "()Z");
+    if ((*env)->ExceptionCheck(env)) return;
 
     cls = [GlassHelper ClassForName:"com.sun.glass.ui.EventLoop" withEnv:env];
     javaIDs.EventLoop.init  = (*env)->GetMethodID(env, cls, "<init>", "()V");
+    if ((*env)->ExceptionCheck(env)) return;
     javaIDs.EventLoop.enter = (*env)->GetMethodID(env, cls, "enter", "()Ljava/lang/Object;");
+    if ((*env)->ExceptionCheck(env)) return;
     javaIDs.EventLoop.leave = (*env)->GetMethodID(env, cls, "leave", "(Ljava/lang/Object;)V");
+    if ((*env)->ExceptionCheck(env)) return;
 
     initJavaIDsList(env);
     initJavaIDsArrayList(env);
@@ -436,8 +447,10 @@
 
     cls = [GlassHelper ClassForName:"com.sun.glass.ui.CommonDialogs$ExtensionFilter" withEnv:env];
     javaIDs.ExtensionFilter.getDescription = (*env)->GetMethodID(env, cls, "getDescription", "()Ljava/lang/String;");
+    if ((*env)->ExceptionCheck(env)) return;
     javaIDs.ExtensionFilter.extensionsToArray  = (*env)->GetMethodID(env, cls, "extensionsToArray", "()[Ljava/lang/String;");
-    
+    if ((*env)->ExceptionCheck(env)) return;
+
     cls = [GlassHelper ClassForName:"com.sun.glass.ui.CommonDialogs$FileChooserResult" withEnv:env];
     javaIDs.FileChooserResult.init = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/util/List;Lcom/sun/glass/ui/CommonDialogs$ExtensionFilter;)V");
 }
@@ -484,13 +497,18 @@
             [dispatcher performSelectorOnMainThread:@selector(runModally) withObject:nil waitUntilDone:YES];
             NSArray *urls = [panel URLs];
 
-            chosenFiles = (*env)->NewObject(env, (*env)->FindClass(env, "java/util/ArrayList"), javaIDs.ArrayList.init);
+            jclass jcls = (*env)->FindClass(env, "java/util/ArrayList");
+            GLASS_CHECK_EXCEPTION(env);
+            chosenFiles = (*env)->NewObject(env, jcls, javaIDs.ArrayList.init);
+            GLASS_CHECK_EXCEPTION(env);
+            
             if (([dispatcher getButton] == NSFileHandlingPanelOKButton) && ([urls count] > 0))
             {
                 for (NSUInteger i=0; i<[urls count]; i++)
                 {
                     NSURL *url = [urls objectAtIndex:i];
                     (*env)->CallBooleanMethod(env, chosenFiles, javaIDs.List.add, convertNSURLtoFile(env, url));
+                    GLASS_CHECK_EXCEPTION(env);
                 }
             }
             
@@ -498,6 +516,7 @@
             {
                 chosenFilter = (*env)->GetObjectArrayElement(env, jExtensionFilters,
                                                              [(NSPopUpButton*)[panel accessoryView] indexOfSelectedItem]);
+                GLASS_CHECK_EXCEPTION(env);
             }
         }
         [dispatcher release];
@@ -554,16 +573,21 @@
             [dispatcher performSelectorOnMainThread:@selector(runModally) withObject:nil waitUntilDone:YES];
             NSURL *url = [panel URL];
 
-            chosenFile = (*env)->NewObject(env, (*env)->FindClass(env, "java/util/ArrayList"), javaIDs.ArrayList.init);
+            jclass jcls = (*env)->FindClass(env, "java/util/ArrayList");
+            GLASS_CHECK_EXCEPTION(env);
+            chosenFile = (*env)->NewObject(env, jcls, javaIDs.ArrayList.init);
+            GLASS_CHECK_EXCEPTION(env);
             if (([dispatcher getButton] == NSFileHandlingPanelOKButton) && (url != nil))
             {
                 (*env)->CallBooleanMethod(env, chosenFile, javaIDs.List.add, convertNSURLtoFile(env, url));
+                GLASS_CHECK_EXCEPTION(env);
             }
             
             if (jExtensionFilters != NULL && (*env)->GetArrayLength(env, jExtensionFilters) > 0)
             {
                 chosenFilter = (*env)->GetObjectArrayElement(env, jExtensionFilters,
                                                              [(NSPopUpButton*)[panel accessoryView] indexOfSelectedItem]);
+                GLASS_CHECK_EXCEPTION(env);
             }
         }
         [dispatcher release];
--- a/modules/graphics/src/main/native-glass/mac/GlassHelper.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassHelper.m	Thu May 08 16:56:06 2014 -0700
@@ -49,7 +49,14 @@
     static jclass classCls = NULL;
     if (classCls == NULL)
     {
-        classCls = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "java/lang/Class"));
+        jclass jcls = (*env)->FindClass(env, "java/lang/Class");
+        GLASS_CHECK_EXCEPTION(env);
+        if (jcls == NULL)
+        {
+            NSLog(@"GlassHelper error: jcls == NULL");
+            return NULL;            
+        }
+        classCls = (*env)->NewGlobalRef(env, jcls);
     }
     if (classCls == NULL)
     {
@@ -61,6 +68,7 @@
     if (forNameMID == NULL)
     {
         forNameMID = (*env)->GetStaticMethodID(env, classCls, "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;");
+        GLASS_CHECK_EXCEPTION(env);
     }
     if (forNameMID == NULL)
     {
@@ -77,6 +85,7 @@
 
     jclass foundClass = (*env)->CallStaticObjectMethod(env, classCls,
         forNameMID,classNameStr, JNI_TRUE, glassClassLoader);
+    GLASS_CHECK_EXCEPTION(env);
     (*env)->DeleteLocalRef(env, classNameStr);
 
     return foundClass;
--- a/modules/graphics/src/main/native-glass/mac/GlassKey.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassKey.m	Thu May 08 16:56:06 2014 -0700
@@ -268,6 +268,7 @@
     [chars getCharacters:jc range:NSMakeRange(0, [chars length])];
     jcharArray jChars = (*env)->NewCharArray(env, (jsize)[chars length]);
     (*env)->SetCharArrayRegion(env, jChars, 0, (jsize)[chars length], jc);
+    GLASS_CHECK_EXCEPTION(env);
     return jChars;
 }
 
--- a/modules/graphics/src/main/native-glass/mac/GlassMenu.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassMenu.m	Thu May 08 16:56:06 2014 -0700
@@ -360,9 +360,13 @@
     jclass jMenuClass = [GlassHelper ClassForName:"com.sun.glass.ui.Menu" withEnv:env];
     
     jMenuActionMethod  = (*env)->GetMethodID(env, jCallbackClass,   "action",  "()V");
+    if ((*env)->ExceptionCheck(env)) return;
     jMenuValidateMethod = (*env)->GetMethodID(env, jCallbackClass,   "validate",  "()V");
+    if ((*env)->ExceptionCheck(env)) return;
     jMenuOpeningMethod = (*env)->GetMethodID(env, jMenuClass, "notifyMenuOpening", "()V");
+    if ((*env)->ExceptionCheck(env)) return;
     jMenuClosedMethod  = (*env)->GetMethodID(env, jMenuClass, "notifyMenuClosed",  "()V");
+    if ((*env)->ExceptionCheck(env)) return;
     jDelegateMenuField = (*env)->GetFieldID(env,  jMenuDelegateClass, "menu", "Lcom/sun/glass/ui/Menu;");
 }
 
--- a/modules/graphics/src/main/native-glass/mac/GlassPasteboard.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassPasteboard.m	Thu May 08 16:56:06 2014 -0700
@@ -115,17 +115,26 @@
         {
             jbyte *w = (jbyte*)&width;
             (*env)->SetByteArrayRegion(env, javaArray, 0, 1, (jbyte *)&w[3]);
+            GLASS_CHECK_EXCEPTION(env);
             (*env)->SetByteArrayRegion(env, javaArray, 1, 1, (jbyte *)&w[2]);
+            GLASS_CHECK_EXCEPTION(env);
             (*env)->SetByteArrayRegion(env, javaArray, 2, 1, (jbyte *)&w[1]);
+            GLASS_CHECK_EXCEPTION(env);
             (*env)->SetByteArrayRegion(env, javaArray, 3, 1, (jbyte *)&w[0]);
-            
+            GLASS_CHECK_EXCEPTION(env);
+
             jbyte *h = (jbyte*)&height;
             (*env)->SetByteArrayRegion(env, javaArray, 4, 1, (jbyte *)&h[3]);
+            GLASS_CHECK_EXCEPTION(env);
             (*env)->SetByteArrayRegion(env, javaArray, 5, 1, (jbyte *)&h[2]);
+            GLASS_CHECK_EXCEPTION(env);
             (*env)->SetByteArrayRegion(env, javaArray, 6, 1, (jbyte *)&h[1]);
+            GLASS_CHECK_EXCEPTION(env);
             (*env)->SetByteArrayRegion(env, javaArray, 7, 1, (jbyte *)&h[0]);
-            
+            GLASS_CHECK_EXCEPTION(env);
+
             (*env)->SetByteArrayRegion(env, javaArray, 8, length, (jbyte *)data);
+            GLASS_CHECK_EXCEPTION(env);
         }
     }
     
@@ -144,6 +153,7 @@
         if (javaArray != NULL)
         {
             (*env)->SetByteArrayRegion(env, javaArray, 0, (jsize)[data length], (jbyte *)[data bytes]);
+            GLASS_CHECK_EXCEPTION(env);
         }
     }
     
@@ -430,7 +440,10 @@
         NSArray *items = [pasteboard pasteboardItems];
         if ([items count] > 0)
         {
-            utfs = (*env)->NewObjectArray(env, (jsize)[items count], (*env)->FindClass(env, "java/lang/Object"), NULL);
+            jclass jcls = (*env)->FindClass(env, "java/lang/Object");
+            GLASS_CHECK_EXCEPTION(env);
+            utfs = (*env)->NewObjectArray(env, (jsize)[items count], jcls, NULL);
+            GLASS_CHECK_EXCEPTION(env);
             for (NSUInteger i=0; i<[items count]; i++)
             {
                 NSPasteboardItem *item = [items objectAtIndex:i];
@@ -438,7 +451,10 @@
                 NSArray *types = [item types];
                 if ([types count] > 0)
                 {
-                    jobjectArray array = (*env)->NewObjectArray(env, (jsize)[types count], (*env)->FindClass(env, "java/lang/String"), NULL);
+                    jcls = (*env)->FindClass(env, "java/lang/String");
+                    GLASS_CHECK_EXCEPTION(env);
+                    jobjectArray array = (*env)->NewObjectArray(env, (jsize)[types count], jcls, NULL);
+                    GLASS_CHECK_EXCEPTION(env);
                     for (NSUInteger j=0; j<[types count]; j++)
                     {
                         NSString *type = [types objectAtIndex:j];
@@ -446,9 +462,11 @@
                         //if (property != nil) // allow null as the platform itself does
                         {
                             (*env)->SetObjectArrayElement(env, array, (jsize)j, (*env)->NewStringUTF(env, [type UTF8String]));
+                            GLASS_CHECK_EXCEPTION(env);
                         }
                     }
                     (*env)->SetObjectArrayElement(env, utfs, (jsize)i, array);
+                    GLASS_CHECK_EXCEPTION(env);
                 }
             }
         }
@@ -679,6 +697,7 @@
             for (int i=0; i<itemCount; i++)
             {
                 jobject array = (*env)->GetObjectArrayElement(env, jObjects, i);
+                GLASS_CHECK_EXCEPTION(env);
                 if (array != NULL)
                 {
                     NSPasteboardItem *item = NSPasteboardItemFromArray(env, array);
--- a/modules/graphics/src/main/native-glass/mac/GlassScreen.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassScreen.m	Thu May 08 16:56:06 2014 -0700
@@ -101,17 +101,20 @@
 
     if (jScreenClass == NULL)
     {
-        jScreenClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "com/sun/glass/ui/Screen"));
+        jclass jcls = (*env)->FindClass(env, "com/sun/glass/ui/Screen");
+        GLASS_CHECK_EXCEPTION(env);
+        jScreenClass = (*env)->NewGlobalRef(env, jcls);
     }
 
     jobjectArray screenArray = (*env)->NewObjectArray(env,
                                                       [screens count],
                                                       jScreenClass,
                                                       NULL);
-
+    GLASS_CHECK_EXCEPTION(env);
     for (NSUInteger index = 0; index < [screens count]; index++) {
         jobject javaScreen = createJavaScreen(env, [screens objectAtIndex:index]);
         (*env)->SetObjectArrayElement(env, screenArray, index, javaScreen);
+        GLASS_CHECK_EXCEPTION(env);
     }
 
     return screenArray;
@@ -122,9 +125,11 @@
     if (jScreenNotifySettingsChanged == NULL) 
     {
         jScreenNotifySettingsChanged = (*env)->GetStaticMethodID(env, jScreenClass, "notifySettingsChanged", "()V");
+        GLASS_CHECK_EXCEPTION(env);
     }
     
     (*env)->CallStaticVoidMethod(env, jScreenClass, jScreenNotifySettingsChanged);
+    GLASS_CHECK_EXCEPTION(env);
 }
 
 @implementation NSScreen (FullscreenAdditions)
--- a/modules/graphics/src/main/native-glass/mac/GlassStatics.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassStatics.m	Thu May 08 16:56:06 2014 -0700
@@ -27,6 +27,7 @@
 #import <pthread.h>
 #import <QuartzCore/CVDisplayLink.h>
 #import "GlassStatics.h"
+#import "GlassMacros.h"
 
 pthread_key_t GlassThreadDataKey = 0;
 
@@ -91,21 +92,36 @@
 void initJavaIDsList(JNIEnv* env)
 {
     if (!javaIDs.List.add) {
-        javaIDs.List.add = (*env)->GetMethodID(env, (*env)->FindClass(env, "java/util/List"), "add", "(Ljava/lang/Object;)Z");
+        jclass jcls = (*env)->FindClass(env, "java/util/List");
+        GLASS_CHECK_EXCEPTION(env);
+        if (jcls) {
+            javaIDs.List.add = (*env)->GetMethodID(env, jcls, "add", "(Ljava/lang/Object;)Z");
+            GLASS_CHECK_EXCEPTION(env);
+        }
     }
 }
 
 void initJavaIDsArrayList(JNIEnv* env)
 {
     if (!javaIDs.ArrayList.init) {
-        javaIDs.ArrayList.init = (*env)->GetMethodID(env, (*env)->FindClass(env, "java/util/ArrayList"), "<init>", "()V");
+        jclass jcls = (*env)->FindClass(env, "java/util/ArrayList");
+        GLASS_CHECK_EXCEPTION(env);
+        if (jcls) {
+            javaIDs.ArrayList.init = (*env)->GetMethodID(env, jcls, "<init>", "()V");
+            GLASS_CHECK_EXCEPTION(env);
+        }
     }
 }
 
 void initJavaIDsFile(JNIEnv* env)
 {
     if (!javaIDs.File.init) {
-        javaIDs.File.init = (*env)->GetMethodID(env, (*env)->FindClass(env, "java/io/File"), "<init>", "(Ljava/lang/String;)V");
+        jclass jcls = (*env)->FindClass(env, "java/io/File");
+        GLASS_CHECK_EXCEPTION(env);
+        if (jcls) {
+            javaIDs.File.init = (*env)->GetMethodID(env, jcls, "<init>", "(Ljava/lang/String;)V");
+            GLASS_CHECK_EXCEPTION(env);
+        }
     }
 }
 
--- a/modules/graphics/src/main/native-glass/mac/GlassView.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassView.m	Thu May 08 16:56:06 2014 -0700
@@ -90,118 +90,145 @@
     
     if (jIntegerClass == NULL)
     {
-        jIntegerClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "java/lang/Integer"));
+        jclass jcls = (*env)->FindClass(env, "java/lang/Integer");
+        if ((*env)->ExceptionCheck(env)) return;
+        jIntegerClass = (*env)->NewGlobalRef(env, jcls);
     }
     
     if (jMapClass == NULL)
     {
-        jMapClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "java/util/Map"));
+        jclass jcls = (*env)->FindClass(env, "java/util/Map");
+        if ((*env)->ExceptionCheck(env)) return;
+        jMapClass = (*env)->NewGlobalRef(env, jcls);
     }
     
     if (jBooleanClass == NULL)
     {
-        jBooleanClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "java/lang/Boolean"));
+        jclass jcls = (*env)->FindClass(env, "java/lang/Boolean");
+        if ((*env)->ExceptionCheck(env)) return;
+        jBooleanClass = (*env)->NewGlobalRef(env, jcls);
     }
     
     if (jViewNotifyEvent == NULL)
     {
         jViewNotifyEvent = (*env)->GetMethodID(env, jViewClass, "notifyView", "(I)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyRepaint == NULL)
     {
         jViewNotifyRepaint = (*env)->GetMethodID(env, jViewClass, "notifyRepaint", "(IIII)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyResize == NULL)
     {
         jViewNotifyResize = (*env)->GetMethodID(env, jViewClass, "notifyResize", "(II)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyKey == NULL)
     {
         jViewNotifyKey = (*env)->GetMethodID(env, jViewClass, "notifyKey", "(II[CI)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyMenu == NULL)
     {
         jViewNotifyMenu = (*env)->GetMethodID(env, jViewClass, "notifyMenu", "(IIIIZ)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyMouse == NULL)
     {
         jViewNotifyMouse = (*env)->GetMethodID(env, jViewClass, "notifyMouse", "(IIIIIIIZZ)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyInputMethod == NULL)
     {
         jViewNotifyInputMethod = (*env)->GetMethodID(env, jViewClass, "notifyInputMethod", "(Ljava/lang/String;[I[I[BIII)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyInputMethodMac == NULL)
     {
         jclass jMacViewClass = [GlassHelper ClassForName:"com.sun.glass.ui.mac.MacView" withEnv:env];
         jViewNotifyInputMethodMac = (*env)->GetMethodID(env, jMacViewClass, "notifyInputMethodMac", "(Ljava/lang/String;III)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if(jViewNotifyInputMethodCandidatePosRequest == NULL)
     {
         jViewNotifyInputMethodCandidatePosRequest = (*env)->GetMethodID(env, jViewClass, "notifyInputMethodCandidatePosRequest", "(I)[D");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyDragEnter == NULL)
     {
         jViewNotifyDragEnter = (*env)->GetMethodID(env, jViewClass, "notifyDragEnter", "(IIIII)I");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyDragOver == NULL)
     {
         jViewNotifyDragOver = (*env)->GetMethodID(env, jViewClass, "notifyDragOver", "(IIIII)I");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyDragLeave == NULL)
     {
         jViewNotifyDragLeave = (*env)->GetMethodID(env, jViewClass, "notifyDragLeave", "()V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyDragDrop == NULL)
     {
         jViewNotifyDragDrop = (*env)->GetMethodID(env, jViewClass, "notifyDragDrop", "(IIIII)I");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jViewNotifyDragEnd == NULL)
     {
         jViewNotifyDragEnd = (*env)->GetMethodID(env, jViewClass, "notifyDragEnd", "(I)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
 
     if (jViewGetAccessible == NULL)
     {
         jViewGetAccessible = (*env)->GetMethodID(env, jViewClass, "getAccessible", "()J");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jMapGetMethod == NULL)
     {
         jMapGetMethod = (*env)->GetMethodID(env, jMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jBooleanValueMethod == NULL)
     {
         jBooleanValueMethod = (*env)->GetMethodID(env, jBooleanClass, "booleanValue", "()Z");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jIntegerInitMethod == NULL)
     {
         jIntegerInitMethod = (*env)->GetMethodID(env, jIntegerClass, "<init>", "(I)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jIntegerValueMethod == NULL)
     {
         jIntegerValueMethod = (*env)->GetMethodID(env, jIntegerClass, "intValue", "()I");
+        if ((*env)->ExceptionCheck(env)) return;
     }
         
     if (jLongClass == NULL)
     {
-        jLongClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "java/lang/Long"));
+        jclass jcls = (*env)->FindClass(env, "java/lang/Long");
+        if ((*env)->ExceptionCheck(env)) return;
+        jLongClass = (*env)->NewGlobalRef(env, jcls);
     }
     
     if (jLongValueMethod == NULL)
@@ -291,7 +318,9 @@
         [view setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)];
         
         [hostView addSubview:view];
-        (*env)->SetLongField(env, jView, (*env)->GetFieldID(env, jViewClass, "ptr", "J"), ptr_to_jlong(view));
+        jfieldID jfID = (*env)->GetFieldID(env, jViewClass, "ptr", "J");
+        GLASS_CHECK_EXCEPTION(env);
+        (*env)->SetLongField(env, jView, jfID, ptr_to_jlong(view));
         
         value = ptr_to_jlong(view);
 
--- a/modules/graphics/src/main/native-glass/mac/GlassView3D.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassView3D.m	Thu May 08 16:56:06 2014 -0700
@@ -120,10 +120,13 @@
     if (jproperties != NULL)
     {
         jobject k3dDepthKey = (*env)->NewObject(env, jIntegerClass, jIntegerInitMethod, com_sun_glass_ui_View_Capability_k3dDepthKeyValue);
+        GLASS_CHECK_EXCEPTION(env);
         jobject k3dDepthKeyValue = (*env)->CallObjectMethod(env, jproperties, jMapGetMethod, k3dDepthKey);
+        GLASS_CHECK_EXCEPTION(env);
         if (k3dDepthKeyValue != NULL)
         {
             depthBits = (*env)->CallIntMethod(env, k3dDepthKeyValue, jIntegerValueMethod);
+            GLASS_CHECK_EXCEPTION(env);
         }
     }
     
@@ -132,9 +135,11 @@
     {
         jobject sharedContextPtrKey = (*env)->NewStringUTF(env, "shareContextPtr");
         jobject sharedContextPtrValue = (*env)->CallObjectMethod(env, jproperties, jMapGetMethod, sharedContextPtrKey);
+        GLASS_CHECK_EXCEPTION(env);
         if (sharedContextPtrValue != NULL)
         {
             jlong jsharedContextPtr = (*env)->CallLongMethod(env, sharedContextPtrValue, jLongValueMethod);
+            GLASS_CHECK_EXCEPTION(env);
             if (jsharedContextPtr != 0)
             {
                 NSOpenGLContext *sharedContextNS = (NSOpenGLContext*)jlong_to_ptr(jsharedContextPtr);
@@ -148,9 +153,11 @@
     {
         jobject contextPtrKey = (*env)->NewStringUTF(env, "contextPtr");
         jobject contextPtrValue = (*env)->CallObjectMethod(env, jproperties, jMapGetMethod, contextPtrKey);
+        GLASS_CHECK_EXCEPTION(env);
         if (contextPtrValue != NULL)
         {
             jlong jcontextPtr = (*env)->CallLongMethod(env, contextPtrValue, jLongValueMethod);
+            GLASS_CHECK_EXCEPTION(env);
             if (jcontextPtr != 0)
             {
                 NSOpenGLContext *clientContextNS = (NSOpenGLContext*)jlong_to_ptr(jcontextPtr);
@@ -173,10 +180,13 @@
     if (jproperties != NULL)
     {
         jobject kHiDPIAwareKey = (*env)->NewObject(env, jIntegerClass, jIntegerInitMethod, com_sun_glass_ui_View_Capability_kHiDPIAwareKeyValue);
+        GLASS_CHECK_EXCEPTION(env);
         jobject kHiDPIAwareValue = (*env)->CallObjectMethod(env, jproperties, jMapGetMethod, kHiDPIAwareKey);
+        GLASS_CHECK_EXCEPTION(env);
         if (kHiDPIAwareValue != NULL)
         {
             self->isHiDPIAware = (*env)->CallBooleanMethod(env, kHiDPIAwareValue, jBooleanValueMethod) ? YES : NO;
+            GLASS_CHECK_EXCEPTION(env);
         }
     }
 
@@ -444,9 +454,10 @@
 {
     KEYLOG("performKeyEquivalent");
     // Crash if the FS window is released while performing a key equivalent
-    [self->_delegate->fullscreenWindow retain];
+    // Local copy of the id keeps the retain/release calls balanced.
+    id fsWindow = [self->_delegate->fullscreenWindow retain];
     [self->_delegate sendJavaKeyEvent:theEvent isDown:YES];
-    [self->_delegate->fullscreenWindow release];
+    [fsWindow release];
     return NO; // return NO to allow system-default processing of Cmd+Q, etc.
 }
 
--- a/modules/graphics/src/main/native-glass/mac/GlassViewDelegate.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassViewDelegate.m	Thu May 08 16:56:06 2014 -0700
@@ -237,6 +237,7 @@
         }
         (*env)->CallVoidMethod(env, self->jView, jViewNotifyEvent, com_sun_glass_events_ViewEvent_REMOVE);
     }
+    GLASS_CHECK_EXCEPTION(env);
 }
 
 - (void)setFrameOrigin:(NSPoint)newOrigin
@@ -1005,6 +1006,7 @@
                                                     self->jView, 
                                                     jViewNotifyInputMethodCandidatePosRequest, 
                                                     pos);
+        GLASS_CHECK_EXCEPTION(env);
         if (theArray != NULL) {
             jint n = (*env)->GetArrayLength(env, theArray);
             if (n == 2) {
--- a/modules/graphics/src/main/native-glass/mac/GlassWindow.m	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-glass/mac/GlassWindow.m	Thu May 08 16:56:06 2014 -0700
@@ -70,7 +70,9 @@
 {
     if (jview != NULL)
     {
-        return (NSView<GlassView>*)jlong_to_ptr((*env)->GetLongField(env, jview, (*env)->GetFieldID(env, jViewClass, "ptr", "J")));
+        jfieldID jfID = (*env)->GetFieldID(env, jViewClass, "ptr", "J");
+        GLASS_CHECK_EXCEPTION(env);
+        return (NSView<GlassView>*)jlong_to_ptr((*env)->GetLongField(env, jview, jfID));
     }
     else
     {
@@ -168,10 +170,11 @@
 }                                                                                       \
 - (void)sendEvent:(NSEvent *)event                                                      \
 {                                                                                       \
-    [self->gWindow->view retain];                                                       \
+    /* Local copy of the id keeps the retain/release calls balanced. */                 \
+    id view = [self->gWindow->view retain];                                             \
     [self->gWindow sendEvent:event];                                                    \
     [super sendEvent:event];                                                            \
-    [self->gWindow->view release];                                                      \
+    [view release];                                                                     \
 }
 
 @implementation GlassWindow_Normal
@@ -604,41 +607,49 @@
     if (jWindowNotifyMove == NULL)
     {
         jWindowNotifyMove = (*env)->GetMethodID(env, jWindowClass, "notifyMove", "(II)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jWindowNotifyResize == NULL)
     {
         jWindowNotifyResize = (*env)->GetMethodID(env, jWindowClass, "notifyResize", "(III)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jWindowNotifyMoveToAnotherScreen == NULL)
     {
         jWindowNotifyMoveToAnotherScreen = (*env)->GetMethodID(env, jWindowClass, "notifyMoveToAnotherScreen", "(Lcom/sun/glass/ui/Screen;)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jWindowNotifyClose == NULL)
     {
         jWindowNotifyClose = (*env)->GetMethodID(env, jWindowClass, "notifyClose", "()V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jWindowNotifyFocus == NULL)
     {
         jWindowNotifyFocus = (*env)->GetMethodID(env, jWindowClass, "notifyFocus", "(I)V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jWindowNotifyFocusUngrab == NULL)
     {
         jWindowNotifyFocusUngrab = (*env)->GetMethodID(env, jWindowClass, "notifyFocusUngrab", "()V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jWindowNotifyFocusDisabled == NULL)
     {
         jWindowNotifyFocusDisabled = (*env)->GetMethodID(env, jWindowClass, "notifyFocusDisabled", "()V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jWindowNotifyDestroy == NULL)
     {
         jWindowNotifyDestroy = (*env)->GetMethodID(env, jWindowClass, "notifyDestroy", "()V");
+        if ((*env)->ExceptionCheck(env)) return;
     }
     
     if (jWindowNotifyDelegatePtr == NULL)
--- a/modules/graphics/src/main/native-iio/jpegloader.c	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-iio/jpegloader.c	Thu May 08 16:56:06 2014 -0700
@@ -59,6 +59,14 @@
 #endif
 #endif
 
+static jboolean checkAndClearException(JNIEnv *env) {
+    if (!(*env)->ExceptionCheck(env)) {
+        return JNI_FALSE;
+    }
+    (*env)->ExceptionClear(env);
+    return JNI_TRUE;
+}
+
 /***************** Begin verbatim copy from jni_util.c ***************/
 
 /**
@@ -67,9 +75,9 @@
 JNIEXPORT void JNICALL
 ThrowByName(JNIEnv *env, const char *name, const char *msg) {
     jclass cls = (*env)->FindClass(env, name);
-
-    if (cls != 0) /* Otherwise an exception has already been thrown */
+    if (!(*env)->ExceptionCheck(env) && cls != 0) {/* Otherwise an exception has already been thrown */
         (*env)->ThrowNew(env, cls, msg);
+    }
 }
 
 JNIEXPORT void * JNICALL
@@ -188,17 +196,11 @@
     /* Initialize a new buffer */
     jbyteArray hInputBuffer = (*env)->NewByteArray(env, STREAMBUF_SIZE);
     if (hInputBuffer == NULL) {
-        ThrowByName(env,
-                "java/lang/OutOfMemoryError",
-                "Initializing Reader");
         return NOT_OK;
     }
     sb->bufferLength = (*env)->GetArrayLength(env, hInputBuffer);
     sb->hstreamBuffer = (*env)->NewGlobalRef(env, hInputBuffer);
     if (sb->hstreamBuffer == NULL) {
-        ThrowByName(env,
-                "java/lang/OutOfMemoryError",
-                "Initializing Reader");
         return NOT_OK;
     }
 
@@ -594,6 +596,7 @@
         (*env)->CallVoidMethod(env, theObject,
                 JPEGImageLoader_emitWarningID,
                 string);
+        checkAndClearException(env);
     }
 }
 
@@ -1210,28 +1213,51 @@
             InputStreamClass,
             "read",
             "([BII)I");
+    if ((*env)->ExceptionCheck(env)) {
+        return;
+    }
+
     InputStream_skipID = (*env)->GetMethodID(env,
             InputStreamClass,
             "skip",
             "(J)J");
+    if ((*env)->ExceptionCheck(env)) {
+        return;
+    }
 
     // JPEGImageLoader IDs.
     JPEGImageLoader_setInputAttributesID = (*env)->GetMethodID(env,
             cls,
             "setInputAttributes",
             "(IIIII[B)V");
+    if ((*env)->ExceptionCheck(env)) {
+        return;
+    }
+
     JPEGImageLoader_setOutputAttributesID = (*env)->GetMethodID(env,
             cls,
             "setOutputAttributes",
             "(II)V");
+    if ((*env)->ExceptionCheck(env)) {
+        return;
+    }
+
     JPEGImageLoader_updateImageProgressID = (*env)->GetMethodID(env,
             cls,
             "updateImageProgress",
             "(I)V");
+    if ((*env)->ExceptionCheck(env)) {
+        return;
+    }
+
     JPEGImageLoader_emitWarningID = (*env)->GetMethodID(env,
             cls,
             "emitWarning",
             "(Ljava/lang/String;)V");
+    if ((*env)->ExceptionCheck(env)) {
+        return;
+    }
+
 }
 
 JNIEXPORT void JNICALL Java_com_sun_javafx_iio_jpeg_JPEGImageLoader_disposeNative
@@ -1340,6 +1366,8 @@
     }
 
     imageio_set_stream(env, (j_common_ptr) cinfo, data, stream);
+    
+    if ((*env)->ExceptionCheck(env)) return 0;
 
     imageio_init_source((j_decompress_ptr) cinfo);
 
@@ -1471,6 +1499,9 @@
                 cinfo->out_color_space,
                 cinfo->num_components,
                 profileData);
+        if ((*env)->ExceptionCheck(env)) {
+            return 0;
+        }
     }
 
     return ptr_to_jlong(data);
@@ -1605,6 +1636,7 @@
             (*env)->CallVoidMethod(env, this,
                     JPEGImageLoader_updateImageProgressID,
                     cinfo->output_scanline);
+            if ((*env)->ExceptionCheck(env)) return JNI_FALSE;
             if (GET_ARRAYS(env, data, &cinfo->src->next_input_byte) == NOT_OK) {
               ThrowByName(env,
                           "java/io/IOException",
@@ -1628,6 +1660,7 @@
         (*env)->CallVoidMethod(env, this,
                 JPEGImageLoader_updateImageProgressID,
                 cinfo->output_height);
+      if ((*env)->ExceptionCheck(env)) return JNI_FALSE;
       if (GET_ARRAYS(env, data, &cinfo->src->next_input_byte) == NOT_OK) {
           ThrowByName(env,
                 "java/io/IOException",
--- a/modules/graphics/src/main/native-prism-d3d/D3DContext.cc	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-prism-d3d/D3DContext.cc	Thu May 08 16:56:06 2014 -0700
@@ -737,7 +737,10 @@
 
     RETURN_STATUS_IF_NULL(pd3dDevice, E_FAIL);
 
-    HRESULT res = pd3dDevice->TestCooperativeLevel();
+    //TODO: call CheckDeviceState only if Present fails
+    HRESULT res = pd3dDeviceEx ?
+        pd3dDeviceEx->CheckDeviceState(NULL) :
+        pd3dDevice->TestCooperativeLevel();
 
     switch (res) {
     case S_OK: break;
@@ -749,6 +752,10 @@
         TraceLn1(NWT_TRACE_VERBOSE, "  device %d needs to be reset",
             adapterOrdinal);
         break;
+    case S_PRESENT_OCCLUDED:
+        break;
+    case S_PRESENT_MODE_CHANGED:
+        break;
     case E_FAIL:
         TraceLn(NWT_TRACE_VERBOSE, "  null device");
         break;
--- a/modules/graphics/src/main/native-prism-d3d/D3DPipeline.cc	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-prism-d3d/D3DPipeline.cc	Thu May 08 16:56:06 2014 -0700
@@ -36,6 +36,16 @@
 FnDirect3DCreate9 * pD3D9FactoryFunction = 0;
 FnDirect3DCreate9Ex * pD3D9FactoryExFunction = 0;
 
+extern jboolean checkAndClearException(JNIEnv *env);
+
+jboolean checkAndClearException(JNIEnv *env) {
+    if (!env->ExceptionCheck()) {
+        return JNI_FALSE;
+    }
+    env->ExceptionClear();
+    return JNI_TRUE;
+}
+
 void loadD3DLibrary() {
     wchar_t path[MAX_PATH];
     if (::GetSystemDirectory(path, sizeof(path) / sizeof(wchar_t)) != 0) {
@@ -168,6 +178,7 @@
 void setStringField(JNIEnv *env, jobject object, jclass clazz, const char *name, const char * string) {
     if (jobject jString = env->NewStringUTF(string)) {
         jfieldID id = env->GetFieldID(clazz, name, jStringField);
+        if (checkAndClearException(env)) return;
         env->SetObjectField(object, id, jString);
         env->DeleteLocalRef(jString);
     }
@@ -175,6 +186,7 @@
 
 void setIntField(JNIEnv *env, jobject object, jclass clazz, const char *name, int value) {
     jfieldID id = env->GetFieldID(clazz, name, "I");
+    if (checkAndClearException(env)) return;
     env->SetIntField(object, id, value);
 }
 
--- a/modules/graphics/src/main/native-prism-d3d/D3DResourceFactory.cc	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-prism-d3d/D3DResourceFactory.cc	Thu May 08 16:56:06 2014 -0700
@@ -537,7 +537,7 @@
 
     RETURN_STATUS_IF_NULL(pResource, FALSE);
 
-    return pResource->IsDefaultPool();
+    return pResource->IsDefaultPool() ? JNI_TRUE : JNI_FALSE;
 }
 
 /*
--- a/modules/graphics/src/main/native-prism-es2/GLContext.c	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-prism-es2/GLContext.c	Thu May 08 16:56:06 2014 -0700
@@ -1847,9 +1847,8 @@
     }
 
     vertexBufferSize = (*env)->GetArrayLength(env, vbArray);
+    indexBufferSize = (*env)->GetArrayLength(env, ibArray);
     vertexBuffer = (GLfloat *) ((*env)->GetPrimitiveArrayCritical(env, vbArray, NULL));
-
-    indexBufferSize = (*env)->GetArrayLength(env, ibArray);
     indexBuffer = (GLushort *) ((*env)->GetPrimitiveArrayCritical(env, ibArray, NULL));
 
     uvbSize = (GLuint) vbSize;
@@ -1917,9 +1916,8 @@
     }
 
     vertexBufferSize = (*env)->GetArrayLength(env, vbArray);
+    indexBufferSize = (*env)->GetArrayLength(env, ibArray);
     vertexBuffer = (GLfloat *) ((*env)->GetPrimitiveArrayCritical(env, vbArray, NULL));
-
-    indexBufferSize = (*env)->GetArrayLength(env, ibArray);
     indexBuffer = (GLuint *) ((*env)->GetPrimitiveArrayCritical(env, ibArray, NULL));
 
     uvbSize = (GLuint) vbSize;
--- a/modules/graphics/src/main/native-prism-es2/windows/WinGLDrawable.c	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-prism-es2/windows/WinGLDrawable.c	Thu May 08 16:56:06 2014 -0700
@@ -124,5 +124,5 @@
     if (dInfo == NULL) {
         return JNI_FALSE;
     }
-    return SwapBuffers(dInfo->hdc);
+    return SwapBuffers(dInfo->hdc) ? JNI_TRUE : JNI_FALSE;
 }
--- a/modules/graphics/src/main/native-prism-sw/JNIUtil.c	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-prism-sw/JNIUtil.c	Thu May 08 16:56:06 2014 -0700
@@ -33,6 +33,7 @@
     while (fields->name != NULL) {
         *dest = (*env)->GetFieldID(env, classHandle, fields->name, 
                                    fields->signature);
+        checkAndClearException(env);
         if (*dest == NULL) {
             retVal = JNI_FALSE;
             break;
@@ -52,6 +53,7 @@
     while (fields->name != NULL) {
         *dest = (*env)->GetStaticFieldID(env, classHandle, fields->name,
                                          fields->signature);
+        checkAndClearException(env);
         if (*dest == NULL) {
             retVal = JNI_FALSE;
             break;
@@ -65,12 +67,27 @@
 
 void
 JNI_ThrowNew(JNIEnv* env, const char* throwable, const char* message) {
-    jclass throwableClass = (*env)->FindClass(env, throwable);
-    if (throwableClass == NULL) {
+    jclass throwableClass;
+    jint status;
+
+    throwableClass = (*env)->FindClass(env, throwable);
+    if ((*env)->ExceptionCheck(env) || throwableClass == NULL) {
         (*env)->FatalError(env, "Failed to load an exception class!");
+        return;
     }
 
-    if ((*env)->ThrowNew(env, throwableClass, message) != 0) {
+    status = (*env)->ThrowNew(env, throwableClass, message);
+    if ((*env)->ExceptionCheck(env) || status != 0) {
         (*env)->FatalError(env, "Failed to throw an exception!");
     }
 }
+
+jboolean
+checkAndClearException(JNIEnv *env) {
+    if (!(*env)->ExceptionCheck(env)) {
+        return JNI_FALSE;
+    }
+    (*env)->ExceptionClear(env);
+    return JNI_TRUE;
+}
+
--- a/modules/graphics/src/main/native-prism-sw/JNIUtil.h	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-prism-sw/JNIUtil.h	Thu May 08 16:56:06 2014 -0700
@@ -43,5 +43,6 @@
 
 void JNI_ThrowNew(JNIEnv* env, const char* throwable, const char* message);
 
+jboolean checkAndClearException(JNIEnv *env);
 
 #endif
--- a/modules/graphics/src/main/native-prism-sw/JPiscesRenderer.c	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/main/native-prism-sw/JPiscesRenderer.c	Thu May 08 16:56:06 2014 -0700
@@ -332,10 +332,9 @@
         classHandle = (*env)->GetObjectClass(env, objectHandle);
     } else if (className != 0) {
         classHandle = (*env)->FindClass(env, className);
+        if (checkAndClearException(env)) return JNI_FALSE;
     } else {
-        classHandle = NULL;
-        JNI_ThrowNew(env, "java/lang/NullPointerException",
-                "Specify object instance or class name.");
+        return JNI_FALSE;
     }
 
     if (initializeFieldIds(fieldIds, env, classHandle, fieldDesc)) {
--- a/modules/graphics/src/test/java/com/sun/javafx/css/Node_cssStateTransition_Test.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/test/java/com/sun/javafx/css/Node_cssStateTransition_Test.java	Thu May 08 16:56:06 2014 -0700
@@ -25,35 +25,21 @@
 
 package com.sun.javafx.css;
 
-import com.sun.javafx.css.converters.FontConverter;
-import com.sun.javafx.css.converters.SizeConverter;
+
 import com.sun.javafx.css.parser.CSSParser;
-import com.sun.javafx.tk.Toolkit;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javafx.collections.FXCollections;
-import javafx.collections.MapChangeListener;
 import javafx.css.CssMetaData;
-import javafx.css.ParsedValue;
 import javafx.css.PseudoClass;
-import javafx.css.StyleOrigin;
-import javafx.css.Styleable;
 import javafx.css.StyleableProperty;
 import javafx.scene.Group;
 import javafx.scene.Scene;
 import javafx.scene.paint.Color;
 import javafx.scene.paint.Paint;
 import javafx.scene.shape.Rectangle;
-import javafx.scene.text.Font;
-import javafx.scene.text.Text;
-import javafx.stage.Stage;
 import static org.junit.Assert.*;
 
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -62,8 +48,17 @@
     public Node_cssStateTransition_Test() {
     }
 
+    @Before
+    public void setUp() {
+        StyleManager sm = StyleManager.getInstance();
+        sm.userAgentStylesheetContainers.clear();
+        sm.platformUserAgentStylesheetContainers.clear();
+        sm.stylesheetContainerMap.clear();
+        sm.cacheContainerMap.clear();
+        sm.hasDefaultUserAgentStylesheet = false;
+    }
 
-    @Test @Ignore("Pending RT-35594")
+    @Test
     public void testPropertiesResetOnStyleclassChange() {
 
         Rectangle rect = new Rectangle(50,50);
@@ -101,30 +96,29 @@
         StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         Scene scene = new Scene(root);
-        Stage stage = new Stage();
-        stage.setScene(scene);
-        stage.show();
+
+        root.applyCss();
 
         assertEquals(Color.RED, rect.getFill());
         assertEquals(Color.YELLOW, rect.getStroke());
         assertEquals(3d, rect.getStrokeWidth(), 1e-6);
 
         rect.getStyleClass().add("green");
-        Toolkit.getToolkit().firePulse();
+        root.applyCss();
 
         assertEquals(Color.GREEN, rect.getFill());
         assertEquals(Color.GREEN, rect.getStroke());
         assertEquals(3d, rect.getStrokeWidth(), 1e-6);
 
         rect.getStyleClass().remove("rect");
-        Toolkit.getToolkit().firePulse();
+        root.applyCss();
 
         assertEquals(defaultFill, rect.getFill());
         assertEquals(Color.GREEN, rect.getStroke());
         assertEquals(defaultStrokeWidth.doubleValue(), rect.getStrokeWidth(), 1e-6);
 
         rect.getStyleClass().remove("green");
-        Toolkit.getToolkit().firePulse();
+        root.applyCss();
 
         assertEquals(defaultFill, rect.getFill());
         assertEquals(defaultStroke, rect.getStroke());
@@ -169,37 +163,36 @@
         StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
 
         Scene scene = new Scene(root);
-        Stage stage = new Stage();
-        stage.setScene(scene);
-        stage.show();
+
+        root.applyCss();
 
         assertEquals(defaultFill, rect.getFill());
         assertEquals(defaultStroke, rect.getStroke());
         assertEquals(defaultStrokeWidth, rect.getStrokeWidth(), 1e-6);
 
         rect.pseudoClassStateChanged(PseudoClass.getPseudoClass("hover"), true);
-        Toolkit.getToolkit().firePulse();
+        root.applyCss();
 
         assertEquals(Color.RED, rect.getFill());
         assertEquals(Color.YELLOW, rect.getStroke());
         assertEquals(3d, rect.getStrokeWidth(), 1e-6);
 
         rect.pseudoClassStateChanged(PseudoClass.getPseudoClass("focused"), true);
-        Toolkit.getToolkit().firePulse();
+        root.applyCss();
 
         assertEquals(Color.GREEN, rect.getFill());
         assertEquals(Color.GREEN, rect.getStroke());
         assertEquals(3d, rect.getStrokeWidth(), 1e-6);
 
         rect.pseudoClassStateChanged(PseudoClass.getPseudoClass("hover"), false);
-        Toolkit.getToolkit().firePulse();
+        root.applyCss();
 
         assertEquals(defaultFill, rect.getFill());
         assertEquals(Color.GREEN, rect.getStroke());
         assertEquals(defaultStrokeWidth.doubleValue(), rect.getStrokeWidth(), 1e-6);
 
         rect.pseudoClassStateChanged(PseudoClass.getPseudoClass("focused"), false);
-        Toolkit.getToolkit().firePulse();
+        root.applyCss();
 
         assertEquals(defaultFill, rect.getFill());
         assertEquals(defaultStroke, rect.getStroke());
--- a/modules/graphics/src/test/java/com/sun/javafx/css/StyleManagerTest.java	Wed May 07 07:56:04 2014 -0700
+++ b/modules/graphics/src/test/java/com/sun/javafx/css/StyleManagerTest.java	Thu May 08 16:56:06 2014 -0700
@@ -33,6 +33,8 @@
 import javafx.scene.layout.Pane;
 import javafx.scene.paint.Color;
 import javafx.scene.shape.Rectangle;
+import javafx.stage.PopupWindow;
+import javafx.stage.Window;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -824,4 +826,66 @@
         assertEquals(Color.YELLOW, obj);
     }
 
+    @Test
+    public void testGetCacheContainer() {
+
+        Rectangle rectangle = new Rectangle();
+        SubScene subScene = new SubScene(null, 0, 0);
+
+        StyleManager sm = StyleManager.getInstance();
+
+        // no scene, should return null
+        StyleManager.CacheContainer container = sm.getCacheContainer(rectangle, subScene);
+
+        assertNull(container);
+
+        // has scene, should return non-null
+        subScene.setRoot(new Group());
+        Scene scene = new Scene(new Group(rectangle,subScene));
+        container = sm.getCacheContainer(rectangle, subScene);
+
+        assertNotNull(container);
+
+    }
+
+    @Test
+    public void testGetCacheContainer_styleable() {
+        Rectangle rectangle = new Rectangle();
+
+        StyleManager sm = StyleManager.getInstance();
+
+        // no scene, should return null
+        StyleManager.CacheContainer container = sm.getCacheContainer(rectangle, null);
+
+        assertNull(container);
+
+        // has scene, should return non-null
+        Scene scene = new Scene(new Group(rectangle));
+        container = sm.getCacheContainer(rectangle, null);
+
+        assertNotNull(container);
+
+    }
+
+    @Test
+    public void testGetCacheContainer_subScene() {
+
+        SubScene subScene = new SubScene(null, 0, 0);
+
+        StyleManager sm = StyleManager.getInstance();
+
+        // no scene, should return null
+        StyleManager.CacheContainer container = sm.getCacheContainer(null, subScene);
+
+        assertNull(container);
+
+        // has scene, should return non-null
+        subScene.setRoot(new Group());
+        Scene scene = new Scene(new Group(subScene));
+        container = sm.getCacheContainer(null, subScene);
+
+        assertNotNull(container);
+
+    }
+
 }
--- a/modules/media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/gst/isomp4/qtdemux.c	Wed May 07 07:56:04 2014 -0700
+++ b/modules/media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/gst/isomp4/qtdemux.c	Thu May 08 16:56:06 2014 -0700
@@ -77,7 +77,12 @@
 #define QTDEMUX_MAX_ATOM_SIZE (25*1024*1024)
 
 /* if the sample index is larger than this, something is likely wrong */
+#ifdef GSTREAMER_LITE
+// relaxing the limitation since some long files has more than 50Mb sample index
+#define QTDEMUX_MAX_SAMPLE_INDEX_SIZE (500*1024*1024)
+#else
 #define QTDEMUX_MAX_SAMPLE_INDEX_SIZE (50*1024*1024)
+#endif // GSTREAMER_LITE 
 
 /* For converting qt creation times to unix epoch times */
 #define QTDEMUX_SECONDS_PER_DAY (60 * 60 * 24)
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/DragTouchInAndOutAWindowTest.java	Wed May 07 07:56:04 2014 -0700
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/DragTouchInAndOutAWindowTest.java	Thu May 08 16:56:06 2014 -0700
@@ -77,7 +77,6 @@
      */
     @Test
     public void singleTouch_dragPointIntoTheWindow() throws Exception {
-        Assume.assumeTrue(!TestApplication.isMonocle()); // RT-35406
         Stage stage = TestApplication.getStage();
         int windowRightEnd = (int)(stage.getX() + stage.getWidth());
         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
@@ -145,7 +144,6 @@
      * 
      */
     public void singleTouch_dragPointInandOutAwindow() throws Exception {
-        Assume.assumeTrue(!TestApplication.isMonocle()); // RT-35406
         Stage stage = TestApplication.getStage();
         int windowMiddleWidth = (int)(stage.getX() + stage.getWidth() / 2);
         int windowMiddleHeight = (int)(stage.getY() + (stage.getHeight() / 2));
@@ -185,7 +183,6 @@
      * 
      */
     public void multiTouch_dragPointInandOutAwindow() throws Exception {
-        Assume.assumeTrue(!TestApplication.isMonocle()); // RT-35406
         Assume.assumeTrue(device.getPointCount() >= 2);
         Stage stage = TestApplication.getStage();
         int windowMiddleWidth = (int)(stage.getX() + stage.getWidth() / 2);
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/MultiTouch2Test.java	Wed May 07 07:56:04 2014 -0700
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/MultiTouch2Test.java	Thu May 08 16:56:06 2014 -0700
@@ -49,13 +49,10 @@
 
     @Test
     public void twoFingerTap() throws Exception {
-        Rectangle2D r = TestTouchDevices.getScreenBounds();
-        final int width = (int) r.getWidth();
-        final int height = (int) r.getHeight();
-        final int x1 = Math.round(width * 0.5f);
-        final int y1 = Math.round(height * 0.5f);
-        final int x2 = Math.round(width * 0.75f);
-        final int y2 = Math.round(height * 0.75f);
+        final int x1 = (int) Math.round(width * 0.5f);
+        final int y1 = (int) Math.round(height * 0.5f);
+        final int x2 = (int) Math.round(width * 0.75f);
+        final int y2 = (int) Math.round(height * 0.75f);
         TestLog.reset();
         // first finger
         int p1 = device.addPoint(x1, y1);
@@ -181,10 +178,6 @@
      */
     @Test
     public void pressReleasePressTest() throws Exception {
-
-        Rectangle2D r = TestTouchDevices.getScreenBounds();
-        final int width = (int) r.getWidth();
-        final int height = (int) r.getHeight();
         int x1 = (int) Math.round(width / 2);
         int y1 = (int) Math.round(height * 0.3);
         int x2 = (int) Math.round(width / 2);
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/ParameterizedTestBase.java	Wed May 07 07:56:04 2014 -0700
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/ParameterizedTestBase.java	Thu May 08 16:56:06 2014 -0700
@@ -74,7 +74,7 @@
     public void createDevice() throws Exception {
         TestApplication.showFullScreenScene();
         TestLog.log("Starting " + name.getMethodName() + "[" + device + "]");
-        Rectangle2D r = TestTouchDevices.getScreenBounds();
+        Rectangle2D r = TestApplication.getScreenBounds();
         width = r.getWidth();
         height = r.getHeight();
         TestLog.reset();
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/SimpleMouseTest.java	Wed May 07 07:56:04 2014 -0700
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/SimpleMouseTest.java	Thu May 08 16:56:06 2014 -0700
@@ -31,6 +31,7 @@
 import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestName;
@@ -237,4 +238,81 @@
         Assert.assertEquals(0, TestLog.countLogContaining("Mouse clicked"));
     }
 
+    @Test
+    public void testGrab1() throws Exception {
+        TestApplication.showInMiddleOfScreen();
+        TestApplication.addMouseListeners();
+        Rectangle2D r = TestApplication.getScreenBounds();
+        final int width = (int) r.getWidth();
+        final int height = (int) r.getHeight();
+        final int x1 = (int) Math.round(width * 0.5);
+        final int y1 = (int) Math.round(height * 0.5);
+        final int x2 = (int) Math.round(width * 0.7);
+        final int y2 = (int) Math.round(height * 0.7);
+        final int x3 = (int) Math.round(width * 0.9);
+        final int y3 = (int) Math.round(height * 0.9);
+        TestApplication.movePointerTo(x1, y1);
+        // press
+        ui.processLine("EV_KEY BTN_LEFT 1");
+        ui.processLine("EV_SYN");
+        // drag to x2, y2
+        ui.processLine("EV_REL REL_X " + (x2 - x1));
+        ui.processLine("EV_REL REL_Y " + (y2 - y1));
+        ui.processLine("EV_SYN");
+        TestLog.waitForLog("Mouse dragged: %d, %d", x2, y2);
+        // drag to x3, y3
+        ui.processLine("EV_REL REL_X " + (x3 - x2));
+        ui.processLine("EV_REL REL_Y " + (y3 - y2));
+        ui.processLine("EV_SYN");
+        TestLog.waitForLog("Mouse dragged: %d, %d", x3, y3);
+        TestLog.waitForLog("Mouse exited: %d, %d", x3, y3);
+        // drag to x2, y2
+        ui.processLine("EV_REL REL_X " + (x2 - x3));
+        ui.processLine("EV_REL REL_Y " + (y2 - y3));
+        ui.processLine("EV_SYN");
+        TestLog.waitForLog("Mouse dragged: %d, %d", x2, y2);
+        TestLog.waitForLog("Mouse entered: %d, %d", x2, y2);
+        // release
+        ui.processLine("EV_KEY BTN_LEFT 0");
+        ui.processLine("EV_SYN");
+        TestLog.waitForLog("Mouse released: %d, %d", x2, y2);
+        TestLog.waitForLog("Mouse clicked: %d, %d", x2, y2);
+    }
+
+    @Test
+    @Ignore("RT-37016")
+    public void testGrab2() throws Exception {
+        TestApplication.showInMiddleOfScreen();
+        TestApplication.addMouseListeners();
+        Rectangle2D r = TestApplication.getScreenBounds();
+        final int width = (int) r.getWidth();
+        final int height = (int) r.getHeight();
+        final int x1 = (int) Math.round(width * 0.5);
+        final int y1 = (int) Math.round(height * 0.5);
+        final int x2 = (int) Math.round(width * 0.7);
+        final int y2 = (int) Math.round(height * 0.7);
+        final int x3 = (int) Math.round(width * 0.9);
+        final int y3 = (int) Math.round(height * 0.9);
+        TestApplication.movePointerTo(x1, y1);
+        // press
+        ui.processLine("EV_KEY BTN_LEFT 1");
+        ui.processLine("EV_SYN");
+        // drag to x2, y2
+        ui.processLine("EV_REL REL_X " + (x2 - x1));
+        ui.processLine("EV_REL REL_Y " + (y2 - y1));
+        ui.processLine("EV_SYN");
+        TestLog.waitForLog("Mouse dragged: %d, %d", x2, y2);
+        // drag to x3, y3
+        ui.processLine("EV_REL REL_X " + (x3 - x2));
+        ui.processLine("EV_REL REL_Y " + (y3 - y2));
+        ui.processLine("EV_SYN");
+        TestLog.waitForLog("Mouse dragged: %d, %d", x3, y3);
+        TestLog.waitForLog("Mouse exited: %d, %d", x3, y3);
+        // release
+        ui.processLine("EV_KEY BTN_LEFT 0");
+        ui.processLine("EV_SYN");
+        TestLog.waitForLog("Mouse released: %d, %d", x3, y3);
+        TestLog.waitForLog("Mouse clicked: %d, %d", x3, y3);
+    }
+
 }
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/TestApplication.java	Wed May 07 07:56:04 2014 -0700
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/TestApplication.java	Thu May 08 16:56:06 2014 -0700
@@ -46,6 +46,7 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Consumer;
 
 public class TestApplication extends Application {
@@ -60,6 +61,7 @@
     private static String glassPlatform;
     private static boolean isMonocle;
     private static boolean isLens;
+    private static AtomicReference<Rectangle2D> screen = new AtomicReference<>();
 
     private static void initGlassPlatform() {
         if (glassPlatform == null) {
@@ -159,7 +161,6 @@
                 Scene scene = new Scene(root, bounds.getWidth() / 2,
                                         bounds.getHeight() / 2);
                 stage.setScene(scene);
-                stage.centerOnScreen();
 
                 stage.show();
                 stage.requestFocus();
@@ -227,6 +228,14 @@
             TestLog.log("Mouse clicked: "
                     + (int) e.getScreenX() + ", " + (int) e.getScreenY());
         });
+        getStage().getScene().setOnMouseEntered((e) -> {
+            TestLog.log("Mouse entered: "
+                                + (int) e.getScreenX() + ", " + (int) e.getScreenY());
+        });
+        getStage().getScene().setOnMouseExited((e) -> {
+            TestLog.log("Mouse exited: "
+                                + (int) e.getScreenX() + ", " + (int) e.getScreenY());
+        });
     }
 
     public static void addTouchListeners() throws Exception {
@@ -380,4 +389,31 @@
         return timeScale;
     }
 
+
+    private static void fetchScreenBounds() {
+        if (Platform.isFxApplicationThread()) {
+            screen.set(Screen.getPrimary().getBounds());
+        } else {
+            CountDownLatch latch = new CountDownLatch(1);
+            Platform.runLater(() -> {
+                screen.set(Screen.getPrimary().getBounds());
+                latch.countDown();
+            });
+            try {
+                latch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public static Rectangle2D getScreenBounds() {
+        Rectangle2D r = screen.get();
+        if (r == null) {
+            fetchScreenBounds();
+            r = screen.get();
+        }
+        return r;
+    }
+
 }
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/TouchLagTest.java	Wed May 07 07:56:04 2014 -0700
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/TouchLagTest.java	Thu May 08 16:56:06 2014 -0700
@@ -145,7 +145,8 @@
         }
         long t = System.currentTimeMillis() - startTime;
         // Make sure events could be sent in the required time
-        Assert.assertTrue("Took " + t + "ms to send 3000 events", t < 3000l);
+        Assert.assertTrue("Took " + t + "ms to send 3000 events",
+                          t < (long) (3000l * TestApplication.getTimeScale()));
         TestLog.log("Sent 3000 events in " + t + "ms");
         // move to 400, 410
         ui.writeValue(b, xs[0], 400);
@@ -158,7 +159,8 @@
         ui.processLine("EV_SYN SYN_MT_REPORT 0");
         ui.processLine("EV_SYN SYN_REPORT 0");
         // Make sure events could be delivered in the required time
-        TestLog.waitForLog("Touch moved: 400, 410", 3000l - t);
+        TestLog.waitForLog("Touch moved: 400, 410",
+                           (long) (3000l * TestApplication.getTimeScale()) - t);
     }
 
     /** Make sure we can process 1000 multitouch move events per second. We are
@@ -223,7 +225,8 @@
         }
         long t = System.currentTimeMillis() - startTime;
         // Make sure events could be sent in the required time
-        Assert.assertTrue("Took " + t + "ms to send 3000 events", t < 3000l);
+        Assert.assertTrue("Took " + t + "ms to send 3000 events",
+                          t < (long) (3000l * TestApplication.getTimeScale()));
         TestLog.log("Sent 3000 events in " + t + "ms");
         // move to (400, 410), (350, 360);
         ui.writeValue(b, baseX, 400);
@@ -247,6 +250,7 @@
         ui.processLine("EV_SYN SYN_MT_REPORT 0");
         ui.processLine("EV_SYN SYN_REPORT 0");
         // Make sure events could be delivered in the required time
-        TestLog.waitForLog("Touch released: 400, 410", 3000l - t);
+        TestLog.waitForLog("Touch released: 400, 410",
+                           (long) (3000l * TestApplication.getTimeScale()) - t);
     }
 }
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/ZoomTest.java	Wed May 07 07:56:04 2014 -0700
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/ZoomTest.java	Thu May 08 16:56:06 2014 -0700
@@ -59,10 +59,6 @@
      */
     @Test
     public void testZoomInSmallStepBigStep() throws Exception {
-
-        Rectangle2D r = TestTouchDevices.getScreenBounds();
-        final int width = (int) r.getWidth();
-        final int height = (int) r.getHeight();
         int x1 = (int) Math.round(width / 2);
         int y1 = (int) Math.round(height * 0.3);
         int x2 = (int) Math.round(width / 2);
@@ -159,10 +155,6 @@
      */
     @Test
     public void testZoomIn() throws Exception {
-
-        Rectangle2D r = TestTouchDevices.getScreenBounds();
-        final int width = (int) r.getWidth();
-        final int height = (int) r.getHeight();
         int x1 = (int) Math.round(width / 2);
         int y1 = (int) Math.round(height * 0.3);
         int x2 = (int) Math.round(width / 2);
@@ -239,10 +231,6 @@
      */
     @Test
     public void testZoomOut() throws Exception {
-
-        Rectangle2D r = TestTouchDevices.getScreenBounds();
-        final int width = (int) r.getWidth();
-        final int height = (int) r.getHeight();
         int x1 = (int) Math.round(width / 2);
         int y1 = (int) Math.round(height * 0.1);
         int x2 = (int) Math.round(width / 2);
@@ -339,10 +327,6 @@
      */
     @Test
     public void testZoomOutSmallStepBigStep() throws Exception {
-
-        Rectangle2D r = TestTouchDevices.getScreenBounds();
-        final int width = (int) r.getWidth();
-        final int height = (int) r.getHeight();
         int x1 = (int) Math.round(width / 2);
         int y1 = (int) Math.round(height * 0.1);
         int x2 = (int) Math.round(width / 2);
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/TestTouchDevice.java	Wed May 07 07:56:04 2014 -0700
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/TestTouchDevice.java	Thu May 08 16:56:06 2014 -0700
@@ -74,7 +74,7 @@
         if (absXMax == 0.0) {
             return (int) Math.round(x);
         } else {
-            Rectangle2D r = TestTouchDevices.getScreenBounds();
+            Rectangle2D r = TestApplication.getScreenBounds();
             return (int) Math.round(x * absXMax / r.getWidth());
         }
     }
@@ -83,7 +83,7 @@
         if (absXMax == 0.0) {
             return (int) Math.round(y);
         } else {
-            Rectangle2D r = TestTouchDevices.getScreenBounds();
+            Rectangle2D r = TestApplication.getScreenBounds();
             return (int) Math.round(y * absYMax / r.getHeight());
         }
     }
--- a/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/TestTouchDevices.java	Wed May 07 07:56:04 2014 -0700
+++ b/tests/system/src/test/java/com/sun/glass/ui/monocle/input/devices/TestTouchDevices.java	Thu May 08 16:56:06 2014 -0700
@@ -25,22 +25,14 @@
 
 package com.sun.glass.ui.monocle.input.devices;
 
-import javafx.application.Platform;
-import javafx.geometry.Rectangle2D;
-import javafx.stage.Screen;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 public class TestTouchDevices {
 
-    protected static AtomicReference<Rectangle2D> screen = new AtomicReference<>();
-
     public static List<TestTouchDevice> getTouchDevices() {
         List<TestTouchDevice> devices = new ArrayList<>();
         String selectedDeviceClass = System.getProperty("device");
@@ -86,30 +78,4 @@
         return c;
     }
 
-    private static void fetchScreenBounds() {
-        if (Platform.isFxApplicationThread()) {
-            screen.set(Screen.getPrimary().getBounds());
-        } else {
-            CountDownLatch latch = new CountDownLatch(1);
-            Platform.runLater(() -> {
-                screen.set(Screen.getPrimary().getBounds());
-                latch.countDown();
-            });
-            try {
-                latch.await();
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    public static Rectangle2D getScreenBounds() {
-        Rectangle2D r = screen.get();
-        if (r == null) {
-            fetchScreenBounds();
-            r = screen.get();
-        }
-        return r;
-    }
-
 }