jdk/src/macosx/classes/sun/lwawt/LWKeyboardFocusManagerPeer.java
author alexsch
Mon, 07 Oct 2013 16:42:29 +0400
changeset 20457 ecb935d774a3
parent 18241 3e009b5be123
permissions -rw-r--r--
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display Reviewed-by: serb, anthony
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
/*
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
     2
 * Copyright (c) 2011, 2013, 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.Component;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    29
import java.awt.Window;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    30
import sun.awt.KeyboardFocusManagerPeerImpl;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    31
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    32
public class LWKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    33
    private static final LWKeyboardFocusManagerPeer inst = new LWKeyboardFocusManagerPeer();
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    34
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    35
    private Window focusedWindow;
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    36
    private Component focusOwner;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    37
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    38
    public static LWKeyboardFocusManagerPeer getInstance() {
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    39
        return inst;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    42
    private LWKeyboardFocusManagerPeer() {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    43
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    44
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    45
    @Override
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    46
    public void setCurrentFocusedWindow(Window win) {
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    47
        LWWindowPeer from, to;
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    48
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    49
        synchronized (this) {
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    50
            if (focusedWindow == win) {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    51
                return;
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    52
            }
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    53
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    54
            from = (LWWindowPeer)LWToolkit.targetToPeer(focusedWindow);
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    55
            to = (LWWindowPeer)LWToolkit.targetToPeer(win);
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    56
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    57
            focusedWindow = win;
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    58
        }
18241
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    59
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    60
        if (from != null) {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    61
            from.updateSecurityWarningVisibility();
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    62
        }
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    63
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    64
        if (to != null) {
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    65
            to.updateSecurityWarningVisibility();
3e009b5be123 8003559: Update display of applet windows
leonidr
parents: 13648
diff changeset
    66
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    67
    }
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
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    70
    public Window getCurrentFocusedWindow() {
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    71
        synchronized (this) {
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    72
            return focusedWindow;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    73
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    74
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    75
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    76
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    77
    public Component getCurrentFocusOwner() {
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    78
        synchronized (this) {
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    79
            return focusOwner;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    80
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    81
    }
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
    @Override
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    84
    public void setCurrentFocusOwner(Component comp) {
13648
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    85
        synchronized (this) {
90effcfc064f 7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents: 12047
diff changeset
    86
            focusOwner = comp;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    87
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    88
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    89
}