changeset 57997:499e5a8a13ea

8237049: Rollback the workaround for JDK-4533057 Reviewed-by: dmarkov
author serb
date Thu, 23 Jan 2020 21:42:27 -0800
parents 635eaa93419e
children ffcc3bd2b5da
files src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java src/java.desktop/windows/native/libawt/windows/awt_Palette.cpp src/java.desktop/windows/native/libawt/windows/awt_Palette.h src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
diffstat 5 files changed, 111 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java	Thu Jan 23 17:32:38 2020 +0530
+++ b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java	Thu Jan 23 21:42:27 2020 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,49 +25,98 @@
 
 package sun.awt.windows;
 
-import java.awt.peer.TaskbarPeer;
-import java.awt.*;
-import java.awt.im.InputMethodHighlight;
-import java.awt.im.spi.InputMethodDescriptor;
-import java.awt.image.*;
-import java.awt.peer.*;
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Canvas;
+import java.awt.Checkbox;
+import java.awt.CheckboxMenuItem;
+import java.awt.Choice;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Desktop;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.FileDialog;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.JobAttributes;
+import java.awt.Label;
+import java.awt.List;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.PageAttributes;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.PopupMenu;
+import java.awt.PrintJob;
+import java.awt.RenderingHints;
+import java.awt.Robot;
+import java.awt.ScrollPane;
+import java.awt.Scrollbar;
+import java.awt.SystemTray;
+import java.awt.Taskbar;
+import java.awt.TextArea;
+import java.awt.TextComponent;
+import java.awt.TextField;
+import java.awt.Toolkit;
+import java.awt.TrayIcon;
+import java.awt.Window;
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.MouseDragGestureRecognizer;
+import java.awt.dnd.peer.DragSourceContextPeer;
 import java.awt.event.FocusEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.MouseEvent;
-import java.awt.datatransfer.Clipboard;
-import java.awt.TextComponent;
-import java.awt.TrayIcon;
+import java.awt.im.InputMethodHighlight;
+import java.awt.im.spi.InputMethodDescriptor;
+import java.awt.image.ColorModel;
+import java.awt.peer.ButtonPeer;
+import java.awt.peer.CanvasPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+import java.awt.peer.CheckboxPeer;
+import java.awt.peer.ChoicePeer;
+import java.awt.peer.DesktopPeer;
+import java.awt.peer.DialogPeer;
+import java.awt.peer.FileDialogPeer;
+import java.awt.peer.FontPeer;
+import java.awt.peer.FramePeer;
+import java.awt.peer.KeyboardFocusManagerPeer;
+import java.awt.peer.LabelPeer;
+import java.awt.peer.ListPeer;
+import java.awt.peer.MenuBarPeer;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.MenuPeer;
+import java.awt.peer.MouseInfoPeer;
+import java.awt.peer.PanelPeer;
+import java.awt.peer.PopupMenuPeer;
+import java.awt.peer.RobotPeer;
+import java.awt.peer.ScrollPanePeer;
+import java.awt.peer.ScrollbarPeer;
+import java.awt.peer.SystemTrayPeer;
+import java.awt.peer.TaskbarPeer;
+import java.awt.peer.TextAreaPeer;
+import java.awt.peer.TextFieldPeer;
+import java.awt.peer.TrayIconPeer;
+import java.awt.peer.WindowPeer;
 import java.beans.PropertyChangeListener;
 import java.lang.ref.WeakReference;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import javax.swing.text.JTextComponent;
-
-import sun.awt.AWTAccessor;
-import sun.awt.AppContext;
-import sun.awt.AWTAutoShutdown;
-import sun.awt.AWTPermissions;
-import sun.awt.AppContext;
-import sun.awt.DisplayChangedListener;
-import sun.awt.LightweightFrame;
-import sun.awt.SunToolkit;
-import sun.awt.util.ThreadGroupUtils;
-import sun.awt.Win32GraphicsDevice;
-import sun.awt.Win32GraphicsEnvironment;
-import sun.awt.datatransfer.DataTransferer;
-import sun.java2d.d3d.D3DRenderQueue;
-import sun.java2d.opengl.OGLRenderQueue;
-
-import sun.print.PrintJob2D;
-
-import java.awt.dnd.DragSource;
-import java.awt.dnd.DragGestureListener;
-import java.awt.dnd.DragGestureEvent;
-import java.awt.dnd.DragGestureRecognizer;
-import java.awt.dnd.MouseDragGestureRecognizer;
-import java.awt.dnd.InvalidDnDOperationException;
-import java.awt.dnd.peer.DragSourceContextPeer;
-
 import java.util.Hashtable;
 import java.util.Locale;
 import java.util.Map;
@@ -75,10 +124,26 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import javax.swing.text.JTextComponent;
+
+import sun.awt.AWTAccessor;
+import sun.awt.AWTAutoShutdown;
+import sun.awt.AWTPermissions;
+import sun.awt.AppContext;
+import sun.awt.DisplayChangedListener;
+import sun.awt.LightweightFrame;
+import sun.awt.SunToolkit;
+import sun.awt.Win32GraphicsDevice;
+import sun.awt.Win32GraphicsEnvironment;
+import sun.awt.datatransfer.DataTransferer;
 import sun.awt.util.PerformanceLogger;
+import sun.awt.util.ThreadGroupUtils;
 import sun.font.FontManager;
 import sun.font.FontManagerFactory;
 import sun.font.SunFontManager;
+import sun.java2d.d3d.D3DRenderQueue;
+import sun.java2d.opengl.OGLRenderQueue;
+import sun.print.PrintJob2D;
 import sun.util.logging.PlatformLogger;
 
 public final class WToolkit extends SunToolkit implements Runnable {
@@ -133,23 +198,8 @@
         if (log.isLoggable(PlatformLogger.Level.FINE)) {
             log.fine("Win version: " + getWindowsVersion());
         }
-
-        AccessController.doPrivileged(
-            new PrivilegedAction <Void> ()
-        {
-            @Override
-            public Void run() {
-                String browserProp = System.getProperty("browser");
-                if (browserProp != null && browserProp.equals("sun.plugin")) {
-                    disableCustomPalette();
-                }
-                return null;
-            }
-        });
     }
 
-    private static native void disableCustomPalette();
-
     /*
      * NOTE: The following embedded*() methods are non-public API intended
      * for internal use only.  The methods are unsupported and could go
--- a/src/java.desktop/windows/native/libawt/windows/awt_Palette.cpp	Thu Jan 23 17:32:38 2020 +0530
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Palette.cpp	Thu Jan 23 21:42:27 2020 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,8 +30,6 @@
 #include "awt_CustomPaletteDef.h"
 #include "Trace.h"
 
-BOOL AwtPalette::m_useCustomPalette = TRUE;
-
 #define ERROR_GRAY (-1)
 #define NON_GRAY 0
 #define LINEAR_STATIC_GRAY 1
@@ -46,8 +44,7 @@
 {
     HPALETTE prevPalette = NULL;
     if (logicalPalette) {
-        BOOL background = !(m_useCustomPalette);
-        prevPalette = ::SelectPalette(hDC, logicalPalette, background);
+        prevPalette = ::SelectPalette(hDC, logicalPalette, FALSE);
     }
     return prevPalette;
 }
@@ -60,8 +57,7 @@
 void AwtPalette::Realize(HDC hDC)
 {
     if (logicalPalette) {
-        if (!m_useCustomPalette ||
-            AwtComponent::QueryNewPaletteCalled() ||
+        if (AwtComponent::QueryNewPaletteCalled() ||
             AwtToolkit::GetInstance().HasDisplayChanged()) {
             // Fix for bug 4178909, workaround for Windows bug.  Shouldn't
             // do a RealizePalette until the first QueryNewPalette message
@@ -80,28 +76,6 @@
 }
 
 /**
- * Disable the use of our custom palette.  This method is called
- * during initialization if we detect that we are running inside
- * the plugin; we do not want to clobber our parent application's
- * palette with our own in that situation.
- */
-void AwtPalette::DisableCustomPalette()
-{
-    m_useCustomPalette = FALSE;
-}
-
-/**
- * Returns whether we are currently using a custom palette.  Used
- * by AwtWin32GraphicsDevice when creating the colorModel of the
- * device.
- */
-BOOL AwtPalette::UseCustomPalette()
-{
-    return m_useCustomPalette;
-}
-
-
-/**
  * Constructor.  Initialize the system and logical palettes.
  * used by this object.
  */
@@ -153,7 +127,7 @@
         return 0;
     }
 
-    hPalOld = ::SelectPalette(hDC, hPal, 1);
+    hPalOld = ::SelectPalette(hDC, hPal, TRUE);
     if (hPalOld == 0) {
         ::DeleteObject(hPal);
         return 0;
@@ -168,7 +142,7 @@
         pPalEntries[iEntry].peBlue = GetBValue(rgb);
     }
 
-    ::SelectPalette(hDC, hPalOld, 0 );
+    ::SelectPalette(hDC, hPalOld, FALSE);
     ::DeleteObject(hPal);
     ::RealizePalette(hDC);
 
--- a/src/java.desktop/windows/native/libawt/windows/awt_Palette.h	Thu Jan 23 17:32:38 2020 +0530
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Palette.h	Thu Jan 23 21:42:27 2020 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,10 +49,6 @@
 
     HPALETTE                GetPalette() { return logicalPalette; }
 
-    static void             DisableCustomPalette();
-
-    static BOOL             UseCustomPalette();
-
                             AwtPalette(AwtWin32GraphicsDevice *device);
 
     static int              FetchPaletteEntries(HDC hDC, PALETTEENTRY* pPalEntries);
@@ -66,8 +62,6 @@
     unsigned char           *GetSystemInverseLUT() { return systemInverseLUT; }
 
 private:
-    static BOOL             m_useCustomPalette;
-
     unsigned int            logicalEntries[256];
     unsigned int            systemEntries[256];
     PALETTEENTRY            systemEntriesWin32[256];  // cached to eliminate
--- a/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp	Thu Jan 23 17:32:38 2020 +0530
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp	Thu Jan 23 21:42:27 2020 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2465,17 +2465,6 @@
     CATCH_BAD_ALLOC;
 }
 
-
-/*
- * Class:     sun_awt_windows_Toolkit
- * Method:    disableCustomPalette
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_windows_WToolkit_disableCustomPalette(JNIEnv *env, jclass cls) {
-    AwtPalette::DisableCustomPalette();
-}
-
 /*
  * Class:     sun_awt_windows_WToolkit
  * Method:    embeddedInit
--- a/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp	Thu Jan 23 17:32:38 2020 +0530
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp	Thu Jan 23 21:42:27 2020 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -405,7 +405,7 @@
                 vbits[sizeof(vbits)-1] = 0;
                 allvalid = JNI_FALSE;
             } else {
-                if (AwtPalette::UseCustomPalette() && !dynamic) {
+                if (!dynamic) {
                     // If we plan to use our custom palette (i.e., we are
                     // not running inside another app and we are not creating
                     // a dynamic colorModel object), then setup ICM with