src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java
Print this page
@@ -23,70 +23,52 @@
* questions.
*/
package sun.awt.X11;
import java.awt.Component;
-import java.awt.KeyboardFocusManager;
import java.awt.Window;
-
-import java.awt.event.FocusEvent;
-
-import java.awt.peer.KeyboardFocusManagerPeer;
-import java.awt.peer.ComponentPeer;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
import sun.util.logging.PlatformLogger;
-
import sun.awt.CausedFocusEvent;
-import sun.awt.SunToolkit;
import sun.awt.KeyboardFocusManagerPeerImpl;
public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XKeyboardFocusManagerPeer");
+ private static final XKeyboardFocusManagerPeer inst = new XKeyboardFocusManagerPeer();
- private static Object lock = new Object() {};
- private static Component currentFocusOwner;
- private static Window currentFocusedWindow;
+ private Component currentFocusOwner;
+ private Window currentFocusedWindow;
- XKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
- super(manager);
+ public static XKeyboardFocusManagerPeer getInstance() {
+ return inst;
}
- @Override
- public void setCurrentFocusOwner(Component comp) {
- setCurrentNativeFocusOwner(comp);
- }
-
- @Override
- public Component getCurrentFocusOwner() {
- return getCurrentNativeFocusOwner();
+ private XKeyboardFocusManagerPeer() {
}
@Override
- public Window getCurrentFocusedWindow() {
- return getCurrentNativeFocusedWindow();
- }
-
- public static void setCurrentNativeFocusOwner(Component comp) {
- synchronized (lock) {
+ public void setCurrentFocusOwner(Component comp) {
+ synchronized (this) {
currentFocusOwner = comp;
}
}
- public static Component getCurrentNativeFocusOwner() {
- synchronized(lock) {
+ @Override
+ public Component getCurrentFocusOwner() {
+ synchronized(this) {
return currentFocusOwner;
}
}
- public static void setCurrentNativeFocusedWindow(Window win) {
- if (focusLog.isLoggable(PlatformLogger.FINER)) focusLog.finer("Setting current native focused window " + win);
+ @Override
+ public void setCurrentFocusedWindow(Window win) {
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
+ focusLog.finer("Setting current focused window " + win);
+ }
+
XWindowPeer from = null, to = null;
- synchronized(lock) {
+ synchronized(this) {
if (currentFocusedWindow != null) {
from = (XWindowPeer)currentFocusedWindow.getPeer();
}
currentFocusedWindow = win;
@@ -102,12 +84,13 @@
if (to != null) {
to.updateSecurityWarningVisibility();
}
}
- public static Window getCurrentNativeFocusedWindow() {
- synchronized(lock) {
+ @Override
+ public Window getCurrentFocusedWindow() {
+ synchronized(this) {
return currentFocusedWindow;
}
}
// TODO: do something to eliminate this forwarding
@@ -122,8 +105,8 @@
target,
temporary,
focusedWindowChangeAllowed,
time,
cause,
- getCurrentNativeFocusOwner());
+ getInstance().getCurrentFocusOwner());
}
}