55 import java.awt.dnd.DragGestureRecognizer; 56 import java.awt.dnd.MouseDragGestureRecognizer; 57 import java.awt.dnd.InvalidDnDOperationException; 58 import java.awt.dnd.peer.DragSourceContextPeer; 59 60 import java.util.Hashtable; 61 import java.util.Locale; 62 import java.util.Map; 63 import java.util.Properties; 64 65 import sun.font.FontManager; 66 import sun.font.FontManagerFactory; 67 import sun.font.SunFontManager; 68 import sun.misc.PerformanceLogger; 69 import sun.util.logging.PlatformLogger; 70 71 public final class WToolkit extends SunToolkit implements Runnable { 72 73 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit"); 74 75 static GraphicsConfiguration config; 76 77 // System clipboard. 78 WClipboard clipboard; 79 80 // cache of font peers 81 private Hashtable<String,FontPeer> cacheFontPeer; 82 83 // Windows properties 84 private WDesktopProperties wprops; 85 86 // Dynamic Layout Resize client code setting 87 protected boolean dynamicLayoutSetting = false; 88 89 //Is it allowed to generate events assigned to extra mouse buttons. 90 //Set to true by default. 91 private static boolean areExtraMouseButtonsEnabled = true; 92 93 /** 94 * Initialize JNI field and method IDs 912 " nativeDynamic == " + nativeDynamic + 913 " wprops.dynamic == " + prop); 914 } 915 916 if ((prop == null) || (nativeDynamic != prop.booleanValue())) { 917 // We missed the WM_SETTINGCHANGE, so we pretend 918 // we just got one - fire the propertyChange, etc. 919 windowsSettingChange(); 920 return nativeDynamic; 921 } 922 923 return prop.booleanValue(); 924 } 925 926 /* 927 * Called from native toolkit code when WM_SETTINGCHANGE message received 928 * Also called from lazilyLoadDynamicLayoutSupportedProperty because 929 * Windows doesn't always send WM_SETTINGCHANGE when it should. 930 */ 931 private void windowsSettingChange() { 932 EventQueue.invokeLater(new Runnable() { 933 @Override 934 public void run() { 935 updateProperties(); 936 } 937 }); 938 } 939 940 private synchronized void updateProperties() { 941 if (null == wprops) { 942 // wprops has not been initialized, so we have nothing to update 943 return; 944 } 945 946 Map<String, Object> props = wprops.getProperties(); 947 for (String propName : props.keySet()) { 948 Object val = props.get(propName); 949 if (log.isLoggable(PlatformLogger.Level.FINER)) { 950 log.finer("changed " + propName + " to " + val); 951 } 952 setDesktopProperty(propName, val); 953 } 954 } 955 956 @Override 957 public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) { 958 if (name == null) { 959 // See JavaDoc for the Toolkit.addPropertyChangeListener() method 960 return; 961 } 962 if ( WDesktopProperties.isWindowsProperty(name) 963 || name.startsWith(awtPrefix) 964 || name.startsWith(dndPrefix)) 965 { 966 // someone is interested in Windows-specific desktop properties 967 // we should initialize wprops 968 lazilyInitWProps(); 969 } 970 super.addPropertyChangeListener(name, pcl); 971 } 972 973 /* | 55 import java.awt.dnd.DragGestureRecognizer; 56 import java.awt.dnd.MouseDragGestureRecognizer; 57 import java.awt.dnd.InvalidDnDOperationException; 58 import java.awt.dnd.peer.DragSourceContextPeer; 59 60 import java.util.Hashtable; 61 import java.util.Locale; 62 import java.util.Map; 63 import java.util.Properties; 64 65 import sun.font.FontManager; 66 import sun.font.FontManagerFactory; 67 import sun.font.SunFontManager; 68 import sun.misc.PerformanceLogger; 69 import sun.util.logging.PlatformLogger; 70 71 public final class WToolkit extends SunToolkit implements Runnable { 72 73 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit"); 74 75 /** 76 * Desktop property which specifies whether XP visual styles are in effect. 77 */ 78 public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive"; 79 80 static GraphicsConfiguration config; 81 82 // System clipboard. 83 WClipboard clipboard; 84 85 // cache of font peers 86 private Hashtable<String,FontPeer> cacheFontPeer; 87 88 // Windows properties 89 private WDesktopProperties wprops; 90 91 // Dynamic Layout Resize client code setting 92 protected boolean dynamicLayoutSetting = false; 93 94 //Is it allowed to generate events assigned to extra mouse buttons. 95 //Set to true by default. 96 private static boolean areExtraMouseButtonsEnabled = true; 97 98 /** 99 * Initialize JNI field and method IDs 917 " nativeDynamic == " + nativeDynamic + 918 " wprops.dynamic == " + prop); 919 } 920 921 if ((prop == null) || (nativeDynamic != prop.booleanValue())) { 922 // We missed the WM_SETTINGCHANGE, so we pretend 923 // we just got one - fire the propertyChange, etc. 924 windowsSettingChange(); 925 return nativeDynamic; 926 } 927 928 return prop.booleanValue(); 929 } 930 931 /* 932 * Called from native toolkit code when WM_SETTINGCHANGE message received 933 * Also called from lazilyLoadDynamicLayoutSupportedProperty because 934 * Windows doesn't always send WM_SETTINGCHANGE when it should. 935 */ 936 private void windowsSettingChange() { 937 // JDK-8039383: Have to update the value of XPSTYLE_THEME_ACTIVE property 938 // as soon as possible to prevent NPE and other errors because theme data 939 // has become unavailable. 940 final Map<String, Object> props = getWProps(); 941 if (props != null) { 942 Object xpstyleOld = getDesktopProperty(XPSTYLE_THEME_ACTIVE); 943 Object xpstyleNew = props.get(XPSTYLE_THEME_ACTIVE); 944 if (xpstyleOld != null && !xpstyleOld.equals(xpstyleNew)) { 945 setDesktopProperty(XPSTYLE_THEME_ACTIVE, xpstyleNew); 946 } 947 948 EventQueue.invokeLater(new Runnable() { 949 @Override 950 public void run() { 951 updateProperties(props); 952 } 953 }); 954 } 955 } 956 957 private synchronized void updateProperties(final Map<String, Object> props) { 958 if (null == props) { 959 return; 960 } 961 962 for (String propName : props.keySet()) { 963 Object val = props.get(propName); 964 if (log.isLoggable(PlatformLogger.Level.FINER)) { 965 log.finer("changed " + propName + " to " + val); 966 } 967 setDesktopProperty(propName, val); 968 } 969 } 970 971 private synchronized void updateProperties() { 972 updateProperties(getWProps()); 973 } 974 975 private synchronized Map<String, Object> getWProps() { 976 return wprops != null ? wprops.getProperties() : null; 977 } 978 979 @Override 980 public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) { 981 if (name == null) { 982 // See JavaDoc for the Toolkit.addPropertyChangeListener() method 983 return; 984 } 985 if ( WDesktopProperties.isWindowsProperty(name) 986 || name.startsWith(awtPrefix) 987 || name.startsWith(dndPrefix)) 988 { 989 // someone is interested in Windows-specific desktop properties 990 // we should initialize wprops 991 lazilyInitWProps(); 992 } 993 super.addPropertyChangeListener(name, pcl); 994 } 995 996 /* |