author | anthony |
Thu, 26 Mar 2009 14:38:46 +0300 | |
changeset 2472 | b7aba00cabb6 |
parent 2464 | 3c6755bdc55f |
child 3938 | ef327bd847c0 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
715 | 2 |
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 | 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. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
package sun.awt.X11; |
|
26 |
||
27 |
import java.awt.Component; |
|
28 |
import java.awt.KeyboardFocusManager; |
|
29 |
import java.awt.Window; |
|
30 |
||
31 |
import java.awt.event.FocusEvent; |
|
32 |
||
33 |
import java.awt.peer.KeyboardFocusManagerPeer; |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
34 |
import java.awt.peer.ComponentPeer; |
2 | 35 |
|
36 |
import java.lang.reflect.InvocationTargetException; |
|
37 |
import java.lang.reflect.Method; |
|
38 |
||
39 |
import java.util.logging.Level; |
|
40 |
import java.util.logging.Logger; |
|
41 |
||
42 |
import sun.awt.CausedFocusEvent; |
|
43 |
import sun.awt.SunToolkit; |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
44 |
import sun.awt.KeyboardFocusManagerPeerImpl; |
2 | 45 |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
46 |
public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl { |
2 | 47 |
private static final Logger focusLog = Logger.getLogger("sun.awt.X11.focus.XKeyboardFocusManagerPeer"); |
48 |
||
49 |
private static Object lock = new Object() {}; |
|
50 |
private static Component currentFocusOwner; |
|
51 |
private static Window currentFocusedWindow; |
|
52 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
53 |
XKeyboardFocusManagerPeer(KeyboardFocusManager manager) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
54 |
super(manager); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
55 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
56 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
57 |
@Override |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
58 |
public void setCurrentFocusOwner(Component comp) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
59 |
setCurrentNativeFocusOwner(comp); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
60 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
61 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
62 |
@Override |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
63 |
public Component getCurrentFocusOwner() { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
64 |
return getCurrentNativeFocusOwner(); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
65 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
66 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
67 |
@Override |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
68 |
public Window getCurrentFocusedWindow() { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
69 |
return getCurrentNativeFocusedWindow(); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
70 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
71 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
72 |
public static void setCurrentNativeFocusOwner(Component comp) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
73 |
synchronized (lock) { |
2 | 74 |
currentFocusOwner = comp; |
75 |
} |
|
76 |
} |
|
77 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
78 |
public static Component getCurrentNativeFocusOwner() { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
79 |
synchronized(lock) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
80 |
return currentFocusOwner; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
81 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
82 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
83 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
84 |
public static void setCurrentNativeFocusedWindow(Window win) { |
2 | 85 |
if (focusLog.isLoggable(Level.FINER)) focusLog.finer("Setting current native focused window " + win); |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
86 |
XWindowPeer from = null, to = null; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
87 |
|
2 | 88 |
synchronized(lock) { |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
89 |
if (currentFocusedWindow != null) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
90 |
from = (XWindowPeer)currentFocusedWindow.getPeer(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
91 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
92 |
|
2 | 93 |
currentFocusedWindow = win; |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
94 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
95 |
if (currentFocusedWindow != null) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
96 |
to = (XWindowPeer)currentFocusedWindow.getPeer(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
97 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
98 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
99 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
100 |
if (from != null) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
101 |
from.updateSecurityWarningVisibility(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
102 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
103 |
if (to != null) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
104 |
to.updateSecurityWarningVisibility(); |
2 | 105 |
} |
106 |
} |
|
107 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
108 |
public static Window getCurrentNativeFocusedWindow() { |
2 | 109 |
synchronized(lock) { |
110 |
return currentFocusedWindow; |
|
111 |
} |
|
112 |
} |
|
113 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
114 |
// TODO: do something to eliminate this forwarding |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
115 |
public static boolean deliverFocus(Component lightweightChild, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
116 |
Component target, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
117 |
boolean temporary, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
118 |
boolean focusedWindowChangeAllowed, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
119 |
long time, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
120 |
CausedFocusEvent.Cause cause) |
2 | 121 |
{ |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
122 |
return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
123 |
target, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
124 |
temporary, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
125 |
focusedWindowChangeAllowed, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
126 |
time, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
127 |
cause, |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
715
diff
changeset
|
128 |
getCurrentNativeFocusOwner()); |
2 | 129 |
} |
130 |
} |