changeset 10111:4981c573fd92 jdk-9+143

8166856: OS X: dual screen rendering issue Reviewed-by: ckyang
author flar
date Fri, 28 Oct 2016 16:22:46 -0700
parents 6eacb5c3f217
children 2e4a005324ed 6122217b5fed
files modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacWindow.java modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java modules/javafx.graphics/src/main/native-glass/mac/GlassStatics.h modules/javafx.graphics/src/main/native-glass/mac/GlassStatics.m modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Overrides.m modules/javafx.graphics/src/main/native-glass/mac/GlassWindow.m
diffstat 7 files changed, 26 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacWindow.java	Thu Oct 27 11:14:40 2016 -0700
+++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacWindow.java	Fri Oct 28 16:22:46 2016 -0700
@@ -52,16 +52,6 @@
         super(parent);
     }
 
-    @Override
-    protected void setScreen(Screen screen) {
-        // SceneState will be called to update with new scale values
-        // before we return from super.setScreen()...
-        super.setScreen(screen);
-        notifyScaleChanged(1.0f, 1.0f,
-                           screen.getRecommendedOutputScaleX(),
-                           screen.getRecommendedOutputScaleY());
-    }
-
     @Override native protected long _createWindow(long ownerPtr, long screenPtr, int mask);
     @Override native protected long _createChildWindow(long parent);
     @Override native protected boolean _close(long ptr);
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Thu Oct 27 11:14:40 2016 -0700
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Fri Oct 28 16:22:46 2016 -0700
@@ -364,13 +364,15 @@
         } else {
             px = py = 0;
         }
-        int pw = (int) (w > 0 ? Math.ceil(w * pScaleX) : w);
-        int ph = (int) (h > 0 ? Math.ceil(h * pScaleY) : h);
-        int pcw = (int) (cw > 0 ? Math.ceil(cw * pScaleX) : cw);
-        int pch = (int) (ch > 0 ? Math.ceil(ch * pScaleY) : ch);
-        platformWindow.setBounds(px, py, xSet, ySet,
-                                 pw, ph, pcw, pch,
-                                 xGravity, yGravity);
+        if (xSet || ySet || w > 0 || h > 0 || cw > 0 || ch > 0) {
+            int pw = (int) (w > 0 ? Math.ceil(w * pScaleX) : w);
+            int ph = (int) (h > 0 ? Math.ceil(h * pScaleY) : h);
+            int pcw = (int) (cw > 0 ? Math.ceil(cw * pScaleX) : cw);
+            int pch = (int) (ch > 0 ? Math.ceil(ch * pScaleY) : ch);
+            platformWindow.setBounds(px, py, xSet, ySet,
+                                     pw, ph, pcw, pch,
+                                     xGravity, yGravity);
+        }
     }
 
     @Override
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassStatics.h	Thu Oct 27 11:14:40 2016 -0700
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassStatics.h	Fri Oct 28 16:22:46 2016 -0700
@@ -51,6 +51,7 @@
 extern jmethodID jWindowNotifyResize;
 extern jmethodID jWindowNotifyClose;
 extern jmethodID jWindowNotifyMoveToAnotherScreen;
+extern jmethodID jWindowNotifyScaleChanged;
 extern jmethodID jWindowNotifyFocus;
 extern jmethodID jWindowNotifyFocusUngrab;
 extern jmethodID jWindowNotifyFocusDisabled;
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassStatics.m	Thu Oct 27 11:14:40 2016 -0700
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassStatics.m	Fri Oct 28 16:22:46 2016 -0700
@@ -53,6 +53,7 @@
 jmethodID jWindowNotifyResize = NULL;
 jmethodID jWindowNotifyClose = NULL;
 jmethodID jWindowNotifyMoveToAnotherScreen = NULL;
+jmethodID jWindowNotifyScaleChanged = NULL;
 jmethodID jWindowNotifyFocus = NULL;
 jmethodID jWindowNotifyFocusUngrab = NULL;
 jmethodID jWindowNotifyFocusDisabled = NULL;
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m	Thu Oct 27 11:14:40 2016 -0700
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m	Fri Oct 28 16:22:46 2016 -0700
@@ -69,6 +69,12 @@
     }
 }
 
+- (void)_sendJavaWindowNotifyScaleChanged:(CGFloat)newScale
+{
+    GET_MAIN_JENV;
+    (*env)->CallVoidMethod(env, jWindow, jWindowNotifyScaleChanged, 1.0f, 1.0f, newScale, newScale);
+}
+
 - (void)_sendJavaWindowMoveEventForFrame:(NSRect)frame
 {
     if (self->suppressWindowMoveEvent == NO)
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Overrides.m	Thu Oct 27 11:14:40 2016 -0700
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Overrides.m	Fri Oct 28 16:22:46 2016 -0700
@@ -137,7 +137,9 @@
     // The spec for [NSWindow backingScaleFactor] only mentions 1.0 and 2.0
     // whereas NSScreen's one is more generic. So use the latter.
     if ([self->nsWindow screen]) {
-        [self->view notifyScaleFactorChanged:GetScreenScaleFactor([self->nsWindow screen])];
+        CGFloat scale = GetScreenScaleFactor([self->nsWindow screen]);
+        [self->view notifyScaleFactorChanged:scale];
+        [self _sendJavaWindowNotifyScaleChanged:scale];
     }
 
     // Screen.notifySettingsChanged() calls Window.setScreen(), and the latter
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow.m	Thu Oct 27 11:14:40 2016 -0700
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow.m	Fri Oct 28 16:22:46 2016 -0700
@@ -636,6 +636,12 @@
         if ((*env)->ExceptionCheck(env)) return;
     }
 
+    if (jWindowNotifyScaleChanged == NULL)
+    {
+        jWindowNotifyScaleChanged = (*env)->GetMethodID(env, jWindowClass, "notifyScaleChanged", "(FFFF)V");
+        if ((*env)->ExceptionCheck(env)) return;
+    }
+
     if (jWindowNotifyClose == NULL)
     {
         jWindowNotifyClose = (*env)->GetMethodID(env, jWindowClass, "notifyClose", "()V");