aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaluca Sauciuc <ralucas@google.com>2018-07-27 10:50:20 -0700
committerDana Dahlstrom <dahlstrom@google.com>2018-07-27 17:58:36 +0000
commit141ca1f6b5a4f79118b276fe5db6cbeba98316bf (patch)
tree143e745be10c9a62740f6eb6e6d6e48b93533a4a
parent1da675d8d72ec67349efea838c95706b1eec373c (diff)
parent1807ee5ceb6114669fe8437cb940ed87ce05b7df (diff)
downloadjdk8u_jdk-141ca1f6b5a4f79118b276fe5db6cbeba98316bf.tar.gz
Merge jb8u152-b1136.39
-rw-r--r--src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java11
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java14
-rw-r--r--src/share/classes/java/awt/Component.java7
-rw-r--r--src/share/classes/java/awt/peer/WindowPeer.java18
-rw-r--r--src/share/classes/javax/swing/Popup.java9
-rw-r--r--src/solaris/classes/sun/awt/X11/XComponentPeer.java2
-rw-r--r--src/solaris/classes/sun/awt/X11/XWindowPeer.java29
-rw-r--r--src/windows/native/sun/windows/awt_Component.cpp39
-rw-r--r--src/windows/native/sun/windows/awt_Component.h6
-rw-r--r--src/windows/native/sun/windows/awt_Window.cpp28
10 files changed, 129 insertions, 34 deletions
diff --git a/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java b/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java
index eda6742c02..89911b8b7a 100644
--- a/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java
+++ b/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java
@@ -163,13 +163,10 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
kOpenGLSwapInterval);
if (cfginfo != 0L) {
textureSize = nativeGetMaxTextureSize();
- // Looks like it is outdated info, moreover on OSX in 4K resolution
- // reducing max size of the texture leads to performance degradation
- // in scrolling
- // // 7160609: GL still fails to create a square texture of this
- // // size. Half should be safe enough.
- // // Explicitly not support a texture more than 2^14, see 8010999.
- // // textureSize = textureSize <= 16384 ? textureSize / 2 : 8192;
+ // 7160609: GL still fails to create a square texture of this
+ // size. Half should be safe enough.
+ // Explicitly not support a texture more than 2^14, see 8010999.
+ textureSize = textureSize <= 16384 ? textureSize / 2 : 8192;
OGLContext.setScratchSurface(cfginfo);
rq.flushAndInvokeNow(() -> ids[0] = OGLContext.getOGLIdString());
}
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
index dbe66dce86..52978cddae 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
@@ -615,7 +615,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
if (visible) {
// Order myself above my parent
if (owner != null && owner.isVisible()) {
- CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr());
applyWindowLevel(target);
}
}
@@ -640,7 +639,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr);
if (!isKeyWindow) {
- CWrapper.NSWindow.makeKeyWindow(nsWindowPtr);
+ CWrapper.NSWindow.makeKeyWindow(nsWindowPtr);
}
} else {
// immediately hide the window
@@ -648,13 +647,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
// process the close
CWrapper.NSWindow.close(nsWindowPtr);
}
- } else {
- // otherwise, put it in a proper z-order
- CWrapper.NSWindow.orderWindow(nsWindowPtr, CWrapper.NSWindow.NSWindowBelow,
- ((CPlatformWindow)blocker.getPlatformWindow()).getNSWindowPtr());
}
- // Order my own children above myself
+ // Order my own children above myself
// Deal with the blocker of the window being shown
if (blocker != null && visible) {
// Make sure the blocker is above its siblings
@@ -1117,7 +1112,10 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) {
CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
} else if (target.getType() == Window.Type.POPUP) {
- CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel);
+ CWrapper.NSWindow.setLevel(getNSWindowPtr(),
+ WindowPeer.isLightweightDialog(target) ?
+ CWrapper.NSWindow.NSNormalWindowLevel :
+ CWrapper.NSWindow.NSPopUpMenuWindowLevel);
}
}
diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java
index eaa26dbe47..c9f129c980 100644
--- a/src/share/classes/java/awt/Component.java
+++ b/src/share/classes/java/awt/Component.java
@@ -62,6 +62,7 @@ import java.security.AccessControlContext;
import javax.accessibility.*;
import java.applet.Applet;
+import sun.security.action.GetBooleanAction;
import sun.security.action.GetPropertyAction;
import sun.awt.AppContext;
import sun.awt.AWTAccessor;
@@ -583,6 +584,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
*/
long eventMask = AWTEvent.INPUT_METHODS_ENABLED_MASK;
+ private static final boolean INPUT_METHODS_DISABLED;
+
/**
* Static properties for incremental drawing.
* @see #imageUpdate
@@ -604,6 +607,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
s = java.security.AccessController.doPrivileged(
new GetPropertyAction("awt.image.redrawrate"));
incRate = (s != null) ? Integer.parseInt(s) : 100;
+
+ INPUT_METHODS_DISABLED = java.security.AccessController.doPrivileged(new GetBooleanAction("awt.ime.disabled"));
}
/**
@@ -1585,6 +1590,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.2
*/
public void enableInputMethods(boolean enable) {
+ if (INPUT_METHODS_DISABLED) return;
if (enable) {
if ((eventMask & AWTEvent.INPUT_METHODS_ENABLED_MASK) != 0)
return;
@@ -5072,6 +5078,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
boolean areInputMethodsEnabled() {
+ if (INPUT_METHODS_DISABLED) return false;
// in 1.2, we assume input method support is required for all
// components that handle key events, but components can turn off
// input methods by calling enableInputMethods(false).
diff --git a/src/share/classes/java/awt/peer/WindowPeer.java b/src/share/classes/java/awt/peer/WindowPeer.java
index d9b2ffd35a..349ef4c18a 100644
--- a/src/share/classes/java/awt/peer/WindowPeer.java
+++ b/src/share/classes/java/awt/peer/WindowPeer.java
@@ -25,6 +25,7 @@
package java.awt.peer;
+import javax.swing.*;
import java.awt.*;
/**
@@ -124,4 +125,21 @@ public interface WindowPeer extends ContainerPeer {
* @return the system insets or null
*/
default Insets getSysInsets() { return null; }
+
+ static boolean isLightweightDialog(Window window) {
+ if (window instanceof RootPaneContainer) {
+ RootPaneContainer rootPaneContainer = (RootPaneContainer) window;
+ JRootPane rootPane = rootPaneContainer.getRootPane();
+ if (rootPane != null) {
+ Object property = rootPane.getClientProperty("SIMPLE_WINDOW");
+ if (property instanceof Boolean) {
+ Boolean isLightweightDialog = (Boolean)property;
+ if (isLightweightDialog) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/src/share/classes/javax/swing/Popup.java b/src/share/classes/javax/swing/Popup.java
index 2a5b1ab3d6..f98564df32 100644
--- a/src/share/classes/javax/swing/Popup.java
+++ b/src/share/classes/javax/swing/Popup.java
@@ -26,6 +26,8 @@
package javax.swing;
import java.awt.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import sun.awt.ModalExclude;
import sun.awt.SunToolkit;
@@ -232,7 +234,12 @@ public class Popup {
HeavyWeightWindow(Window parent) {
super(parent);
setFocusableWindowState(false);
-// setType(Window.Type.POPUP);
+
+ if (AccessController.doPrivileged(
+ (PrivilegedAction<Boolean>) () ->
+ System.getProperty("jbre.popupwindow.settype") != null)) {
+ setType(Window.Type.POPUP);
+ }
// Popups are typically transient and most likely won't benefit
// from true double buffering. Turn it off here.
diff --git a/src/solaris/classes/sun/awt/X11/XComponentPeer.java b/src/solaris/classes/sun/awt/X11/XComponentPeer.java
index f7409b23d2..b57f1bd170 100644
--- a/src/solaris/classes/sun/awt/X11/XComponentPeer.java
+++ b/src/solaris/classes/sun/awt/X11/XComponentPeer.java
@@ -335,7 +335,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
}
// If parent window can be made focused and has been made focused(synchronously)
// then we can proceed with children, otherwise we retreat.
- if (!res) {
+ if (!(res && parentWindow.isFocused())) {
return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
}
return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
diff --git a/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/src/solaris/classes/sun/awt/X11/XWindowPeer.java
index 2a9fe2a28a..d85781b2dd 100644
--- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java
+++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java
@@ -57,6 +57,8 @@ import sun.awt.IconInfo;
import sun.java2d.pipe.Region;
+import javax.swing.*;
+
class XWindowPeer extends XPanelPeer implements WindowPeer,
DisplayChangedListener {
@@ -108,10 +110,10 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
* The type is supposed to be immutable while the peer object exists.
* The value gets initialized in the preInit() method.
*/
- private Window.Type windowType = Window.Type.NORMAL;
+ private Window.Type windowType = getWindowType();
- public final Window.Type getWindowType() {
- return windowType;
+ final Window.Type getWindowType() {
+ return windowType == null ? Window.Type.NORMAL : windowType;
}
// It need to be accessed from XFramePeer.
@@ -1229,7 +1231,8 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
boolean isOverrideRedirect() {
return XWM.getWMID() == XWM.OPENLOOK_WM ||
- Window.Type.POPUP.equals(getWindowType());
+ (Window.Type.POPUP.equals(getWindowType()) &&
+ !isDialogLikePopup(getTarget()));
}
final boolean isOLWMDecorBug() {
@@ -1969,7 +1972,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_UTILITY;
break;
case POPUP:
- typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_POPUP_MENU;
+ typeAtom = isDialogLikePopup(getTarget()) ?
+ protocol.XA_NET_WM_WINDOW_TYPE_NORMAL :
+ protocol.XA_NET_WM_WINDOW_TYPE_POPUP_MENU;
break;
}
@@ -1984,6 +1989,20 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
}
+ boolean isDialogLikePopup (Object t) {
+ if (t instanceof JWindow) {
+ final JWindow target = (JWindow) getTarget();
+ final JRootPane rootPane = target.getRootPane();
+ if (rootPane != null) {
+ final Object value = rootPane.getClientProperty("SIMPLE_WINDOW");
+ if (value != null && (Boolean)value) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
@Override
public void xSetVisible(boolean visible) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
diff --git a/src/windows/native/sun/windows/awt_Component.cpp b/src/windows/native/sun/windows/awt_Component.cpp
index 2642b23471..f8dc397b64 100644
--- a/src/windows/native/sun/windows/awt_Component.cpp
+++ b/src/windows/native/sun/windows/awt_Component.cpp
@@ -52,6 +52,7 @@
#include <Region.h>
#include <jawt.h>
+#include <math.h>
#include <java_awt_Toolkit.h>
#include <java_awt_FontMetrics.h>
@@ -1558,6 +1559,12 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
SetCompositionWindow(r);
break;
}
+ case WM_ENTERSIZEMOVE:
+ {
+ m_inMoveResizeLoop = TRUE;
+ mr = mrDoDefault;
+ break;
+ }
case WM_SIZING:
mr = WmSizing();
break;
@@ -1569,6 +1576,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
break;
case WM_EXITSIZEMOVE:
+ m_inMoveResizeLoop = FALSE;
mr = WmExitSizeMove();
break;
// Bug #4039858 (Selecting menu item causes bogus mouse click event)
@@ -1867,6 +1875,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
"new = 0x%08X",
GetHWnd(), GetClassName(), (UINT)lParam);
mr = WmInputLangChange(static_cast<UINT>(wParam), reinterpret_cast<HKL>(lParam));
+ g_bUserHasChangedInputLang = TRUE;
CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
// should return non-zero if we process this message
retValue = 1;
@@ -2289,8 +2298,8 @@ void AwtComponent::PaintUpdateRgn(const RECT *insets)
*/
RECT* r = (RECT*)(buffer + rgndata->rdh.dwSize);
RECT* un[2] = {0, 0};
- DWORD i;
- for (i = 0; i < rgndata->rdh.nCount; i++, r++) {
+ DWORD i;
+ for (i = 0; i < rgndata->rdh.nCount; i++, r++) {
int width = r->right-r->left;
int height = r->bottom-r->top;
if (width > 0 && height > 0) {
@@ -2304,11 +2313,12 @@ void AwtComponent::PaintUpdateRgn(const RECT *insets)
}
for(i = 0; i < 2; i++) {
if (un[i] != 0) {
+ ScaleDownRect(*un[i]);
DoCallback("handleExpose", "(IIII)V",
- ScaleDownX(un[i]->left),
- ScaleDownY(un[i]->top),
- ScaleDownX(un[i]->right - un[i]->left),
- ScaleDownY(un[i]->bottom - un[i]->top));
+ un[i]->left,
+ un[i]->top,
+ un[i]->right - un[i]->left,
+ un[i]->bottom - un[i]->top);
}
}
delete [] buffer;
@@ -3863,13 +3873,14 @@ void AwtComponent::OpenCandidateWindow(int x, int y)
{
UINT bits = 1;
POINT p = {0, 0}; // upper left corner of the client area
- HWND hWnd = GetHWnd();
+ HWND hWnd = ImmGetHWnd();
HWND hTop = GetTopLevelParentForWindow(hWnd);
::ClientToScreen(hTop, &p);
-
+ int sx = ScaleUpDX(x) - p.x;
+ int sy = ScaleUpDY(y) - p.y;
for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
if ( m_bitsCandType & bits )
- SetCandidateWindow(iCandType, x - p.x, y - p.y);
+ SetCandidateWindow(iCandType, sx, sy);
}
if (m_bitsCandType != 0) {
// REMIND: is there any chance GetProxyFocusOwner() returns NULL here?
@@ -4778,6 +4789,16 @@ int AwtComponent::ScaleDownDY(int y) {
return device == NULL ? y : device->ScaleDownDY(y);
}
+void AwtComponent::ScaleDownRect(RECT& r) {
+ int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
+ Devices::InstanceAccess devices;
+ AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
+ if (device == NULL) return;
+ float sx = device->GetScaleX();
+ float sy = device->GetScaleY();
+ ::SetRect(&r, floor(r.left / sx), floor(r.top / sy), ceil(r.right / sx), ceil(r.bottom / sy));
+}
+
jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
diff --git a/src/windows/native/sun/windows/awt_Component.h b/src/windows/native/sun/windows/awt_Component.h
index 85e6faaf82..e4718523d9 100644
--- a/src/windows/native/sun/windows/awt_Component.h
+++ b/src/windows/native/sun/windows/awt_Component.h
@@ -728,6 +728,8 @@ public:
int ScaleUpDY(int y);
int ScaleDownDX(int x);
int ScaleDownDY(int y);
+ void ScaleDownRect(RECT& r);
+ //void ScaleDownDRect(RECT& r);
protected:
static AwtComponent* GetComponentImpl(HWND hWnd);
@@ -742,6 +744,8 @@ protected:
static BOOL sm_suppressFocusAndActivation;
static BOOL sm_restoreFocusAndActivation;
+ INLINE BOOL IsInMoveResizeLoop() { return m_inMoveResizeLoop; }
+
/*
* The function sets the focus-restore flag ON/OFF.
* When the flag is ON, focus is restored immidiately after the proxy loses it.
@@ -834,6 +838,8 @@ private:
int m_wheelRotationAmountX;
int m_wheelRotationAmountY;
+ BOOL m_inMoveResizeLoop;
+
BOOL deadKeyActive;
/*
diff --git a/src/windows/native/sun/windows/awt_Window.cpp b/src/windows/native/sun/windows/awt_Window.cpp
index 5a4588e98a..ffbedb70d7 100644
--- a/src/windows/native/sun/windows/awt_Window.cpp
+++ b/src/windows/native/sun/windows/awt_Window.cpp
@@ -955,8 +955,17 @@ MsgRouting AwtWindow::WmDPIChanged(UINT xDPI, UINT yDPI, RECT* bounds) {
// may diverge with Component::Reshape in this state
return mrDoDefault;
}
- // set the new bounds for async update
- ::CopyRect(&m_boundsOnDPIChange, bounds);
+ if (IsInMoveResizeLoop()) {
+ // Dragged with mouse to new screen. In this case the new bounds must be set immediately
+ // or otherwise OS will reset it back to the previous values.
+ ::SetWindowPos(GetHWnd(), NULL,
+ bounds->left, bounds->top,
+ bounds->right - bounds->left, bounds->bottom - bounds->top,
+ SWP_NOZORDER | SWP_NOACTIVATE);
+ } else {
+ // DPI of this screen changed. Store the new bounds for async update.
+ ::CopyRect(&m_boundsOnDPIChange, bounds);
+ }
return mrConsume;
}
@@ -1360,7 +1369,20 @@ void AwtWindow::Show()
if (nCmdShow == SW_SHOWNA) {
flags |= SWP_NOACTIVATE;
}
- ::SetWindowPos(GetHWnd(), HWND_TOPMOST, 0, 0, 0, 0, flags);
+
+ // This flag allows the toplevel to be bellow other process toplevels.
+ // This behaviour is preferable for popups, but it is not appropriate
+ // for menus
+ BOOL isLightweightDialog = TRUE;
+ jclass windowPeerClass = env->FindClass("java/awt/peer/WindowPeer");
+ if (windowPeerClass != NULL) {
+ jmethodID isLightweightDialogMID = env->GetStaticMethodID(windowPeerClass, "isLightweightDialog", "(Ljava/awt/Window;)Z");
+ if (isLightweightDialogMID != NULL) {
+ isLightweightDialog = env->CallStaticBooleanMethod(windowPeerClass, isLightweightDialogMID, target);
+ }
+ }
+
+ ::SetWindowPos(GetHWnd(), isLightweightDialog ? HWND_TOP : HWND_TOPMOST, 0, 0, 0, 0, flags);
} else {
::ShowWindow(GetHWnd(), nCmdShow);
}