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

Print this page

        

*** 34,43 **** --- 34,44 ---- import java.awt.datatransfer.Clipboard; import java.awt.TrayIcon; import java.beans.PropertyChangeListener; import java.security.AccessController; import java.security.PrivilegedAction; + import sun.awt.AppContext; import sun.awt.AWTAutoShutdown; import sun.awt.AppContext; import sun.awt.SunToolkit; import sun.misc.ThreadGroupUtils; import sun.awt.Win32GraphicsDevice;
*** 68,77 **** --- 69,81 ---- public 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;
*** 827,837 **** } private synchronized void lazilyInitWProps() { if (wprops == null) { wprops = new WDesktopProperties(this); ! updateProperties(); } } /* * Called from lazilyLoadDesktopProperty because Windows doesn't --- 831,841 ---- } private synchronized void lazilyInitWProps() { if (wprops == null) { wprops = new WDesktopProperties(this); ! updateProperties(wprops.getProperties()); } } /* * Called from lazilyLoadDesktopProperty because Windows doesn't
*** 862,886 **** * 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.FINER)) { log.finer("changed " + propName + " to " + val); } --- 866,910 ---- * 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 = getWProps(); + if (props == null) { + // props has not been initialized, so we have nothing to update + return; + } + + updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE)); + + if (AppContext.getAppContext() == null) { + // We cannot post the update to any EventQueue. Listeners will + // be called on EDTs by DesktopPropertyChangeSupport + updateProperties(props); + } else { + // Cannot update on Toolkit thread. + // DesktopPropertyChangeSupport will call listeners on Toolkit + // thread if it has AppContext (standalone mode) 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.FINER)) { log.finer("changed " + propName + " to " + val); }
*** 1005,1014 **** --- 1029,1046 ---- return areExtraMouseButtonsEnabled; } private native synchronized int getNumberOfButtonsImpl(); + private synchronized Map<String, Object> getWProps() { + return (wprops != null) ? wprops.getProperties() : null; + } + + private void updateXPStyleEnabled(final Object dskProp) { + ThemeReader.xpStyleEnabled = Boolean.TRUE.equals(dskProp); + } + @Override public int getNumberOfButtons(){ if (numberOfButtons == 0) { numberOfButtons = getNumberOfButtonsImpl(); }