src/solaris/classes/sun/awt/X11/XIconWindow.java

Print this page




  44         super(new XCreateWindowParams(new Object[] {
  45             PARENT, parent,
  46             DELAYED, Boolean.TRUE}));
  47     }
  48 
  49     void instantPreInit(XCreateWindowParams params) {
  50         super.instantPreInit(params);
  51         this.parent = (XDecoratedPeer)params.get(PARENT);
  52     }
  53 
  54     /**
  55      * @return array of XIconsSize structures, caller must free this array after use.
  56      */
  57     private XIconSize[] getIconSizes() {
  58         XToolkit.awtLock();
  59         try {
  60             AwtGraphicsConfigData adata = parent.getGraphicsConfigurationData();
  61             final long screen = adata.get_awt_visInfo().get_screen();
  62             final long display = XToolkit.getDisplay();
  63 
  64             if (log.isLoggable(PlatformLogger.FINEST)) log.finest(adata.toString());


  65 
  66             long status =
  67                 XlibWrapper.XGetIconSizes(display, XToolkit.getDefaultRootWindow(),
  68                                           XlibWrapper.larg1, XlibWrapper.iarg1);
  69             if (status == 0) {
  70                 return null;
  71             }
  72             int count = Native.getInt(XlibWrapper.iarg1);
  73             long sizes_ptr = Native.getLong(XlibWrapper.larg1); // XIconSize*
  74             log.finest("count = {1}, sizes_ptr = {0}", Long.valueOf(sizes_ptr), Integer.valueOf(count));
  75             XIconSize[] res = new XIconSize[count];
  76             for (int i = 0; i < count; i++, sizes_ptr += XIconSize.getSize()) {
  77                 res[i] = new XIconSize(sizes_ptr);
  78                 log.finest("sizes_ptr[{1}] = {0}", res[i], Integer.valueOf(i));
  79             }
  80             return res;
  81         } finally {
  82             XToolkit.awtUnlock();
  83         }
  84     }
  85 
  86     private Dimension calcIconSize(int widthHint, int heightHint) {
  87         if (XWM.getWMID() == XWM.ICE_WM) {
  88             // ICE_WM has a bug - it only displays icons of the size
  89             // 16x16, while reporting 32x32 in its size list
  90             log.finest("Returning ICE_WM icon size: 16x16");
  91             return new Dimension(16, 16);
  92         }
  93 
  94         XIconSize[] sizeList = getIconSizes();

  95         log.finest("Icon sizes: {0}", (Object[]) sizeList);

  96         if (sizeList == null) {
  97             // No icon sizes so we simply fall back to 16x16
  98             return new Dimension(16, 16);
  99         }
 100         boolean found = false;
 101         int dist = 0xffffffff, newDist, diff = 0, closestHeight, closestWidth;
 102         int saveWidth = 0, saveHeight = 0;
 103         for (int i = 0; i < sizeList.length; i++) {
 104             if (widthHint >= sizeList[i].get_min_width() &&
 105                 widthHint <= sizeList[i].get_max_width() &&
 106                 heightHint >= sizeList[i].get_min_height() &&
 107                 heightHint <= sizeList[i].get_max_height()) {
 108                 found = true;
 109                 if ((((widthHint-sizeList[i].get_min_width())
 110                       % sizeList[i].get_width_inc()) == 0) &&
 111                     (((heightHint-sizeList[i].get_min_height())
 112                       % sizeList[i].get_height_inc()) ==0)) {
 113                     /* Found an exact match */
 114                     saveWidth = widthHint;
 115                     saveHeight = heightHint;




  44         super(new XCreateWindowParams(new Object[] {
  45             PARENT, parent,
  46             DELAYED, Boolean.TRUE}));
  47     }
  48 
  49     void instantPreInit(XCreateWindowParams params) {
  50         super.instantPreInit(params);
  51         this.parent = (XDecoratedPeer)params.get(PARENT);
  52     }
  53 
  54     /**
  55      * @return array of XIconsSize structures, caller must free this array after use.
  56      */
  57     private XIconSize[] getIconSizes() {
  58         XToolkit.awtLock();
  59         try {
  60             AwtGraphicsConfigData adata = parent.getGraphicsConfigurationData();
  61             final long screen = adata.get_awt_visInfo().get_screen();
  62             final long display = XToolkit.getDisplay();
  63 
  64             if (log.isLoggable(PlatformLogger.FINEST)) {
  65                 log.finest(adata.toString());
  66             }
  67 
  68             long status =
  69                 XlibWrapper.XGetIconSizes(display, XToolkit.getDefaultRootWindow(),
  70                                           XlibWrapper.larg1, XlibWrapper.iarg1);
  71             if (status == 0) {
  72                 return null;
  73             }
  74             int count = Native.getInt(XlibWrapper.iarg1);
  75             long sizes_ptr = Native.getLong(XlibWrapper.larg1); // XIconSize*
  76             log.finest("count = {1}, sizes_ptr = {0}", Long.valueOf(sizes_ptr), Integer.valueOf(count));
  77             XIconSize[] res = new XIconSize[count];
  78             for (int i = 0; i < count; i++, sizes_ptr += XIconSize.getSize()) {
  79                 res[i] = new XIconSize(sizes_ptr);
  80                 log.finest("sizes_ptr[{1}] = {0}", res[i], Integer.valueOf(i));
  81             }
  82             return res;
  83         } finally {
  84             XToolkit.awtUnlock();
  85         }
  86     }
  87 
  88     private Dimension calcIconSize(int widthHint, int heightHint) {
  89         if (XWM.getWMID() == XWM.ICE_WM) {
  90             // ICE_WM has a bug - it only displays icons of the size
  91             // 16x16, while reporting 32x32 in its size list
  92             log.finest("Returning ICE_WM icon size: 16x16");
  93             return new Dimension(16, 16);
  94         }
  95 
  96         XIconSize[] sizeList = getIconSizes();
  97         if (log.isLoggable(PlatformLogger.FINEST)) {
  98             log.finest("Icon sizes: {0}", (Object[]) sizeList);
  99         }
 100         if (sizeList == null) {
 101             // No icon sizes so we simply fall back to 16x16
 102             return new Dimension(16, 16);
 103         }
 104         boolean found = false;
 105         int dist = 0xffffffff, newDist, diff = 0, closestHeight, closestWidth;
 106         int saveWidth = 0, saveHeight = 0;
 107         for (int i = 0; i < sizeList.length; i++) {
 108             if (widthHint >= sizeList[i].get_min_width() &&
 109                 widthHint <= sizeList[i].get_max_width() &&
 110                 heightHint >= sizeList[i].get_min_height() &&
 111                 heightHint <= sizeList[i].get_max_height()) {
 112                 found = true;
 113                 if ((((widthHint-sizeList[i].get_min_width())
 114                       % sizeList[i].get_width_inc()) == 0) &&
 115                     (((heightHint-sizeList[i].get_min_height())
 116                       % sizeList[i].get_height_inc()) ==0)) {
 117                     /* Found an exact match */
 118                     saveWidth = widthHint;
 119                     saveHeight = heightHint;