jdk/src/windows/classes/sun/awt/windows/WToolkit.java
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 7004 3f92ea1ffcac
child 7954 13aa14c7723e
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: 7004
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: 5275
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: 5275
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: 5275
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5275
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5275
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt.windows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.im.InputMethodHighlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.im.spi.InputMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.event.KeyEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.datatransfer.Clipboard;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.TrayIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.awt.AWTAutoShutdown;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.awt.Win32GraphicsDevice;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.awt.Win32GraphicsEnvironment;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    43
import sun.java2d.d3d.D3DRenderQueue;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.java2d.opengl.OGLRenderQueue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.print.PrintJob2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.awt.dnd.DragSource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.awt.dnd.DragGestureListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.awt.dnd.DragGestureEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.awt.dnd.DragGestureRecognizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.awt.dnd.MouseDragGestureRecognizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.awt.dnd.InvalidDnDOperationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.awt.dnd.peer.DragSourceContextPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import java.util.Properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3246
diff changeset
    61
import sun.font.FontManager;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3246
diff changeset
    62
import sun.font.FontManagerFactory;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3246
diff changeset
    63
import sun.font.SunFontManager;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
import sun.misc.PerformanceLogger;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
    65
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
public class WToolkit extends SunToolkit implements Runnable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
    69
    private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    static GraphicsConfiguration config;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // System clipboard.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    WClipboard clipboard;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    // cache of font peers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private Hashtable cacheFontPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    // Windows properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private WDesktopProperties  wprops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    // Dynamic Layout Resize client code setting
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    protected boolean dynamicLayoutSetting = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
    85
    //Is it allowed to generate events assigned to extra mouse buttons.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
    86
    //Set to true by default.
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
    87
    private static boolean areExtraMouseButtonsEnabled = true;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
    88
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Initialize JNI field and method IDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private static boolean loaded = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public static void loadLibraries() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        if (!loaded) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                          new sun.security.action.LoadLibraryAction("awt"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            loaded = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    private static native String getWindowsVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        // Force Win32GE to load if it is not already loaded; this loads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        // various other classes that are required for basic awt functionality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        Win32GraphicsEnvironment.init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        // Print out which version of Windows is running
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   112
        if (log.isLoggable(PlatformLogger.FINE)) {
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   113
            log.fine("Win version: " + getWindowsVersion());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        java.security.AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            new java.security.PrivilegedAction()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                String browserProp = System.getProperty("browser");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                if (browserProp != null && browserProp.equals("sun.plugin")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    disableCustomPalette();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    private static native void disableCustomPalette();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Reset the static GraphicsConfiguration to the default.  Called on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * startup and when display settings have changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public static void resetGC() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            config = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
          config = (GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                  .getLocalGraphicsEnvironment()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
          .getDefaultScreenDevice()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
          .getDefaultConfiguration());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * NOTE: The following embedded*() methods are non-public API intended
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * for internal use only.  The methods are unsupported and could go
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * away in future releases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * New hook functions for using the AWT as an embedded service. These
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * functions replace the global C function AwtInit() which was previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * exported by awt.dll.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * When used as an embedded service, the AWT does NOT have its own
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * message pump. It instead relies on the parent application to provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * this functionality. embeddedInit() assumes that the thread on which it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * is called is the message pumping thread. Violating this assumption
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * will lead to undefined behavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * embeddedInit must be called before the WToolkit() constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * embeddedDispose should be called before the applicaton terminates the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * Java VM. It is currently unsafe to reinitialize the toolkit again
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * after it has been disposed. Instead, awt.dll must be reloaded and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * class loader which loaded WToolkit must be finalized before it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * safe to reuse AWT. Dynamic reusability may be added to the toolkit in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Initializes the Toolkit for use in an embedded environment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @return true if the the initialization succeeded; false if it failed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *         The function will fail if the Toolkit was already initialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public static native boolean embeddedInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Disposes the Toolkit in an embedded environment. This method should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * not be called on exit unless the Toolkit was constructed with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * embeddedInit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @return true if the disposal succeeded; false if it failed. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *         function will fail if the calling thread is not the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *         thread which called embeddedInit(), or if the Toolkit was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *         already disposed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public static native boolean embeddedDispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * To be called after processing the event queue by users of the above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * embeddedInit() function.  The reason for this additional call is that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * there are some operations performed during idle time in the AwtToolkit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * event loop which should also be performed during idle time in any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * other native event loop.  Failure to do so could result in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * deadlocks.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * This method was added at the last minute of the jdk1.4 release
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * to work around a specific customer problem.  As with the above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * embedded*() class, this method is non-public and should not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * used by external applications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * See bug #4526587 for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public native void embeddedEventLoopIdleProcessing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.windows.WDataTransferer";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    static class ToolkitDisposer implements sun.java2d.DisposerRecord {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            WToolkit.postDispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    private final Object anchor = new Object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    private static native void postDispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 5506
diff changeset
   221
    private static native boolean startToolkitThread(Runnable thread);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 5506
diff changeset
   222
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    public WToolkit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        // Startup toolkit threads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        if (PerformanceLogger.loggingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            PerformanceLogger.setTime("WToolkit construction");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        sun.java2d.Disposer.addRecord(anchor, new ToolkitDisposer());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            // Fix for bug #4046430 -- Race condition
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            // where notifyAll can be called before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            // the "AWT-Windows" thread's parent thread is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            // waiting, resulting in a deadlock on startup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
             * Fix for 4701990.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
             * AWTAutoShutdown state must be changed before the toolkit thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
             * starts to avoid race condition.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            AWTAutoShutdown.notifyToolkitThreadBusy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 5506
diff changeset
   244
            if (!startToolkitThread(this)) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 5506
diff changeset
   245
                Thread toolkitThread = new Thread(this, "AWT-Windows");
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 5506
diff changeset
   246
                toolkitThread.setDaemon(true);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 5506
diff changeset
   247
                toolkitThread.start();
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 5506
diff changeset
   248
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                wait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            catch (InterruptedException x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        // Enabled "live resizing" by default.  It remains controlled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        // by the native system though.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        setDynamicLayout(true);
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   261
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   262
        areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   263
        //set system property if not yet assigned
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   264
        System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   265
        setExtraMouseButtonsEnabledNative(areExtraMouseButtonsEnabled);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public void run() {
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 5506
diff changeset
   269
        Thread.currentThread().setPriority(Thread.NORM_PRIORITY+1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        boolean startPump = init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        if (startPump) {
5275
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   273
            AccessController.doPrivileged(new PrivilegedAction() {
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   274
                public Object run() {
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   275
                    ThreadGroup currentTG =
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   276
                        Thread.currentThread().getThreadGroup();
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   277
                    ThreadGroup parentTG = currentTG.getParent();
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   278
                    while (parentTG != null) {
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   279
                        currentTG = parentTG;
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   280
                        parentTG = currentTG.getParent();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                    }
5275
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   282
                    Thread shutdown = new Thread(currentTG, new Runnable() {
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   283
                            public void run() {
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   284
                                shutdown();
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   285
                            }
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   286
                        });
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   287
                    shutdown.setContextClassLoader(null);
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   288
                    Runtime.getRuntime().addShutdownHook(shutdown);
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   289
                    return null;
fa9f5ce2006e 6936389: FontManager.fileCloser may cause memory leak in applets
bae
parents: 4831
diff changeset
   290
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        if (startPump) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            eventLoop(); // will Dispose Toolkit when shutdown hook executes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * eventLoop() begins the native message pump which retrieves and processes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * native events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * When shutdown() is called by the ShutdownHook added in run(), a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * WM_QUIT message is posted to the Toolkit thread indicating that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * eventLoop() should Dispose the toolkit and exit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    private native boolean init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    private native void eventLoop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    private native void shutdown();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Instead of blocking the "AWT-Windows" thread uselessly on a semaphore,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * use these functions. startSecondaryEventLoop() corresponds to wait()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * and quitSecondaryEventLoop() corresponds to notify.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * These functions simulate blocking while allowing the AWT to continue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * processing native events, eliminating a potential deadlock situation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * with SendMessage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * WARNING: startSecondaryEventLoop must only be called from the "AWT-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Windows" thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public static native void startSecondaryEventLoop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    public static native void quitSecondaryEventLoop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * Create peer objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    public ButtonPeer createButton(Button target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        ButtonPeer peer = new WButtonPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    public TextFieldPeer createTextField(TextField target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        TextFieldPeer peer = new WTextFieldPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    public LabelPeer createLabel(Label target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        LabelPeer peer = new WLabelPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    public ListPeer createList(List target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        ListPeer peer = new WListPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    public CheckboxPeer createCheckbox(Checkbox target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        CheckboxPeer peer = new WCheckboxPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public ScrollbarPeer createScrollbar(Scrollbar target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        ScrollbarPeer peer = new WScrollbarPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    public ScrollPanePeer createScrollPane(ScrollPane target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        ScrollPanePeer peer = new WScrollPanePeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    public TextAreaPeer createTextArea(TextArea target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        TextAreaPeer peer = new WTextAreaPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public ChoicePeer createChoice(Choice target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        ChoicePeer peer = new WChoicePeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    public FramePeer  createFrame(Frame target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        FramePeer peer = new WFramePeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    public CanvasPeer createCanvas(Canvas target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        CanvasPeer peer = new WCanvasPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    public void disableBackgroundErase(Canvas canvas) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        WCanvasPeer peer = (WCanvasPeer)canvas.getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        if (peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            throw new IllegalStateException("Canvas must have a valid peer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        peer.disableBackgroundErase();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    public PanelPeer createPanel(Panel target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        PanelPeer peer = new WPanelPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public WindowPeer createWindow(Window target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        WindowPeer peer = new WWindowPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    public DialogPeer createDialog(Dialog target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        DialogPeer peer = new WDialogPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    public FileDialogPeer createFileDialog(FileDialog target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        FileDialogPeer peer = new WFileDialogPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    public MenuBarPeer createMenuBar(MenuBar target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        MenuBarPeer peer = new WMenuBarPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public MenuPeer createMenu(Menu target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        MenuPeer peer = new WMenuPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    public PopupMenuPeer createPopupMenu(PopupMenu target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        PopupMenuPeer peer = new WPopupMenuPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    public MenuItemPeer createMenuItem(MenuItem target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        MenuItemPeer peer = new WMenuItemPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        CheckboxMenuItemPeer peer = new WCheckboxMenuItemPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        // (target is unused for now)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        // Robot's don't need to go in the peer map since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        // they're not Component's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        return new WRobotPeer(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    public WEmbeddedFramePeer createEmbeddedFrame(WEmbeddedFrame target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        WEmbeddedFramePeer peer = new WEmbeddedFramePeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    WPrintDialogPeer createWPrintDialog(WPrintDialog target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        WPrintDialogPeer peer = new WPrintDialogPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    WPageDialogPeer createWPageDialog(WPageDialog target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        WPageDialogPeer peer = new WPageDialogPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    public TrayIconPeer createTrayIcon(TrayIcon target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        WTrayIconPeer peer = new WTrayIconPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        targetCreatedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    public SystemTrayPeer createSystemTray(SystemTray target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        return new WSystemTrayPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    public boolean isTraySupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   501
    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager)
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   502
      throws HeadlessException
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   503
    {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   504
        return new WKeyboardFocusManagerPeer(manager);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   505
    }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 2451
diff changeset
   506
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    protected native void setDynamicLayoutNative(boolean b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    public void setDynamicLayout(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        if (b == dynamicLayoutSetting) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        dynamicLayoutSetting = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        setDynamicLayoutNative(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    protected boolean isDynamicLayoutSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        return dynamicLayoutSetting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * Called from lazilyLoadDynamicLayoutSupportedProperty because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * Windows doesn't always send WM_SETTINGCHANGE when it should.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    protected native boolean isDynamicLayoutSupportedNative();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    public boolean isDynamicLayoutActive() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        return (isDynamicLayoutSet() && isDynamicLayoutSupported());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * Returns <code>true</code> if this frame state is supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    public boolean isFrameStateSupported(int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        switch (state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
          case Frame.NORMAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
          case Frame.ICONIFIED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
          case Frame.MAXIMIZED_BOTH:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
              return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
              return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    static native ColorModel makeColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    static ColorModel screenmodel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    static ColorModel getStaticColorModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        if (config == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            resetGC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        return config.getColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    public ColorModel getColorModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        return getStaticColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    public Insets getScreenInsets(GraphicsConfiguration gc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        return getScreenInsets(((Win32GraphicsDevice) gc.getDevice()).getScreen());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    public int getScreenResolution() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        Win32GraphicsEnvironment ge = (Win32GraphicsEnvironment)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            GraphicsEnvironment.getLocalGraphicsEnvironment();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        return ge.getXResolution();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    protected native int getScreenWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    protected native int getScreenHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    protected native Insets getScreenInsets(int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    public FontMetrics getFontMetrics(Font font) {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3246
diff changeset
   579
        // This is an unsupported hack, but left in for a customer.
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3246
diff changeset
   580
        // Do not remove.
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3246
diff changeset
   581
        FontManager fm = FontManagerFactory.getInstance();
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3246
diff changeset
   582
        if (fm instanceof SunFontManager
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 3246
diff changeset
   583
            && ((SunFontManager) fm).usePlatformFontMetrics()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            return WFontMetrics.getFontMetrics(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        return super.getFontMetrics(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    public FontPeer getFontPeer(String name, int style) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        FontPeer retval = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        String lcName = name.toLowerCase();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        if (null != cacheFontPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            retval = (FontPeer)cacheFontPeer.get(lcName + style);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            if (null != retval) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        retval = new WFontPeer(name, style);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        if (retval != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            if (null == cacheFontPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                cacheFontPeer = new Hashtable(5, (float)0.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            if (null != cacheFontPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                cacheFontPeer.put(lcName + style, retval);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    private native void nativeSync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    public void sync() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        // flush the GDI/DD buffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        nativeSync();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        // now flush the OGL pipeline (this is a no-op if OGL is not enabled)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        OGLRenderQueue.sync();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   617
        // now flush the D3D pipeline (this is a no-op if D3D is not enabled)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   618
        D3DRenderQueue.sync();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    public PrintJob getPrintJob(Frame frame, String doctitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                                Properties props) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        return getPrintJob(frame, doctitle, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    public PrintJob getPrintJob(Frame frame, String doctitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                                JobAttributes jobAttributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                                PageAttributes pageAttributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        if (GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        PrintJob2D printJob = new PrintJob2D(frame, doctitle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                                             jobAttributes, pageAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        if (printJob.printDialog() == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            printJob = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        return printJob;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    public native void beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    public boolean getLockingKeyState(int key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
               key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        return getLockingKeyStateNative(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    public native boolean getLockingKeyStateNative(int key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    public void setLockingKeyState(int key, boolean on) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
               key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            throw new IllegalArgumentException("invalid key for Toolkit.setLockingKeyState");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        setLockingKeyStateNative(key, on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    public native void setLockingKeyStateNative(int key, boolean on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    public Clipboard getSystemClipboard() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        if (security != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
          security.checkSystemClipboardAccess();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            if (clipboard == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                clipboard = new WClipboard();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        return clipboard;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    protected native void loadSystemColors(int[] systemColors);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    public static final Object targetToPeer(Object target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        return SunToolkit.targetToPeer(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    public static final void targetDisposedPeer(Object target, Object peer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        SunToolkit.targetDisposedPeer(target, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * Returns a new input method adapter descriptor for native input methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    public InputMethodDescriptor getInputMethodAdapterDescriptor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        return new WInputMethodDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * Returns a style map for the input method highlight.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        return WInputMethod.mapInputMethodHighlight(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * Returns whether enableInputMethods should be set to true for peered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * TextComponent instances on this platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    public boolean enableInputMethodsForTextComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * Returns the default keyboard locale of the underlying operating system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    public Locale getDefaultKeyboardLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        Locale locale = WInputMethod.getNativeLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        if (locale == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            return super.getDefaultKeyboardLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
            return locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * Returns a new custom cursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        throws IndexOutOfBoundsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        return new WCustomCursor(cursor, hotSpot, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     * Returns the supported cursor size (Win32 only has one).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        return new Dimension(WCustomCursor.getCursorWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                             WCustomCursor.getCursorHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    public native int getMaximumCursorColors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    static void paletteChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        ((Win32GraphicsEnvironment)GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        .getLocalGraphicsEnvironment())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        .paletteChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * Called from Toolkit native code when a WM_DISPLAYCHANGE occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * Have Win32GraphicsEnvironment execute the display change code on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * Event thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    static public void displayChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        EventQueue.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                ((Win32GraphicsEnvironment)GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                .getLocalGraphicsEnvironment())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                .displayChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * create the peer for a DragSourceContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        return WDragSourceContextPeer.createDragSourceContextPeer(dge);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    public <T extends DragGestureRecognizer> T
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        createDragGestureRecognizer(Class<T> abstractRecognizerClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                                    DragSource ds, Component c, int srcActions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                                    DragGestureListener dgl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        if (MouseDragGestureRecognizer.class.equals(abstractRecognizerClass))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            return (T)new WMouseDragGestureRecognizer(ds, c, srcActions, dgl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    private static final String prefix  = "DnD.Cursor.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    private static final String postfix = ".32x32";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    private static final String awtPrefix  = "awt.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    private static final String dndPrefix  = "DnD.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    protected Object lazilyLoadDesktopProperty(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        if (name.startsWith(prefix)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
            String cursorName = name.substring(prefix.length(), name.length()) + postfix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                return Cursor.getSystemCustomCursor(cursorName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            } catch (AWTException awte) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                throw new RuntimeException("cannot load system cursor: " + cursorName, awte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        if (name.equals("awt.dynamicLayoutSupported")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
            return  Boolean.valueOf(isDynamicLayoutSupported());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        if (WDesktopProperties.isWindowsProperty(name) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
            name.startsWith(awtPrefix) || name.startsWith(dndPrefix))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                lazilyInitWProps();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                return desktopProperties.get(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        return super.lazilyLoadDesktopProperty(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    private synchronized void lazilyInitWProps() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        if (wprops == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            wprops = new WDesktopProperties(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            updateProperties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * Called from lazilyLoadDesktopProperty because Windows doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * always send WM_SETTINGCHANGE when it should.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    private synchronized boolean isDynamicLayoutSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        boolean nativeDynamic = isDynamicLayoutSupportedNative();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        lazilyInitWProps();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        Boolean prop = (Boolean) desktopProperties.get("awt.dynamicLayoutSupported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   834
        if (log.isLoggable(PlatformLogger.FINER)) {
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   835
            log.finer("In WTK.isDynamicLayoutSupported()" +
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   836
                      "   nativeDynamic == " + nativeDynamic +
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   837
                      "   wprops.dynamic == " + prop);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        if ((prop == null) || (nativeDynamic != prop.booleanValue())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            // We missed the WM_SETTINGCHANGE, so we pretend
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
            // we just got one - fire the propertyChange, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
            windowsSettingChange();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            return nativeDynamic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        return prop.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     * Called from native toolkit code when WM_SETTINGCHANGE message received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     * Also called from lazilyLoadDynamicLayoutSupportedProperty because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * Windows doesn't always send WM_SETTINGCHANGE when it should.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    private void windowsSettingChange() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        EventQueue.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                updateProperties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    private synchronized void updateProperties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        if (null == wprops) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
            // wprops has not been initialized, so we have nothing to update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        Map<String, Object> props = wprops.getProperties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        for (String propName : props.keySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            Object val = props.get(propName);
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   872
            if (log.isLoggable(PlatformLogger.FINER)) {
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 3928
diff changeset
   873
                log.finer("changed " + propName + " to " + val);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            setDesktopProperty(propName, val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        if ( WDesktopProperties.isWindowsProperty(name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
             || name.startsWith(awtPrefix)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
             || name.startsWith(dndPrefix))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            // someone is interested in Windows-specific desktop properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            // we should initialize wprops
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
            lazilyInitWProps();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        super.addPropertyChangeListener(name, pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * initialize only static props here and do not try to initialize props which depends on wprops,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * this should be done in lazilyLoadDesktopProperty() only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    protected synchronized void initializeDesktopProperties() {
3246
7441718ff264 6857870: Regression tests are failing with ExceptionInInitializerError
dcherepanov
parents: 2810
diff changeset
   896
        desktopProperties.put("DnD.Autoscroll.initialDelay",
7441718ff264 6857870: Regression tests are failing with ExceptionInInitializerError
dcherepanov
parents: 2810
diff changeset
   897
                              Integer.valueOf(50));
7441718ff264 6857870: Regression tests are failing with ExceptionInInitializerError
dcherepanov
parents: 2810
diff changeset
   898
        desktopProperties.put("DnD.Autoscroll.interval",
7441718ff264 6857870: Regression tests are failing with ExceptionInInitializerError
dcherepanov
parents: 2810
diff changeset
   899
                              Integer.valueOf(50));
4831
85d01a4fe115 4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents: 3938
diff changeset
   900
        desktopProperties.put("DnD.isDragImageSupported",
85d01a4fe115 4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents: 3938
diff changeset
   901
                              Boolean.TRUE);
3246
7441718ff264 6857870: Regression tests are failing with ExceptionInInitializerError
dcherepanov
parents: 2810
diff changeset
   902
        desktopProperties.put("Shell.shellFolderManager",
7441718ff264 6857870: Regression tests are failing with ExceptionInInitializerError
dcherepanov
parents: 2810
diff changeset
   903
                              "sun.awt.shell.Win32ShellFolderManager2");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
     * This returns the value for the desktop property "awt.font.desktophints"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
     * This requires that the Windows properties have already been gathered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    protected synchronized RenderingHints getDesktopAAHints() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        if (wprops == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            return wprops.getDesktopAAHints();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        return (modalityType == null) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
               (modalityType == Dialog.ModalityType.MODELESS) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
               (modalityType == Dialog.ModalityType.DOCUMENT_MODAL) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
               (modalityType == Dialog.ModalityType.APPLICATION_MODAL) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
               (modalityType == Dialog.ModalityType.TOOLKIT_MODAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        return (exclusionType == null) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
               (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
               (exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
               (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    public static WToolkit getWToolkit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        WToolkit toolkit = (WToolkit)Toolkit.getDefaultToolkit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        return toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   938
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   939
     * There are two reasons why we don't use buffer per window when
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   940
     * Vista's DWM (aka Aero) is enabled:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   941
     * - since with DWM all windows are already double-buffered, the application
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   942
     *   doesn't get expose events so we don't get to use our true back-buffer,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   943
     *   wasting memory and performance (this is valid for both d3d and gdi
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   944
     *   pipelines)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   945
     * - in some cases with buffer per window enabled it is possible for the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   946
     *   paint manager to redirect rendering to the screen for some operations
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   947
     *   (like copyArea), and since bpw uses its own BufferStrategy the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   948
     *   d3d onscreen rendering support is disabled and rendering goes through
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   949
     *   GDI. This doesn't work well with Vista's DWM since one
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   950
     *   can not perform GDI and D3D operations on the same surface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   951
     *   (see 6630702 for more info)
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
     * Note: even though DWM composition state can change during the lifetime
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   954
     * of the application it is a rare event, and it is more often that it
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   955
     * is temporarily disabled (because of some app) than it is getting
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   956
     * permanently enabled so we can live with this approach without the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   957
     * complexity of dwm state listeners and such. This can be revisited if
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   958
     * proved otherwise.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   959
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   960
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
    public boolean useBufferPerWindow() {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   962
        return !Win32GraphicsEnvironment.isDWMCompositionEnabled();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
    public void grab(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        if (w.getPeer() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
            ((WWindowPeer)w.getPeer()).grab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
    public void ungrab(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        if (w.getPeer() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
           ((WWindowPeer)w.getPeer()).ungrab();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    public native boolean syncNativeQueue(final long timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
    public boolean isDesktopSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
    public DesktopPeer createDesktopPeer(Desktop target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        return new WDesktopPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
1962
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   986
    public static native void setExtraMouseButtonsEnabledNative(boolean enable);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   987
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   988
    public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   989
        return areExtraMouseButtonsEnabled;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents: 888
diff changeset
   990
    }
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
   991
2810
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
   992
    private native synchronized int getNumberOfButtonsImpl();
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
   993
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
   994
    @Override
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
   995
    public int getNumberOfButtons(){
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
   996
        if (numberOfButtons == 0) {
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
   997
            numberOfButtons = getNumberOfButtonsImpl();
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
   998
        }
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
   999
        return (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
  1000
    }
fa49c6a06baf 6799099: All automatic regression tests that create Robot fail on X11
dav
parents: 2464
diff changeset
  1001
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1002
    @Override
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1003
    public boolean isWindowOpacitySupported() {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1004
        // supported in Win2K and later
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1005
        return true;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1006
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1007
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1008
    @Override
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1009
    public boolean isWindowShapingSupported() {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1010
        return true;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1011
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1012
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1013
    @Override
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1014
    public boolean isWindowTranslucencySupported() {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1015
        // supported in Win2K and later
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1016
        return true;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1017
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1018
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1019
    @Override
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1020
    public boolean isTranslucencyCapable(GraphicsConfiguration gc) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1021
        //XXX: worth checking if 8-bit? Anyway, it doesn't hurt.
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1022
        return true;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1023
    }
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1024
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1025
    // On MS Windows one must use the peer.updateWindow() to implement
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1026
    // non-opaque windows.
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1027
    @Override
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1028
    public boolean needUpdateWindow() {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1029
        return true;
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1962
diff changeset
  1030
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
}