Skip to content
Permalink
Browse files

8237049: Rollback the workaround for JDK-4533057

Reviewed-by: dmarkov
  • Loading branch information
mrserb committed Jan 24, 2020
1 parent 7fa7536 commit 05b98dd4f9681dc19d7675b86daafd2b253f7cbe
@@ -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,60 +25,125 @@

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 java.util.Hashtable;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

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;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

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 @@ public Void run() {
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
@@ -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 AwtPalette::Select(HDC hDC)
{
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 @@ HPALETTE AwtPalette::Select(HDC hDC)
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
@@ -79,28 +75,6 @@ void AwtPalette::Realize(HDC hDC)
}
}

/**
* 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 @@ int AwtPalette::FetchPaletteEntries(HDC hDC, PALETTEENTRY* pPalEntries)
return 0;
}

hPalOld = ::SelectPalette(hDC, hPal, 1);
hPalOld = ::SelectPalette(hDC, hPal, TRUE);
if (hPalOld == 0) {
::DeleteObject(hPal);
return 0;
@@ -168,7 +142,7 @@ int AwtPalette::FetchPaletteEntries(HDC hDC, PALETTEENTRY* pPalEntries)
pPalEntries[iEntry].peBlue = GetBValue(rgb);
}

::SelectPalette(hDC, hPalOld, 0 );
::SelectPalette(hDC, hPalOld, FALSE);
::DeleteObject(hPal);
::RealizePalette(hDC);

@@ -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 @@ class AwtPalette {

HPALETTE GetPalette() { return logicalPalette; }

static void DisableCustomPalette();

static BOOL UseCustomPalette();

AwtPalette(AwtWin32GraphicsDevice *device);

static int FetchPaletteEntries(HDC hDC, PALETTEENTRY* pPalEntries);
@@ -66,8 +62,6 @@ class AwtPalette {
unsigned char *GetSystemInverseLUT() { return systemInverseLUT; }

private:
static BOOL m_useCustomPalette;

unsigned int logicalEntries[256];
unsigned int systemEntries[256];
PALETTEENTRY systemEntriesWin32[256]; // cached to eliminate
@@ -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 @@ Java_sun_awt_windows_WToolkit_initIDs(JNIEnv *env, jclass cls)
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
@@ -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 @@ jobject AwtWin32GraphicsDevice::GetColorModel(JNIEnv *env, jboolean dynamic)
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

0 comments on commit 05b98dd

Please sign in to comment.