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

Print this page




  44 import sun.awt.Win32GraphicsDevice;
  45 import sun.awt.Win32GraphicsEnvironment;
  46 import sun.awt.datatransfer.DataTransferer;
  47 import sun.java2d.d3d.D3DRenderQueue;
  48 import sun.java2d.opengl.OGLRenderQueue;
  49 
  50 import sun.print.PrintJob2D;
  51 
  52 import java.awt.dnd.DragSource;
  53 import java.awt.dnd.DragGestureListener;
  54 import java.awt.dnd.DragGestureEvent;
  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
  95      */
  96     private static native void initIDs();
  97     private static boolean loaded = false;
  98     public static void loadLibraries() {
  99         if (!loaded) {
 100             java.security.AccessController.doPrivileged(
 101                 new java.security.PrivilegedAction<Void>() {
 102                     @Override
 103                     public Void run() {
 104                         System.loadLibrary("awt");
 105                         return null;


 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     /*




  44 import sun.awt.Win32GraphicsDevice;
  45 import sun.awt.Win32GraphicsEnvironment;
  46 import sun.awt.datatransfer.DataTransferer;
  47 import sun.java2d.d3d.D3DRenderQueue;
  48 import sun.java2d.opengl.OGLRenderQueue;
  49 
  50 import sun.print.PrintJob2D;
  51 
  52 import java.awt.dnd.DragSource;
  53 import java.awt.dnd.DragGestureListener;
  54 import java.awt.dnd.DragGestureEvent;
  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 import java.util.concurrent.atomic.AtomicBoolean;
  65 
  66 import sun.font.FontManager;
  67 import sun.font.FontManagerFactory;
  68 import sun.font.SunFontManager;
  69 import sun.misc.PerformanceLogger;
  70 import sun.util.logging.PlatformLogger;
  71 
  72 public final class WToolkit extends SunToolkit implements Runnable {
  73 
  74     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit");
  75 
  76     // Desktop property which specifies whether XP visual styles are in effect
  77     public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive";
  78 
  79     static GraphicsConfiguration config;
  80 
  81     // System clipboard.
  82     WClipboard clipboard;
  83 
  84     // cache of font peers
  85     private Hashtable<String,FontPeer> cacheFontPeer;
  86 
  87     // Windows properties
  88     private WDesktopProperties  wprops;
  89 
  90     // Visual styles enabled?
  91     private final AtomicBoolean xpstyleEnabled = new AtomicBoolean(false);
  92 
  93     // Dynamic Layout Resize client code setting
  94     protected boolean dynamicLayoutSetting = false;
  95 
  96     //Is it allowed to generate events assigned to extra mouse buttons.
  97     //Set to true by default.
  98     private static boolean areExtraMouseButtonsEnabled = true;
  99 
 100     /**
 101      * Initialize JNI field and method IDs
 102      */
 103     private static native void initIDs();
 104     private static boolean loaded = false;
 105     public static void loadLibraries() {
 106         if (!loaded) {
 107             java.security.AccessController.doPrivileged(
 108                 new java.security.PrivilegedAction<Void>() {
 109                     @Override
 110                     public Void run() {
 111                         System.loadLibrary("awt");
 112                         return null;


 919                       "   nativeDynamic == " + nativeDynamic +
 920                       "   wprops.dynamic == " + prop);
 921         }
 922 
 923         if ((prop == null) || (nativeDynamic != prop.booleanValue())) {
 924             // We missed the WM_SETTINGCHANGE, so we pretend
 925             // we just got one - fire the propertyChange, etc.
 926             windowsSettingChange();
 927             return nativeDynamic;
 928         }
 929 
 930         return prop.booleanValue();
 931     }
 932 
 933     /*
 934      * Called from native toolkit code when WM_SETTINGCHANGE message received
 935      * Also called from lazilyLoadDynamicLayoutSupportedProperty because
 936      * Windows doesn't always send WM_SETTINGCHANGE when it should.
 937      */
 938     private void windowsSettingChange() {
 939         // JDK-8039383: Have to update the value of XPSTYLE_THEME_ACTIVE property
 940         // as soon as possible to prevent NPE and other errors because theme data
 941         // has become unavailable.
 942         final Map<String, Object> props = wprops != null ? wprops.getProperties() : null;
 943         updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE));
 944 
 945         EventQueue.invokeLater(new Runnable() {
 946             @Override
 947             public void run() {
 948                 updateProperties(props);
 949             }
 950         });
 951     }
 952 
 953     private synchronized void updateProperties(final Map<String, Object> props) {
 954         if (null == props) {

 955             return;
 956         }
 957 
 958         updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE));
 959 
 960         for (String propName : props.keySet()) {
 961             Object val = props.get(propName);
 962             if (log.isLoggable(PlatformLogger.Level.FINER)) {
 963                 log.finer("changed " + propName + " to " + val);
 964             }
 965             setDesktopProperty(propName, val);
 966         }
 967     }
 968 
 969     private synchronized void updateProperties() {
 970         if (null == wprops) {
 971             // wprops has not been initialized, so we have nothing to update
 972             return;
 973         }
 974 
 975         updateProperties(wprops.getProperties());
 976     }
 977 
 978     private void updateXPStyleEnabled(final Object dskProp) {
 979         xpstyleEnabled.set(Boolean.TRUE.equals(dskProp));
 980     }
 981 
 982     public AtomicBoolean getXPStyleEnabled() {
 983         return xpstyleEnabled;
 984     }
 985 
 986     @Override
 987     public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
 988         if (name == null) {
 989             // See JavaDoc for the Toolkit.addPropertyChangeListener() method
 990             return;
 991         }
 992         if ( WDesktopProperties.isWindowsProperty(name)
 993              || name.startsWith(awtPrefix)
 994              || name.startsWith(dndPrefix))
 995         {
 996             // someone is interested in Windows-specific desktop properties
 997             // we should initialize wprops
 998             lazilyInitWProps();
 999         }
1000         super.addPropertyChangeListener(name, pcl);
1001     }
1002 
1003     /*