jdk/src/solaris/classes/sun/awt/X11/XQueryTree.java
author yan
Mon, 06 Oct 2008 16:45:00 +0400
changeset 1966 12a51fb0db0d
parent 2 90ce3da70b43
child 2802 d05a9dcc8296
permissions -rw-r--r--
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif Summary: Does not work on Motif but works on XToolkit now; implemented using XQueryPointer. Reviewed-by: anthony
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
// This file is an automatically generated file, please do not edit this file, modify the WrapperGenerator.java file instead !
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.misc.Unsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.logging.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
public class XQueryTree {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
        private static Unsafe unsafe = XlibWrapper.unsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    private static final Logger log = Logger.getLogger("sun.awt.X11.XQueryTree");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
        private boolean __executed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        long _w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        long root_ptr = unsafe.allocateMemory(Native.getLongSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        long parent_ptr = unsafe.allocateMemory(Native.getLongSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        long children_ptr = unsafe.allocateMemory(Native.getLongSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        long nchildren_ptr = unsafe.allocateMemory(Native.getIntSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    UnsafeXDisposerRecord disposer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        public XQueryTree(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
                long w  )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                set_w(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
                sun.java2d.Disposer.addRecord(this, disposer = new UnsafeXDisposerRecord("XQueryTree",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                                                                                         new long[]{root_ptr, parent_ptr, nchildren_ptr},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
                                                                                         new long[] {children_ptr}));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
                set_children(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        public int execute() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
                return execute(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        public int execute(XToolkit.XErrorHandler errorHandler) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                    if (isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                        throw new IllegalStateException("Disposed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                        if (__executed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                            throw new IllegalStateException("Already executed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                        __executed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                        if (errorHandler != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                            XToolkit.WITH_XERROR_HANDLER(errorHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                        Native.putLong(children_ptr, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                        int status =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                        XlibWrapper.XQueryTree(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                                get_w(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                                root_ptr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                                parent_ptr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                                children_ptr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                nchildren_ptr                   );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                        if (errorHandler != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                            XToolkit.RESTORE_XERROR_HANDLER();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                        return status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                    XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        public boolean isExecuted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            return __executed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        public boolean isDisposed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            return disposer.disposed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                if (isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                disposer.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        public long get_w() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                if (isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                    throw new IllegalStateException("Disposed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                if (!__executed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                    throw new IllegalStateException("Not executed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                return _w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        public void set_w(long data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                _w = data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        public long get_root() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                if (isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                    throw new IllegalStateException("Disposed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                if (!__executed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    throw new IllegalStateException("Not executed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                return Native.getLong(root_ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        public void set_root(long data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                Native.putLong(root_ptr, data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        public long get_parent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                if (isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    throw new IllegalStateException("Disposed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                if (!__executed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    throw new IllegalStateException("Not executed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                return Native.getLong(parent_ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        public void set_parent(long data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                Native.putLong(parent_ptr, data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        public long get_children() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                if (isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                    throw new IllegalStateException("Disposed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                if (!__executed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                    throw new IllegalStateException("Not executed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                return Native.getLong(children_ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        public void set_children(long data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                Native.putLong(children_ptr, data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        public int get_nchildren() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                if (isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                    throw new IllegalStateException("Disposed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                if (!__executed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                    throw new IllegalStateException("Not executed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                return Native.getInt(nchildren_ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        public void set_nchildren(int data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                Native.putInt(nchildren_ptr, data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
}