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

Print this page




  95     public static void loadLibraries() {
  96         if (!loaded) {
  97             java.security.AccessController.doPrivileged(
  98                 new java.security.PrivilegedAction<Void>() {
  99                     public Void run() {
 100                         System.loadLibrary("awt");
 101                         return null;
 102                     }
 103                 });
 104             loaded = true;
 105         }
 106     }
 107 
 108     private static native String getWindowsVersion();
 109 
 110     static {
 111         loadLibraries();
 112         initIDs();
 113 
 114         // Print out which version of Windows is running
 115         if (log.isLoggable(PlatformLogger.FINE)) {
 116             log.fine("Win version: " + getWindowsVersion());
 117         }
 118 
 119         AccessController.doPrivileged(
 120             new PrivilegedAction <Void> ()
 121         {
 122             public Void run() {
 123                 String browserProp = System.getProperty("browser");
 124                 if (browserProp != null && browserProp.equals("sun.plugin")) {
 125                     disableCustomPalette();
 126                 }
 127                 return null;
 128             }
 129         });
 130     }
 131 
 132     private static native void disableCustomPalette();
 133 
 134     /*
 135      * Reset the static GraphicsConfiguration to the default.  Called on


 831 
 832         return super.lazilyLoadDesktopProperty(name);
 833     }
 834 
 835     private synchronized void lazilyInitWProps() {
 836         if (wprops == null) {
 837             wprops = new WDesktopProperties(this);
 838             updateProperties();
 839         }
 840     }
 841 
 842     /*
 843      * Called from lazilyLoadDesktopProperty because Windows doesn't
 844      * always send WM_SETTINGCHANGE when it should.
 845      */
 846     private synchronized boolean isDynamicLayoutSupported() {
 847         boolean nativeDynamic = isDynamicLayoutSupportedNative();
 848         lazilyInitWProps();
 849         Boolean prop = (Boolean) desktopProperties.get("awt.dynamicLayoutSupported");
 850 
 851         if (log.isLoggable(PlatformLogger.FINER)) {
 852             log.finer("In WTK.isDynamicLayoutSupported()" +
 853                       "   nativeDynamic == " + nativeDynamic +
 854                       "   wprops.dynamic == " + prop);
 855         }
 856 
 857         if ((prop == null) || (nativeDynamic != prop.booleanValue())) {
 858             // We missed the WM_SETTINGCHANGE, so we pretend
 859             // we just got one - fire the propertyChange, etc.
 860             windowsSettingChange();
 861             return nativeDynamic;
 862         }
 863 
 864         return prop.booleanValue();
 865     }
 866 
 867     /*
 868      * Called from native toolkit code when WM_SETTINGCHANGE message received
 869      * Also called from lazilyLoadDynamicLayoutSupportedProperty because
 870      * Windows doesn't always send WM_SETTINGCHANGE when it should.
 871      */
 872     private void windowsSettingChange() {
 873         EventQueue.invokeLater(new Runnable() {
 874             public void run() {
 875                 updateProperties();
 876             }
 877         });
 878     }
 879 
 880     private synchronized void updateProperties() {
 881         if (null == wprops) {
 882             // wprops has not been initialized, so we have nothing to update
 883             return;
 884         }
 885 
 886         Map<String, Object> props = wprops.getProperties();
 887         for (String propName : props.keySet()) {
 888             Object val = props.get(propName);
 889             if (log.isLoggable(PlatformLogger.FINER)) {
 890                 log.finer("changed " + propName + " to " + val);
 891             }
 892             setDesktopProperty(propName, val);
 893         }
 894     }
 895 
 896     public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
 897         if (name == null) {
 898             // See JavaDoc for the Toolkit.addPropertyChangeListener() method
 899             return;
 900         }
 901         if ( WDesktopProperties.isWindowsProperty(name)
 902              || name.startsWith(awtPrefix)
 903              || name.startsWith(dndPrefix))
 904         {
 905             // someone is interested in Windows-specific desktop properties
 906             // we should initialize wprops
 907             lazilyInitWProps();
 908         }
 909         super.addPropertyChangeListener(name, pcl);




  95     public static void loadLibraries() {
  96         if (!loaded) {
  97             java.security.AccessController.doPrivileged(
  98                 new java.security.PrivilegedAction<Void>() {
  99                     public Void run() {
 100                         System.loadLibrary("awt");
 101                         return null;
 102                     }
 103                 });
 104             loaded = true;
 105         }
 106     }
 107 
 108     private static native String getWindowsVersion();
 109 
 110     static {
 111         loadLibraries();
 112         initIDs();
 113 
 114         // Print out which version of Windows is running
 115         if (log.isLoggable(PlatformLogger.Level.FINE)) {
 116             log.fine("Win version: " + getWindowsVersion());
 117         }
 118 
 119         AccessController.doPrivileged(
 120             new PrivilegedAction <Void> ()
 121         {
 122             public Void run() {
 123                 String browserProp = System.getProperty("browser");
 124                 if (browserProp != null && browserProp.equals("sun.plugin")) {
 125                     disableCustomPalette();
 126                 }
 127                 return null;
 128             }
 129         });
 130     }
 131 
 132     private static native void disableCustomPalette();
 133 
 134     /*
 135      * Reset the static GraphicsConfiguration to the default.  Called on


 831 
 832         return super.lazilyLoadDesktopProperty(name);
 833     }
 834 
 835     private synchronized void lazilyInitWProps() {
 836         if (wprops == null) {
 837             wprops = new WDesktopProperties(this);
 838             updateProperties();
 839         }
 840     }
 841 
 842     /*
 843      * Called from lazilyLoadDesktopProperty because Windows doesn't
 844      * always send WM_SETTINGCHANGE when it should.
 845      */
 846     private synchronized boolean isDynamicLayoutSupported() {
 847         boolean nativeDynamic = isDynamicLayoutSupportedNative();
 848         lazilyInitWProps();
 849         Boolean prop = (Boolean) desktopProperties.get("awt.dynamicLayoutSupported");
 850 
 851         if (log.isLoggable(PlatformLogger.Level.FINER)) {
 852             log.finer("In WTK.isDynamicLayoutSupported()" +
 853                       "   nativeDynamic == " + nativeDynamic +
 854                       "   wprops.dynamic == " + prop);
 855         }
 856 
 857         if ((prop == null) || (nativeDynamic != prop.booleanValue())) {
 858             // We missed the WM_SETTINGCHANGE, so we pretend
 859             // we just got one - fire the propertyChange, etc.
 860             windowsSettingChange();
 861             return nativeDynamic;
 862         }
 863 
 864         return prop.booleanValue();
 865     }
 866 
 867     /*
 868      * Called from native toolkit code when WM_SETTINGCHANGE message received
 869      * Also called from lazilyLoadDynamicLayoutSupportedProperty because
 870      * Windows doesn't always send WM_SETTINGCHANGE when it should.
 871      */
 872     private void windowsSettingChange() {
 873         EventQueue.invokeLater(new Runnable() {
 874             public void run() {
 875                 updateProperties();
 876             }
 877         });
 878     }
 879 
 880     private synchronized void updateProperties() {
 881         if (null == wprops) {
 882             // wprops has not been initialized, so we have nothing to update
 883             return;
 884         }
 885 
 886         Map<String, Object> props = wprops.getProperties();
 887         for (String propName : props.keySet()) {
 888             Object val = props.get(propName);
 889             if (log.isLoggable(PlatformLogger.Level.FINER)) {
 890                 log.finer("changed " + propName + " to " + val);
 891             }
 892             setDesktopProperty(propName, val);
 893         }
 894     }
 895 
 896     public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
 897         if (name == null) {
 898             // See JavaDoc for the Toolkit.addPropertyChangeListener() method
 899             return;
 900         }
 901         if ( WDesktopProperties.isWindowsProperty(name)
 902              || name.startsWith(awtPrefix)
 903              || name.startsWith(dndPrefix))
 904         {
 905             // someone is interested in Windows-specific desktop properties
 906             // we should initialize wprops
 907             lazilyInitWProps();
 908         }
 909         super.addPropertyChangeListener(name, pcl);