1 /* |
|
2 * Copyright 1995-2006 Sun Microsystems, Inc. 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. 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 |
|
26 #ifdef HEADLESS |
|
27 #error This file should not be included in headless library |
|
28 #endif |
|
29 |
|
30 #include "awt_p.h" |
|
31 #include "canvas.h" |
|
32 #include "awt_AWTEvent.h" |
|
33 #include "VDrawingArea.h" |
|
34 #include "awt_KeyboardFocusManager.h" |
|
35 #include "awt_MToolkit.h" |
|
36 #include "awt_TopLevel.h" |
|
37 #include "java_awt_Color.h" |
|
38 #include "java_awt_Cursor.h" |
|
39 #include "java_awt_Font.h" |
|
40 #include "java_awt_Point.h" |
|
41 #include "java_awt_Component.h" |
|
42 #include "java_awt_AWTEvent.h" |
|
43 #include "java_awt_KeyboardFocusManager.h" |
|
44 #include "java_awt_event_KeyEvent.h" |
|
45 #include "java_awt_event_MouseEvent.h" |
|
46 #include "sun_awt_motif_MComponentPeer.h" |
|
47 |
|
48 #include "multi_font.h" |
|
49 #include "jni.h" |
|
50 #include "jni_util.h" |
|
51 #include <jawt.h> |
|
52 #include <Xm/PrimitiveP.h> |
|
53 #include <Xm/ManagerP.h> |
|
54 #include <Xm/ComboBox.h> |
|
55 |
|
56 /* CanvasType widgets: Frame, Dialog, Window, Panel, Canvas, |
|
57 * & all lightweights (Component, Container) |
|
58 */ |
|
59 #define IsCanvasTypeWidget(w) \ |
|
60 XtIsSubclass(w, xmDrawingAreaWidgetClass) ||\ |
|
61 XtIsSubclass(w, vDrawingAreaClass) |
|
62 |
|
63 |
|
64 #include "awt_Component.h" |
|
65 #include "awt_GraphicsEnv.h" |
|
66 |
|
67 #include "awt_AWTEvent.h" |
|
68 #include "awt_Cursor.h" |
|
69 |
|
70 extern struct CursorIDs cursorIDs; |
|
71 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs; |
|
72 extern struct KeyboardFocusManagerIDs keyboardFocusManagerIDs; |
|
73 |
|
74 /* fieldIDs for Component fields that may be accessed from C */ |
|
75 struct ComponentIDs componentIDs; |
|
76 |
|
77 /* |
|
78 * Class: java_awt_Component |
|
79 * Method: initIDs |
|
80 * Signature: ()V |
|
81 */ |
|
82 |
|
83 /* This function gets called from the static initializer for Component.java |
|
84 to initialize the fieldIDs for fields that may be accessed from C */ |
|
85 |
|
86 JNIEXPORT void JNICALL |
|
87 Java_java_awt_Component_initIDs |
|
88 (JNIEnv *env, jclass cls) |
|
89 { |
|
90 jclass keyclass = NULL; |
|
91 |
|
92 componentIDs.x = (*env)->GetFieldID(env, cls, "x", "I"); |
|
93 componentIDs.y = (*env)->GetFieldID(env, cls, "y", "I"); |
|
94 componentIDs.width = (*env)->GetFieldID(env, cls, "width", "I"); |
|
95 componentIDs.height = (*env)->GetFieldID(env, cls, "height", "I"); |
|
96 componentIDs.isPacked = (*env)->GetFieldID(env, cls, "isPacked", "Z"); |
|
97 componentIDs.peer = |
|
98 (*env)->GetFieldID(env, cls, "peer", "Ljava/awt/peer/ComponentPeer;"); |
|
99 componentIDs.background = |
|
100 (*env)->GetFieldID(env, cls, "background", "Ljava/awt/Color;"); |
|
101 componentIDs.foreground = |
|
102 (*env)->GetFieldID(env, cls, "foreground", "Ljava/awt/Color;"); |
|
103 componentIDs.graphicsConfig = |
|
104 (*env)->GetFieldID(env, cls, "graphicsConfig", |
|
105 "Ljava/awt/GraphicsConfiguration;"); |
|
106 componentIDs.name = |
|
107 (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;"); |
|
108 |
|
109 /* Use _NoClientCode() methods for trusted methods, so that we |
|
110 * know that we are not invoking client code on trusted threads |
|
111 */ |
|
112 componentIDs.getParent = |
|
113 (*env)->GetMethodID(env, cls, "getParent_NoClientCode", |
|
114 "()Ljava/awt/Container;"); |
|
115 |
|
116 componentIDs.getLocationOnScreen = |
|
117 (*env)->GetMethodID(env, cls, "getLocationOnScreen_NoTreeLock", |
|
118 "()Ljava/awt/Point;"); |
|
119 |
|
120 componentIDs.resetGCMID = |
|
121 (*env)->GetMethodID(env, cls, "resetGC", "()V"); |
|
122 |
|
123 keyclass = (*env)->FindClass(env, "java/awt/event/KeyEvent"); |
|
124 DASSERT (keyclass != NULL); |
|
125 |
|
126 componentIDs.isProxyActive = |
|
127 (*env)->GetFieldID(env, keyclass, "isProxyActive", |
|
128 "Z"); |
|
129 |
|
130 componentIDs.appContext = |
|
131 (*env)->GetFieldID(env, cls, "appContext", |
|
132 "Lsun/awt/AppContext;"); |
|
133 |
|
134 (*env)->DeleteLocalRef(env, keyclass); |
|
135 |
|
136 DASSERT(componentIDs.resetGCMID); |
|
137 } |
|
138 |
|
139 /* fieldIDs for MComponentPeer fields that may be accessed from C */ |
|
140 struct MComponentPeerIDs mComponentPeerIDs; |
|
141 |
|
142 /* |
|
143 * Class: sun_awt_motif_MComponentPeer |
|
144 * Method: initIDs |
|
145 * Signature: ()V |
|
146 */ |
|
147 |
|
148 /* This function gets called from the static initializer for |
|
149 MComponentPeer.java to initialize the fieldIDs for fields that may |
|
150 be accessed from C */ |
|
151 |
|
152 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_initIDs |
|
153 (JNIEnv *env, jclass cls) |
|
154 { |
|
155 mComponentPeerIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J"); |
|
156 mComponentPeerIDs.target = |
|
157 (*env)->GetFieldID(env, cls, "target", "Ljava/awt/Component;"); |
|
158 mComponentPeerIDs.jniGlobalRef = |
|
159 (*env)->GetFieldID(env, cls, "jniGlobalRef", "J"); |
|
160 mComponentPeerIDs.graphicsConfig = |
|
161 (*env)->GetFieldID(env, cls, "graphicsConfig", |
|
162 "Lsun/awt/X11GraphicsConfig;"); |
|
163 mComponentPeerIDs.drawState = |
|
164 (*env)->GetFieldID(env, cls, "drawState", "I"); |
|
165 mComponentPeerIDs.isFocusableMID = |
|
166 (*env)->GetMethodID(env, cls, "isFocusable", "()Z"); |
|
167 } |
|
168 |
|
169 /* field and method IDs for java.awt.Container. */ |
|
170 struct ContainerIDs containerIDs; |
|
171 |
|
172 /* |
|
173 * Class: java_awt_Container |
|
174 * Method: initIDs |
|
175 * Signature: ()V |
|
176 */ |
|
177 /* This function gets called from the static initializer for java.awt.Container |
|
178 to initialize the fieldIDs for fields that may be accessed from C */ |
|
179 JNIEXPORT void JNICALL |
|
180 Java_java_awt_Container_initIDs |
|
181 (JNIEnv *env, jclass cls) |
|
182 { |
|
183 containerIDs.layoutMgr = |
|
184 (*env)->GetFieldID(env, cls, "layoutMgr", "Ljava/awt/LayoutManager;"); |
|
185 |
|
186 containerIDs.getComponents = |
|
187 (*env)->GetMethodID(env, cls, "getComponents_NoClientCode", |
|
188 "()[Ljava/awt/Component;"); |
|
189 containerIDs.findComponentAt = |
|
190 (*env)->GetMethodID(env, cls, "findComponentAt", |
|
191 "(IIZ)Ljava/awt/Component;"); |
|
192 } |
|
193 |
|
194 /* |
|
195 * Fix for 4090493. When Motif computes indicator size, it uses |
|
196 * (effectively) XmTextExtents, so the size of the indicator depends |
|
197 * on the text of the label. The side effect is that if the label |
|
198 * text is rendered using different platform fonts (for a single Java |
|
199 * logical font) the display is inconsistent. E.g. for 12pt font |
|
200 * English label will have a check mark, while Japanese label will |
|
201 * not, because underlying X11 fonts have different metrics. |
|
202 * |
|
203 * The fix is to override Motif calculations for the indicatorSize and |
|
204 * compute it ourselves based on the font metrics for all the platform |
|
205 * fonts given Java font maps onto. Every time we set XmNfontList we |
|
206 * should set XmNindicatorSize as well. |
|
207 * |
|
208 * The logic is in awt_computeIndicatorSize that just compute the |
|
209 * arithmetic mean of platform fonts by now. HIE should take a look |
|
210 * at this. |
|
211 */ |
|
212 |
|
213 struct changeFontInfo { |
|
214 XmFontList fontList; /* value to set */ |
|
215 Boolean isMultiFont; /* only need to compute for multifont */ |
|
216 struct FontData *fontData; /* need this to compute indicator size */ |
|
217 Dimension indSize; /* computed once by changeFont */ |
|
218 |
|
219 Boolean initialized; |
|
220 Boolean error; |
|
221 JNIEnv *env; |
|
222 jobject fObj; |
|
223 }; |
|
224 |
|
225 static void |
|
226 changeFont(Widget w, void *info) |
|
227 { |
|
228 struct changeFontInfo *f = (struct changeFontInfo *)info; |
|
229 WidgetClass widgetClass; |
|
230 |
|
231 if (f->error) |
|
232 return; |
|
233 |
|
234 /* Some widgets use no fonts - skip them! */ |
|
235 /* Also skip the Text widgets, since they each have their own setFont. */ |
|
236 widgetClass = XtClass(w); |
|
237 if (widgetClass == xmDrawingAreaWidgetClass || |
|
238 widgetClass == xmScrollBarWidgetClass || |
|
239 widgetClass == xmScrolledWindowWidgetClass || |
|
240 widgetClass == xmComboBoxWidgetClass || |
|
241 widgetClass == xmTextWidgetClass || |
|
242 widgetClass == xmTextFieldWidgetClass) |
|
243 return; |
|
244 |
|
245 if (!f->initialized) { |
|
246 struct FontData *fdata; |
|
247 char *err; |
|
248 |
|
249 f->initialized = TRUE; |
|
250 |
|
251 fdata = awtJNI_GetFontData(f->env, f->fObj, &err); |
|
252 if (fdata == NULL) { |
|
253 JNU_ThrowInternalError(f->env, err); |
|
254 f->error = TRUE; |
|
255 return; |
|
256 } |
|
257 |
|
258 if (awtJNI_IsMultiFont(f->env, f->fObj)) { |
|
259 f->fontList = awtJNI_GetFontList(f->env, f->fObj); |
|
260 f->isMultiFont = TRUE; |
|
261 } else { |
|
262 f->fontList = XmFontListCreate(fdata->xfont, "labelFont"); |
|
263 f->isMultiFont = FALSE; |
|
264 } |
|
265 |
|
266 if (f->fontList == NULL) { |
|
267 JNU_ThrowNullPointerException(f->env, "NullPointerException"); |
|
268 f->error = TRUE; |
|
269 return; |
|
270 } |
|
271 } |
|
272 |
|
273 /* Fix for 4090493. */ |
|
274 if (f->isMultiFont && XmIsToggleButton(w)) { |
|
275 Dimension indSize; |
|
276 |
|
277 /* Compute indicator size if first time through. Note that |
|
278 ToggleButtons that are children of menus live in different |
|
279 hierarchy (MenuComponent), so we don't check for this case |
|
280 here. In fact, the only time the XmNfontList is set on |
|
281 MCheckboxMenuItemPeer widget is when it is created. */ |
|
282 if (f->indSize == 0) |
|
283 f->indSize = awt_computeIndicatorSize(f->fontData); |
|
284 |
|
285 XtVaSetValues(w, XmNfontList, f->fontList, NULL); |
|
286 if (f->indSize != MOTIF_XmINVALID_DIMENSION) |
|
287 XtVaSetValues(w, XmNindicatorSize, f->indSize, NULL); |
|
288 } |
|
289 else { /* usual case */ |
|
290 XtVaSetValues(w, XmNfontList, f->fontList, NULL); |
|
291 } |
|
292 } |
|
293 |
|
294 static void |
|
295 changeForeground(Widget w, void *fg) |
|
296 { |
|
297 XtVaSetValues(w, XmNforeground, fg, NULL); |
|
298 } |
|
299 |
|
300 static void |
|
301 changeBackground(Widget w, void *bg) |
|
302 { |
|
303 Pixel fg; |
|
304 |
|
305 XtVaGetValues(w, XmNforeground, &fg, NULL); |
|
306 XmChangeColor(w, (Pixel) bg); |
|
307 XtVaSetValues(w, XmNforeground, fg, NULL); |
|
308 } |
|
309 |
|
310 // Sets widget's traversalOn property into value 'value' |
|
311 void setTraversal(Widget w, Boolean value) { |
|
312 if (w == NULL) { |
|
313 return; |
|
314 } |
|
315 if (XmIsPrimitive(w)) { |
|
316 XmPrimitiveWidget prim = (XmPrimitiveWidget)w; |
|
317 prim->primitive.traversal_on = value; |
|
318 } else |
|
319 if (XmIsManager(w)) { |
|
320 XmManagerWidget man = (XmManagerWidget)w; |
|
321 man->manager.traversal_on = value; |
|
322 } |
|
323 } |
|
324 |
|
325 |
|
326 AwtGraphicsConfigDataPtr |
|
327 getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this) { |
|
328 AwtGraphicsConfigDataPtr adata; |
|
329 jobject gc_object; |
|
330 |
|
331 /* GraphicsConfiguration object of MComponentPeer */ |
|
332 gc_object = (*env)->GetObjectField(env, this, |
|
333 mComponentPeerIDs.graphicsConfig); |
|
334 |
|
335 if (gc_object != NULL) { |
|
336 adata = (AwtGraphicsConfigDataPtr) |
|
337 JNU_GetLongFieldAsPtr(env, gc_object, |
|
338 x11GraphicsConfigIDs.aData); |
|
339 } else { |
|
340 adata = getDefaultConfig(DefaultScreen(awt_display)); |
|
341 } |
|
342 |
|
343 return adata; |
|
344 } |
|
345 |
|
346 AwtGraphicsConfigDataPtr |
|
347 copyGraphicsConfigToPeer(JNIEnv *env, jobject this) { |
|
348 |
|
349 jobject component_object, gc_object; |
|
350 AwtGraphicsConfigDataPtr adata; |
|
351 |
|
352 /** |
|
353 * Copy the GraphicsConfiguration object from Component object to |
|
354 * MComponentPeer object. |
|
355 */ |
|
356 component_object = (*env)->GetObjectField(env, this, |
|
357 mComponentPeerIDs.target); |
|
358 /* GraphicsConfiguration object of Component */ |
|
359 gc_object = (JNU_CallMethodByName(env, NULL, component_object, |
|
360 "getGraphicsConfiguration", |
|
361 "()Ljava/awt/GraphicsConfiguration;")).l; |
|
362 |
|
363 if (gc_object != NULL) { |
|
364 /* Set graphicsConfig field of MComponentPeer */ |
|
365 (*env)->SetObjectField (env, this, |
|
366 mComponentPeerIDs.graphicsConfig, |
|
367 gc_object); |
|
368 adata = (AwtGraphicsConfigDataPtr) |
|
369 JNU_GetLongFieldAsPtr(env, gc_object, |
|
370 x11GraphicsConfigIDs.aData); |
|
371 } else { |
|
372 /* Component was not constructed with a GraphicsConfiguration |
|
373 object */ |
|
374 adata = getDefaultConfig(DefaultScreen(awt_display)); |
|
375 } |
|
376 |
|
377 return adata; |
|
378 } |
|
379 |
|
380 /* |
|
381 * Class: sun_awt_motif_MComponentPeer |
|
382 * Method: getNativeColor |
|
383 * Signature (Ljava/awt/Color;Ljava/awt/GraphicsConfiguration;)I |
|
384 */ |
|
385 JNIEXPORT jint JNICALL Java_sun_awt_motif_MComponentPeer_getNativeColor |
|
386 (JNIEnv *env, jobject this, jobject color, jobject gc_object) { |
|
387 AwtGraphicsConfigDataPtr adata; |
|
388 adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, gc_object, |
|
389 x11GraphicsConfigIDs.aData); |
|
390 return awtJNI_GetColorForVis(env, color, adata); |
|
391 } |
|
392 |
|
393 /* |
|
394 * Class: sun_awt_motif_MComponentPeer |
|
395 * Method: pInitialize |
|
396 * Signature: ()V |
|
397 */ |
|
398 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pInitialize |
|
399 (JNIEnv *env, jobject this) |
|
400 { |
|
401 struct ComponentData *cdata; |
|
402 Widget parent; |
|
403 jobject target; |
|
404 jobject globalRef; |
|
405 EventMask xtMask; |
|
406 jlong awtMask = (jlong) 0; |
|
407 AwtGraphicsConfigDataPtr adata; |
|
408 Boolean initialTraversal = False; |
|
409 |
|
410 globalRef = (jobject) |
|
411 JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.jniGlobalRef); |
|
412 |
|
413 adata = copyGraphicsConfigToPeer(env, this); |
|
414 |
|
415 AWT_LOCK(); |
|
416 |
|
417 target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target); |
|
418 |
|
419 cdata = (struct ComponentData *) |
|
420 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
421 if (JNU_IsNull(env, cdata) || (cdata == NULL)) { |
|
422 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
423 AWT_UNLOCK(); |
|
424 return; |
|
425 } |
|
426 /* Allow FileDialog to have its own traversal policy because |
|
427 * it doesn't interfer with our. |
|
428 */ |
|
429 if (XtIsSubclass(cdata->widget, xmFileSelectionBoxWidgetClass)) { |
|
430 initialTraversal = True; |
|
431 } |
|
432 XtVaSetValues(cdata->widget, |
|
433 XmNx, (*env)->GetIntField(env, target, componentIDs.x), |
|
434 XmNy, (*env)->GetIntField(env, target, componentIDs.y), |
|
435 XmNvisual, adata->awt_visInfo.visual, |
|
436 XmNscreen, ScreenOfDisplay(awt_display, |
|
437 adata->awt_visInfo.screen), |
|
438 /** |
|
439 * From now we keep all but the focus owner widget unable |
|
440 * to receive focus. This will prevent Motif from unexpected |
|
441 * focus transfers. |
|
442 */ |
|
443 XmNtraversalOn, initialTraversal, |
|
444 NULL); |
|
445 |
|
446 |
|
447 /* For all but canvas-style components, pre-process |
|
448 * mouse and keyboard events (which means posting them |
|
449 * to the Java EventQueue before dispatching them to Xt). |
|
450 * For canvas-style components ONLY pre-process mouse events |
|
451 * because the input-method currently relies on key events |
|
452 * being processed by Xt first. |
|
453 */ |
|
454 awtMask = java_awt_AWTEvent_MOUSE_EVENT_MASK | |
|
455 java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK; |
|
456 xtMask = ExposureMask | FocusChangeMask; |
|
457 |
|
458 if (!IsCanvasTypeWidget(cdata->widget)) { |
|
459 awtMask |= java_awt_AWTEvent_KEY_EVENT_MASK; |
|
460 } else { |
|
461 xtMask |= (KeyPressMask | KeyReleaseMask); |
|
462 } |
|
463 XtAddEventHandler(cdata->widget, xtMask, |
|
464 True, awt_canvas_event_handler, globalRef); |
|
465 |
|
466 awt_addWidget(cdata->widget, cdata->widget, globalRef, awtMask); |
|
467 |
|
468 cdata->repaintPending = RepaintPending_NONE; |
|
469 |
|
470 AWT_UNLOCK(); |
|
471 } |
|
472 |
|
473 /** |
|
474 * Updates stacking order of X windows according to the order of children widgets in |
|
475 * parent widget |
|
476 */ |
|
477 void restack(Widget parent) { |
|
478 WidgetList children; |
|
479 int32_t num_children; |
|
480 Window *windows; |
|
481 int32_t num_windows = 0; |
|
482 int32_t i; |
|
483 XtVaGetValues(parent, |
|
484 XmNnumChildren, &num_children, |
|
485 XmNchildren, &children, |
|
486 NULL); |
|
487 |
|
488 windows = (Window *) XtMalloc(num_children * sizeof(Window)); |
|
489 for (i = 0; i < num_children; i++) { |
|
490 if (XtIsRealized(children[i])) { |
|
491 windows[num_windows++] = XtWindow(children[i]); |
|
492 } |
|
493 } |
|
494 XRestackWindows(awt_display, windows, num_windows); |
|
495 XtFree((char *) windows); |
|
496 } |
|
497 |
|
498 /* |
|
499 * Class: sun_awt_motif_MComponentPeer |
|
500 * Method: pShow |
|
501 * Signature: ()V |
|
502 */ |
|
503 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pShow |
|
504 (JNIEnv *env, jobject this) |
|
505 { |
|
506 struct ComponentData *cdata; |
|
507 |
|
508 AWT_LOCK(); |
|
509 cdata = (struct ComponentData *) |
|
510 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
511 if (cdata == NULL || cdata->widget == NULL) { |
|
512 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
513 AWT_UNLOCK(); |
|
514 return; |
|
515 } |
|
516 |
|
517 awt_util_show(cdata->widget); |
|
518 |
|
519 AWT_FLUSH_UNLOCK(); |
|
520 } |
|
521 |
|
522 /* |
|
523 * Class: sun_awt_motif_MComponentPeer |
|
524 * Method: pHide |
|
525 * Signature: ()V |
|
526 */ |
|
527 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pHide |
|
528 (JNIEnv *env, jobject this) |
|
529 { |
|
530 struct ComponentData *cdata; |
|
531 |
|
532 AWT_LOCK(); |
|
533 cdata = (struct ComponentData *) |
|
534 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
535 if (cdata == NULL || cdata->widget == NULL) { |
|
536 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
537 AWT_UNLOCK(); |
|
538 return; |
|
539 } |
|
540 |
|
541 awt_util_hide(cdata->widget); |
|
542 AWT_FLUSH_UNLOCK(); |
|
543 } |
|
544 |
|
545 /* |
|
546 * Class: sun_awt_motif_MComponentPeer |
|
547 * Method: pEnable |
|
548 * Signature: ()V |
|
549 */ |
|
550 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pEnable |
|
551 (JNIEnv *env, jobject this) |
|
552 { |
|
553 struct ComponentData *cdata; |
|
554 |
|
555 AWT_LOCK(); |
|
556 cdata = (struct ComponentData *) |
|
557 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
558 if (cdata == NULL || cdata->widget == NULL) { |
|
559 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
560 AWT_UNLOCK(); |
|
561 return; |
|
562 } |
|
563 awt_util_enable(cdata->widget); |
|
564 AWT_UNLOCK(); |
|
565 } |
|
566 |
|
567 /* |
|
568 * Class: sun_awt_motif_MComponentPeer |
|
569 * Method: pDisable |
|
570 * Signature: ()V |
|
571 */ |
|
572 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pDisable |
|
573 (JNIEnv *env, jobject this) |
|
574 { |
|
575 struct ComponentData *cdata; |
|
576 |
|
577 AWT_LOCK(); |
|
578 cdata = (struct ComponentData *) |
|
579 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
580 if (cdata == NULL || cdata->widget == NULL) { |
|
581 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
582 AWT_UNLOCK(); |
|
583 return; |
|
584 } |
|
585 awt_util_disable(cdata->widget); |
|
586 AWT_FLUSH_UNLOCK(); |
|
587 } |
|
588 |
|
589 /* |
|
590 * Class: sun_awt_motif_MComponentPeer |
|
591 * Method: pReshape |
|
592 * Signature: (IIII)V |
|
593 */ |
|
594 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pReshape |
|
595 (JNIEnv *env, jobject this, jint x, jint y, jint w, jint h) |
|
596 { |
|
597 struct ComponentData *cdata; |
|
598 jint drawState; |
|
599 |
|
600 AWT_LOCK(); |
|
601 cdata = (struct ComponentData *) |
|
602 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
603 if (cdata == NULL || cdata->widget == NULL) { |
|
604 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
605 AWT_UNLOCK(); |
|
606 return; |
|
607 } |
|
608 /* Set the draw state */ |
|
609 drawState = (*env)->GetIntField(env, this, |
|
610 mComponentPeerIDs.drawState); |
|
611 (*env)->SetIntField(env, this, |
|
612 mComponentPeerIDs.drawState, |
|
613 drawState | JAWT_LOCK_BOUNDS_CHANGED | JAWT_LOCK_CLIP_CHANGED); |
|
614 awt_util_reshape(cdata->widget, x, y, w, h); |
|
615 |
|
616 AWT_FLUSH_UNLOCK(); |
|
617 } |
|
618 |
|
619 /* |
|
620 * Class: sun_awt_motif_MComponentPeer |
|
621 * Method: pDispose |
|
622 * Signature: ()V |
|
623 */ |
|
624 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pDispose |
|
625 (JNIEnv *env, jobject this) |
|
626 { |
|
627 struct ComponentData *cdata; |
|
628 |
|
629 AWT_LOCK(); |
|
630 cdata = (struct ComponentData *) |
|
631 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
632 if (cdata == NULL || cdata->widget == NULL) { |
|
633 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
634 AWT_UNLOCK(); |
|
635 return; |
|
636 } |
|
637 |
|
638 XtUnmanageChild(cdata->widget); |
|
639 |
|
640 awt_delWidget(cdata->widget); |
|
641 awt_util_consumeAllXEvents(cdata->widget); |
|
642 awt_util_cleanupBeforeDestroyWidget(cdata->widget); |
|
643 XtDestroyWidget(cdata->widget); |
|
644 |
|
645 free((void *) cdata); |
|
646 (*env)->SetLongField(env,this,mComponentPeerIDs.pData, (int64_t) 0); |
|
647 |
|
648 awtJNI_DeleteGlobalRef(env, this); |
|
649 |
|
650 AWT_UNLOCK(); |
|
651 } |
|
652 |
|
653 /* |
|
654 * Class: sun_awt_motif_MComponentPeer |
|
655 * Method: pMakeCursorVisible |
|
656 * Signature: ()V |
|
657 */ |
|
658 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible |
|
659 (JNIEnv *env, jobject this) |
|
660 { |
|
661 struct ComponentData *cdata; |
|
662 |
|
663 AWT_LOCK(); |
|
664 cdata = (struct ComponentData *) |
|
665 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
666 if (cdata == NULL || cdata->widget == NULL) { |
|
667 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
668 AWT_UNLOCK(); |
|
669 return; |
|
670 } |
|
671 // need to change, may not be needed |
|
672 // awt_util_setCursor(cdata->widget, cdata->cursor); |
|
673 |
|
674 AWT_FLUSH_UNLOCK(); |
|
675 } |
|
676 |
|
677 |
|
678 /* |
|
679 * Call with AWT_LOCK held. |
|
680 */ |
|
681 static jobject |
|
682 MComponentPeer_doGetLocationOnScreen(JNIEnv *env, jobject this) |
|
683 { |
|
684 jobject point = NULL; |
|
685 struct ComponentData *cdata; |
|
686 int32_t x = 0, y = 0; |
|
687 Screen *widget_screen = NULL; |
|
688 Window child_ignored; |
|
689 |
|
690 cdata = (struct ComponentData *) |
|
691 JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData); |
|
692 if (cdata == NULL || cdata->widget == NULL) { |
|
693 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
694 return NULL; |
|
695 } |
|
696 if (!XtIsRealized(cdata->widget)) { |
|
697 JNU_ThrowInternalError(env, "widget not visible on screen"); |
|
698 return NULL; |
|
699 } |
|
700 |
|
701 /* Translate the component to the screen coordinate system */ |
|
702 XtVaGetValues(cdata->widget, XmNscreen, &widget_screen, NULL); |
|
703 XTranslateCoordinates(awt_display, XtWindow(cdata->widget), |
|
704 XRootWindowOfScreen(widget_screen), |
|
705 0, 0, &x, &y, |
|
706 &child_ignored); |
|
707 |
|
708 point = JNU_NewObjectByName(env, "java/awt/Point", "(II)V", |
|
709 (jint)x, (jint)y); |
|
710 if (((*env)->ExceptionOccurred(env)) || JNU_IsNull(env, point)) { |
|
711 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
712 return NULL; |
|
713 } |
|
714 |
|
715 return point; |
|
716 } |
|
717 |
|
718 |
|
719 /* |
|
720 * Class: sun_awt_motif_MComponentPeer |
|
721 * Method: pGetLocationOnScreen |
|
722 * Signature: ()Ljava/awt/Point; |
|
723 */ |
|
724 JNIEXPORT jobject JNICALL |
|
725 Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen(JNIEnv *env, |
|
726 jobject this) |
|
727 { |
|
728 jobject point; |
|
729 |
|
730 AWT_LOCK(); |
|
731 point = MComponentPeer_doGetLocationOnScreen(env, this); |
|
732 AWT_UNLOCK(); |
|
733 return point; |
|
734 } |
|
735 |
|
736 |
|
737 /* |
|
738 * Class: sun_awt_motif_MComponentPeer |
|
739 * Method: pGetLocationOnScreen |
|
740 * Signature: (Ljava/awt/Window;Lsun/awt/motif/MWindowPeer;)Ljava/awt/Point; |
|
741 */ |
|
742 JNIEXPORT jobject JNICALL |
|
743 Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2( |
|
744 JNIEnv *env, jobject this, jobject wtarget, jobject wpeer) |
|
745 { |
|
746 jobject point; |
|
747 struct ComponentData *cdata; |
|
748 struct FrameData *wdata; |
|
749 Screen *widget_screen = NULL; |
|
750 Window child_ignored; |
|
751 int32_t x = 0, y = 0; |
|
752 |
|
753 AWT_LOCK(); |
|
754 |
|
755 wdata = (struct ComponentData *) |
|
756 JNU_GetLongFieldAsPtr(env, wpeer, mComponentPeerIDs.pData); |
|
757 |
|
758 if (wdata == NULL || wdata->winData.comp.widget == NULL) { |
|
759 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
760 AWT_UNLOCK(); |
|
761 return NULL; |
|
762 } |
|
763 if (!XtIsRealized(wdata->winData.comp.widget)) { |
|
764 JNU_ThrowInternalError(env, "widget not visible on screen"); |
|
765 AWT_UNLOCK(); |
|
766 return NULL; |
|
767 } |
|
768 |
|
769 /* |
|
770 * Translate directly if the parent window is already adopted by WM. |
|
771 */ |
|
772 if (wdata->configure_seen) { |
|
773 point = MComponentPeer_doGetLocationOnScreen(env, this); |
|
774 AWT_UNLOCK(); |
|
775 return point; |
|
776 } |
|
777 |
|
778 /* |
|
779 * We are called while the parent window is still not adopted by |
|
780 * WM (but may already be in the process of being reparented). |
|
781 * Translate to the parent and add parent target's (x,y) to avoid |
|
782 * racing with WM shuffling us into the final position. |
|
783 */ |
|
784 cdata = (struct ComponentData *) |
|
785 JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData); |
|
786 |
|
787 if (cdata == &wdata->winData.comp) { /* called for the window itself */ |
|
788 x = y = 0; |
|
789 } |
|
790 else { |
|
791 if (cdata == NULL || cdata->widget == NULL) { |
|
792 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
793 AWT_UNLOCK(); |
|
794 return NULL; |
|
795 } |
|
796 if (!XtIsRealized(cdata->widget)) { |
|
797 JNU_ThrowInternalError(env, "widget not visible on screen"); |
|
798 AWT_UNLOCK(); |
|
799 return NULL; |
|
800 } |
|
801 |
|
802 /* Translate to the outer canvas coordinate system first */ |
|
803 XtVaGetValues(cdata->widget, XmNscreen, &widget_screen, NULL); |
|
804 XTranslateCoordinates(awt_display, XtWindow(cdata->widget), |
|
805 XtWindow(wdata->winData.comp.widget), |
|
806 0, 0, &x, &y, |
|
807 &child_ignored); |
|
808 } |
|
809 |
|
810 x += (*env)->GetIntField(env, wtarget, componentIDs.x); |
|
811 y += (*env)->GetIntField(env, wtarget, componentIDs.y); |
|
812 |
|
813 point = JNU_NewObjectByName(env, "java/awt/Point", "(II)V", |
|
814 (jint)x, (jint)y); |
|
815 if (((*env)->ExceptionOccurred(env)) || JNU_IsNull(env, point)) { |
|
816 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
817 AWT_UNLOCK(); |
|
818 return NULL; |
|
819 } |
|
820 |
|
821 AWT_UNLOCK(); |
|
822 return point; |
|
823 } |
|
824 |
|
825 |
|
826 /* |
|
827 * Class: sun_awt_motif_MComponentPeer |
|
828 * Method: getParent_NoClientCode |
|
829 * Signature: (Ljava/awt/Component)Ljava/awt/Container; |
|
830 * |
|
831 * NOTE: This method may be called by privileged threads. |
|
832 * DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
833 */ |
|
834 JNIEXPORT jobject JNICALL Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode |
|
835 (JNIEnv *env, jclass thisClass, jobject component) |
|
836 { |
|
837 jobject parent = NULL; |
|
838 |
|
839 /* getParent is actually getParent_NoClientCode() */ |
|
840 parent = (*env)->CallObjectMethod(env,component,componentIDs.getParent); |
|
841 DASSERT(!((*env)->ExceptionOccurred(env))); |
|
842 return parent; |
|
843 } |
|
844 |
|
845 /* |
|
846 * Class: sun_awt_motif_MComponentPeer |
|
847 * Method: getComponents_NoClientCode |
|
848 * Signature: (Ljava/awt/Container)[Ljava/awt/Component; |
|
849 * REMIND: Signature is incorrect for returned array value |
|
850 * |
|
851 * NOTE: This method may be called by privileged threads. |
|
852 * DO NOT INVOKE CLIENT CODE ON THIS THREAD! |
|
853 */ |
|
854 JNIEXPORT jobjectArray JNICALL Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode |
|
855 (JNIEnv *env, jclass thisClass, jobject container) |
|
856 { |
|
857 jobjectArray contents = NULL; |
|
858 contents = (*env)->CallObjectMethod( |
|
859 env, container, containerIDs.getComponents); |
|
860 DASSERT(!((*env)->ExceptionOccurred(env))); |
|
861 return contents; |
|
862 } |
|
863 |
|
864 /* |
|
865 * Class: sun_awt_motif_MComponentPeer |
|
866 * Method: pSetForeground |
|
867 * Signature: (Ljava/awt/Color;)V |
|
868 */ |
|
869 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetForeground |
|
870 (JNIEnv *env, jobject this, jobject c) |
|
871 { |
|
872 struct ComponentData *bdata; |
|
873 Pixel color; |
|
874 AwtGraphicsConfigDataPtr adata; |
|
875 |
|
876 if (JNU_IsNull(env, c)) { |
|
877 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
878 return; |
|
879 } |
|
880 AWT_LOCK(); |
|
881 bdata = (struct ComponentData *) |
|
882 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
883 if (bdata == NULL || bdata->widget == NULL) { |
|
884 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
885 AWT_UNLOCK(); |
|
886 return; |
|
887 } |
|
888 |
|
889 adata = getGraphicsConfigFromComponentPeer(env, this); |
|
890 |
|
891 color = (Pixel) awtJNI_GetColorForVis (env, c, adata); |
|
892 XtVaSetValues(bdata->widget, XmNforeground, color, NULL); |
|
893 AWT_FLUSH_UNLOCK(); |
|
894 } |
|
895 |
|
896 /* |
|
897 * Class: sun_awt_motif_MComponentPeer |
|
898 * Method: pSetBackground |
|
899 * Signature: (Ljava/awt/Color;)V |
|
900 */ |
|
901 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetBackground |
|
902 (JNIEnv *env, jobject this, jobject c) |
|
903 { |
|
904 struct ComponentData *bdata; |
|
905 Pixel color; |
|
906 Pixel fg; |
|
907 AwtGraphicsConfigDataPtr adata; |
|
908 |
|
909 if (JNU_IsNull(env, c)) { |
|
910 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
911 return; |
|
912 } |
|
913 AWT_LOCK(); |
|
914 bdata = (struct ComponentData *) |
|
915 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
916 if (bdata == NULL || bdata->widget == NULL) { |
|
917 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
918 AWT_UNLOCK(); |
|
919 return; |
|
920 } |
|
921 |
|
922 adata = getGraphicsConfigFromComponentPeer(env, this); |
|
923 |
|
924 color = (Pixel) awtJNI_GetColorForVis (env, c, adata); |
|
925 XtVaGetValues(bdata->widget, XmNforeground, &fg, NULL); |
|
926 XmChangeColor(bdata->widget, color); |
|
927 XtVaSetValues(bdata->widget, XmNforeground, fg, NULL); |
|
928 AWT_FLUSH_UNLOCK(); |
|
929 } |
|
930 |
|
931 /* |
|
932 * Class: sun_awt_motif_MComponentPeer |
|
933 * Method: pSetScrollbarBackground |
|
934 * Signature: (Ljava/awt/Color;)V |
|
935 */ |
|
936 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground |
|
937 (JNIEnv *env, jobject this, jobject c) |
|
938 { |
|
939 struct ComponentData *bdata; |
|
940 Pixel color; |
|
941 Pixel fg; |
|
942 int32_t i; |
|
943 WidgetList wlist; |
|
944 Cardinal wlen = 0; |
|
945 |
|
946 /* This method propagates the specified background color to the scrollbars in the composite widget. |
|
947 * Used to set background scrollbar color in List, TextArea, ScrollPane to its parent. |
|
948 */ |
|
949 if (JNU_IsNull(env, c)) { |
|
950 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
951 return; |
|
952 } |
|
953 AWT_LOCK(); |
|
954 bdata = (struct ComponentData *) |
|
955 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
956 if (bdata == NULL || bdata->widget == NULL) { |
|
957 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
958 AWT_UNLOCK(); |
|
959 return; |
|
960 } |
|
961 if (!XtIsComposite(bdata->widget)) { |
|
962 AWT_UNLOCK(); |
|
963 return; |
|
964 } |
|
965 color = (Pixel) awtJNI_GetColor(env, c); |
|
966 |
|
967 XtVaGetValues(bdata->widget, |
|
968 XmNchildren, &wlist, |
|
969 XmNnumChildren, &wlen, |
|
970 NULL); |
|
971 if (wlen > 0) { /* this test doesn't make much sense, since wlen |
|
972 is a Cardinal and cardinal is unsigned int... */ |
|
973 for (i=0; i < wlen; i++) { |
|
974 if (XtIsSubclass(wlist[i], xmScrollBarWidgetClass)) { |
|
975 XtVaGetValues(wlist[i], XmNforeground, &fg, NULL); |
|
976 XmChangeColor(wlist[i], color); |
|
977 XtVaSetValues(wlist[i], XmNforeground, fg, NULL); |
|
978 } |
|
979 } |
|
980 XtVaGetValues(bdata->widget, XmNforeground, &fg, NULL); |
|
981 XmChangeColor(bdata->widget, color); |
|
982 XtVaSetValues(bdata->widget, XmNforeground, fg, NULL); |
|
983 } |
|
984 |
|
985 AWT_FLUSH_UNLOCK(); |
|
986 } |
|
987 |
|
988 /* |
|
989 * Class: sun_awt_motif_MComponentPeer |
|
990 * Method: pSetInnerForeground |
|
991 * Signature: (Ljava/awt/Color;)V |
|
992 */ |
|
993 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetInnerForeground |
|
994 (JNIEnv *env, jobject this, jobject c) |
|
995 { |
|
996 struct ComponentData *bdata; |
|
997 Pixel color; |
|
998 |
|
999 /* This method propagates the specified foreground color to all its children. |
|
1000 * It is called to set foreground color in List, TextArea, ScrollPane. |
|
1001 */ |
|
1002 if (JNU_IsNull(env, c)) { |
|
1003 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
1004 return; |
|
1005 } |
|
1006 AWT_LOCK(); |
|
1007 bdata = (struct ComponentData *) |
|
1008 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
1009 if (bdata == NULL || bdata->widget == NULL) { |
|
1010 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
1011 AWT_UNLOCK(); |
|
1012 return; |
|
1013 } |
|
1014 color = awtJNI_GetColor(env, c); |
|
1015 awt_util_mapChildren(bdata->widget, changeForeground, 1, (void *) color); |
|
1016 AWT_FLUSH_UNLOCK(); |
|
1017 } |
|
1018 |
|
1019 /* |
|
1020 * Class: sun_awt_motif_MComponentPeer |
|
1021 * Method: pSetFont |
|
1022 * Signature: (Ljava/awt/Font;)V |
|
1023 */ |
|
1024 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetFont |
|
1025 (JNIEnv *env, jobject this, jobject f) |
|
1026 { |
|
1027 struct ComponentData *cdata; |
|
1028 |
|
1029 struct changeFontInfo finfo = { NULL, FALSE, NULL, 0, |
|
1030 FALSE, FALSE, NULL, NULL }; |
|
1031 |
|
1032 if (JNU_IsNull(env, f)) { |
|
1033 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
1034 return; |
|
1035 } |
|
1036 AWT_LOCK(); |
|
1037 |
|
1038 cdata = (struct ComponentData *) |
|
1039 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
1040 if (cdata == NULL || cdata->widget == NULL) { |
|
1041 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
1042 AWT_UNLOCK(); |
|
1043 return; |
|
1044 } |
|
1045 |
|
1046 finfo.env = env; |
|
1047 finfo.fObj = f; |
|
1048 awt_util_mapChildren(cdata->widget, changeFont, 1, (void *)&finfo); |
|
1049 if (!finfo.error && finfo.fontList != NULL) { |
|
1050 XmFontListFree(finfo.fontList); |
|
1051 } |
|
1052 |
|
1053 AWT_FLUSH_UNLOCK(); |
|
1054 } /* MComponentPeer.pSetFont() */ |
|
1055 |
|
1056 /* |
|
1057 * Class: sun_awt_motif_MComponentPeer |
|
1058 * Method: setTargetBackground |
|
1059 * Signature: (Ljava/awt/Color;)V |
|
1060 */ |
|
1061 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_setTargetBackground |
|
1062 (JNIEnv *env, jobject this, jobject c) |
|
1063 { |
|
1064 jobject target = NULL; |
|
1065 |
|
1066 if ((*env)->EnsureLocalCapacity(env, 1) < 0) { |
|
1067 return; |
|
1068 } |
|
1069 |
|
1070 target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target); |
|
1071 (*env)->SetObjectField(env, target, componentIDs.background, c); |
|
1072 (*env)->DeleteLocalRef(env, target); |
|
1073 } |
|
1074 |
|
1075 /* |
|
1076 * Class: sun_awt_motif_MComponentPeer |
|
1077 * Method: pSetCursor |
|
1078 * Signature: (Ljava/awt/Cursor;)V |
|
1079 */ |
|
1080 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetCursor |
|
1081 (JNIEnv *env, jobject this, jobject cursor) |
|
1082 { |
|
1083 Cursor xcursor; |
|
1084 struct ComponentData *cdata; |
|
1085 |
|
1086 AWT_LOCK(); |
|
1087 |
|
1088 cdata = (struct ComponentData *) |
|
1089 JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData); |
|
1090 if (cdata == NULL || cdata->widget == NULL || JNU_IsNull(env, cursor)) { |
|
1091 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
1092 AWT_UNLOCK(); |
|
1093 return; |
|
1094 } |
|
1095 |
|
1096 awt_util_setCursor(cdata->widget, getCursor(env, cursor)); |
|
1097 |
|
1098 AWT_FLUSH_UNLOCK(); |
|
1099 } |
|
1100 |
|
1101 /* |
|
1102 * Class: sun_awt_motif_MComponentPeer |
|
1103 * Method: nativeHandleEvent |
|
1104 * Signature: (Ljava/awt/AWTEvent;)V |
|
1105 */ |
|
1106 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_nativeHandleEvent |
|
1107 (JNIEnv *env, jobject this, jobject event) |
|
1108 { |
|
1109 extern void awt_modify_KeyEvent(JNIEnv *env, XEvent * xevent, jobject jevent); |
|
1110 jbyteArray array; |
|
1111 XEvent *xevent; |
|
1112 Widget widget = NULL; |
|
1113 Boolean consumed; |
|
1114 |
|
1115 if (JNU_IsNull(env, event)) { |
|
1116 return; |
|
1117 } |
|
1118 AWT_LOCK(); |
|
1119 |
|
1120 consumed = (*env)->GetBooleanField(env, event, awtEventIDs.consumed); |
|
1121 |
|
1122 /* |
|
1123 * Fix for bug 4280561 |
|
1124 * |
|
1125 * If a menu is up, we must dispatch all XEvents, to allow |
|
1126 * mouse grabs to be released and prevent server hangs. |
|
1127 */ |
|
1128 consumed = consumed && !awt_util_focusIsOnMenu(awt_display); |
|
1129 |
|
1130 if (consumed) { |
|
1131 AWT_UNLOCK(); |
|
1132 return; |
|
1133 } |
|
1134 |
|
1135 array = (jbyteArray)(*env)->GetObjectField(env, event, awtEventIDs.bdata); |
|
1136 if (array == NULL) { |
|
1137 AWT_UNLOCK(); |
|
1138 return; |
|
1139 } |
|
1140 |
|
1141 xevent = (XEvent *)(*env)->GetByteArrayElements(env, array, NULL); |
|
1142 if (xevent == NULL) { |
|
1143 AWT_UNLOCK(); |
|
1144 return; |
|
1145 } |
|
1146 |
|
1147 switch ((*env)->GetIntField(env, event, awtEventIDs.id)) { |
|
1148 case java_awt_event_KeyEvent_KEY_RELEASED: |
|
1149 case java_awt_event_KeyEvent_KEY_PRESSED: |
|
1150 awt_modify_KeyEvent(env, xevent, event); |
|
1151 if ((*env)->GetBooleanField(env, event, componentIDs.isProxyActive) == JNI_TRUE) { |
|
1152 xevent->xany.send_event = SPECIAL_KEY_EVENT; |
|
1153 } |
|
1154 break; |
|
1155 default: |
|
1156 break; |
|
1157 } |
|
1158 widget = XtWindowToWidget(awt_display, xevent->xany.window); |
|
1159 |
|
1160 if (!((widget == NULL) || (!XtIsObject(widget)) || |
|
1161 (widget->core.being_destroyed))) { |
|
1162 /* Queue the event to be handled by the AWT-Motif thread */ |
|
1163 if (!IsCanvasTypeWidget(widget)) { |
|
1164 awt_put_back_event(env, xevent); |
|
1165 } |
|
1166 } |
|
1167 |
|
1168 (*env)->ReleaseByteArrayElements(env, array, (jbyte *)xevent, JNI_ABORT); |
|
1169 (*env)->DeleteLocalRef(env, array); |
|
1170 |
|
1171 AWT_UNLOCK(); |
|
1172 return; |
|
1173 } |
|
1174 |
|
1175 // Returns the widget from parent's hierarchy which should be |
|
1176 // used for focus operations. This widget is stored in WidgetInfo |
|
1177 // structure and should be prepared by the appropriate component |
|
1178 // type constructor |
|
1179 Widget getFocusWidget(Widget parent) { |
|
1180 struct WidgetInfo * winfo = NULL; |
|
1181 DASSERT(parent != NULL); |
|
1182 if (parent == NULL) { |
|
1183 return NULL; |
|
1184 } |
|
1185 winfo = findWidgetInfo(parent); |
|
1186 if (winfo == NULL) { |
|
1187 return NULL; |
|
1188 } |
|
1189 return winfo->widget; |
|
1190 } |
|
1191 |
|
1192 |
|
1193 // Returns value of widget's traversalOn property |
|
1194 Boolean getTraversal(Widget w) { |
|
1195 if (w == NULL) { |
|
1196 return False; |
|
1197 } |
|
1198 if (XmIsPrimitive(w)) { |
|
1199 XmPrimitiveWidget prim = (XmPrimitiveWidget)w; |
|
1200 return prim->primitive.traversal_on; |
|
1201 } |
|
1202 if (XmIsManager(w)) { |
|
1203 XmManagerWidget man = (XmManagerWidget)w; |
|
1204 return man->manager.traversal_on; |
|
1205 } |
|
1206 return False; |
|
1207 } |
|
1208 |
|
1209 |
|
1210 void processTree(Widget from, Widget to, Boolean action) { |
|
1211 // Workhorse function that makes sure that the only widgets |
|
1212 // which have traversalOn == true are the ones on the path from |
|
1213 // shell to current focus widget. Function uses two widgets - |
|
1214 // the one which is supposed to have focus currently(from) and |
|
1215 // the one which will receive focus(to). Function disables and |
|
1216 // enables the appropriate widgets so 'to' can become focus owner. |
|
1217 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1218 int32_t count_from = 0, count_to = 0; |
|
1219 Widget parent_from = NULL, parent_to = NULL; |
|
1220 Widget * parents_from = NULL, * parents_to = NULL; |
|
1221 int32_t index = 0; |
|
1222 |
|
1223 // Count amount of parents up the tree from widget |
|
1224 parent_from = from; |
|
1225 while (parent_from != NULL) { |
|
1226 parent_from = XtParent(parent_from); |
|
1227 count_from++; |
|
1228 } |
|
1229 parent_to = to; |
|
1230 while (parent_to != NULL) { |
|
1231 parent_to = XtParent(parent_to); |
|
1232 count_to++; |
|
1233 } |
|
1234 |
|
1235 // Store all the parents in the list. Both list wittingly |
|
1236 // have common parts starting from the beginning. We need |
|
1237 // to find the end of this common part. |
|
1238 parents_from = (Widget*)malloc(count_from*sizeof(Widget*)); |
|
1239 parents_to = (Widget*)malloc(count_to*sizeof(Widget*)); |
|
1240 parent_from = from; |
|
1241 index = count_from; |
|
1242 while (parent_from != NULL) { |
|
1243 parents_from[index-1] = parent_from; |
|
1244 parent_from = XtParent(parent_from); |
|
1245 index--; |
|
1246 } |
|
1247 parent_to = to; |
|
1248 index = count_to; |
|
1249 while (parent_to != NULL) { |
|
1250 parents_to[index-1] = parent_to; |
|
1251 parent_to = XtParent(parent_to); |
|
1252 index--; |
|
1253 } |
|
1254 |
|
1255 // Process parents list. Find common part which is usually doesn't |
|
1256 // require changes. At the exit of the cycle index will point |
|
1257 // to the first widget which requeires the change. |
|
1258 |
|
1259 if (from != NULL && to != NULL) { |
|
1260 do { |
|
1261 if (index >= count_from-1 || index >= count_to-1) { |
|
1262 break; |
|
1263 } |
|
1264 if (parents_from[index] == parents_to[index]) |
|
1265 { |
|
1266 if (XtIsShell(parents_from[index])) { |
|
1267 index++; |
|
1268 continue; |
|
1269 } |
|
1270 if (action) { |
|
1271 if (getTraversal(parents_from[index])) { |
|
1272 index++; |
|
1273 } else { |
|
1274 break; |
|
1275 } |
|
1276 } else { |
|
1277 index++; |
|
1278 } |
|
1279 } else { |
|
1280 break; |
|
1281 } |
|
1282 } while (True); |
|
1283 } |
|
1284 |
|
1285 |
|
1286 if (action) { // enable the tree starting from uncommon part till 'to' |
|
1287 if (to != NULL) { |
|
1288 while (index < count_to - 1) { |
|
1289 if (!getTraversal(parents_to[index])) { |
|
1290 XtVaSetValues(parents_to[index], XmNtraversalOn, True, NULL); |
|
1291 } |
|
1292 index++; |
|
1293 } |
|
1294 XtVaSetValues(to, XmNtraversalOn, True, NULL); |
|
1295 } |
|
1296 } else if (from != NULL) { |
|
1297 // disable the tree starting from uncommon part to 'from' |
|
1298 if (parents_from[index] == parents_to[index]) { |
|
1299 if (index == count_from - 1) { |
|
1300 // 'from' is one of the parents of 'to' - no need |
|
1301 // to disable 'from' |
|
1302 goto skip_disable; |
|
1303 } |
|
1304 index++; |
|
1305 } |
|
1306 while (index < count_from - 1) { |
|
1307 if (!XmIsGadget(parents_from[index]) && !XtIsShell(parents_from[index])) { |
|
1308 setTraversal(parents_from[index], False); |
|
1309 } |
|
1310 index++; |
|
1311 } |
|
1312 if (!XmIsGadget(from)) { |
|
1313 setTraversal(parents_from[index], False); |
|
1314 } |
|
1315 } |
|
1316 skip_disable: |
|
1317 free(parents_from); |
|
1318 free(parents_to); |
|
1319 } |
|
1320 |
|
1321 /* |
|
1322 * Class: sun_awt_motif_MComponentPeer |
|
1323 * Method: requestFocus |
|
1324 * Signature: (Ljava/awt/Component;ZZJ)Z |
|
1325 */ |
|
1326 JNIEXPORT jboolean JNICALL Java_sun_awt_motif_MComponentPeer__1requestFocus |
|
1327 (JNIEnv *env, jobject this, jobject lightweightChild, jboolean temporary, |
|
1328 jboolean focusedWindowChangeAllowed, jlong time, jobject cause) |
|
1329 { |
|
1330 struct ComponentData *bdata; |
|
1331 Boolean result; |
|
1332 jobject target; |
|
1333 jint retval; |
|
1334 Widget currentOwner = NULL; |
|
1335 jobject curPeer = NULL; |
|
1336 Widget shell; |
|
1337 Widget widgetToFocus = NULL; |
|
1338 |
|
1339 AWT_LOCK(); |
|
1340 |
|
1341 bdata = (struct ComponentData *) |
|
1342 JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData); |
|
1343 if (bdata == NULL || bdata->widget == NULL) { |
|
1344 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
1345 AWT_UNLOCK(); |
|
1346 return JNI_FALSE; |
|
1347 } |
|
1348 if ((*env)->EnsureLocalCapacity(env, 1) < 0) { |
|
1349 AWT_UNLOCK(); |
|
1350 return JNI_FALSE; |
|
1351 } |
|
1352 |
|
1353 target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target); |
|
1354 /* Don't need to free target explicitly. That will happen automatically |
|
1355 when this function returns. */ |
|
1356 |
|
1357 if (target == NULL) { |
|
1358 JNU_ThrowNullPointerException(env, "NullPointerException"); |
|
1359 AWT_UNLOCK(); |
|
1360 return JNI_FALSE; |
|
1361 } |
|
1362 |
|
1363 /* The X11 implementation does not permit cross-Window focus transfers, |
|
1364 so always pass JNI_FALSE for that parameter. */ |
|
1365 retval = (*env)->CallStaticIntMethod |
|
1366 (env, keyboardFocusManagerIDs.keyboardFocusManagerCls, |
|
1367 keyboardFocusManagerIDs.shouldNativelyFocusHeavyweightMID, |
|
1368 target, lightweightChild, temporary, JNI_FALSE, time, cause); |
|
1369 |
|
1370 if (retval == java_awt_KeyboardFocusManager_SNFH_SUCCESS_HANDLED) { |
|
1371 AWT_UNLOCK(); |
|
1372 (*env)->DeleteLocalRef(env, target); |
|
1373 return JNI_TRUE; |
|
1374 } |
|
1375 if (retval == java_awt_KeyboardFocusManager_SNFH_FAILURE) { |
|
1376 AWT_UNLOCK(); |
|
1377 (*env)->DeleteLocalRef(env, target); |
|
1378 return JNI_FALSE; |
|
1379 } |
|
1380 |
|
1381 DASSERT(retval == java_awt_KeyboardFocusManager_SNFH_SUCCESS_PROCEED); |
|
1382 |
|
1383 shell = getShellWidget(bdata->widget); |
|
1384 currentOwner = XmGetFocusWidget(shell); |
|
1385 |
|
1386 widgetToFocus = getFocusWidget(bdata->widget); |
|
1387 |
|
1388 globalClearFocusPath(shell); |
|
1389 |
|
1390 // Prepare widgets tree |
|
1391 processTree(currentOwner, widgetToFocus, False); |
|
1392 processTree(currentOwner, widgetToFocus, True); |
|
1393 |
|
1394 /* |
|
1395 Fix for bug 4157017: replace XmProcessTraversal with |
|
1396 XtSetKeyboardFocus because XmProcessTraversal does not allow |
|
1397 focus to go to non-visible widgets. |
|
1398 |
|
1399 (There is a corresponding change to awt_MToolkit.c:dispatchToWidget) |
|
1400 |
|
1401 I found a last minute problem with this fix i.e. it broke the test |
|
1402 case for bug 4053856. XmProcessTraversal does something else (that |
|
1403 XtSetKeyboardFocus does not do) that stops this test case from |
|
1404 failing. So, as I do not have time to investigate, and having |
|
1405 both XmProcessTraversal and XtSetKeyboardFocus fixes 4157017 and |
|
1406 4053856 and should be harmless (reviewer agreed), we have both |
|
1407 below - XmProcessTraversal AND XtSetKeyboardFocus. |
|
1408 */ |
|
1409 result = XmProcessTraversal(widgetToFocus, XmTRAVERSE_CURRENT); |
|
1410 if (!result) |
|
1411 { |
|
1412 Widget w = widgetToFocus; |
|
1413 |
|
1414 shell = getShellWidget(w); |
|
1415 XtSetKeyboardFocus(shell, w); |
|
1416 } |
|
1417 /* end 4157017 */ |
|
1418 |
|
1419 // Because Motif focus callbacks are disabled we need to generate |
|
1420 // the required events by ourselves. |
|
1421 // First, check if the current focused widget has the entry in focus |
|
1422 // list. If not, add it because it is required for further processing |
|
1423 if (currentOwner != NULL) { |
|
1424 jobject last = NULL; |
|
1425 curPeer = findPeer(¤tOwner); |
|
1426 if (curPeer == NULL) { |
|
1427 currentOwner = findTopLevelByShell(currentOwner); |
|
1428 if (currentOwner != NULL) { |
|
1429 curPeer = findPeer(¤tOwner); |
|
1430 } |
|
1431 } |
|
1432 if (curPeer != NULL) { |
|
1433 curPeer = (*env)->GetObjectField(env, curPeer, mComponentPeerIDs.target); |
|
1434 if (focusList == NULL) { |
|
1435 awt_canvas_addToFocusListWithDuplicates(curPeer, JNI_TRUE); |
|
1436 } else { |
|
1437 last = (*env)->NewLocalRef(env, focusList->requestor); |
|
1438 if (!(*env)->IsSameObject(env, last, curPeer)) { |
|
1439 awt_canvas_addToFocusList(curPeer); |
|
1440 } |
|
1441 if (!JNU_IsNull(env, last)) { |
|
1442 (*env)->DeleteLocalRef(env, last); |
|
1443 } |
|
1444 } |
|
1445 (*env)->DeleteLocalRef(env, curPeer); |
|
1446 } |
|
1447 } |
|
1448 awt_canvas_addToFocusList(target); |
|
1449 |
|
1450 // If new and current focus owners are the same do not generate FOCUS_LOST |
|
1451 // event because we don't expect it, but generate FOCUS_GAIN because we |
|
1452 // wait for it. |
|
1453 if ( currentOwner != NULL && !JNU_IsNull(env, curPeer) && |
|
1454 !(*env)->IsSameObject(env, curPeer, target)) { |
|
1455 callFocusHandler(currentOwner, FocusOut, cause); |
|
1456 } |
|
1457 callFocusHandler(widgetToFocus, FocusIn, cause); |
|
1458 (*env)->DeleteLocalRef(env, target); |
|
1459 |
|
1460 AWT_FLUSH_UNLOCK(); |
|
1461 return JNI_TRUE; |
|
1462 } |
|
1463 |
|
1464 Dimension |
|
1465 awt_computeIndicatorSize(struct FontData *fdata) |
|
1466 { |
|
1467 int32_t height; |
|
1468 int32_t acc; |
|
1469 int32_t i; |
|
1470 |
|
1471 if (fdata == (struct FontData *) NULL) |
|
1472 return MOTIF_XmINVALID_DIMENSION; |
|
1473 |
|
1474 /* |
|
1475 * If Java font maps into single platform font - there's no |
|
1476 * problem. Let Motif use its usual calculations in this case. |
|
1477 */ |
|
1478 if (fdata->charset_num == 1) |
|
1479 return MOTIF_XmINVALID_DIMENSION; |
|
1480 |
|
1481 acc = 0; |
|
1482 for (i = 0; i < fdata->charset_num; ++i) { |
|
1483 XFontStruct *xfont = fdata->flist[i].xfont; |
|
1484 acc += xfont->ascent + xfont->descent; |
|
1485 } |
|
1486 |
|
1487 height = acc / fdata->charset_num; |
|
1488 if (height < MOTIF_XmDEFAULT_INDICATOR_DIM) |
|
1489 height = MOTIF_XmDEFAULT_INDICATOR_DIM; |
|
1490 |
|
1491 return height; |
|
1492 } |
|
1493 |
|
1494 Dimension |
|
1495 awt_adjustIndicatorSizeForMenu(Dimension indSize) |
|
1496 { |
|
1497 if (indSize == 0 || indSize == MOTIF_XmINVALID_DIMENSION) |
|
1498 return MOTIF_XmINVALID_DIMENSION; /* let motif do the job */ |
|
1499 |
|
1500 /* Indicators in menus are smaller. |
|
1501 2/3 is a magic number from Motif internals. */ |
|
1502 indSize = indSize * 2 / 3; |
|
1503 if (indSize < MOTIF_XmDEFAULT_INDICATOR_DIM) |
|
1504 indSize = MOTIF_XmDEFAULT_INDICATOR_DIM; |
|
1505 |
|
1506 return indSize; |
|
1507 } |
|
1508 |
|
1509 /* |
|
1510 * Class: sun_awt_motif_MComponentPeer |
|
1511 * Method: getWindow |
|
1512 * Signature: (J)J |
|
1513 */ |
|
1514 JNIEXPORT jlong JNICALL Java_sun_awt_motif_MComponentPeer_getWindow |
|
1515 (JNIEnv *env, jobject this, jlong pData) |
|
1516 { |
|
1517 jlong ret = (jlong)0; |
|
1518 struct ComponentData* cdata; |
|
1519 cdata = (struct ComponentData*)pData; |
|
1520 AWT_LOCK(); |
|
1521 ret = (jlong)XtWindow(cdata->widget); |
|
1522 AWT_FLUSH_UNLOCK(); |
|
1523 return ret; |
|
1524 } |
|
1525 |
|
1526 /* |
|
1527 * Class: sun_awt_motif_MComponentPeer |
|
1528 * Method: restore_Focus |
|
1529 * Signature: ()V |
|
1530 */ |
|
1531 JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_restoreFocus |
|
1532 (JNIEnv *env, jobject this) |
|
1533 { |
|
1534 jobject focus_peer; |
|
1535 AWT_LOCK(); |
|
1536 |
|
1537 focus_peer = awt_canvas_getFocusOwnerPeer(); |
|
1538 if (!JNU_IsNull(env, focus_peer)) { |
|
1539 struct ComponentData *bdata; |
|
1540 Boolean result; |
|
1541 |
|
1542 bdata = (struct ComponentData *) |
|
1543 JNU_GetLongFieldAsPtr(env, focus_peer, mComponentPeerIDs.pData); |
|
1544 if (bdata != NULL) { |
|
1545 Widget widgetToFocus = getFocusWidget(bdata->widget); |
|
1546 result = XmProcessTraversal(widgetToFocus, XmTRAVERSE_CURRENT); |
|
1547 if (!result) |
|
1548 { |
|
1549 XtSetKeyboardFocus(getShellWidget(widgetToFocus), widgetToFocus); |
|
1550 } |
|
1551 } |
|
1552 } |
|
1553 (*env)->DeleteLocalRef(env, focus_peer); |
|
1554 |
|
1555 AWT_UNLOCK(); |
|
1556 } |
|
1557 |
|
1558 JNIEXPORT jboolean JNICALL |
|
1559 Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer( |
|
1560 JNIEnv * env, jclass cls, jobject heavyweight, jobject descendant, |
|
1561 jboolean temporary, jboolean focusedWindowChangeAllowed, jlong time) |
|
1562 { |
|
1563 return (*env)->CallStaticBooleanMethod(env, keyboardFocusManagerIDs.keyboardFocusManagerCls, |
|
1564 keyboardFocusManagerIDs.processSynchronousTransferMID, |
|
1565 heavyweight, descendant, temporary, |
|
1566 focusedWindowChangeAllowed, time); |
|
1567 } |
|
1568 /* |
|
1569 * Class: sun_awt_motif_MComponentPeer |
|
1570 * Method: getNativeFocusedWindow |
|
1571 * Signature: ()Ljava/awt/Window; |
|
1572 */ |
|
1573 JNIEXPORT jobject JNICALL |
|
1574 Java_sun_awt_motif_MComponentPeer_getNativeFocusedWindow |
|
1575 (JNIEnv *env, jclass cls) |
|
1576 { |
|
1577 jobject l_peer; |
|
1578 |
|
1579 AWT_LOCK(); |
|
1580 l_peer = awt_canvas_getFocusedWindowPeer(); |
|
1581 AWT_UNLOCK(); |
|
1582 |
|
1583 return (l_peer != NULL) |
|
1584 ? (*env)->GetObjectField(env, l_peer, mComponentPeerIDs.target) |
|
1585 : NULL; |
|
1586 } |
|
1587 |
|
1588 /** |
|
1589 * Makes sure that child has correct index inside parent |
|
1590 * Note: there was a short time when we were counting index in the |
|
1591 * opposite order when it seemed that X and Java z-order notions |
|
1592 * are different. Now we know they are not: last component is |
|
1593 * painted first and appears below all other components with |
|
1594 * smaller indices. |
|
1595 */ |
|
1596 void ensureIndex(Widget parent, Widget child, int index) { |
|
1597 WidgetList children; |
|
1598 int32_t num_children; |
|
1599 int32_t i; |
|
1600 |
|
1601 if (parent == NULL) { |
|
1602 return; |
|
1603 } |
|
1604 if (child == NULL) { |
|
1605 return; |
|
1606 } |
|
1607 XtVaGetValues(parent, |
|
1608 XmNnumChildren, &num_children, |
|
1609 XmNchildren, &children, |
|
1610 NULL); |
|
1611 if (index < 0 || index >= num_children) { |
|
1612 return; |
|
1613 } |
|
1614 if (children[index] != child) { |
|
1615 for (i = 0; i < num_children; i++) { |
|
1616 if (children[i] == child) { |
|
1617 break; |
|
1618 } |
|
1619 } |
|
1620 if (i < num_children) { |
|
1621 Widget temp = children[index]; |
|
1622 children[index] = child; |
|
1623 children[i] = temp; |
|
1624 } |
|
1625 } |
|
1626 } |
|
1627 |
|
1628 JNIEXPORT void JNICALL |
|
1629 Java_sun_awt_motif_MPanelPeer_pEnsureIndex(JNIEnv * env, jobject this, jobject child, jint index) { |
|
1630 struct ComponentData *cdata; |
|
1631 Widget w_parent, w_child; |
|
1632 AWT_LOCK(); |
|
1633 |
|
1634 cdata = (struct ComponentData *) |
|
1635 JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData); |
|
1636 w_parent = cdata->widget; |
|
1637 |
|
1638 cdata = (struct ComponentData *) |
|
1639 JNU_GetLongFieldAsPtr(env, child, mComponentPeerIDs.pData); |
|
1640 w_child = cdata->widget; |
|
1641 ensureIndex(w_parent, w_child, index); |
|
1642 AWT_UNLOCK(); |
|
1643 } |
|
1644 |
|
1645 JNIEXPORT void JNICALL |
|
1646 Java_sun_awt_motif_MPanelPeer_pRestack(JNIEnv * env, jobject this) { |
|
1647 struct ComponentData *cdata; |
|
1648 Widget w_parent; |
|
1649 AWT_LOCK(); |
|
1650 |
|
1651 cdata = (struct ComponentData *) |
|
1652 JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData); |
|
1653 w_parent = cdata->widget; |
|
1654 restack(w_parent); |
|
1655 AWT_UNLOCK(); |
|
1656 } |
|