< prev index next >

src/java.desktop/unix/classes/sun/awt/XSettings.java

Print this page




  27 
  28 import java.awt.Color;
  29 
  30 import java.io.UnsupportedEncodingException;
  31 
  32 import java.util.HashMap;
  33 import java.util.Map;
  34 
  35 
  36 /**
  37  * Per-screen XSETTINGS.
  38  */
  39 public class XSettings {
  40 
  41     /**
  42      */
  43     private long serial = -1;
  44 
  45 
  46     /**
  47      * Update these settings with <code>data</code> obtained from
  48      * XSETTINGS manager.
  49      *
  50      * @param data settings data obtained from
  51      *     <code>_XSETTINGS_SETTINGS</code> window property of the
  52      *     settings manager.
  53      * @return a <code>Map</code> of changed settings.
  54      */
  55     public Map<String, Object> update(byte[] data) {
  56         return (new Update(data)).update();
  57     }
  58 
  59 
  60     /**
  61      * TBS ...
  62      */
  63     class Update {
  64 
  65         /* byte order mark */
  66         private static final int LITTLE_ENDIAN = 0;
  67         private static final int BIG_ENDIAN    = 1;
  68 
  69         /* setting type */
  70         private static final int TYPE_INTEGER = 0;
  71         private static final int TYPE_STRING  = 1;
  72         private static final int TYPE_COLOR   = 2;
  73 
  74         private byte[] data;
  75         private int dlen;
  76         private int idx;
  77         private boolean isLittle;
  78         private long serial = -1;
  79         private int nsettings = 0;
  80         private boolean isValid;
  81 
  82         private HashMap<String, Object> updatedSettings;
  83 
  84 
  85         /**
  86          * Construct an Update object for the data read from
  87          * <code>_XSETTINGS_SETTINGS</code> property of the XSETTINGS
  88          * selection owner.
  89          *
  90          * @param data <code>_XSETTINGS_SETTINGS</code> contents.
  91          */
  92         Update(byte[] data) {
  93             this.data = data;
  94 
  95             dlen = data.length;
  96             if (dlen < 12) {
  97                 // XXX: debug trace?
  98                 return;
  99             }
 100 
 101             // first byte gives endianness of the data
 102             // next 3 bytes are unused (pad to 32 bit)
 103             idx = 0;
 104             isLittle = (getCARD8() == LITTLE_ENDIAN);
 105 
 106             idx = 4;
 107             serial = getCARD32();
 108 
 109             // N_SETTINGS is actually CARD32 (i.e. unsigned), but
 110             // since java doesn't have an unsigned int type, and




  27 
  28 import java.awt.Color;
  29 
  30 import java.io.UnsupportedEncodingException;
  31 
  32 import java.util.HashMap;
  33 import java.util.Map;
  34 
  35 
  36 /**
  37  * Per-screen XSETTINGS.
  38  */
  39 public class XSettings {
  40 
  41     /**
  42      */
  43     private long serial = -1;
  44 
  45 
  46     /**
  47      * Update these settings with {@code data} obtained from
  48      * XSETTINGS manager.
  49      *
  50      * @param data settings data obtained from
  51      *     {@code _XSETTINGS_SETTINGS} window property of the
  52      *     settings manager.
  53      * @return a {@code Map} of changed settings.
  54      */
  55     public Map<String, Object> update(byte[] data) {
  56         return (new Update(data)).update();
  57     }
  58 
  59 
  60     /**
  61      * TBS ...
  62      */
  63     class Update {
  64 
  65         /* byte order mark */
  66         private static final int LITTLE_ENDIAN = 0;
  67         private static final int BIG_ENDIAN    = 1;
  68 
  69         /* setting type */
  70         private static final int TYPE_INTEGER = 0;
  71         private static final int TYPE_STRING  = 1;
  72         private static final int TYPE_COLOR   = 2;
  73 
  74         private byte[] data;
  75         private int dlen;
  76         private int idx;
  77         private boolean isLittle;
  78         private long serial = -1;
  79         private int nsettings = 0;
  80         private boolean isValid;
  81 
  82         private HashMap<String, Object> updatedSettings;
  83 
  84 
  85         /**
  86          * Construct an Update object for the data read from
  87          * {@code _XSETTINGS_SETTINGS} property of the XSETTINGS
  88          * selection owner.
  89          *
  90          * @param data {@code _XSETTINGS_SETTINGS} contents.
  91          */
  92         Update(byte[] data) {
  93             this.data = data;
  94 
  95             dlen = data.length;
  96             if (dlen < 12) {
  97                 // XXX: debug trace?
  98                 return;
  99             }
 100 
 101             // first byte gives endianness of the data
 102             // next 3 bytes are unused (pad to 32 bit)
 103             idx = 0;
 104             isLittle = (getCARD8() == LITTLE_ENDIAN);
 105 
 106             idx = 4;
 107             serial = getCARD32();
 108 
 109             // N_SETTINGS is actually CARD32 (i.e. unsigned), but
 110             // since java doesn't have an unsigned int type, and


< prev index next >