jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java
author prr
Sat, 19 Sep 2015 15:45:59 -0700
changeset 32865 f9cb6e427f9e
parent 31653 d88ff422c7fb
child 36903 addc2e9d4bd4
permissions -rw-r--r--
8136783: Run blessed-modifier-order script on java.desktop Reviewed-by: martin, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     1
/*
30924
c8765f1fea21 8035568: [macosx] Cursor management unification
pchelko
parents: 29922
diff changeset
     2
 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     4
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    10
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    15
 * accompanied this code).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    16
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    20
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    23
 * questions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    24
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    25
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    26
package sun.lwawt;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    27
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    28
import java.awt.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    29
import java.awt.List;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    30
import java.awt.datatransfer.*;
24551
cccf7dd14729 8042219: [macosx] LWComponentPeer should not reference classes from sun.lwawt.macosx
pchelko
parents: 24520
diff changeset
    31
import java.awt.dnd.DropTarget;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    32
import java.awt.image.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    33
import java.awt.peer.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    34
import java.security.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    35
import java.util.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    36
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    37
import sun.awt.*;
31653
d88ff422c7fb 8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
serb
parents: 30924
diff changeset
    38
import sun.misc.ManagedLocalsThread;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    39
import sun.print.*;
24520
e8afd90fcb69 8035169: Move ThreadGroupUtils from the sun.misc package
pchelko
parents: 23900
diff changeset
    40
import sun.awt.util.ThreadGroupUtils;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
    42
import static sun.lwawt.LWWindowPeer.PeerType;
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
    43
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    44
public abstract class LWToolkit extends SunToolkit implements Runnable {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    45
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 31653
diff changeset
    46
    private static final int STATE_NONE = 0;
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 31653
diff changeset
    47
    private static final int STATE_INIT = 1;
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 31653
diff changeset
    48
    private static final int STATE_MESSAGELOOP = 2;
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 31653
diff changeset
    49
    private static final int STATE_SHUTDOWN = 3;
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 31653
diff changeset
    50
    private static final int STATE_CLEANUP = 4;
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 31653
diff changeset
    51
    private static final int STATE_DONE = 5;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    52
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    53
    private int runState = STATE_NONE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    54
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    55
    private Clipboard clipboard;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    56
    private MouseInfoPeer mouseInfoPeer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    57
17410
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    58
    /**
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    59
     * Dynamic Layout Resize client code setting.
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    60
     */
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    61
    private volatile boolean dynamicLayoutSetting = true;
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    62
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    63
    protected LWToolkit() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    64
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    65
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    66
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    67
     * This method is called by subclasses to start this toolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    68
     * by launching the message loop.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    69
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    70
     * This method waits for the toolkit to be completely initialized
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    71
     * and returns before the message pump is started.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    72
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    73
    protected final void init() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    74
        AWTAutoShutdown.notifyToolkitThreadBusy();
29922
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    75
        AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    76
            Runnable shutdownRunnable = () -> {
23900
fd98305f0d19 8031477: [macosx] Loading AWT native library fails
pchelko
parents: 23276
diff changeset
    77
                shutdown();
fd98305f0d19 8031477: [macosx] Loading AWT native library fails
pchelko
parents: 23276
diff changeset
    78
                waitForRunState(STATE_CLEANUP);
29922
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    79
            };
31653
d88ff422c7fb 8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
serb
parents: 30924
diff changeset
    80
            Thread shutdown = new ManagedLocalsThread(
d88ff422c7fb 8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
serb
parents: 30924
diff changeset
    81
                    ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
29922
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    82
            shutdown.setContextClassLoader(null);
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    83
            Runtime.getRuntime().addShutdownHook(shutdown);
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    84
            String name = "AWT-LW";
31653
d88ff422c7fb 8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
serb
parents: 30924
diff changeset
    85
            Thread toolkitThread = new ManagedLocalsThread(
d88ff422c7fb 8080405: Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
serb
parents: 30924
diff changeset
    86
                    ThreadGroupUtils.getRootThreadGroup(), this, name);
29922
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    87
            toolkitThread.setDaemon(true);
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    88
            toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    89
            toolkitThread.start();
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    90
            return null;
7b9c1e1532cf 8027771: Enhance thread contexts
serb
parents: 25859
diff changeset
    91
        });
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    92
        waitForRunState(STATE_MESSAGELOOP);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    93
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    94
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    95
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    96
     * Implemented in subclasses to initialize platform-dependent
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    97
     * part of the toolkit (open X display connection, create
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    98
     * toolkit HWND, etc.)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    99
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   100
     * This method is called on the toolkit thread.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   101
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   102
    protected abstract void platformInit();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   103
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   104
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   105
     * Sends a request to stop the message pump.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   106
     */
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   107
    public final void shutdown() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   108
        setRunState(STATE_SHUTDOWN);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   109
        platformShutdown();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   110
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   111
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   112
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   113
     * Implemented in subclasses to release all the platform-
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   114
     * dependent resources. Called after the message loop is
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   115
     * terminated.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   116
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   117
     * Could be called (always called?) on a non-toolkit thread.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   118
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   119
    protected abstract void platformShutdown();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   120
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   121
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   122
     * Implemented in subclasses to release all the platform
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   123
     * resources before the application is terminated.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   124
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   125
     * This method is called on the toolkit thread.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   126
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   127
    protected abstract void platformCleanup();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   128
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   129
    private synchronized int getRunState() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   130
        return runState;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   131
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   132
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   133
    private synchronized void setRunState(int state) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   134
        runState = state;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   135
        notifyAll();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   136
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   137
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   138
    public final boolean isTerminating() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   139
        return getRunState() >= STATE_SHUTDOWN;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   140
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   141
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   142
    private void waitForRunState(int state) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   143
        while (getRunState() < state) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   144
            try {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   145
                synchronized (this) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   146
                    wait();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   147
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   148
            } catch (InterruptedException z) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   149
                // TODO: log
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   150
                break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   151
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   152
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   153
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   154
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   155
    @Override
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   156
    public final void run() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   157
        setRunState(STATE_INIT);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   158
        platformInit();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   159
        AWTAutoShutdown.notifyToolkitThreadFree();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   160
        setRunState(STATE_MESSAGELOOP);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   161
        while (getRunState() < STATE_SHUTDOWN) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   162
            try {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   163
                platformRunMessage();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   164
                if (Thread.currentThread().isInterrupted()) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   165
                    if (AppContext.getAppContext().isDisposed()) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   166
                        break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   167
                    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   168
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   169
            } catch (ThreadDeath td) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   170
                //XXX: if there isn't native code on the stack, the VM just
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   171
                //kills the thread right away. Do we expect to catch it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   172
                //nevertheless?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   173
                break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   174
            } catch (Throwable t) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   175
                // TODO: log
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   176
                System.err.println("Exception on the toolkit thread");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   177
                t.printStackTrace(System.err);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   178
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   179
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   180
        //XXX: if that's a secondary loop, jump back to the STATE_MESSAGELOOP
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   181
        setRunState(STATE_CLEANUP);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   182
        AWTAutoShutdown.notifyToolkitThreadFree();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   183
        platformCleanup();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   184
        setRunState(STATE_DONE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   185
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   186
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   187
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   188
     * Process the next message(s) from the native event queue.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   189
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   190
     * Initially, all the LWToolkit implementations were supposed
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   191
     * to have the similar message loop sequence: check if any events
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   192
     * available, peek events, wait. However, the later analysis shown
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   193
     * that X11 and Windows implementations are really different, so
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   194
     * let the subclasses do whatever they require.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   195
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   196
    protected abstract void platformRunMessage();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   197
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   198
    public static LWToolkit getLWToolkit() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   199
        return (LWToolkit)Toolkit.getDefaultToolkit();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   200
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   201
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   202
    // ---- TOPLEVEL PEERS ---- //
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   203
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   204
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   205
     * Note that LWWindowPeer implements WindowPeer, FramePeer
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   206
     * and DialogPeer interfaces.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   207
     */
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   208
    protected LWWindowPeer createDelegatedPeer(Window target,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   209
                                               PlatformComponent platformComponent,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   210
                                               PlatformWindow platformWindow,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   211
                                               PeerType peerType) {
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 13993
diff changeset
   212
        LWWindowPeer peer = new LWWindowPeer(target, platformComponent, platformWindow, peerType);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   213
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   214
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   215
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   216
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   217
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   218
    @Override
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   219
    public final FramePeer createLightweightFrame(LightweightFrame target) {
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   220
        PlatformComponent platformComponent = createLwPlatformComponent();
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   221
        PlatformWindow platformWindow = createPlatformWindow(PeerType.LW_FRAME);
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   222
        LWLightweightFramePeer peer = new LWLightweightFramePeer(target,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   223
                                                                 platformComponent,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   224
                                                                 platformWindow);
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   225
        targetCreatedPeer(target, peer);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   226
        peer.initialize();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   227
        return peer;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   228
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   229
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   230
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   231
    public final WindowPeer createWindow(Window target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   232
        PlatformComponent platformComponent = createPlatformComponent();
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   233
        PlatformWindow platformWindow = createPlatformWindow(PeerType.SIMPLEWINDOW);
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   234
        return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.SIMPLEWINDOW);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   235
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   236
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   237
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   238
    public final FramePeer createFrame(Frame target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   239
        PlatformComponent platformComponent = createPlatformComponent();
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   240
        PlatformWindow platformWindow = createPlatformWindow(PeerType.FRAME);
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   241
        return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.FRAME);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   242
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   243
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   244
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   245
    public DialogPeer createDialog(Dialog target) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   246
        PlatformComponent platformComponent = createPlatformComponent();
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   247
        PlatformWindow platformWindow = createPlatformWindow(PeerType.DIALOG);
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   248
        return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.DIALOG);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   249
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   250
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   251
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   252
    public final FileDialogPeer createFileDialog(FileDialog target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   253
        FileDialogPeer peer = createFileDialogPeer(target);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   254
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   255
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   256
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   257
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   258
    // ---- LIGHTWEIGHT COMPONENT PEERS ---- //
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   259
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   260
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   261
    public final ButtonPeer createButton(Button target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   262
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   263
        LWButtonPeer peer = new LWButtonPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   264
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   265
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   266
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   267
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   268
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   269
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   270
    public final CheckboxPeer createCheckbox(Checkbox target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   271
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   272
        LWCheckboxPeer peer = new LWCheckboxPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   273
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   274
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   275
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   276
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   277
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   278
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   279
    public final ChoicePeer createChoice(Choice target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   280
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   281
        LWChoicePeer peer = new LWChoicePeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   282
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   283
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   284
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   285
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   286
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   287
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   288
    public final LabelPeer createLabel(Label target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   289
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   290
        LWLabelPeer peer = new LWLabelPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   291
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   292
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   293
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   294
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   295
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   296
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   297
    public final CanvasPeer createCanvas(Canvas target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   298
        PlatformComponent platformComponent = createPlatformComponent();
13993
8b3fe3d8badb 7160627: [macosx] TextArea has wrong initial size
serb
parents: 13648
diff changeset
   299
        LWCanvasPeer<?, ?> peer = new LWCanvasPeer<>(target, platformComponent);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   300
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   301
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   302
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   303
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   304
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   305
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   306
    public final ListPeer createList(List target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   307
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   308
        LWListPeer peer = new LWListPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   309
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   310
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   311
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   312
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   313
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   314
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   315
    public final PanelPeer createPanel(Panel target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   316
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   317
        LWPanelPeer peer = new LWPanelPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   318
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   319
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   320
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   321
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   322
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   323
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   324
    public final ScrollPanePeer createScrollPane(ScrollPane target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   325
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   326
        LWScrollPanePeer peer = new LWScrollPanePeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   327
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   328
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   329
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   330
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   331
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   332
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   333
    public final ScrollbarPeer createScrollbar(Scrollbar target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   334
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   335
        LWScrollBarPeer peer = new LWScrollBarPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   336
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   337
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   338
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   339
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   340
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   341
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   342
    public final TextAreaPeer createTextArea(TextArea target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   343
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   344
        LWTextAreaPeer peer = new LWTextAreaPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   345
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   346
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   347
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   348
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   349
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   350
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   351
    public final TextFieldPeer createTextField(TextField target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   352
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   353
        LWTextFieldPeer peer = new LWTextFieldPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   354
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   355
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   356
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   357
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   358
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   359
    // ---- NON-COMPONENT PEERS ---- //
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   360
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   361
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   362
    public final ColorModel getColorModel() throws HeadlessException {
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   363
        return GraphicsEnvironment.getLocalGraphicsEnvironment()
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   364
                                  .getDefaultScreenDevice()
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   365
                                  .getDefaultConfiguration().getColorModel();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   366
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   367
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   368
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   369
    public final boolean isDesktopSupported() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   370
        return true;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   371
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   372
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   373
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   374
    public final KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 13233
diff changeset
   375
        return LWKeyboardFocusManagerPeer.getInstance();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   376
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   377
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   378
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   379
    public final synchronized MouseInfoPeer getMouseInfoPeer() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   380
        if (mouseInfoPeer == null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   381
            mouseInfoPeer = createMouseInfoPeerImpl();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   382
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   383
        return mouseInfoPeer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   384
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   385
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   386
    protected final MouseInfoPeer createMouseInfoPeerImpl() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   387
        return new LWMouseInfoPeer();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   388
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   389
30924
c8765f1fea21 8035568: [macosx] Cursor management unification
pchelko
parents: 29922
diff changeset
   390
    protected abstract PlatformWindow getPlatformWindowUnderMouse();
c8765f1fea21 8035568: [macosx] Cursor management unification
pchelko
parents: 29922
diff changeset
   391
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   392
    @Override
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   393
    public final PrintJob getPrintJob(Frame frame, String doctitle,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   394
                                      Properties props) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   395
        return getPrintJob(frame, doctitle, null, null);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   396
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   397
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   398
    @Override
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   399
    public final PrintJob getPrintJob(Frame frame, String doctitle,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   400
                                      JobAttributes jobAttributes,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   401
                                      PageAttributes pageAttributes) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   402
        if (GraphicsEnvironment.isHeadless()) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   403
            throw new IllegalArgumentException();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   404
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   405
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   406
        PrintJob2D printJob = new PrintJob2D(frame, doctitle, jobAttributes, pageAttributes);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   407
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   408
        if (!printJob.printDialog()) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   409
            printJob = null;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   410
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   411
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   412
        return printJob;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   413
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   414
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   415
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   416
    public final Clipboard getSystemClipboard() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   417
        SecurityManager security = System.getSecurityManager();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   418
        if (security != null) {
22060
cd4f9d7dbeda 8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents: 20153
diff changeset
   419
            security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   420
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   421
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   422
        synchronized (this) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   423
            if (clipboard == null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   424
                clipboard = createPlatformClipboard();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   425
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   426
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   427
        return clipboard;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   428
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   429
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   430
    protected abstract SecurityWarningWindow createSecurityWarning(
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   431
            Window ownerWindow, LWWindowPeer ownerPeer);
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15323
diff changeset
   432
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   433
    // ---- DELEGATES ---- //
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   434
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   435
    public abstract Clipboard createPlatformClipboard();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   436
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   437
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   438
     * Creates a delegate for the given peer type (window, frame, dialog, etc.)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   439
     */
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   440
    protected abstract PlatformWindow createPlatformWindow(PeerType peerType);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   441
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   442
    protected abstract PlatformComponent createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   443
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   444
    protected abstract PlatformComponent createLwPlatformComponent();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   445
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   446
    protected abstract FileDialogPeer createFileDialogPeer(FileDialog target);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   447
24551
cccf7dd14729 8042219: [macosx] LWComponentPeer should not reference classes from sun.lwawt.macosx
pchelko
parents: 24520
diff changeset
   448
    protected abstract PlatformDropTarget createDropTarget(DropTarget dropTarget,
cccf7dd14729 8042219: [macosx] LWComponentPeer should not reference classes from sun.lwawt.macosx
pchelko
parents: 24520
diff changeset
   449
                                                           Component component,
cccf7dd14729 8042219: [macosx] LWComponentPeer should not reference classes from sun.lwawt.macosx
pchelko
parents: 24520
diff changeset
   450
                                                           LWComponentPeer<?, ?> peer);
cccf7dd14729 8042219: [macosx] LWComponentPeer should not reference classes from sun.lwawt.macosx
pchelko
parents: 24520
diff changeset
   451
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   452
    // ---- UTILITY METHODS ---- //
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   453
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   454
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   455
     * Expose non-public targetToPeer() method.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   456
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 31653
diff changeset
   457
    public static final Object targetToPeer(Object target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   458
        return SunToolkit.targetToPeer(target);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   459
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   460
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   461
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   462
     * Expose non-public targetDisposedPeer() method.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   463
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 31653
diff changeset
   464
    public static final void targetDisposedPeer(Object target, Object peer) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   465
        SunToolkit.targetDisposedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   466
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   467
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   468
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   469
     * Returns the current cursor manager.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   470
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   471
    public abstract LWCursorManager getCursorManager();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   472
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   473
    public static void postEvent(AWTEvent event) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   474
        postEvent(targetToAppContext(event.getSource()), event);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   475
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   476
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   477
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   478
    public final void grab(final Window w) {
20153
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   479
        final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   480
        if (peer != null) {
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   481
            ((LWWindowPeer) peer).grab();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   482
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   483
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   484
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   485
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   486
    public final void ungrab(final Window w) {
20153
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   487
        final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   488
        if (peer != null) {
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   489
            ((LWWindowPeer) peer).ungrab(false);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   490
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   491
    }
17410
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   492
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   493
    @Override
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   494
    protected final Object lazilyLoadDesktopProperty(final String name) {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   495
        if (name.equals("awt.dynamicLayoutSupported")) {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   496
            return isDynamicLayoutSupported();
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   497
        }
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   498
        return super.lazilyLoadDesktopProperty(name);
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   499
    }
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   500
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   501
    @Override
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   502
    public final void setDynamicLayout(final boolean dynamic) {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   503
        dynamicLayoutSetting = dynamic;
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   504
    }
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   505
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   506
    @Override
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   507
    protected final boolean isDynamicLayoutSet() {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   508
        return dynamicLayoutSetting;
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   509
    }
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   510
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   511
    @Override
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   512
    public final boolean isDynamicLayoutActive() {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   513
        // "Live resizing" is active by default and user's data is ignored.
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   514
        return isDynamicLayoutSupported();
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   515
    }
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   516
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   517
    /**
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   518
     * Returns true if dynamic layout of Containers on resize is supported by
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   519
     * the underlying operating system and/or window manager.
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   520
     */
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   521
    protected final boolean isDynamicLayoutSupported() {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   522
        // "Live resizing" is supported by default.
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   523
        return true;
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   524
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   525
}