1 /*
2 * Copyright (c) 2003, 2014, 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
149 XToolkit.awtUnlock();
150 }
151 }
152 public ColorModel getColorModel() { return null; }
153 public Toolkit getToolkit() { return Toolkit.getDefaultToolkit(); }
154
155 public Graphics getGraphics() { return null; }
156 public FontMetrics getFontMetrics(Font font) { return null; }
157 public void dispose() {
158 container.detachChild(handle);
159 }
160 public void setForeground(Color c) {}
161 public void setBackground(Color c) {}
162 public void setFont(Font f) {}
163 public void updateCursorImmediately() {}
164
165 void postEvent(AWTEvent event) {
166 XToolkit.postEvent(XToolkit.targetToAppContext(proxy), event);
167 }
168
169 @SuppressWarnings("deprecation")
170 boolean simulateMotifRequestFocus(Component lightweightChild, boolean temporary,
171 boolean focusedWindowChangeAllowed, long time)
172 {
173 if (lightweightChild == null) {
174 lightweightChild = (Component)proxy;
175 }
176 Component currentOwner = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
177 if (currentOwner != null && currentOwner.getPeer() == null) {
178 currentOwner = null;
179 }
180 FocusEvent fg = new FocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner );
181 FocusEvent fl = null;
182 if (currentOwner != null) {
183 fl = new FocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild);
184 }
185
186 // TODO: do we need to wrap in sequenced?
187 if (fl != null) {
188 postEvent(XComponentPeer.wrapInSequenced(fl));
189 }
190 postEvent(XComponentPeer.wrapInSequenced(fg));
191 // End of Motif compatibility code
192 return true;
193 }
194
195 public boolean requestFocus(Component lightweightChild,
196 boolean temporary,
197 boolean focusedWindowChangeAllowed,
|
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
149 XToolkit.awtUnlock();
150 }
151 }
152 public ColorModel getColorModel() { return null; }
153 public Toolkit getToolkit() { return Toolkit.getDefaultToolkit(); }
154
155 public Graphics getGraphics() { return null; }
156 public FontMetrics getFontMetrics(Font font) { return null; }
157 public void dispose() {
158 container.detachChild(handle);
159 }
160 public void setForeground(Color c) {}
161 public void setBackground(Color c) {}
162 public void setFont(Font f) {}
163 public void updateCursorImmediately() {}
164
165 void postEvent(AWTEvent event) {
166 XToolkit.postEvent(XToolkit.targetToAppContext(proxy), event);
167 }
168
169 boolean simulateMotifRequestFocus(Component lightweightChild, boolean temporary,
170 boolean focusedWindowChangeAllowed, long time)
171 {
172 if (lightweightChild == null) {
173 lightweightChild = (Component)proxy;
174 }
175 Component currentOwner = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
176 if (currentOwner != null && !currentOwner.isDisplayable()) {
177 currentOwner = null;
178 }
179 FocusEvent fg = new FocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED, false, currentOwner );
180 FocusEvent fl = null;
181 if (currentOwner != null) {
182 fl = new FocusEvent(currentOwner, FocusEvent.FOCUS_LOST, false, lightweightChild);
183 }
184
185 // TODO: do we need to wrap in sequenced?
186 if (fl != null) {
187 postEvent(XComponentPeer.wrapInSequenced(fl));
188 }
189 postEvent(XComponentPeer.wrapInSequenced(fg));
190 // End of Motif compatibility code
191 return true;
192 }
193
194 public boolean requestFocus(Component lightweightChild,
195 boolean temporary,
196 boolean focusedWindowChangeAllowed,
|