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

Print this page


   1 /*
   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.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 284                     buf[i] = (buf[i] >= num_colors) ?
 285                         0 : cdata.get_awt_icmLUT2Colors(buf[i]);
 286                 }
 287                 bytes = Native.toData(buf);
 288             } else if (srcBuf instanceof DataBufferInt) {
 289                 bytes = Native.toData(((DataBufferInt)srcBuf).getData());
 290             } else if (srcBuf instanceof DataBufferUShort) {
 291                 bytes = Native.toData(((DataBufferUShort)srcBuf).getData());
 292             } else {
 293                 throw new IllegalArgumentException("Unknown data buffer: " + srcBuf);
 294             }
 295             int bpp = awtImage.get_wsImageFormat().get_bits_per_pixel();
 296             int slp =awtImage.get_wsImageFormat().get_scanline_pad();
 297             int bpsl = paddedwidth(iconWidth*bpp, slp) >> 3;
 298             if (((bpsl << 3) / bpp) < iconWidth) {
 299                 log.finest("Image format doesn't fit to icon width");
 300                 return;
 301             }
 302             long dst = XlibWrapper.XCreateImage(XToolkit.getDisplay(),
 303                                                 visInfo.get_visual(),
 304                                                 (int)awtImage.get_Depth(),
 305                                                 (int)XConstants.ZPixmap,
 306                                                 0,
 307                                                 bytes,
 308                                                 iconWidth,
 309                                                 iconHeight,
 310                                                 32,
 311                                                 bpsl);
 312             if (dst == 0) {
 313                 log.finest("Can't create XImage for icon");
 314                 XlibWrapper.XFreePixmap(XToolkit.getDisplay(), iconPixmap);
 315                 iconPixmap = 0;
 316                 return;
 317             } else {
 318                 log.finest("Created XImage for icon");
 319             }
 320             long gc = XlibWrapper.XCreateGC(XToolkit.getDisplay(), iconPixmap, 0, 0);
 321             if (gc == 0) {
 322                 log.finest("Can't create GC for pixmap");
 323                 XlibWrapper.XFreePixmap(XToolkit.getDisplay(), iconPixmap);
 324                 iconPixmap = 0;
 325                 return;


 466                 iconHeight = 0;
 467             }
 468             replaceImage(img);
 469             replaceMask(img);
 470         }
 471         //create icon window and set XWMHints
 472         XToolkit.awtLock();
 473         try {
 474             AwtGraphicsConfigData adata = parent.getGraphicsConfigurationData();
 475             awtImageData awtImage = adata.get_awtImage(0);
 476             XVisualInfo visInfo = adata.get_awt_visInfo();
 477             XWMHints hints = parent.getWMHints();
 478             window = hints.get_icon_window();
 479             if (window == 0) {
 480                 log.finest("Icon window wasn't set");
 481                 XCreateWindowParams params = getDelayedParams();
 482                 params.add(BORDER_PIXEL, Long.valueOf(XToolkit.getAwtDefaultFg()));
 483                 params.add(BACKGROUND_PIXMAP, iconPixmap);
 484                 params.add(COLORMAP, adata.get_awt_cmap());
 485                 params.add(DEPTH, awtImage.get_Depth());
 486                 params.add(VISUAL_CLASS, (int)XConstants.InputOutput);
 487                 params.add(VISUAL, visInfo.get_visual());
 488                 params.add(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWColormap | XConstants.CWBackPixmap);
 489                 params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), visInfo.get_screen()));
 490                 params.add(BOUNDS, new Rectangle(0, 0, iconWidth, iconHeight));
 491                 params.remove(DELAYED);
 492                 init(params);
 493                 if (getWindow() == 0) {
 494                     log.finest("Can't create new icon window");
 495                 } else {
 496                     log.finest("Created new icon window");
 497                 }
 498             }
 499             if (getWindow() != 0) {
 500                 XlibWrapper.XSetWindowBackgroundPixmap(XToolkit.getDisplay(), getWindow(), iconPixmap);
 501                 XlibWrapper.XClearWindow(XToolkit.getDisplay(), getWindow());
 502             }
 503             // Provide both pixmap and window, WM or Taskbar will use the one they find more appropriate
 504             long newFlags = hints.get_flags() | XUtilConstants.IconPixmapHint | XUtilConstants.IconMaskHint;
 505             if (getWindow()  != 0) {
 506                 newFlags |= XUtilConstants.IconWindowHint;
   1 /*
   2  * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 284                     buf[i] = (buf[i] >= num_colors) ?
 285                         0 : cdata.get_awt_icmLUT2Colors(buf[i]);
 286                 }
 287                 bytes = Native.toData(buf);
 288             } else if (srcBuf instanceof DataBufferInt) {
 289                 bytes = Native.toData(((DataBufferInt)srcBuf).getData());
 290             } else if (srcBuf instanceof DataBufferUShort) {
 291                 bytes = Native.toData(((DataBufferUShort)srcBuf).getData());
 292             } else {
 293                 throw new IllegalArgumentException("Unknown data buffer: " + srcBuf);
 294             }
 295             int bpp = awtImage.get_wsImageFormat().get_bits_per_pixel();
 296             int slp =awtImage.get_wsImageFormat().get_scanline_pad();
 297             int bpsl = paddedwidth(iconWidth*bpp, slp) >> 3;
 298             if (((bpsl << 3) / bpp) < iconWidth) {
 299                 log.finest("Image format doesn't fit to icon width");
 300                 return;
 301             }
 302             long dst = XlibWrapper.XCreateImage(XToolkit.getDisplay(),
 303                                                 visInfo.get_visual(),
 304                                                 awtImage.get_Depth(),
 305                                                 XConstants.ZPixmap,
 306                                                 0,
 307                                                 bytes,
 308                                                 iconWidth,
 309                                                 iconHeight,
 310                                                 32,
 311                                                 bpsl);
 312             if (dst == 0) {
 313                 log.finest("Can't create XImage for icon");
 314                 XlibWrapper.XFreePixmap(XToolkit.getDisplay(), iconPixmap);
 315                 iconPixmap = 0;
 316                 return;
 317             } else {
 318                 log.finest("Created XImage for icon");
 319             }
 320             long gc = XlibWrapper.XCreateGC(XToolkit.getDisplay(), iconPixmap, 0, 0);
 321             if (gc == 0) {
 322                 log.finest("Can't create GC for pixmap");
 323                 XlibWrapper.XFreePixmap(XToolkit.getDisplay(), iconPixmap);
 324                 iconPixmap = 0;
 325                 return;


 466                 iconHeight = 0;
 467             }
 468             replaceImage(img);
 469             replaceMask(img);
 470         }
 471         //create icon window and set XWMHints
 472         XToolkit.awtLock();
 473         try {
 474             AwtGraphicsConfigData adata = parent.getGraphicsConfigurationData();
 475             awtImageData awtImage = adata.get_awtImage(0);
 476             XVisualInfo visInfo = adata.get_awt_visInfo();
 477             XWMHints hints = parent.getWMHints();
 478             window = hints.get_icon_window();
 479             if (window == 0) {
 480                 log.finest("Icon window wasn't set");
 481                 XCreateWindowParams params = getDelayedParams();
 482                 params.add(BORDER_PIXEL, Long.valueOf(XToolkit.getAwtDefaultFg()));
 483                 params.add(BACKGROUND_PIXMAP, iconPixmap);
 484                 params.add(COLORMAP, adata.get_awt_cmap());
 485                 params.add(DEPTH, awtImage.get_Depth());
 486                 params.add(VISUAL_CLASS, XConstants.InputOutput);
 487                 params.add(VISUAL, visInfo.get_visual());
 488                 params.add(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWColormap | XConstants.CWBackPixmap);
 489                 params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), visInfo.get_screen()));
 490                 params.add(BOUNDS, new Rectangle(0, 0, iconWidth, iconHeight));
 491                 params.remove(DELAYED);
 492                 init(params);
 493                 if (getWindow() == 0) {
 494                     log.finest("Can't create new icon window");
 495                 } else {
 496                     log.finest("Created new icon window");
 497                 }
 498             }
 499             if (getWindow() != 0) {
 500                 XlibWrapper.XSetWindowBackgroundPixmap(XToolkit.getDisplay(), getWindow(), iconPixmap);
 501                 XlibWrapper.XClearWindow(XToolkit.getDisplay(), getWindow());
 502             }
 503             // Provide both pixmap and window, WM or Taskbar will use the one they find more appropriate
 504             long newFlags = hints.get_flags() | XUtilConstants.IconPixmapHint | XUtilConstants.IconMaskHint;
 505             if (getWindow()  != 0) {
 506                 newFlags |= XUtilConstants.IconWindowHint;