28 |
28 |
29 import java.awt.event.ComponentEvent; |
29 import java.awt.event.ComponentEvent; |
30 import java.awt.event.FocusEvent; |
30 import java.awt.event.FocusEvent; |
31 import java.awt.event.WindowEvent; |
31 import java.awt.event.WindowEvent; |
32 |
32 |
33 import java.awt.image.BufferedImage; |
|
34 |
|
35 import java.awt.peer.ComponentPeer; |
33 import java.awt.peer.ComponentPeer; |
36 import java.awt.peer.WindowPeer; |
34 import java.awt.peer.WindowPeer; |
37 |
35 |
38 import java.io.UnsupportedEncodingException; |
36 import java.io.UnsupportedEncodingException; |
39 |
37 |
53 import sun.awt.AWTAccessor; |
51 import sun.awt.AWTAccessor; |
54 import sun.awt.DisplayChangedListener; |
52 import sun.awt.DisplayChangedListener; |
55 import sun.awt.SunToolkit; |
53 import sun.awt.SunToolkit; |
56 import sun.awt.X11GraphicsDevice; |
54 import sun.awt.X11GraphicsDevice; |
57 import sun.awt.X11GraphicsEnvironment; |
55 import sun.awt.X11GraphicsEnvironment; |
|
56 import sun.awt.IconInfo; |
58 |
57 |
59 import sun.java2d.pipe.Region; |
58 import sun.java2d.pipe.Region; |
60 |
59 |
61 class XWindowPeer extends XPanelPeer implements WindowPeer, |
60 class XWindowPeer extends XPanelPeer implements WindowPeer, |
62 DisplayChangedListener { |
61 DisplayChangedListener { |
290 |
289 |
291 public void updateIconImages() { |
290 public void updateIconImages() { |
292 Window target = (Window)this.target; |
291 Window target = (Window)this.target; |
293 java.util.List<Image> iconImages = ((Window)target).getIconImages(); |
292 java.util.List<Image> iconImages = ((Window)target).getIconImages(); |
294 XWindowPeer ownerPeer = getOwnerPeer(); |
293 XWindowPeer ownerPeer = getOwnerPeer(); |
295 winAttr.icons = new ArrayList<XIconInfo>(); |
294 winAttr.icons = new ArrayList<IconInfo>(); |
296 if (iconImages.size() != 0) { |
295 if (iconImages.size() != 0) { |
297 //read icon images from target |
296 //read icon images from target |
298 winAttr.iconsInherited = false; |
297 winAttr.iconsInherited = false; |
299 for (Iterator<Image> i = iconImages.iterator(); i.hasNext(); ) { |
298 for (Iterator<Image> i = iconImages.iterator(); i.hasNext(); ) { |
300 Image image = i.next(); |
299 Image image = i.next(); |
302 if (log.isLoggable(PlatformLogger.FINEST)) { |
301 if (log.isLoggable(PlatformLogger.FINEST)) { |
303 log.finest("XWindowPeer.updateIconImages: Skipping the image passed into Java because it's null."); |
302 log.finest("XWindowPeer.updateIconImages: Skipping the image passed into Java because it's null."); |
304 } |
303 } |
305 continue; |
304 continue; |
306 } |
305 } |
307 XIconInfo iconInfo; |
306 IconInfo iconInfo; |
308 try { |
307 try { |
309 iconInfo = new XIconInfo(image); |
308 iconInfo = new IconInfo(image); |
310 } catch (Exception e){ |
309 } catch (Exception e){ |
311 if (log.isLoggable(PlatformLogger.FINEST)) { |
310 if (log.isLoggable(PlatformLogger.FINEST)) { |
312 log.finest("XWindowPeer.updateIconImages: Perhaps the image passed into Java is broken. Skipping this icon."); |
311 log.finest("XWindowPeer.updateIconImages: Perhaps the image passed into Java is broken. Skipping this icon."); |
313 } |
312 } |
314 continue; |
313 continue; |
342 * image buffer is too large. This function help us accommodate |
341 * image buffer is too large. This function help us accommodate |
343 * initial list of the icon images to certainly-acceptable. |
342 * initial list of the icon images to certainly-acceptable. |
344 * It does scale some of these icons to appropriate size |
343 * It does scale some of these icons to appropriate size |
345 * if it's necessary. |
344 * if it's necessary. |
346 */ |
345 */ |
347 static java.util.List<XIconInfo> normalizeIconImages(java.util.List<XIconInfo> icons) { |
346 static java.util.List<IconInfo> normalizeIconImages(java.util.List<IconInfo> icons) { |
348 java.util.List<XIconInfo> result = new ArrayList<XIconInfo>(); |
347 java.util.List<IconInfo> result = new ArrayList<IconInfo>(); |
349 int totalLength = 0; |
348 int totalLength = 0; |
350 boolean haveLargeIcon = false; |
349 boolean haveLargeIcon = false; |
351 |
350 |
352 for (XIconInfo icon : icons) { |
351 for (IconInfo icon : icons) { |
353 int width = icon.getWidth(); |
352 int width = icon.getWidth(); |
354 int height = icon.getHeight(); |
353 int height = icon.getHeight(); |
355 int length = icon.getRawLength(); |
354 int length = icon.getRawLength(); |
356 |
355 |
357 if (width > PREFERRED_SIZE_FOR_ICON || height > PREFERRED_SIZE_FOR_ICON) { |
356 if (width > PREFERRED_SIZE_FOR_ICON || height > PREFERRED_SIZE_FOR_ICON) { |
388 } |
387 } |
389 |
388 |
390 /* |
389 /* |
391 * Dumps each icon from the list |
390 * Dumps each icon from the list |
392 */ |
391 */ |
393 static void dumpIcons(java.util.List<XIconInfo> icons) { |
392 static void dumpIcons(java.util.List<IconInfo> icons) { |
394 if (iconLog.isLoggable(PlatformLogger.FINEST)) { |
393 if (iconLog.isLoggable(PlatformLogger.FINEST)) { |
395 iconLog.finest(">>> Sizes of icon images:"); |
394 iconLog.finest(">>> Sizes of icon images:"); |
396 for (Iterator<XIconInfo> i = icons.iterator(); i.hasNext(); ) { |
395 for (Iterator<IconInfo> i = icons.iterator(); i.hasNext(); ) { |
397 iconLog.finest(" {0}", i.next()); |
396 iconLog.finest(" {0}", i.next()); |
398 } |
397 } |
399 } |
398 } |
400 } |
399 } |
401 |
400 |
402 public void recursivelySetIcon(java.util.List<XIconInfo> icons) { |
401 public void recursivelySetIcon(java.util.List<IconInfo> icons) { |
403 dumpIcons(winAttr.icons); |
402 dumpIcons(winAttr.icons); |
404 setIconHints(icons); |
403 setIconHints(icons); |
405 Window target = (Window)this.target; |
404 Window target = (Window)this.target; |
406 Window[] children = target.getOwnedWindows(); |
405 Window[] children = target.getOwnedWindows(); |
407 int cnt = children.length; |
406 int cnt = children.length; |
414 } |
413 } |
415 } |
414 } |
416 } |
415 } |
417 } |
416 } |
418 |
417 |
419 java.util.List<XIconInfo> getIconInfo() { |
418 java.util.List<IconInfo> getIconInfo() { |
420 return winAttr.icons; |
419 return winAttr.icons; |
421 } |
420 } |
422 void setIconHints(java.util.List<XIconInfo> icons) { |
421 void setIconHints(java.util.List<IconInfo> icons) { |
423 //This does nothing for XWindowPeer, |
422 //This does nothing for XWindowPeer, |
424 //It's overriden in XDecoratedPeer |
423 //It's overriden in XDecoratedPeer |
425 } |
424 } |
426 |
425 |
427 private static ArrayList<XIconInfo> defaultIconInfo; |
426 private static ArrayList<IconInfo> defaultIconInfo; |
428 protected synchronized static java.util.List<XIconInfo> getDefaultIconInfo() { |
427 protected synchronized static java.util.List<IconInfo> getDefaultIconInfo() { |
429 if (defaultIconInfo == null) { |
428 if (defaultIconInfo == null) { |
430 defaultIconInfo = new ArrayList<XIconInfo>(); |
429 defaultIconInfo = new ArrayList<IconInfo>(); |
431 if (XlibWrapper.dataModel == 32) { |
430 if (XlibWrapper.dataModel == 32) { |
432 defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon16_png.java_icon16_png)); |
431 defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon16_png.java_icon16_png)); |
433 defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon24_png.java_icon24_png)); |
432 defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon24_png.java_icon24_png)); |
434 defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon32_png.java_icon32_png)); |
433 defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon32_png.java_icon32_png)); |
435 defaultIconInfo.add(new XIconInfo(XAWTIcon32_java_icon48_png.java_icon48_png)); |
434 defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon32_java_icon48_png.java_icon48_png)); |
436 } else { |
435 } else { |
437 defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon16_png.java_icon16_png)); |
436 defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon16_png.java_icon16_png)); |
438 defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon24_png.java_icon24_png)); |
437 defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon24_png.java_icon24_png)); |
439 defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon32_png.java_icon32_png)); |
438 defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon32_png.java_icon32_png)); |
440 defaultIconInfo.add(new XIconInfo(XAWTIcon64_java_icon48_png.java_icon48_png)); |
439 defaultIconInfo.add(new IconInfo(sun.awt.AWTIcon64_java_icon48_png.java_icon48_png)); |
441 } |
440 } |
442 } |
441 } |
443 return defaultIconInfo; |
442 return defaultIconInfo; |
444 } |
443 } |
445 |
444 |