jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 6645 63ea2d282026
child 7762 6e45e1e87347
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 6645
diff changeset
     2
 * Copyright (c) 1996, 2010, 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
package sun.awt.windows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.VolatileImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.awt.RepaintArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.awt.CausedFocusEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.awt.image.SunVolatileImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.awt.image.ToolkitImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.image.ImageProducer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.image.ImageObserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.event.PaintEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.event.InvocationEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.event.KeyEvent;
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
    41
import java.awt.event.FocusEvent;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
    42
import java.awt.event.MouseEvent;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
    43
import java.awt.event.MouseWheelEvent;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
    44
import java.awt.event.InputEvent;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import sun.awt.Win32GraphicsConfig;
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
    46
import sun.awt.Win32GraphicsEnvironment;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import sun.java2d.InvalidPipeException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import sun.java2d.SurfaceData;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    49
import sun.java2d.ScreenUpdateManager;
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
    50
import sun.java2d.d3d.D3DSurfaceData;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import sun.java2d.opengl.OGLSurfaceData;
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
    52
import sun.java2d.pipe.Region;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import sun.awt.DisplayChangedListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import sun.awt.PaintEventDispatcher;
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
    55
import sun.awt.SunToolkit;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import sun.awt.event.IgnorePaintEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import java.awt.dnd.DropTarget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import java.awt.dnd.peer.DropTargetPeer;
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4259
diff changeset
    60
import sun.awt.AWTAccessor;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
    62
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
public abstract class WComponentPeer extends WObjectPeer
2459
08f3416ff334 6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents: 2451
diff changeset
    65
    implements ComponentPeer, DropTargetPeer
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Handle to native window
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    protected volatile long hwnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
    72
    private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WComponentPeer");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
    73
    private static final PlatformLogger shapeLog = PlatformLogger.getLogger("sun.awt.windows.shape.WComponentPeer");
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
    74
    private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.windows.focus.WComponentPeer");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    // ComponentPeer implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    SurfaceData surfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private RepaintArea paintArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    protected Win32GraphicsConfig winGraphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    boolean isLayouting = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    boolean paintPending = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    int     oldWidth = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    int     oldHeight = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private int numBackBuffers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private VolatileImage backBuffer = null;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    89
    private BufferCapabilities backBufferCaps = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    // foreground, background and color are cached to avoid calling back
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    // into the Component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private Color foreground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private Color background;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    private Font font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public native boolean isObscured();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public boolean canDetermineObscurity() { return true; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    // DropTarget support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    int nDropTargets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    long nativeDropTargetContext; // native pointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public synchronized native void pShow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public synchronized native void hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public synchronized native void enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public synchronized native void disable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public long getHWnd() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return hwnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /* New 1.1 API */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public native Point getLocationOnScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /* New 1.1 API */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public void setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        if (b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public void show() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        Dimension s = ((Component)target).getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        oldHeight = s.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        oldWidth = s.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        pShow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /* New 1.1 API */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public void setEnabled(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            enable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            disable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public int serialNum = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    private native void reshapeNoCheck(int x, int y, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /* New 1.1 API */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public void setBounds(int x, int y, int width, int height, int op) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        // Should set paintPending before reahape to prevent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        // thread race between paint events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        // Native components do redraw after resize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        paintPending = (width != oldWidth) || (height != oldHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        if ( (op & NO_EMBEDDED_CHECK) != 0 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            reshapeNoCheck(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            reshape(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        if ((width != oldWidth) || (height != oldHeight)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            // Only recreate surfaceData if this setBounds is called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            // for a resize; a simple move should not trigger a recreation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                replaceSurfaceData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            } catch (InvalidPipeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                // REMIND : what do we do if our surface creation failed?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            oldWidth = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            oldHeight = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        serialNum++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * Called from native code (on Toolkit thread) in order to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * dynamically layout the Container during resizing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    void dynamicallyLayoutContainer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        // If we got the WM_SIZING, this must be a Container, right?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        // In fact, it must be the top-level Container.
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   180
        if (log.isLoggable(PlatformLogger.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            Container parent = WToolkit.getNativeContainer((Component)target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            if (parent != null) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   183
                log.fine("Assertion (parent == null) failed");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        final Container cont = (Container)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        WToolkit.executeOnEventHandlerThread(cont, new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                // Discarding old paint events doesn't seem to be necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                cont.invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                cont.validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
   194
                if (surfaceData instanceof D3DSurfaceData.D3DWindowSurfaceData ||
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   195
                    surfaceData instanceof OGLSurfaceData)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   196
                {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   197
                    // When OGL or D3D is enabled, it is necessary to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    // replace the SurfaceData for each dynamic layout
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   199
                    // request so that the viewport stays in sync
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                    // with the window bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                        replaceSurfaceData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                    } catch (InvalidPipeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                        // REMIND: this is unlikely to occur for OGL, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                        // what do we do if surface creation fails?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                // Forcing a paint here doesn't seem to be necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                // paintDamagedAreaImmediately();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Paints any portion of the component that needs updating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * before the call returns (similar to the Win32 API UpdateWindow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    void paintDamagedAreaImmediately() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        // force Windows to send any pending WM_PAINT events so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        // the damage area is updated on the Java side
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        updateWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        // make sure paint events are transferred to main event queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        // for coalescing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        WToolkit.getWToolkit().flushPendingEvents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        // paint the damaged area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        paintArea.paint(target, shouldClearRectBeforePaint());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    native synchronized void updateWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public void paint(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        ((Component)target).paint(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public void repaint(long tm, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    private static final double BANDING_DIVISOR = 4.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    private native int[] createPrintedPixels(int srcX, int srcY,
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2805
diff changeset
   241
                                             int srcW, int srcH,
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2805
diff changeset
   242
                                             int alpha);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public void print(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        Component comp = (Component)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        // To conserve memory usage, we will band the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        int totalW = comp.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        int totalH = comp.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        int hInc = (int)(totalH / BANDING_DIVISOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if (hInc == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            hInc = totalH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        for (int startY = 0; startY < totalH; startY += hInc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            int endY = startY + hInc - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            if (endY >= totalH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                endY = totalH - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            int h = endY - startY + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2805
diff changeset
   264
            Color bgColor = comp.getBackground();
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2805
diff changeset
   265
            int[] pix = createPrintedPixels(0, startY, totalW, h,
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2805
diff changeset
   266
                                            bgColor == null ? 255 : bgColor.getAlpha());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            if (pix != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                BufferedImage bim = new BufferedImage(totalW, h,
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
   269
                                              BufferedImage.TYPE_INT_ARGB);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                bim.setRGB(0, 0, totalW, h, pix, 0, totalW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                g.drawImage(bim, 0, startY, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                bim.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        comp.print(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public void coalescePaintEvent(PaintEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        Rectangle r = e.getUpdateRect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        if (!(e instanceof IgnorePaintEvent)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            paintArea.add(r, e.getID());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   285
        if (log.isLoggable(PlatformLogger.FINEST)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            switch(e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            case PaintEvent.UPDATE:
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   288
                log.finest("coalescePaintEvent: UPDATE: add: x = " +
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                    r.x + ", y = " + r.y + ", width = " + r.width + ", height = " + r.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            case PaintEvent.PAINT:
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   292
                log.finest("coalescePaintEvent: PAINT: add: x = " +
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    r.x + ", y = " + r.y + ", width = " + r.width + ", height = " + r.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    public synchronized native void reshape(int x, int y, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    // returns true if the event has been handled and shouldn't be propagated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    // though handleEvent method chain - e.g. WTextFieldPeer returns true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    // on handling '\n' to prevent it from being passed to native code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    public boolean handleJavaKeyEvent(KeyEvent e) { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   306
    public void handleJavaMouseEvent(MouseEvent e) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   307
        switch (e.getID()) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   308
          case MouseEvent.MOUSE_PRESSED:
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   309
              // Note that Swing requests focus in its own mouse event handler.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   310
              if (target == e.getSource() &&
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   311
                  !((Component)target).isFocusOwner() &&
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   312
                  WKeyboardFocusManagerPeer.shouldFocusOnClick((Component)target))
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   313
              {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   314
                  WKeyboardFocusManagerPeer.requestFocusFor((Component)target,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   315
                                                            CausedFocusEvent.Cause.MOUSE_EVENT);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   316
              }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   317
              break;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   318
        }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   319
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   320
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    native void nativeHandleEvent(AWTEvent e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    public void handleEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        int id = e.getID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   326
        if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() &&
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   327
            ((Component)target).isEnabled())
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   328
        {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   329
            if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   330
                handleJavaMouseEvent((MouseEvent) e);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   331
            } else if (e instanceof KeyEvent) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   332
                if (handleJavaKeyEvent((KeyEvent)e)) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   333
                    return;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   334
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            case PaintEvent.PAINT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                // Got native painting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                paintPending = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                // Fallthrough to next statement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            case PaintEvent.UPDATE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                // Skip all painting while layouting and all UPDATEs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                // while waiting for native paint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                if (!isLayouting && ! paintPending) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                    paintArea.paint(target,shouldClearRectBeforePaint());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                return;
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   350
            case FocusEvent.FOCUS_LOST:
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   351
            case FocusEvent.FOCUS_GAINED:
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   352
                handleJavaFocusEvent((FocusEvent)e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        // Call the native code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        nativeHandleEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   361
    void handleJavaFocusEvent(FocusEvent fe) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   362
        if (focusLog.isLoggable(PlatformLogger.FINER)) focusLog.finer(fe.toString());
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   363
        setFocus(fe.getID() == FocusEvent.FOCUS_GAINED);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   364
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   365
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   366
    native void setFocus(boolean doSetFocus);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   367
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    public Dimension getMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        return ((Component)target).getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        return getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    // Do nothing for heavyweight implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    public void layout() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        return ((Component)target).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public boolean isFocusable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * Return the GraphicsConfiguration associated with this peer, either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * the locally stored winGraphicsConfig, or that of the target Component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    public GraphicsConfiguration getGraphicsConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        if (winGraphicsConfig != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            return winGraphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            // we don't need a treelock here, since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            // Component.getGraphicsConfiguration() gets it itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            return ((Component)target).getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    public SurfaceData getSurfaceData() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        return surfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * Creates new surfaceData object and invalidates the previous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * surfaceData object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * Replacing the surface data should never lock on any resources which are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * required by other threads which may have them and may require
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * the tree-lock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * This is a degenerate version of replaceSurfaceData(numBackBuffers), so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * just call that version with our current numBackBuffers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    public void replaceSurfaceData() {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   416
        replaceSurfaceData(this.numBackBuffers, this.backBufferCaps);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   419
    public void createScreenSurface(boolean isResize)
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   420
    {
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   421
        Win32GraphicsConfig gc = (Win32GraphicsConfig)getGraphicsConfiguration();
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   422
        ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   423
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   424
        surfaceData = mgr.createScreenSurface(gc, this, numBackBuffers, isResize);
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   425
    }
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   426
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   427
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * Multi-buffer version of replaceSurfaceData.  This version is called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * by createBuffers(), which needs to acquire the same locks in the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * order, but also needs to perform additional functions inside the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * locks.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   434
    public void replaceSurfaceData(int newNumBackBuffers,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   435
                                   BufferCapabilities caps)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   436
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   437
        SurfaceData oldData = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   438
        VolatileImage oldBB = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        synchronized(((Component)target).getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                if (pData == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                numBackBuffers = newNumBackBuffers;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   445
                ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   446
                oldData = surfaceData;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   447
                mgr.dropScreenSurface(oldData);
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   448
                createScreenSurface(true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                if (oldData != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                    oldData.invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   453
                oldBB = backBuffer;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   454
                if (numBackBuffers > 0) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   455
                    // set the caps first, they're used when creating the bb
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   456
                    backBufferCaps = caps;
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   457
                    Win32GraphicsConfig gc =
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   458
                        (Win32GraphicsConfig)getGraphicsConfiguration();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   459
                    backBuffer = gc.createBackBuffer(this);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   460
                } else if (backBuffer != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   461
                    backBufferCaps = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                    backBuffer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   466
        // it would be better to do this before we create new ones,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   467
        // but then we'd run into deadlock issues
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   468
        if (oldData != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   469
            oldData.flush();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   470
            // null out the old data to make it collected faster
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   471
            oldData = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   472
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   473
        if (oldBB != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   474
            oldBB.flush();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   475
            // null out the old data to make it collected faster
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   476
            oldData = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   477
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    public void replaceSurfaceDataLater() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        Runnable r = new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                // Shouldn't do anything if object is disposed in meanwhile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                // No need for sync as disposeAction in Window is performed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                // on EDT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                if (!isDisposed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                        replaceSurfaceData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                    } catch (InvalidPipeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                    // REMIND : what do we do if our surface creation failed?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        // Fix 6255371.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing((Component)target, r)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), r));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
2805
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2648
diff changeset
   501
    public boolean updateGraphicsData(GraphicsConfiguration gc) {
2459
08f3416ff334 6804747: Ensure consistent graphicsConfig member across components hierarchy
anthony
parents: 2451
diff changeset
   502
        winGraphicsConfig = (Win32GraphicsConfig)gc;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            replaceSurfaceData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        } catch (InvalidPipeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            // REMIND : what do we do if our surface creation failed?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        }
2805
9f18d7e66042 6812298: Dynamic GraphicsConfig changes don't work on X11 platforms
anthony
parents: 2648
diff changeset
   508
        return false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    //This will return null for Components not yet added to a Container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    public ColorModel getColorModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        GraphicsConfiguration gc = getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        if (gc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            return gc.getColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    //This will return null for Components not yet added to a Container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    public ColorModel getDeviceColorModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        Win32GraphicsConfig gc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            (Win32GraphicsConfig)getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        if (gc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            return gc.getDeviceColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    //Returns null for Components not yet added to a Container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    public ColorModel getColorModel(int transparency) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
//      return WToolkit.config.getColorModel(transparency);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        GraphicsConfiguration gc = getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        if (gc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            return gc.getColorModel(transparency);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    public java.awt.Toolkit getToolkit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        return Toolkit.getDefaultToolkit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    // fallback default font object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    final static Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    public Graphics getGraphics() {
4258
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   553
        if (isDisposed()) {
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   554
            return null;
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   555
        }
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   556
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   557
        Component target = (Component)getTarget();
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   558
        Window window = SunToolkit.getContainingWindow(target);
6645
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   559
        if (window != null) {
4258
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   560
            Graphics g =
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   561
                ((WWindowPeer)window.getPeer()).getTranslucentGraphics();
6645
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   562
            // getTranslucentGraphics() returns non-null value for non-opaque windows only
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   563
            if (g != null) {
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   564
                // Non-opaque windows do not support heavyweight children.
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   565
                // Redirect all painting to the Window's Graphics instead.
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   566
                // The caller is responsible for calling the
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   567
                // WindowPeer.updateWindow() after painting has finished.
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   568
                int x = 0, y = 0;
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   569
                for (Component c = target; c != window; c = c.getParent()) {
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   570
                    x += c.getX();
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   571
                    y += c.getY();
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   572
                }
4258
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   573
6645
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   574
                g.translate(x, y);
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   575
                g.clipRect(0, 0, target.getWidth(), target.getHeight());
4258
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   576
6645
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   577
                return g;
63ea2d282026 6982279: java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java failed due to NPE
anthony
parents: 5506
diff changeset
   578
            }
4258
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   579
        }
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   580
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        SurfaceData surfaceData = this.surfaceData;
4258
50b23b28d857 6884960: java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java fails
anthony
parents: 3084
diff changeset
   582
        if (surfaceData != null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            /* Fix for bug 4746122. Color and Font shouldn't be null */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            Color bgColor = background;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            if (bgColor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                bgColor = SystemColor.window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            Color fgColor = foreground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            if (fgColor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                fgColor = SystemColor.windowText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            Font font = this.font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            if (font == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                font = defaultFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   596
            ScreenUpdateManager mgr =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   597
                ScreenUpdateManager.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   598
            return mgr.createGraphics(surfaceData, this, fgColor,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   599
                                      bgColor, font);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    public FontMetrics getFontMetrics(Font font) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        return WFontMetrics.getFontMetrics(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    private synchronized native void _dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    protected void disposeImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        SurfaceData oldData = surfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        surfaceData = null;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   611
        ScreenUpdateManager.getInstance().dropScreenSurface(oldData);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        oldData.invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        // remove from updater before calling targetDisposedPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        WToolkit.targetDisposedPeer(target, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        _dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    public synchronized void setForeground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        foreground = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        _setForeground(c.getRGB());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    public synchronized void setBackground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        background = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        _setBackground(c.getRGB());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   628
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   629
     * This method is intentionally not synchronized as it is called while
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   630
     * holding other locks.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   631
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   632
     * @see sun.java2d.d3d.D3DScreenUpdateManager#validate(D3DWindowSurfaceData)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   633
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   634
    public Color getBackgroundNoSync() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   635
        return background;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   636
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   637
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    public native void _setForeground(int rgb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    public native void _setBackground(int rgb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    public synchronized void setFont(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        font = f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        _setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    public synchronized native void _setFont(Font f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    public final void updateCursorImmediately() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        WGlobalCursorManager.getCursorManager().updateCursorImmediately();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   650
    // TODO: consider moving it to KeyboardFocusManagerPeerImpl
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   651
    public boolean requestFocus(Component lightweightChild, boolean temporary,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   652
                                boolean focusedWindowChangeAllowed, long time,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   653
                                CausedFocusEvent.Cause cause)
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   654
    {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   655
        if (WKeyboardFocusManagerPeer.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   656
            processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   657
                                                  focusedWindowChangeAllowed, time))
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   658
        {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        }
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   661
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   662
        int result = WKeyboardFocusManagerPeer
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   663
            .shouldNativelyFocusHeavyweight((Component)target, lightweightChild,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   664
                                            temporary, focusedWindowChangeAllowed,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   665
                                            time, cause);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   666
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   667
        switch (result) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   668
          case WKeyboardFocusManagerPeer.SNFH_FAILURE:
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   669
              return false;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   670
          case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   671
              if (focusLog.isLoggable(PlatformLogger.FINER)) {
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   672
                  focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   673
              }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   674
              Window parentWindow = SunToolkit.getContainingWindow((Component)target);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   675
              if (parentWindow == null) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   676
                  return rejectFocusRequestHelper("WARNING: Parent window is null");
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   677
              }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   678
              WWindowPeer wpeer = (WWindowPeer)parentWindow.getPeer();
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   679
              if (wpeer == null) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   680
                  return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   681
              }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   682
              boolean res = wpeer.requestWindowFocus(cause);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   683
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   684
              if (focusLog.isLoggable(PlatformLogger.FINER)) focusLog.finer("Requested window focus: " + res);
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   685
              // If parent window can be made focused and has been made focused(synchronously)
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   686
              // then we can proceed with children, otherwise we retreat.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   687
              if (!(res && parentWindow.isFocused())) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   688
                  return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   689
              }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   690
              return WKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   691
                                                            (Component)target,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   692
                                                            temporary,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   693
                                                            focusedWindowChangeAllowed,
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   694
                                                            time, cause);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   695
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   696
          case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   697
              // Either lightweight or excessive request - all events are generated.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   698
              return true;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   699
        }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   700
        return false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    }
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   702
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   703
    private boolean rejectFocusRequestHelper(String logMsg) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
   704
        if (focusLog.isLoggable(PlatformLogger.FINER)) focusLog.finer(logMsg);
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   705
        WKeyboardFocusManagerPeer.removeLastFocusRequest((Component)target);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   706
        return false;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   707
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    public Image createImage(ImageProducer producer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        return new ToolkitImage(producer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    public Image createImage(int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        Win32GraphicsConfig gc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            (Win32GraphicsConfig)getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        return gc.createAcceleratedImage((Component)target, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    public VolatileImage createVolatileImage(int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        return new SunVolatileImage((Component)target, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        return getToolkit().prepareImage(img, w, h, o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    public int checkImage(Image img, int w, int h, ImageObserver o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        return getToolkit().checkImage(img, w, h, o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    // Object overrides
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        return getClass().getName() + "[" + target + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    // Toolkit & peer internals
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    private int updateX1, updateY1, updateX2, updateY2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    WComponentPeer(Component target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        this.target = target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        this.paintArea = new RepaintArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        Container parent = WToolkit.getNativeContainer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        WComponentPeer parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        create(parentPeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        // fix for 5088782: check if window object is created successfully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        checkCreation();
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   749
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2808
diff changeset
   750
        createScreenSurface(false);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        initialize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        start();  // Initialize enable/disable state, turn on callbacks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
    abstract void create(WComponentPeer parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    protected void checkCreation()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        if ((hwnd == 0) || (pData == 0))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            if (createError != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                throw createError;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                throw new InternalError("couldn't create component peer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    synchronized native void start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    void initialize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        if (((Component)target).isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            show();  // the wnd starts hidden
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        Color fg = ((Component)target).getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        if (fg != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            setForeground(fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        // Set background color in C++, to avoid inheriting a parent's color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        Font  f = ((Component)target).getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        if (f != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        if (! ((Component)target).isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            disable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        Rectangle r = ((Component)target).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        setBounds(r.x, r.y, r.width, r.height, SET_BOUNDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    // Callbacks for window-system events to the frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    // Invoke a update() method call on the target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    void handleRepaint(int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        // Repaints are posted from updateClient now...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    // Invoke a paint() method call on the target, after clearing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    // damaged area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    void handleExpose(int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        // Bug ID 4081126 & 4129709 - can't do the clearRect() here,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        // since it interferes with the java thread working in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        // same window on multi-processor NT machines.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        postPaintIfNecessary(x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    /* Invoke a paint() method call on the target, without clearing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     * damaged area.  This is normally called by a native control after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     * it has painted itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * NOTE: This is called on the privileged toolkit thread. Do not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     *       call directly into user code using this thread!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     */
2467
6f07b02fe2c0 6774258: api/java_awt/Component/index.html#PaintUpdate fails randomly
dcherepanov
parents: 2464
diff changeset
   817
    public void handlePaint(int x, int y, int w, int h) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        postPaintIfNecessary(x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    private void postPaintIfNecessary(int x, int y, int w, int h) {
4371
dc9dcb8b0ae7 6823138: Need to replace ComponentAccessor with AWTAccessor
dcherepanov
parents: 4259
diff changeset
   822
        if ( !AWTAccessor.getComponentAccessor().getIgnoreRepaint( (Component) target) ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
                createPaintEvent((Component)target, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
            if (event != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                postEvent(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * Post an event. Queue it for execution by the callback thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    void postEvent(AWTEvent event) {
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   835
        preprocessPostEvent(event);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        WToolkit.postEvent(WToolkit.targetToAppContext(target), event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   839
    void preprocessPostEvent(AWTEvent event) {}
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2462
diff changeset
   840
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    // Routines to support deferred window positioning.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    public void beginLayout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        // Skip all painting till endLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        isLayouting = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    public void endLayout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        if(!paintArea.isEmpty() && !paintPending &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            !((Component)target).getIgnoreRepaint()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            // if not waiting for native painting repaint damaged area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            postEvent(new PaintEvent((Component)target, PaintEvent.PAINT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                          new Rectangle()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        isLayouting = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    public native void beginValidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    public native void endValidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     * DEPRECATED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    public Dimension minimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        return getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * DEPRECATED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    public Dimension preferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        return getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * register a DropTarget with this native peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    public synchronized void addDropTarget(DropTarget dt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        if (nDropTargets == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            nativeDropTargetContext = addNativeDropTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        nDropTargets++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * unregister a DropTarget with this native peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    public synchronized void removeDropTarget(DropTarget dt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        nDropTargets--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        if (nDropTargets == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            removeNativeDropTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
            nativeDropTargetContext = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * add the native peer's AwtDropTarget COM object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     * @return reference to AwtDropTarget object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    native long addNativeDropTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * remove the native peer's AwtDropTarget COM object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    native void removeNativeDropTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    native boolean nativeHandlesWheelScrolling();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    public boolean handlesWheelScrolling() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        // should this be cached?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        return nativeHandlesWheelScrolling();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    // Returns true if we are inside begin/endLayout and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    // are waiting for native painting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    public boolean isPaintPending() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        return paintPending && isLayouting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     * The following multibuffering-related methods delegate to our
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     * associated GraphicsConfig (Win or WGL) to handle the appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     * native windowing system specific actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   928
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    public void createBuffers(int numBuffers, BufferCapabilities caps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        throws AWTException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        Win32GraphicsConfig gc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            (Win32GraphicsConfig)getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        gc.assertOperationSupported((Component)target, numBuffers, caps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        // Re-create the primary surface with the new number of back buffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        try {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   938
            replaceSurfaceData(numBuffers - 1, caps);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        } catch (InvalidPipeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
            throw new AWTException(e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   944
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   945
    public void destroyBuffers() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   946
        replaceSurfaceData(0, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   949
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   950
    public void flip(int x1, int y1, int x2, int y2,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   951
                                  BufferCapabilities.FlipContents flipAction)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   952
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   953
        VolatileImage backBuffer = this.backBuffer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        if (backBuffer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
            throw new IllegalStateException("Buffers have not been created");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        Win32GraphicsConfig gc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            (Win32GraphicsConfig)getGraphicsConfiguration();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   959
        gc.flip(this, (Component)target, backBuffer, x1, y1, x2, y2, flipAction);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   962
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    public synchronized Image getBackBuffer() {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   964
        Image backBuffer = this.backBuffer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        if (backBuffer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
            throw new IllegalStateException("Buffers have not been created");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        return backBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   970
    public BufferCapabilities getBackBufferCaps() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   971
        return backBufferCaps;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   972
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   973
    public int getBackBuffersNum() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   974
        return numBackBuffers;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   975
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    /* override and return false on components that DO NOT require
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
       a clearRect() before painting (i.e. native components) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
    public boolean shouldClearRectBeforePaint() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
    native void pSetParent(ComponentPeer newNativeParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * @see java.awt.peer.ComponentPeer#reparent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
    public void reparent(ContainerPeer newNativeParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
        pSetParent(newNativeParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * @see java.awt.peer.ComponentPeer#isReparentSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    public boolean isReparentSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
    public void setBoundsOperation(int operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1002
    /**
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1003
     * Returns whether this component is capable of being hw accelerated.
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1004
     * More specifically, whether rendering to this component or a
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1005
     * BufferStrategy's back-buffer for this component can be hw accelerated.
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1006
     *
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1007
     * Conditions which could prevent hw acceleration include the toplevel
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1008
     * window containing this component being
2648
aa45a227fce3 6802853: API: shaped & translucent windows
anthony
parents: 2467
diff changeset
  1009
     * {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
aa45a227fce3 6802853: API: shaped & translucent windows
anthony
parents: 2467
diff changeset
  1010
     * PERPIXEL_TRANSLUCENT}.
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1011
     *
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1012
     * @return {@code true} if this component is capable of being hw
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1013
     * accelerated, {@code false} otherwise
2648
aa45a227fce3 6802853: API: shaped & translucent windows
anthony
parents: 2467
diff changeset
  1014
     * @see GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1015
     */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1016
    public boolean isAccelCapable() {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1017
        boolean isTranslucent =
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1018
            SunToolkit.isContainingTopLevelTranslucent((Component)target);
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1019
        // D3D/OGL and translucent windows interacted poorly in Windows XP;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1020
        // these problems are no longer present in Vista
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1021
        return !isTranslucent || Win32GraphicsEnvironment.isVistaOS();
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1022
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
    native void setRectangularShape(int lox, int loy, int hix, int hiy,
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1025
                     Region region);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1028
    // REMIND: Temp workaround for issues with using HW acceleration
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1029
    // in the browser on Vista when DWM is enabled.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1030
    // @return true if the toplevel container is not an EmbeddedFrame or
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1031
    // if this EmbeddedFrame is acceleration capable, false otherwise
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1032
    private static final boolean isContainingTopLevelAccelCapable(Component c) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1033
        while (c != null && !(c instanceof WEmbeddedFrame)) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1034
            c = c.getParent();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1035
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1036
        if (c == null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1037
            return true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1038
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1039
        return ((WEmbeddedFramePeer)c.getPeer()).isAccelCapable();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1040
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1041
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1042
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     * Applies the shape to the native component window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     */
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1978
diff changeset
  1046
    public void applyShape(Region shape) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3084
diff changeset
  1047
        if (shapeLog.isLoggable(PlatformLogger.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
            shapeLog.finer(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                    "*** INFO: Setting shape: PEER: " + this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                    + "; TARGET: " + target
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                    + "; SHAPE: " + shape);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
1978
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1954
diff changeset
  1054
        if (shape != null) {
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1954
diff changeset
  1055
            setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1954
diff changeset
  1056
                    (shape.isRectangular() ? null : shape));
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1954
diff changeset
  1057
        } else {
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1954
diff changeset
  1058
            setRectangularShape(0, 0, 0, 0, null);
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 1954
diff changeset
  1059
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
2462
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1062
    /**
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1063
     * Lowers this component at the bottom of the above component. If the above parameter
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1064
     * is null then the method places this component at the top of the Z-order.
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1065
     */
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1066
    public void setZOrder(ComponentPeer above) {
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1067
        long aboveHWND = (above != null) ? ((WComponentPeer)above).getHWnd() : 0;
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1068
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1069
        setZOrder(aboveHWND);
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1070
    }
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1071
192552ca8292 6809227: poor performance on Panel.Add() method in jdk6
dcherepanov
parents: 2459
diff changeset
  1072
    private native void setZOrder(long above);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
}