author | lana |
Thu, 26 Dec 2013 12:04:16 -0800 | |
changeset 23010 | 6dadb192ad81 |
parent 5506 | 202f599c92aa |
child 25186 | 63e1a2ec30f5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.awt.X11; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
||
30 |
/** |
|
31 |
* This class represent focus holder window implementation. When toplevel requests or receives focus |
|
32 |
* it instead sets focus to this proxy. This proxy is mapped but invisible(it is kept at (-1,-1)) |
|
33 |
* and therefore X doesn't control focus after we have set it to proxy. |
|
34 |
*/ |
|
35 |
public class XFocusProxyWindow extends XBaseWindow { |
|
36 |
XWindowPeer owner; |
|
37 |
||
38 |
public XFocusProxyWindow(XWindowPeer owner) { |
|
39 |
super(new XCreateWindowParams(new Object[] { |
|
40 |
BOUNDS, new Rectangle(-1, -1, 1, 1), |
|
41 |
PARENT_WINDOW, new Long(owner.getWindow()), |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
2
diff
changeset
|
42 |
EVENT_MASK, new Long(XConstants.FocusChangeMask | XConstants.KeyPressMask | XConstants.KeyReleaseMask) |
2 | 43 |
})); |
44 |
this.owner = owner; |
|
45 |
} |
|
46 |
||
47 |
public void postInit(XCreateWindowParams params){ |
|
48 |
super.postInit(params); |
|
49 |
setWMClass(getWMClass()); |
|
50 |
xSetVisible(true); |
|
51 |
} |
|
52 |
||
53 |
protected String getWMName() { |
|
54 |
return "FocusProxy"; |
|
55 |
} |
|
56 |
protected String[] getWMClass() { |
|
57 |
return new String[] {"Focus-Proxy-Window", "FocusProxy"}; |
|
58 |
} |
|
59 |
||
60 |
public XWindowPeer getOwner() { |
|
61 |
return owner; |
|
62 |
} |
|
63 |
||
64 |
public void dispatchEvent(XEvent ev) { |
|
65 |
int type = ev.get_type(); |
|
66 |
switch (type) |
|
67 |
{ |
|
439
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
2
diff
changeset
|
68 |
case XConstants.FocusIn: |
3488710b02f8
6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents:
2
diff
changeset
|
69 |
case XConstants.FocusOut: |
2 | 70 |
handleFocusEvent(ev); |
71 |
break; |
|
72 |
} |
|
73 |
super.dispatchEvent(ev); |
|
74 |
} |
|
75 |
||
76 |
public void handleFocusEvent(XEvent xev) { |
|
77 |
owner.handleFocusEvent(xev); |
|
78 |
} |
|
79 |
||
80 |
public void handleKeyPress(XEvent xev) { |
|
81 |
owner.handleKeyPress(xev); |
|
82 |
} |
|
83 |
||
84 |
public void handleKeyRelease(XEvent xev) { |
|
85 |
owner.handleKeyRelease(xev); |
|
86 |
} |
|
87 |
} |