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

Print this page


   1 /*
   2  * Copyright (c) 2002, 2008, 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


 664      *         or has different format
 665      */
 666     XAtom[] getAtomListProperty(long window) {
 667         if (atom == 0) {
 668             throw new IllegalStateException("Atom should be initialized");
 669         }
 670         checkWindow(window);
 671 
 672         WindowPropertyGetter getter =
 673             new WindowPropertyGetter(window, this, 0, 0xFFFF,
 674                                      false, XA_ATOM);
 675         try {
 676             int status = getter.execute();
 677             if (status != XConstants.Success || getter.getData() == 0) {
 678                 return emptyList;
 679             }
 680             if (getter.getActualType() != XA_ATOM || getter.getActualFormat() != 32) {
 681                 return emptyList;
 682             }
 683 
 684             int count = (int)getter.getNumberOfItems();
 685             if (count == 0) {
 686                 return emptyList;
 687             }
 688             long list_atoms = getter.getData();
 689             XAtom[] res = new XAtom[count];
 690             for (int index = 0; index < count; index++) {
 691                 res[index] = XAtom.get(XAtom.getAtom(list_atoms+index*getAtomSize()));
 692             }
 693             return res;
 694         } finally {
 695             getter.dispose();
 696         }
 697     }
 698 
 699     /*
 700      * Returns the value of property of type ATOM[]/32 as XAtomList
 701      * @return list of atoms, empty list if the atom list is empty
 702      *         or has different format
 703      */
 704     XAtomList getAtomListPropertyList(long window) {


   1 /*
   2  * Copyright (c) 2002, 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


 664      *         or has different format
 665      */
 666     XAtom[] getAtomListProperty(long window) {
 667         if (atom == 0) {
 668             throw new IllegalStateException("Atom should be initialized");
 669         }
 670         checkWindow(window);
 671 
 672         WindowPropertyGetter getter =
 673             new WindowPropertyGetter(window, this, 0, 0xFFFF,
 674                                      false, XA_ATOM);
 675         try {
 676             int status = getter.execute();
 677             if (status != XConstants.Success || getter.getData() == 0) {
 678                 return emptyList;
 679             }
 680             if (getter.getActualType() != XA_ATOM || getter.getActualFormat() != 32) {
 681                 return emptyList;
 682             }
 683 
 684             int count = getter.getNumberOfItems();
 685             if (count == 0) {
 686                 return emptyList;
 687             }
 688             long list_atoms = getter.getData();
 689             XAtom[] res = new XAtom[count];
 690             for (int index = 0; index < count; index++) {
 691                 res[index] = XAtom.get(XAtom.getAtom(list_atoms+index*getAtomSize()));
 692             }
 693             return res;
 694         } finally {
 695             getter.dispose();
 696         }
 697     }
 698 
 699     /*
 700      * Returns the value of property of type ATOM[]/32 as XAtomList
 701      * @return list of atoms, empty list if the atom list is empty
 702      *         or has different format
 703      */
 704     XAtomList getAtomListPropertyList(long window) {