jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java
author prr
Sat, 19 Sep 2015 15:45:59 -0700
changeset 32865 f9cb6e427f9e
parent 30918 ee2374d4aae3
child 39850 81332a77764d
permissions -rw-r--r--
8136783: Run blessed-modifier-order script on java.desktop Reviewed-by: martin, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2808
diff changeset
     2
 * Copyright (c) 1996, 2008, 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: 2808
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: 2808
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: 2808
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2808
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2808
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.awt.windows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
abstract class WObjectPeer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
        initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
108
deaaed5cedb7 6592751: EmbeddedFrame disposal is fragile and breaks clean AppContext termination
son
parents: 2
diff changeset
    33
    // The Windows handle for the native widget.
30918
ee2374d4aae3 7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
ssadetsky
parents: 25859
diff changeset
    34
    volatile long pData;
108
deaaed5cedb7 6592751: EmbeddedFrame disposal is fragile and breaks clean AppContext termination
son
parents: 2
diff changeset
    35
    // if the native peer has been destroyed
30918
ee2374d4aae3 7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
ssadetsky
parents: 25859
diff changeset
    36
    volatile boolean destroyed = false;
108
deaaed5cedb7 6592751: EmbeddedFrame disposal is fragile and breaks clean AppContext termination
son
parents: 2
diff changeset
    37
    // The associated AWT object.
deaaed5cedb7 6592751: EmbeddedFrame disposal is fragile and breaks clean AppContext termination
son
parents: 2
diff changeset
    38
    Object target;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    private volatile boolean disposed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    // set from JNI if any errors in creating the peer occur
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    protected Error createError = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 108
diff changeset
    45
    // used to synchronize the state of this peer
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 108
diff changeset
    46
    private final Object stateLock = new Object();
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 108
diff changeset
    47
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    public static WObjectPeer getPeerForTarget(Object t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        WObjectPeer peer = (WObjectPeer) WToolkit.targetToPeer(t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public long getData() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        return pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public Object getTarget() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        return target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 108
diff changeset
    61
    public final Object getStateLock() {
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 108
diff changeset
    62
        return stateLock;
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 108
diff changeset
    63
    }
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 108
diff changeset
    64
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * Subclasses should override disposeImpl() instead of dispose(). Client
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * code should always invoke dispose(), never disposeImpl().
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 30918
diff changeset
    69
    protected abstract void disposeImpl();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public final void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        boolean call_disposeImpl = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            if (!disposed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                disposed = call_disposeImpl = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        if (call_disposeImpl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            disposeImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    protected final boolean isDisposed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        return disposed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Initialize JNI field and method IDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
}