jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java
author darcy
Thu, 13 Mar 2014 12:40:27 -0700
changeset 23647 41d22f2dbeb5
parent 22584 eed64ee05369
permissions -rw-r--r--
8033712: Fix more serial lint warnings in sun.awt Reviewed-by: alanb, serb, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 20165
diff changeset
     2
 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4371
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.peer.ComponentPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.lang.ref.WeakReference;
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
    31
import sun.awt.AWTAccessor;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.awt.GlobalCursorManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
public final class XGlobalCursorManager extends GlobalCursorManager {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    // cached nativeContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    private WeakReference<Component> nativeContainer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * The XGlobalCursorManager is a singleton.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static XGlobalCursorManager manager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    static GlobalCursorManager getCursorManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        if (manager == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            manager = new XGlobalCursorManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        return manager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * Should be called in response to a native mouse enter or native mouse
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * button released message. Should not be called during a mouse drag.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static void nativeUpdateCursor(Component heavy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        XGlobalCursorManager.getCursorManager().updateCursorLater(heavy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        if (comp == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        Cursor cur = useCache ? cursor : getCapableCursor(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        Component nc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        if (useCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                nc = nativeContainer.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        } else {
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
    77
           nc = SunToolkit.getHeavyweightComponent(comp);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        if (nc != null) {
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
    81
            ComponentPeer nc_peer = AWTAccessor.getComponentAccessor().getPeer(nc);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            if (nc_peer instanceof XComponentPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                    nativeContainer = new WeakReference<Component>(nc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
8133
c7e4a02e928e 6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents: 5506
diff changeset
    87
                //6431076. A subcomponents (a XTextArea in particular)
c7e4a02e928e 6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents: 5506
diff changeset
    88
                //may want to override the cursor over some of their parts.
c7e4a02e928e 6431076: Cursor gets reset to text cursor in xawt TextArea when autoscrolling on append
dav
parents: 5506
diff changeset
    89
                ((XComponentPeer)nc_peer).pSetCursor(cur, false);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                // in case of grab we do for Swing we need to update keep cursor updated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                // (we don't need this in case of AWT menus).  Window Manager consider
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                // the grabber as a current window and use its cursor.  So we need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                // change cursor on the grabber too.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                updateGrabbedCursor(cur);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Updates cursor on the grabber if it is window peer (i.e. current grab is for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Swing, not for AWT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private static void updateGrabbedCursor(Cursor cur) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        XBaseWindow target = XAwtState.getGrabWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        if (target instanceof XWindowPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            XWindowPeer grabber = (XWindowPeer) target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            grabber.pSetCursor(cur);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    protected void updateCursorOutOfJava() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        // in case we have grabbed input for Swing we need to reset cursor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        // when mouse pointer is out of any java toplevel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // let's use default cursor for this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        updateGrabbedCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    protected void getCursorPos(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        if (!((XToolkit)Toolkit.getDefaultToolkit()).getLastCursorPos(p)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                long display = XToolkit.getDisplay();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                long root_window = XlibWrapper.RootWindow(display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                                                          XlibWrapper.DefaultScreen(display));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                XlibWrapper.XQueryPointer(display, root_window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                                          XlibWrapper.larg1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                          XlibWrapper.larg2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                          XlibWrapper.larg3,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                                          XlibWrapper.larg4,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                                          XlibWrapper.larg5,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                          XlibWrapper.larg6,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                          XlibWrapper.larg7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 20165
diff changeset
   136
                p.x = XlibWrapper.unsafe.getInt(XlibWrapper.larg3);
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 20165
diff changeset
   137
                p.y = XlibWrapper.unsafe.getInt(XlibWrapper.larg4);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    protected  Component findHeavyweightUnderCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        return XAwtState.getComponentMouseEntered();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /*
20165
75e673bbdba6 8007155: [macosx] Disabled panel takes mouse input in JLayeredPane
alexsch
parents: 13604
diff changeset
   148
     * native method to call corresponding methods in Component
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    protected  Point getLocationOnScreen(Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return c.getLocationOnScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    protected Component findHeavyweightUnderCursor(boolean useCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return findHeavyweightUnderCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    private Cursor getCapableCursor(Component comp) {
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   159
        AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   160
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        Component c = comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        while ((c != null) && !(c instanceof Window)
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   163
               && compAccessor.isEnabled(c)
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   164
               && compAccessor.isVisible(c)
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   165
               && compAccessor.isDisplayable(c))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        {
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   167
            c = compAccessor.getParent(c);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        if (c instanceof Window) {
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   170
            return (compAccessor.isEnabled(c)
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   171
                    && compAccessor.isVisible(c)
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   172
                    && compAccessor.isDisplayable(c)
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   173
                    && compAccessor.isEnabled(comp))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                   ?
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   175
                    compAccessor.getCursor(comp)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                   :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        } else if (c == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 439
diff changeset
   181
        return getCapableCursor(compAccessor.getParent(c));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /* This methods needs to be called from within XToolkit.awtLock / XToolkit.awtUnlock section. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    static long getCursor(Cursor c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        long pData = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        int type = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        try {
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 9035
diff changeset
   191
            pData = AWTAccessor.getCursorAccessor().getPData(c);
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 9035
diff changeset
   192
            type = AWTAccessor.getCursorAccessor().getType(c);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        catch (Exception e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        if (pData != 0) return pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        int cursorType = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
          case Cursor.DEFAULT_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   204
              cursorType = XCursorFontConstants.XC_left_ptr;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
          case Cursor.CROSSHAIR_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   207
              cursorType = XCursorFontConstants.XC_crosshair;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
          case Cursor.TEXT_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   210
              cursorType = XCursorFontConstants.XC_xterm;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
          case Cursor.WAIT_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   213
              cursorType = XCursorFontConstants.XC_watch;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
          case Cursor.SW_RESIZE_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   216
              cursorType = XCursorFontConstants.XC_bottom_left_corner;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
          case Cursor.NW_RESIZE_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   219
              cursorType = XCursorFontConstants.XC_top_left_corner;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
          case Cursor.SE_RESIZE_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   222
              cursorType = XCursorFontConstants.XC_bottom_right_corner;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
          case Cursor.NE_RESIZE_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   225
              cursorType = XCursorFontConstants.XC_top_right_corner;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
          case Cursor.S_RESIZE_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   228
              cursorType = XCursorFontConstants.XC_bottom_side;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
          case Cursor.N_RESIZE_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   231
              cursorType = XCursorFontConstants.XC_top_side;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
          case Cursor.W_RESIZE_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   234
              cursorType = XCursorFontConstants.XC_left_side;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
          case Cursor.E_RESIZE_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   237
              cursorType = XCursorFontConstants.XC_right_side;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
          case Cursor.HAND_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   240
              cursorType = XCursorFontConstants.XC_hand2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
          case Cursor.MOVE_CURSOR:
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 2
diff changeset
   243
              cursorType = XCursorFontConstants.XC_fleur;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            pData =(long) XlibWrapper.XCreateFontCursor(XToolkit.getDisplay(), cursorType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        setPData(c,pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    static void setPData(Cursor c, long pData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        try {
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 9035
diff changeset
   262
            AWTAccessor.getCursorAccessor().setPData(c, pData);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        catch (Exception e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
}