1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package sun.awt.X11;
26
27 import java.awt.Component;
28 import java.awt.Window;
29
30 import sun.awt.AWTAccessor;
31 import sun.awt.CausedFocusEvent;
32 import sun.awt.KeyboardFocusManagerPeerImpl;
33 import sun.util.logging.PlatformLogger;
34
35 public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
36 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XKeyboardFocusManagerPeer");
37 private static final XKeyboardFocusManagerPeer inst = new XKeyboardFocusManagerPeer();
38
39 private Component currentFocusOwner;
40 private Window currentFocusedWindow;
41
42 public static XKeyboardFocusManagerPeer getInstance() {
43 return inst;
44 }
45
46 private XKeyboardFocusManagerPeer() {
47 }
48
49 @Override
50 public void setCurrentFocusOwner(Component comp) {
51 synchronized (this) {
84 from.updateSecurityWarningVisibility();
85 }
86 if (to != null) {
87 to.updateSecurityWarningVisibility();
88 }
89 }
90
91 @Override
92 public Window getCurrentFocusedWindow() {
93 synchronized(this) {
94 return currentFocusedWindow;
95 }
96 }
97
98 // TODO: do something to eliminate this forwarding
99 public static boolean deliverFocus(Component lightweightChild,
100 Component target,
101 boolean temporary,
102 boolean focusedWindowChangeAllowed,
103 long time,
104 CausedFocusEvent.Cause cause)
105 {
106 return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
107 target,
108 temporary,
109 focusedWindowChangeAllowed,
110 time,
111 cause,
112 getInstance().getCurrentFocusOwner());
113 }
114 }
|
1 /*
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package sun.awt.X11;
26
27 import java.awt.Component;
28 import java.awt.Window;
29
30 import sun.awt.AWTAccessor;
31 import java.awt.event.FocusEvent;
32 import sun.awt.KeyboardFocusManagerPeerImpl;
33 import sun.util.logging.PlatformLogger;
34
35 public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
36 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XKeyboardFocusManagerPeer");
37 private static final XKeyboardFocusManagerPeer inst = new XKeyboardFocusManagerPeer();
38
39 private Component currentFocusOwner;
40 private Window currentFocusedWindow;
41
42 public static XKeyboardFocusManagerPeer getInstance() {
43 return inst;
44 }
45
46 private XKeyboardFocusManagerPeer() {
47 }
48
49 @Override
50 public void setCurrentFocusOwner(Component comp) {
51 synchronized (this) {
84 from.updateSecurityWarningVisibility();
85 }
86 if (to != null) {
87 to.updateSecurityWarningVisibility();
88 }
89 }
90
91 @Override
92 public Window getCurrentFocusedWindow() {
93 synchronized(this) {
94 return currentFocusedWindow;
95 }
96 }
97
98 // TODO: do something to eliminate this forwarding
99 public static boolean deliverFocus(Component lightweightChild,
100 Component target,
101 boolean temporary,
102 boolean focusedWindowChangeAllowed,
103 long time,
104 FocusEvent.Cause cause)
105 {
106 return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
107 target,
108 temporary,
109 focusedWindowChangeAllowed,
110 time,
111 cause,
112 getInstance().getCurrentFocusOwner());
113 }
114 }
|