1 /* |
1 /* |
2 * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
25 |
25 |
26 |
26 |
27 package sun.awt.X11; |
27 package sun.awt.X11; |
28 |
28 |
29 import java.awt.Frame; |
29 import java.awt.Frame; |
|
30 |
|
31 import sun.awt.IconInfo; |
30 import sun.util.logging.PlatformLogger; |
32 import sun.util.logging.PlatformLogger; |
31 |
33 |
32 final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol |
34 final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol |
33 { |
35 { |
34 private final static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XNETProtocol"); |
36 private final static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XNETProtocol"); |
348 return null; |
350 return null; |
349 } |
351 } |
350 } |
352 } |
351 |
353 |
352 /** |
354 /** |
353 * Sets _NET_WM_ICON property on the window using the List of XIconInfo |
355 * Sets _NET_WM_ICON property on the window using the List of IconInfo |
354 * If icons is null or empty list, removes _NET_WM_ICON property |
356 * If icons is null or empty list, removes _NET_WM_ICON property |
355 */ |
357 */ |
356 public void setWMIcons(XWindowPeer window, java.util.List<XIconInfo> icons) { |
358 public void setWMIcons(XWindowPeer window, java.util.List<IconInfo> icons) { |
357 if (window == null) return; |
359 if (window == null) return; |
358 |
360 |
359 XAtom iconsAtom = XAtom.get("_NET_WM_ICON"); |
361 XAtom iconsAtom = XAtom.get("_NET_WM_ICON"); |
360 if (icons == null) { |
362 if (icons == null) { |
361 iconsAtom.DeleteProperty(window); |
363 iconsAtom.DeleteProperty(window); |
362 return; |
364 return; |
363 } |
365 } |
364 |
366 |
365 int length = 0; |
367 int length = 0; |
366 for (XIconInfo ii : icons) { |
368 for (IconInfo ii : icons) { |
367 length += ii.getRawLength(); |
369 length += ii.getRawLength(); |
368 } |
370 } |
369 int cardinalSize = (XlibWrapper.dataModel == 32) ? 4 : 8; |
371 int cardinalSize = (XlibWrapper.dataModel == 32) ? 4 : 8; |
370 int bufferSize = length * cardinalSize; |
372 int bufferSize = length * cardinalSize; |
371 |
373 |
372 if (bufferSize != 0) { |
374 if (bufferSize != 0) { |
373 long buffer = XlibWrapper.unsafe.allocateMemory(bufferSize); |
375 long buffer = XlibWrapper.unsafe.allocateMemory(bufferSize); |
374 try { |
376 try { |
375 long ptr = buffer; |
377 long ptr = buffer; |
376 for (XIconInfo ii : icons) { |
378 for (IconInfo ii : icons) { |
377 int size = ii.getRawLength() * cardinalSize; |
379 int size = ii.getRawLength() * cardinalSize; |
378 if (XlibWrapper.dataModel == 32) { |
380 if (XlibWrapper.dataModel == 32) { |
379 XlibWrapper.copyIntArray(ptr, ii.getIntData(), size); |
381 XlibWrapper.copyIntArray(ptr, ii.getIntData(), size); |
380 } else { |
382 } else { |
381 XlibWrapper.copyLongArray(ptr, ii.getLongData(), size); |
383 XlibWrapper.copyLongArray(ptr, ii.getLongData(), size); |