src/windows/classes/sun/awt/windows/WToolkit.java

Print this page

        

*** 59,68 **** --- 59,69 ---- import java.util.Hashtable; import java.util.Locale; import java.util.Map; import java.util.Properties; + import java.util.concurrent.atomic.AtomicBoolean; import sun.font.FontManager; import sun.font.FontManagerFactory; import sun.font.SunFontManager; import sun.misc.PerformanceLogger;
*** 70,79 **** --- 71,83 ---- public final class WToolkit extends SunToolkit implements Runnable { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit"); + // Desktop property which specifies whether XP visual styles are in effect + public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive"; + static GraphicsConfiguration config; // System clipboard. WClipboard clipboard;
*** 81,90 **** --- 85,97 ---- private Hashtable<String,FontPeer> cacheFontPeer; // Windows properties private WDesktopProperties wprops; + // Visual styles enabled? + private final AtomicBoolean xpstyleEnabled = new AtomicBoolean(false); + // Dynamic Layout Resize client code setting protected boolean dynamicLayoutSetting = false; //Is it allowed to generate events assigned to extra mouse buttons. //Set to true by default.
*** 927,960 **** * Called from native toolkit code when WM_SETTINGCHANGE message received * Also called from lazilyLoadDynamicLayoutSupportedProperty because * Windows doesn't always send WM_SETTINGCHANGE when it should. */ private void windowsSettingChange() { EventQueue.invokeLater(new Runnable() { @Override public void run() { ! updateProperties(); } }); } ! private synchronized void updateProperties() { ! if (null == wprops) { ! // wprops has not been initialized, so we have nothing to update return; } ! Map<String, Object> props = wprops.getProperties(); for (String propName : props.keySet()) { Object val = props.get(propName); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("changed " + propName + " to " + val); } setDesktopProperty(propName, val); } } @Override public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) { if (name == null) { // See JavaDoc for the Toolkit.addPropertyChangeListener() method return; --- 934,990 ---- * Called from native toolkit code when WM_SETTINGCHANGE message received * Also called from lazilyLoadDynamicLayoutSupportedProperty because * Windows doesn't always send WM_SETTINGCHANGE when it should. */ private void windowsSettingChange() { + // JDK-8039383: Have to update the value of XPSTYLE_THEME_ACTIVE property + // as soon as possible to prevent NPE and other errors because theme data + // has become unavailable. + final Map<String, Object> props = wprops != null ? wprops.getProperties() : null; + updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE)); + EventQueue.invokeLater(new Runnable() { @Override public void run() { ! updateProperties(props); } }); } ! private synchronized void updateProperties(final Map<String, Object> props) { ! if (null == props) { return; } ! updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE)); ! for (String propName : props.keySet()) { Object val = props.get(propName); if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("changed " + propName + " to " + val); } setDesktopProperty(propName, val); } } + private synchronized void updateProperties() { + if (null == wprops) { + // wprops has not been initialized, so we have nothing to update + return; + } + + updateProperties(wprops.getProperties()); + } + + private void updateXPStyleEnabled(final Object dskProp) { + xpstyleEnabled.set(Boolean.TRUE.equals(dskProp)); + } + + public AtomicBoolean getXPStyleEnabled() { + return xpstyleEnabled; + } + @Override public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) { if (name == null) { // See JavaDoc for the Toolkit.addPropertyChangeListener() method return;