jdk/src/macosx/classes/sun/lwawt/LWToolkit.java
author mcherkas
Mon, 28 Jul 2014 16:09:26 +0400
changeset 26008 ccab11700f07
parent 24551 cccf7dd14729
permissions -rw-r--r--
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread. Reviewed-by: ant, pchelko Contributed-by: artem.malinko@oracle.com
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
/*
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
     2
 * Copyright (c) 2011, 2014, 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.*;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    38
import sun.print.*;
24520
e8afd90fcb69 8035169: Move ThreadGroupUtils from the sun.misc package
pchelko
parents: 23900
diff changeset
    39
import sun.awt.util.ThreadGroupUtils;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
    41
import static sun.lwawt.LWWindowPeer.PeerType;
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
    42
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    43
public abstract class LWToolkit extends SunToolkit implements Runnable {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    44
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    45
    private final static int STATE_NONE = 0;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    46
    private final static int STATE_INIT = 1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    47
    private final static int STATE_MESSAGELOOP = 2;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    48
    private final static int STATE_SHUTDOWN = 3;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    49
    private final static int STATE_CLEANUP = 4;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    50
    private final static int STATE_DONE = 5;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    51
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    52
    private int runState = STATE_NONE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    53
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    54
    private Clipboard clipboard;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    55
    private MouseInfoPeer mouseInfoPeer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    56
17410
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    57
    /**
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    58
     * 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
    59
     */
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    60
    private volatile boolean dynamicLayoutSetting = true;
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    61
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
    62
    protected LWToolkit() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    63
    }
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
     * This method is called by subclasses to start this toolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    67
     * by launching the message loop.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    68
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    69
     * This method waits for the toolkit to be completely initialized
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    70
     * and returns before the message pump is started.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    71
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    72
    protected final void init() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    73
        AWTAutoShutdown.notifyToolkitThreadBusy();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    74
23900
fd98305f0d19 8031477: [macosx] Loading AWT native library fails
pchelko
parents: 23276
diff changeset
    75
        ThreadGroup rootTG = AccessController.doPrivileged(
fd98305f0d19 8031477: [macosx] Loading AWT native library fails
pchelko
parents: 23276
diff changeset
    76
                (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    77
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    78
        Runtime.getRuntime().addShutdownHook(
23900
fd98305f0d19 8031477: [macosx] Loading AWT native library fails
pchelko
parents: 23276
diff changeset
    79
            new Thread(rootTG, () -> {
fd98305f0d19 8031477: [macosx] Loading AWT native library fails
pchelko
parents: 23276
diff changeset
    80
                shutdown();
fd98305f0d19 8031477: [macosx] Loading AWT native library fails
pchelko
parents: 23276
diff changeset
    81
                waitForRunState(STATE_CLEANUP);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    82
            })
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    83
        );
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    84
23900
fd98305f0d19 8031477: [macosx] Loading AWT native library fails
pchelko
parents: 23276
diff changeset
    85
        Thread toolkitThread = new Thread(rootTG, this, "AWT-LW");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    86
        toolkitThread.setDaemon(true);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    87
        toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    88
        toolkitThread.start();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    89
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    90
        waitForRunState(STATE_MESSAGELOOP);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    91
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    92
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
     * Implemented in subclasses to initialize platform-dependent
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    95
     * part of the toolkit (open X display connection, create
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    96
     * toolkit HWND, etc.)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    97
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    98
     * This method is called on the toolkit thread.
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
    protected abstract void platformInit();
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
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   103
     * Sends a request to stop the message pump.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   104
     */
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   105
    public final void shutdown() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   106
        setRunState(STATE_SHUTDOWN);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   107
        platformShutdown();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   108
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   109
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
     * Implemented in subclasses to release all the platform-
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   112
     * dependent resources. Called after the message loop is
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   113
     * terminated.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   114
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   115
     * Could be called (always called?) on a non-toolkit thread.
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
    protected abstract void platformShutdown();
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
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   120
     * Implemented in subclasses to release all the platform
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   121
     * resources before the application is terminated.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   122
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   123
     * This method is called on the toolkit thread.
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
    protected abstract void platformCleanup();
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
    private synchronized int getRunState() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   128
        return runState;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   129
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   130
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   131
    private synchronized void setRunState(int state) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   132
        runState = state;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   133
        notifyAll();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   134
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   135
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   136
    public final boolean isTerminating() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   137
        return getRunState() >= STATE_SHUTDOWN;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   138
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   139
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   140
    private void waitForRunState(int state) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   141
        while (getRunState() < state) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   142
            try {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   143
                synchronized (this) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   144
                    wait();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   145
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   146
            } catch (InterruptedException z) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   147
                // TODO: log
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   148
                break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   149
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   150
        }
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
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   153
    @Override
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   154
    public final void run() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   155
        setRunState(STATE_INIT);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   156
        platformInit();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   157
        AWTAutoShutdown.notifyToolkitThreadFree();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   158
        setRunState(STATE_MESSAGELOOP);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   159
        while (getRunState() < STATE_SHUTDOWN) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   160
            try {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   161
                platformRunMessage();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   162
                if (Thread.currentThread().isInterrupted()) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   163
                    if (AppContext.getAppContext().isDisposed()) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   164
                        break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   165
                    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   166
                }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   167
            } catch (ThreadDeath td) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   168
                //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
   169
                //kills the thread right away. Do we expect to catch it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   170
                //nevertheless?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   171
                break;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   172
            } catch (Throwable t) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   173
                // TODO: log
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   174
                System.err.println("Exception on the toolkit thread");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   175
                t.printStackTrace(System.err);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   176
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   177
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   178
        //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
   179
        setRunState(STATE_CLEANUP);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   180
        AWTAutoShutdown.notifyToolkitThreadFree();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   181
        platformCleanup();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   182
        setRunState(STATE_DONE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   183
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   184
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
     * Process the next message(s) from the native event queue.
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
     * Initially, all the LWToolkit implementations were supposed
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   189
     * to have the similar message loop sequence: check if any events
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   190
     * available, peek events, wait. However, the later analysis shown
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   191
     * that X11 and Windows implementations are really different, so
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   192
     * let the subclasses do whatever they require.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   193
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   194
    protected abstract void platformRunMessage();
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
    public static LWToolkit getLWToolkit() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   197
        return (LWToolkit)Toolkit.getDefaultToolkit();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   198
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   199
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   200
    // ---- TOPLEVEL PEERS ---- //
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
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   203
     * Note that LWWindowPeer implements WindowPeer, FramePeer
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   204
     * and DialogPeer interfaces.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   205
     */
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   206
    protected LWWindowPeer createDelegatedPeer(Window target,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   207
                                               PlatformComponent platformComponent,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   208
                                               PlatformWindow platformWindow,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   209
                                               PeerType peerType) {
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 13993
diff changeset
   210
        LWWindowPeer peer = new LWWindowPeer(target, platformComponent, platformWindow, peerType);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   211
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   212
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   213
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   214
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   215
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   216
    @Override
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   217
    public final FramePeer createLightweightFrame(LightweightFrame target) {
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   218
        PlatformComponent platformComponent = createLwPlatformComponent();
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   219
        PlatformWindow platformWindow = createPlatformWindow(PeerType.LW_FRAME);
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   220
        LWLightweightFramePeer peer = new LWLightweightFramePeer(target,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   221
                                                                 platformComponent,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   222
                                                                 platformWindow);
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   223
        targetCreatedPeer(target, peer);
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   224
        peer.initialize();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   225
        return peer;
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   226
    }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   227
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   228
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   229
    public final WindowPeer createWindow(Window target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   230
        PlatformComponent platformComponent = createPlatformComponent();
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   231
        PlatformWindow platformWindow = createPlatformWindow(PeerType.SIMPLEWINDOW);
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   232
        return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.SIMPLEWINDOW);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   233
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   234
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   235
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   236
    public final FramePeer createFrame(Frame target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   237
        PlatformComponent platformComponent = createPlatformComponent();
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   238
        PlatformWindow platformWindow = createPlatformWindow(PeerType.FRAME);
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   239
        return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.FRAME);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   240
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   241
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   242
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   243
    public DialogPeer createDialog(Dialog target) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   244
        PlatformComponent platformComponent = createPlatformComponent();
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   245
        PlatformWindow platformWindow = createPlatformWindow(PeerType.DIALOG);
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   246
        return createDelegatedPeer(target, platformComponent, platformWindow, PeerType.DIALOG);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   247
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   248
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   249
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   250
    public final FileDialogPeer createFileDialog(FileDialog target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   251
        FileDialogPeer peer = createFileDialogPeer(target);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   252
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   253
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   254
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   255
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   256
    // ---- LIGHTWEIGHT COMPONENT PEERS ---- //
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
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   259
    public final ButtonPeer createButton(Button target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   260
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   261
        LWButtonPeer peer = new LWButtonPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   262
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   263
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   264
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   265
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   266
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   267
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   268
    public final CheckboxPeer createCheckbox(Checkbox target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   269
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   270
        LWCheckboxPeer peer = new LWCheckboxPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   271
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   272
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   273
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   274
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   275
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   276
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   277
    public final ChoicePeer createChoice(Choice target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   278
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   279
        LWChoicePeer peer = new LWChoicePeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   280
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   281
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   282
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   283
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   284
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   285
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   286
    public final LabelPeer createLabel(Label target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   287
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   288
        LWLabelPeer peer = new LWLabelPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   289
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   290
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   291
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   292
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   293
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   294
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   295
    public final CanvasPeer createCanvas(Canvas target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   296
        PlatformComponent platformComponent = createPlatformComponent();
13993
8b3fe3d8badb 7160627: [macosx] TextArea has wrong initial size
serb
parents: 13648
diff changeset
   297
        LWCanvasPeer<?, ?> peer = new LWCanvasPeer<>(target, platformComponent);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   298
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   299
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   300
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   301
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   302
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   303
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   304
    public final ListPeer createList(List target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   305
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   306
        LWListPeer peer = new LWListPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   307
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   308
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   309
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   310
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   311
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   312
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   313
    public final PanelPeer createPanel(Panel target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   314
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   315
        LWPanelPeer peer = new LWPanelPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   316
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   317
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   318
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   319
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   320
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   321
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   322
    public final ScrollPanePeer createScrollPane(ScrollPane target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   323
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   324
        LWScrollPanePeer peer = new LWScrollPanePeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   325
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   326
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   327
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   328
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   329
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   330
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   331
    public final ScrollbarPeer createScrollbar(Scrollbar target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   332
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   333
        LWScrollBarPeer peer = new LWScrollBarPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   334
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   335
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   336
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   337
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   338
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   339
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   340
    public final TextAreaPeer createTextArea(TextArea target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   341
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   342
        LWTextAreaPeer peer = new LWTextAreaPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   343
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   344
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   345
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   346
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   347
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   348
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   349
    public final TextFieldPeer createTextField(TextField target) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   350
        PlatformComponent platformComponent = createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   351
        LWTextFieldPeer peer = new LWTextFieldPeer(target, platformComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   352
        targetCreatedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   353
        peer.initialize();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   354
        return peer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   355
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   356
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   357
    // ---- NON-COMPONENT PEERS ---- //
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
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   360
    public final ColorModel getColorModel() throws HeadlessException {
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   361
        return GraphicsEnvironment.getLocalGraphicsEnvironment()
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   362
                                  .getDefaultScreenDevice()
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   363
                                  .getDefaultConfiguration().getColorModel();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   364
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   365
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   366
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   367
    public final boolean isDesktopSupported() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   368
        return true;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   369
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   370
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   371
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   372
    public final KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 13233
diff changeset
   373
        return LWKeyboardFocusManagerPeer.getInstance();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   374
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   375
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   376
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   377
    public final synchronized MouseInfoPeer getMouseInfoPeer() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   378
        if (mouseInfoPeer == null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   379
            mouseInfoPeer = createMouseInfoPeerImpl();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   380
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   381
        return mouseInfoPeer;
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
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   384
    protected final MouseInfoPeer createMouseInfoPeerImpl() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   385
        return new LWMouseInfoPeer();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   386
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   387
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   388
    @Override
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   389
    public final PrintJob getPrintJob(Frame frame, String doctitle,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   390
                                      Properties props) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   391
        return getPrintJob(frame, doctitle, null, null);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   392
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   393
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   394
    @Override
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   395
    public final PrintJob getPrintJob(Frame frame, String doctitle,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   396
                                      JobAttributes jobAttributes,
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   397
                                      PageAttributes pageAttributes) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   398
        if (GraphicsEnvironment.isHeadless()) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   399
            throw new IllegalArgumentException();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   400
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   401
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   402
        PrintJob2D printJob = new PrintJob2D(frame, doctitle, jobAttributes, pageAttributes);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   403
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   404
        if (!printJob.printDialog()) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   405
            printJob = null;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   406
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   407
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   408
        return printJob;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   409
    }
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
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   412
    public final Clipboard getSystemClipboard() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   413
        SecurityManager security = System.getSecurityManager();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   414
        if (security != null) {
22060
cd4f9d7dbeda 8029886: Change SecurityManager check{TopLevelWindow, SystemClipboardAccessAwtEventQueueAccess} to check AllPermission
alanb
parents: 20153
diff changeset
   415
            security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   416
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   417
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   418
        synchronized (this) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   419
            if (clipboard == null) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   420
                clipboard = createPlatformClipboard();
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
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   423
        return clipboard;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   424
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   425
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   426
    protected abstract SecurityWarningWindow createSecurityWarning(
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   427
            Window ownerWindow, LWWindowPeer ownerPeer);
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 15323
diff changeset
   428
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   429
    // ---- DELEGATES ---- //
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   430
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   431
    public abstract Clipboard createPlatformClipboard();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   432
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   433
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   434
     * 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
   435
     */
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   436
    protected abstract PlatformWindow createPlatformWindow(PeerType peerType);
12047
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
    protected abstract PlatformComponent createPlatformComponent();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   439
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   440
    protected abstract PlatformComponent createLwPlatformComponent();
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 15323
diff changeset
   441
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   442
    protected abstract FileDialogPeer createFileDialogPeer(FileDialog target);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   443
24551
cccf7dd14729 8042219: [macosx] LWComponentPeer should not reference classes from sun.lwawt.macosx
pchelko
parents: 24520
diff changeset
   444
    protected abstract PlatformDropTarget createDropTarget(DropTarget dropTarget,
cccf7dd14729 8042219: [macosx] LWComponentPeer should not reference classes from sun.lwawt.macosx
pchelko
parents: 24520
diff changeset
   445
                                                           Component component,
cccf7dd14729 8042219: [macosx] LWComponentPeer should not reference classes from sun.lwawt.macosx
pchelko
parents: 24520
diff changeset
   446
                                                           LWComponentPeer<?, ?> peer);
cccf7dd14729 8042219: [macosx] LWComponentPeer should not reference classes from sun.lwawt.macosx
pchelko
parents: 24520
diff changeset
   447
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   448
    // ---- UTILITY METHODS ---- //
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   449
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   450
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   451
     * Expose non-public targetToPeer() method.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   452
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   453
    public final static Object targetToPeer(Object target) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   454
        return SunToolkit.targetToPeer(target);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   455
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   456
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   457
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   458
     * Expose non-public targetDisposedPeer() method.
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
    public final static void targetDisposedPeer(Object target, Object peer) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   461
        SunToolkit.targetDisposedPeer(target, peer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   462
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   463
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   464
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   465
     * Returns the current cursor manager.
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
    public abstract LWCursorManager getCursorManager();
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
    public static void postEvent(AWTEvent event) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   470
        postEvent(targetToAppContext(event.getSource()), event);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   471
    }
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
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   474
    public final void grab(final Window w) {
20153
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   475
        final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   476
        if (peer != null) {
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   477
            ((LWWindowPeer) peer).grab();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   478
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   479
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   480
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   481
    @Override
23261
49117dc9e97c 8031090: [macosx] LWToolkit should not depends from the macosx.
serb
parents: 20153
diff changeset
   482
    public final void ungrab(final Window w) {
20153
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   483
        final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   484
        if (peer != null) {
d5bf90bfcb6d 8005255: [macosx] Cleanup warnings in sun.lwawt
serb
parents: 19807
diff changeset
   485
            ((LWWindowPeer) peer).ungrab(false);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   486
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   487
    }
17410
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   488
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   489
    @Override
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   490
    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
   491
        if (name.equals("awt.dynamicLayoutSupported")) {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   492
            return isDynamicLayoutSupported();
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   493
        }
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   494
        return super.lazilyLoadDesktopProperty(name);
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   495
    }
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   496
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   497
    @Override
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   498
    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
   499
        dynamicLayoutSetting = dynamic;
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
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   502
    @Override
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   503
    protected final boolean isDynamicLayoutSet() {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   504
        return dynamicLayoutSetting;
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
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   507
    @Override
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   508
    public final boolean isDynamicLayoutActive() {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   509
        // "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
   510
        return isDynamicLayoutSupported();
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   511
    }
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   512
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   513
    /**
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   514
     * 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
   515
     * 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
   516
     */
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   517
    protected final boolean isDynamicLayoutSupported() {
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   518
        // "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
   519
        return true;
c9c726c5ce7e 7161575: [macosx] On MacOSX port java.awt.Toolkit.is/setDynamicLayout() are not consistent
serb
parents: 15983
diff changeset
   520
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   521
}