Merge jdk7-b36
authorlana
Fri, 19 Sep 2008 19:38:12 -0700
changeset 565134fd1a656ea
parent 539 16818689f727
parent 564 9d5e52760d53
child 566 73b3e1a40bdf
child 592 b54ba7058851
child 642 af375b98f9b3
Merge
src/solaris/classes/sun/awt/motif/MButtonPeer.java
src/solaris/classes/sun/awt/motif/MCanvasPeer.java
src/solaris/classes/sun/awt/motif/MCheckboxMenuItemPeer.java
src/solaris/classes/sun/awt/motif/MCheckboxPeer.java
src/solaris/classes/sun/awt/motif/MChoicePeer.java
src/solaris/classes/sun/awt/motif/MComponentPeer.java
src/solaris/classes/sun/awt/motif/MCustomCursor.java
src/solaris/classes/sun/awt/motif/MDataTransferer.java
src/solaris/classes/sun/awt/motif/MDialogPeer.java
src/solaris/classes/sun/awt/motif/MDragSourceContextPeer.java
src/solaris/classes/sun/awt/motif/MDropTargetContextPeer.java
src/solaris/classes/sun/awt/motif/MEmbedCanvasPeer.java
src/solaris/classes/sun/awt/motif/MEmbeddedFrame.java
src/solaris/classes/sun/awt/motif/MEmbeddedFramePeer.java
src/solaris/classes/sun/awt/motif/MFileDialogPeer.java
src/solaris/classes/sun/awt/motif/MFramePeer.java
src/solaris/classes/sun/awt/motif/MGlobalCursorManager.java
src/solaris/classes/sun/awt/motif/MInputMethod.java
src/solaris/classes/sun/awt/motif/MInputMethodControl.java
src/solaris/classes/sun/awt/motif/MInputMethodDescriptor.java
src/solaris/classes/sun/awt/motif/MLabelPeer.java
src/solaris/classes/sun/awt/motif/MListPeer.java
src/solaris/classes/sun/awt/motif/MMenuBarPeer.java
src/solaris/classes/sun/awt/motif/MMenuItemPeer.java
src/solaris/classes/sun/awt/motif/MMenuPeer.java
src/solaris/classes/sun/awt/motif/MMouseDragGestureRecognizer.java
src/solaris/classes/sun/awt/motif/MPanelPeer.java
src/solaris/classes/sun/awt/motif/MPopupMenuPeer.java
src/solaris/classes/sun/awt/motif/MRobotPeer.java
src/solaris/classes/sun/awt/motif/MScrollPanePeer.java
src/solaris/classes/sun/awt/motif/MScrollbarPeer.java
src/solaris/classes/sun/awt/motif/MTextAreaPeer.java
src/solaris/classes/sun/awt/motif/MTextFieldPeer.java
src/solaris/classes/sun/awt/motif/MWindowPeer.java
src/solaris/classes/sun/awt/motif/X11Clipboard.java
src/solaris/classes/sun/awt/motif/X11DragSourceContextPeer.java
src/solaris/classes/sun/awt/motif/X11DropTargetContextPeer.java
src/solaris/classes/sun/awt/motif/X11Selection.java
src/solaris/classes/sun/awt/motif/X11SelectionHolder.java
src/solaris/native/sun/awt/awt_Button.c
src/solaris/native/sun/awt/awt_Canvas.c
src/solaris/native/sun/awt/awt_Checkbox.c
src/solaris/native/sun/awt/awt_Choice12.c
src/solaris/native/sun/awt/awt_Choice21.c
src/solaris/native/sun/awt/awt_Component.c
src/solaris/native/sun/awt/awt_Cursor.c
src/solaris/native/sun/awt/awt_DataTransferer.c
src/solaris/native/sun/awt/awt_DataTransferer.h
src/solaris/native/sun/awt/awt_FileDialog.c
src/solaris/native/sun/awt/awt_GlobalCursorManager.c
src/solaris/native/sun/awt/awt_KeyboardFocusManager.c
src/solaris/native/sun/awt/awt_Label.c
src/solaris/native/sun/awt/awt_List.c
src/solaris/native/sun/awt/awt_Menu.c
src/solaris/native/sun/awt/awt_Menu.h
src/solaris/native/sun/awt/awt_MenuBar.c
src/solaris/native/sun/awt/awt_MenuBar.h
src/solaris/native/sun/awt/awt_MenuComponent.c
src/solaris/native/sun/awt/awt_MenuItem.c
src/solaris/native/sun/awt/awt_PopupMenu.c
src/solaris/native/sun/awt/awt_ScrollPane.c
src/solaris/native/sun/awt/awt_Scrollbar.c
src/solaris/native/sun/awt/awt_Selection.c
src/solaris/native/sun/awt/awt_TextArea.c
src/solaris/native/sun/awt/awt_TextArea.h
src/solaris/native/sun/awt/awt_TextField.c
src/solaris/native/sun/awt/awt_TextField.h
src/solaris/native/sun/awt/awt_TopLevel.c
src/solaris/native/sun/awt/awt_XmDnD.c
src/solaris/native/sun/awt/awt_XmDnD.h
src/solaris/native/sun/awt/awt_dnd.c
src/solaris/native/sun/awt/awt_dnd.h
src/solaris/native/sun/awt/awt_dnd_ds.c
src/solaris/native/sun/awt/awt_dnd_dt.c
src/solaris/native/sun/awt/awt_motif.c
src/solaris/native/sun/awt/awt_motif12.c
src/solaris/native/sun/awt/awt_motif21.c
src/solaris/native/sun/awt/awt_xembed.c
src/solaris/native/sun/awt/canvas.c
src/solaris/native/sun/awt/cursor.c
     1.1 --- a/make/sun/awt/FILES_c_unix.gmk	Wed Sep 17 13:45:37 2008 -0700
     1.2 +++ b/make/sun/awt/FILES_c_unix.gmk	Fri Sep 19 19:38:12 2008 -0700
     1.3 @@ -142,59 +142,59 @@
     1.4  # These files rely on motif to be built, and should not be included
     1.5  # in a headless build.
     1.6  
     1.7 -FILES_MOTIF_c = \
     1.8 -	awt_AWTEvent.c \
     1.9 -	awt_Button.c \
    1.10 -	awt_Canvas.c \
    1.11 -	awt_Checkbox.c \
    1.12 -	awt_Component.c \
    1.13 -	awt_Cursor.c \
    1.14 -	awt_DataTransferer.c \
    1.15 -	awt_DrawingSurface.c \
    1.16 -	awt_Event.c \
    1.17 -	awt_FileDialog.c \
    1.18 -	awt_GlobalCursorManager.c \
    1.19 -	awt_GraphicsEnv.c \
    1.20 -	awt_InputMethod.c \
    1.21 -	awt_Insets.c \
    1.22 -	awt_KeyboardFocusManager.c \
    1.23 -	awt_Label.c \
    1.24 -	awt_List.c \
    1.25 -	awt_Menu.c \
    1.26 -	awt_MenuBar.c \
    1.27 -	awt_MenuComponent.c \
    1.28 -	awt_MenuItem.c \
    1.29 -	awt_motif.c \
    1.30 -	awt_Plugin.c \
    1.31 -	awt_PopupMenu.c \
    1.32 -	awt_Robot.c \
    1.33 -	awt_Scrollbar.c \
    1.34 -	awt_ScrollPane.c \
    1.35 -	awt_Selection.c \
    1.36 -	awt_UNIXToolkit.c \
    1.37 -	awt_TextArea.c \
    1.38 -	awt_TextField.c \
    1.39 -	awt_TopLevel.c \
    1.40 -	awt_mgrsel.c \
    1.41 -	awt_util.c \
    1.42 -	awt_wm.c \
    1.43 -	awt_XmDnD.c \
    1.44 -	awt_dnd.c \
    1.45 -	awt_dnd_ds.c \
    1.46 -	awt_dnd_dt.c \
    1.47 -	canvas.c \
    1.48 -	cursor.c \
    1.49 -	multi_font.c \
    1.50 -	robot_common.c \
    1.51 -        list.c \
    1.52 -        multiVis.c \
    1.53 -	XDrawingArea.c \
    1.54 -	MouseInfo.c \
    1.55 -	awt_xembed.c \
    1.56 -	awt_xembed_server.c \
    1.57 -        gtk2_interface.c \
    1.58 -        swing_GTKEngine.c \
    1.59 -        swing_GTKStyle.c
    1.60 +#FILES_MOTIF_c = \
    1.61 +#keep	awt_AWTEvent.c \
    1.62 +#	awt_Button.c \
    1.63 +#	awt_Canvas.c \
    1.64 +#	awt_Checkbox.c \
    1.65 +#keep .h	awt_Component.c \
    1.66 +#keep .h	awt_Cursor.c \
    1.67 +#	awt_DataTransferer.c \
    1.68 +#	awt_DrawingSurface.c \
    1.69 +#	awt_Event.c \
    1.70 +#	awt_FileDialog.c \
    1.71 +#	awt_GlobalCursorManager.c \
    1.72 +#	awt_GraphicsEnv.c \
    1.73 +#	awt_InputMethod.c \
    1.74 +#keep	awt_Insets.c \
    1.75 +#	awt_KeyboardFocusManager.c \
    1.76 +#	awt_Label.c \
    1.77 +#	awt_List.c \
    1.78 +#	awt_Menu.c \
    1.79 +#	awt_MenuBar.c \
    1.80 +#	awt_MenuComponent.c \
    1.81 +#	awt_MenuItem.c \
    1.82 +#	awt_motif.c \
    1.83 +#	awt_Plugin.c \
    1.84 +#	awt_PopupMenu.c \
    1.85 +#	awt_Robot.c \
    1.86 +#	awt_Scrollbar.c \
    1.87 +#	awt_ScrollPane.c \
    1.88 +#	awt_Selection.c \
    1.89 +#	awt_UNIXToolkit.c \
    1.90 +#	awt_TextArea.c \
    1.91 +#	awt_TextField.c \
    1.92 +#	awt_TopLevel.c \
    1.93 +#	awt_mgrsel.c \
    1.94 +#	awt_util.c \
    1.95 +#	awt_wm.c \
    1.96 +#	awt_XmDnD.c \
    1.97 +#	awt_dnd.c \
    1.98 +#	awt_dnd_ds.c \
    1.99 +#	awt_dnd_dt.c \
   1.100 +#	canvas.c \
   1.101 +#	cursor.c \
   1.102 +#	multi_font.c \
   1.103 +#	robot_common.c \
   1.104 +#        list.c \
   1.105 +#        multiVis.c \
   1.106 +#	XDrawingArea.c \
   1.107 +#	MouseInfo.c \
   1.108 +#	awt_xembed.c \
   1.109 +#	awt_xembed_server.c \
   1.110 +#        gtk2_interface.c \
   1.111 +#        swing_GTKEngine.c \
   1.112 +#        swing_GTKStyle.c
   1.113  
   1.114  
   1.115  # These files are required to be built, with or without motif.  Some of
     2.1 --- a/make/sun/awt/FILES_export_unix.gmk	Wed Sep 17 13:45:37 2008 -0700
     2.2 +++ b/make/sun/awt/FILES_export_unix.gmk	Fri Sep 19 19:38:12 2008 -0700
     2.3 @@ -60,48 +60,15 @@
     2.4  	sun/awt/image/DataBufferNative.java \
     2.5  	\
     2.6  	sun/awt/motif/X11FontMetrics.java \
     2.7 -	sun/awt/motif/X11Clipboard.java \
     2.8 -	sun/awt/motif/X11Selection.java \
     2.9 -	sun/awt/motif/X11SelectionHolder.java \
    2.10  	sun/awt/X11InputMethod.java \
    2.11 -	sun/awt/motif/MInputMethod.java \
    2.12 -	sun/awt/motif/MInputMethodControl.java \
    2.13 -	sun/awt/motif/MCustomCursor.java \
    2.14  	sun/awt/motif/MFontConfiguration.java \
    2.15  	sun/awt/motif/MFontPeer.java \
    2.16  	sun/awt/motif/MToolkit.java \
    2.17 -	sun/awt/motif/MComponentPeer.java \
    2.18 -	sun/awt/motif/MButtonPeer.java \
    2.19 -	sun/awt/motif/MCanvasPeer.java \
    2.20 -	sun/awt/motif/MCheckboxPeer.java \
    2.21 -	sun/awt/motif/MFileDialogPeer.java \
    2.22 -	sun/awt/motif/MGlobalCursorManager.java \
    2.23 -	sun/awt/motif/MTextFieldPeer.java \
    2.24 -	sun/awt/motif/MLabelPeer.java \
    2.25 -	sun/awt/motif/MListPeer.java \
    2.26 -	sun/awt/motif/MWindowPeer.java \
    2.27 -	sun/awt/motif/MMenuBarPeer.java \
    2.28 -	sun/awt/motif/MMenuPeer.java \
    2.29 -        sun/awt/motif/MPopupMenuPeer.java \
    2.30 -	sun/awt/motif/MDialogPeer.java \
    2.31 -	sun/awt/motif/MMenuItemPeer.java \
    2.32 -	sun/awt/motif/MCheckboxMenuItemPeer.java \
    2.33 -	sun/awt/motif/MChoicePeer.java \
    2.34 -	sun/awt/motif/MTextAreaPeer.java \
    2.35 -	sun/awt/motif/MScrollbarPeer.java \
    2.36 -	sun/awt/motif/MScrollPanePeer.java \
    2.37 -	sun/awt/motif/MFramePeer.java \
    2.38          sun/awt/DebugSettings.java \
    2.39  	sun/awt/EmbeddedFrame.java \
    2.40 -	sun/awt/motif/MEmbeddedFramePeer.java \
    2.41  	sun/awt/PlatformFont.java \
    2.42  	sun/awt/FontDescriptor.java \
    2.43  	sun/awt/NativeLibLoader.java \
    2.44 -	sun/awt/motif/MDropTargetContextPeer.java \
    2.45 -	sun/awt/motif/MDragSourceContextPeer.java \
    2.46 -	sun/awt/motif/MRobotPeer.java \
    2.47 -	sun/awt/motif/X11DragSourceContextPeer.java \
    2.48 -	sun/awt/motif/X11DropTargetContextPeer.java \
    2.49  	sun/awt/X11GraphicsEnvironment.java \
    2.50  	sun/awt/X11GraphicsDevice.java \
    2.51  	sun/awt/X11GraphicsConfig.java \
    2.52 @@ -124,7 +91,6 @@
    2.53          sun/java2d/cmm/ColorTransform.java \
    2.54          sun/awt/datatransfer/DataTransferer.java \
    2.55  	sun/awt/dnd/SunDragSourceContextPeer.java \
    2.56 -	sun/awt/motif/MDataTransferer.java \
    2.57  	sun/awt/motif/MToolkitThreadBlockedHandler.java \
    2.58  	sun/java2d/opengl/OGLBlitLoops.java \
    2.59  	sun/java2d/opengl/OGLContext.java \
    2.60 @@ -220,6 +186,5 @@
    2.61  	java/awt/event/NativeLibLoader.java \
    2.62  	java/awt/peer/ComponentPeer.java \
    2.63  	java/awt/dnd/DnDConstants.java \
    2.64 -	sun/awt/CausedFocusEvent.java \
    2.65 -	sun/awt/motif/MEmbedCanvasPeer.java
    2.66 +	sun/awt/CausedFocusEvent.java
    2.67  
     3.1 --- a/make/sun/awt/mapfile-mawt-vers	Wed Sep 17 13:45:37 2008 -0700
     3.2 +++ b/make/sun/awt/mapfile-mawt-vers	Fri Sep 19 19:38:12 2008 -0700
     3.3 @@ -31,7 +31,7 @@
     3.4  	global:
     3.5  		JNI_OnLoad;
     3.6  
     3.7 -                Java_sun_awt_motif_MComponentPeer_restoreFocus;
     3.8 +                #Java_sun_awt_motif_MComponentPeer_restoreFocus;
     3.9  		Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords;
    3.10  		Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse;
    3.11  		Java_java_awt_AWTEvent_nativeSetSource;
    3.12 @@ -56,163 +56,163 @@
    3.13                  Java_sun_awt_UNIXToolkit_load_1stock_1icon;
    3.14                  Java_sun_awt_UNIXToolkit_load_1gtk_1icon;
    3.15  		Java_sun_awt_UNIXToolkit_nativeSync;
    3.16 -		Java_sun_awt_motif_MButtonPeer_create;
    3.17 -		Java_sun_awt_motif_MButtonPeer_setLabel;
    3.18 -                Java_sun_awt_motif_MPanelPeer_pEnsureIndex;
    3.19 -                Java_sun_awt_motif_MPanelPeer_pRestack;
    3.20 -		Java_sun_awt_motif_MCanvasPeer_create;
    3.21 -		Java_sun_awt_motif_MCanvasPeer_initIDs;
    3.22 -		Java_sun_awt_motif_MCanvasPeer_resetTargetGC;
    3.23 -		Java_sun_awt_motif_MCheckboxMenuItemPeer_pSetState;
    3.24 -		Java_sun_awt_motif_MCheckboxPeer_create;
    3.25 -		Java_sun_awt_motif_MCheckboxPeer_setCheckboxGroup;
    3.26 -		Java_sun_awt_motif_MCheckboxPeer_setLabel;
    3.27 -		Java_sun_awt_motif_MCheckboxPeer_pSetState;
    3.28 -		Java_sun_awt_motif_MCheckboxPeer_pGetState;
    3.29 -		Java_sun_awt_motif_MChoicePeer_addItem;
    3.30 -		Java_sun_awt_motif_MChoicePeer_appendItems;
    3.31 -		Java_sun_awt_motif_MChoicePeer_create;
    3.32 -		Java_sun_awt_motif_MChoicePeer_pReshape;
    3.33 -		Java_sun_awt_motif_MChoicePeer_remove;
    3.34 -		Java_sun_awt_motif_MChoicePeer_removeAll;
    3.35 -		Java_sun_awt_motif_MChoicePeer_setBackground;
    3.36 -		Java_sun_awt_motif_MChoicePeer_pSelect;
    3.37 -		Java_sun_awt_motif_MChoicePeer_setFont;
    3.38 -		Java_sun_awt_motif_MChoicePeer_setForeground;
    3.39 -		Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
    3.40 -		Java_sun_awt_motif_MComponentPeer_getNativeColor;
    3.41 -		Java_sun_awt_motif_MComponentPeer_getWindow;
    3.42 -		Java_sun_awt_motif_MComponentPeer_pDisable;
    3.43 -		Java_sun_awt_motif_MComponentPeer_pDispose;
    3.44 -		Java_sun_awt_motif_MComponentPeer_pEnable;
    3.45 -		Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen;
    3.46 -		Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2;
    3.47 -		Java_sun_awt_motif_MComponentPeer_pHide;
    3.48 -		Java_sun_awt_motif_MComponentPeer_pInitialize;
    3.49 -		Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible;
    3.50 -		Java_sun_awt_motif_MComponentPeer_pReshape;
    3.51 -		Java_sun_awt_motif_MComponentPeer_pShow;
    3.52 -		Java_sun_awt_motif_MComponentPeer_removeNativeDropTarget;
    3.53 -		Java_sun_awt_motif_MComponentPeer_pSetBackground;
    3.54 -		Java_sun_awt_motif_MComponentPeer_pSetFont;
    3.55 -                Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer;
    3.56 -                Java_sun_awt_motif_MComponentPeer__1requestFocus;
    3.57 -                Java_sun_awt_motif_MComponentPeer_getNativeFocusedWindow;
    3.58 -		Java_sun_awt_motif_MCheckboxMenuItemPeer_getState;
    3.59 -		Java_sun_awt_motif_MComponentPeer_pSetForeground;
    3.60 -		Java_sun_awt_motif_MDragSourceContextPeer_startDrag;
    3.61 -		Java_sun_awt_motif_MDragSourceContextPeer_setNativeCursor;
    3.62 -		Java_sun_awt_motif_MDropTargetContextPeer_addTransfer;
    3.63 -		Java_sun_awt_motif_MDropTargetContextPeer_dropDone;
    3.64 -		Java_sun_awt_motif_MDropTargetContextPeer_startTransfer;
    3.65 -		Java_sun_awt_motif_X11DragSourceContextPeer_startDrag;
    3.66 -		Java_sun_awt_motif_X11DragSourceContextPeer_setNativeCursor;
    3.67 -		Java_sun_awt_motif_X11DropTargetContextPeer_sendResponse;
    3.68 -		Java_sun_awt_motif_X11DropTargetContextPeer_dropDone;
    3.69 -		Java_sun_awt_motif_X11DropTargetContextPeer_getData;
    3.70 -		Java_sun_awt_motif_MEmbeddedFramePeer_NEFcreate;
    3.71 -		Java_sun_awt_motif_MEmbeddedFramePeer_pShowImpl;
    3.72 -		Java_sun_awt_motif_MEmbeddedFramePeer_requestXEmbedFocus;
    3.73 -		Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedApplicationActive;
    3.74 -		Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedActive;
    3.75 -                Java_sun_awt_motif_MEmbeddedFramePeer_synthesizeFocusInOut;
    3.76 -		Java_sun_awt_motif_MEmbeddedFramePeer_pReshapePrivate;
    3.77 -		Java_sun_awt_motif_MEmbeddedFramePeer_getBoundsPrivate;
    3.78 -		Java_sun_awt_motif_MEmbeddedFrame_getWidget;
    3.79 -		Java_sun_awt_motif_MEmbeddedFrame_mapWidget;
    3.80 -                Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded;       
    3.81 -		Java_sun_awt_motif_MFramePeer_pSetIconImage___3B_3I_3SII;
    3.82 -		Java_sun_awt_motif_MFileDialogPeer_create;
    3.83 -		Java_sun_awt_motif_MFileDialogPeer_pDispose;
    3.84 -		Java_sun_awt_motif_MFileDialogPeer_pHide;
    3.85 -		Java_sun_awt_motif_MFileDialogPeer_pReshape;
    3.86 -		Java_sun_awt_motif_MFileDialogPeer_pShow;
    3.87 -		Java_sun_awt_motif_MFileDialogPeer_setFileEntry;
    3.88 -		Java_sun_awt_motif_MFileDialogPeer_setFont;
    3.89 -		Java_sun_awt_motif_MFramePeer_pGetIconSize;
    3.90 -		Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
    3.91 -		Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
    3.92 -		Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
    3.93 -		Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
    3.94 -		Java_sun_awt_motif_MGlobalCursorManager_getLocationOnScreen;
    3.95 -		Java_sun_awt_motif_MLabelPeer_create;
    3.96 -		Java_sun_awt_motif_MLabelPeer_setAlignment;
    3.97 -		Java_sun_awt_motif_MLabelPeer_setText;
    3.98 -		Java_sun_awt_motif_MListPeer_addItem;
    3.99 -		Java_sun_awt_motif_MListPeer_create;
   3.100 -		Java_sun_awt_motif_MListPeer_delItems;
   3.101 -		Java_sun_awt_motif_MListPeer_deselect;
   3.102 -		Java_sun_awt_motif_MListPeer_isSelected;
   3.103 -		Java_sun_awt_motif_MListPeer_makeVisible;
   3.104 -		Java_sun_awt_motif_MListPeer_nativeHandleMouseWheel;
   3.105 -		Java_sun_awt_motif_MListPeer_select;
   3.106 -		Java_sun_awt_motif_MListPeer_setMultipleSelections;
   3.107 -		Java_sun_awt_motif_MMenuBarPeer_create;
   3.108 -		Java_sun_awt_motif_MMenuItemPeer_createMenuItem;
   3.109 -		Java_sun_awt_motif_MMenuItemPeer_pDisable;
   3.110 -		Java_sun_awt_motif_MMenuItemPeer_pDispose;
   3.111 -		Java_sun_awt_motif_MMenuItemPeer_pEnable;
   3.112 -		Java_sun_awt_motif_MMenuItemPeer_pSetLabel;
   3.113 -		Java_sun_awt_motif_MMenuPeer_createMenu;
   3.114 -		Java_sun_awt_motif_MMenuPeer_createSubMenu;
   3.115 -		Java_sun_awt_motif_MMenuPeer_pDispose;
   3.116 -		Java_sun_awt_motif_MPopupMenuPeer_createMenu;
   3.117 -		Java_sun_awt_motif_MPopupMenuPeer_pDispose;
   3.118 -		Java_sun_awt_motif_MPopupMenuPeer_pShow;
   3.119 -		Java_sun_awt_motif_MRobotPeer_getRGBPixelsImpl;
   3.120 -		Java_sun_awt_motif_MRobotPeer_keyPressImpl;
   3.121 -		Java_sun_awt_motif_MRobotPeer_keyReleaseImpl;
   3.122 -		Java_sun_awt_motif_MRobotPeer_mouseMoveImpl;
   3.123 -		Java_sun_awt_motif_MRobotPeer_mousePressImpl;
   3.124 -		Java_sun_awt_motif_MRobotPeer_mouseReleaseImpl;
   3.125 -		Java_sun_awt_motif_MRobotPeer_mouseWheelImpl;
   3.126 -		Java_sun_awt_motif_MRobotPeer_setup;
   3.127 -		Java_sun_awt_motif_MScrollbarPeer_create;
   3.128 -		Java_sun_awt_motif_MScrollbarPeer_setLineIncrement;
   3.129 -		Java_sun_awt_motif_MScrollbarPeer_setPageIncrement;
   3.130 -		Java_sun_awt_motif_MScrollbarPeer_pSetValues;
   3.131 -		Java_sun_awt_motif_MScrollPanePeer_create;
   3.132 -		Java_sun_awt_motif_MScrollPanePeer_pGetBlockIncrement;
   3.133 -		Java_sun_awt_motif_MScrollPanePeer_pGetScrollbarSpace;
   3.134 -		Java_sun_awt_motif_MScrollPanePeer_pGetShadow;
   3.135 -		Java_sun_awt_motif_MScrollPanePeer_pInsets;
   3.136 -		Java_sun_awt_motif_MScrollPanePeer_pSetIncrement;
   3.137 -		Java_sun_awt_motif_MScrollPanePeer_pSetScrollChild;
   3.138 -		Java_sun_awt_motif_MScrollPanePeer_setScrollPosition;
   3.139 -		Java_sun_awt_motif_MScrollPanePeer_setTypedValue;
   3.140 -		Java_sun_awt_motif_MTextAreaPeer_initIDs;
   3.141 -		Java_sun_awt_motif_MTextAreaPeer_pCreate;
   3.142 -		Java_sun_awt_motif_MTextAreaPeer_getCaretPosition;
   3.143 -		Java_sun_awt_motif_MTextAreaPeer_getExtraHeight;
   3.144 -		Java_sun_awt_motif_MTextAreaPeer_getExtraWidth;
   3.145 -		Java_sun_awt_motif_MTextAreaPeer_getSelectionEnd;
   3.146 -		Java_sun_awt_motif_MTextAreaPeer_getSelectionStart;
   3.147 -		Java_sun_awt_motif_MTextAreaPeer_getText;
   3.148 -		Java_sun_awt_motif_MTextAreaPeer_insert;
   3.149 -		Java_sun_awt_motif_MTextAreaPeer_nativeHandleMouseWheel;
   3.150 -		Java_sun_awt_motif_MTextAreaPeer_pMakeCursorVisible;
   3.151 -		Java_sun_awt_motif_MTextAreaPeer_pSetEditable;
   3.152 -		Java_sun_awt_motif_MTextAreaPeer_pShow2;
   3.153 -		Java_sun_awt_motif_MTextAreaPeer_replaceRange;
   3.154 -		Java_sun_awt_motif_MTextAreaPeer_select;
   3.155 -		Java_sun_awt_motif_MTextAreaPeer_setCaretPosition;
   3.156 -		Java_sun_awt_motif_MTextAreaPeer_setFont;
   3.157 -		Java_sun_awt_motif_MTextAreaPeer_setText;
   3.158 -		Java_sun_awt_motif_MTextAreaPeer_setTextBackground;
   3.159 -		Java_sun_awt_motif_MTextFieldPeer_initIDs;
   3.160 -		Java_sun_awt_motif_MTextFieldPeer_pCreate;
   3.161 -		Java_sun_awt_motif_MTextFieldPeer_getCaretPosition;
   3.162 -		Java_sun_awt_motif_MTextFieldPeer_getSelectionEnd;
   3.163 -		Java_sun_awt_motif_MTextFieldPeer_getSelectionStart;
   3.164 -		Java_sun_awt_motif_MTextFieldPeer_getText;
   3.165 -		Java_sun_awt_motif_MTextFieldPeer_insertReplaceText;
   3.166 -		Java_sun_awt_motif_MTextFieldPeer_preDispose;
   3.167 -		Java_sun_awt_motif_MTextFieldPeer_pSetEditable;
   3.168 -		Java_sun_awt_motif_MTextFieldPeer_select;
   3.169 -		Java_sun_awt_motif_MTextFieldPeer_setCaretPosition;
   3.170 -		Java_sun_awt_motif_MTextFieldPeer_setEchoChar;
   3.171 -		Java_sun_awt_motif_MTextFieldPeer_setFont;
   3.172 -		Java_sun_awt_motif_MTextFieldPeer_setText;
   3.173 +		#Java_sun_awt_motif_MButtonPeer_create;
   3.174 +		#Java_sun_awt_motif_MButtonPeer_setLabel;
   3.175 +                #Java_sun_awt_motif_MPanelPeer_pEnsureIndex;
   3.176 +                #Java_sun_awt_motif_MPanelPeer_pRestack;
   3.177 +		#Java_sun_awt_motif_MCanvasPeer_create;
   3.178 +		#Java_sun_awt_motif_MCanvasPeer_initIDs;
   3.179 +		#Java_sun_awt_motif_MCanvasPeer_resetTargetGC;
   3.180 +		#Java_sun_awt_motif_MCheckboxMenuItemPeer_pSetState;
   3.181 +		#Java_sun_awt_motif_MCheckboxPeer_create;
   3.182 +		#Java_sun_awt_motif_MCheckboxPeer_setCheckboxGroup;
   3.183 +		#Java_sun_awt_motif_MCheckboxPeer_setLabel;
   3.184 +		#Java_sun_awt_motif_MCheckboxPeer_pSetState;
   3.185 +		#Java_sun_awt_motif_MCheckboxPeer_pGetState;
   3.186 +		#Java_sun_awt_motif_MChoicePeer_addItem;
   3.187 +		#Java_sun_awt_motif_MChoicePeer_appendItems;
   3.188 +		#Java_sun_awt_motif_MChoicePeer_create;
   3.189 +		#Java_sun_awt_motif_MChoicePeer_pReshape;
   3.190 +		#Java_sun_awt_motif_MChoicePeer_remove;
   3.191 +		#Java_sun_awt_motif_MChoicePeer_removeAll;
   3.192 +		#Java_sun_awt_motif_MChoicePeer_setBackground;
   3.193 +		#Java_sun_awt_motif_MChoicePeer_pSelect;
   3.194 +		#Java_sun_awt_motif_MChoicePeer_setFont;
   3.195 +		#Java_sun_awt_motif_MChoicePeer_setForeground;
   3.196 +		#Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
   3.197 +		#Java_sun_awt_motif_MComponentPeer_getNativeColor;
   3.198 +		#Java_sun_awt_motif_MComponentPeer_getWindow;
   3.199 +		#Java_sun_awt_motif_MComponentPeer_pDisable;
   3.200 +		#Java_sun_awt_motif_MComponentPeer_pDispose;
   3.201 +		#Java_sun_awt_motif_MComponentPeer_pEnable;
   3.202 +		#Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen;
   3.203 +		#Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2;
   3.204 +		#Java_sun_awt_motif_MComponentPeer_pHide;
   3.205 +		#Java_sun_awt_motif_MComponentPeer_pInitialize;
   3.206 +		#Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible;
   3.207 +		#Java_sun_awt_motif_MComponentPeer_pReshape;
   3.208 +		#Java_sun_awt_motif_MComponentPeer_pShow;
   3.209 +		#Java_sun_awt_motif_MComponentPeer_removeNativeDropTarget;
   3.210 +		#Java_sun_awt_motif_MComponentPeer_pSetBackground;
   3.211 +		#Java_sun_awt_motif_MComponentPeer_pSetFont;
   3.212 +                #Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer;
   3.213 +                #Java_sun_awt_motif_MComponentPeer__1requestFocus;
   3.214 +                #Java_sun_awt_motif_MComponentPeer_getNativeFocusedWindow;
   3.215 +		#Java_sun_awt_motif_MCheckboxMenuItemPeer_getState;
   3.216 +		#Java_sun_awt_motif_MComponentPeer_pSetForeground;
   3.217 +		#Java_sun_awt_motif_MDragSourceContextPeer_startDrag;
   3.218 +		#Java_sun_awt_motif_MDragSourceContextPeer_setNativeCursor;
   3.219 +		#Java_sun_awt_motif_MDropTargetContextPeer_addTransfer;
   3.220 +		#Java_sun_awt_motif_MDropTargetContextPeer_dropDone;
   3.221 +		#Java_sun_awt_motif_MDropTargetContextPeer_startTransfer;
   3.222 +		#Java_sun_awt_motif_X11DragSourceContextPeer_startDrag;
   3.223 +		#Java_sun_awt_motif_X11DragSourceContextPeer_setNativeCursor;
   3.224 +		#Java_sun_awt_motif_X11DropTargetContextPeer_sendResponse;
   3.225 +		#Java_sun_awt_motif_X11DropTargetContextPeer_dropDone;
   3.226 +		#Java_sun_awt_motif_X11DropTargetContextPeer_getData;
   3.227 +		#Java_sun_awt_motif_MEmbeddedFramePeer_NEFcreate;
   3.228 +		#Java_sun_awt_motif_MEmbeddedFramePeer_pShowImpl;
   3.229 +		#Java_sun_awt_motif_MEmbeddedFramePeer_requestXEmbedFocus;
   3.230 +		#Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedApplicationActive;
   3.231 +		#Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedActive;
   3.232 +                #Java_sun_awt_motif_MEmbeddedFramePeer_synthesizeFocusInOut;
   3.233 +		#Java_sun_awt_motif_MEmbeddedFramePeer_pReshapePrivate;
   3.234 +		#Java_sun_awt_motif_MEmbeddedFramePeer_getBoundsPrivate;
   3.235 +		#Java_sun_awt_motif_MEmbeddedFrame_getWidget;
   3.236 +		#Java_sun_awt_motif_MEmbeddedFrame_mapWidget;
   3.237 +                #Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded;       
   3.238 +		#Java_sun_awt_motif_MFramePeer_pSetIconImage___3B_3I_3SII;
   3.239 +		#Java_sun_awt_motif_MFileDialogPeer_create;
   3.240 +		#Java_sun_awt_motif_MFileDialogPeer_pDispose;
   3.241 +		#Java_sun_awt_motif_MFileDialogPeer_pHide;
   3.242 +		#Java_sun_awt_motif_MFileDialogPeer_pReshape;
   3.243 +		#Java_sun_awt_motif_MFileDialogPeer_pShow;
   3.244 +		#Java_sun_awt_motif_MFileDialogPeer_setFileEntry;
   3.245 +		#Java_sun_awt_motif_MFileDialogPeer_setFont;
   3.246 +		#Java_sun_awt_motif_MFramePeer_pGetIconSize;
   3.247 +		#Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
   3.248 +		#Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
   3.249 +		#Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
   3.250 +		#Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
   3.251 +		#Java_sun_awt_motif_MGlobalCursorManager_getLocationOnScreen;
   3.252 +		#Java_sun_awt_motif_MLabelPeer_create;
   3.253 +		#Java_sun_awt_motif_MLabelPeer_setAlignment;
   3.254 +		#Java_sun_awt_motif_MLabelPeer_setText;
   3.255 +		#Java_sun_awt_motif_MListPeer_addItem;
   3.256 +		#Java_sun_awt_motif_MListPeer_create;
   3.257 +		#Java_sun_awt_motif_MListPeer_delItems;
   3.258 +		#Java_sun_awt_motif_MListPeer_deselect;
   3.259 +		#Java_sun_awt_motif_MListPeer_isSelected;
   3.260 +		#Java_sun_awt_motif_MListPeer_makeVisible;
   3.261 +		#Java_sun_awt_motif_MListPeer_nativeHandleMouseWheel;
   3.262 +		#Java_sun_awt_motif_MListPeer_select;
   3.263 +		#Java_sun_awt_motif_MListPeer_setMultipleSelections;
   3.264 +		#Java_sun_awt_motif_MMenuBarPeer_create;
   3.265 +		#Java_sun_awt_motif_MMenuItemPeer_createMenuItem;
   3.266 +		#Java_sun_awt_motif_MMenuItemPeer_pDisable;
   3.267 +		#Java_sun_awt_motif_MMenuItemPeer_pDispose;
   3.268 +		#Java_sun_awt_motif_MMenuItemPeer_pEnable;
   3.269 +		#Java_sun_awt_motif_MMenuItemPeer_pSetLabel;
   3.270 +		#Java_sun_awt_motif_MMenuPeer_createMenu;
   3.271 +		#Java_sun_awt_motif_MMenuPeer_createSubMenu;
   3.272 +		#Java_sun_awt_motif_MMenuPeer_pDispose;
   3.273 +		#Java_sun_awt_motif_MPopupMenuPeer_createMenu;
   3.274 +		#Java_sun_awt_motif_MPopupMenuPeer_pDispose;
   3.275 +		#Java_sun_awt_motif_MPopupMenuPeer_pShow;
   3.276 +		#Java_sun_awt_motif_MRobotPeer_getRGBPixelsImpl;
   3.277 +		#Java_sun_awt_motif_MRobotPeer_keyPressImpl;
   3.278 +		#Java_sun_awt_motif_MRobotPeer_keyReleaseImpl;
   3.279 +		#Java_sun_awt_motif_MRobotPeer_mouseMoveImpl;
   3.280 +		#Java_sun_awt_motif_MRobotPeer_mousePressImpl;
   3.281 +		#Java_sun_awt_motif_MRobotPeer_mouseReleaseImpl;
   3.282 +		#Java_sun_awt_motif_MRobotPeer_mouseWheelImpl;
   3.283 +		#Java_sun_awt_motif_MRobotPeer_setup;
   3.284 +		#Java_sun_awt_motif_MScrollbarPeer_create;
   3.285 +		#Java_sun_awt_motif_MScrollbarPeer_setLineIncrement;
   3.286 +		#Java_sun_awt_motif_MScrollbarPeer_setPageIncrement;
   3.287 +		#Java_sun_awt_motif_MScrollbarPeer_pSetValues;
   3.288 +		#Java_sun_awt_motif_MScrollPanePeer_create;
   3.289 +		#Java_sun_awt_motif_MScrollPanePeer_pGetBlockIncrement;
   3.290 +		#Java_sun_awt_motif_MScrollPanePeer_pGetScrollbarSpace;
   3.291 +		#Java_sun_awt_motif_MScrollPanePeer_pGetShadow;
   3.292 +		#Java_sun_awt_motif_MScrollPanePeer_pInsets;
   3.293 +		#Java_sun_awt_motif_MScrollPanePeer_pSetIncrement;
   3.294 +		#Java_sun_awt_motif_MScrollPanePeer_pSetScrollChild;
   3.295 +		#Java_sun_awt_motif_MScrollPanePeer_setScrollPosition;
   3.296 +		#Java_sun_awt_motif_MScrollPanePeer_setTypedValue;
   3.297 +		#Java_sun_awt_motif_MTextAreaPeer_initIDs;
   3.298 +		#Java_sun_awt_motif_MTextAreaPeer_pCreate;
   3.299 +		#Java_sun_awt_motif_MTextAreaPeer_getCaretPosition;
   3.300 +		#Java_sun_awt_motif_MTextAreaPeer_getExtraHeight;
   3.301 +		#Java_sun_awt_motif_MTextAreaPeer_getExtraWidth;
   3.302 +		#Java_sun_awt_motif_MTextAreaPeer_getSelectionEnd;
   3.303 +		#Java_sun_awt_motif_MTextAreaPeer_getSelectionStart;
   3.304 +		#Java_sun_awt_motif_MTextAreaPeer_getText;
   3.305 +		#Java_sun_awt_motif_MTextAreaPeer_insert;
   3.306 +		#Java_sun_awt_motif_MTextAreaPeer_nativeHandleMouseWheel;
   3.307 +		#Java_sun_awt_motif_MTextAreaPeer_pMakeCursorVisible;
   3.308 +		#Java_sun_awt_motif_MTextAreaPeer_pSetEditable;
   3.309 +		#Java_sun_awt_motif_MTextAreaPeer_pShow2;
   3.310 +		#Java_sun_awt_motif_MTextAreaPeer_replaceRange;
   3.311 +		#Java_sun_awt_motif_MTextAreaPeer_select;
   3.312 +                #Java_sun_awt_motif_MTextAreaPeer_setCaretPosition;
   3.313 +		#Java_sun_awt_motif_MTextAreaPeer_setFont;
   3.314 +		#Java_sun_awt_motif_MTextAreaPeer_setText;
   3.315 +		#Java_sun_awt_motif_MTextAreaPeer_setTextBackground;
   3.316 +		#Java_sun_awt_motif_MTextFieldPeer_initIDs;
   3.317 +		#Java_sun_awt_motif_MTextFieldPeer_pCreate;
   3.318 +		#Java_sun_awt_motif_MTextFieldPeer_getCaretPosition;
   3.319 +		#Java_sun_awt_motif_MTextFieldPeer_getSelectionEnd;
   3.320 +		#Java_sun_awt_motif_MTextFieldPeer_getSelectionStart;
   3.321 +		#Java_sun_awt_motif_MTextFieldPeer_getText;
   3.322 +		#Java_sun_awt_motif_MTextFieldPeer_insertReplaceText;
   3.323 +		#Java_sun_awt_motif_MTextFieldPeer_preDispose;
   3.324 +		#Java_sun_awt_motif_MTextFieldPeer_pSetEditable;
   3.325 +		#Java_sun_awt_motif_MTextFieldPeer_select;
   3.326 +		#Java_sun_awt_motif_MTextFieldPeer_setCaretPosition;
   3.327 +		#Java_sun_awt_motif_MTextFieldPeer_setEchoChar;
   3.328 +		#Java_sun_awt_motif_MTextFieldPeer_setFont;
   3.329 +		#Java_sun_awt_motif_MTextFieldPeer_setText;
   3.330  		Java_sun_awt_motif_MToolkit_beep;
   3.331  		Java_sun_awt_motif_MToolkit_getLockingKeyStateNative;
   3.332  		Java_sun_awt_motif_MToolkit_getMulticlickTime;
   3.333 @@ -236,30 +236,30 @@
   3.334                  Java_sun_awt_motif_MToolkit_nativeGrab;
   3.335                  Java_sun_awt_motif_MToolkit_getWMName;
   3.336  		Java_sun_awt_motif_MWindowAttributes_initIDs;
   3.337 -		Java_sun_awt_motif_MWindowPeer_pDispose;
   3.338 -		Java_sun_awt_motif_MWindowPeer_pHide;
   3.339 -		Java_sun_awt_motif_MWindowPeer_pReshape;
   3.340 -		Java_sun_awt_motif_MWindowPeer_pSetTitle;
   3.341 -		Java_sun_awt_motif_MWindowPeer_pShow;
   3.342 -		Java_sun_awt_motif_MWindowPeer_setResizable;
   3.343 -		Java_sun_awt_motif_MWindowPeer_toBack;
   3.344 -		Java_sun_awt_motif_MWindowPeer_addTextComponentNative;
   3.345 -		Java_sun_awt_motif_MWindowPeer_getState;
   3.346 -		Java_sun_awt_motif_MWindowPeer_pSetIMMOption;
   3.347 -		Java_sun_awt_motif_MWindowPeer_pSetMenuBar;
   3.348 -		Java_sun_awt_motif_MWindowPeer_pShowModal;
   3.349 -		Java_sun_awt_motif_MWindowPeer_removeTextComponentNative;
   3.350 -		Java_sun_awt_motif_MWindowPeer_setSaveUnder;
   3.351 -		Java_sun_awt_motif_MWindowPeer_setState;
   3.352 -		Java_sun_awt_motif_MWindowPeer_resetTargetGC;
   3.353 -		Java_sun_awt_motif_MWindowPeer_registerX11DropTarget;
   3.354 -		Java_sun_awt_motif_MWindowPeer_unregisterX11DropTarget;
   3.355 -		Java_sun_awt_motif_MWindowPeer_updateAlwaysOnTop;
   3.356 -                Java_sun_awt_motif_MWindowPeer_setFocusableWindow;
   3.357 -                Java_sun_awt_motif_MWindowPeer_pToFront;
   3.358 -		Java_sun_awt_motif_MCustomCursor_cacheInit;
   3.359 -		Java_sun_awt_motif_MCustomCursor_createCursor;
   3.360 -		Java_sun_awt_motif_MCustomCursor_queryBestCursor;
   3.361 +		#Java_sun_awt_motif_MWindowPeer_pDispose;
   3.362 +		#Java_sun_awt_motif_MWindowPeer_pHide;
   3.363 +		#Java_sun_awt_motif_MWindowPeer_pReshape;
   3.364 +		#Java_sun_awt_motif_MWindowPeer_pSetTitle;
   3.365 +		#Java_sun_awt_motif_MWindowPeer_pShow;
   3.366 +		#Java_sun_awt_motif_MWindowPeer_setResizable;
   3.367 +		#Java_sun_awt_motif_MWindowPeer_toBack;
   3.368 +		#Java_sun_awt_motif_MWindowPeer_addTextComponentNative;
   3.369 +		#Java_sun_awt_motif_MWindowPeer_getState;
   3.370 +		#Java_sun_awt_motif_MWindowPeer_pSetIMMOption;
   3.371 +		#Java_sun_awt_motif_MWindowPeer_pSetMenuBar;
   3.372 +		#Java_sun_awt_motif_MWindowPeer_pShowModal;
   3.373 +		#Java_sun_awt_motif_MWindowPeer_removeTextComponentNative;
   3.374 +		#Java_sun_awt_motif_MWindowPeer_setSaveUnder;
   3.375 +		#Java_sun_awt_motif_MWindowPeer_setState;
   3.376 +		#Java_sun_awt_motif_MWindowPeer_resetTargetGC;
   3.377 +		#Java_sun_awt_motif_MWindowPeer_registerX11DropTarget;
   3.378 +		#Java_sun_awt_motif_MWindowPeer_unregisterX11DropTarget;
   3.379 +		#Java_sun_awt_motif_MWindowPeer_updateAlwaysOnTop;
   3.380 +                #Java_sun_awt_motif_MWindowPeer_setFocusableWindow;
   3.381 +                #Java_sun_awt_motif_MWindowPeer_pToFront;
   3.382 +		#Java_sun_awt_motif_MCustomCursor_cacheInit;
   3.383 +		#Java_sun_awt_motif_MCustomCursor_createCursor;
   3.384 +		#Java_sun_awt_motif_MCustomCursor_queryBestCursor;
   3.385  		Java_sun_awt_motif_X11FontMetrics_bytesWidth;
   3.386  		Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth;
   3.387  		Java_sun_awt_motif_X11FontMetrics_init;
   3.388 @@ -268,18 +268,18 @@
   3.389  		Java_sun_awt_X11InputMethod_resetXIC;
   3.390  		Java_sun_awt_X11InputMethod_setCompositionEnabledNative;
   3.391  		Java_sun_awt_X11InputMethod_turnoffStatusWindow;
   3.392 -		Java_sun_awt_motif_MInputMethod_openXIMNative;
   3.393 -		Java_sun_awt_motif_MInputMethod_configureStatusAreaNative;
   3.394 -		Java_sun_awt_motif_MInputMethod_createXICNative;
   3.395 -		Java_sun_awt_motif_MInputMethod_reconfigureXICNative;
   3.396 -		Java_sun_awt_motif_MInputMethod_setXICFocusNative;
   3.397 -		Java_sun_awt_motif_X11Clipboard_getClipboardData;
   3.398 -		Java_sun_awt_motif_X11Clipboard_getClipboardFormats;
   3.399 -		Java_sun_awt_motif_X11Clipboard_registerClipboardViewer;
   3.400 -		Java_sun_awt_motif_X11Clipboard_unregisterClipboardViewer;
   3.401 -		Java_sun_awt_motif_X11Selection_init;
   3.402 -		Java_sun_awt_motif_X11Selection_pGetSelectionOwnership;
   3.403 -		Java_sun_awt_motif_X11Selection_clearNativeContext;
   3.404 +		#Java_sun_awt_motif_MInputMethod_openXIMNative;
   3.405 +		#Java_sun_awt_motif_MInputMethod_configureStatusAreaNative;
   3.406 +		#Java_sun_awt_motif_MInputMethod_createXICNative;
   3.407 +		#Java_sun_awt_motif_MInputMethod_reconfigureXICNative;
   3.408 +		#Java_sun_awt_motif_MInputMethod_setXICFocusNative;
   3.409 +		#Java_sun_awt_motif_X11Clipboard_getClipboardData;
   3.410 +		#Java_sun_awt_motif_X11Clipboard_getClipboardFormats;
   3.411 +		#Java_sun_awt_motif_X11Clipboard_registerClipboardViewer;
   3.412 +		#Java_sun_awt_motif_X11Clipboard_unregisterClipboardViewer;
   3.413 +		#Java_sun_awt_motif_X11Selection_init;
   3.414 +		#Java_sun_awt_motif_X11Selection_pGetSelectionOwnership;
   3.415 +		#Java_sun_awt_motif_X11Selection_clearNativeContext;
   3.416  		Java_sun_awt_SunToolkit_closeSplashScreen;
   3.417  		Java_sun_awt_PlatformFont_initIDs;
   3.418  		Java_sun_awt_X11GraphicsConfig_init;
   3.419 @@ -311,25 +311,25 @@
   3.420                  Java_sun_awt_X11GraphicsEnvironment_initGLX;
   3.421  		Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama;
   3.422  		Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint;
   3.423 -                Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer;
   3.424 -                Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer;
   3.425 -                Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive;
   3.426 -                Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching;
   3.427 -                Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching;
   3.428 -                Java_sun_awt_motif_MEmbedCanvasPeer_embedChild;
   3.429 -                Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed;
   3.430 -                Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize;
   3.431 -                Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize;
   3.432 -                Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds;
   3.433 -                Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded;
   3.434 -                Java_sun_awt_motif_MEmbedCanvasPeer_detachChild;
   3.435 -                Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent;
   3.436 -                Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym;
   3.437 -                Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I;
   3.438 -                Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ;
   3.439 -                Java_sun_awt_motif_MEmbedCanvasPeer_getWindow;       
   3.440 -                Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers;
   3.441 -                Java_sun_awt_motif_MEmbeddedFramePeer_traverseOut;
   3.442 +                #Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer;
   3.443 +                #Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer;
   3.444 +                #Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive;
   3.445 +                #Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching;
   3.446 +                #Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching;
   3.447 +                #Java_sun_awt_motif_MEmbedCanvasPeer_embedChild;
   3.448 +                #Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed;
   3.449 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize;
   3.450 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize;
   3.451 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds;
   3.452 +                #Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded;
   3.453 +                #Java_sun_awt_motif_MEmbedCanvasPeer_detachChild;
   3.454 +                #Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent;
   3.455 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym;
   3.456 +                #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I;
   3.457 +                #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ;
   3.458 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getWindow;       
   3.459 +                #Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers;
   3.460 +                #Java_sun_awt_motif_MEmbeddedFramePeer_traverseOut;
   3.461  		Java_java_awt_AWTEvent_initIDs;
   3.462  		Java_java_awt_Button_initIDs;
   3.463  		Java_java_awt_Container_initIDs;
   3.464 @@ -343,39 +343,39 @@
   3.465  		Java_java_awt_Insets_initIDs;
   3.466  		Java_java_awt_TextField_initIDs;
   3.467  		Java_java_awt_Window_initIDs;
   3.468 -		Java_sun_awt_motif_MCheckboxPeer_getIndicatorSize;
   3.469 -		Java_sun_awt_motif_MCheckboxPeer_getSpacing;
   3.470 -		Java_sun_awt_motif_MChoicePeer_freeNativeData;
   3.471 -		Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
   3.472 -		Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
   3.473 -		Java_sun_awt_motif_MComponentPeer_initIDs;
   3.474 -		Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
   3.475 -		Java_sun_awt_motif_MComponentPeer_pSetCursor;
   3.476 -		Java_sun_awt_motif_MComponentPeer_pSetInnerForeground;
   3.477 -		Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground;
   3.478 -		Java_sun_awt_motif_MComponentPeer_setTargetBackground;
   3.479 -		Java_sun_awt_motif_MDataTransferer_dragQueryFile;
   3.480 -		Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
   3.481 -		Java_sun_awt_motif_MDataTransferer_getTargetNameForAtom;
   3.482 -		Java_sun_awt_motif_MFileDialogPeer_insertReplaceFileDialogText;
   3.483 +		#Java_sun_awt_motif_MCheckboxPeer_getIndicatorSize;
   3.484 +		#Java_sun_awt_motif_MCheckboxPeer_getSpacing;
   3.485 +		#Java_sun_awt_motif_MChoicePeer_freeNativeData;
   3.486 +		#Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
   3.487 +		#Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
   3.488 +		#Java_sun_awt_motif_MComponentPeer_initIDs;
   3.489 +		#Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
   3.490 +		#Java_sun_awt_motif_MComponentPeer_pSetCursor;
   3.491 +		#Java_sun_awt_motif_MComponentPeer_pSetInnerForeground;
   3.492 +		#Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground;
   3.493 +		#Java_sun_awt_motif_MComponentPeer_setTargetBackground;
   3.494 +		#Java_sun_awt_motif_MDataTransferer_dragQueryFile;
   3.495 +		#Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
   3.496 +		#Java_sun_awt_motif_MDataTransferer_getTargetNameForAtom;
   3.497 +		#Java_sun_awt_motif_MFileDialogPeer_insertReplaceFileDialogText;
   3.498  		Java_sun_awt_motif_MFontPeer_initIDs;
   3.499 -		Java_sun_awt_motif_MListPeer_setBackground;
   3.500 -		Java_sun_awt_motif_MMenuBarPeer_initIDs;
   3.501 -		Java_sun_awt_motif_MMenuBarPeer_pDispose;
   3.502 -		Java_sun_awt_motif_MMenuItemPeer_getParent_1NoClientCode;
   3.503 -		Java_sun_awt_motif_MMenuItemPeer_initIDs;
   3.504 -		Java_sun_awt_motif_MMenuItemPeer_pSetShortcut;
   3.505 -		Java_sun_awt_motif_MPopupMenuPeer_initIDs;
   3.506 -		Java_sun_awt_motif_MScrollbarPeer_initIDs;
   3.507 -		Java_sun_awt_motif_MScrollPanePeer_initIDs;
   3.508 -		Java_sun_awt_motif_MTextAreaPeer_pSetCursor;
   3.509 +		#Java_sun_awt_motif_MListPeer_setBackground;
   3.510 +		#Java_sun_awt_motif_MMenuBarPeer_initIDs;
   3.511 +		#Java_sun_awt_motif_MMenuBarPeer_pDispose;
   3.512 +		#Java_sun_awt_motif_MMenuItemPeer_getParent_1NoClientCode;
   3.513 +		#Java_sun_awt_motif_MMenuItemPeer_initIDs;
   3.514 +		#Java_sun_awt_motif_MMenuItemPeer_pSetShortcut;
   3.515 +		#Java_sun_awt_motif_MPopupMenuPeer_initIDs;
   3.516 +		#Java_sun_awt_motif_MScrollbarPeer_initIDs;
   3.517 +		#Java_sun_awt_motif_MScrollPanePeer_initIDs;
   3.518 +		#Java_sun_awt_motif_MTextAreaPeer_pSetCursor;
   3.519  		Java_sun_awt_motif_MToolkit_shutdown;
   3.520 -		Java_sun_awt_motif_MWindowPeer_initIDs;
   3.521 -		Java_sun_awt_motif_MWindowPeer_pCreate;
   3.522 -		Java_sun_awt_motif_MWindowPeer_wrapInSequenced;
   3.523 +		#Java_sun_awt_motif_MWindowPeer_initIDs;
   3.524 +		#Java_sun_awt_motif_MWindowPeer_pCreate;
   3.525 +		#Java_sun_awt_motif_MWindowPeer_wrapInSequenced;
   3.526  		Java_sun_awt_motif_X11FontMetrics_initIDs;
   3.527 -		Java_sun_awt_X11InputMethod_initIDs;
   3.528 -		Java_sun_awt_motif_X11Selection_initIDs;
   3.529 +		#Java_sun_awt_X11InputMethod_initIDs;
   3.530 +		#Java_sun_awt_motif_X11Selection_initIDs;
   3.531  		Java_sun_awt_motif_MToolkitThreadBlockedHandler_enter;
   3.532  		Java_sun_awt_motif_MToolkitThreadBlockedHandler_exit;
   3.533  		Java_sun_awt_X11GraphicsConfig_init;
     4.1 --- a/make/sun/awt/mapfile-vers-linux	Wed Sep 17 13:45:37 2008 -0700
     4.2 +++ b/make/sun/awt/mapfile-vers-linux	Fri Sep 19 19:38:12 2008 -0700
     4.3 @@ -170,7 +170,7 @@
     4.4  		GrPrim_Sg2dGetPixel;
     4.5  		GrPrim_Sg2dGetLCDTextContrast;
     4.6  
     4.7 -		Java_sun_awt_motif_MComponentPeer_restoreFocus;
     4.8 +		#Java_sun_awt_motif_MComponentPeer_restoreFocus;
     4.9  		Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords;
    4.10  		Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse;
    4.11  		Java_java_awt_AWTEvent_nativeSetSource;
    4.12 @@ -189,158 +189,158 @@
    4.13  		Java_java_awt_ScrollPane_initIDs;
    4.14  		Java_java_awt_TextArea_initIDs;
    4.15  		Java_sun_awt_FontDescriptor_initIDs;
    4.16 -		Java_sun_awt_motif_MButtonPeer_create;
    4.17 -		Java_sun_awt_motif_MButtonPeer_setLabel;
    4.18 -		Java_sun_awt_motif_MCanvasPeer_create;
    4.19 -		Java_sun_awt_motif_MCanvasPeer_initIDs;
    4.20 -		Java_sun_awt_motif_MCanvasPeer_resetTargetGC;
    4.21 -		Java_sun_awt_motif_MCheckboxMenuItemPeer_pSetState;
    4.22 -		Java_sun_awt_motif_MCheckboxPeer_create;
    4.23 -		Java_sun_awt_motif_MCheckboxPeer_setCheckboxGroup;
    4.24 -		Java_sun_awt_motif_MCheckboxPeer_setLabel;
    4.25 -		Java_sun_awt_motif_MCheckboxPeer_pSetState;
    4.26 -		Java_sun_awt_motif_MCheckboxPeer_pGetState;
    4.27 -		Java_sun_awt_motif_MChoicePeer_addItem;
    4.28 -		Java_sun_awt_motif_MChoicePeer_appendItems;
    4.29 -		Java_sun_awt_motif_MChoicePeer_create;
    4.30 -		Java_sun_awt_motif_MChoicePeer_pReshape;
    4.31 -		Java_sun_awt_motif_MChoicePeer_remove;
    4.32 -		Java_sun_awt_motif_MChoicePeer_removeAll;
    4.33 -		Java_sun_awt_motif_MChoicePeer_setBackground;
    4.34 -		Java_sun_awt_motif_MChoicePeer_pSelect;
    4.35 -		Java_sun_awt_motif_MChoicePeer_setFont;
    4.36 -		Java_sun_awt_motif_MChoicePeer_setForeground;
    4.37 -		Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
    4.38 -		Java_sun_awt_motif_MComponentPeer_createBackBuffer;
    4.39 -		Java_sun_awt_motif_MComponentPeer_destroyBackBuffer;
    4.40 -		Java_sun_awt_motif_MComponentPeer_getNativeColor;
    4.41 -		Java_sun_awt_motif_MComponentPeer_getWindow;
    4.42 -		Java_sun_awt_motif_MComponentPeer_pDisable;
    4.43 -		Java_sun_awt_motif_MComponentPeer_pDispose;
    4.44 -		Java_sun_awt_motif_MComponentPeer_pEnable;
    4.45 -		Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen;
    4.46 -		Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2;
    4.47 -		Java_sun_awt_motif_MComponentPeer_pHide;
    4.48 -		Java_sun_awt_motif_MComponentPeer_pInitialize;
    4.49 -		Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible;
    4.50 -		Java_sun_awt_motif_MComponentPeer_pReshape;
    4.51 -		Java_sun_awt_motif_MComponentPeer_pShow;
    4.52 -		Java_sun_awt_motif_MComponentPeer_removeNativeDropTarget;
    4.53 -		Java_sun_awt_motif_MComponentPeer_swapBuffers;
    4.54 -		Java_sun_awt_motif_MComponentPeer_pSetBackground;
    4.55 -		Java_sun_awt_motif_MComponentPeer_pSetFont;
    4.56 -                Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer;
    4.57 -                Java_sun_awt_motif_MComponentPeer__1requestFocus;
    4.58 -		Java_sun_awt_motif_MCheckboxMenuItemPeer_getState;
    4.59 -		Java_sun_awt_motif_MComponentPeer_pSetForeground;
    4.60 -		Java_sun_awt_motif_MDragSourceContextPeer_startDrag;
    4.61 -		Java_sun_awt_motif_MDragSourceContextPeer_setNativeCursor;
    4.62 -		Java_sun_awt_motif_MDropTargetContextPeer_addTransfer;
    4.63 -		Java_sun_awt_motif_MDropTargetContextPeer_dropDone;
    4.64 -		Java_sun_awt_motif_MDropTargetContextPeer_startTransfer;
    4.65 -		Java_sun_awt_motif_X11DragSourceContextPeer_startDrag;
    4.66 -		Java_sun_awt_motif_X11DragSourceContextPeer_setNativeCursor;
    4.67 -		Java_sun_awt_motif_X11DropTargetContextPeer_sendResponse;
    4.68 -		Java_sun_awt_motif_X11DropTargetContextPeer_dropDone;
    4.69 -		Java_sun_awt_motif_X11DropTargetContextPeer_getData;
    4.70 -		Java_sun_awt_motif_MEmbeddedFramePeer_NEFcreate;
    4.71 -		Java_sun_awt_motif_MEmbeddedFramePeer_pShowImpl;
    4.72 -		Java_sun_awt_motif_MEmbeddedFramePeer_pReshapePrivate;
    4.73 -		Java_sun_awt_motif_MEmbeddedFramePeer_getBoundsPrivate;
    4.74 -		Java_sun_awt_motif_MFramePeer_pSetIconImage___3B_3I_3SII;
    4.75 -		Java_sun_awt_motif_MEmbeddedFramePeer_requestXEmbedFocus;
    4.76 -		Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedApplicationActive;
    4.77 -		Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedActive;
    4.78 -		Java_sun_awt_motif_MEmbeddedFrame_getWidget;
    4.79 -		Java_sun_awt_motif_MEmbeddedFrame_mapWidget;
    4.80 -		Java_sun_awt_motif_MFileDialogPeer_create;
    4.81 -		Java_sun_awt_motif_MFileDialogPeer_pDispose;
    4.82 -		Java_sun_awt_motif_MFileDialogPeer_pHide;
    4.83 -		Java_sun_awt_motif_MFileDialogPeer_pReshape;
    4.84 -		Java_sun_awt_motif_MFileDialogPeer_pShow;
    4.85 -		Java_sun_awt_motif_MFileDialogPeer_setFileEntry;
    4.86 -		Java_sun_awt_motif_MFileDialogPeer_setFont;
    4.87 -		Java_sun_awt_motif_MFramePeer_pGetIconSize;
    4.88 -		Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
    4.89 -		Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
    4.90 -		Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
    4.91 -		Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
    4.92 -		Java_sun_awt_motif_MGlobalCursorManager_getLocationOnScreen;
    4.93 -		Java_sun_awt_motif_MLabelPeer_create;
    4.94 -		Java_sun_awt_motif_MLabelPeer_setAlignment;
    4.95 -		Java_sun_awt_motif_MLabelPeer_setText;
    4.96 -		Java_sun_awt_motif_MListPeer_addItem;
    4.97 -		Java_sun_awt_motif_MListPeer_create;
    4.98 -		Java_sun_awt_motif_MListPeer_delItems;
    4.99 -		Java_sun_awt_motif_MListPeer_deselect;
   4.100 -		Java_sun_awt_motif_MListPeer_isSelected;
   4.101 -		Java_sun_awt_motif_MListPeer_makeVisible;
   4.102 -		Java_sun_awt_motif_MListPeer_select;
   4.103 -		Java_sun_awt_motif_MListPeer_setMultipleSelections;
   4.104 -		Java_sun_awt_motif_MMenuBarPeer_create;
   4.105 -		Java_sun_awt_motif_MMenuItemPeer_createMenuItem;
   4.106 -		Java_sun_awt_motif_MMenuItemPeer_pDisable;
   4.107 -		Java_sun_awt_motif_MMenuItemPeer_pDispose;
   4.108 -		Java_sun_awt_motif_MMenuItemPeer_pEnable;
   4.109 -		Java_sun_awt_motif_MMenuItemPeer_pSetLabel;
   4.110 -		Java_sun_awt_motif_MMenuPeer_createMenu;
   4.111 -		Java_sun_awt_motif_MMenuPeer_createSubMenu;
   4.112 -		Java_sun_awt_motif_MMenuPeer_pDispose;
   4.113 -		Java_sun_awt_motif_MPopupMenuPeer_createMenu;
   4.114 -		Java_sun_awt_motif_MPopupMenuPeer_pDispose;
   4.115 -		Java_sun_awt_motif_MPopupMenuPeer_pShow;
   4.116 -		Java_sun_awt_motif_MRobotPeer_getRGBPixelsImpl;
   4.117 -		Java_sun_awt_motif_MRobotPeer_keyPressImpl;
   4.118 -		Java_sun_awt_motif_MRobotPeer_keyReleaseImpl;
   4.119 -		Java_sun_awt_motif_MRobotPeer_mouseMoveImpl;
   4.120 -		Java_sun_awt_motif_MRobotPeer_mousePressImpl;
   4.121 -		Java_sun_awt_motif_MRobotPeer_mouseReleaseImpl;
   4.122 -		Java_sun_awt_motif_MRobotPeer_mouseWheelImpl;
   4.123 -		Java_sun_awt_motif_MRobotPeer_setup;
   4.124 -		Java_sun_awt_motif_MScrollbarPeer_create;
   4.125 -		Java_sun_awt_motif_MScrollbarPeer_setLineIncrement;
   4.126 -		Java_sun_awt_motif_MScrollbarPeer_setPageIncrement;
   4.127 -		Java_sun_awt_motif_MScrollbarPeer_pSetValues;
   4.128 -		Java_sun_awt_motif_MScrollPanePeer_create;
   4.129 -		Java_sun_awt_motif_MScrollPanePeer_pGetBlockIncrement;
   4.130 -		Java_sun_awt_motif_MScrollPanePeer_pGetScrollbarSpace;
   4.131 -		Java_sun_awt_motif_MScrollPanePeer_pGetShadow;
   4.132 -		Java_sun_awt_motif_MScrollPanePeer_pInsets;
   4.133 -		Java_sun_awt_motif_MScrollPanePeer_pSetIncrement;
   4.134 -		Java_sun_awt_motif_MScrollPanePeer_pSetScrollChild;
   4.135 -		Java_sun_awt_motif_MScrollPanePeer_setScrollPosition;
   4.136 -		Java_sun_awt_motif_MTextAreaPeer_initIDs;
   4.137 -		Java_sun_awt_motif_MTextAreaPeer_pCreate;
   4.138 -		Java_sun_awt_motif_MTextAreaPeer_getCaretPosition;
   4.139 -		Java_sun_awt_motif_MTextAreaPeer_getExtraHeight;
   4.140 -		Java_sun_awt_motif_MTextAreaPeer_getExtraWidth;
   4.141 -		Java_sun_awt_motif_MTextAreaPeer_getSelectionEnd;
   4.142 -		Java_sun_awt_motif_MTextAreaPeer_getSelectionStart;
   4.143 -		Java_sun_awt_motif_MTextAreaPeer_getText;
   4.144 -		Java_sun_awt_motif_MTextAreaPeer_insert;
   4.145 -		Java_sun_awt_motif_MTextAreaPeer_pMakeCursorVisible;
   4.146 -		Java_sun_awt_motif_MTextAreaPeer_pSetEditable;
   4.147 -		Java_sun_awt_motif_MTextAreaPeer_pShow2;
   4.148 -		Java_sun_awt_motif_MTextAreaPeer_replaceRange;
   4.149 -		Java_sun_awt_motif_MTextAreaPeer_select;
   4.150 -		Java_sun_awt_motif_MTextAreaPeer_setCaretPosition;
   4.151 -		Java_sun_awt_motif_MTextAreaPeer_setFont;
   4.152 -		Java_sun_awt_motif_MTextAreaPeer_setText;
   4.153 -		Java_sun_awt_motif_MTextAreaPeer_setTextBackground;
   4.154 -		Java_sun_awt_motif_MTextFieldPeer_initIDs;
   4.155 -		Java_sun_awt_motif_MTextFieldPeer_pCreate;
   4.156 -		Java_sun_awt_motif_MTextFieldPeer_getCaretPosition;
   4.157 -		Java_sun_awt_motif_MTextFieldPeer_getSelectionEnd;
   4.158 -		Java_sun_awt_motif_MTextFieldPeer_getSelectionStart;
   4.159 -		Java_sun_awt_motif_MTextFieldPeer_getText;
   4.160 -		Java_sun_awt_motif_MTextFieldPeer_insertReplaceText;
   4.161 -		Java_sun_awt_motif_MTextFieldPeer_preDispose;
   4.162 -		Java_sun_awt_motif_MTextFieldPeer_pSetEditable;
   4.163 -		Java_sun_awt_motif_MTextFieldPeer_select;
   4.164 -		Java_sun_awt_motif_MTextFieldPeer_setCaretPosition;
   4.165 -		Java_sun_awt_motif_MTextFieldPeer_setEchoChar;
   4.166 -		Java_sun_awt_motif_MTextFieldPeer_setFont;
   4.167 -		Java_sun_awt_motif_MTextFieldPeer_setText;
   4.168 +		#Java_sun_awt_motif_MButtonPeer_create;
   4.169 +		#Java_sun_awt_motif_MButtonPeer_setLabel;
   4.170 +		#Java_sun_awt_motif_MCanvasPeer_create;
   4.171 +		#Java_sun_awt_motif_MCanvasPeer_initIDs;
   4.172 +		#Java_sun_awt_motif_MCanvasPeer_resetTargetGC;
   4.173 +		#Java_sun_awt_motif_MCheckboxMenuItemPeer_pSetState;
   4.174 +		#Java_sun_awt_motif_MCheckboxPeer_create;
   4.175 +		#Java_sun_awt_motif_MCheckboxPeer_setCheckboxGroup;
   4.176 +		#Java_sun_awt_motif_MCheckboxPeer_setLabel;
   4.177 +		#Java_sun_awt_motif_MCheckboxPeer_pSetState;
   4.178 +		#Java_sun_awt_motif_MCheckboxPeer_pGetState;
   4.179 +		#Java_sun_awt_motif_MChoicePeer_addItem;
   4.180 +		#Java_sun_awt_motif_MChoicePeer_appendItems;
   4.181 +		#Java_sun_awt_motif_MChoicePeer_create;
   4.182 +		#Java_sun_awt_motif_MChoicePeer_pReshape;
   4.183 +		#Java_sun_awt_motif_MChoicePeer_remove;
   4.184 +		#Java_sun_awt_motif_MChoicePeer_removeAll;
   4.185 +		#Java_sun_awt_motif_MChoicePeer_setBackground;
   4.186 +		#Java_sun_awt_motif_MChoicePeer_pSelect;
   4.187 +		#Java_sun_awt_motif_MChoicePeer_setFont;
   4.188 +		#Java_sun_awt_motif_MChoicePeer_setForeground;
   4.189 +		#Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
   4.190 +		#Java_sun_awt_motif_MComponentPeer_createBackBuffer;
   4.191 +		#Java_sun_awt_motif_MComponentPeer_destroyBackBuffer;
   4.192 +		#Java_sun_awt_motif_MComponentPeer_getNativeColor;
   4.193 +		#Java_sun_awt_motif_MComponentPeer_getWindow;
   4.194 +		#Java_sun_awt_motif_MComponentPeer_pDisable;
   4.195 +		#Java_sun_awt_motif_MComponentPeer_pDispose;
   4.196 +		#Java_sun_awt_motif_MComponentPeer_pEnable;
   4.197 +		#Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen;
   4.198 +		#Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2;
   4.199 +		#Java_sun_awt_motif_MComponentPeer_pHide;
   4.200 +		#Java_sun_awt_motif_MComponentPeer_pInitialize;
   4.201 +		#Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible;
   4.202 +		#Java_sun_awt_motif_MComponentPeer_pReshape;
   4.203 +		#Java_sun_awt_motif_MComponentPeer_pShow;
   4.204 +		#Java_sun_awt_motif_MComponentPeer_removeNativeDropTarget;
   4.205 +		#Java_sun_awt_motif_MComponentPeer_swapBuffers;
   4.206 +		#Java_sun_awt_motif_MComponentPeer_pSetBackground;
   4.207 +		#Java_sun_awt_motif_MComponentPeer_pSetFont;
   4.208 +                #Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer;
   4.209 +                #Java_sun_awt_motif_MComponentPeer__1requestFocus;
   4.210 +		#Java_sun_awt_motif_MCheckboxMenuItemPeer_getState;
   4.211 +		#Java_sun_awt_motif_MComponentPeer_pSetForeground;
   4.212 +		#Java_sun_awt_motif_MDragSourceContextPeer_startDrag;
   4.213 +		#Java_sun_awt_motif_MDragSourceContextPeer_setNativeCursor;
   4.214 +		#Java_sun_awt_motif_MDropTargetContextPeer_addTransfer;
   4.215 +		#Java_sun_awt_motif_MDropTargetContextPeer_dropDone;
   4.216 +		#Java_sun_awt_motif_MDropTargetContextPeer_startTransfer;
   4.217 +		#Java_sun_awt_motif_X11DragSourceContextPeer_startDrag;
   4.218 +		#Java_sun_awt_motif_X11DragSourceContextPeer_setNativeCursor;
   4.219 +		#Java_sun_awt_motif_X11DropTargetContextPeer_sendResponse;
   4.220 +		#Java_sun_awt_motif_X11DropTargetContextPeer_dropDone;
   4.221 +		#Java_sun_awt_motif_X11DropTargetContextPeer_getData;
   4.222 +		#Java_sun_awt_motif_MEmbeddedFramePeer_NEFcreate;
   4.223 +		#Java_sun_awt_motif_MEmbeddedFramePeer_pShowImpl;
   4.224 +		#Java_sun_awt_motif_MEmbeddedFramePeer_pReshapePrivate;
   4.225 +		#Java_sun_awt_motif_MEmbeddedFramePeer_getBoundsPrivate;
   4.226 +		#Java_sun_awt_motif_MFramePeer_pSetIconImage___3B_3I_3SII;
   4.227 +		#Java_sun_awt_motif_MEmbeddedFramePeer_requestXEmbedFocus;
   4.228 +		#Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedApplicationActive;
   4.229 +		#Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedActive;
   4.230 +		#Java_sun_awt_motif_MEmbeddedFrame_getWidget;
   4.231 +		#Java_sun_awt_motif_MEmbeddedFrame_mapWidget;
   4.232 +		#Java_sun_awt_motif_MFileDialogPeer_create;
   4.233 +		#Java_sun_awt_motif_MFileDialogPeer_pDispose;
   4.234 +		#Java_sun_awt_motif_MFileDialogPeer_pHide;
   4.235 +		#Java_sun_awt_motif_MFileDialogPeer_pReshape;
   4.236 +		#Java_sun_awt_motif_MFileDialogPeer_pShow;
   4.237 +		#Java_sun_awt_motif_MFileDialogPeer_setFileEntry;
   4.238 +		#Java_sun_awt_motif_MFileDialogPeer_setFont;
   4.239 +		#Java_sun_awt_motif_MFramePeer_pGetIconSize;
   4.240 +		#Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
   4.241 +		#Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
   4.242 +		#Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
   4.243 +		#Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
   4.244 +		#Java_sun_awt_motif_MGlobalCursorManager_getLocationOnScreen;
   4.245 +		#Java_sun_awt_motif_MLabelPeer_create;
   4.246 +		#Java_sun_awt_motif_MLabelPeer_setAlignment;
   4.247 +		#Java_sun_awt_motif_MLabelPeer_setText;
   4.248 +		#Java_sun_awt_motif_MListPeer_addItem;
   4.249 +		#Java_sun_awt_motif_MListPeer_create;
   4.250 +		#Java_sun_awt_motif_MListPeer_delItems;
   4.251 +		#Java_sun_awt_motif_MListPeer_deselect;
   4.252 +		#Java_sun_awt_motif_MListPeer_isSelected;
   4.253 +		#Java_sun_awt_motif_MListPeer_makeVisible;
   4.254 +		#Java_sun_awt_motif_MListPeer_select;
   4.255 +		#Java_sun_awt_motif_MListPeer_setMultipleSelections;
   4.256 +		#Java_sun_awt_motif_MMenuBarPeer_create;
   4.257 +		#Java_sun_awt_motif_MMenuItemPeer_createMenuItem;
   4.258 +		#Java_sun_awt_motif_MMenuItemPeer_pDisable;
   4.259 +		#Java_sun_awt_motif_MMenuItemPeer_pDispose;
   4.260 +		#Java_sun_awt_motif_MMenuItemPeer_pEnable;
   4.261 +		#Java_sun_awt_motif_MMenuItemPeer_pSetLabel;
   4.262 +		#Java_sun_awt_motif_MMenuPeer_createMenu;
   4.263 +		#Java_sun_awt_motif_MMenuPeer_createSubMenu;
   4.264 +		#Java_sun_awt_motif_MMenuPeer_pDispose;
   4.265 +		#Java_sun_awt_motif_MPopupMenuPeer_createMenu;
   4.266 +		#Java_sun_awt_motif_MPopupMenuPeer_pDispose;
   4.267 +		#Java_sun_awt_motif_MPopupMenuPeer_pShow;
   4.268 +		#Java_sun_awt_motif_MRobotPeer_getRGBPixelsImpl;
   4.269 +		#Java_sun_awt_motif_MRobotPeer_keyPressImpl;
   4.270 +		#Java_sun_awt_motif_MRobotPeer_keyReleaseImpl;
   4.271 +		#Java_sun_awt_motif_MRobotPeer_mouseMoveImpl;
   4.272 +		#Java_sun_awt_motif_MRobotPeer_mousePressImpl;
   4.273 +		#Java_sun_awt_motif_MRobotPeer_mouseReleaseImpl;
   4.274 +		#Java_sun_awt_motif_MRobotPeer_mouseWheelImpl;
   4.275 +		#Java_sun_awt_motif_MRobotPeer_setup;
   4.276 +		#Java_sun_awt_motif_MScrollbarPeer_create;
   4.277 +		#Java_sun_awt_motif_MScrollbarPeer_setLineIncrement;
   4.278 +		#Java_sun_awt_motif_MScrollbarPeer_setPageIncrement;
   4.279 +		#Java_sun_awt_motif_MScrollbarPeer_pSetValues;
   4.280 +		#Java_sun_awt_motif_MScrollPanePeer_create;
   4.281 +		#Java_sun_awt_motif_MScrollPanePeer_pGetBlockIncrement;
   4.282 +		#Java_sun_awt_motif_MScrollPanePeer_pGetScrollbarSpace;
   4.283 +		#Java_sun_awt_motif_MScrollPanePeer_pGetShadow;
   4.284 +		#Java_sun_awt_motif_MScrollPanePeer_pInsets;
   4.285 +		#Java_sun_awt_motif_MScrollPanePeer_pSetIncrement;
   4.286 +		#Java_sun_awt_motif_MScrollPanePeer_pSetScrollChild;
   4.287 +		#Java_sun_awt_motif_MScrollPanePeer_setScrollPosition;
   4.288 +		#Java_sun_awt_motif_MTextAreaPeer_initIDs;
   4.289 +		#Java_sun_awt_motif_MTextAreaPeer_pCreate;
   4.290 +		#Java_sun_awt_motif_MTextAreaPeer_getCaretPosition;
   4.291 +		#Java_sun_awt_motif_MTextAreaPeer_getExtraHeight;
   4.292 +		#Java_sun_awt_motif_MTextAreaPeer_getExtraWidth;
   4.293 +		#Java_sun_awt_motif_MTextAreaPeer_getSelectionEnd;
   4.294 +		#Java_sun_awt_motif_MTextAreaPeer_getSelectionStart;
   4.295 +		#Java_sun_awt_motif_MTextAreaPeer_getText;
   4.296 +		#Java_sun_awt_motif_MTextAreaPeer_insert;
   4.297 +		#Java_sun_awt_motif_MTextAreaPeer_pMakeCursorVisible;
   4.298 +		#Java_sun_awt_motif_MTextAreaPeer_pSetEditable;
   4.299 +		#Java_sun_awt_motif_MTextAreaPeer_pShow2;
   4.300 +		#Java_sun_awt_motif_MTextAreaPeer_replaceRange;
   4.301 +		#Java_sun_awt_motif_MTextAreaPeer_select;
   4.302 +		#Java_sun_awt_motif_MTextAreaPeer_setCaretPosition;
   4.303 +		#Java_sun_awt_motif_MTextAreaPeer_setFont;
   4.304 +		#Java_sun_awt_motif_MTextAreaPeer_setText;
   4.305 +		#Java_sun_awt_motif_MTextAreaPeer_setTextBackground;
   4.306 +		#Java_sun_awt_motif_MTextFieldPeer_initIDs;
   4.307 +		#Java_sun_awt_motif_MTextFieldPeer_pCreate;
   4.308 +		#Java_sun_awt_motif_MTextFieldPeer_getCaretPosition;
   4.309 +		#Java_sun_awt_motif_MTextFieldPeer_getSelectionEnd;
   4.310 +		#Java_sun_awt_motif_MTextFieldPeer_getSelectionStart;
   4.311 +		#Java_sun_awt_motif_MTextFieldPeer_getText;
   4.312 +		#Java_sun_awt_motif_MTextFieldPeer_insertReplaceText;
   4.313 +		#Java_sun_awt_motif_MTextFieldPeer_preDispose;
   4.314 +		#Java_sun_awt_motif_MTextFieldPeer_pSetEditable;
   4.315 +		#Java_sun_awt_motif_MTextFieldPeer_select;
   4.316 +		#Java_sun_awt_motif_MTextFieldPeer_setCaretPosition;
   4.317 +		#Java_sun_awt_motif_MTextFieldPeer_setEchoChar;
   4.318 +		#Java_sun_awt_motif_MTextFieldPeer_setFont;
   4.319 +		#Java_sun_awt_motif_MTextFieldPeer_setText;
   4.320  		Java_sun_awt_motif_MToolkit_beep;
   4.321  		Java_sun_awt_motif_MToolkit_getLockingKeyStateNative;
   4.322  		Java_sun_awt_motif_MToolkit_getMulticlickTime;
   4.323 @@ -357,28 +357,28 @@
   4.324  		Java_sun_awt_motif_MToolkit_sync;
   4.325                  Java_sun_awt_motif_MToolkit_isAlwaysOnTopSupported;
   4.326  		Java_sun_awt_motif_MWindowAttributes_initIDs;
   4.327 -		Java_sun_awt_motif_MWindowPeer_pDispose;
   4.328 -		Java_sun_awt_motif_MWindowPeer_pHide;
   4.329 -		Java_sun_awt_motif_MWindowPeer_pReshape;
   4.330 -		Java_sun_awt_motif_MWindowPeer_pSetTitle;
   4.331 -		Java_sun_awt_motif_MWindowPeer_pShow;
   4.332 -		Java_sun_awt_motif_MWindowPeer_setResizable;
   4.333 -		Java_sun_awt_motif_MWindowPeer_toBack;
   4.334 -		Java_sun_awt_motif_MWindowPeer_addTextComponentNative;
   4.335 -		Java_sun_awt_motif_MWindowPeer_getState;
   4.336 -		Java_sun_awt_motif_MWindowPeer_pSetIMMOption;
   4.337 -		Java_sun_awt_motif_MWindowPeer_pSetMenuBar;
   4.338 -		Java_sun_awt_motif_MWindowPeer_pShowModal;
   4.339 -		Java_sun_awt_motif_MWindowPeer_removeTextComponentNative;
   4.340 -		Java_sun_awt_motif_MWindowPeer_setSaveUnder;
   4.341 -		Java_sun_awt_motif_MWindowPeer_setState;
   4.342 -		Java_sun_awt_motif_MWindowPeer_resetTargetGC;
   4.343 -		Java_sun_awt_motif_MWindowPeer_registerX11DropTarget;
   4.344 -		Java_sun_awt_motif_MWindowPeer_unregisterX11DropTarget;
   4.345 -                Java_sun_awt_motif_MWindowPeer_updateAlwaysOnTop;
   4.346 -		Java_sun_awt_motif_X11CustomCursor_cacheInit;
   4.347 -		Java_sun_awt_motif_X11CustomCursor_createCursor;
   4.348 -		Java_sun_awt_motif_X11CustomCursor_queryBestCursor;
   4.349 +		#Java_sun_awt_motif_MWindowPeer_pDispose;
   4.350 +		#Java_sun_awt_motif_MWindowPeer_pHide;
   4.351 +		#Java_sun_awt_motif_MWindowPeer_pReshape;
   4.352 +		#Java_sun_awt_motif_MWindowPeer_pSetTitle;
   4.353 +		#Java_sun_awt_motif_MWindowPeer_pShow;
   4.354 +		#Java_sun_awt_motif_MWindowPeer_setResizable;
   4.355 +		#Java_sun_awt_motif_MWindowPeer_toBack;
   4.356 +		#Java_sun_awt_motif_MWindowPeer_addTextComponentNative;
   4.357 +		#Java_sun_awt_motif_MWindowPeer_getState;
   4.358 +		#Java_sun_awt_motif_MWindowPeer_pSetIMMOption;
   4.359 +		#Java_sun_awt_motif_MWindowPeer_pSetMenuBar;
   4.360 +		#Java_sun_awt_motif_MWindowPeer_pShowModal;
   4.361 +		#Java_sun_awt_motif_MWindowPeer_removeTextComponentNative;
   4.362 +		#Java_sun_awt_motif_MWindowPeer_setSaveUnder;
   4.363 +		#Java_sun_awt_motif_MWindowPeer_setState;
   4.364 +		#Java_sun_awt_motif_MWindowPeer_resetTargetGC;
   4.365 +		#Java_sun_awt_motif_MWindowPeer_registerX11DropTarget;
   4.366 +		#Java_sun_awt_motif_MWindowPeer_unregisterX11DropTarget;
   4.367 +                #Java_sun_awt_motif_MWindowPeer_updateAlwaysOnTop;
   4.368 +		#Java_sun_awt_motif_X11CustomCursor_cacheInit;
   4.369 +		#Java_sun_awt_motif_X11CustomCursor_createCursor;
   4.370 +		#Java_sun_awt_motif_X11CustomCursor_queryBestCursor;
   4.371  		Java_sun_awt_motif_X11FontMetrics_bytesWidth;
   4.372  		Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth;
   4.373  		Java_sun_awt_motif_X11FontMetrics_init;
   4.374 @@ -387,18 +387,18 @@
   4.375  		Java_sun_awt_X11InputMethod_resetXIC;
   4.376  		Java_sun_awt_X11InputMethod_setCompositionEnabledNative;
   4.377  		Java_sun_awt_X11InputMethod_turnoffStatusWindow;
   4.378 -		Java_sun_awt_motif_MInputMethod_openXIMNative;
   4.379 -		Java_sun_awt_motif_MInputMethod_configureStatusAreaNative;
   4.380 -		Java_sun_awt_motif_MInputMethod_createXICNative;
   4.381 -		Java_sun_awt_motif_MInputMethod_reconfigureXICNative;
   4.382 -		Java_sun_awt_motif_MInputMethod_setXICFocusNative;
   4.383 -		Java_sun_awt_motif_X11Clipboard_getClipboardData;
   4.384 -		Java_sun_awt_motif_X11Clipboard_getClipboardFormats;
   4.385 -		Java_sun_awt_motif_X11Clipboard_registerClipboardViewer;
   4.386 -		Java_sun_awt_motif_X11Clipboard_unregisterClipboardViewer;
   4.387 -		Java_sun_awt_motif_X11Selection_init;
   4.388 -		Java_sun_awt_motif_X11Selection_pGetSelectionOwnership;
   4.389 -		Java_sun_awt_motif_X11Selection_clearNativeContext;
   4.390 +		#Java_sun_awt_motif_MInputMethod_openXIMNative;
   4.391 +		#Java_sun_awt_motif_MInputMethod_configureStatusAreaNative;
   4.392 +		#Java_sun_awt_motif_MInputMethod_createXICNative;
   4.393 +		#Java_sun_awt_motif_MInputMethod_reconfigureXICNative;
   4.394 +		#Java_sun_awt_motif_MInputMethod_setXICFocusNative;
   4.395 +		#Java_sun_awt_motif_X11Clipboard_getClipboardData;
   4.396 +		#Java_sun_awt_motif_X11Clipboard_getClipboardFormats;
   4.397 +		#Java_sun_awt_motif_X11Clipboard_registerClipboardViewer;
   4.398 +		#Java_sun_awt_motif_X11Clipboard_unregisterClipboardViewer;
   4.399 +		#Java_sun_awt_motif_X11Selection_init;
   4.400 +		#Java_sun_awt_motif_X11Selection_pGetSelectionOwnership;
   4.401 +		#Java_sun_awt_motif_X11Selection_clearNativeContext;
   4.402  		Java_sun_awt_SunToolkit_closeSplashScreen;
   4.403  		Java_sun_awt_PlatformFont_initIDs;
   4.404  		Java_sun_awt_X11GraphicsConfig_init;
   4.405 @@ -442,40 +442,40 @@
   4.406  		Java_java_awt_Insets_initIDs;
   4.407  		Java_java_awt_TextField_initIDs;
   4.408  		Java_java_awt_Window_initIDs;
   4.409 -		Java_sun_awt_motif_MCheckboxPeer_getIndicatorSize;
   4.410 -		Java_sun_awt_motif_MCheckboxPeer_getSpacing;
   4.411 -		Java_sun_awt_motif_MChoicePeer_freeNativeData;
   4.412 -		Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
   4.413 -		Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
   4.414 -		Java_sun_awt_motif_MComponentPeer_initIDs;
   4.415 -		Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
   4.416 -		Java_sun_awt_motif_MComponentPeer_pSetCursor;
   4.417 -		Java_sun_awt_motif_MComponentPeer_pSetInnerForeground;
   4.418 -		Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground;
   4.419 -		Java_sun_awt_motif_MComponentPeer_setTargetBackground;
   4.420 -		Java_sun_awt_motif_MDataTransferer_dragQueryFile;
   4.421 -		Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
   4.422 -		Java_sun_awt_motif_MDataTransferer_getTargetNameForAtom;
   4.423 -		Java_sun_awt_motif_MFileDialogPeer_insertReplaceFileDialogText;
   4.424 +		#Java_sun_awt_motif_MCheckboxPeer_getIndicatorSize;
   4.425 +		#Java_sun_awt_motif_MCheckboxPeer_getSpacing;
   4.426 +		#Java_sun_awt_motif_MChoicePeer_freeNativeData;
   4.427 +		#Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
   4.428 +		#Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
   4.429 +		#Java_sun_awt_motif_MComponentPeer_initIDs;
   4.430 +		#Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
   4.431 +		#Java_sun_awt_motif_MComponentPeer_pSetCursor;
   4.432 +		#Java_sun_awt_motif_MComponentPeer_pSetInnerForeground;
   4.433 +		#Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground;
   4.434 +		#Java_sun_awt_motif_MComponentPeer_setTargetBackground;
   4.435 +		#Java_sun_awt_motif_MDataTransferer_dragQueryFile;
   4.436 +		#Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
   4.437 +		#Java_sun_awt_motif_MDataTransferer_getTargetNameForAtom;
   4.438 +		#Java_sun_awt_motif_MFileDialogPeer_insertReplaceFileDialogText;
   4.439  		Java_sun_awt_motif_MFontPeer_initIDs;
   4.440 -		Java_sun_awt_motif_MListPeer_setBackground;
   4.441 -		Java_sun_awt_motif_MMenuBarPeer_initIDs;
   4.442 -		Java_sun_awt_motif_MMenuBarPeer_pDispose;
   4.443 -		Java_sun_awt_motif_MMenuItemPeer_getParent_1NoClientCode;
   4.444 -		Java_sun_awt_motif_MMenuItemPeer_initIDs;
   4.445 -		Java_sun_awt_motif_MMenuItemPeer_pSetShortcut;
   4.446 -		Java_sun_awt_motif_MPopupMenuPeer_initIDs;
   4.447 -		Java_sun_awt_motif_MScrollbarPeer_initIDs;
   4.448 -		Java_sun_awt_motif_MScrollPanePeer_initIDs;
   4.449 -		Java_sun_awt_motif_MTextAreaPeer_pSetCursor;
   4.450 +		#Java_sun_awt_motif_MListPeer_setBackground;
   4.451 +		#Java_sun_awt_motif_MMenuBarPeer_initIDs;
   4.452 +		#Java_sun_awt_motif_MMenuBarPeer_pDispose;
   4.453 +		#Java_sun_awt_motif_MMenuItemPeer_getParent_1NoClientCode;
   4.454 +		#Java_sun_awt_motif_MMenuItemPeer_initIDs;
   4.455 +		#Java_sun_awt_motif_MMenuItemPeer_pSetShortcut;
   4.456 +		#Java_sun_awt_motif_MPopupMenuPeer_initIDs;
   4.457 +		#Java_sun_awt_motif_MScrollbarPeer_initIDs;
   4.458 +		#Java_sun_awt_motif_MScrollPanePeer_initIDs;
   4.459 +		#Java_sun_awt_motif_MTextAreaPeer_pSetCursor;
   4.460  		Java_sun_awt_motif_MToolkit_shutdown;
   4.461 -		Java_sun_awt_motif_MWindowPeer_initIDs;
   4.462 -		Java_sun_awt_motif_MWindowPeer_pCreate;
   4.463 -		Java_sun_awt_motif_MWindowPeer_wrapInSequenced;
   4.464 +		#Java_sun_awt_motif_MWindowPeer_initIDs;
   4.465 +		#Java_sun_awt_motif_MWindowPeer_pCreate;
   4.466 +		#Java_sun_awt_motif_MWindowPeer_wrapInSequenced;
   4.467  		Java_sun_awt_motif_X11FontMetrics_initIDs;
   4.468 -		Java_sun_awt_X11InputMethod_initIDs;
   4.469 +		#Java_sun_awt_X11InputMethod_initIDs;
   4.470  		Java_sun_awt_motif_X11OffScreenImage_updateBitmask;
   4.471 -		Java_sun_awt_motif_X11Selection_initIDs;
   4.472 +		#Java_sun_awt_motif_X11Selection_initIDs;
   4.473  		Java_sun_awt_motif_MToolkitThreadBlockedHandler_enter;
   4.474  		Java_sun_awt_motif_MToolkitThreadBlockedHandler_exit;
   4.475  		Java_sun_awt_X11GraphicsConfig_init;
   4.476 @@ -503,26 +503,26 @@
   4.477  		Java_sun_awt_X11SurfaceData_isDgaAvailable;
   4.478  		Java_sun_awt_X11SurfaceData_setInvalid;
   4.479  		Java_sun_awt_X11SurfaceData_flushNativeSurface;
   4.480 -                Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer;
   4.481 -                Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer;
   4.482 -                Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive;
   4.483 -                Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching;
   4.484 -                Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching;
   4.485 -                Java_sun_awt_motif_MEmbedCanvasPeer_embedChild;
   4.486 -                Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed;
   4.487 -                Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize;
   4.488 -                Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize;
   4.489 -                Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds;
   4.490 -                Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded;
   4.491 -                Java_sun_awt_motif_MEmbedCanvasPeer_detachChild;
   4.492 -                Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent;
   4.493 -                Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym;
   4.494 -                Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I;
   4.495 -                Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ;
   4.496 -                Java_sun_awt_motif_MEmbedCanvasPeer_getWindow;       
   4.497 -                Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded;       
   4.498 -                Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers;
   4.499 -                Java_sun_awt_motif_MEmbeddedFramePeer_traverseOut;
   4.500 +                #Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer;
   4.501 +                #Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer;
   4.502 +                #Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive;
   4.503 +                #Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching;
   4.504 +                #Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching;
   4.505 +                #Java_sun_awt_motif_MEmbedCanvasPeer_embedChild;
   4.506 +                #Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed;
   4.507 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize;
   4.508 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize;
   4.509 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds;
   4.510 +                #Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded;
   4.511 +                #Java_sun_awt_motif_MEmbedCanvasPeer_detachChild;
   4.512 +                #Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent;
   4.513 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym;
   4.514 +                #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I;
   4.515 +                #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ;
   4.516 +                #Java_sun_awt_motif_MEmbedCanvasPeer_getWindow;       
   4.517 +                #Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded;       
   4.518 +                #Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers;
   4.519 +                #Java_sun_awt_motif_MEmbeddedFramePeer_traverseOut;
   4.520  		awt_display;
   4.521  		awt_lock;
   4.522  		awt_Lock;
     5.1 --- a/make/sun/awt/mawt.gmk	Wed Sep 17 13:45:37 2008 -0700
     5.2 +++ b/make/sun/awt/mawt.gmk	Fri Sep 19 19:38:12 2008 -0700
     5.3 @@ -28,14 +28,6 @@
     5.4  #
     5.5  INIT += $(LIB_LOCATION) 
     5.6  
     5.7 -ifndef HEADLESS
     5.8 -ifeq ($(PLATFORM), linux)
     5.9 -ifeq ($(STATIC_MOTIF),false)
    5.10 -INIT += $(LIB_LOCATION)/libXm.so
    5.11 -endif
    5.12 -endif
    5.13 -endif
    5.14 -
    5.15  #
    5.16  # Files
    5.17  #
    5.18 @@ -52,13 +44,9 @@
    5.19  ifdef HEADLESS
    5.20    FILES_c = $(FILES_NO_MOTIF_c)
    5.21  else
    5.22 -  FILES_c = $(FILES_MOTIF_c) $(FILES_NO_MOTIF_c)
    5.23 -
    5.24 -  ifeq ($(MOTIF_VERSION), 2)
    5.25 -    FILES_c += awt_motif21.c
    5.26 -    FILES_c += awt_Choice21.c
    5.27 -  endif
    5.28 -
    5.29 +#  FILES_c = $(FILES_MOTIF_c) $(FILES_NO_MOTIF_c)
    5.30 +#  XXX if in FILES_MOTIF_c there are unrelated to motif stuff, create a separate list!
    5.31 +  FILES_c = $(FILES_NO_MOTIF_c)
    5.32  endif
    5.33  
    5.34  ifeq ($(PLATFORM), solaris)
    5.35 @@ -93,15 +81,6 @@
    5.36  $(LIB_LOCATION):
    5.37  	$(MKDIR) -p $@
    5.38  
    5.39 -ifeq ($(PLATFORM), linux)
    5.40 -ifeq ($(STATIC_MOTIF),false)
    5.41 -$(LIB_LOCATION)/libXm.so:
    5.42 -	$(CP) $(MOTIF_LIB)/libXm.so $(LIB_LOCATION)/libXm.so
    5.43 -# Automounter problem makes the link fail on Redhat 6.1.
    5.44 -#	$(LN) -s $(MOTIF_LIB)/libXm.so $(LIB_LOCATION)/libXm.so
    5.45 -endif
    5.46 -endif
    5.47 -
    5.48  clean:: 
    5.49  
    5.50  #
    5.51 @@ -135,33 +114,49 @@
    5.52  CPPFLAGS += -DHEADLESS=$(HEADLESS)
    5.53  OTHER_LDLIBS =
    5.54  else
    5.55 -CFLAGS += -DMOTIF_VERSION=$(MOTIF_VERSION)
    5.56 +#CFLAGS += -DMOTIF_VERSION=$(MOTIF_VERSION)
    5.57  
    5.58 -ifeq ($(STATIC_MOTIF),true)
    5.59 -    LIBXM = $(MOTIF_LIB)/libXm.a -lXp -lXmu
    5.60 -    ifeq ($(PLATFORM), linux)
    5.61 -	ifeq ($(ARCH_DATA_MODEL), 64)
    5.62 -            LIBXT = -lXt
    5.63 -        else
    5.64 -        # Allows for builds on Debian GNU Linux, X11 is in a different place 
    5.65 -	    LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \
    5.66 -                            $(wildcard /usr/lib/libXt.a))
    5.67 -	    LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
    5.68 -                            $(wildcard /usr/lib/libSM.a))
    5.69 -	    LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \
    5.70 -                             $(wildcard /usr/lib/libICE.a))
    5.71 -	endif
    5.72 -    endif
    5.73 -else
    5.74 -    LIBXM = -L$(MOTIF_LIB) -lXm -lXp
    5.75 -    ifeq ($(PLATFORM), linux)
    5.76 -	LIBXT = -lXt
    5.77 -	LIBSM = 
    5.78 -	LIBICE = 
    5.79 -    endif
    5.80 -endif
    5.81 +#ifeq ($(STATIC_MOTIF),true)
    5.82 +#    LIBXM = $(MOTIF_LIB)/libXm.a -lXp -lXmu
    5.83 +#    ifeq ($(PLATFORM), linux)
    5.84 +#	ifeq ($(ARCH_DATA_MODEL), 64)
    5.85 +#            LIBXT = -lXt
    5.86 +#        else
    5.87 +#        # Allows for builds on Debian GNU Linux, X11 is in a different place 
    5.88 +#	    LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \
    5.89 +#                            $(wildcard /usr/lib/libXt.a))
    5.90 +#	    LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
    5.91 +#                            $(wildcard /usr/lib/libSM.a))
    5.92 +#	    LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \
    5.93 +#                             $(wildcard /usr/lib/libICE.a))
    5.94 +#	endif
    5.95 +#    endif
    5.96 +#else
    5.97 +#    LIBXM = -L$(MOTIF_LIB) -lXm -lXp
    5.98 +#    ifeq ($(PLATFORM), linux)
    5.99 +#	LIBXT = -lXt
   5.100 +#	LIBSM = 
   5.101 +#	LIBICE = 
   5.102 +#    endif
   5.103 +#endif
   5.104  
   5.105  LIBXTST = -lXtst
   5.106 +ifeq ($(PLATFORM), linux)
   5.107 +   ifeq ($(ARCH_DATA_MODEL), 64)
   5.108 +   # XXX what about the rest of them?
   5.109 +        LIBXT = -lXt
   5.110 +    else
   5.111 +    # Allows for builds on Debian GNU Linux, X11 is in a different place 
   5.112 +       LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \
   5.113 +                        $(wildcard /usr/lib/libXt.a))
   5.114 +       LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
   5.115 +                        $(wildcard /usr/lib/libSM.a))
   5.116 +       LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \
   5.117 +                         $(wildcard /usr/lib/libICE.a))
   5.118 +       LIBXTST = $(firstword $(wildcard /usr/X11R6/lib/libXtst.a) \
   5.119 +                         $(wildcard /usr/lib/libXtst.a))
   5.120 +   endif
   5.121 +endif
   5.122  
   5.123  # Use -lXmu for EditRes support
   5.124  LIBXMU_DBG	= -lXmu
   5.125 @@ -169,14 +164,14 @@
   5.126  LIBXMU		= $(LIBXMU_$(VARIANT))
   5.127  
   5.128  ifeq ($(PLATFORM), solaris)
   5.129 -OTHER_LDLIBS = $(LIBXM) -lXt -lXext $(LIBXTST) $(LIBXMU) -lX11 -lXi
   5.130 +OTHER_LDLIBS = -lXt -lXext $(LIBXTST) $(LIBXMU) -lX11 -lXi
   5.131  endif
   5.132  
   5.133  ifeq ($(PLATFORM), linux)
   5.134  OTHER_CFLAGS += -DMLIB_NO_LIBSUNMATH
   5.135 -OTHER_CFLAGS += -DMOTIF_VERSION=2
   5.136 +# XXX what is this define below? Isn't it motif-related?
   5.137  OTHER_CFLAGS += -DXMSTRINGDEFINES=1
   5.138 -OTHER_LDLIBS = $(LIBXM) $(LIBXMU) $(LIBXTST) -lXext $(LIBXT) $(LIBSM) $(LIBICE) -lX11 -lXi
   5.139 +OTHER_LDLIBS =  $(LIBXMU) $(LIBXTST) -lXext $(LIBXT) $(LIBSM) $(LIBICE) -lX11 -lXi
   5.140  endif
   5.141  
   5.142  endif
   5.143 @@ -199,9 +194,8 @@
   5.144  CPPFLAGS += -I$(CUPS_HEADERS_PATH)
   5.145  
   5.146  ifndef HEADLESS
   5.147 -CPPFLAGS += -I$(MOTIF_DIR)/include \
   5.148 -            -I$(OPENWIN_HOME)/include 
   5.149 -LDFLAGS  += -L$(MOTIF_LIB) -L$(OPENWIN_LIB)
   5.150 +CPPFLAGS += -I$(OPENWIN_HOME)/include 
   5.151 +LDFLAGS  += -L$(OPENWIN_LIB)
   5.152  
   5.153  endif # !HEADLESS
   5.154  
     6.1 --- a/src/share/classes/java/awt/Button.java	Wed Sep 17 13:45:37 2008 -0700
     6.2 +++ b/src/share/classes/java/awt/Button.java	Fri Sep 19 19:38:12 2008 -0700
     6.3 @@ -213,8 +213,8 @@
     6.4          }
     6.5  
     6.6          // This could change the preferred size of the Component.
     6.7 -        if (testvalid && valid) {
     6.8 -            invalidate();
     6.9 +        if (testvalid) {
    6.10 +            invalidateIfValid();
    6.11          }
    6.12      }
    6.13  
     7.1 --- a/src/share/classes/java/awt/Checkbox.java	Wed Sep 17 13:45:37 2008 -0700
     7.2 +++ b/src/share/classes/java/awt/Checkbox.java	Fri Sep 19 19:38:12 2008 -0700
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
     7.6 + * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -284,8 +284,8 @@
    7.11          }
    7.12  
    7.13          // This could change the preferred size of the Component.
    7.14 -        if (testvalid && valid) {
    7.15 -            invalidate();
    7.16 +        if (testvalid) {
    7.17 +            invalidateIfValid();
    7.18          }
    7.19      }
    7.20  
     8.1 --- a/src/share/classes/java/awt/Choice.java	Wed Sep 17 13:45:37 2008 -0700
     8.2 +++ b/src/share/classes/java/awt/Choice.java	Fri Sep 19 19:38:12 2008 -0700
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
     8.6 + * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -207,9 +207,7 @@
    8.11          }
    8.12  
    8.13          // This could change the preferred size of the Component.
    8.14 -        if (valid) {
    8.15 -            invalidate();
    8.16 -        }
    8.17 +        invalidateIfValid();
    8.18      }
    8.19  
    8.20      /**
    8.21 @@ -269,9 +267,7 @@
    8.22          }
    8.23  
    8.24          // This could change the preferred size of the Component.
    8.25 -        if (valid) {
    8.26 -            invalidate();
    8.27 -        }
    8.28 +        invalidateIfValid();
    8.29      }
    8.30  
    8.31      /**
    8.32 @@ -299,9 +295,7 @@
    8.33          }
    8.34  
    8.35          // This could change the preferred size of the Component.
    8.36 -        if (valid) {
    8.37 -            invalidate();
    8.38 -        }
    8.39 +        invalidateIfValid();
    8.40      }
    8.41  
    8.42      /**
    8.43 @@ -323,9 +317,7 @@
    8.44          }
    8.45  
    8.46          // This could change the preferred size of the Component.
    8.47 -        if (valid) {
    8.48 -            invalidate();
    8.49 -        }
    8.50 +        invalidateIfValid();
    8.51      }
    8.52  
    8.53      /**
    8.54 @@ -367,9 +359,7 @@
    8.55          }
    8.56  
    8.57          // This could change the preferred size of the Component.
    8.58 -        if (valid) {
    8.59 -            invalidate();
    8.60 -        }
    8.61 +        invalidateIfValid();
    8.62      }
    8.63  
    8.64      /**
     9.1 --- a/src/share/classes/java/awt/Component.java	Wed Sep 17 13:45:37 2008 -0700
     9.2 +++ b/src/share/classes/java/awt/Component.java	Fri Sep 19 19:38:12 2008 -0700
     9.3 @@ -350,7 +350,7 @@
     9.4       * @see #validate
     9.5       * @see #invalidate
     9.6       */
     9.7 -    volatile boolean valid = false;
     9.8 +    private volatile boolean valid = false;
     9.9  
    9.10      /**
    9.11       * The <code>DropTarget</code> associated with this component.
    9.12 @@ -639,11 +639,21 @@
    9.13       */
    9.14      private PropertyChangeSupport changeSupport;
    9.15  
    9.16 -    // Note: this field is considered final, though readObject() prohibits
    9.17 -    // initializing final fields.
    9.18 -    private transient Object changeSupportLock = new Object();
    9.19 -    private Object getChangeSupportLock() {
    9.20 -        return changeSupportLock;
    9.21 +    /*
    9.22 +     * In some cases using "this" as an object to synchronize by
    9.23 +     * can lead to a deadlock if client code also uses synchronization
    9.24 +     * by a component object. For every such situation revealed we should
    9.25 +     * consider possibility of replacing "this" with the package private
    9.26 +     * objectLock object introduced below. So far there're 2 issues known:
    9.27 +     * - CR 6708322 (the getName/setName methods);
    9.28 +     * - CR 6608764 (the PropertyChangeListener machinery).
    9.29 +     *
    9.30 +     * Note: this field is considered final, though readObject() prohibits
    9.31 +     * initializing final fields.
    9.32 +     */
    9.33 +    private transient Object objectLock = new Object();
    9.34 +    Object getObjectLock() {
    9.35 +        return objectLock;
    9.36      }
    9.37  
    9.38      boolean isPacked = false;
    9.39 @@ -816,7 +826,7 @@
    9.40       */
    9.41      public String getName() {
    9.42          if (name == null && !nameExplicitlySet) {
    9.43 -            synchronized(this) {
    9.44 +            synchronized(getObjectLock()) {
    9.45                  if (name == null && !nameExplicitlySet)
    9.46                      name = constructComponentName();
    9.47              }
    9.48 @@ -833,7 +843,7 @@
    9.49       */
    9.50      public void setName(String name) {
    9.51          String oldName;
    9.52 -        synchronized(this) {
    9.53 +        synchronized(getObjectLock()) {
    9.54              oldName = this.name;
    9.55              this.name = name;
    9.56              nameExplicitlySet = true;
    9.57 @@ -1708,9 +1718,9 @@
    9.58          // This could change the preferred size of the Component.
    9.59          // Fix for 6213660. Should compare old and new fonts and do not
    9.60          // call invalidate() if they are equal.
    9.61 -        if (valid && f != oldFont && (oldFont == null ||
    9.62 +        if (f != oldFont && (oldFont == null ||
    9.63                                        !oldFont.equals(f))) {
    9.64 -            invalidate();
    9.65 +            invalidateIfValid();
    9.66          }
    9.67      }
    9.68  
    9.69 @@ -1767,9 +1777,7 @@
    9.70          firePropertyChange("locale", oldValue, l);
    9.71  
    9.72          // This could change the preferred size of the Component.
    9.73 -        if (valid) {
    9.74 -            invalidate();
    9.75 -        }
    9.76 +        invalidateIfValid();
    9.77      }
    9.78  
    9.79      /**
    9.80 @@ -2078,8 +2086,8 @@
    9.81                      if (resized) {
    9.82                          invalidate();
    9.83                      }
    9.84 -                    if (parent != null && parent.valid) {
    9.85 -                        parent.invalidate();
    9.86 +                    if (parent != null) {
    9.87 +                        parent.invalidateIfValid();
    9.88                      }
    9.89                  }
    9.90                  if (needNotify) {
    9.91 @@ -2135,7 +2143,7 @@
    9.92                      Toolkit.getEventQueue().postEvent(e);
    9.93                  }
    9.94              } else {
    9.95 -                if (this instanceof Container && ((Container)this).ncomponents > 0) {
    9.96 +                if (this instanceof Container && ((Container)this).countComponents() > 0) {
    9.97                      boolean enabledOnToolkit =
    9.98                          Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK);
    9.99                      if (resized) {
   9.100 @@ -2648,7 +2656,8 @@
   9.101      public void validate() {
   9.102          synchronized (getTreeLock()) {
   9.103              ComponentPeer peer = this.peer;
   9.104 -            if (!valid && peer != null) {
   9.105 +            boolean wasValid = isValid();
   9.106 +            if (!wasValid && peer != null) {
   9.107                  Font newfont = getFont();
   9.108                  Font oldfont = peerFont;
   9.109                  if (newfont != oldfont && (oldfont == null
   9.110 @@ -2659,6 +2668,9 @@
   9.111                  peer.layout();
   9.112              }
   9.113              valid = true;
   9.114 +            if (!wasValid) {
   9.115 +                mixOnValidating();
   9.116 +            }
   9.117          }
   9.118      }
   9.119  
   9.120 @@ -2687,9 +2699,17 @@
   9.121              if (!isMaximumSizeSet()) {
   9.122                  maxSize = null;
   9.123              }
   9.124 -            if (parent != null && parent.valid) {
   9.125 -                parent.invalidate();
   9.126 -            }
   9.127 +            if (parent != null) {
   9.128 +                parent.invalidateIfValid();
   9.129 +            }
   9.130 +        }
   9.131 +    }
   9.132 +
   9.133 +    /** Invalidates the component unless it is already invalid.
   9.134 +     */
   9.135 +    final void invalidateIfValid() {
   9.136 +        if (isValid()) {
   9.137 +            invalidate();
   9.138          }
   9.139      }
   9.140  
   9.141 @@ -5794,7 +5814,7 @@
   9.142          }
   9.143      }
   9.144  
   9.145 -    transient EventQueueItem[] eventCache;
   9.146 +    transient sun.awt.EventQueueItem[] eventCache;
   9.147  
   9.148      /**
   9.149       * @see #isCoalescingEnabled
   9.150 @@ -7545,9 +7565,7 @@
   9.151          Container rootAncestor = getTraversalRoot();
   9.152          Component comp = this;
   9.153          while (rootAncestor != null &&
   9.154 -               !(rootAncestor.isShowing() &&
   9.155 -                 rootAncestor.isFocusable() &&
   9.156 -                 rootAncestor.isEnabled()))
   9.157 +               !(rootAncestor.isShowing() && rootAncestor.canBeFocusOwner()))
   9.158          {
   9.159              comp = rootAncestor;
   9.160              rootAncestor = comp.getFocusCycleRootAncestor();
   9.161 @@ -7596,9 +7614,7 @@
   9.162          Container rootAncestor = getTraversalRoot();
   9.163          Component comp = this;
   9.164          while (rootAncestor != null &&
   9.165 -               !(rootAncestor.isShowing() &&
   9.166 -                 rootAncestor.isFocusable() &&
   9.167 -                 rootAncestor.isEnabled()))
   9.168 +               !(rootAncestor.isShowing() && rootAncestor.canBeFocusOwner()))
   9.169          {
   9.170              comp = rootAncestor;
   9.171              rootAncestor = comp.getFocusCycleRootAncestor();
   9.172 @@ -7777,7 +7793,7 @@
   9.173      protected String paramString() {
   9.174          String thisName = getName();
   9.175          String str = (thisName != null? thisName : "") + "," + x + "," + y + "," + width + "x" + height;
   9.176 -        if (!valid) {
   9.177 +        if (!isValid()) {
   9.178              str += ",invalid";
   9.179          }
   9.180          if (!visible) {
   9.181 @@ -7905,7 +7921,7 @@
   9.182       */
   9.183      public void addPropertyChangeListener(
   9.184                                                         PropertyChangeListener listener) {
   9.185 -        synchronized (getChangeSupportLock()) {
   9.186 +        synchronized (getObjectLock()) {
   9.187              if (listener == null) {
   9.188                  return;
   9.189              }
   9.190 @@ -7931,7 +7947,7 @@
   9.191       */
   9.192      public void removePropertyChangeListener(
   9.193                                                            PropertyChangeListener listener) {
   9.194 -        synchronized (getChangeSupportLock()) {
   9.195 +        synchronized (getObjectLock()) {
   9.196              if (listener == null || changeSupport == null) {
   9.197                  return;
   9.198              }
   9.199 @@ -7954,7 +7970,7 @@
   9.200       * @since    1.4
   9.201       */
   9.202      public PropertyChangeListener[] getPropertyChangeListeners() {
   9.203 -        synchronized (getChangeSupportLock()) {
   9.204 +        synchronized (getObjectLock()) {
   9.205              if (changeSupport == null) {
   9.206                  return new PropertyChangeListener[0];
   9.207              }
   9.208 @@ -7996,7 +8012,7 @@
   9.209      public void addPropertyChangeListener(
   9.210                                                         String propertyName,
   9.211                                                         PropertyChangeListener listener) {
   9.212 -        synchronized (getChangeSupportLock()) {
   9.213 +        synchronized (getObjectLock()) {
   9.214              if (listener == null) {
   9.215                  return;
   9.216              }
   9.217 @@ -8026,7 +8042,7 @@
   9.218      public void removePropertyChangeListener(
   9.219                                                            String propertyName,
   9.220                                                            PropertyChangeListener listener) {
   9.221 -        synchronized (getChangeSupportLock()) {
   9.222 +        synchronized (getObjectLock()) {
   9.223              if (listener == null || changeSupport == null) {
   9.224                  return;
   9.225              }
   9.226 @@ -8050,7 +8066,7 @@
   9.227       */
   9.228      public PropertyChangeListener[] getPropertyChangeListeners(
   9.229                                                                              String propertyName) {
   9.230 -        synchronized (getChangeSupportLock()) {
   9.231 +        synchronized (getObjectLock()) {
   9.232              if (changeSupport == null) {
   9.233                  return new PropertyChangeListener[0];
   9.234              }
   9.235 @@ -8071,7 +8087,7 @@
   9.236      protected void firePropertyChange(String propertyName,
   9.237                                        Object oldValue, Object newValue) {
   9.238          PropertyChangeSupport changeSupport;
   9.239 -        synchronized (getChangeSupportLock()) {
   9.240 +        synchronized (getObjectLock()) {
   9.241              changeSupport = this.changeSupport;
   9.242          }
   9.243          if (changeSupport == null ||
   9.244 @@ -8373,7 +8389,7 @@
   9.245      private void readObject(ObjectInputStream s)
   9.246        throws ClassNotFoundException, IOException
   9.247      {
   9.248 -        changeSupportLock = new Object();
   9.249 +        objectLock = new Object();
   9.250  
   9.251          s.defaultReadObject();
   9.252  
   9.253 @@ -8537,9 +8553,7 @@
   9.254          firePropertyChange("componentOrientation", oldValue, o);
   9.255  
   9.256          // This could change the preferred size of the Component.
   9.257 -        if (valid) {
   9.258 -            invalidate();
   9.259 -        }
   9.260 +        invalidateIfValid();
   9.261      }
   9.262  
   9.263      /**
   9.264 @@ -8575,6 +8589,14 @@
   9.265          setComponentOrientation(orientation);
   9.266      }
   9.267  
   9.268 +    final boolean canBeFocusOwner() {
   9.269 +        // It is enabled, visible, focusable.
   9.270 +        if (isEnabled() && isDisplayable() && isVisible() && isFocusable()) {
   9.271 +            return true;
   9.272 +        }
   9.273 +        return false;
   9.274 +    }
   9.275 +
   9.276      /**
   9.277       * Checks that this component meets the prerequesites to be focus owner:
   9.278       * - it is enabled, visible, focusable
   9.279 @@ -8584,9 +8606,9 @@
   9.280       * this component as focus owner
   9.281       * @since 1.5
   9.282       */
   9.283 -    final boolean canBeFocusOwner() {
   9.284 +    final boolean canBeFocusOwnerRecursively() {
   9.285          // - it is enabled, visible, focusable
   9.286 -        if (!(isEnabled() && isDisplayable() && isVisible() && isFocusable())) {
   9.287 +        if (!canBeFocusOwner()) {
   9.288              return false;
   9.289          }
   9.290  
   9.291 @@ -9381,7 +9403,8 @@
   9.292       */
   9.293      private boolean areBoundsValid() {
   9.294          Container cont = getContainer();
   9.295 -        return cont == null || cont.isValid() || cont.getLayout() == null;
   9.296 +        return cont == null || cont.isValid()
   9.297 +            || cont.getLayout() == null;
   9.298      }
   9.299  
   9.300      /**
   9.301 @@ -9652,5 +9675,10 @@
   9.302          }
   9.303      }
   9.304  
   9.305 +    void mixOnValidating() {
   9.306 +        // This method gets overriden in the Container. Obviously, a plain
   9.307 +        // non-container components don't need to handle validation.
   9.308 +    }
   9.309 +
   9.310      // ****************** END OF MIXING CODE ********************************
   9.311  }
    10.1 --- a/src/share/classes/java/awt/Container.java	Wed Sep 17 13:45:37 2008 -0700
    10.2 +++ b/src/share/classes/java/awt/Container.java	Fri Sep 19 19:38:12 2008 -0700
    10.3 @@ -44,8 +44,6 @@
    10.4  import java.util.Arrays;
    10.5  import java.util.EventListener;
    10.6  import java.util.HashSet;
    10.7 -import java.util.Iterator;
    10.8 -import java.util.LinkedList;
    10.9  import java.util.Set;
   10.10  
   10.11  import java.util.logging.*;
   10.12 @@ -90,21 +88,14 @@
   10.13      private static final Logger log = Logger.getLogger("java.awt.Container");
   10.14      private static final Logger eventLog = Logger.getLogger("java.awt.event.Container");
   10.15  
   10.16 -    /**
   10.17 -     * The number of components in this container.
   10.18 -     * This value can be null.
   10.19 -     * @see #getComponent
   10.20 -     * @see #getComponents
   10.21 -     * @see #getComponentCount
   10.22 -     */
   10.23 -    int ncomponents;
   10.24 +    private static final Component[] EMPTY_ARRAY = new Component[0];
   10.25  
   10.26      /**
   10.27       * The components in this container.
   10.28       * @see #add
   10.29       * @see #getComponents
   10.30       */
   10.31 -    Component component[] = new Component[0];
   10.32 +    private java.util.List<Component> component = new java.util.ArrayList<Component>();
   10.33  
   10.34      /**
   10.35       * Layout manager for this container.
   10.36 @@ -290,7 +281,9 @@
   10.37       */
   10.38      @Deprecated
   10.39      public int countComponents() {
   10.40 -        return ncomponents;
   10.41 +        synchronized (getTreeLock()) {
   10.42 +            return component.size();
   10.43 +        }
   10.44      }
   10.45  
   10.46      /**
   10.47 @@ -302,10 +295,10 @@
   10.48       */
   10.49      public Component getComponent(int n) {
   10.50          synchronized (getTreeLock()) {
   10.51 -            if ((n < 0) || (n >= ncomponents)) {
   10.52 +            if ((n < 0) || (n >= component.size())) {
   10.53                  throw new ArrayIndexOutOfBoundsException("No such child: " + n);
   10.54              }
   10.55 -            return component[n];
   10.56 +            return component.get(n);
   10.57          }
   10.58      }
   10.59  
   10.60 @@ -322,7 +315,7 @@
   10.61      //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   10.62      final Component[] getComponents_NoClientCode() {
   10.63          synchronized (getTreeLock()) {
   10.64 -            return Arrays.copyOf(component, ncomponents);
   10.65 +            return component.toArray(EMPTY_ARRAY);
   10.66          }
   10.67      } // getComponents_NoClientCode()
   10.68  
   10.69 @@ -422,6 +415,29 @@
   10.70      }
   10.71  
   10.72      /**
   10.73 +     * Checks that the component
   10.74 +     * isn't supposed to be added into itself.
   10.75 +     */
   10.76 +    private void checkAddToSelf(Component comp){
   10.77 +        if (comp instanceof Container) {
   10.78 +            for (Container cn = this; cn != null; cn=cn.parent) {
   10.79 +                if (cn == comp) {
   10.80 +                    throw new IllegalArgumentException("adding container's parent to itself");
   10.81 +                }
   10.82 +            }
   10.83 +        }
   10.84 +    }
   10.85 +
   10.86 +    /**
   10.87 +     * Checks that the component is not a Window instance.
   10.88 +     */
   10.89 +    private void checkNotAWindow(Component comp){
   10.90 +        if (comp instanceof Window) {
   10.91 +            throw new IllegalArgumentException("adding a window to a container");
   10.92 +        }
   10.93 +    }
   10.94 +
   10.95 +    /**
   10.96       * Checks that the component comp can be added to this container
   10.97       * Checks :  index in bounds of container's size,
   10.98       * comp is not one of this container's parents,
   10.99 @@ -437,26 +453,18 @@
  10.100  
  10.101          GraphicsConfiguration thisGC = getGraphicsConfiguration();
  10.102  
  10.103 -        if (index > ncomponents || index < 0) {
  10.104 +        if (index > component.size() || index < 0) {
  10.105              throw new IllegalArgumentException("illegal component position");
  10.106          }
  10.107          if (comp.parent == this) {
  10.108 -            if (index == ncomponents) {
  10.109 +            if (index == component.size()) {
  10.110                  throw new IllegalArgumentException("illegal component position " +
  10.111 -                                                   index + " should be less then " + ncomponents);
  10.112 +                                                   index + " should be less then " + component.size());
  10.113              }
  10.114          }
  10.115 -        if (comp instanceof Container) {
  10.116 -            for (Container cn = this; cn != null; cn=cn.parent) {
  10.117 -                if (cn == comp) {
  10.118 -                    throw new IllegalArgumentException("adding container's parent to itself");
  10.119 -                }
  10.120 -            }
  10.121 -
  10.122 -            if (comp instanceof Window) {
  10.123 -                throw new IllegalArgumentException("adding a window to a container");
  10.124 -            }
  10.125 -        }
  10.126 +        checkAddToSelf(comp);
  10.127 +        checkNotAWindow(comp);
  10.128 +
  10.129          Window thisTopLevel = getContainingWindow();
  10.130          Window compTopLevel = comp.getContainingWindow();
  10.131          if (thisTopLevel != compTopLevel) {
  10.132 @@ -495,25 +503,17 @@
  10.133              adjustDescendants(-(comp.countHierarchyMembers()));
  10.134  
  10.135              comp.parent = null;
  10.136 -            System.arraycopy(component, index + 1,
  10.137 -                             component, index,
  10.138 -                             ncomponents - index - 1);
  10.139 -            component[--ncomponents] = null;
  10.140 -
  10.141 -            if (valid) {
  10.142 -                invalidate();
  10.143 -            }
  10.144 +            component.remove(index);
  10.145 +
  10.146 +            invalidateIfValid();
  10.147          } else {
  10.148 -            if (newIndex > index) { // 2->4: 012345 -> 013425, 2->5: 012345 -> 013452
  10.149 -                if (newIndex-index > 0) {
  10.150 -                    System.arraycopy(component, index+1, component, index, newIndex-index);
  10.151 -                }
  10.152 -            } else { // 4->2: 012345 -> 014235
  10.153 -                if (index-newIndex > 0) {
  10.154 -                    System.arraycopy(component, newIndex, component, newIndex+1, index-newIndex);
  10.155 -                }
  10.156 -            }
  10.157 -            component[newIndex] = comp;
  10.158 +            // We should remove component and then
  10.159 +            // add it by the newIndex without newIndex decrement if even we shift components to the left
  10.160 +            // after remove. Consult the rules below:
  10.161 +            // 2->4: 012345 -> 013425, 2->5: 012345 -> 013452
  10.162 +            // 4->2: 012345 -> 014235
  10.163 +            component.remove(index);
  10.164 +            component.add(newIndex, comp);
  10.165          }
  10.166          if (comp.parent == null) { // was actually removed
  10.167              if (containerListener != null ||
  10.168 @@ -779,17 +779,11 @@
  10.169  
  10.170          // Check if moving between containers
  10.171          if (curParent != this) {
  10.172 -            /* Add component to list; allocate new array if necessary. */
  10.173 -            if (ncomponents == component.length) {
  10.174 -                component = Arrays.copyOf(component, ncomponents * 2 + 1);
  10.175 -            }
  10.176 -            if (index == -1 || index == ncomponents) {
  10.177 -                component[ncomponents++] = comp;
  10.178 +            //index == -1 means add to the end.
  10.179 +            if (index == -1) {
  10.180 +                component.add(comp);
  10.181              } else {
  10.182 -                System.arraycopy(component, index, component,
  10.183 -                                 index + 1, ncomponents - index);
  10.184 -                component[index] = comp;
  10.185 -                ncomponents++;
  10.186 +                component.add(index, comp);
  10.187              }
  10.188              comp.parent = this;
  10.189  
  10.190 @@ -799,14 +793,12 @@
  10.191                                      comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
  10.192              adjustDescendants(comp.countHierarchyMembers());
  10.193          } else {
  10.194 -            if (index < ncomponents) {
  10.195 -                component[index] = comp;
  10.196 +            if (index < component.size()) {
  10.197 +                component.set(index, comp);
  10.198              }
  10.199          }
  10.200  
  10.201 -        if (valid) {
  10.202 -            invalidate();
  10.203 -        }
  10.204 +        invalidateIfValid();
  10.205          if (peer != null) {
  10.206              if (comp.peer == null) { // Remove notify was called or it didn't have peer - create new one
  10.207                  comp.addNotify();
  10.208 @@ -860,11 +852,11 @@
  10.209  
  10.210              // If component is focus owner or parent container of focus owner check that after reparenting
  10.211              // focus owner moved out if new container prohibit this kind of focus owner.
  10.212 -            if (comp.isFocusOwner() && !comp.canBeFocusOwner()) {
  10.213 +            if (comp.isFocusOwner() && !comp.canBeFocusOwnerRecursively()) {
  10.214                  comp.transferFocus();
  10.215              } else if (comp instanceof Container) {
  10.216                  Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  10.217 -                if (focusOwner != null && isParentOf(focusOwner) && !focusOwner.canBeFocusOwner()) {
  10.218 +                if (focusOwner != null && isParentOf(focusOwner) && !focusOwner.canBeFocusOwnerRecursively()) {
  10.219                      focusOwner.transferFocus();
  10.220                  }
  10.221              }
  10.222 @@ -901,14 +893,8 @@
  10.223              if (comp.parent != this) {
  10.224                  return -1;
  10.225              }
  10.226 -            for (int i = 0; i < ncomponents; i++) {
  10.227 -                if (component[i] == comp) {
  10.228 -                    return i;
  10.229 -                }
  10.230 -            }
  10.231 +            return component.indexOf(comp);
  10.232          }
  10.233 -        // To please javac
  10.234 -        return -1;
  10.235      }
  10.236  
  10.237      /**
  10.238 @@ -1042,22 +1028,12 @@
  10.239               */
  10.240              GraphicsConfiguration thisGC = this.getGraphicsConfiguration();
  10.241  
  10.242 -            if (index > ncomponents || (index < 0 && index != -1)) {
  10.243 +            if (index > component.size() || (index < 0 && index != -1)) {
  10.244                  throw new IllegalArgumentException(
  10.245                            "illegal component position");
  10.246              }
  10.247 -        if (comp instanceof Container) {
  10.248 -            for (Container cn = this; cn != null; cn=cn.parent) {
  10.249 -                if (cn == comp) {
  10.250 -                throw new IllegalArgumentException(
  10.251 -                      "adding container's parent to itself");
  10.252 -                }
  10.253 -            }
  10.254 -            if (comp instanceof Window) {
  10.255 -                throw new IllegalArgumentException(
  10.256 -                       "adding a window to a container");
  10.257 -            }
  10.258 -        }
  10.259 +            checkAddToSelf(comp);
  10.260 +            checkNotAWindow(comp);
  10.261          if (thisGC != null) {
  10.262              comp.checkGD(thisGC.getDevice().getIDstring());
  10.263          }
  10.264 @@ -1065,22 +1041,16 @@
  10.265              /* Reparent the component and tidy up the tree's state. */
  10.266              if (comp.parent != null) {
  10.267                  comp.parent.remove(comp);
  10.268 -                    if (index > ncomponents) {
  10.269 +                    if (index > component.size()) {
  10.270                          throw new IllegalArgumentException("illegal component position");
  10.271                      }
  10.272              }
  10.273  
  10.274 -            /* Add component to list; allocate new array if necessary. */
  10.275 -            if (ncomponents == component.length) {
  10.276 -                component = Arrays.copyOf(component, ncomponents * 2 + 1);
  10.277 -            }
  10.278 -            if (index == -1 || index == ncomponents) {
  10.279 -                component[ncomponents++] = comp;
  10.280 +            //index == -1 means add to the end.
  10.281 +            if (index == -1) {
  10.282 +                component.add(comp);
  10.283              } else {
  10.284 -                System.arraycopy(component, index, component,
  10.285 -                                 index + 1, ncomponents - index);
  10.286 -                component[index] = comp;
  10.287 -                ncomponents++;
  10.288 +                component.add(index, comp);
  10.289              }
  10.290              comp.parent = this;
  10.291  
  10.292 @@ -1090,9 +1060,7 @@
  10.293                  comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
  10.294              adjustDescendants(comp.countHierarchyMembers());
  10.295  
  10.296 -            if (valid) {
  10.297 -                invalidate();
  10.298 -            }
  10.299 +            invalidateIfValid();
  10.300              if (peer != null) {
  10.301                  comp.addNotify();
  10.302              }
  10.303 @@ -1129,11 +1097,9 @@
  10.304       * IllegalArgumentException.
  10.305       */
  10.306      void checkGD(String stringID) {
  10.307 -        Component tempComp;
  10.308 -        for (int i = 0; i < component.length; i++) {
  10.309 -            tempComp= component[i];
  10.310 -            if (tempComp != null) {
  10.311 -                tempComp.checkGD(stringID);
  10.312 +        for (Component comp : component) {
  10.313 +            if (comp != null) {
  10.314 +                comp.checkGD(stringID);
  10.315              }
  10.316          }
  10.317      }
  10.318 @@ -1163,10 +1129,10 @@
  10.319       */
  10.320      public void remove(int index) {
  10.321          synchronized (getTreeLock()) {
  10.322 -            if (index < 0  || index >= ncomponents) {
  10.323 +            if (index < 0  || index >= component.size()) {
  10.324                  throw new ArrayIndexOutOfBoundsException(index);
  10.325              }
  10.326 -            Component comp = component[index];
  10.327 +            Component comp = component.get(index);
  10.328              if (peer != null) {
  10.329                  comp.removeNotify();
  10.330              }
  10.331 @@ -1181,14 +1147,9 @@
  10.332              adjustDescendants(-(comp.countHierarchyMembers()));
  10.333  
  10.334              comp.parent = null;
  10.335 -            System.arraycopy(component, index + 1,
  10.336 -                             component, index,
  10.337 -                             ncomponents - index - 1);
  10.338 -            component[--ncomponents] = null;
  10.339 -
  10.340 -            if (valid) {
  10.341 -                invalidate();
  10.342 -            }
  10.343 +            component.remove(index);
  10.344 +
  10.345 +            invalidateIfValid();
  10.346              if (containerListener != null ||
  10.347                  (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
  10.348                  Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
  10.349 @@ -1229,14 +1190,9 @@
  10.350      public void remove(Component comp) {
  10.351          synchronized (getTreeLock()) {
  10.352              if (comp.parent == this)  {
  10.353 -                /* Search backwards, expect that more recent additions
  10.354 -                 * are more likely to be removed.
  10.355 -                 */
  10.356 -                Component component[] = this.component;
  10.357 -                for (int i = ncomponents; --i >= 0; ) {
  10.358 -                    if (component[i] == comp) {
  10.359 -                        remove(i);
  10.360 -                    }
  10.361 +                int index = component.indexOf(comp);
  10.362 +                if (index >= 0) {
  10.363 +                    remove(index);
  10.364                  }
  10.365              }
  10.366          }
  10.367 @@ -1258,9 +1214,8 @@
  10.368                                      -listeningBoundsChildren);
  10.369              adjustDescendants(-descendantsCount);
  10.370  
  10.371 -            while (ncomponents > 0) {
  10.372 -                Component comp = component[--ncomponents];
  10.373 -                component[ncomponents] = null;
  10.374 +            while (!component.isEmpty()) {
  10.375 +                Component comp = component.remove(component.size()-1);
  10.376  
  10.377                  if (peer != null) {
  10.378                      comp.removeNotify();
  10.379 @@ -1286,9 +1241,7 @@
  10.380              if (peer != null && layoutMgr == null && isVisible()) {
  10.381                  updateCursorImmediately();
  10.382              }
  10.383 -            if (valid) {
  10.384 -                invalidate();
  10.385 -            }
  10.386 +            invalidateIfValid();
  10.387          }
  10.388      }
  10.389  
  10.390 @@ -1300,8 +1253,8 @@
  10.391              if (eventLog.isLoggable(Level.FINE)) {
  10.392                  // Verify listeningChildren is correct
  10.393                  int sum = 0;
  10.394 -                for (int i = 0; i < ncomponents; i++) {
  10.395 -                    sum += component[i].numListening(mask);
  10.396 +                for (Component comp : component) {
  10.397 +                    sum += comp.numListening(mask);
  10.398                  }
  10.399                  if (listeningChildren != sum) {
  10.400                      eventLog.log(Level.FINE, "Assertion (listeningChildren == sum) failed");
  10.401 @@ -1312,8 +1265,8 @@
  10.402              if (eventLog.isLoggable(Level.FINE)) {
  10.403                  // Verify listeningBoundsChildren is correct
  10.404                  int sum = 0;
  10.405 -                for (int i = 0; i < ncomponents; i++) {
  10.406 -                    sum += component[i].numListening(mask);
  10.407 +                for (Component comp : component) {
  10.408 +                    sum += comp.numListening(mask);
  10.409                  }
  10.410                  if (listeningBoundsChildren != sum) {
  10.411                      eventLog.log(Level.FINE, "Assertion (listeningBoundsChildren == sum) failed");
  10.412 @@ -1375,8 +1328,8 @@
  10.413          if (log.isLoggable(Level.FINE)) {
  10.414              // Verify descendantsCount is correct
  10.415              int sum = 0;
  10.416 -            for (int i = 0; i < ncomponents; i++) {
  10.417 -                sum += component[i].countHierarchyMembers();
  10.418 +            for (Component comp : component) {
  10.419 +                sum += comp.countHierarchyMembers();
  10.420              }
  10.421              if (descendantsCount != sum) {
  10.422                  log.log(Level.FINE, "Assertion (descendantsCount == sum) failed");
  10.423 @@ -1408,7 +1361,7 @@
  10.424          int listeners = getListenersCount(id, enabledOnToolkit);
  10.425  
  10.426          for (int count = listeners, i = 0; count > 0; i++) {
  10.427 -            count -= component[i].createHierarchyEvents(id, changed,
  10.428 +            count -= component.get(i).createHierarchyEvents(id, changed,
  10.429                  changedParent, changeFlags, enabledOnToolkit);
  10.430          }
  10.431          return listeners +
  10.432 @@ -1420,13 +1373,13 @@
  10.433          boolean enabledOnToolkit)
  10.434      {
  10.435          assert Thread.holdsLock(getTreeLock());
  10.436 -        if (ncomponents == 0) {
  10.437 +        if (component.isEmpty()) {
  10.438              return;
  10.439          }
  10.440          int listeners = getListenersCount(id, enabledOnToolkit);
  10.441  
  10.442          for (int count = listeners, i = 0; count > 0; i++) {
  10.443 -            count -= component[i].createHierarchyEvents(id, this, parent,
  10.444 +            count -= component.get(i).createHierarchyEvents(id, this, parent,
  10.445                  changeFlags, enabledOnToolkit);
  10.446          }
  10.447      }
  10.448 @@ -1448,9 +1401,7 @@
  10.449       */
  10.450      public void setLayout(LayoutManager mgr) {
  10.451          layoutMgr = mgr;
  10.452 -        if (valid) {
  10.453 -            invalidate();
  10.454 -        }
  10.455 +        invalidateIfValid();
  10.456      }
  10.457  
  10.458      /**
  10.459 @@ -1522,10 +1473,10 @@
  10.460       */
  10.461      public void validate() {
  10.462          /* Avoid grabbing lock unless really necessary. */
  10.463 -        if (!valid) {
  10.464 +        if (!isValid()) {
  10.465              boolean updateCur = false;
  10.466              synchronized (getTreeLock()) {
  10.467 -                if (!valid && peer != null) {
  10.468 +                if (!isValid() && peer != null) {
  10.469                      ContainerPeer p = null;
  10.470                      if (peer instanceof ContainerPeer) {
  10.471                          p = (ContainerPeer) peer;
  10.472 @@ -1534,7 +1485,6 @@
  10.473                          p.beginValidate();
  10.474                      }
  10.475                      validateTree();
  10.476 -                    valid = true;
  10.477                      if (p != null) {
  10.478                          p.endValidate();
  10.479                          updateCur = isVisible();
  10.480 @@ -1557,17 +1507,16 @@
  10.481       * @see #validate
  10.482       */
  10.483      protected void validateTree() {
  10.484 -        if (!valid) {
  10.485 +        if (!isValid()) {
  10.486              if (peer instanceof ContainerPeer) {
  10.487                  ((ContainerPeer)peer).beginLayout();
  10.488              }
  10.489              doLayout();
  10.490 -            Component component[] = this.component;
  10.491 -            for (int i = 0 ; i < ncomponents ; ++i) {
  10.492 -                Component comp = component[i];
  10.493 +            for (int i = 0; i < component.size(); i++) {
  10.494 +                Component comp = component.get(i);
  10.495                  if (   (comp instanceof Container)
  10.496 -                    && !(comp instanceof Window)
  10.497 -                    && !comp.valid) {
  10.498 +                       && !(comp instanceof Window)
  10.499 +                       && !comp.isValid()) {
  10.500                      ((Container)comp).validateTree();
  10.501                  } else {
  10.502                      comp.validate();
  10.503 @@ -1577,7 +1526,7 @@
  10.504                  ((ContainerPeer)peer).endLayout();
  10.505              }
  10.506          }
  10.507 -        valid = true;
  10.508 +        super.validate();
  10.509      }
  10.510  
  10.511      /**
  10.512 @@ -1586,20 +1535,16 @@
  10.513       */
  10.514      void invalidateTree() {
  10.515          synchronized (getTreeLock()) {
  10.516 -            for (int i = 0; i < ncomponents; ++i) {
  10.517 -                Component comp = component[i];
  10.518 +            for (int i = 0; i < component.size(); i++) {
  10.519 +                Component comp = component.get(i);
  10.520                  if (comp instanceof Container) {
  10.521                      ((Container)comp).invalidateTree();
  10.522                  }
  10.523                  else {
  10.524 -                    if (comp.valid) {
  10.525 -                        comp.invalidate();
  10.526 -                    }
  10.527 +                    comp.invalidateIfValid();
  10.528                  }
  10.529              }
  10.530 -            if (valid) {
  10.531 -                invalidate();
  10.532 -            }
  10.533 +            invalidateIfValid();
  10.534          }
  10.535      }
  10.536  
  10.537 @@ -1838,7 +1783,7 @@
  10.538              // super.paint(); -- Don't bother, since it's a NOP.
  10.539  
  10.540              GraphicsCallback.PaintCallback.getInstance().
  10.541 -                runComponents(component, g, GraphicsCallback.LIGHTWEIGHTS);
  10.542 +                runComponents(component.toArray(EMPTY_ARRAY), g, GraphicsCallback.LIGHTWEIGHTS);
  10.543          }
  10.544      }
  10.545  
  10.546 @@ -1893,7 +1838,7 @@
  10.547              }
  10.548  
  10.549              GraphicsCallback.PrintCallback.getInstance().
  10.550 -                runComponents(component, g, GraphicsCallback.LIGHTWEIGHTS);
  10.551 +                runComponents(component.toArray(EMPTY_ARRAY), g, GraphicsCallback.LIGHTWEIGHTS);
  10.552          }
  10.553      }
  10.554  
  10.555 @@ -1906,7 +1851,7 @@
  10.556      public void paintComponents(Graphics g) {
  10.557          if (isShowing()) {
  10.558              GraphicsCallback.PaintAllCallback.getInstance().
  10.559 -                runComponents(component, g, GraphicsCallback.TWO_PASSES);
  10.560 +                runComponents(component.toArray(EMPTY_ARRAY), g, GraphicsCallback.TWO_PASSES);
  10.561          }
  10.562      }
  10.563  
  10.564 @@ -1928,7 +1873,7 @@
  10.565      void paintHeavyweightComponents(Graphics g) {
  10.566          if (isShowing()) {
  10.567              GraphicsCallback.PaintHeavyweightComponentsCallback.getInstance().
  10.568 -                runComponents(component, g, GraphicsCallback.LIGHTWEIGHTS |
  10.569 +                runComponents(component.toArray(EMPTY_ARRAY), g, GraphicsCallback.LIGHTWEIGHTS |
  10.570                                              GraphicsCallback.HEAVYWEIGHTS);
  10.571          }
  10.572      }
  10.573 @@ -1942,7 +1887,7 @@
  10.574      public void printComponents(Graphics g) {
  10.575          if (isShowing()) {
  10.576              GraphicsCallback.PrintAllCallback.getInstance().
  10.577 -                runComponents(component, g, GraphicsCallback.TWO_PASSES);
  10.578 +                runComponents(component.toArray(EMPTY_ARRAY), g, GraphicsCallback.TWO_PASSES);
  10.579          }
  10.580      }
  10.581  
  10.582 @@ -1964,7 +1909,7 @@
  10.583      void printHeavyweightComponents(Graphics g) {
  10.584          if (isShowing()) {
  10.585              GraphicsCallback.PrintHeavyweightComponentsCallback.getInstance().
  10.586 -                runComponents(component, g, GraphicsCallback.LIGHTWEIGHTS |
  10.587 +                runComponents(component.toArray(EMPTY_ARRAY), g, GraphicsCallback.LIGHTWEIGHTS |
  10.588                                              GraphicsCallback.HEAVYWEIGHTS);
  10.589          }
  10.590      }
  10.591 @@ -2260,11 +2205,9 @@
  10.592                                           boolean searchHeavyweightChildren,
  10.593                                           boolean searchHeavyweightDescendants) {
  10.594          synchronized (getTreeLock()) {
  10.595 -            int ncomponents = this.ncomponents;
  10.596 -            Component component[] = this.component;
  10.597 -
  10.598 -            for (int i = 0 ; i < ncomponents ; i++) {
  10.599 -                Component comp = component[i];
  10.600 +
  10.601 +            for (int i = 0; i < component.size(); i++) {
  10.602 +                Component comp = component.get(i);
  10.603                  if (comp != null && comp.visible &&
  10.604                      ((!searchHeavyweightChildren &&
  10.605                        comp.peer instanceof LightweightPeer) ||
  10.606 @@ -2415,8 +2358,8 @@
  10.607          }
  10.608          synchronized (getTreeLock()) {
  10.609              // Two passes: see comment in sun.awt.SunGraphicsCallback
  10.610 -            for (int i = 0 ; i < ncomponents ; i++) {
  10.611 -                Component comp = component[i];
  10.612 +            for (int i = 0; i < component.size(); i++) {
  10.613 +                Component comp = component.get(i);
  10.614                  if (comp != null &&
  10.615                      !(comp.peer instanceof LightweightPeer)) {
  10.616                      if (comp.contains(x - comp.x, y - comp.y)) {
  10.617 @@ -2424,8 +2367,8 @@
  10.618                      }
  10.619                  }
  10.620              }
  10.621 -            for (int i = 0 ; i < ncomponents ; i++) {
  10.622 -                Component comp = component[i];
  10.623 +            for (int i = 0; i < component.size(); i++) {
  10.624 +                Component comp = component.get(i);
  10.625                  if (comp != null &&
  10.626                      comp.peer instanceof LightweightPeer) {
  10.627                      if (comp.contains(x - comp.x, y - comp.y)) {
  10.628 @@ -2544,43 +2487,43 @@
  10.629          if (!(contains(x, y) && visible && (ignoreEnabled || enabled))) {
  10.630              return null;
  10.631          }
  10.632 -        int ncomponents = this.ncomponents;
  10.633 -        Component component[] = this.component;
  10.634  
  10.635          // Two passes: see comment in sun.awt.SunGraphicsCallback
  10.636 -        for (int i = 0 ; i < ncomponents ; i++) {
  10.637 -            Component comp = component[i];
  10.638 -            if (comp != null &&
  10.639 -                !(comp.peer instanceof LightweightPeer)) {
  10.640 -                if (comp instanceof Container) {
  10.641 -                    comp = ((Container)comp).findComponentAtImpl(x - comp.x,
  10.642 -                                                             y - comp.y,
  10.643 -                                                             ignoreEnabled);
  10.644 -                } else {
  10.645 -                    comp = comp.locate(x - comp.x, y - comp.y);
  10.646 -                }
  10.647 -                if (comp != null && comp.visible &&
  10.648 -                    (ignoreEnabled || comp.enabled))
  10.649 -                {
  10.650 -                    return comp;
  10.651 +        synchronized (getTreeLock()) {
  10.652 +            for (int i = 0; i < component.size(); i++) {
  10.653 +                Component comp = component.get(i);
  10.654 +                if (comp != null &&
  10.655 +                    !(comp.peer instanceof LightweightPeer)) {
  10.656 +                    if (comp instanceof Container) {
  10.657 +                        comp = ((Container)comp).findComponentAtImpl(x - comp.x,
  10.658 +                                                                     y - comp.y,
  10.659 +                                                                     ignoreEnabled);
  10.660 +                    } else {
  10.661 +                        comp = comp.locate(x - comp.x, y - comp.y);
  10.662 +                    }
  10.663 +                    if (comp != null && comp.visible &&
  10.664 +                        (ignoreEnabled || comp.enabled))
  10.665 +                        {
  10.666 +                            return comp;
  10.667 +                        }
  10.668                  }
  10.669              }
  10.670 -        }
  10.671 -        for (int i = 0 ; i < ncomponents ; i++) {
  10.672 -            Component comp = component[i];
  10.673 -            if (comp != null &&
  10.674 -                comp.peer instanceof LightweightPeer) {
  10.675 -                if (comp instanceof Container) {
  10.676 -                    comp = ((Container)comp).findComponentAtImpl(x - comp.x,
  10.677 -                                                             y - comp.y,
  10.678 -                                                             ignoreEnabled);
  10.679 -                } else {
  10.680 -                    comp = comp.locate(x - comp.x, y - comp.y);
  10.681 -                }
  10.682 -                if (comp != null && comp.visible &&
  10.683 -                    (ignoreEnabled || comp.enabled))
  10.684 -                {
  10.685 -                    return comp;
  10.686 +            for (int i = 0; i < component.size(); i++) {
  10.687 +                Component comp = component.get(i);
  10.688 +                if (comp != null &&
  10.689 +                    comp.peer instanceof LightweightPeer) {
  10.690 +                    if (comp instanceof Container) {
  10.691 +                        comp = ((Container)comp).findComponentAtImpl(x - comp.x,
  10.692 +                                                                     y - comp.y,
  10.693 +                                                                     ignoreEnabled);
  10.694 +                    } else {
  10.695 +                        comp = comp.locate(x - comp.x, y - comp.y);
  10.696 +                    }
  10.697 +                    if (comp != null && comp.visible &&
  10.698 +                        (ignoreEnabled || comp.enabled))
  10.699 +                        {
  10.700 +                            return comp;
  10.701 +                        }
  10.702                  }
  10.703              }
  10.704          }
  10.705 @@ -2632,10 +2575,14 @@
  10.706              if (! (peer instanceof LightweightPeer)) {
  10.707                  dispatcher = new LightweightDispatcher(this);
  10.708              }
  10.709 -            int ncomponents = this.ncomponents;
  10.710 -            Component component[] = this.component;
  10.711 -            for (int i = 0 ; i < ncomponents ; i++) {
  10.712 -                component[i].addNotify();
  10.713 +
  10.714 +            // We shouldn't use iterator because of the Swing menu
  10.715 +            // implementation specifics:
  10.716 +            // the menu is being assigned as a child to JLayeredPane
  10.717 +            // instead of particular component so always affect
  10.718 +            // collection of component if menu is becoming shown or hidden.
  10.719 +            for (int i = 0; i < component.size(); i++) {
  10.720 +                component.get(i).addNotify();
  10.721              }
  10.722              // Update stacking order if native platform allows
  10.723              ContainerPeer cpeer = (ContainerPeer)peer;
  10.724 @@ -2658,21 +2605,25 @@
  10.725       */
  10.726      public void removeNotify() {
  10.727          synchronized (getTreeLock()) {
  10.728 -            int ncomponents = this.ncomponents;
  10.729 -            Component component[] = this.component;
  10.730 -            for (int i = ncomponents - 1; i >= 0; i--) {
  10.731 -                if( component[i] != null ) {
  10.732 +            // We shouldn't use iterator because of the Swing menu
  10.733 +            // implementation specifics:
  10.734 +            // the menu is being assigned as a child to JLayeredPane
  10.735 +            // instead of particular component so always affect
  10.736 +            // collection of component if menu is becoming shown or hidden.
  10.737 +            for (int i = component.size()-1 ; i >= 0 ; i--) {
  10.738 +                Component comp = component.get(i);
  10.739 +                if (comp != null) {
  10.740                      // Fix for 6607170.
  10.741                      // We want to suppress focus change on disposal
  10.742                      // of the focused component. But because of focus
  10.743                      // is asynchronous, we should suppress focus change
  10.744                      // on every component in case it receives native focus
  10.745                      // in the process of disposal.
  10.746 -                    component[i].setAutoFocusTransferOnDisposal(false);
  10.747 -                    component[i].removeNotify();
  10.748 -                    component[i].setAutoFocusTransferOnDisposal(true);
  10.749 -                }
  10.750 -            }
  10.751 +                    comp.setAutoFocusTransferOnDisposal(false);
  10.752 +                    comp.removeNotify();
  10.753 +                    comp.setAutoFocusTransferOnDisposal(true);
  10.754 +                 }
  10.755 +             }
  10.756              // If some of the children had focus before disposal then it still has.
  10.757              // Auto-transfer focus to the next (or previous) component if auto-transfer
  10.758              // is enabled.
  10.759 @@ -2683,7 +2634,7 @@
  10.760              }
  10.761              if ( dispatcher != null ) {
  10.762                  dispatcher.dispose();
  10.763 -        dispatcher = null;
  10.764 +                dispatcher = null;
  10.765              }
  10.766              super.removeNotify();
  10.767          }
  10.768 @@ -2873,12 +2824,12 @@
  10.769       */
  10.770      public void list(PrintStream out, int indent) {
  10.771          super.list(out, indent);
  10.772 -        int ncomponents = this.ncomponents;
  10.773 -        Component component[] = this.component;
  10.774 -        for (int i = 0 ; i < ncomponents ; i++) {
  10.775 -            Component comp = component[i];
  10.776 -            if (comp != null) {
  10.777 -                comp.list(out, indent+1);
  10.778 +        synchronized(getTreeLock()) {
  10.779 +            for (int i = 0; i < component.size(); i++) {
  10.780 +                Component comp = component.get(i);
  10.781 +                if (comp != null) {
  10.782 +                    comp.list(out, indent+1);
  10.783 +                }
  10.784              }
  10.785          }
  10.786      }
  10.787 @@ -2899,12 +2850,12 @@
  10.788       */
  10.789      public void list(PrintWriter out, int indent) {
  10.790          super.list(out, indent);
  10.791 -        int ncomponents = this.ncomponents;
  10.792 -        Component component[] = this.component;
  10.793 -        for (int i = 0 ; i < ncomponents ; i++) {
  10.794 -            Component comp = component[i];
  10.795 -            if (comp != null) {
  10.796 -                comp.list(out, indent+1);
  10.797 +        synchronized(getTreeLock()) {
  10.798 +            for (int i = 0; i < component.size(); i++) {
  10.799 +                Component comp = component.get(i);
  10.800 +                if (comp != null) {
  10.801 +                    comp.list(out, indent+1);
  10.802 +                }
  10.803              }
  10.804          }
  10.805      }
  10.806 @@ -3414,9 +3365,11 @@
  10.807       */
  10.808      public void applyComponentOrientation(ComponentOrientation o) {
  10.809          super.applyComponentOrientation(o);
  10.810 -
  10.811 -        for (int i = 0 ; i < ncomponents ; ++i) {
  10.812 -             component[i].applyComponentOrientation(o);
  10.813 +        synchronized (getTreeLock()) {
  10.814 +            for (int i = 0; i < component.size(); i++) {
  10.815 +                Component comp = component.get(i);
  10.816 +                comp.applyComponentOrientation(o);
  10.817 +            }
  10.818          }
  10.819      }
  10.820  
  10.821 @@ -3534,8 +3487,8 @@
  10.822       */
  10.823      private void writeObject(ObjectOutputStream s) throws IOException {
  10.824          ObjectOutputStream.PutField f = s.putFields();
  10.825 -        f.put("ncomponents", ncomponents);
  10.826 -        f.put("component", component);
  10.827 +        f.put("ncomponents", component.size());
  10.828 +        f.put("component", component.toArray(EMPTY_ARRAY));
  10.829          f.put("layoutMgr", layoutMgr);
  10.830          f.put("dispatcher", dispatcher);
  10.831          f.put("maxSize", maxSize);
  10.832 @@ -3574,8 +3527,12 @@
  10.833          throws ClassNotFoundException, IOException
  10.834      {
  10.835          ObjectInputStream.GetField f = s.readFields();
  10.836 -        ncomponents = f.get("ncomponents", 0);
  10.837 -        component = (Component[])f.get("component", new Component[0]);
  10.838 +        Component [] tmpComponent = (Component[])f.get("component", EMPTY_ARRAY);
  10.839 +        int ncomponents = (Integer) f.get("ncomponents", 0);
  10.840 +        component = new java.util.ArrayList<Component>(ncomponents);
  10.841 +        for (int i = 0; i < ncomponents; ++i) {
  10.842 +            component.add(tmpComponent[i]);
  10.843 +        }
  10.844          layoutMgr = (LayoutManager)f.get("layoutMgr", null);
  10.845          dispatcher = (LightweightDispatcher)f.get("dispatcher", null);
  10.846          // Old stream. Doesn't contain maxSize among Component's fields.
  10.847 @@ -3585,16 +3542,14 @@
  10.848          focusCycleRoot = f.get("focusCycleRoot", false);
  10.849          containerSerializedDataVersion = f.get("containerSerializedDataVersion", 1);
  10.850          focusTraversalPolicyProvider = f.get("focusTraversalPolicyProvider", false);
  10.851 -
  10.852 -        Component component[] = this.component;
  10.853 -        for(int i = 0; i < ncomponents; i++) {
  10.854 -            component[i].parent = this;
  10.855 +        java.util.List<Component> component = this.component;
  10.856 +        for(Component comp : component) {
  10.857 +            comp.parent = this;
  10.858              adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
  10.859 -                component[i].numListening(AWTEvent.HIERARCHY_EVENT_MASK));
  10.860 +                                    comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
  10.861              adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
  10.862 -                component[i].numListening(
  10.863 -                    AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
  10.864 -            adjustDescendants(component[i].countHierarchyMembers());
  10.865 +                                    comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
  10.866 +            adjustDescendants(comp.countHierarchyMembers());
  10.867          }
  10.868  
  10.869          Object keyOrNull;
  10.870 @@ -4111,6 +4066,21 @@
  10.871          }
  10.872      }
  10.873  
  10.874 +    @Override
  10.875 +    void mixOnValidating() {
  10.876 +        synchronized (getTreeLock()) {
  10.877 +            if (mixingLog.isLoggable(Level.FINE)) {
  10.878 +                mixingLog.fine("this = " + this);
  10.879 +            }
  10.880 +
  10.881 +            if (hasHeavyweightDescendants()) {
  10.882 +                recursiveApplyCurrentShape();
  10.883 +            }
  10.884 +
  10.885 +            super.mixOnValidating();
  10.886 +        }
  10.887 +    }
  10.888 +
  10.889      // ****************** END OF MIXING CODE ********************************
  10.890  }
  10.891  
    11.1 --- a/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java	Wed Sep 17 13:45:37 2008 -0700
    11.2 +++ b/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java	Fri Sep 19 19:38:12 2008 -0700
    11.3 @@ -556,8 +556,7 @@
    11.4       *         enabled, and focusable; <code>false</code> otherwise
    11.5       */
    11.6      protected boolean accept(Component aComponent) {
    11.7 -        if (!(aComponent.isVisible() && aComponent.isDisplayable() &&
    11.8 -              aComponent.isFocusable() && aComponent.isEnabled())) {
    11.9 +        if (!aComponent.canBeFocusOwner()) {
   11.10              return false;
   11.11          }
   11.12  
    12.1 --- a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Wed Sep 17 13:45:37 2008 -0700
    12.2 +++ b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Fri Sep 19 19:38:12 2008 -0700
    12.3 @@ -154,7 +154,7 @@
    12.4      private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
    12.5                                     boolean clearOnFailure)
    12.6      {
    12.7 -        if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.isFocusable() &&
    12.8 +        if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
    12.9              toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
   12.10          {
   12.11              return true;
   12.12 @@ -500,8 +500,11 @@
   12.13                      }
   12.14                  }
   12.15  
   12.16 -                if (!(newFocusOwner.isFocusable() && newFocusOwner.isEnabled()
   12.17 -                      && newFocusOwner.isShowing()))
   12.18 +                if (!(newFocusOwner.isFocusable() && newFocusOwner.isShowing() &&
   12.19 +                    // Refuse focus on a disabled component if the focus event
   12.20 +                    // isn't of UNKNOWN reason (i.e. not a result of a direct request
   12.21 +                    // but traversal, activation or system generated).
   12.22 +                    (newFocusOwner.isEnabled() || cause.equals(CausedFocusEvent.Cause.UNKNOWN))))
   12.23                  {
   12.24                      // we should not accept focus on such component, so reject it.
   12.25                      dequeueKeyEvents(-1, newFocusOwner);
   12.26 @@ -742,8 +745,7 @@
   12.27      public boolean dispatchKeyEvent(KeyEvent e) {
   12.28          Component focusOwner = (((AWTEvent)e).isPosted) ? getFocusOwner() : e.getComponent();
   12.29  
   12.30 -        if (focusOwner != null && focusOwner.isShowing() &&
   12.31 -            focusOwner.isFocusable() && focusOwner.isEnabled()) {
   12.32 +        if (focusOwner != null && focusOwner.isShowing() && focusOwner.canBeFocusOwner()) {
   12.33              if (!e.isConsumed()) {
   12.34                  Component comp = e.getComponent();
   12.35                  if (comp != null && comp.isEnabled()) {
    13.1 --- a/src/share/classes/java/awt/Dialog.java	Wed Sep 17 13:45:37 2008 -0700
    13.2 +++ b/src/share/classes/java/awt/Dialog.java	Fri Sep 19 19:38:12 2008 -0700
    13.3 @@ -1,5 +1,5 @@
    13.4  /*
    13.5 - * Copyright 1995-2007 Sun Microsystems, Inc.  All Rights Reserved.
    13.6 + * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
    13.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.8   *
    13.9   * This code is free software; you can redistribute it and/or modify it
   13.10 @@ -1327,8 +1327,8 @@
   13.11          // the insets of the Dialog. If we could, we'd call invalidate()
   13.12          // from the peer, but we need to guarantee that we're not holding
   13.13          // the Dialog lock when we call invalidate().
   13.14 -        if (testvalid && valid) {
   13.15 -            invalidate();
   13.16 +        if (testvalid) {
   13.17 +            invalidateIfValid();
   13.18          }
   13.19      }
   13.20  
    14.1 --- a/src/share/classes/java/awt/EventQueue.java	Wed Sep 17 13:45:37 2008 -0700
    14.2 +++ b/src/share/classes/java/awt/EventQueue.java	Fri Sep 19 19:38:12 2008 -0700
    14.3 @@ -42,6 +42,7 @@
    14.4  import sun.awt.AWTAutoShutdown;
    14.5  import sun.awt.PeerEvent;
    14.6  import sun.awt.SunToolkit;
    14.7 +import sun.awt.EventQueueItem;
    14.8  
    14.9  /**
   14.10   * <code>EventQueue</code> is a platform-independent class
   14.11 @@ -359,7 +360,7 @@
   14.12              entry != null; entry = entry.next)
   14.13          {
   14.14              // Give Component.coalesceEvents a chance
   14.15 -            if (entry.event.getSource() == source && entry.id == id) {
   14.16 +            if (entry.event.getSource() == source && entry.event.getID() == id) {
   14.17                  AWTEvent coalescedEvent = source.coalesceEvents(
   14.18                      entry.event, e);
   14.19                  if (coalescedEvent != null) {
   14.20 @@ -499,7 +500,7 @@
   14.21                      for (EventQueueItem entry = queues[i].head, prev = null;
   14.22                           entry != null; prev = entry, entry = entry.next)
   14.23                      {
   14.24 -                        if (entry.id == id) {
   14.25 +                        if (entry.event.getID() == id) {
   14.26                              if (prev == null) {
   14.27                                  queues[i].head = entry.next;
   14.28                              } else {
   14.29 @@ -545,7 +546,7 @@
   14.30          for (int i = NUM_PRIORITIES - 1; i >= 0; i--) {
   14.31              EventQueueItem q = queues[i].head;
   14.32              for (; q != null; q = q.next) {
   14.33 -                if (q.id == id) {
   14.34 +                if (q.event.getID() == id) {
   14.35                      return q.event;
   14.36                  }
   14.37              }
   14.38 @@ -1051,14 +1052,3 @@
   14.39      EventQueueItem head;
   14.40      EventQueueItem tail;
   14.41  }
   14.42 -
   14.43 -class EventQueueItem {
   14.44 -    AWTEvent event;
   14.45 -    int      id;
   14.46 -    EventQueueItem next;
   14.47 -
   14.48 -    EventQueueItem(AWTEvent evt) {
   14.49 -        event = evt;
   14.50 -        id = evt.getID();
   14.51 -    }
   14.52 -}
    15.1 --- a/src/share/classes/java/awt/Frame.java	Wed Sep 17 13:45:37 2008 -0700
    15.2 +++ b/src/share/classes/java/awt/Frame.java	Fri Sep 19 19:38:12 2008 -0700
    15.3 @@ -1,5 +1,5 @@
    15.4  /*
    15.5 - * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
    15.6 + * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
    15.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.8   *
    15.9   * This code is free software; you can redistribute it and/or modify it
   15.10 @@ -590,9 +590,7 @@
   15.11                  if (peer != null) {
   15.12                      mbManagement = true;
   15.13                      menuBar.addNotify();
   15.14 -                    if (valid) {
   15.15 -                        invalidate();
   15.16 -                    }
   15.17 +                    invalidateIfValid();
   15.18                      peer.setMenuBar(menuBar);
   15.19                  }
   15.20              }
   15.21 @@ -633,8 +631,8 @@
   15.22          // the insets of the Frame. If we could, we'd call invalidate()
   15.23          // from the peer, but we need to guarantee that we're not holding
   15.24          // the Frame lock when we call invalidate().
   15.25 -        if (testvalid && valid) {
   15.26 -            invalidate();
   15.27 +        if (testvalid) {
   15.28 +            invalidateIfValid();
   15.29          }
   15.30          firePropertyChange("resizable", oldResizable, resizable);
   15.31      }
   15.32 @@ -907,9 +905,7 @@
   15.33                  FramePeer peer = (FramePeer)this.peer;
   15.34                  if (peer != null) {
   15.35                      mbManagement = true;
   15.36 -                    if (valid) {
   15.37 -                        invalidate();
   15.38 -                    }
   15.39 +                    invalidateIfValid();
   15.40                      peer.setMenuBar(null);
   15.41                      m.removeNotify();
   15.42                  }
    16.1 --- a/src/share/classes/java/awt/Label.java	Wed Sep 17 13:45:37 2008 -0700
    16.2 +++ b/src/share/classes/java/awt/Label.java	Fri Sep 19 19:38:12 2008 -0700
    16.3 @@ -1,5 +1,5 @@
    16.4  /*
    16.5 - * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
    16.6 + * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
    16.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.8   *
    16.9   * This code is free software; you can redistribute it and/or modify it
   16.10 @@ -257,8 +257,8 @@
   16.11          }
   16.12  
   16.13          // This could change the preferred size of the Component.
   16.14 -        if (testvalid && valid) {
   16.15 -            invalidate();
   16.16 +        if (testvalid) {
   16.17 +            invalidateIfValid();
   16.18          }
   16.19      }
   16.20  
    17.1 --- a/src/share/classes/java/awt/ScrollPane.java	Wed Sep 17 13:45:37 2008 -0700
    17.2 +++ b/src/share/classes/java/awt/ScrollPane.java	Fri Sep 19 19:38:12 2008 -0700
    17.3 @@ -357,7 +357,7 @@
    17.4       */
    17.5      public void setScrollPosition(int x, int y) {
    17.6          synchronized (getTreeLock()) {
    17.7 -            if (ncomponents <= 0) {
    17.8 +            if (getComponentCount()==0) {
    17.9                  throw new NullPointerException("child is null");
   17.10              }
   17.11              hAdjustable.setValue(x);
   17.12 @@ -393,10 +393,12 @@
   17.13       */
   17.14      @Transient
   17.15      public Point getScrollPosition() {
   17.16 -        if (ncomponents <= 0) {
   17.17 -            throw new NullPointerException("child is null");
   17.18 +        synchronized (getTreeLock()) {
   17.19 +            if (getComponentCount()==0) {
   17.20 +                throw new NullPointerException("child is null");
   17.21 +            }
   17.22 +            return new Point(hAdjustable.getValue(), vAdjustable.getValue());
   17.23          }
   17.24 -        return new Point(hAdjustable.getValue(), vAdjustable.getValue());
   17.25      }
   17.26  
   17.27      /**
   17.28 @@ -486,26 +488,27 @@
   17.29       */
   17.30      @Deprecated
   17.31      public void layout() {
   17.32 -        if (ncomponents > 0) {
   17.33 -            Component c = getComponent(0);
   17.34 -            Point p = getScrollPosition();
   17.35 -            Dimension cs = calculateChildSize();
   17.36 -            Dimension vs = getViewportSize();
   17.37 -            Insets i = getInsets();
   17.38 +        if (getComponentCount()==0) {
   17.39 +            return;
   17.40 +        }
   17.41 +        Component c = getComponent(0);
   17.42 +        Point p = getScrollPosition();
   17.43 +        Dimension cs = calculateChildSize();
   17.44 +        Dimension vs = getViewportSize();
   17.45 +        Insets i = getInsets();
   17.46  
   17.47 -            c.reshape(i.left - p.x, i.top - p.y, cs.width, cs.height);
   17.48 -            ScrollPanePeer peer = (ScrollPanePeer)this.peer;
   17.49 -            if (peer != null) {
   17.50 -                peer.childResized(cs.width, cs.height);
   17.51 -            }
   17.52 +        c.reshape(i.left - p.x, i.top - p.y, cs.width, cs.height);
   17.53 +        ScrollPanePeer peer = (ScrollPanePeer)this.peer;
   17.54 +        if (peer != null) {
   17.55 +            peer.childResized(cs.width, cs.height);
   17.56 +        }
   17.57  
   17.58 -            // update adjustables... the viewport size may have changed
   17.59 -            // with the scrollbars coming or going so the viewport size
   17.60 -            // is updated before the adjustables.
   17.61 -            vs = getViewportSize();
   17.62 -            hAdjustable.setSpan(0, cs.width, vs.width);
   17.63 -            vAdjustable.setSpan(0, cs.height, vs.height);
   17.64 -        }
   17.65 +        // update adjustables... the viewport size may have changed
   17.66 +        // with the scrollbars coming or going so the viewport size
   17.67 +        // is updated before the adjustables.
   17.68 +        vs = getViewportSize();
   17.69 +        hAdjustable.setSpan(0, cs.width, vs.width);
   17.70 +        vAdjustable.setSpan(0, cs.height, vs.height);
   17.71      }
   17.72  
   17.73      /**
   17.74 @@ -515,20 +518,21 @@
   17.75       * @see Component#printAll
   17.76       */
   17.77      public void printComponents(Graphics g) {
   17.78 -        if (ncomponents > 0) {
   17.79 -            Component c = component[0];
   17.80 -            Point p = c.getLocation();
   17.81 -            Dimension vs = getViewportSize();
   17.82 -            Insets i = getInsets();
   17.83 +        if (getComponentCount()==0) {
   17.84 +            return;
   17.85 +        }
   17.86 +        Component c = getComponent(0);
   17.87 +        Point p = c.getLocation();
   17.88 +        Dimension vs = getViewportSize();
   17.89 +        Insets i = getInsets();
   17.90  
   17.91 -            Graphics cg = g.create();
   17.92 -            try {
   17.93 -                cg.clipRect(i.left, i.top, vs.width, vs.height);
   17.94 -                cg.translate(p.x, p.y);
   17.95 -                c.printAll(cg);
   17.96 -            } finally {
   17.97 -                cg.dispose();
   17.98 -            }
   17.99 +        Graphics cg = g.create();
  17.100 +        try {
  17.101 +            cg.clipRect(i.left, i.top, vs.width, vs.height);
  17.102 +            cg.translate(p.x, p.y);
  17.103 +            c.printAll(cg);
  17.104 +        } finally {
  17.105 +            cg.dispose();
  17.106          }
  17.107      }
  17.108  
  17.109 @@ -589,7 +593,7 @@
  17.110              default:
  17.111                  sdpStr = "invalid display policy";
  17.112          }
  17.113 -        Point p = ncomponents > 0? getScrollPosition() : new Point(0,0);
  17.114 +        Point p = (getComponentCount()>0)? getScrollPosition() : new Point(0,0);
  17.115          Insets i = getInsets();
  17.116          return super.paramString()+",ScrollPosition=("+p.x+","+p.y+")"+
  17.117              ",Insets=("+i.top+","+i.left+","+i.bottom+","+i.right+")"+
    18.1 --- a/src/share/classes/java/awt/SystemTray.java	Wed Sep 17 13:45:37 2008 -0700
    18.2 +++ b/src/share/classes/java/awt/SystemTray.java	Fri Sep 19 19:38:12 2008 -0700
    18.3 @@ -1,5 +1,5 @@
    18.4  /*
    18.5 - * Copyright 2005-2007 Sun Microsystems, Inc.  All Rights Reserved.
    18.6 + * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
    18.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.8   *
    18.9   * This code is free software; you can redistribute it and/or modify it
   18.10 @@ -125,6 +125,8 @@
   18.11  
   18.12      transient private SystemTrayPeer peer;
   18.13  
   18.14 +    private static final TrayIcon[] EMPTY_TRAY_ARRAY = new TrayIcon[0];
   18.15 +
   18.16      /**
   18.17       * Private <code>SystemTray</code> constructor.
   18.18       *
   18.19 @@ -201,17 +203,18 @@
   18.20       * functionality is supported for the current platform
   18.21       */
   18.22      public static boolean isSupported() {
   18.23 -        initializeSystemTrayIfNeeded();
   18.24 -
   18.25 -        if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
   18.26 -
   18.27 -            return ((SunToolkit)Toolkit.getDefaultToolkit()).isTraySupported();
   18.28 -
   18.29 -        } else if (Toolkit.getDefaultToolkit() instanceof HeadlessToolkit) {
   18.30 -
   18.31 -            return ((HeadlessToolkit)Toolkit.getDefaultToolkit()).isTraySupported();
   18.32 +        Toolkit toolkit = Toolkit.getDefaultToolkit();
   18.33 +        if (toolkit instanceof SunToolkit) {
   18.34 +            // connecting tray to native resource
   18.35 +            initializeSystemTrayIfNeeded();
   18.36 +            return ((SunToolkit)toolkit).isTraySupported();
   18.37 +        } else if (toolkit instanceof HeadlessToolkit) {
   18.38 +            // skip initialization as the init routine
   18.39 +            // throws HeadlessException
   18.40 +            return ((HeadlessToolkit)toolkit).isTraySupported();
   18.41 +        } else {
   18.42 +            return false;
   18.43          }
   18.44 -        return false;
   18.45      }
   18.46  
   18.47      /**
   18.48 @@ -323,7 +326,7 @@
   18.49          if (icons != null) {
   18.50              return (TrayIcon[])icons.toArray(new TrayIcon[icons.size()]);
   18.51          }
   18.52 -        return new TrayIcon[0];
   18.53 +        return EMPTY_TRAY_ARRAY;
   18.54      }
   18.55  
   18.56      /**
   18.57 @@ -475,7 +478,12 @@
   18.58  
   18.59      synchronized void addNotify() {
   18.60          if (peer == null) {
   18.61 -            peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createSystemTray(this);
   18.62 +            Toolkit toolkit = Toolkit.getDefaultToolkit();
   18.63 +            if (toolkit instanceof SunToolkit) {
   18.64 +                peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createSystemTray(this);
   18.65 +            } else if (toolkit instanceof HeadlessToolkit) {
   18.66 +                peer = ((HeadlessToolkit)Toolkit.getDefaultToolkit()).createSystemTray(this);
   18.67 +            }
   18.68          }
   18.69      }
   18.70  
    19.1 --- a/src/share/classes/java/awt/TextField.java	Wed Sep 17 13:45:37 2008 -0700
    19.2 +++ b/src/share/classes/java/awt/TextField.java	Fri Sep 19 19:38:12 2008 -0700
    19.3 @@ -1,5 +1,5 @@
    19.4  /*
    19.5 - * Copyright 1995-2007 Sun Microsystems, Inc.  All Rights Reserved.
    19.6 + * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
    19.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.8   *
    19.9   * This code is free software; you can redistribute it and/or modify it
   19.10 @@ -296,9 +296,7 @@
   19.11          super.setText(t);
   19.12  
   19.13          // This could change the preferred size of the Component.
   19.14 -        if (valid) {
   19.15 -            invalidate();
   19.16 -        }
   19.17 +        invalidateIfValid();
   19.18      }
   19.19  
   19.20      /**
    20.1 --- a/src/share/classes/java/awt/TrayIcon.java	Wed Sep 17 13:45:37 2008 -0700
    20.2 +++ b/src/share/classes/java/awt/TrayIcon.java	Fri Sep 19 19:38:12 2008 -0700
    20.3 @@ -1,5 +1,5 @@
    20.4  /*
    20.5 - * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
    20.6 + * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
    20.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.8   *
    20.9   * This code is free software; you can redistribute it and/or modify it
   20.10 @@ -38,6 +38,7 @@
   20.11  import java.awt.peer.TrayIconPeer;
   20.12  import sun.awt.AppContext;
   20.13  import sun.awt.SunToolkit;
   20.14 +import sun.awt.HeadlessToolkit;
   20.15  import java.util.EventObject;
   20.16  
   20.17  /**
   20.18 @@ -142,9 +143,6 @@
   20.19       */
   20.20      public TrayIcon(Image image) {
   20.21          this();
   20.22 -        if (image == null) {
   20.23 -            throw new IllegalArgumentException("creating TrayIcon with null Image");
   20.24 -        }
   20.25          setImage(image);
   20.26      }
   20.27  
   20.28 @@ -433,7 +431,7 @@
   20.29       * @see      java.awt.event.MouseListener
   20.30       */
   20.31      public synchronized MouseListener[] getMouseListeners() {
   20.32 -        return (MouseListener[])(getListeners(MouseListener.class));
   20.33 +        return AWTEventMulticaster.getListeners(mouseListener, MouseListener.class);
   20.34      }
   20.35  
   20.36      /**
   20.37 @@ -494,7 +492,7 @@
   20.38       * @see      java.awt.event.MouseMotionListener
   20.39       */
   20.40      public synchronized MouseMotionListener[] getMouseMotionListeners() {
   20.41 -        return (MouseMotionListener[]) (getListeners(MouseMotionListener.class));
   20.42 +        return AWTEventMulticaster.getListeners(mouseMotionListener, MouseMotionListener.class);
   20.43      }
   20.44  
   20.45      /**
   20.46 @@ -581,7 +579,7 @@
   20.47       * @see      java.awt.event.ActionListener
   20.48       */
   20.49      public synchronized ActionListener[] getActionListeners() {
   20.50 -        return (ActionListener[])(getListeners(ActionListener.class));
   20.51 +        return AWTEventMulticaster.getListeners(actionListener, ActionListener.class);
   20.52      }
   20.53  
   20.54      /**
   20.55 @@ -635,7 +633,7 @@
   20.56  
   20.57          TrayIconPeer peer = this.peer;
   20.58          if (peer != null) {
   20.59 -            peer.displayMessage(caption, text, messageType.toString());
   20.60 +            peer.displayMessage(caption, text, messageType.name());
   20.61          }
   20.62      }
   20.63  
   20.64 @@ -657,24 +655,17 @@
   20.65      // ****************************************************************
   20.66      // ****************************************************************
   20.67  
   20.68 -    <T extends EventListener> T[] getListeners(Class<T> listenerType) {
   20.69 -        EventListener l = null;
   20.70 -        if (listenerType == MouseListener.class) {
   20.71 -            l = mouseListener;
   20.72 -        } else if (listenerType == MouseMotionListener.class) {
   20.73 -            l = mouseMotionListener;
   20.74 -        } else if (listenerType == ActionListener.class) {
   20.75 -            l = actionListener;
   20.76 -        }
   20.77 -        return AWTEventMulticaster.getListeners(l, listenerType);
   20.78 -    }
   20.79 -
   20.80      void addNotify()
   20.81        throws AWTException
   20.82      {
   20.83          synchronized (this) {
   20.84              if (peer == null) {
   20.85 -                peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createTrayIcon(this);
   20.86 +                Toolkit toolkit = Toolkit.getDefaultToolkit();
   20.87 +                if (toolkit instanceof SunToolkit) {
   20.88 +                    peer = ((SunToolkit)Toolkit.getDefaultToolkit()).createTrayIcon(this);
   20.89 +                } else if (toolkit instanceof HeadlessToolkit) {
   20.90 +                    peer = ((HeadlessToolkit)Toolkit.getDefaultToolkit()).createTrayIcon(this);
   20.91 +                }
   20.92              }
   20.93          }
   20.94          peer.setToolTip(tooltip);
    21.1 --- a/src/share/classes/java/awt/Window.java	Wed Sep 17 13:45:37 2008 -0700
    21.2 +++ b/src/share/classes/java/awt/Window.java	Fri Sep 19 19:38:12 2008 -0700
    21.3 @@ -3145,9 +3145,7 @@
    21.4          Component previousComp = temporaryLostComponent;
    21.5          // Check that "component" is an acceptable focus owner and don't store it otherwise
    21.6          // - or later we will have problems with opposite while handling  WINDOW_GAINED_FOCUS
    21.7 -        if (component == null
    21.8 -            || (component.isDisplayable() && component.isVisible() && component.isEnabled() && component.isFocusable()))
    21.9 -        {
   21.10 +        if (component == null || component.canBeFocusOwner()) {
   21.11              temporaryLostComponent = component;
   21.12          } else {
   21.13              temporaryLostComponent = null;
    22.1 --- a/src/share/classes/java/awt/dnd/DragSourceContext.java	Wed Sep 17 13:45:37 2008 -0700
    22.2 +++ b/src/share/classes/java/awt/dnd/DragSourceContext.java	Fri Sep 19 19:38:12 2008 -0700
    22.3 @@ -486,6 +486,8 @@
    22.4          Cursor c = null;
    22.5  
    22.6          switch (status) {
    22.7 +            default:
    22.8 +                targetAct = DnDConstants.ACTION_NONE;
    22.9              case ENTER:
   22.10              case OVER:
   22.11              case CHANGED:
   22.12 @@ -506,10 +508,6 @@
   22.13                      else
   22.14                          c = DragSource.DefaultCopyDrop;
   22.15                  }
   22.16 -                break;
   22.17 -            default:
   22.18 -                targetAct = DnDConstants.ACTION_NONE;
   22.19 -
   22.20          }
   22.21  
   22.22          setCursorImpl(c);
    23.1 --- a/src/share/classes/javax/swing/Popup.java	Wed Sep 17 13:45:37 2008 -0700
    23.2 +++ b/src/share/classes/javax/swing/Popup.java	Fri Sep 19 19:38:12 2008 -0700
    23.3 @@ -26,7 +26,9 @@
    23.4  package javax.swing;
    23.5  
    23.6  import java.awt.*;
    23.7 +
    23.8  import sun.awt.ModalExclude;
    23.9 +import sun.awt.SunToolkit;
   23.10  
   23.11  /**
   23.12   * Popups are used to display a <code>Component</code> to the user, typically
   23.13 @@ -225,7 +227,12 @@
   23.14          HeavyWeightWindow(Window parent) {
   23.15              super(parent);
   23.16              setFocusableWindowState(false);
   23.17 -            setName("###overrideRedirect###");
   23.18 +            Toolkit tk = Toolkit.getDefaultToolkit();
   23.19 +            if (tk instanceof SunToolkit) {
   23.20 +                // all the short-lived windows like Popups should be
   23.21 +                // OverrideRedirect on X11 platforms
   23.22 +                ((SunToolkit)tk).setOverrideRedirect(this);
   23.23 +            }
   23.24              // Popups are typically transient and most likely won't benefit
   23.25              // from true double buffering.  Turn it off here.
   23.26              getRootPane().setUseTrueDoubleBuffering(false);
    24.1 --- a/src/share/classes/sun/awt/EmbeddedFrame.java	Wed Sep 17 13:45:37 2008 -0700
    24.2 +++ b/src/share/classes/sun/awt/EmbeddedFrame.java	Fri Sep 19 19:38:12 2008 -0700
    24.3 @@ -257,21 +257,27 @@
    24.4          Set toTest;
    24.5          Component currentFocused = e.getComponent();
    24.6  
    24.7 -        Component last = getFocusTraversalPolicy().getLastComponent(this);
    24.8          toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    24.9 -        if (toTest.contains(stroke) && (currentFocused == last || last == null)) {
   24.10 -            if (traverseOut(FORWARD)) {
   24.11 -                e.consume();
   24.12 -                return true;
   24.13 +        if (toTest.contains(stroke)) {
   24.14 +            // 6581899: performance improvement for SortingFocusTraversalPolicy
   24.15 +            Component last = getFocusTraversalPolicy().getLastComponent(this);
   24.16 +            if (currentFocused == last || last == null) {
   24.17 +                if (traverseOut(FORWARD)) {
   24.18 +                    e.consume();
   24.19 +                    return true;
   24.20 +                }
   24.21              }
   24.22          }
   24.23  
   24.24 -        Component first = getFocusTraversalPolicy().getFirstComponent(this);
   24.25          toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
   24.26 -        if (toTest.contains(stroke) && (currentFocused == first || first == null)) {
   24.27 -            if (traverseOut(BACKWARD)) {
   24.28 -                e.consume();
   24.29 -                return true;
   24.30 +        if (toTest.contains(stroke)) {
   24.31 +            // 6581899: performance improvement for SortingFocusTraversalPolicy
   24.32 +            Component first = getFocusTraversalPolicy().getFirstComponent(this);
   24.33 +            if (currentFocused == first || first == null) {
   24.34 +                if (traverseOut(BACKWARD)) {
   24.35 +                    e.consume();
   24.36 +                    return true;
   24.37 +                }
   24.38              }
   24.39          }
   24.40          return false;
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/src/share/classes/sun/awt/EventQueueItem.java	Fri Sep 19 19:38:12 2008 -0700
    25.3 @@ -0,0 +1,37 @@
    25.4 +/*
    25.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
    25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 + *
    25.8 + * This code is free software; you can redistribute it and/or modify it
    25.9 + * under the terms of the GNU General Public License version 2 only, as
   25.10 + * published by the Free Software Foundation.  Sun designates this
   25.11 + * particular file as subject to the "Classpath" exception as provided
   25.12 + * by Sun in the LICENSE file that accompanied this code.
   25.13 + *
   25.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   25.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.17 + * version 2 for more details (a copy is included in the LICENSE file that
   25.18 + * accompanied this code).
   25.19 + *
   25.20 + * You should have received a copy of the GNU General Public License version
   25.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   25.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.23 + *
   25.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   25.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
   25.26 + * have any questions.
   25.27 + */
   25.28 +
   25.29 +package sun.awt;
   25.30 +
   25.31 +import java.awt.AWTEvent;
   25.32 +
   25.33 +public class EventQueueItem {
   25.34 +    public AWTEvent event;
   25.35 +    public EventQueueItem next;
   25.36 +
   25.37 +    public EventQueueItem(AWTEvent evt) {
   25.38 +        event = evt;
   25.39 +    }
   25.40 +}
    26.1 --- a/src/share/classes/sun/awt/SunToolkit.java	Wed Sep 17 13:45:37 2008 -0700
    26.2 +++ b/src/share/classes/sun/awt/SunToolkit.java	Fri Sep 19 19:38:12 2008 -0700
    26.3 @@ -1,5 +1,5 @@
    26.4  /*
    26.5 - * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
    26.6 + * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
    26.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.8   *
    26.9   * This code is free software; you can redistribute it and/or modify it
   26.10 @@ -852,6 +852,15 @@
   26.11          return AccessController.doPrivileged(new GetBooleanAction("sun.awt.erasebackgroundonresize"));
   26.12      }
   26.13  
   26.14 +
   26.15 +    /**
   26.16 +     * Makes the window OverrideRedirect, on X11 platforms. See
   26.17 +     * ICCCM specification for more details about OverrideRedirect
   26.18 +     * windows. Implemented in XToolkit, no-op in WToolkit.
   26.19 +     */
   26.20 +    public void setOverrideRedirect(Window target) {
   26.21 +    }
   26.22 +
   26.23      static SoftCache imgCache = new SoftCache();
   26.24  
   26.25      static synchronized Image getImageFromHash(Toolkit tk, URL url) {
   26.26 @@ -2039,12 +2048,3 @@
   26.27          SunToolkit.wakeupEventQueue(eventQueue, event.getSource() == AWTAutoShutdown.getInstance());
   26.28      }
   26.29  } // class PostEventQueue
   26.30 -
   26.31 -class EventQueueItem {
   26.32 -    AWTEvent event;
   26.33 -    EventQueueItem next;
   26.34 -
   26.35 -    EventQueueItem(AWTEvent evt) {
   26.36 -        event = evt;
   26.37 -    }
   26.38 -} // class EventQueueItem
    27.1 --- a/src/solaris/classes/sun/awt/X11/XKeysym.java	Wed Sep 17 13:45:37 2008 -0700
    27.2 +++ b/src/solaris/classes/sun/awt/X11/XKeysym.java	Fri Sep 19 19:38:12 2008 -0700
    27.3 @@ -101,10 +101,15 @@
    27.4          // Otherwise, it is [1].
    27.5          int ndx = XToolkit.isXsunServer() &&
    27.6                    ! XToolkit.isXKBenabled() ? 2 : 1;
    27.7 +        // Even if XKB is enabled, we have another problem: some symbol tables (e.g. cz) force
    27.8 +        // a regular comma instead of KP_comma for a decimal separator. Result is,
    27.9 +        // bugs like 6454041. So, we will try for keypadness  a keysym with ndx==0 as well.
   27.10          XToolkit.awtLock();
   27.11          try {
   27.12 -            return XlibWrapper.IsKeypadKey(
   27.13 -                XlibWrapper.XKeycodeToKeysym(ev.get_display(), ev.get_keycode(), ndx ) );
   27.14 +            return (XlibWrapper.IsKeypadKey(
   27.15 +                XlibWrapper.XKeycodeToKeysym(ev.get_display(), ev.get_keycode(), ndx ) ) ||
   27.16 +                   XlibWrapper.IsKeypadKey(
   27.17 +                XlibWrapper.XKeycodeToKeysym(ev.get_display(), ev.get_keycode(), 0 ) ));
   27.18          } finally {
   27.19              XToolkit.awtUnlock();
   27.20          }
    28.1 --- a/src/solaris/classes/sun/awt/X11/XNETProtocol.java	Wed Sep 17 13:45:37 2008 -0700
    28.2 +++ b/src/solaris/classes/sun/awt/X11/XNETProtocol.java	Fri Sep 19 19:38:12 2008 -0700
    28.3 @@ -189,6 +189,8 @@
    28.4                  req.set_format(32);
    28.5                  req.set_data(0, (!set) ? _NET_WM_STATE_REMOVE : _NET_WM_STATE_ADD);
    28.6                  req.set_data(1, state.getAtom());
    28.7 +                // Fix for 6735584: req.data[2] must be set to 0 when only one property is changed
    28.8 +                req.set_data(2, 0);
    28.9                  log.log(Level.FINE, "Setting _NET_STATE atom {0} on {1} for {2}", new Object[] {state, window, Boolean.valueOf(set)});
   28.10                  XToolkit.awtLock();
   28.11                  try {
    29.1 --- a/src/solaris/classes/sun/awt/X11/XToolkit.java	Wed Sep 17 13:45:37 2008 -0700
    29.2 +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java	Fri Sep 19 19:38:12 2008 -0700
    29.3 @@ -97,6 +97,11 @@
    29.4      static int awt_multiclick_time;
    29.5      static boolean securityWarningEnabled;
    29.6  
    29.7 +    // WeakSet should be used here, but there is no such class
    29.8 +    // in JDK (at least in JDK6 and earlier versions)
    29.9 +    private WeakHashMap<Window, Boolean> overrideRedirectWindows =
   29.10 +        new WeakHashMap<Window, Boolean>();
   29.11 +
   29.12      private static int screenWidth = -1, screenHeight = -1; // Dimensions of default screen
   29.13      static long awt_defaultFg; // Pixel
   29.14      private static XMouseInfoPeer xPeer;
   29.15 @@ -1248,6 +1253,19 @@
   29.16          }
   29.17      }
   29.18  
   29.19 +    @Override
   29.20 +    public void setOverrideRedirect(Window target) {
   29.21 +        synchronized (overrideRedirectWindows) {
   29.22 +            overrideRedirectWindows.put(target, true);
   29.23 +        }
   29.24 +    }
   29.25 +
   29.26 +    public boolean isOverrideRedirect(Window target) {
   29.27 +        synchronized (overrideRedirectWindows) {
   29.28 +            return overrideRedirectWindows.containsKey(target);
   29.29 +        }
   29.30 +    }
   29.31 +
   29.32      static void dumpPeers() {
   29.33          if (log.isLoggable(Level.FINE)) {
   29.34              log.fine("Mapped windows:");
    30.1 --- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Wed Sep 17 13:45:37 2008 -0700
    30.2 +++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Fri Sep 19 19:38:12 2008 -0700
    30.3 @@ -129,6 +129,7 @@
    30.4      private static final int MAXIMUM_BUFFER_LENGTH_NET_WM_ICON = (2<<15) - 1;
    30.5  
    30.6      void preInit(XCreateWindowParams params) {
    30.7 +        target = (Component)params.get(TARGET);
    30.8          params.put(REPARENTED,
    30.9                     Boolean.valueOf(isOverrideRedirect() || isSimpleWindow()));
   30.10          super.preInit(params);
   30.11 @@ -1117,6 +1118,7 @@
   30.12  
   30.13      boolean isOverrideRedirect() {
   30.14          return (XWM.getWMID() == XWM.OPENLOOK_WM ? true : false) ||
   30.15 +            ((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target) ||
   30.16              XTrayIconPeer.isTrayIconStuffWindow((Window)target);
   30.17      }
   30.18  
    31.1 --- a/src/solaris/classes/sun/awt/X11/keysym2ucs.h	Wed Sep 17 13:45:37 2008 -0700
    31.2 +++ b/src/solaris/classes/sun/awt/X11/keysym2ucs.h	Fri Sep 19 19:38:12 2008 -0700
    31.3 @@ -139,10 +139,15 @@
    31.4  tojava         // Otherwise, it is [1].
    31.5  tojava         int ndx = XToolkit.isXsunServer() &&
    31.6  tojava                   ! XToolkit.isXKBenabled() ? 2 : 1;
    31.7 +tojava         // Even if XKB is enabled, we have another problem: some symbol tables (e.g. cz) force
    31.8 +tojava         // a regular comma instead of KP_comma for a decimal separator. Result is,
    31.9 +tojava         // bugs like 6454041. So, we will try for keypadness  a keysym with ndx==0 as well.
   31.10  tojava         XToolkit.awtLock();
   31.11  tojava         try {
   31.12 -tojava             return XlibWrapper.IsKeypadKey(
   31.13 -tojava                 XlibWrapper.XKeycodeToKeysym(ev.get_display(), ev.get_keycode(), ndx ) );
   31.14 +tojava             return (XlibWrapper.IsKeypadKey(
   31.15 +tojava                 XlibWrapper.XKeycodeToKeysym(ev.get_display(), ev.get_keycode(), ndx ) ) ||
   31.16 +tojava                    XlibWrapper.IsKeypadKey(
   31.17 +tojava                 XlibWrapper.XKeycodeToKeysym(ev.get_display(), ev.get_keycode(), 0 ) ));
   31.18  tojava         } finally {
   31.19  tojava             XToolkit.awtUnlock();
   31.20  tojava         }
    32.1 --- a/src/solaris/classes/sun/awt/motif/MButtonPeer.java	Wed Sep 17 13:45:37 2008 -0700
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,97 +0,0 @@
    32.4 -/*
    32.5 - * Copyright 1995-2001 Sun Microsystems, Inc.  All Rights Reserved.
    32.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.7 - *
    32.8 - * This code is free software; you can redistribute it and/or modify it
    32.9 - * under the terms of the GNU General Public License version 2 only, as
   32.10 - * published by the Free Software Foundation.  Sun designates this
   32.11 - * particular file as subject to the "Classpath" exception as provided
   32.12 - * by Sun in the LICENSE file that accompanied this code.
   32.13 - *
   32.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   32.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   32.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   32.17 - * version 2 for more details (a copy is included in the LICENSE file that
   32.18 - * accompanied this code).
   32.19 - *
   32.20 - * You should have received a copy of the GNU General Public License version
   32.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   32.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   32.23 - *
   32.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   32.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   32.26 - * have any questions.
   32.27 - */
   32.28 -package sun.awt.motif;
   32.29 -
   32.30 -import java.awt.*;
   32.31 -import java.awt.peer.*;
   32.32 -import java.awt.event.ActionEvent;
   32.33 -
   32.34 -class MButtonPeer extends MComponentPeer implements ButtonPeer {
   32.35 -    native void create(MComponentPeer peer);
   32.36 -    public native void setLabel(String label);
   32.37 -
   32.38 -    MButtonPeer(Button target) {
   32.39 -        super(target);
   32.40 -    }
   32.41 -
   32.42 -    public Dimension getMinimumSize() {
   32.43 -        FontMetrics fm = getFontMetrics(target.getFont());
   32.44 -        String label = ((Button)target).getLabel();
   32.45 -        if ( label == null ) {
   32.46 -            label = "";
   32.47 -        }
   32.48 -        return new Dimension(fm.stringWidth(label) + 14,
   32.49 -                             fm.getHeight() + 8);
   32.50 -    }
   32.51 -
   32.52 -    public boolean isFocusable() {
   32.53 -        return true;
   32.54 -    }
   32.55 -
   32.56 -    // NOTE: This method is called by privileged threads.
   32.57 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   32.58 -    public void action(final long when, final int modifiers) {
   32.59 -        MToolkit.executeOnEventHandlerThread(target, new Runnable() {
   32.60 -            public void run() {
   32.61 -                postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
   32.62 -                                          ((Button)target).getActionCommand(),
   32.63 -                                          when, modifiers));
   32.64 -            }
   32.65 -        });
   32.66 -    }
   32.67 -
   32.68 -    /*
   32.69 -     * Print the native component by rendering the Motif look ourselves.
   32.70 -     * ToDo(aim): needs to query native motif for more accurate size and
   32.71 -     * color information.
   32.72 -     */
   32.73 -    public void print(Graphics g) {
   32.74 -        Button b = (Button)target;
   32.75 -        Dimension d = b.size();
   32.76 -        Color bg = b.getBackground();
   32.77 -        Color fg = b.getForeground();
   32.78 -
   32.79 -        g.setColor(bg);
   32.80 -        g.fillRect(2, 2, d.width - 3, d.height - 3);
   32.81 -        draw3DRect(g, bg, 1, 1, d.width - 2, d.height - 2, true);
   32.82 -
   32.83 -        g.setColor(fg);
   32.84 -        g.setFont(b.getFont());
   32.85 -        FontMetrics fm = g.getFontMetrics();
   32.86 -        String lbl = b.getLabel();
   32.87 -        g.drawString(lbl, (d.width - fm.stringWidth(lbl)) / 2,
   32.88 -                          (d.height + fm.getMaxAscent() - fm.getMaxDescent()) / 2);
   32.89 -
   32.90 -        target.print(g);
   32.91 -    }
   32.92 -
   32.93 -    /**
   32.94 -     * DEPRECATED
   32.95 -     */
   32.96 -    public Dimension minimumSize() {
   32.97 -        return getMinimumSize();
   32.98 -    }
   32.99 -
  32.100 -}
    33.1 --- a/src/solaris/classes/sun/awt/motif/MCanvasPeer.java	Wed Sep 17 13:45:37 2008 -0700
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,113 +0,0 @@
    33.4 -/*
    33.5 - * Copyright 1995-2005 Sun Microsystems, Inc.  All Rights Reserved.
    33.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.7 - *
    33.8 - * This code is free software; you can redistribute it and/or modify it
    33.9 - * under the terms of the GNU General Public License version 2 only, as
   33.10 - * published by the Free Software Foundation.  Sun designates this
   33.11 - * particular file as subject to the "Classpath" exception as provided
   33.12 - * by Sun in the LICENSE file that accompanied this code.
   33.13 - *
   33.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   33.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   33.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   33.17 - * version 2 for more details (a copy is included in the LICENSE file that
   33.18 - * accompanied this code).
   33.19 - *
   33.20 - * You should have received a copy of the GNU General Public License version
   33.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   33.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   33.23 - *
   33.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   33.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   33.26 - * have any questions.
   33.27 - */
   33.28 -package sun.awt.motif;
   33.29 -
   33.30 -import java.awt.*;
   33.31 -import java.awt.peer.*;
   33.32 -import sun.awt.DisplayChangedListener;
   33.33 -import sun.awt.X11GraphicsConfig;
   33.34 -import sun.awt.X11GraphicsDevice;
   33.35 -import sun.awt.X11GraphicsEnvironment;
   33.36 -
   33.37 -class MCanvasPeer extends MComponentPeer implements CanvasPeer,
   33.38 - DisplayChangedListener {
   33.39 -
   33.40 -    native void create(MComponentPeer parent);
   33.41 -    private static native void initIDs();
   33.42 -    static {
   33.43 -        initIDs();
   33.44 -    }
   33.45 -
   33.46 -    MCanvasPeer() {}
   33.47 -
   33.48 -    MCanvasPeer(Component target) {
   33.49 -        super(target);
   33.50 -    }
   33.51 -
   33.52 -    MCanvasPeer(Component target, Object arg) {
   33.53 -        super(target, arg);
   33.54 -    }
   33.55 -
   33.56 -/* --- DisplayChangedListener Stuff --- */
   33.57 -    public void displayChanged() {}
   33.58 -    public void paletteChanged() {}
   33.59 -    native void resetTargetGC(Component target);
   33.60 -
   33.61 -    /*
   33.62 -     * Called when the Window this
   33.63 -     * Canvas is on is moved onto another Xinerama screen.
   33.64 -     *
   33.65 -     * Canvases can be created with a non-defulat GraphicsConfiguration.  The
   33.66 -     * GraphicsConfiguration needs to be changed to one on the new screen,
   33.67 -     * preferably with the same visual ID.
   33.68 -     *
   33.69 -     * Up-called for other windows peer instances (WPanelPeer, WWindowPeer).
   33.70 -     *
   33.71 -     * Should only be called from the event thread.
   33.72 -     */
   33.73 -     public void displayChanged(int screenNum) {
   33.74 -        resetLocalGC(screenNum);
   33.75 -        resetTargetGC(target);  /* call Canvas.setGCFromPeer() via native */
   33.76 -    }
   33.77 -
   33.78 -    /* Set graphicsConfig to a GraphicsConfig with the same visual on the new
   33.79 -     * screen, which should be easy in Xinerama mode.
   33.80 -     *
   33.81 -     * Should only be called from displayChanged(), and therefore only from
   33.82 -     * the event thread.
   33.83 -     */
   33.84 -    void resetLocalGC(int screenNum) {
   33.85 -        // Opt: Only need to do if we're not using the default GC
   33.86 -        if (graphicsConfig != null) {
   33.87 -            X11GraphicsConfig parentgc;
   33.88 -            // save vis id of current gc
   33.89 -            int visual = graphicsConfig.getVisual();
   33.90 -
   33.91 -            X11GraphicsDevice newDev = (X11GraphicsDevice) GraphicsEnvironment.
   33.92 -                                                 getLocalGraphicsEnvironment().
   33.93 -                                                 getScreenDevices()[screenNum];
   33.94 -
   33.95 -            for (int i = 0; i < newDev.getNumConfigs(screenNum); i++) {
   33.96 -                if (visual == newDev.getConfigVisualId(i, screenNum)) {
   33.97 -                    // use that
   33.98 -                    graphicsConfig = (X11GraphicsConfig)newDev.getConfigurations()[i];
   33.99 -                    break;
  33.100 -                }
  33.101 -            }
  33.102 -            // just in case...
  33.103 -            if (graphicsConfig == null) {
  33.104 -                graphicsConfig = (X11GraphicsConfig) GraphicsEnvironment.
  33.105 -                                           getLocalGraphicsEnvironment().
  33.106 -                                           getScreenDevices()[screenNum].
  33.107 -                                           getDefaultConfiguration();
  33.108 -            }
  33.109 -        }
  33.110 -    }
  33.111 -
  33.112 -    protected boolean shouldFocusOnClick() {
  33.113 -        // Canvas should always be able to be focused by mouse clicks.
  33.114 -        return true;
  33.115 -    }
  33.116 -}
    34.1 --- a/src/solaris/classes/sun/awt/motif/MCheckboxMenuItemPeer.java	Wed Sep 17 13:45:37 2008 -0700
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,93 +0,0 @@
    34.4 -/*
    34.5 - * Copyright 1995-2005 Sun Microsystems, Inc.  All Rights Reserved.
    34.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.7 - *
    34.8 - * This code is free software; you can redistribute it and/or modify it
    34.9 - * under the terms of the GNU General Public License version 2 only, as
   34.10 - * published by the Free Software Foundation.  Sun designates this
   34.11 - * particular file as subject to the "Classpath" exception as provided
   34.12 - * by Sun in the LICENSE file that accompanied this code.
   34.13 - *
   34.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   34.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   34.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   34.17 - * version 2 for more details (a copy is included in the LICENSE file that
   34.18 - * accompanied this code).
   34.19 - *
   34.20 - * You should have received a copy of the GNU General Public License version
   34.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   34.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   34.23 - *
   34.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   34.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   34.26 - * have any questions.
   34.27 - */
   34.28 -
   34.29 -package sun.awt.motif;
   34.30 -
   34.31 -
   34.32 -import java.awt.*;
   34.33 -import java.awt.event.*;
   34.34 -import java.awt.peer.*;
   34.35 -
   34.36 -class MCheckboxMenuItemPeer extends MMenuItemPeer
   34.37 -                            implements CheckboxMenuItemPeer {
   34.38 -    private boolean inUpCall=false;
   34.39 -    private boolean inInit=false;
   34.40 -
   34.41 -    native void pSetState(boolean t);
   34.42 -    native boolean getState();
   34.43 -
   34.44 -    void create(MMenuPeer parent) {
   34.45 -        super.create(parent);
   34.46 -        inInit=true;
   34.47 -        setState(((CheckboxMenuItem)target).getState());
   34.48 -        inInit=false;
   34.49 -    }
   34.50 -
   34.51 -    MCheckboxMenuItemPeer(CheckboxMenuItem target) {
   34.52 -        this.target = target;
   34.53 -        isCheckbox = true;
   34.54 -        MMenuPeer parent = (MMenuPeer) MToolkit.targetToPeer(getParent_NoClientCode(target));
   34.55 -        create(parent);
   34.56 -    }
   34.57 -
   34.58 -    public void setState(boolean t) {
   34.59 -        if (!nativeCreated) {
   34.60 -            return;
   34.61 -        }
   34.62 -        if (!inUpCall && (t != getState())) {
   34.63 -            pSetState(t);
   34.64 -            if (!inInit) {
   34.65 -                // 4135725 : do not notify on programatic changes
   34.66 -                // notifyStateChanged(t);
   34.67 -            }
   34.68 -        }
   34.69 -    }
   34.70 -
   34.71 -    void notifyStateChanged(boolean state) {
   34.72 -        CheckboxMenuItem cb = (CheckboxMenuItem)target;
   34.73 -        ItemEvent e = new ItemEvent(cb,
   34.74 -                          ItemEvent.ITEM_STATE_CHANGED,
   34.75 -                          cb.getLabel(),
   34.76 -                          state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
   34.77 -        postEvent(e);
   34.78 -    }
   34.79 -
   34.80 -
   34.81 -    // NOTE: This method may be called by privileged threads.
   34.82 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   34.83 -    public void action(long when, int modifiers, boolean state) {
   34.84 -        final CheckboxMenuItem cb = (CheckboxMenuItem)target;
   34.85 -        final boolean newState = state;
   34.86 -
   34.87 -        MToolkit.executeOnEventHandlerThread(cb, new Runnable() {
   34.88 -            public void run() {
   34.89 -                cb.setState(newState);
   34.90 -                notifyStateChanged(newState);
   34.91 -            }
   34.92 -        });
   34.93 -        //Fix for 5005195: MAWT: CheckboxMenuItem fires action events
   34.94 -        //super.action() is not invoked
   34.95 -    } // action()
   34.96 -} // class MCheckboxMenuItemPeer
    35.1 --- a/src/solaris/classes/sun/awt/motif/MCheckboxPeer.java	Wed Sep 17 13:45:37 2008 -0700
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,187 +0,0 @@
    35.4 -/*
    35.5 - * Copyright 1995-2000 Sun Microsystems, Inc.  All Rights Reserved.
    35.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    35.7 - *
    35.8 - * This code is free software; you can redistribute it and/or modify it
    35.9 - * under the terms of the GNU General Public License version 2 only, as
   35.10 - * published by the Free Software Foundation.  Sun designates this
   35.11 - * particular file as subject to the "Classpath" exception as provided
   35.12 - * by Sun in the LICENSE file that accompanied this code.
   35.13 - *
   35.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   35.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   35.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   35.17 - * version 2 for more details (a copy is included in the LICENSE file that
   35.18 - * accompanied this code).
   35.19 - *
   35.20 - * You should have received a copy of the GNU General Public License version
   35.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   35.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   35.23 - *
   35.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   35.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   35.26 - * have any questions.
   35.27 - */
   35.28 -
   35.29 -package sun.awt.motif;
   35.30 -
   35.31 -import java.awt.*;
   35.32 -import java.awt.peer.*;
   35.33 -import java.awt.event.*;
   35.34 -
   35.35 -public class MCheckboxPeer extends MComponentPeer implements CheckboxPeer {
   35.36 -    private boolean inUpCall = false;
   35.37 -    private boolean inInit=false;
   35.38 -
   35.39 -    native void create(MComponentPeer parent);
   35.40 -    native void pSetState(boolean state);
   35.41 -    native boolean pGetState();
   35.42 -
   35.43 -    public native void setLabel(String label);
   35.44 -    public native void setCheckboxGroup(CheckboxGroup g);
   35.45 -
   35.46 -
   35.47 -    void initialize() {
   35.48 -        Checkbox t = (Checkbox)target;
   35.49 -        inInit=true;
   35.50 -
   35.51 -        setState(t.getState());
   35.52 -        setCheckboxGroup(t.getCheckboxGroup());
   35.53 -        super.initialize();
   35.54 -        inInit=false;
   35.55 -    }
   35.56 -
   35.57 -    public MCheckboxPeer(Checkbox target) {
   35.58 -        super(target);
   35.59 -    }
   35.60 -
   35.61 -    public boolean isFocusable() {
   35.62 -        return true;
   35.63 -    }
   35.64 -
   35.65 -    public void setState(boolean state) {
   35.66 -        if (inInit) {
   35.67 -                pSetState(state);
   35.68 -        } else if (!inUpCall && (state != pGetState())) {
   35.69 -                pSetState(state);
   35.70 -                // 4135725 : do not notify on programatic changes
   35.71 -                // notifyStateChanged(state);
   35.72 -        }
   35.73 -    }
   35.74 -    private native int getIndicatorSize();
   35.75 -    private native int getSpacing();
   35.76 -
   35.77 -    public Dimension getMinimumSize() {
   35.78 -        String lbl = ((Checkbox)target).getLabel();
   35.79 -        if (lbl == null) {
   35.80 -            lbl = "";
   35.81 -        }
   35.82 -        FontMetrics fm = getFontMetrics(target.getFont());
   35.83 -        /*
   35.84 -         * Spacing (number of pixels between check mark and label text) is
   35.85 -         * currently set to 0, but in case it ever changes we have to add
   35.86 -         * it. 8 is a heuristic number. Indicator size depends on font
   35.87 -         * height, so we don't need to include it in checkbox's height
   35.88 -         * calculation.
   35.89 -         */
   35.90 -        int wdth = fm.stringWidth(lbl) + getIndicatorSize() + getSpacing() + 8;
   35.91 -        int hght = Math.max(fm.getHeight() + 8, 15);
   35.92 -        return new Dimension(wdth, hght);
   35.93 -    }
   35.94 -
   35.95 -
   35.96 -    void notifyStateChanged(boolean state) {
   35.97 -        Checkbox cb = (Checkbox) target;
   35.98 -        ItemEvent e = new ItemEvent(cb,
   35.99 -                          ItemEvent.ITEM_STATE_CHANGED,
  35.100 -                          cb.getLabel(),
  35.101 -                          state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
  35.102 -        postEvent(e);
  35.103 -    }
  35.104 -
  35.105 -
  35.106 -    // NOTE: This method is called by privileged threads.
  35.107 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  35.108 -    void action(boolean state) {
  35.109 -        final Checkbox cb = (Checkbox)target;
  35.110 -        final boolean newState = state;
  35.111 -        MToolkit.executeOnEventHandlerThread(cb, new Runnable() {
  35.112 -            public void run() {
  35.113 -                CheckboxGroup cbg = cb.getCheckboxGroup();
  35.114 -                /* Bugid 4039594. If this is the current Checkbox in
  35.115 -                 * a CheckboxGroup, then return to prevent deselection.
  35.116 -                 * Otherwise, it's logical state will be turned off,
  35.117 -                 * but it will appear on.
  35.118 -                 */
  35.119 -                if ((cbg != null) && (cbg.getSelectedCheckbox() == cb) &&
  35.120 -                    cb.getState()) {
  35.121 -                  inUpCall = false;
  35.122 -                  cb.setState(true);
  35.123 -                  return;
  35.124 -                }
  35.125 -                // All clear - set the new state
  35.126 -                cb.setState(newState);
  35.127 -                notifyStateChanged(newState);
  35.128 -            } // run()
  35.129 -        });
  35.130 -    } // action()
  35.131 -
  35.132 -
  35.133 -
  35.134 -    static final int SIZE = 19;
  35.135 -    static final int BORDER = 4;
  35.136 -    static final int SIZ = SIZE - BORDER*2 - 1;
  35.137 -
  35.138 -    /*
  35.139 -     * Print the native component by rendering the Motif look ourselves.
  35.140 -     * ToDo(aim): needs to query native motif for more accurate size and
  35.141 -     * color information; need to render check mark.
  35.142 -     */
  35.143 -    public void print(Graphics g) {
  35.144 -        Checkbox cb = (Checkbox)target;
  35.145 -        Dimension d = cb.size();
  35.146 -        Color bg = cb.getBackground();
  35.147 -        Color fg = cb.getForeground();
  35.148 -        Color shadow = bg.darker();
  35.149 -        int x = BORDER;
  35.150 -        int y = ((d.height - SIZE) / 2) + BORDER;
  35.151 -
  35.152 -        g.setColor(cb.getState()? shadow : bg);
  35.153 -
  35.154 -        if (cb.getCheckboxGroup() != null) {
  35.155 -            g.fillOval(x, y, SIZ, SIZ);
  35.156 -            draw3DOval(g, bg, x, y, SIZ, SIZ, !(cb.getState()));
  35.157 -            if (cb.getState()) {
  35.158 -                g.setColor(fg);
  35.159 -                g.fillOval(x + 3, y + 3, SIZ - 6, SIZ - 6);
  35.160 -            }
  35.161 -        } else {
  35.162 -            g.fillRect(x, y, SIZ, SIZ);
  35.163 -            draw3DRect(g, bg, x, y, SIZ, SIZ, !(cb.getState()));
  35.164 -            if (cb.getState()) {
  35.165 -                g.setColor(fg);
  35.166 -                g.drawLine(x+1, y+1, x+SIZ-1, y+SIZ-1);
  35.167 -                g.drawLine(x+1, y+SIZ-1, x+SIZ-1, y+1);
  35.168 -            }
  35.169 -        }
  35.170 -        g.setColor(fg);
  35.171 -        String lbl = cb.getLabel();
  35.172 -        if (lbl != null) {
  35.173 -            // REMIND: align
  35.174 -            g.setFont(cb.getFont());
  35.175 -            FontMetrics fm = g.getFontMetrics();
  35.176 -            g.drawString(lbl, SIZE,
  35.177 -                         (d.height + fm.getMaxAscent() - fm.getMaxDescent()) / 2);
  35.178 -        }
  35.179 -
  35.180 -        target.print(g);
  35.181 -    }
  35.182 -
  35.183 -    /**
  35.184 -     * DEPRECATED
  35.185 -     */
  35.186 -    public Dimension minimumSize() {
  35.187 -            return getMinimumSize();
  35.188 -    }
  35.189 -
  35.190 -}
    36.1 --- a/src/solaris/classes/sun/awt/motif/MChoicePeer.java	Wed Sep 17 13:45:37 2008 -0700
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,177 +0,0 @@
    36.4 -/*
    36.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
    36.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    36.7 - *
    36.8 - * This code is free software; you can redistribute it and/or modify it
    36.9 - * under the terms of the GNU General Public License version 2 only, as
   36.10 - * published by the Free Software Foundation.  Sun designates this
   36.11 - * particular file as subject to the "Classpath" exception as provided
   36.12 - * by Sun in the LICENSE file that accompanied this code.
   36.13 - *
   36.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   36.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   36.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   36.17 - * version 2 for more details (a copy is included in the LICENSE file that
   36.18 - * accompanied this code).
   36.19 - *
   36.20 - * You should have received a copy of the GNU General Public License version
   36.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   36.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   36.23 - *
   36.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   36.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   36.26 - * have any questions.
   36.27 - */
   36.28 -
   36.29 -package sun.awt.motif;
   36.30 -
   36.31 -import java.awt.*;
   36.32 -import java.awt.peer.*;
   36.33 -import java.awt.event.ItemEvent;
   36.34 -
   36.35 -class MChoicePeer extends MComponentPeer implements ChoicePeer {
   36.36 -    boolean inUpCall=false;
   36.37 -
   36.38 -    native void create(MComponentPeer parent);
   36.39 -    native void pReshape(int x, int y, int width, int height);
   36.40 -    native void pSelect(int index, boolean init);
   36.41 -    native void appendItems(String[] items);
   36.42 -
   36.43 -    void initialize() {
   36.44 -        Choice opt = (Choice)target;
   36.45 -        int itemCount = opt.countItems();
   36.46 -        String[] items = new String[itemCount];
   36.47 -        for (int i=0; i < itemCount; i++) {
   36.48 -            items[i] = opt.getItem(i);
   36.49 -        }
   36.50 -        if (itemCount > 0) {
   36.51 -            appendItems(items);
   36.52 -            pSelect(opt.getSelectedIndex(), true);
   36.53 -        }
   36.54 -        super.initialize();
   36.55 -    }
   36.56 -
   36.57 -    public MChoicePeer(Choice target) {
   36.58 -        super(target);
   36.59 -    }
   36.60 -
   36.61 -    public boolean isFocusable() {
   36.62 -        return true;
   36.63 -    }
   36.64 -
   36.65 -    public Dimension getMinimumSize() {
   36.66 -        FontMetrics fm = getFontMetrics(target.getFont());
   36.67 -        Choice c = (Choice)target;
   36.68 -        int w = 0;
   36.69 -        for (int i = c.countItems() ; i-- > 0 ;) {
   36.70 -            w = Math.max(fm.stringWidth(c.getItem(i)), w);
   36.71 -        }
   36.72 -        return new Dimension(32 + w, Math.max(fm.getHeight() + 8, 15) + 5);
   36.73 -    }
   36.74 -
   36.75 -    public native void setFont(Font f);
   36.76 -
   36.77 -    public void add(String item, int index) {
   36.78 -        addItem(item, index);
   36.79 -        // Adding an item can change the size of the Choice, so do
   36.80 -        // a reshape, based on the font size.
   36.81 -        Rectangle r = target.getBounds();
   36.82 -        reshape(r.x, r.y, 0, 0);
   36.83 -    }
   36.84 -
   36.85 -    public native void remove(int index);
   36.86 -
   36.87 -    public native void removeAll();
   36.88 -
   36.89 -    /**
   36.90 -     * DEPRECATED, but for now, called by add(String, int).
   36.91 -     */
   36.92 -    public native void addItem(String item, int index);
   36.93 -
   36.94 -    // public native void remove(int index);
   36.95 -
   36.96 -    public native void setBackground(Color c);
   36.97 -
   36.98 -    public native void setForeground(Color c);
   36.99 -
  36.100 -    public void select(int index) {
  36.101 -        if (!inUpCall) {
  36.102 -            pSelect(index, false);
  36.103 -        }
  36.104 -    }
  36.105 -
  36.106 -    void notifySelection(String item) {
  36.107 -        Choice c = (Choice)target;
  36.108 -        ItemEvent e = new ItemEvent(c, ItemEvent.ITEM_STATE_CHANGED,
  36.109 -                                item, ItemEvent.SELECTED);
  36.110 -        postEvent(e);
  36.111 -    }
  36.112 -
  36.113 -
  36.114 -    // NOTE: This method is called by privileged threads.
  36.115 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  36.116 -    void action(final int index) {
  36.117 -        final Choice c = (Choice)target;
  36.118 -        inUpCall = false;  /* Used to prevent native selection. */
  36.119 -        MToolkit.executeOnEventHandlerThread(c, new Runnable() {
  36.120 -            public void run() {
  36.121 -                String item;
  36.122 -                synchronized(c) {
  36.123 -                    if (index >= c.getItemCount()) {
  36.124 -                        /* Nothing to do when the list is too short */
  36.125 -                        return;
  36.126 -                    }
  36.127 -                    inUpCall = true;       /* Prevent native selection. */
  36.128 -                    c.select(index);       /* set value in target */
  36.129 -                    item = c.getItem(index);
  36.130 -                    inUpCall = false;
  36.131 -                }
  36.132 -                notifySelection(item);
  36.133 -            }
  36.134 -        });
  36.135 -    }
  36.136 -
  36.137 -    /*
  36.138 -     * Print the native component by rendering the Motif look ourselves.
  36.139 -     * ToDo(aim): needs to query native motif for more accurate size and
  36.140 -     * color information.
  36.141 -     */
  36.142 -    public void print(Graphics g) {
  36.143 -        Choice ch = (Choice)target;
  36.144 -        Dimension d = ch.size();
  36.145 -        Color bg = ch.getBackground();
  36.146 -        Color fg = ch.getForeground();
  36.147 -
  36.148 -        g.setColor(bg);
  36.149 -        g.fillRect(2, 2, d.width-1, d.height-1);
  36.150 -        draw3DRect(g, bg, 1, 1, d.width-2, d.height-2, true);
  36.151 -        draw3DRect(g, bg, d.width - 18, (d.height / 2) - 3, 10, 6, true);
  36.152 -
  36.153 -        g.setColor(fg);
  36.154 -        g.setFont(ch.getFont());
  36.155 -        FontMetrics fm = g.getFontMetrics();
  36.156 -        String lbl = ch.getSelectedItem();
  36.157 -        if (lbl == null){
  36.158 -            lbl = "";
  36.159 -        }
  36.160 -        if (lbl != ""){
  36.161 -            g.drawString(lbl, 5, (d.height + fm.getMaxAscent()-fm.getMaxDescent())/2);
  36.162 -        }
  36.163 -
  36.164 -        target.print(g);
  36.165 -    }
  36.166 -
  36.167 -    /**
  36.168 -     * DEPRECATED
  36.169 -     */
  36.170 -    public Dimension minimumSize() {
  36.171 -            return getMinimumSize();
  36.172 -    }
  36.173 -
  36.174 -    protected void disposeImpl() {
  36.175 -        freeNativeData();
  36.176 -        super.disposeImpl();
  36.177 -    }
  36.178 -
  36.179 -    private native void freeNativeData();
  36.180 -}
    37.1 --- a/src/solaris/classes/sun/awt/motif/MComponentPeer.java	Wed Sep 17 13:45:37 2008 -0700
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,1185 +0,0 @@
    37.4 -/*
    37.5 - * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
    37.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    37.7 - *
    37.8 - * This code is free software; you can redistribute it and/or modify it
    37.9 - * under the terms of the GNU General Public License version 2 only, as
   37.10 - * published by the Free Software Foundation.  Sun designates this
   37.11 - * particular file as subject to the "Classpath" exception as provided
   37.12 - * by Sun in the LICENSE file that accompanied this code.
   37.13 - *
   37.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   37.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   37.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   37.17 - * version 2 for more details (a copy is included in the LICENSE file that
   37.18 - * accompanied this code).
   37.19 - *
   37.20 - * You should have received a copy of the GNU General Public License version
   37.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   37.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   37.23 - *
   37.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   37.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   37.26 - * have any questions.
   37.27 - */
   37.28 -
   37.29 -package sun.awt.motif;
   37.30 -
   37.31 -import java.awt.*;
   37.32 -import java.awt.peer.*;
   37.33 -import java.awt.event.PaintEvent;
   37.34 -import java.awt.event.MouseEvent;
   37.35 -import java.awt.event.InputEvent;
   37.36 -
   37.37 -import sun.awt.*;
   37.38 -import sun.awt.image.ToolkitImage;
   37.39 -import sun.awt.image.SunVolatileImage;
   37.40 -import java.awt.image.ImageProducer;
   37.41 -import java.awt.image.ImageObserver;
   37.42 -import java.awt.image.ColorModel;
   37.43 -import java.awt.image.VolatileImage;
   37.44 -
   37.45 -import java.awt.dnd.DropTarget;
   37.46 -import java.awt.dnd.peer.DropTargetPeer;
   37.47 -
   37.48 -import sun.java2d.SunGraphics2D;
   37.49 -import sun.java2d.SurfaceData;
   37.50 -
   37.51 -import java.lang.reflect.Method;
   37.52 -
   37.53 -import java.util.logging.*;
   37.54 -
   37.55 -import sun.java2d.pipe.Region;
   37.56 -
   37.57 -
   37.58 -public /* REMIND: should not be public */
   37.59 -abstract class MComponentPeer implements ComponentPeer, DropTargetPeer, X11ComponentPeer {
   37.60 -
   37.61 -    private static final Logger log = Logger.getLogger("sun.awt.motif.MComponentPeer");
   37.62 -    private static final Logger focusLog = Logger.getLogger("sun.awt.motif.focus.MComponentPeer");
   37.63 -
   37.64 -    Component   target;
   37.65 -    long        pData;
   37.66 -    long        jniGlobalRef;
   37.67 -    protected X11GraphicsConfig graphicsConfig;
   37.68 -    SurfaceData surfaceData;
   37.69 -    int         oldWidth = -1;
   37.70 -    int         oldHeight = -1;
   37.71 -
   37.72 -    private RepaintArea paintArea;
   37.73 -
   37.74 -    boolean isLayouting = false;
   37.75 -    boolean paintPending = false;
   37.76 -
   37.77 -    protected boolean disposed = false;
   37.78 -    private static int JAWT_LOCK_ERROR=0x00000001;
   37.79 -    private static int JAWT_LOCK_CLIP_CHANGED=0x00000002;
   37.80 -    private static int JAWT_LOCK_BOUNDS_CHANGED=0x00000004;
   37.81 -    private static int JAWT_LOCK_SURFACE_CHANGED=0x00000008;
   37.82 -    private int drawState = JAWT_LOCK_CLIP_CHANGED |
   37.83 -    JAWT_LOCK_BOUNDS_CHANGED |
   37.84 -    JAWT_LOCK_SURFACE_CHANGED;
   37.85 -
   37.86 -    /* These are the enumerated types in awt_p.h*/
   37.87 -    static final int MOTIF_NA = 0 ;
   37.88 -    static final int MOTIF_V1 = 1 ;
   37.89 -    static final int MOTIF_V2 = 2 ;
   37.90 -
   37.91 -    private Font font;
   37.92 -    private long backBuffer = 0;
   37.93 -    private VolatileImage xBackBuffer = null;
   37.94 -
   37.95 -    static {
   37.96 -        initIDs();
   37.97 -    }
   37.98 -
   37.99 -    /* initialize the fieldIDs of fields that may be accessed from C */
  37.100 -    private native static void initIDs();
  37.101 -
  37.102 -
  37.103 -    /* This will return the last state of a window. ie the specific
  37.104 -     * "gotcha" is that if you iconify a window its obscurity remains
  37.105 -     * unchanged. Current use of this is just in user-initiated scrolling.
  37.106 -     * If that use expands to more cases you may need to "and" this with
  37.107 -     * the value of the iconic state of a Frame.
  37.108 -     * Note that de-iconifying an X11 window DOES generate a new event
  37.109 -     * correctly notifying you of the new visibility of the window
  37.110 -     */
  37.111 -    public boolean isObscured() {
  37.112 -
  37.113 -        Container container  = (target instanceof Container) ?
  37.114 -            (Container)target : target.getParent();
  37.115 -
  37.116 -        if (container == null) {
  37.117 -            return true;
  37.118 -        }
  37.119 -
  37.120 -        Container parent;
  37.121 -        while ((parent = container.getParent()) != null) {
  37.122 -            container = parent;
  37.123 -        }
  37.124 -
  37.125 -        if (container instanceof Window) {
  37.126 -            MWindowPeer wpeer = (MWindowPeer)(container.getPeer());
  37.127 -            if (wpeer != null) {
  37.128 -                return (wpeer.winAttr.visibilityState !=
  37.129 -                        MWindowAttributes.AWT_UNOBSCURED);
  37.130 -            }
  37.131 -        }
  37.132 -        return true;
  37.133 -    }
  37.134 -
  37.135 -    public boolean canDetermineObscurity() {
  37.136 -        return true;
  37.137 -    }
  37.138 -
  37.139 -    abstract void create(MComponentPeer parent);
  37.140 -    void create(MComponentPeer parent, Object arg) {
  37.141 -        create(parent);
  37.142 -    }
  37.143 -
  37.144 -    void EFcreate(MComponentPeer parent, int x){}
  37.145 -
  37.146 -    native void pInitialize();
  37.147 -    native void pShow();
  37.148 -    native void pHide();
  37.149 -    native void pEnable();
  37.150 -    native void pDisable();
  37.151 -    native void pReshape(int x, int y, int width, int height);
  37.152 -    native void pDispose();
  37.153 -    native void pMakeCursorVisible();
  37.154 -    native Point pGetLocationOnScreen();
  37.155 -    native Point pGetLocationOnScreen2(Window win, MWindowPeer wpeer);
  37.156 -    native void pSetForeground(Color c);
  37.157 -    native void pSetBackground(Color c);
  37.158 -    private native void pSetFont(Font f);
  37.159 -
  37.160 -    //Added for bug 4175560
  37.161 -    //Returns the native representation for the Color argument,
  37.162 -    //using the given GraphicsConfiguration.
  37.163 -    native int getNativeColor(Color clr, GraphicsConfiguration gc);
  37.164 -
  37.165 -    // Returns the parent of the component, without invoking client
  37.166 -    // code. This must go through native code, because it invokes
  37.167 -    // private methods in the java.awt package, which we cannot
  37.168 -    // do from this package.
  37.169 -    static native Container getParent_NoClientCode(Component component);
  37.170 -
  37.171 -    // Returns the parent of the component, without invoking client
  37.172 -    // code. This must go through native code, because it invokes
  37.173 -    // private methods in the java.awt package, which we cannot
  37.174 -    // do from this package.
  37.175 -    static native Component[] getComponents_NoClientCode(Container container);
  37.176 -
  37.177 -    void initialize() {
  37.178 -        if (!target.isVisible()) {
  37.179 -            hide();
  37.180 -        }
  37.181 -        Color c;
  37.182 -        Font  f;
  37.183 -        Cursor cursor;
  37.184 -
  37.185 -        pInitialize();
  37.186 -
  37.187 -        if ((c = target.getForeground()) != null) {
  37.188 -            setForeground(c);
  37.189 -        }
  37.190 -        if ((c = target.getBackground()) != null) {
  37.191 -            setBackground(c);
  37.192 -        }
  37.193 -        if ((f = target.getFont()) != null) {
  37.194 -            setFont(f);
  37.195 -        }
  37.196 -        pSetCursor(target.getCursor());
  37.197 -        if (!target.isEnabled()) {
  37.198 -            disable();
  37.199 -        }
  37.200 -        Rectangle r = target.getBounds();
  37.201 -        reshape(r.x, r.y, r.width, r.height);
  37.202 -        if (target.isVisible()) {
  37.203 -            show();
  37.204 -        }
  37.205 -
  37.206 -        surfaceData = graphicsConfig.createSurfaceData(this);
  37.207 -    }
  37.208 -
  37.209 -    public void init(Component target, Object arg) {
  37.210 -        this.target = target;
  37.211 -        this.paintArea = new RepaintArea();
  37.212 -
  37.213 -        Container parent = MToolkit.getNativeContainer(target);
  37.214 -        MComponentPeer parentPeer = (MComponentPeer) MToolkit.targetToPeer(parent);
  37.215 -        create(parentPeer, arg);
  37.216 -
  37.217 -        initialize();
  37.218 -    }
  37.219 -
  37.220 -    MComponentPeer(Component target, Object arg) {
  37.221 -        init(target, arg);
  37.222 -    }
  37.223 -
  37.224 -    MComponentPeer() {}
  37.225 -
  37.226 -    public void init(Component target) {
  37.227 -        this.target = target;
  37.228 -        this.paintArea = new RepaintArea();
  37.229 -
  37.230 -        Container parent = MToolkit.getNativeContainer(target);
  37.231 -        MComponentPeer parentPeer = (MComponentPeer) MToolkit.targetToPeer(parent);
  37.232 -        create(parentPeer);
  37.233 -
  37.234 -        if (parent != null && parent instanceof ScrollPane) {
  37.235 -            MScrollPanePeer speer = (MScrollPanePeer) parentPeer;
  37.236 -            speer.setScrollChild(this);
  37.237 -        }
  37.238 -        initialize();
  37.239 -    }
  37.240 -
  37.241 -    MComponentPeer(Component target) {
  37.242 -        init(target);
  37.243 -    }
  37.244 -
  37.245 -    protected void finalize() throws Throwable {
  37.246 -        dispose();
  37.247 -        super.finalize();
  37.248 -    }
  37.249 -
  37.250 -    public void setForeground(Color c) {
  37.251 -        pSetForeground(c);
  37.252 -    }
  37.253 -
  37.254 -    public void setBackground(Color c) {
  37.255 -        pSetBackground(c);
  37.256 -    }
  37.257 -
  37.258 -    public void updateCursorImmediately() {
  37.259 -        MGlobalCursorManager.getCursorManager().updateCursorImmediately();
  37.260 -    }
  37.261 -
  37.262 -    public void setFont(Font f) {
  37.263 -        ComponentPeer peer;
  37.264 -        if (f == null) {
  37.265 -            f = defaultFont;
  37.266 -        }
  37.267 -        pSetFont(f);
  37.268 -        if ( target instanceof Container ) {
  37.269 -            Container container = (Container) target;
  37.270 -            int count = container.getComponentCount();
  37.271 -            Component[] children = container.getComponents();
  37.272 -            for (int i=0; i<count; i++) {
  37.273 -                if ( children[i] != null ) {
  37.274 -/*
  37.275 -** note: recursion in the widget in pSetFont() has by now broken any
  37.276 -**       children with different Fonts - so fix now:
  37.277 -*/
  37.278 -                    peer = children[i].getPeer();
  37.279 -                    if (peer != null) {
  37.280 -                        Font rightFont = children[i].getFont();
  37.281 -                        if (!f.equals(rightFont)) {
  37.282 -                            peer.setFont(rightFont);
  37.283 -                        } else
  37.284 -                            if (children[i] instanceof Container) {
  37.285 -                                peer.setFont(f);
  37.286 -                            }
  37.287 -                    }
  37.288 -                }
  37.289 -            }
  37.290 -        }
  37.291 -
  37.292 -        /*
  37.293 -         * Keep a reference to the java.awt.Font object in order to
  37.294 -         * preserve the XFontStructs which underlying widgets are using.
  37.295 -         * Save this AFTER changing the widgets in order to keep the
  37.296 -         * previous reference (if any) alive.
  37.297 -         */
  37.298 -        font = f;
  37.299 -    }
  37.300 -
  37.301 -
  37.302 -    public native void setTargetBackground(Color c);
  37.303 -    public native void pSetCursor(Cursor c);
  37.304 -    public native void pSetScrollbarBackground(Color c);
  37.305 -    public native void pSetInnerForeground(Color c);
  37.306 -
  37.307 -    public boolean isFocusable() {
  37.308 -        return false;
  37.309 -    }
  37.310 -
  37.311 -    public SurfaceData getSurfaceData() {
  37.312 -        return surfaceData;
  37.313 -    }
  37.314 -
  37.315 -    public ColorModel getColorModel() {
  37.316 -        return graphicsConfig.getColorModel();
  37.317 -    }
  37.318 -
  37.319 -    public ColorModel getColorModel(int transparency) {
  37.320 -        return graphicsConfig.getColorModel(transparency);
  37.321 -    }
  37.322 -
  37.323 -    public int updatePriority() {
  37.324 -        return Thread.NORM_PRIORITY;
  37.325 -    }
  37.326 -
  37.327 -    public void repaint(long tm, int x, int y, int width, int height) {
  37.328 -    }
  37.329 -
  37.330 -    public void paint(Graphics g) {
  37.331 -        Dimension d = target.getSize();
  37.332 -        if (g instanceof Graphics2D ||
  37.333 -            g instanceof sun.awt.Graphics2Delegate) {
  37.334 -            // background color is setup correctly, so just use clearRect
  37.335 -            g.clearRect(0, 0, d.width, d.height);
  37.336 -        } else {
  37.337 -            // emulate clearRect
  37.338 -            g.setColor(target.getBackground());
  37.339 -            g.fillRect(0, 0, d.width, d.height);
  37.340 -            g.setColor(target.getForeground());
  37.341 -        }
  37.342 -
  37.343 -        target.paint(g);
  37.344 -    }
  37.345 -    public void print(Graphics g) {
  37.346 -        Dimension d = target.getSize();
  37.347 -        if (g instanceof Graphics2D ||
  37.348 -            g instanceof sun.awt.Graphics2Delegate) {
  37.349 -            // background color is setup correctly, so just use clearRect
  37.350 -            g.clearRect(0, 0, d.width, d.height);
  37.351 -        } else {
  37.352 -            // emulate clearRect
  37.353 -            g.setColor(target.getBackground());
  37.354 -            g.fillRect(0, 0, d.width, d.height);
  37.355 -            g.setColor(target.getForeground());
  37.356 -        }
  37.357 -
  37.358 -        target.print(g);
  37.359 -    }
  37.360 -
  37.361 -    public void coalescePaintEvent(PaintEvent e) {
  37.362 -        Rectangle r = e.getUpdateRect();
  37.363 -        paintArea.add(r, e.getID());
  37.364 -
  37.365 -        if (log.isLoggable(Level.FINEST)) {
  37.366 -            switch(e.getID()) {
  37.367 -              case PaintEvent.UPDATE:
  37.368 -                  log.log(Level.FINEST, "coalescePaintEvent: UPDATE: add: x = " +
  37.369 -                          r.x + ", y = " + r.y + ", width = " + r.width + ", height = " + r.height);
  37.370 -                  return;
  37.371 -              case PaintEvent.PAINT:
  37.372 -                  log.log(Level.FINEST, "coalescePaintEvent: PAINT: add: x = " +
  37.373 -                          r.x + ", y = " + r.y + ", width = " + r.width + ", height = " + r.height);
  37.374 -                  return;
  37.375 -            }
  37.376 -        }
  37.377 -    }
  37.378 -
  37.379 -    native void nativeHandleEvent(AWTEvent e);
  37.380 -
  37.381 -    /**
  37.382 -     * Returns whether or not this component should be given focus on mouse click.
  37.383 -     * Default implementation return whether or not this peer is "focusable"
  37.384 -     * Descendants might want to override it to extend/restrict conditions at which this
  37.385 -     * component should be focused by click (see MCanvasPeer and MPanelPeer)
  37.386 -     */
  37.387 -    protected boolean shouldFocusOnClick() {
  37.388 -        return isFocusable();
  37.389 -    }
  37.390 -
  37.391 -    /**
  37.392 -     * Checks whether or not this component would be focused by native system if it would be allowed to do so.
  37.393 -     * Currently it checks that it displayable, visible, enabled and focusable.
  37.394 -     */
  37.395 -    static boolean canBeFocusedByClick(Component component) {
  37.396 -        if (component == null) {
  37.397 -            return false;
  37.398 -        } else {
  37.399 -            return component.isDisplayable() && component.isVisible() && component.isEnabled() && component.isFocusable();
  37.400 -        }
  37.401 -    }
  37.402 -
  37.403 -    static Method requestFocusWithCause;
  37.404 -
  37.405 -    static void callRequestFocusInWindow(Component target, CausedFocusEvent.Cause cause) {
  37.406 -        if (requestFocusWithCause == null) {
  37.407 -            requestFocusWithCause = SunToolkit.getMethod(Component.class, "requestFocusInWindow", new Class[] {CausedFocusEvent.Cause.class});
  37.408 -        }
  37.409 -        if (requestFocusWithCause != null) {
  37.410 -            try {
  37.411 -                requestFocusWithCause.invoke(target, new Object[] {cause});
  37.412 -            } catch (Exception e) {
  37.413 -                e.printStackTrace();
  37.414 -            }
  37.415 -        }
  37.416 -    }
  37.417 -
  37.418 -    public void handleEvent(AWTEvent e) {
  37.419 -        int id = e.getID();
  37.420 -
  37.421 -        switch(id) {
  37.422 -          case PaintEvent.PAINT:
  37.423 -              // Got native painting
  37.424 -              paintPending = false;
  37.425 -              // Fallthrough to next statement
  37.426 -          case PaintEvent.UPDATE:
  37.427 -              // Skip all painting while layouting and all UPDATEs
  37.428 -              // while waiting for native paint
  37.429 -              if (!isLayouting && !paintPending) {
  37.430 -                  paintArea.paint(target,false);
  37.431 -              }
  37.432 -              return;
  37.433 -          case MouseEvent.MOUSE_PRESSED:
  37.434 -              if (target == e.getSource() && !((InputEvent)e).isConsumed() && shouldFocusOnClick()
  37.435 -                  && !target.isFocusOwner() && canBeFocusedByClick(target))
  37.436 -              {
  37.437 -                  callRequestFocusInWindow(target, CausedFocusEvent.Cause.MOUSE_EVENT);
  37.438 -              }
  37.439 -              break;
  37.440 -          default:
  37.441 -              break;
  37.442 -        }
  37.443 -
  37.444 -        // Call the native code
  37.445 -        nativeHandleEvent(e);
  37.446 -    }
  37.447 -
  37.448 -    /* New API for 1.1 */
  37.449 -    public Dimension getMinimumSize() {
  37.450 -        return target.getSize();
  37.451 -    }
  37.452 -
  37.453 -    /* New API for 1.1 */
  37.454 -    public Dimension getPreferredSize() {
  37.455 -        return getMinimumSize();
  37.456 -    }
  37.457 -
  37.458 -    // Do nothing for heavyweight implementation
  37.459 -    public void layout() {}
  37.460 -
  37.461 -    public Rectangle getBounds() {
  37.462 -        return ((Component)target).getBounds();
  37.463 -    }
  37.464 -
  37.465 -    public Object getTarget() {
  37.466 -        return target;
  37.467 -    }
  37.468 -
  37.469 -    public java.awt.Toolkit getToolkit() {
  37.470 -        // XXX: bogus
  37.471 -        return Toolkit.getDefaultToolkit();
  37.472 -    }
  37.473 -
  37.474 -    // fallback default font object
  37.475 -    final static Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
  37.476 -
  37.477 -    public synchronized Graphics getGraphics() {
  37.478 -        if (!disposed) {
  37.479 -            Component target = (Component) this.target;
  37.480 -
  37.481 -            /* Fix for bug 4746122. Color and Font shouldn't be null */
  37.482 -            Color bgColor = target.getBackground();
  37.483 -            if (bgColor == null) {
  37.484 -                bgColor = SystemColor.window;
  37.485 -            }
  37.486 -            Color fgColor = target.getForeground();
  37.487 -            if (fgColor == null) {
  37.488 -                fgColor = SystemColor.windowText;
  37.489 -            }
  37.490 -            Font font = target.getFont();
  37.491 -            if (font == null) {
  37.492 -                font = defaultFont;
  37.493 -            }
  37.494 -            return new SunGraphics2D(surfaceData, fgColor, bgColor, font);
  37.495 -        }
  37.496 -
  37.497 -        return null;
  37.498 -    }
  37.499 -
  37.500 -    public Image createImage(ImageProducer producer) {
  37.501 -        return new ToolkitImage(producer);
  37.502 -    }
  37.503 -
  37.504 -    public Image createImage(int width, int height) {
  37.505 -        return graphicsConfig.createAcceleratedImage(target, width, height);
  37.506 -    }
  37.507 -
  37.508 -    public VolatileImage createVolatileImage(int width, int height) {
  37.509 -        return new SunVolatileImage(target, width, height);
  37.510 -    }
  37.511 -
  37.512 -    public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
  37.513 -        return getToolkit().prepareImage(img, w, h, o);
  37.514 -    }
  37.515 -
  37.516 -    public int checkImage(Image img, int w, int h, ImageObserver o) {
  37.517 -        return getToolkit().checkImage(img, w, h, o);
  37.518 -    }
  37.519 -
  37.520 -    public FontMetrics getFontMetrics(Font font) {
  37.521 -        return X11FontMetrics.getFontMetrics(font);
  37.522 -    }
  37.523 -
  37.524 -    /*
  37.525 -     * Subclasses should override disposeImpl() instead of dispose(). Client
  37.526 -     * code should always invoke dispose(), never disposeImpl().
  37.527 -     */
  37.528 -    protected void disposeImpl() {
  37.529 -        SurfaceData oldData = surfaceData;
  37.530 -        surfaceData = null;
  37.531 -        oldData.invalidate();
  37.532 -        MToolkit.targetDisposedPeer(target, this);
  37.533 -        pDispose();
  37.534 -    }
  37.535 -    public final void dispose() {
  37.536 -        boolean call_disposeImpl = false;
  37.537 -
  37.538 -        if (!disposed) {
  37.539 -            synchronized (this) {
  37.540 -                SunToolkit.awtLock();
  37.541 -                try {
  37.542 -                    if (!disposed) {
  37.543 -                        disposed = call_disposeImpl = true;
  37.544 -                    }
  37.545 -                } finally {
  37.546 -                    SunToolkit.awtUnlock();
  37.547 -                }
  37.548 -            }
  37.549 -        }
  37.550 -
  37.551 -        if (call_disposeImpl) {
  37.552 -            disposeImpl();
  37.553 -        }
  37.554 -    }
  37.555 -
  37.556 -    native static boolean processSynchronousLightweightTransfer(Component heavyweight, Component descendant,
  37.557 -                                                                boolean temporary, boolean focusedWindowChangeAllowed,
  37.558 -                                                                long time);
  37.559 -    public boolean requestFocus
  37.560 -    (Component lightweightChild, boolean temporary,
  37.561 -         boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause) {
  37.562 -        if (processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
  37.563 -                                                  focusedWindowChangeAllowed, time)) {
  37.564 -            return true;
  37.565 -        } else {
  37.566 -            if (focusLog.isLoggable(Level.FINER)) {
  37.567 -                focusLog.log(Level.FINER, "Current native focused window " + getNativeFocusedWindow());
  37.568 -            }
  37.569 -            /**
  37.570 -             * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
  37.571 -             * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
  37.572 -             * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
  37.573 -             * in requests list - and it breaks our requests sequence as first record on WGF should be the last focus
  37.574 -             * owner which had focus before WLF. So, we should not add request record for such requests
  37.575 -             * but store this component in mostRecent - and return true as before for compatibility.
  37.576 -             */
  37.577 -            Container parent = (target instanceof Container) ? ((Container)target) : (target.getParent());
  37.578 -            // Search for parent window
  37.579 -            while (parent != null && !(parent instanceof Window)) {
  37.580 -                parent = getParent_NoClientCode(parent);
  37.581 -            }
  37.582 -            if (parent != null) {
  37.583 -                Window parentWindow = (Window)parent;
  37.584 -                // and check that it is focused
  37.585 -                if (focusLog.isLoggable(Level.FINER)) {
  37.586 -                    focusLog.log(Level.FINER, "Parent window " + parentWindow);
  37.587 -                }
  37.588 -                if (!parentWindow.isFocused() && getNativeFocusedWindow() == parentWindow) {
  37.589 -                    // if it is not - skip requesting focus on Solaris
  37.590 -                    // but return true for compatibility.
  37.591 -                    return true;
  37.592 -                } else if (getNativeFocusedWindow() != parentWindow) {
  37.593 -                    WindowPeer wpeer = (WindowPeer)parentWindow.getPeer();
  37.594 -                    boolean res = wpeer.requestWindowFocus();
  37.595 -                    if (focusLog.isLoggable(Level.FINER)) {
  37.596 -                        focusLog.log(Level.FINER, "Requested window focus: " + res);
  37.597 -                    }
  37.598 -                    // If parent window can be made focused and has been made focused(synchronously)
  37.599 -                    // then we can proceed with children, otherwise we retreat.
  37.600 -                    if (!(res && parentWindow.isFocused())) {
  37.601 -                        focusLog.finer("Waiting for asynchronous processing of window focus request");
  37.602 -                        KeyboardFocusManagerPeerImpl.removeLastFocusRequest(target);
  37.603 -                        return false;
  37.604 -                    }
  37.605 -                }
  37.606 -            }
  37.607 -            return _requestFocus(lightweightChild, temporary, focusedWindowChangeAllowed, time, cause);
  37.608 -        }
  37.609 -    }
  37.610 -
  37.611 -    native boolean _requestFocus
  37.612 -        (Component lightweightChild, boolean temporary,
  37.613 -         boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause);
  37.614 -
  37.615 -    static native Window getNativeFocusedWindow();
  37.616 -
  37.617 -    /*
  37.618 -     * Post an event to the event queue.
  37.619 -     */
  37.620 -    // NOTE: This method may be called by privileged threads.
  37.621 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  37.622 -    void postEvent(AWTEvent event) {
  37.623 -        MToolkit.postEvent(MToolkit.targetToAppContext(target), event);
  37.624 -    }
  37.625 -
  37.626 -    /* Callbacks for window-system events to the frame
  37.627 -     *
  37.628 -     * NOTE: This method may be called by privileged threads.
  37.629 -     *       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  37.630 -     */
  37.631 -    void handleExpose(int x, int y, int w, int h) {
  37.632 -        if ( !ComponentAccessor.getIgnoreRepaint(target) ) {
  37.633 -            postEvent(new PaintEvent(target, PaintEvent.PAINT,
  37.634 -                                     new Rectangle(x, y, w, h)));
  37.635 -        }
  37.636 -    }
  37.637 -
  37.638 -    /* Callbacks for window-system events to the frame
  37.639 -     *
  37.640 -     * NOTE: This method may be called by privileged threads.
  37.641 -     *       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  37.642 -     */
  37.643 -    void handleRepaint(int x, int y, int w, int h) {
  37.644 -        if ( !ComponentAccessor.getIgnoreRepaint(target) ) {
  37.645 -            postEvent(new PaintEvent(target, PaintEvent.UPDATE,
  37.646 -                                     new Rectangle(x, y, w, h)));
  37.647 -        }
  37.648 -    }
  37.649 -
  37.650 -    /* Return the component's z-order position relative to
  37.651 -     * other peer'd siblings (don't count lightweight siblings
  37.652 -     * or siblings who don't yet have valid peers).
  37.653 -     *
  37.654 -     * NOTE: This method may be called by privileged threads.
  37.655 -     *       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  37.656 -     */
  37.657 -    public int getZOrderPosition_NoClientCode() {
  37.658 -        // SECURITY: use _NoClientCode() methods, because we may
  37.659 -        //           be running on a privileged thread
  37.660 -        Container p = getParent_NoClientCode(target);
  37.661 -        if (p != null) {
  37.662 -            // SECURITY: use _NoClientCode() methods, because we may
  37.663 -            //           be running on a privileged thread
  37.664 -            Component children[] = getComponents_NoClientCode(p);
  37.665 -            int i;
  37.666 -            int index = 0;
  37.667 -            for (i = 0; i < children.length; i++) {
  37.668 -                if (children[i] == target) {
  37.669 -                    return index;
  37.670 -                } else {
  37.671 -                    Object cpeer = MToolkit.targetToPeer(children[i]);
  37.672 -                    if (cpeer != null &&
  37.673 -                        !(cpeer instanceof java.awt.peer.LightweightPeer)) {
  37.674 -                        index++;
  37.675 -                    }
  37.676 -                }
  37.677 -            }
  37.678 -        }
  37.679 -        return -1;
  37.680 -    }
  37.681 -
  37.682 -    /*
  37.683 -     * drawXXX() methods are used to print the native components by
  37.684 -     * rendering the Motif look ourselves.
  37.685 -     * ToDo(aim): needs to query native motif for more accurate color
  37.686 -     * information.
  37.687 -     */
  37.688 -    void draw3DOval(Graphics g, Color bg,
  37.689 -                    int x, int y, int w, int h, boolean raised) {
  37.690 -        Color c = g.getColor();
  37.691 -        Color shadow = bg.darker();
  37.692 -        Color highlight = bg.brighter();
  37.693 -
  37.694 -        g.setColor(raised ? highlight : shadow);
  37.695 -        g.drawArc(x, y, w, h, 45, 180);
  37.696 -        g.setColor(raised ? shadow : highlight);
  37.697 -        g.drawArc(x, y, w, h, 225, 180);
  37.698 -        g.setColor(c);
  37.699 -    }
  37.700 -    void draw3DRect(Graphics g, Color bg,
  37.701 -                    int x, int y, int width, int height,
  37.702 -                    boolean raised) {
  37.703 -        Color c = g.getColor();
  37.704 -        Color shadow = bg.darker();
  37.705 -        Color highlight = bg.brighter();
  37.706 -
  37.707 -        g.setColor(raised ? highlight : shadow);
  37.708 -        g.drawLine(x, y, x, y + height);
  37.709 -        g.drawLine(x + 1, y, x + width - 1, y);
  37.710 -        g.setColor(raised ? shadow : highlight);
  37.711 -        g.drawLine(x + 1, y + height, x + width, y + height);
  37.712 -        g.drawLine(x + width, y, x + width, y + height - 1);
  37.713 -        g.setColor(c);
  37.714 -    }
  37.715 -    void drawScrollbar(Graphics g, Color bg, int thickness, int length,
  37.716 -                       int min, int max, int val, int vis, boolean horizontal) {
  37.717 -        Color c = g.getColor();
  37.718 -        double f = (double)(length - 2*(thickness-1)) / Math.max(1, ((max - min) + vis));
  37.719 -        int v1 = thickness + (int)(f * (val - min));
  37.720 -        int v2 = (int)(f * vis);
  37.721 -        int w2 = thickness-4;
  37.722 -        int tpts_x[] = new int[3];
  37.723 -        int tpts_y[] = new int[3];
  37.724 -
  37.725 -        if (length < 3*w2 ) {
  37.726 -            v1 = v2 = 0;
  37.727 -            if (length < 2*w2 + 2) {
  37.728 -                w2 = (length-2)/2;
  37.729 -            }
  37.730 -        } else  if (v2 < 7) {
  37.731 -            // enforce a minimum handle size
  37.732 -            v1 = Math.max(0, v1 - ((7 - v2)>>1));
  37.733 -            v2 = 7;
  37.734 -        }
  37.735 -
  37.736 -        int ctr   = thickness/2;
  37.737 -        int sbmin = ctr - w2/2;
  37.738 -        int sbmax = ctr + w2/2;
  37.739 -
  37.740 -        // paint the background slightly darker
  37.741 -        {
  37.742 -            Color d = new Color((int) (bg.getRed()   * 0.85),
  37.743 -                                (int) (bg.getGreen() * 0.85),
  37.744 -                                (int) (bg.getBlue()  * 0.85));
  37.745 -
  37.746 -            g.setColor(d);
  37.747 -            if (horizontal) {
  37.748 -                g.fillRect(0, 0, length, thickness);
  37.749 -            } else {
  37.750 -                g.fillRect(0, 0, thickness, length);
  37.751 -            }
  37.752 -        }
  37.753 -
  37.754 -        // paint the thumb and arrows in the normal background color
  37.755 -        g.setColor(bg);
  37.756 -        if (v1 > 0) {
  37.757 -            if (horizontal) {
  37.758 -                g.fillRect(v1, 3, v2, thickness-3);
  37.759 -            } else {
  37.760 -                g.fillRect(3, v1, thickness-3, v2);
  37.761 -            }
  37.762 -        }
  37.763 -
  37.764 -        tpts_x[0] = ctr;        tpts_y[0] = 2;
  37.765 -        tpts_x[1] = sbmin;      tpts_y[1] = w2;
  37.766 -        tpts_x[2] = sbmax;      tpts_y[2] = w2;
  37.767 -        if (horizontal) {
  37.768 -            g.fillPolygon(tpts_y, tpts_x, 3);
  37.769 -        } else {
  37.770 -            g.fillPolygon(tpts_x, tpts_y, 3);
  37.771 -        }
  37.772 -
  37.773 -        tpts_y[0] = length-2;
  37.774 -        tpts_y[1] = length-w2;
  37.775 -        tpts_y[2] = length-w2;
  37.776 -        if (horizontal) {
  37.777 -            g.fillPolygon(tpts_y, tpts_x, 3);
  37.778 -        } else {
  37.779 -            g.fillPolygon(tpts_x, tpts_y, 3);
  37.780 -        }
  37.781 -
  37.782 -        Color highlight = bg.brighter();
  37.783 -
  37.784 -        // // // // draw the "highlighted" edges
  37.785 -        g.setColor(highlight);
  37.786 -
  37.787 -        // outline & arrows
  37.788 -        if (horizontal) {
  37.789 -            g.drawLine(1, thickness, length - 1, thickness);
  37.790 -            g.drawLine(length - 1, 1, length - 1, thickness);
  37.791 -
  37.792 -            // arrows
  37.793 -            g.drawLine(1, ctr, w2, sbmin);
  37.794 -            g.drawLine(length - w2, sbmin, length - w2, sbmax);
  37.795 -            g.drawLine(length - w2, sbmin, length - 2, ctr);
  37.796 -
  37.797 -        } else {
  37.798 -            g.drawLine(thickness, 1, thickness, length - 1);
  37.799 -            g.drawLine(1, length - 1, thickness, length - 1);
  37.800 -
  37.801 -            // arrows
  37.802 -            g.drawLine(ctr, 1, sbmin, w2);
  37.803 -            g.drawLine(sbmin, length - w2, sbmax, length - w2);
  37.804 -            g.drawLine(sbmin, length - w2, ctr, length - 2);
  37.805 -        }
  37.806 -
  37.807 -        // thumb
  37.808 -        if (v1 > 0) {
  37.809 -            if (horizontal) {
  37.810 -                g.drawLine(v1, 2, v1 + v2, 2);
  37.811 -                g.drawLine(v1, 2, v1, thickness-3);
  37.812 -            } else {
  37.813 -                g.drawLine(2, v1, 2, v1 + v2);
  37.814 -                g.drawLine(2, v1, thickness-3, v1);
  37.815 -            }
  37.816 -        }
  37.817 -
  37.818 -        Color shadow = bg.darker();
  37.819 -
  37.820 -        // // // // draw the "shadowed" edges
  37.821 -        g.setColor(shadow);
  37.822 -
  37.823 -        // outline && arrows
  37.824 -        if (horizontal) {
  37.825 -            g.drawLine(0, 0, 0, thickness);
  37.826 -            g.drawLine(0, 0, length - 1, 0);
  37.827 -
  37.828 -            // arrows
  37.829 -            g.drawLine(w2, sbmin, w2, sbmax);
  37.830 -            g.drawLine(w2, sbmax, 1, ctr);
  37.831 -            g.drawLine(length-2, ctr, length-w2, sbmax);
  37.832 -
  37.833 -        } else {
  37.834 -            g.drawLine(0, 0, thickness, 0);
  37.835 -            g.drawLine(0, 0, 0, length - 1);
  37.836 -
  37.837 -            // arrows
  37.838 -            g.drawLine(sbmin, w2, sbmax, w2);
  37.839 -            g.drawLine(sbmax, w2, ctr, 1);
  37.840 -            g.drawLine(ctr, length-2, sbmax, length-w2);
  37.841 -        }
  37.842 -
  37.843 -        // thumb
  37.844 -        if (v1 > 0) {
  37.845 -            if (horizontal) {
  37.846 -                g.drawLine(v1 + v2, 2, v1 + v2, thickness-2);
  37.847 -                g.drawLine(v1, thickness-2, v1 + v2, thickness-2);
  37.848 -            } else {
  37.849 -                g.drawLine(2, v1 + v2, thickness-2, v1 + v2);
  37.850 -                g.drawLine(thickness-2, v1, thickness-2, v1 + v2);
  37.851 -            }
  37.852 -        }
  37.853 -        g.setColor(c);
  37.854 -    }
  37.855 -
  37.856 -    public String toString() {
  37.857 -        return getClass().getName() + "[" + target + "]";
  37.858 -    }
  37.859 -
  37.860 -    /* New 1.1 API */
  37.861 -    public void setVisible(boolean b) {
  37.862 -        if (b) {
  37.863 -            Dimension s = target.getSize();
  37.864 -            oldWidth = s.width;
  37.865 -            oldHeight = s.height;
  37.866 -            pShow();
  37.867 -        } else {
  37.868 -            pHide();
  37.869 -        }
  37.870 -    }
  37.871 -
  37.872 -    /* New 1.1 API */
  37.873 -    public void setEnabled(boolean b) {
  37.874 -        if (b) {
  37.875 -            pEnable();
  37.876 -        } else {
  37.877 -            pDisable();
  37.878 -        }
  37.879 -    }
  37.880 -
  37.881 -    /* New 1.1 API */
  37.882 -    public Point getLocationOnScreen() {
  37.883 -        synchronized (target.getTreeLock()) {
  37.884 -            Component comp = target;
  37.885 -            while (comp != null && !(comp instanceof Window)) {
  37.886 -                comp = getParent_NoClientCode(comp);
  37.887 -            }
  37.888 -
  37.889 -            // applets, embedded, etc - translate directly
  37.890 -            if (comp == null || comp instanceof sun.awt.EmbeddedFrame) {
  37.891 -                return pGetLocationOnScreen();
  37.892 -            }
  37.893 -
  37.894 -            MWindowPeer wpeer = (MWindowPeer)(MToolkit.targetToPeer(comp));
  37.895 -            if (wpeer == null) {
  37.896 -                return pGetLocationOnScreen();
  37.897 -            }
  37.898 -            return pGetLocationOnScreen2((Window)comp, wpeer);
  37.899 -        }
  37.900 -    }
  37.901 -
  37.902 -    public int serialNum = 0;
  37.903 -
  37.904 -    /* Returns the native paint should be posted after setting new size
  37.905 -     */
  37.906 -    public boolean checkNativePaintOnSetBounds(int width, int height) {
  37.907 -        return (width != oldWidth) || (height != oldHeight);
  37.908 -    }
  37.909 -
  37.910 -    void setBounds(int x, int y, int width, int height) {
  37.911 -        setBounds(x, y, width, height, SET_BOUNDS);
  37.912 -    }
  37.913 -
  37.914 -    /* New 1.1 API */
  37.915 -    public void setBounds(int x, int y, int width, int height, int op) {
  37.916 -        if (disposed) return;
  37.917 -
  37.918 -        Container parent = getParent_NoClientCode(target);
  37.919 -
  37.920 -        // Should set paintPending before reshape to prevent
  37.921 -        // thread race between PaintEvent and setBounds
  37.922 -        // This part of the 4267393 fix proved to be unstable under solaris,
  37.923 -        // dissabled due to regressions 4418155, 4486762, 4490079
  37.924 -        paintPending = false; //checkNativePaintOnSetBounds(width, height);
  37.925 -
  37.926 -        // Note: it would be ideal to NOT execute this if it's
  37.927 -        // merely a Move which is occurring.
  37.928 -        if (parent != null && parent instanceof ScrollPane) {
  37.929 -            MScrollPanePeer speer = (MScrollPanePeer)parent.getPeer();
  37.930 -            if (!speer.ignore) {
  37.931 -                pReshape(x, y, width, height);
  37.932 -                speer.childResized(width, height);
  37.933 -            }
  37.934 -        } else {
  37.935 -            pReshape(x, y, width, height);
  37.936 -        }
  37.937 -
  37.938 -        if ((width != oldWidth) || (height != oldHeight)) {
  37.939 -            SurfaceData oldData = surfaceData;
  37.940 -            if (oldData != null) {
  37.941 -                surfaceData = graphicsConfig.createSurfaceData(this);
  37.942 -                oldData.invalidate();
  37.943 -            }
  37.944 -            oldWidth = width;
  37.945 -            oldHeight = height;
  37.946 -        }
  37.947 -        validateSurface(width, height);
  37.948 -        serialNum++;
  37.949 -    }
  37.950 -
  37.951 -    void validateSurface(int width, int height) {
  37.952 -        SunToolkit.awtLock();
  37.953 -        try {
  37.954 -            if (!disposed && (width != oldWidth || height != oldHeight)) {
  37.955 -                SurfaceData oldData = surfaceData;
  37.956 -                if (oldData != null) {
  37.957 -                    surfaceData = graphicsConfig.createSurfaceData(this);
  37.958 -                    oldData.invalidate();
  37.959 -                }
  37.960 -                oldWidth = width;
  37.961 -                oldHeight = height;
  37.962 -            }
  37.963 -        } finally {
  37.964 -            SunToolkit.awtUnlock();
  37.965 -        }
  37.966 -    }
  37.967 -
  37.968 -    public void beginValidate() {
  37.969 -    }
  37.970 -
  37.971 -    native void restoreFocus();
  37.972 -
  37.973 -    public void endValidate() {
  37.974 -        restoreFocus();
  37.975 -    }
  37.976 -
  37.977 -    public void beginLayout() {
  37.978 -        // Skip all painting till endLayout
  37.979 -        isLayouting = true;
  37.980 -    }
  37.981 -
  37.982 -    public void endLayout() {
  37.983 -        if (!paintPending && !paintArea.isEmpty() &&
  37.984 -            !((Component)target).getIgnoreRepaint()) {
  37.985 -            // if not waiting for native painting repaint damaged area
  37.986 -            postEvent(new PaintEvent((Component)target, PaintEvent.PAINT,
  37.987 -                                     new Rectangle()));
  37.988 -        }
  37.989 -        isLayouting = false;
  37.990 -    }
  37.991 -
  37.992 -    /**
  37.993 -     * DEPRECATED:  Replaced by setVisible(boolean).
  37.994 -     */
  37.995 -    public void show() {
  37.996 -        setVisible(true);
  37.997 -    }
  37.998 -
  37.999 -    /**
 37.1000 -     * DEPRECATED:  Replaced by setVisible(boolean).
 37.1001 -     */
 37.1002 -    public void hide() {
 37.1003 -        setVisible(false);
 37.1004 -    }
 37.1005 -
 37.1006 -    /**
 37.1007 -     * DEPRECATED:  Replaced by setEnabled(boolean).
 37.1008 -     */
 37.1009 -    public void enable() {
 37.1010 -        setEnabled(true);
 37.1011 -    }
 37.1012 -
 37.1013 -    /**
 37.1014 -     * DEPRECATED:  Replaced by setEnabled(boolean).
 37.1015 -     */
 37.1016 -    public void disable() {
 37.1017 -        setEnabled(false);
 37.1018 -    }
 37.1019 -
 37.1020 -    /**
 37.1021 -     * DEPRECATED:  Replaced by setBounds(int, int, int, int).
 37.1022 -     */
 37.1023 -    public void reshape(int x, int y, int width, int height) {
 37.1024 -        setBounds(x, y, width, height);
 37.1025 -    }
 37.1026 -
 37.1027 -    /**
 37.1028 -     * DEPRECATED:  Replaced by getMinimumSize().
 37.1029 -     */
 37.1030 -    public Dimension minimumSize() {
 37.1031 -        return getMinimumSize();
 37.1032 -    }
 37.1033 -
 37.1034 -    /**
 37.1035 -     * DEPRECATED:  Replaced by getPreferredSize().
 37.1036 -     */
 37.1037 -    public Dimension preferredSize() {
 37.1038 -        return getPreferredSize();
 37.1039 -    }
 37.1040 -
 37.1041 -    /**
 37.1042 -     *
 37.1043 -     */
 37.1044 -
 37.1045 -    public void addDropTarget(DropTarget dt) {
 37.1046 -        if (MToolkit.useMotifDnD()) {
 37.1047 -            addNativeDropTarget(dt);
 37.1048 -        } else {
 37.1049 -            Component comp = target;
 37.1050 -            while(!(comp == null || comp instanceof java.awt.Window)) {
 37.1051 -                comp = getParent_NoClientCode(comp);
 37.1052 -            }
 37.1053 -
 37.1054 -            if (comp instanceof Window) {
 37.1055 -                MWindowPeer wpeer = (MWindowPeer)(comp.getPeer());
 37.1056 -                if (wpeer != null) {
 37.1057 -                    wpeer.addDropTarget();
 37.1058 -                }
 37.1059 -            }
 37.1060 -        }
 37.1061 -    }
 37.1062 -
 37.1063 -    /**
 37.1064 -     *
 37.1065 -     */
 37.1066 -
 37.1067 -    public void removeDropTarget(DropTarget dt) {
 37.1068 -        if (MToolkit.useMotifDnD()) {
 37.1069 -            removeNativeDropTarget(dt);
 37.1070 -        } else {
 37.1071 -            Component comp = target;
 37.1072 -            while(!(comp == null || comp instanceof java.awt.Window)) {
 37.1073 -                comp = getParent_NoClientCode(comp);
 37.1074 -            }
 37.1075 -
 37.1076 -            if (comp instanceof Window) {
 37.1077 -                MWindowPeer wpeer = (MWindowPeer)(comp.getPeer());
 37.1078 -                if (wpeer != null) {
 37.1079 -                    wpeer.removeDropTarget();
 37.1080 -                }
 37.1081 -            }
 37.1082 -        }
 37.1083 -    }
 37.1084 -
 37.1085 -    public void notifyTextComponentChange(boolean add){
 37.1086 -        Container parent = getParent_NoClientCode(target);
 37.1087 -        while(!(parent == null ||
 37.1088 -                parent instanceof java.awt.Frame ||
 37.1089 -                parent instanceof java.awt.Dialog)) {
 37.1090 -            parent = getParent_NoClientCode(parent);
 37.1091 -        }
 37.1092 -
 37.1093 -        if (parent instanceof java.awt.Frame ||
 37.1094 -            parent instanceof java.awt.Dialog) {
 37.1095 -            if (add)
 37.1096 -                ((MInputMethodControl)parent.getPeer()).addTextComponent((MComponentPeer)this);
 37.1097 -            else
 37.1098 -                ((MInputMethodControl)parent.getPeer()).removeTextComponent((MComponentPeer)this);
 37.1099 -        }
 37.1100 -    }
 37.1101 -
 37.1102 -    native void addNativeDropTarget(DropTarget dt);
 37.1103 -
 37.1104 -    native void removeNativeDropTarget(DropTarget dt);
 37.1105 -
 37.1106 -    public GraphicsConfiguration getGraphicsConfiguration() {
 37.1107 -        GraphicsConfiguration ret = graphicsConfig;
 37.1108 -        if (ret == null) {
 37.1109 -            ret = target.getGraphicsConfiguration();
 37.1110 -        }
 37.1111 -        return ret;
 37.1112 -    }
 37.1113 -
 37.1114 -    // Returns true if we are inside begin/endLayout and
 37.1115 -    // are waiting for native painting
 37.1116 -    public boolean isPaintPending() {
 37.1117 -        return paintPending && isLayouting;
 37.1118 -    }
 37.1119 -
 37.1120 -    public boolean handlesWheelScrolling() {
 37.1121 -        return false;
 37.1122 -    }
 37.1123 -
 37.1124 -    /**
 37.1125 -     * The following multibuffering-related methods delegate to our
 37.1126 -     * associated GraphicsConfig (X11 or GLX) to handle the appropriate
 37.1127 -     * native windowing system specific actions.
 37.1128 -     */
 37.1129 -
 37.1130 -    private native long getWindow(long pData);
 37.1131 -
 37.1132 -    public long getContentWindow() {
 37.1133 -        return getWindow(pData);
 37.1134 -    }
 37.1135 -
 37.1136 -    public void createBuffers(int numBuffers, BufferCapabilities caps)
 37.1137 -      throws AWTException
 37.1138 -    {
 37.1139 -        backBuffer = graphicsConfig.createBackBuffer(this, numBuffers, caps);
 37.1140 -        xBackBuffer = graphicsConfig.createBackBufferImage(target,
 37.1141 -                                                           backBuffer);
 37.1142 -    }
 37.1143 -
 37.1144 -    public void flip(int x1, int y1, int x2, int y2,
 37.1145 -                     BufferCapabilities.FlipContents flipAction)
 37.1146 -    {
 37.1147 -        if (backBuffer == 0) {
 37.1148 -            throw new IllegalStateException("Buffers have not been created");
 37.1149 -        }
 37.1150 -        graphicsConfig.flip(this, target, xBackBuffer,
 37.1151 -                            x1, y1, x2, y2, flipAction);
 37.1152 -    }
 37.1153 -
 37.1154 -    public Image getBackBuffer() {
 37.1155 -        if (backBuffer == 0) {
 37.1156 -            throw new IllegalStateException("Buffers have not been created");
 37.1157 -        }
 37.1158 -        return xBackBuffer;
 37.1159 -    }
 37.1160 -
 37.1161 -    public void destroyBuffers() {
 37.1162 -        graphicsConfig.destroyBackBuffer(backBuffer);
 37.1163 -        backBuffer = 0;
 37.1164 -        xBackBuffer = null;
 37.1165 -    }
 37.1166 -
 37.1167 -    /**
 37.1168 -     * @see java.awt.peer.ComponentPeer#isReparentSupported
 37.1169 -     */
 37.1170 -    public boolean isReparentSupported() {
 37.1171 -        return false;
 37.1172 -    }
 37.1173 -
 37.1174 -    /**
 37.1175 -     * @see java.awt.peer.ComponentPeer#reparent
 37.1176 -     */
 37.1177 -    public void reparent(ContainerPeer newNativeParent) {
 37.1178 -        throw new UnsupportedOperationException();
 37.1179 -    }
 37.1180 -
 37.1181 -    /**
 37.1182 -     * Applies the shape to the native component window.
 37.1183 -     * @since 1.7
 37.1184 -     */
 37.1185 -    public void applyShape(Region shape) {
 37.1186 -    }
 37.1187 -
 37.1188 -}
    38.1 --- a/src/solaris/classes/sun/awt/motif/MCustomCursor.java	Wed Sep 17 13:45:37 2008 -0700
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,68 +0,0 @@
    38.4 -/*
    38.5 - * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
    38.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.7 - *
    38.8 - * This code is free software; you can redistribute it and/or modify it
    38.9 - * under the terms of the GNU General Public License version 2 only, as
   38.10 - * published by the Free Software Foundation.  Sun designates this
   38.11 - * particular file as subject to the "Classpath" exception as provided
   38.12 - * by Sun in the LICENSE file that accompanied this code.
   38.13 - *
   38.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   38.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   38.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   38.17 - * version 2 for more details (a copy is included in the LICENSE file that
   38.18 - * accompanied this code).
   38.19 - *
   38.20 - * You should have received a copy of the GNU General Public License version
   38.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   38.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   38.23 - *
   38.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   38.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   38.26 - * have any questions.
   38.27 - */
   38.28 -
   38.29 -package sun.awt.motif;
   38.30 -
   38.31 -import sun.awt.X11CustomCursor;
   38.32 -import sun.awt.CustomCursor;
   38.33 -import java.awt.*;
   38.34 -import java.awt.image.*;
   38.35 -import sun.awt.image.ImageRepresentation;
   38.36 -
   38.37 -public class MCustomCursor extends X11CustomCursor {
   38.38 -
   38.39 -    public MCustomCursor(Image cursor, Point hotSpot, String name)
   38.40 -            throws IndexOutOfBoundsException {
   38.41 -        super(cursor, hotSpot, name);
   38.42 -    }
   38.43 -    /**
   38.44 -     * Returns the supported cursor size
   38.45 -     */
   38.46 -    public static Dimension getBestCursorSize(
   38.47 -        int preferredWidth, int preferredHeight) {
   38.48 -
   38.49 -        // Fix for bug 4212593 The Toolkit.createCustomCursor does not
   38.50 -        //                     check absence of the image of cursor
   38.51 -        // We use XQueryBestCursor which accepts unsigned ints to obtain
   38.52 -        // the largest cursor size that could be dislpayed
   38.53 -        Dimension d = new Dimension(Math.abs(preferredWidth), Math.abs(preferredHeight));
   38.54 -
   38.55 -        queryBestCursor(d);
   38.56 -        return d;
   38.57 -    }
   38.58 -
   38.59 -    private static native void queryBestCursor(Dimension d);
   38.60 -
   38.61 -    protected native void createCursor(byte[] xorMask, byte[] andMask,
   38.62 -                                     int width, int height,
   38.63 -                                     int fcolor, int bcolor,
   38.64 -                                     int xHotSpot, int yHotSpot);
   38.65 -
   38.66 -    static {
   38.67 -        cacheInit();
   38.68 -    }
   38.69 -
   38.70 -    private native static void cacheInit();
   38.71 -}
    39.1 --- a/src/solaris/classes/sun/awt/motif/MDataTransferer.java	Wed Sep 17 13:45:37 2008 -0700
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,386 +0,0 @@
    39.4 -/*
    39.5 - * Copyright 2000-2004 Sun Microsystems, Inc.  All Rights Reserved.
    39.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.7 - *
    39.8 - * This code is free software; you can redistribute it and/or modify it
    39.9 - * under the terms of the GNU General Public License version 2 only, as
   39.10 - * published by the Free Software Foundation.  Sun designates this
   39.11 - * particular file as subject to the "Classpath" exception as provided
   39.12 - * by Sun in the LICENSE file that accompanied this code.
   39.13 - *
   39.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   39.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   39.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   39.17 - * version 2 for more details (a copy is included in the LICENSE file that
   39.18 - * accompanied this code).
   39.19 - *
   39.20 - * You should have received a copy of the GNU General Public License version
   39.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   39.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   39.23 - *
   39.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   39.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   39.26 - * have any questions.
   39.27 - */
   39.28 -
   39.29 -package sun.awt.motif;
   39.30 -
   39.31 -import java.awt.Image;
   39.32 -
   39.33 -import java.awt.datatransfer.DataFlavor;
   39.34 -
   39.35 -import java.awt.image.BufferedImage;
   39.36 -import java.awt.image.ColorModel;
   39.37 -import java.awt.image.WritableRaster;
   39.38 -
   39.39 -import java.io.InputStream;
   39.40 -import java.io.IOException;
   39.41 -
   39.42 -import java.util.ArrayList;
   39.43 -import java.util.Iterator;
   39.44 -import java.util.List;
   39.45 -
   39.46 -import javax.imageio.ImageIO;
   39.47 -import javax.imageio.ImageTypeSpecifier;
   39.48 -import javax.imageio.ImageWriter;
   39.49 -import javax.imageio.spi.ImageWriterSpi;
   39.50 -
   39.51 -import sun.awt.datatransfer.DataTransferer;
   39.52 -import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
   39.53 -
   39.54 -/**
   39.55 - * Platform-specific support for the data transfer subsystem.
   39.56 - *
   39.57 - * @author Roger Brinkley
   39.58 - * @author Danila Sinopalnikov
   39.59 - *
   39.60 - * @since 1.3.1
   39.61 - */
   39.62 -public class MDataTransferer extends DataTransferer {
   39.63 -    private static final long FILE_NAME_ATOM;
   39.64 -    private static final long DT_NET_FILE_ATOM;
   39.65 -    private static final long PNG_ATOM;
   39.66 -    private static final long JFIF_ATOM;
   39.67 -
   39.68 -    static {
   39.69 -        FILE_NAME_ATOM = getAtomForTarget("FILE_NAME");
   39.70 -        DT_NET_FILE_ATOM = getAtomForTarget("_DT_NETFILE");
   39.71 -        PNG_ATOM = getAtomForTarget("PNG");
   39.72 -        JFIF_ATOM = getAtomForTarget("JFIF");
   39.73 -    }
   39.74 -
   39.75 -    /**
   39.76 -     * Singleton constructor
   39.77 -     */
   39.78 -    private MDataTransferer() {
   39.79 -    }
   39.80 -
   39.81 -    private static MDataTransferer transferer;
   39.82 -
   39.83 -    static MDataTransferer getInstanceImpl() {
   39.84 -        if (transferer == null) {
   39.85 -            synchronized (MDataTransferer.class) {
   39.86 -                if (transferer == null) {
   39.87 -                    transferer = new MDataTransferer();
   39.88 -                }
   39.89 -            }
   39.90 -        }
   39.91 -        return transferer;
   39.92 -    }
   39.93 -
   39.94 -    public String getDefaultUnicodeEncoding() {
   39.95 -        return "iso-10646-ucs-2";
   39.96 -    }
   39.97 -
   39.98 -    public boolean isLocaleDependentTextFormat(long format) {
   39.99 -        return false;
  39.100 -    }
  39.101 -
  39.102 -    public boolean isTextFormat(long format) {
  39.103 -        return super.isTextFormat(format)
  39.104 -            || isMimeFormat(format, "text");
  39.105 -    }
  39.106 -
  39.107 -    protected String getCharsetForTextFormat(Long lFormat) {
  39.108 -        long format = lFormat.longValue();
  39.109 -        if (isMimeFormat(format, "text")) {
  39.110 -            String nat = getNativeForFormat(format);
  39.111 -            DataFlavor df = new DataFlavor(nat, null);
  39.112 -            // Ignore the charset parameter of the MIME type if the subtype
  39.113 -            // doesn't support charset.
  39.114 -            if (!DataTransferer.doesSubtypeSupportCharset(df)) {
  39.115 -                return null;
  39.116 -            }
  39.117 -            String charset = df.getParameter("charset");
  39.118 -            if (charset != null) {
  39.119 -                return charset;
  39.120 -            }
  39.121 -        }
  39.122 -        return super.getCharsetForTextFormat(lFormat);
  39.123 -    }
  39.124 -
  39.125 -    public boolean isFileFormat(long format) {
  39.126 -        return format == FILE_NAME_ATOM || format == DT_NET_FILE_ATOM;
  39.127 -    }
  39.128 -
  39.129 -    public boolean isImageFormat(long format) {
  39.130 -        return format == PNG_ATOM || format == JFIF_ATOM
  39.131 -            || isMimeFormat(format, "image");
  39.132 -    }
  39.133 -
  39.134 -    protected Long getFormatForNativeAsLong(String str) {
  39.135 -        // Just get the atom. If it has already been retrived
  39.136 -        // once, we'll get a copy so this should be very fast.
  39.137 -        long atom = getAtomForTarget(str);
  39.138 -        if (atom <= 0) {
  39.139 -            throw new InternalError("Cannot register a target");
  39.140 -        }
  39.141 -        return Long.valueOf(atom);
  39.142 -    }
  39.143 -
  39.144 -    protected String getNativeForFormat(long format) {
  39.145 -        return getTargetNameForAtom(format);
  39.146 -    }
  39.147 -
  39.148 -    public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() {
  39.149 -        return MToolkitThreadBlockedHandler.getToolkitThreadBlockedHandler();
  39.150 -    }
  39.151 -
  39.152 -    /**
  39.153 -     * Gets an atom for a format name.
  39.154 -     */
  39.155 -    static native long getAtomForTarget(String name);
  39.156 -
  39.157 -    /**
  39.158 -     * Gets an format name for a given format (atom)
  39.159 -     */
  39.160 -    private static native String getTargetNameForAtom(long atom);
  39.161 -
  39.162 -    protected byte[] imageToPlatformBytes(Image image, long format)
  39.163 -      throws IOException {
  39.164 -        String mimeType = null;
  39.165 -        if (format == PNG_ATOM) {
  39.166 -            mimeType = "image/png";
  39.167 -        } else if (format == JFIF_ATOM) {
  39.168 -            mimeType = "image/jpeg";
  39.169 -        } else {
  39.170 -            // Check if an image MIME format.
  39.171 -            try {
  39.172 -                String nat = getNativeForFormat(format);
  39.173 -                DataFlavor df = new DataFlavor(nat);
  39.174 -                String primaryType = df.getPrimaryType();
  39.175 -                if ("image".equals(primaryType)) {
  39.176 -                    mimeType = df.getPrimaryType() + "/" + df.getSubType();
  39.177 -                }
  39.178 -            } catch (Exception e) {
  39.179 -                // Not an image MIME format.
  39.180 -            }
  39.181 -        }
  39.182 -        if (mimeType != null) {
  39.183 -            return imageToStandardBytes(image, mimeType);
  39.184 -        } else {
  39.185 -            String nativeFormat = getNativeForFormat(format);
  39.186 -            throw new IOException("Translation to " + nativeFormat +
  39.187 -                                  " is not supported.");
  39.188 -        }
  39.189 -    }
  39.190 -
  39.191 -    /**
  39.192 -     * Translates either a byte array or an input stream which contain
  39.193 -     * platform-specific image data in the given format into an Image.
  39.194 -     */
  39.195 -    protected Image platformImageBytesOrStreamToImage(InputStream inputStream,
  39.196 -                                                      byte[] bytes,
  39.197 -                                                      long format)
  39.198 -      throws IOException {
  39.199 -        String mimeType = null;
  39.200 -        if (format == PNG_ATOM) {
  39.201 -            mimeType = "image/png";
  39.202 -        } else if (format == JFIF_ATOM) {
  39.203 -            mimeType = "image/jpeg";
  39.204 -        } else {
  39.205 -            // Check if an image MIME format.
  39.206 -            try {
  39.207 -                String nat = getNativeForFormat(format);
  39.208 -                DataFlavor df = new DataFlavor(nat);
  39.209 -                String primaryType = df.getPrimaryType();
  39.210 -                if ("image".equals(primaryType)) {
  39.211 -                    mimeType = df.getPrimaryType() + "/" + df.getSubType();
  39.212 -                }
  39.213 -            } catch (Exception e) {
  39.214 -                // Not an image MIME format.
  39.215 -            }
  39.216 -        }
  39.217 -        if (mimeType != null) {
  39.218 -            return standardImageBytesOrStreamToImage(inputStream, bytes, mimeType);
  39.219 -        } else {
  39.220 -            String nativeFormat = getNativeForFormat(format);
  39.221 -            throw new IOException("Translation from " + nativeFormat +
  39.222 -                                  " is not supported.");
  39.223 -        }
  39.224 -    }
  39.225 -
  39.226 -    /**
  39.227 -     * Returns true if and only if the name of the specified format Atom
  39.228 -     * constitutes a valid MIME type with the specified primary type.
  39.229 -     */
  39.230 -    private boolean isMimeFormat(long format, String primaryType) {
  39.231 -        String nat = getNativeForFormat(format);
  39.232 -
  39.233 -        if (nat == null) {
  39.234 -            return false;
  39.235 -        }
  39.236 -
  39.237 -        try {
  39.238 -            DataFlavor df = new DataFlavor(nat);
  39.239 -            if (primaryType.equals(df.getPrimaryType())) {
  39.240 -                return true;
  39.241 -            }
  39.242 -        } catch (Exception e) {
  39.243 -            // Not a MIME format.
  39.244 -        }
  39.245 -
  39.246 -        return false;
  39.247 -    }
  39.248 -
  39.249 -    /*
  39.250 -     * The XDnD protocol prescribes that the Atoms used as targets for data
  39.251 -     * transfer should have string names that represent the corresponding MIME
  39.252 -     * types.
  39.253 -     * To meet this requirement we check if the passed native format constitutes
  39.254 -     * a valid MIME and return a list of flavors to which the data in this MIME
  39.255 -     * type can be translated by the Data Transfer subsystem.
  39.256 -     */
  39.257 -    public List getPlatformMappingsForNative(String nat) {
  39.258 -        List flavors = new ArrayList();
  39.259 -
  39.260 -        if (nat == null) {
  39.261 -            return flavors;
  39.262 -        }
  39.263 -
  39.264 -        DataFlavor df = null;
  39.265 -
  39.266 -        try {
  39.267 -            df = new DataFlavor(nat);
  39.268 -        } catch (Exception e) {
  39.269 -            // The string doesn't constitute a valid MIME type.
  39.270 -            return flavors;
  39.271 -        }
  39.272 -
  39.273 -        Object value = df;
  39.274 -        final String primaryType = df.getPrimaryType();
  39.275 -        final String baseType = primaryType + "/" + df.getSubType();
  39.276 -
  39.277 -        // For text formats we map natives to MIME strings instead of data
  39.278 -        // flavors to enable dynamic text native-to-flavor mapping generation.
  39.279 -        // See SystemFlavorMap.getFlavorsForNative() for details.
  39.280 -        if ("text".equals(primaryType)) {
  39.281 -            value = primaryType + "/" + df.getSubType();
  39.282 -        } else if ("image".equals(primaryType)) {
  39.283 -            Iterator readers = ImageIO.getImageReadersByMIMEType(baseType);
  39.284 -            if (readers.hasNext()) {
  39.285 -                flavors.add(DataFlavor.imageFlavor);
  39.286 -            }
  39.287 -        }
  39.288 -
  39.289 -        flavors.add(value);
  39.290 -
  39.291 -        return flavors;
  39.292 -    }
  39.293 -
  39.294 -    private static ImageTypeSpecifier defaultSpecifier = null;
  39.295 -
  39.296 -    private ImageTypeSpecifier getDefaultImageTypeSpecifier() {
  39.297 -        if (defaultSpecifier == null) {
  39.298 -            ColorModel model = ColorModel.getRGBdefault();
  39.299 -            WritableRaster raster =
  39.300 -                model.createCompatibleWritableRaster(10, 10);
  39.301 -
  39.302 -            BufferedImage bufferedImage =
  39.303 -                new BufferedImage(model, raster, model.isAlphaPremultiplied(),
  39.304 -                                  null);
  39.305 -
  39.306 -            defaultSpecifier = new ImageTypeSpecifier(bufferedImage);
  39.307 -        }
  39.308 -
  39.309 -        return defaultSpecifier;
  39.310 -    }
  39.311 -
  39.312 -    /*
  39.313 -     * The XDnD protocol prescribes that the Atoms used as targets for data
  39.314 -     * transfer should have string names that represent the corresponding MIME
  39.315 -     * types.
  39.316 -     * To meet this requirement we return a list of formats that represent
  39.317 -     * MIME types to which the data in this flavor can be translated by the Data
  39.318 -     * Transfer subsystem.
  39.319 -     */
  39.320 -    public List getPlatformMappingsForFlavor(DataFlavor df) {
  39.321 -        List natives = new ArrayList(1);
  39.322 -
  39.323 -        if (df == null) {
  39.324 -            return natives;
  39.325 -        }
  39.326 -
  39.327 -        String charset = df.getParameter("charset");
  39.328 -        String baseType = df.getPrimaryType() + "/" + df.getSubType();
  39.329 -        String mimeType = baseType;
  39.330 -
  39.331 -        if (charset != null && DataTransferer.isFlavorCharsetTextType(df)) {
  39.332 -            mimeType += ";charset=" + charset;
  39.333 -        }
  39.334 -
  39.335 -        // Add a mapping to the MIME native whenever the representation class
  39.336 -        // doesn't require translation.
  39.337 -        if (df.getRepresentationClass() != null &&
  39.338 -            (df.isRepresentationClassInputStream() ||
  39.339 -             df.isRepresentationClassByteBuffer() ||
  39.340 -             byteArrayClass.equals(df.getRepresentationClass()))) {
  39.341 -            natives.add(mimeType);
  39.342 -        }
  39.343 -
  39.344 -        if (DataFlavor.imageFlavor.equals(df)) {
  39.345 -            String[] mimeTypes = ImageIO.getWriterMIMETypes();
  39.346 -            if (mimeTypes != null) {
  39.347 -                for (int i = 0; i < mimeTypes.length; i++) {
  39.348 -                    Iterator writers =
  39.349 -                        ImageIO.getImageWritersByMIMEType(mimeTypes[i]);
  39.350 -
  39.351 -                    while (writers.hasNext()) {
  39.352 -                        ImageWriter imageWriter = (ImageWriter)writers.next();
  39.353 -                        ImageWriterSpi writerSpi =
  39.354 -                            imageWriter.getOriginatingProvider();
  39.355 -
  39.356 -                        if (writerSpi != null &&
  39.357 -                            writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) {
  39.358 -                            natives.add(mimeTypes[i]);
  39.359 -                            break;
  39.360 -                        }
  39.361 -                    }
  39.362 -                }
  39.363 -            }
  39.364 -        } else if (DataTransferer.isFlavorCharsetTextType(df)) {
  39.365 -            final Iterator iter = DataTransferer.standardEncodings();
  39.366 -
  39.367 -            // stringFlavor is semantically equivalent to the standard
  39.368 -            // "text/plain" MIME type.
  39.369 -            if (DataFlavor.stringFlavor.equals(df)) {
  39.370 -                baseType = "text/plain";
  39.371 -            }
  39.372 -
  39.373 -            while (iter.hasNext()) {
  39.374 -                String encoding = (String)iter.next();
  39.375 -                if (!encoding.equals(charset)) {
  39.376 -                    natives.add(baseType + ";charset=" + encoding);
  39.377 -                }
  39.378 -            }
  39.379 -
  39.380 -            // Add a MIME format without specified charset.
  39.381 -            if (!natives.contains(baseType)) {
  39.382 -                natives.add(baseType);
  39.383 -            }
  39.384 -        }
  39.385 -
  39.386 -        return natives;
  39.387 -    }
  39.388 -    protected native String[] dragQueryFile(byte[] bytes);
  39.389 -}
    40.1 --- a/src/solaris/classes/sun/awt/motif/MDialogPeer.java	Wed Sep 17 13:45:37 2008 -0700
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,110 +0,0 @@
    40.4 -/*
    40.5 - * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
    40.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.7 - *
    40.8 - * This code is free software; you can redistribute it and/or modify it
    40.9 - * under the terms of the GNU General Public License version 2 only, as
   40.10 - * published by the Free Software Foundation.  Sun designates this
   40.11 - * particular file as subject to the "Classpath" exception as provided
   40.12 - * by Sun in the LICENSE file that accompanied this code.
   40.13 - *
   40.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   40.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   40.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   40.17 - * version 2 for more details (a copy is included in the LICENSE file that
   40.18 - * accompanied this code).
   40.19 - *
   40.20 - * You should have received a copy of the GNU General Public License version
   40.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   40.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   40.23 - *
   40.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   40.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   40.26 - * have any questions.
   40.27 - */
   40.28 -package sun.awt.motif;
   40.29 -
   40.30 -import java.util.Vector;
   40.31 -import java.awt.*;
   40.32 -import java.awt.peer.*;
   40.33 -import java.awt.event.*;
   40.34 -import sun.awt.motif.MInputMethodControl;
   40.35 -import sun.awt.im.*;
   40.36 -
   40.37 -class MDialogPeer extends MWindowPeer implements DialogPeer, MInputMethodControl {
   40.38 -
   40.39 -    static Vector allDialogs = new Vector();
   40.40 -
   40.41 -    MDialogPeer(Dialog target) {
   40.42 -
   40.43 -        /* create MWindowPeer object */
   40.44 -        super();
   40.45 -
   40.46 -        winAttr.nativeDecor = !target.isUndecorated();
   40.47 -        winAttr.initialFocus = true;
   40.48 -        winAttr.isResizable =  target.isResizable();
   40.49 -        winAttr.initialState = MWindowAttributes.NORMAL;
   40.50 -        winAttr.title = target.getTitle();
   40.51 -        winAttr.icon = null;
   40.52 -        if (winAttr.nativeDecor) {
   40.53 -            winAttr.decorations = winAttr.AWT_DECOR_ALL |
   40.54 -                                  winAttr.AWT_DECOR_MINIMIZE |
   40.55 -                                  winAttr.AWT_DECOR_MAXIMIZE;
   40.56 -        } else {
   40.57 -            winAttr.decorations = winAttr.AWT_DECOR_NONE;
   40.58 -        }
   40.59 -        /* create and init native component */
   40.60 -        init(target);
   40.61 -        allDialogs.addElement(this);
   40.62 -    }
   40.63 -
   40.64 -    public void setTitle(String title) {
   40.65 -        pSetTitle(title);
   40.66 -    }
   40.67 -
   40.68 -    protected void disposeImpl() {
   40.69 -        allDialogs.removeElement(this);
   40.70 -        super.disposeImpl();
   40.71 -    }
   40.72 -
   40.73 -    // NOTE: This method is called by privileged threads.
   40.74 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   40.75 -    public void handleMoved(int x, int y) {
   40.76 -        postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
   40.77 -    }
   40.78 -
   40.79 -    public void show() {
   40.80 -        pShowModal( ((Dialog)target).isModal() );
   40.81 -        updateAlwaysOnTop(alwaysOnTop);
   40.82 -    }
   40.83 -
   40.84 -
   40.85 -    // NOTE: This method may be called by privileged threads.
   40.86 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   40.87 -    public void handleIconify() {
   40.88 -// Note: These routines are necessary for Coaleseing of native implementations
   40.89 -//       As Dialogs do not currently send Iconify/DeIconify messages but
   40.90 -//       Windows/Frames do.  If this should be made consistent...to do so
   40.91 -//       uncomment the postEvent.
   40.92 -//       postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED));
   40.93 -    }
   40.94 -
   40.95 -    // NOTE: This method may be called by privileged threads.
   40.96 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   40.97 -    public void handleDeiconify() {
   40.98 -// Note: These routines are necessary for Coaleseing of native implementations
   40.99 -//       As Dialogs do not currently send Iconify/DeIconify messages but
  40.100 -//       Windows/Frames do. If this should be made consistent...to do so
  40.101 -//       uncomment the postEvent.
  40.102 -//       postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED));
  40.103 -    }
  40.104 -
  40.105 -    public void blockWindows(java.util.List<Window> toBlock) {
  40.106 -        // do nothing
  40.107 -    }
  40.108 -
  40.109 -    @Override
  40.110 -    final boolean isTargetUndecorated() {
  40.111 -        return ((Dialog)target).isUndecorated();
  40.112 -    }
  40.113 -}
    41.1 --- a/src/solaris/classes/sun/awt/motif/MDragSourceContextPeer.java	Wed Sep 17 13:45:37 2008 -0700
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,120 +0,0 @@
    41.4 -/*
    41.5 - * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
    41.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.7 - *
    41.8 - * This code is free software; you can redistribute it and/or modify it
    41.9 - * under the terms of the GNU General Public License version 2 only, as
   41.10 - * published by the Free Software Foundation.  Sun designates this
   41.11 - * particular file as subject to the "Classpath" exception as provided
   41.12 - * by Sun in the LICENSE file that accompanied this code.
   41.13 - *
   41.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   41.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   41.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   41.17 - * version 2 for more details (a copy is included in the LICENSE file that
   41.18 - * accompanied this code).
   41.19 - *
   41.20 - * You should have received a copy of the GNU General Public License version
   41.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   41.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   41.23 - *
   41.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   41.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   41.26 - * have any questions.
   41.27 - */
   41.28 -
   41.29 -package sun.awt.motif;
   41.30 -
   41.31 -import java.awt.Component;
   41.32 -import java.awt.Cursor;
   41.33 -import java.awt.Image;
   41.34 -import java.awt.Point;
   41.35 -
   41.36 -import java.awt.datatransfer.Transferable;
   41.37 -
   41.38 -import java.awt.dnd.DragSourceContext;
   41.39 -import java.awt.dnd.DragGestureEvent;
   41.40 -import java.awt.dnd.InvalidDnDOperationException;
   41.41 -
   41.42 -import java.awt.event.InputEvent;
   41.43 -
   41.44 -import java.awt.peer.ComponentPeer;
   41.45 -import java.awt.peer.LightweightPeer;
   41.46 -
   41.47 -import java.util.Map;
   41.48 -import sun.awt.SunToolkit;
   41.49 -import sun.awt.dnd.SunDragSourceContextPeer;
   41.50 -
   41.51 -/**
   41.52 - * <p>
   41.53 - * TBC
   41.54 - * </p>
   41.55 - *
   41.56 - * @since JDK1.2
   41.57 - *
   41.58 - */
   41.59 -
   41.60 -final class MDragSourceContextPeer extends SunDragSourceContextPeer {
   41.61 -
   41.62 -    private static final MDragSourceContextPeer theInstance =
   41.63 -        new MDragSourceContextPeer(null);
   41.64 -
   41.65 -    /**
   41.66 -     * construct a new MDragSourceContextPeer
   41.67 -     */
   41.68 -
   41.69 -    private MDragSourceContextPeer(DragGestureEvent dge) {
   41.70 -        super(dge);
   41.71 -    }
   41.72 -
   41.73 -    static MDragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
   41.74 -        theInstance.setTrigger(dge);
   41.75 -        return theInstance;
   41.76 -    }
   41.77 -
   41.78 -    protected void startDrag(Transferable transferable,
   41.79 -                             long[] formats, Map formatMap) {
   41.80 -        try {
   41.81 -            long nativeCtxtLocal = startDrag(getTrigger().getComponent(),
   41.82 -                                             transferable,
   41.83 -                                             getTrigger().getTriggerEvent(),
   41.84 -                                             getCursor(),
   41.85 -                                             getCursor() == null ? 0 : getCursor().getType(),
   41.86 -                                             getDragSourceContext().getSourceActions(),
   41.87 -                                             formats,
   41.88 -                                             formatMap);
   41.89 -            setNativeContext(nativeCtxtLocal);
   41.90 -        } catch (Exception e) {
   41.91 -            throw new InvalidDnDOperationException("failed to create native peer: " + e);
   41.92 -        }
   41.93 -
   41.94 -        if (getNativeContext() == 0) {
   41.95 -            throw new InvalidDnDOperationException("failed to create native peer");
   41.96 -        }
   41.97 -
   41.98 -        MDropTargetContextPeer.setCurrentJVMLocalSourceTransferable(transferable);
   41.99 -    }
  41.100 -
  41.101 -    /**
  41.102 -     * downcall into native code
  41.103 -     */
  41.104 -
  41.105 -    private native long startDrag(Component component,
  41.106 -                                  Transferable transferable,
  41.107 -                                  InputEvent nativeTrigger,
  41.108 -                                  Cursor c, int ctype, int actions,
  41.109 -                                  long[] formats, Map formatMap);
  41.110 -
  41.111 -    /**
  41.112 -     * set cursor
  41.113 -     */
  41.114 -
  41.115 -    public void setCursor(Cursor c) throws InvalidDnDOperationException {
  41.116 -        SunToolkit.awtLock();
  41.117 -        super.setCursor(c);
  41.118 -        SunToolkit.awtUnlock();
  41.119 -    }
  41.120 -
  41.121 -    protected native void setNativeCursor(long nativeCtxt, Cursor c, int cType);
  41.122 -
  41.123 -}
    42.1 --- a/src/solaris/classes/sun/awt/motif/MDropTargetContextPeer.java	Wed Sep 17 13:45:37 2008 -0700
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,147 +0,0 @@
    42.4 -/*
    42.5 - * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
    42.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    42.7 - *
    42.8 - * This code is free software; you can redistribute it and/or modify it
    42.9 - * under the terms of the GNU General Public License version 2 only, as
   42.10 - * published by the Free Software Foundation.  Sun designates this
   42.11 - * particular file as subject to the "Classpath" exception as provided
   42.12 - * by Sun in the LICENSE file that accompanied this code.
   42.13 - *
   42.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   42.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   42.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   42.17 - * version 2 for more details (a copy is included in the LICENSE file that
   42.18 - * accompanied this code).
   42.19 - *
   42.20 - * You should have received a copy of the GNU General Public License version
   42.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   42.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   42.23 - *
   42.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   42.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   42.26 - * have any questions.
   42.27 - */
   42.28 -
   42.29 -package sun.awt.motif;
   42.30 -
   42.31 -import java.awt.datatransfer.DataFlavor;
   42.32 -import java.awt.datatransfer.UnsupportedFlavorException;
   42.33 -
   42.34 -import java.awt.dnd.DnDConstants;
   42.35 -import java.awt.dnd.InvalidDnDOperationException;
   42.36 -
   42.37 -import java.io.InputStream;
   42.38 -
   42.39 -import java.util.Map;
   42.40 -
   42.41 -import java.io.IOException;
   42.42 -import sun.awt.dnd.SunDropTargetContextPeer;
   42.43 -import sun.awt.SunToolkit;
   42.44 -
   42.45 -/**
   42.46 - * <p>
   42.47 - * The MDropTargetContextPeer class is the class responsible for handling
   42.48 - * the interaction between the Motif DnD system and Java.
   42.49 - * </p>
   42.50 - *
   42.51 - * @since JDK1.2
   42.52 - *
   42.53 - */
   42.54 -
   42.55 -final class MDropTargetContextPeer extends SunDropTargetContextPeer {
   42.56 -
   42.57 -    private long              nativeDropTransfer;
   42.58 -
   42.59 -    long                      nativeDataAvailable = 0;
   42.60 -    Object                    nativeData          = null;
   42.61 -
   42.62 -    /**
   42.63 -     * create the peer
   42.64 -     */
   42.65 -
   42.66 -    static MDropTargetContextPeer createMDropTargetContextPeer() {
   42.67 -        return new MDropTargetContextPeer();
   42.68 -    }
   42.69 -
   42.70 -    /**
   42.71 -     * create the peer
   42.72 -     */
   42.73 -
   42.74 -    private MDropTargetContextPeer() {
   42.75 -        super();
   42.76 -    }
   42.77 -
   42.78 -    protected Object getNativeData(long format) {
   42.79 -        SunToolkit.awtLock();
   42.80 -        if (nativeDropTransfer == 0) {
   42.81 -            nativeDropTransfer = startTransfer(getNativeDragContext(),
   42.82 -                                               format);
   42.83 -        } else {
   42.84 -            addTransfer (nativeDropTransfer, format);
   42.85 -        }
   42.86 -
   42.87 -        for (nativeDataAvailable = 0;
   42.88 -             format != nativeDataAvailable;) {
   42.89 -            try {
   42.90 -                SunToolkit.awtLockWait();
   42.91 -            } catch (Throwable e) {
   42.92 -                e.printStackTrace();
   42.93 -            }
   42.94 -        }
   42.95 -        SunToolkit.awtUnlock();
   42.96 -
   42.97 -        return nativeData;
   42.98 -    }
   42.99 -
  42.100 -    /**
  42.101 -     * signal drop complete
  42.102 -     */
  42.103 -
  42.104 -    protected void doDropDone(boolean success, int dropAction,
  42.105 -                              boolean isLocal) {
  42.106 -        dropDone(getNativeDragContext(), nativeDropTransfer, isLocal,
  42.107 -                 success, dropAction);
  42.108 -    }
  42.109 -
  42.110 -    /**
  42.111 -     * notify transfer complete
  42.112 -     */
  42.113 -
  42.114 -    private void newData(long format, String type, byte[] data) {
  42.115 -        nativeDataAvailable = format;
  42.116 -        nativeData          = data;
  42.117 -
  42.118 -        SunToolkit.awtLockNotifyAll();
  42.119 -    }
  42.120 -
  42.121 -    /**
  42.122 -     * notify transfer failed
  42.123 -     */
  42.124 -
  42.125 -    private void transferFailed(long format) {
  42.126 -        nativeDataAvailable = format;
  42.127 -        nativeData          = null;
  42.128 -
  42.129 -        SunToolkit.awtLockNotifyAll();
  42.130 -    }
  42.131 -
  42.132 -    /**
  42.133 -     * schedule a native DnD transfer
  42.134 -     */
  42.135 -
  42.136 -    private native long startTransfer(long nativeDragContext, long format);
  42.137 -
  42.138 -    /**
  42.139 -     * schedule a native DnD data transfer
  42.140 -     */
  42.141 -
  42.142 -    private native void addTransfer(long nativeDropTransfer, long format);
  42.143 -
  42.144 -    /**
  42.145 -     * signal that drop is completed
  42.146 -     */
  42.147 -
  42.148 -    private native void dropDone(long nativeDragContext, long nativeDropTransfer,
  42.149 -                                 boolean localTx, boolean success, int dropAction);
  42.150 -}
    43.1 --- a/src/solaris/classes/sun/awt/motif/MEmbedCanvasPeer.java	Wed Sep 17 13:45:37 2008 -0700
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,584 +0,0 @@
    43.4 -/*
    43.5 - * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
    43.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    43.7 - *
    43.8 - * This code is free software; you can redistribute it and/or modify it
    43.9 - * under the terms of the GNU General Public License version 2 only, as
   43.10 - * published by the Free Software Foundation.  Sun designates this
   43.11 - * particular file as subject to the "Classpath" exception as provided
   43.12 - * by Sun in the LICENSE file that accompanied this code.
   43.13 - *
   43.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   43.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   43.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   43.17 - * version 2 for more details (a copy is included in the LICENSE file that
   43.18 - * accompanied this code).
   43.19 - *
   43.20 - * You should have received a copy of the GNU General Public License version
   43.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   43.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   43.23 - *
   43.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   43.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   43.26 - * have any questions.
   43.27 - */
   43.28 -
   43.29 -package sun.awt.motif;
   43.30 -
   43.31 -import java.awt.*;
   43.32 -import java.awt.dnd.DropTarget;
   43.33 -import java.awt.dnd.DropTargetListener;
   43.34 -import java.awt.event.*;
   43.35 -import java.awt.image.ColorModel;
   43.36 -import java.awt.image.ImageObserver;
   43.37 -import java.awt.image.ImageProducer;
   43.38 -import java.awt.image.VolatileImage;
   43.39 -import java.awt.peer.*;
   43.40 -import sun.awt.*;
   43.41 -import sun.awt.motif.X11FontMetrics;
   43.42 -import java.lang.reflect.*;
   43.43 -import java.util.logging.*;
   43.44 -import java.util.*;
   43.45 -
   43.46 -// FIXME: Add X errors handling
   43.47 -// FIXME: Add chaining of parameters to XEmbed-client if we are both(accelerators; XDND; focus already automatically)
   43.48 -public class MEmbedCanvasPeer extends MCanvasPeer implements WindowFocusListener, KeyEventPostProcessor, ModalityListener, WindowIDProvider {
   43.49 -    private static final Logger xembedLog = Logger.getLogger("sun.awt.motif.xembed.MEmbedCanvasPeer");
   43.50 -
   43.51 -    final static int XEMBED_VERSION = 0,
   43.52 -        XEMBED_MAPPED = (1 << 0);
   43.53 -/* XEMBED messages */
   43.54 -    final static int XEMBED_EMBEDDED_NOTIFY     =       0;
   43.55 -    final static int XEMBED_WINDOW_ACTIVATE  =  1;
   43.56 -    final static int XEMBED_WINDOW_DEACTIVATE =         2;
   43.57 -    final static int XEMBED_REQUEST_FOCUS               =3;
   43.58 -    final static int XEMBED_FOCUS_IN    =       4;
   43.59 -    final static int XEMBED_FOCUS_OUT   =       5;
   43.60 -    final static int XEMBED_FOCUS_NEXT  =       6;
   43.61 -    final static int XEMBED_FOCUS_PREV  =       7;
   43.62 -/* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */
   43.63 -    final static int XEMBED_GRAB_KEY = 8;
   43.64 -    final static int XEMBED_UNGRAB_KEY = 9;
   43.65 -    final static int XEMBED_MODALITY_ON         =       10;
   43.66 -    final static int XEMBED_MODALITY_OFF        =       11;
   43.67 -    final static int XEMBED_REGISTER_ACCELERATOR =    12;
   43.68 -    final static int XEMBED_UNREGISTER_ACCELERATOR=   13;
   43.69 -    final static int XEMBED_ACTIVATE_ACCELERATOR  =   14;
   43.70 -
   43.71 -    final static int NON_STANDARD_XEMBED_GTK_GRAB_KEY = 108;
   43.72 -    final static int NON_STANDARD_XEMBED_GTK_UNGRAB_KEY = 109;
   43.73 -
   43.74 -//     A detail code is required for XEMBED_FOCUS_IN. The following values are valid:
   43.75 -/* Details for  XEMBED_FOCUS_IN: */
   43.76 -    final static int XEMBED_FOCUS_CURRENT       =       0;
   43.77 -    final static int XEMBED_FOCUS_FIRST         =       1;
   43.78 -    final static int XEMBED_FOCUS_LAST  =       2;
   43.79 -
   43.80 -// Modifiers bits
   43.81 -    final static int XEMBED_MODIFIER_SHIFT   = (1 << 0);
   43.82 -    final static int XEMBED_MODIFIER_CONTROL = (1 << 1);
   43.83 -    final static int XEMBED_MODIFIER_ALT     = (1 << 2);
   43.84 -    final static int XEMBED_MODIFIER_SUPER   = (1 << 3);
   43.85 -    final static int XEMBED_MODIFIER_HYPER   = (1 << 4);
   43.86 -
   43.87 -    boolean applicationActive; // Whether the application is active(has focus)
   43.88 -    Map<Long, AWTKeyStroke> accelerators = new HashMap<Long, AWTKeyStroke>(); // Maps accelerator ID into AWTKeyStroke
   43.89 -    Map<AWTKeyStroke, Long> accel_lookup = new HashMap<AWTKeyStroke, Long>(); // Maps AWTKeyStroke into accelerator ID
   43.90 -    Set<GrabbedKey> grabbed_keys = new HashSet<GrabbedKey>(); // A set of keys grabbed by client
   43.91 -    Object ACCEL_LOCK = accelerators; // Lock object for working with accelerators;
   43.92 -    Object GRAB_LOCK = grabbed_keys; // Lock object for working with keys grabbed by client
   43.93 -
   43.94 -    MEmbedCanvasPeer() {}
   43.95 -
   43.96 -    MEmbedCanvasPeer(Component target) {
   43.97 -        super(target);
   43.98 -    }
   43.99 -
  43.100 -    void initialize() {
  43.101 -        super.initialize();
  43.102 -
  43.103 -        installActivateListener();
  43.104 -        installAcceleratorListener();
  43.105 -        installModalityListener();
  43.106 -
  43.107 -        // XEmbed canvas should be non-traversable.
  43.108 -        // FIXME: Probably should be removed and enforced setting of it by the users
  43.109 -        target.setFocusTraversalKeysEnabled(false);
  43.110 -
  43.111 -        initXEmbedServer();
  43.112 -    }
  43.113 -
  43.114 -    void installModalityListener() {
  43.115 -        ((SunToolkit)Toolkit.getDefaultToolkit()).addModalityListener(this);
  43.116 -    }
  43.117 -
  43.118 -    void deinstallModalityListener() {
  43.119 -        ((SunToolkit)Toolkit.getDefaultToolkit()).removeModalityListener(this);
  43.120 -    }
  43.121 -
  43.122 -    void installAcceleratorListener() {
  43.123 -        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor(this);
  43.124 -    }
  43.125 -
  43.126 -    void deinstallAcceleratorListener() {
  43.127 -        KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventPostProcessor(this);
  43.128 -    }
  43.129 -
  43.130 -    void installActivateListener() {
  43.131 -        // FIXME: should watch for hierarchy changes
  43.132 -        Window toplevel = getTopLevel(target);
  43.133 -        if (toplevel != null) {
  43.134 -            toplevel.addWindowFocusListener(this);
  43.135 -            applicationActive = toplevel.isFocused();
  43.136 -        }
  43.137 -    }
  43.138 -
  43.139 -    void deinstallActivateListener() {
  43.140 -        Window toplevel = getTopLevel(target);
  43.141 -        if (toplevel != null) {
  43.142 -            toplevel.removeWindowFocusListener(this);
  43.143 -        }
  43.144 -    }
  43.145 -
  43.146 -    native boolean isXEmbedActive();
  43.147 -
  43.148 -    boolean isApplicationActive() {
  43.149 -        return applicationActive;
  43.150 -    }
  43.151 -
  43.152 -    native void initDispatching();
  43.153 -
  43.154 -    native void endDispatching();
  43.155 -
  43.156 -    native void embedChild(long child);
  43.157 -
  43.158 -    native void childDestroyed();
  43.159 -
  43.160 -    public void handleEvent(AWTEvent e) {
  43.161 -        super.handleEvent(e);
  43.162 -        if (isXEmbedActive()) {
  43.163 -            switch (e.getID()) {
  43.164 -              case FocusEvent.FOCUS_GAINED:
  43.165 -                  canvasFocusGained((FocusEvent)e);
  43.166 -                  break;
  43.167 -              case FocusEvent.FOCUS_LOST:
  43.168 -                  canvasFocusLost((FocusEvent)e);
  43.169 -                  break;
  43.170 -              case KeyEvent.KEY_PRESSED:
  43.171 -              case KeyEvent.KEY_RELEASED:
  43.172 -                  if (!((InputEvent)e).isConsumed()) {
  43.173 -                      forwardKeyEvent((KeyEvent)e);
  43.174 -                  }
  43.175 -                  break;
  43.176 -            }
  43.177 -        }
  43.178 -    }
  43.179 -
  43.180 -    public Dimension getPreferredSize() {
  43.181 -        if (isXEmbedActive()) {
  43.182 -            Dimension dim = getEmbedPreferredSize();
  43.183 -            if (dim == null) {
  43.184 -                return super.getPreferredSize();
  43.185 -            } else {
  43.186 -                return dim;
  43.187 -            }
  43.188 -        } else {
  43.189 -            return super.getPreferredSize();
  43.190 -        }
  43.191 -    }
  43.192 -    native Dimension getEmbedPreferredSize();
  43.193 -    public Dimension getMinimumSize() {
  43.194 -        if (isXEmbedActive()) {
  43.195 -            Dimension dim = getEmbedMinimumSize();
  43.196 -            if (dim == null) {
  43.197 -                return super.getMinimumSize();
  43.198 -            } else {
  43.199 -                return dim;
  43.200 -            }
  43.201 -        } else {
  43.202 -            return super.getMinimumSize();
  43.203 -        }
  43.204 -    }
  43.205 -    native Dimension getEmbedMinimumSize();
  43.206 -    protected void disposeImpl() {
  43.207 -        if (isXEmbedActive()) {
  43.208 -            detachChild();
  43.209 -        }
  43.210 -        deinstallActivateListener();
  43.211 -        deinstallModalityListener();
  43.212 -        deinstallAcceleratorListener();
  43.213 -
  43.214 -        destroyXEmbedServer();
  43.215 -        super.disposeImpl();
  43.216 -    }
  43.217 -
  43.218 -    public boolean isFocusable() {
  43.219 -        return true;
  43.220 -    }
  43.221 -
  43.222 -    Window getTopLevel(Component comp) {
  43.223 -        while (comp != null && !(comp instanceof Window)) {
  43.224 -            comp = comp.getParent();
  43.225 -        }
  43.226 -        return (Window)comp;
  43.227 -    }
  43.228 -
  43.229 -    native Rectangle getClientBounds();
  43.230 -
  43.231 -    void childResized() {
  43.232 -        if (xembedLog.isLoggable(Level.FINER)) {
  43.233 -            Rectangle bounds = getClientBounds();
  43.234 -            xembedLog.finer("Child resized: " + bounds);
  43.235 -            // It is not required to update embedder's size when client size changes
  43.236 -            // However, since there is no any means to get client size it seems to be the
  43.237 -            // only way to provide it. However, it contradicts with Java layout concept -
  43.238 -            // so it is disabled for now.
  43.239 -//             Rectangle my_bounds = getBounds();
  43.240 -//             setBounds(my_bounds.x, my_bounds.y, bounds.width, bounds.height, SET_BOUNDS);
  43.241 -        }
  43.242 -        postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
  43.243 -    }
  43.244 -
  43.245 -    void focusNext() {
  43.246 -        if (isXEmbedActive()) {
  43.247 -            xembedLog.fine("Requesting focus for the next component after embedder");
  43.248 -            postEvent(new InvocationEvent(target, new Runnable() {
  43.249 -                    public void run() {
  43.250 -                        KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(target);
  43.251 -                    }
  43.252 -                }));
  43.253 -        } else {
  43.254 -            xembedLog.fine("Application is not active - denying focus next");
  43.255 -        }
  43.256 -    }
  43.257 -
  43.258 -    void focusPrev() {
  43.259 -        if (isXEmbedActive()) {
  43.260 -            xembedLog.fine("Requesting focus for the next component after embedder");
  43.261 -            postEvent(new InvocationEvent(target, new Runnable() {
  43.262 -                    public void run() {
  43.263 -                        KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent(target);
  43.264 -                    }
  43.265 -                }));
  43.266 -        } else {
  43.267 -            xembedLog.fine("Application is not active - denying focus prev");
  43.268 -        }
  43.269 -    }
  43.270 -
  43.271 -    void requestXEmbedFocus() {
  43.272 -        if (isXEmbedActive()) {
  43.273 -            xembedLog.fine("Requesting focus for client");
  43.274 -            postEvent(new InvocationEvent(target, new Runnable() {
  43.275 -                    public void run() {
  43.276 -                        target.requestFocusInWindow();
  43.277 -                    }
  43.278 -                }));
  43.279 -        } else {
  43.280 -            xembedLog.fine("Application is not active - denying request focus");
  43.281 -        }
  43.282 -    }
  43.283 -
  43.284 -    native void notifyChildEmbedded();
  43.285 -
  43.286 -    native void detachChild();
  43.287 -
  43.288 -    public void windowGainedFocus(WindowEvent e) {
  43.289 -        applicationActive = true;
  43.290 -        if (isXEmbedActive()) {
  43.291 -            xembedLog.fine("Sending WINDOW_ACTIVATE");
  43.292 -            sendMessage(XEMBED_WINDOW_ACTIVATE);
  43.293 -        }
  43.294 -    }
  43.295 -
  43.296 -    public void windowLostFocus(WindowEvent e) {
  43.297 -        applicationActive = false;
  43.298 -        if (isXEmbedActive()) {
  43.299 -            xembedLog.fine("Sending WINDOW_DEACTIVATE");
  43.300 -            sendMessage(XEMBED_WINDOW_DEACTIVATE);
  43.301 -        }
  43.302 -    }
  43.303 -
  43.304 -    void canvasFocusGained(FocusEvent e) {
  43.305 -        if (isXEmbedActive()) {
  43.306 -            xembedLog.fine("Forwarding FOCUS_GAINED");
  43.307 -            int flavor = XEMBED_FOCUS_CURRENT;
  43.308 -            if (e instanceof CausedFocusEvent) {
  43.309 -                CausedFocusEvent ce = (CausedFocusEvent)e;
  43.310 -                if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_FORWARD) {
  43.311 -                    flavor = XEMBED_FOCUS_FIRST;
  43.312 -                } else if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_BACKWARD) {
  43.313 -                    flavor = XEMBED_FOCUS_LAST;
  43.314 -                }
  43.315 -            }
  43.316 -            sendMessage(XEMBED_FOCUS_IN, flavor, 0, 0);
  43.317 -        }
  43.318 -    }
  43.319 -
  43.320 -    void canvasFocusLost(FocusEvent e) {
  43.321 -        if (isXEmbedActive() && !e.isTemporary()) {
  43.322 -            xembedLog.fine("Forwarding FOCUS_LOST");
  43.323 -            Component opp = e.getOppositeComponent();
  43.324 -            int num = 0;
  43.325 -            try {
  43.326 -                num = Integer.parseInt(opp.getName());
  43.327 -            } catch (NumberFormatException nfe) {
  43.328 -            }
  43.329 -            sendMessage(XEMBED_FOCUS_OUT, num, 0, 0);
  43.330 -        }
  43.331 -    }
  43.332 -
  43.333 -    native void forwardKeyEvent(KeyEvent e);
  43.334 -
  43.335 -    void grabKey(final long keysym, final long modifiers) {
  43.336 -        postEvent(new InvocationEvent(target, new Runnable() {
  43.337 -                public void run() {
  43.338 -                    GrabbedKey grab = new GrabbedKey(keysym, modifiers);
  43.339 -                    if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Grabbing key: " + grab);
  43.340 -                    synchronized(GRAB_LOCK) {
  43.341 -                        grabbed_keys.add(grab);
  43.342 -                    }
  43.343 -                }
  43.344 -            }));
  43.345 -    }
  43.346 -
  43.347 -    void ungrabKey(final long keysym, final long modifiers) {
  43.348 -        postEvent(new InvocationEvent(target, new Runnable() {
  43.349 -                public void run() {
  43.350 -                    GrabbedKey grab = new GrabbedKey(keysym, modifiers);
  43.351 -                    if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("UnGrabbing key: " + grab);
  43.352 -                    synchronized(GRAB_LOCK) {
  43.353 -                        grabbed_keys.remove(grab);
  43.354 -                    }
  43.355 -                }
  43.356 -            }));
  43.357 -    }
  43.358 -
  43.359 -    void registerAccelerator(final long accel_id, final long keysym, final long modifiers) {
  43.360 -        postEvent(new InvocationEvent(target, new Runnable() {
  43.361 -                public void run() {
  43.362 -                    AWTKeyStroke stroke = getKeyStrokeForKeySym(keysym, modifiers);
  43.363 -                    if (stroke != null) {
  43.364 -                        if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Registering accelerator " + accel_id + " for " + stroke);
  43.365 -                        synchronized(ACCEL_LOCK) {
  43.366 -                            accelerators.put(accel_id, stroke);
  43.367 -                            accel_lookup.put(stroke, accel_id);
  43.368 -                        }
  43.369 -                    }
  43.370 -                    // Propogate accelerators to the another embedder
  43.371 -                    propogateRegisterAccelerator(stroke);
  43.372 -                }
  43.373 -            }));
  43.374 -    }
  43.375 -
  43.376 -    void unregisterAccelerator(final long accel_id) {
  43.377 -        postEvent(new InvocationEvent(target, new Runnable() {
  43.378 -                public void run() {
  43.379 -                    AWTKeyStroke stroke = null;
  43.380 -                    synchronized(ACCEL_LOCK) {
  43.381 -                        stroke = accelerators.get(accel_id);
  43.382 -                        if (stroke != null) {
  43.383 -                            if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Unregistering accelerator: " + accel_id);
  43.384 -                            accelerators.remove(accel_id);
  43.385 -                            accel_lookup.remove(stroke); // FIXME: How about several accelerators with the same stroke?
  43.386 -                        }
  43.387 -                    }
  43.388 -                    // Propogate accelerators to the another embedder
  43.389 -                    propogateUnRegisterAccelerator(stroke);
  43.390 -                }
  43.391 -            }));
  43.392 -    }
  43.393 -
  43.394 -    void propogateRegisterAccelerator(AWTKeyStroke stroke) {
  43.395 -        // Find the top-level and see if it is XEmbed client. If so, ask him to
  43.396 -        // register the accelerator
  43.397 -        MWindowPeer parent = getParentWindow();
  43.398 -        if (parent != null && parent instanceof MEmbeddedFramePeer) {
  43.399 -            MEmbeddedFramePeer embedded = (MEmbeddedFramePeer)parent;
  43.400 -            embedded.registerAccelerator(stroke);
  43.401 -        }
  43.402 -    }
  43.403 -
  43.404 -    void propogateUnRegisterAccelerator(AWTKeyStroke stroke) {
  43.405 -        // Find the top-level and see if it is XEmbed client. If so, ask him to
  43.406 -        // register the accelerator
  43.407 -        MWindowPeer parent = getParentWindow();
  43.408 -        if (parent != null && parent instanceof MEmbeddedFramePeer) {
  43.409 -            MEmbeddedFramePeer embedded = (MEmbeddedFramePeer)parent;
  43.410 -            embedded.unregisterAccelerator(stroke);
  43.411 -        }
  43.412 -    }
  43.413 -
  43.414 -    public boolean postProcessKeyEvent(KeyEvent e) {
  43.415 -        // Processing events only if we are in the focused window.
  43.416 -        MWindowPeer parent = getParentWindow();
  43.417 -        if (parent == null || !((Window)parent.target).isFocused() || target.isFocusOwner()) {
  43.418 -            return false;
  43.419 -        }
  43.420 -
  43.421 -        boolean result = false;
  43.422 -
  43.423 -        if (xembedLog.isLoggable(Level.FINER)) xembedLog.finer("Post-processing event " + e);
  43.424 -
  43.425 -        // Process ACCELERATORS
  43.426 -        AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
  43.427 -        long accel_id = 0;
  43.428 -        boolean exists = false;
  43.429 -        synchronized(ACCEL_LOCK) {
  43.430 -            exists = accel_lookup.containsKey(stroke);
  43.431 -            if (exists) {
  43.432 -                accel_id = accel_lookup.get(stroke).longValue();
  43.433 -            }
  43.434 -        }
  43.435 -        if (exists) {
  43.436 -            if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Activating accelerator " + accel_id);
  43.437 -            sendMessage(XEMBED_ACTIVATE_ACCELERATOR, accel_id, 0, 0); // FIXME: How about overloaded?
  43.438 -            result = true;
  43.439 -        }
  43.440 -
  43.441 -        // Process Grabs, unofficial GTK feature
  43.442 -        exists = false;
  43.443 -        GrabbedKey key = new GrabbedKey(e);
  43.444 -        synchronized(GRAB_LOCK) {
  43.445 -            exists = grabbed_keys.contains(key);
  43.446 -        }
  43.447 -        if (exists) {
  43.448 -            if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Forwarding grabbed key " + e);
  43.449 -            forwardKeyEvent(e);
  43.450 -            result = true;
  43.451 -        }
  43.452 -
  43.453 -        return result;
  43.454 -    }
  43.455 -
  43.456 -    public void modalityPushed(ModalityEvent ev) {
  43.457 -        sendMessage(XEMBED_MODALITY_ON);
  43.458 -    }
  43.459 -
  43.460 -    public void modalityPopped(ModalityEvent ev) {
  43.461 -        sendMessage(XEMBED_MODALITY_OFF);
  43.462 -    }
  43.463 -
  43.464 -    int getModifiers(int state) {
  43.465 -        int mods = 0;
  43.466 -        if ((state & XEMBED_MODIFIER_SHIFT) != 0) {
  43.467 -            mods |= InputEvent.SHIFT_DOWN_MASK;
  43.468 -        }
  43.469 -        if ((state & XEMBED_MODIFIER_CONTROL) != 0) {
  43.470 -            mods |= InputEvent.CTRL_DOWN_MASK;
  43.471 -        }
  43.472 -        if ((state & XEMBED_MODIFIER_ALT) != 0) {
  43.473 -            mods |= InputEvent.ALT_DOWN_MASK;
  43.474 -        }
  43.475 -        // FIXME: What is super/hyper?
  43.476 -        // FIXME: Experiments show that SUPER is ALT. So what is Alt then?
  43.477 -        if ((state & XEMBED_MODIFIER_SUPER) != 0) {
  43.478 -            mods |= InputEvent.ALT_DOWN_MASK;
  43.479 -        }
  43.480 -//         if ((state & XEMBED_MODIFIER_HYPER) != 0) {
  43.481 -//             mods |= InputEvent.DOWN_MASK;
  43.482 -//         }
  43.483 -        return mods;
  43.484 -    }
  43.485 -
  43.486 -    // Shouldn't be called on Toolkit thread.
  43.487 -    AWTKeyStroke getKeyStrokeForKeySym(long keysym, long state) {
  43.488 -
  43.489 -        int keycode = getAWTKeyCodeForKeySym((int)keysym);
  43.490 -        int modifiers = getModifiers((int)state);
  43.491 -        return AWTKeyStroke.getAWTKeyStroke(keycode, modifiers);
  43.492 -    }
  43.493 -    native int getAWTKeyCodeForKeySym(int keysym);
  43.494 -    native void sendMessage(int msg);
  43.495 -    native void sendMessage(int msg, long detail, long data1, long data2);
  43.496 -    MWindowPeer getParentWindow() {
  43.497 -        Component parent = target.getParent();
  43.498 -        synchronized(target.getTreeLock()) {
  43.499 -            while (parent != null && !(parent.getPeer() instanceof MWindowPeer)) {
  43.500 -                parent = parent.getParent();
  43.501 -            }
  43.502 -            return (parent != null)?(MWindowPeer)parent.getPeer():null;
  43.503 -        }
  43.504 -    }
  43.505 -
  43.506 -    private static class XEmbedDropTarget extends DropTarget {
  43.507 -        public void addDropTargetListener(DropTargetListener dtl)
  43.508 -          throws TooManyListenersException {
  43.509 -            // Drop target listeners registered with this target will never be
  43.510 -            // notified, since all drag notifications are routed to the XEmbed
  43.511 -            // client. To avoid confusion we prohibit listeners registration
  43.512 -            // by throwing TooManyListenersException as if there is a listener
  43.513 -            // registered with this target already.
  43.514 -            throw new TooManyListenersException();
  43.515 -        }
  43.516 -    }
  43.517 -
  43.518 -    public void setXEmbedDropTarget() {
  43.519 -        // Register a drop site on the top level.
  43.520 -        Runnable r = new Runnable() {
  43.521 -                public void run() {
  43.522 -                    target.setDropTarget(new XEmbedDropTarget());
  43.523 -                }
  43.524 -            };
  43.525 -        SunToolkit.executeOnEventHandlerThread(target, r);
  43.526 -    }
  43.527 -
  43.528 -    public void removeXEmbedDropTarget() {
  43.529 -        // Unregister a drop site on the top level.
  43.530 -        Runnable r = new Runnable() {
  43.531 -                public void run() {
  43.532 -                    if (target.getDropTarget() instanceof XEmbedDropTarget) {
  43.533 -                        target.setDropTarget(null);
  43.534 -                    }
  43.535 -                }
  43.536 -            };
  43.537 -        SunToolkit.executeOnEventHandlerThread(target, r);
  43.538 -    }
  43.539 -
  43.540 -    public boolean processXEmbedDnDEvent(long ctxt, int eventID) {
  43.541 -        if (target.getDropTarget() instanceof XEmbedDropTarget) {
  43.542 -            forwardEventToEmbedded(ctxt, eventID);
  43.543 -            return true;
  43.544 -        } else {
  43.545 -            return false;
  43.546 -        }
  43.547 -    }
  43.548 -
  43.549 -    native void forwardEventToEmbedded(long ctxt, int eventID);
  43.550 -    native void initXEmbedServer();
  43.551 -    native void destroyXEmbedServer();
  43.552 -    public native long getWindow();
  43.553 -}
  43.554 -class GrabbedKey {
  43.555 -    long keysym;
  43.556 -    long modifiers;
  43.557 -    GrabbedKey(long keysym, long modifiers) {
  43.558 -        this.keysym = keysym;
  43.559 -        this.modifiers = modifiers;
  43.560 -    }
  43.561 -
  43.562 -    GrabbedKey(KeyEvent ev) {
  43.563 -        init(ev);
  43.564 -    }
  43.565 -
  43.566 -    native void initKeySymAndModifiers(KeyEvent e);
  43.567 -
  43.568 -    private void init(KeyEvent e) {
  43.569 -        initKeySymAndModifiers(e);
  43.570 -    }
  43.571 -
  43.572 -    public int hashCode() {
  43.573 -        return (int)keysym & 0xFFFFFFFF;
  43.574 -    }
  43.575 -
  43.576 -    public boolean equals(Object o) {
  43.577 -        if (!(o instanceof GrabbedKey)) {
  43.578 -            return false;
  43.579 -        }
  43.580 -        GrabbedKey key = (GrabbedKey)o;
  43.581 -        return (keysym == key.keysym && modifiers == key.modifiers);
  43.582 -    }
  43.583 -
  43.584 -    public String toString() {
  43.585 -        return "Key combination[keysym=" + keysym + ", mods=" + modifiers + "]";
  43.586 -    }
  43.587 -}
    44.1 --- a/src/solaris/classes/sun/awt/motif/MEmbeddedFrame.java	Wed Sep 17 13:45:37 2008 -0700
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,141 +0,0 @@
    44.4 -/*
    44.5 - * Copyright 1996-2004 Sun Microsystems, Inc.  All Rights Reserved.
    44.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.7 - *
    44.8 - * This code is free software; you can redistribute it and/or modify it
    44.9 - * under the terms of the GNU General Public License version 2 only, as
   44.10 - * published by the Free Software Foundation.  Sun designates this
   44.11 - * particular file as subject to the "Classpath" exception as provided
   44.12 - * by Sun in the LICENSE file that accompanied this code.
   44.13 - *
   44.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   44.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   44.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   44.17 - * version 2 for more details (a copy is included in the LICENSE file that
   44.18 - * accompanied this code).
   44.19 - *
   44.20 - * You should have received a copy of the GNU General Public License version
   44.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   44.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   44.23 - *
   44.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   44.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   44.26 - * have any questions.
   44.27 - */
   44.28 -
   44.29 -package sun.awt.motif;
   44.30 -
   44.31 -import java.awt.Component;
   44.32 -import java.awt.peer.FramePeer;
   44.33 -import sun.awt.EmbeddedFrame;
   44.34 -import java.awt.peer.ComponentPeer;
   44.35 -import sun.awt.*;
   44.36 -import java.awt.*;
   44.37 -
   44.38 -public class MEmbeddedFrame extends EmbeddedFrame {
   44.39 -
   44.40 -    /**
   44.41 -     * Widget id of the shell widget
   44.42 -     */
   44.43 -    long handle;
   44.44 -
   44.45 -    public enum IDKind {
   44.46 -        WIDGET,
   44.47 -        WINDOW
   44.48 -    };
   44.49 -
   44.50 -    public MEmbeddedFrame() {
   44.51 -    }
   44.52 -
   44.53 -    /**
   44.54 -     * Backward-compatible implementation. This constructor takes widget which represents Frame's
   44.55 -     * shell and uses it as top-level to build hierarchy of top-level widgets upon. It assumes that
   44.56 -     * no XEmbed support is provided.
   44.57 -     * @param widget a valid Xt widget pointer.
   44.58 -     */
   44.59 -    public MEmbeddedFrame(long widget) {
   44.60 -        this(widget, IDKind.WIDGET, false);
   44.61 -    }
   44.62 -
   44.63 -    /**
   44.64 -     * New constructor, gets X Window id and allows to specify whether XEmbed is supported by parent
   44.65 -     * X window. Creates hierarchy of top-level widgets under supplied window ID.
   44.66 -     * @param winid a valid X window
   44.67 -     * @param supportsXEmbed whether the host application supports XEMBED protocol
   44.68 -     */
   44.69 -    public MEmbeddedFrame(long winid, boolean supportsXEmbed) {
   44.70 -        this(winid, IDKind.WINDOW, supportsXEmbed);
   44.71 -    }
   44.72 -
   44.73 -    /**
   44.74 -     * Creates embedded frame using ID as parent.
   44.75 -     * @param ID parent ID
   44.76 -     * @param supportsXEmbed whether the host application supports XEMBED protocol
   44.77 -     * @param kind if WIDGET, ID represents a valid Xt widget pointer; if WINDOW, ID is a valid X Window
   44.78 -     * ID
   44.79 -     */
   44.80 -    public MEmbeddedFrame(long ID, IDKind kind, boolean supportsXEmbed) {
   44.81 -        super(supportsXEmbed);
   44.82 -        if (kind == IDKind.WIDGET) {
   44.83 -            this.handle = ID;
   44.84 -        } else {
   44.85 -            this.handle = getWidget(ID);
   44.86 -        }
   44.87 -        MToolkit toolkit = (MToolkit)Toolkit.getDefaultToolkit();
   44.88 -        setPeer(toolkit.createEmbeddedFrame(this));
   44.89 -        /*
   44.90 -         * addNotify() creates a LightweightDispatcher that propagates
   44.91 -         * SunDropTargetEvents to subcomponents.
   44.92 -         * NOTE: show() doesn't call addNotify() for embedded frames.
   44.93 -         */
   44.94 -        addNotify();
   44.95 -        show();
   44.96 -    }
   44.97 -
   44.98 -    public void synthesizeWindowActivation(boolean b) {
   44.99 -        MEmbeddedFramePeer peer = (MEmbeddedFramePeer)getPeer();
  44.100 -        if (peer != null) {
  44.101 -            if (peer.supportsXEmbed()) {
  44.102 -                if (peer.isXEmbedActive()) {
  44.103 -                    // If XEmbed is active no synthetic focus events are allowed - everything
  44.104 -                    // should go through XEmbed
  44.105 -                    if (b) {
  44.106 -                        peer.requestXEmbedFocus();
  44.107 -                    }
  44.108 -                }
  44.109 -            } else {
  44.110 -                peer.synthesizeFocusInOut(b);
  44.111 -            }
  44.112 -        }
  44.113 -    }
  44.114 -
  44.115 -    public void show() {
  44.116 -        if (handle != 0) {
  44.117 -            mapWidget(handle);
  44.118 -        }
  44.119 -        super.show();
  44.120 -    }
  44.121 -
  44.122 -    protected boolean traverseOut(boolean direction) {
  44.123 -        MEmbeddedFramePeer xefp = (MEmbeddedFramePeer) getPeer();
  44.124 -        xefp.traverseOut(direction);
  44.125 -        return true;
  44.126 -    }
  44.127 -
  44.128 -    // Native methods to handle widget <-> X Windows mapping
  44.129 -    //
  44.130 -    static native long getWidget(long winid);
  44.131 -    static native int mapWidget(long widget);
  44.132 -    public void registerAccelerator(AWTKeyStroke stroke) {
  44.133 -        MEmbeddedFramePeer xefp = (MEmbeddedFramePeer) getPeer();
  44.134 -        if (xefp != null) {
  44.135 -            xefp.registerAccelerator(stroke);
  44.136 -        }
  44.137 -    }
  44.138 -    public void unregisterAccelerator(AWTKeyStroke stroke) {
  44.139 -        MEmbeddedFramePeer xefp = (MEmbeddedFramePeer) getPeer();
  44.140 -        if (xefp != null) {
  44.141 -            xefp.unregisterAccelerator(stroke);
  44.142 -        }
  44.143 -    }
  44.144 -}
    45.1 --- a/src/solaris/classes/sun/awt/motif/MEmbeddedFramePeer.java	Wed Sep 17 13:45:37 2008 -0700
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,213 +0,0 @@
    45.4 -/*
    45.5 - * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
    45.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    45.7 - *
    45.8 - * This code is free software; you can redistribute it and/or modify it
    45.9 - * under the terms of the GNU General Public License version 2 only, as
   45.10 - * published by the Free Software Foundation.  Sun designates this
   45.11 - * particular file as subject to the "Classpath" exception as provided
   45.12 - * by Sun in the LICENSE file that accompanied this code.
   45.13 - *
   45.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   45.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   45.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   45.17 - * version 2 for more details (a copy is included in the LICENSE file that
   45.18 - * accompanied this code).
   45.19 - *
   45.20 - * You should have received a copy of the GNU General Public License version
   45.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   45.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   45.23 - *
   45.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   45.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   45.26 - * have any questions.
   45.27 - */
   45.28 -
   45.29 -package sun.awt.motif;
   45.30 -
   45.31 -import sun.awt.EmbeddedFrame;
   45.32 -import java.util.logging.*;
   45.33 -import java.awt.Component;
   45.34 -import java.awt.Point;
   45.35 -import java.awt.Rectangle;
   45.36 -import java.awt.Window;
   45.37 -import java.awt.AWTKeyStroke;
   45.38 -import java.awt.Component;
   45.39 -import java.awt.Container;
   45.40 -import sun.awt.SunToolkit;
   45.41 -import java.util.LinkedList;
   45.42 -import java.util.Iterator;
   45.43 -
   45.44 -import sun.java2d.SurfaceData;
   45.45 -
   45.46 -public class MEmbeddedFramePeer extends MFramePeer {
   45.47 -    private static final Logger xembedLog = Logger.getLogger("sun.awt.motif.xembed.MEmbeddedFramePeer");
   45.48 -
   45.49 -//     A detail code is required for XEMBED_FOCUS_IN. The following values are valid:
   45.50 -/* Details for  XEMBED_FOCUS_IN: */
   45.51 -    final static int XEMBED_FOCUS_CURRENT       =       0;
   45.52 -    final static int XEMBED_FOCUS_FIRST         =       1;
   45.53 -    final static int XEMBED_FOCUS_LAST  =       2;
   45.54 -
   45.55 -    LinkedList<AWTKeyStroke> strokes = new LinkedList<AWTKeyStroke>();
   45.56 -
   45.57 -    public MEmbeddedFramePeer(EmbeddedFrame target) {
   45.58 -        super(target);
   45.59 -        xembedLog.fine("Creating XEmbed-enabled motif embedded frame, frame supports XEmbed:" + supportsXEmbed());
   45.60 -    }
   45.61 -
   45.62 -    void create(MComponentPeer parent) {
   45.63 -        NEFcreate(parent, ((MEmbeddedFrame)target).handle);
   45.64 -    }
   45.65 -    native void NEFcreate(MComponentPeer parent, long handle);
   45.66 -    native void pShowImpl();
   45.67 -    void pShow() {
   45.68 -        pShowImpl();
   45.69 -    }
   45.70 -
   45.71 -    boolean supportsXEmbed() {
   45.72 -        EmbeddedFrame frame = (EmbeddedFrame)target;
   45.73 -        if (frame != null) {
   45.74 -            return frame.supportsXEmbed();
   45.75 -        } else {
   45.76 -            return false;
   45.77 -        }
   45.78 -    }
   45.79 -
   45.80 -    public void setVisible(boolean vis) {
   45.81 -        super.setVisible(vis);
   45.82 -        xembedLog.fine("Peer made visible");
   45.83 -        if (vis && !supportsXEmbed()) {
   45.84 -            xembedLog.fine("Synthesizing FocusIn");
   45.85 -            // Fix for 4878303 - generate WINDOW_GAINED_FOCUS and update if we were focused
   45.86 -            // since noone will do it for us(WM does it for regular top-levels)
   45.87 -            synthesizeFocusInOut(true);
   45.88 -        }
   45.89 -    }
   45.90 -    public native void synthesizeFocusInOut(boolean b);
   45.91 -
   45.92 -    native boolean isXEmbedActive();
   45.93 -    native boolean isXEmbedApplicationActive();
   45.94 -    native void requestXEmbedFocus();
   45.95 -
   45.96 -    public boolean requestWindowFocus() {
   45.97 -        xembedLog.fine("In requestWindowFocus");
   45.98 -        // Should check for active state of host application
   45.99 -        if (isXEmbedActive()) {
  45.100 -            if (isXEmbedApplicationActive()) {
  45.101 -                xembedLog.fine("Requesting focus from embedding host");
  45.102 -                requestXEmbedFocus();
  45.103 -                return true;
  45.104 -            } else {
  45.105 -                xembedLog.fine("Host application is not active");
  45.106 -                return false;
  45.107 -            }
  45.108 -        } else {
  45.109 -            xembedLog.fine("Requesting focus from X");
  45.110 -            return super.requestWindowFocus();
  45.111 -        }
  45.112 -    }
  45.113 -
  45.114 -    void registerAccelerator(AWTKeyStroke stroke) {
  45.115 -//         if (stroke == null) return;
  45.116 -//         strokes.add(stroke);
  45.117 -//         if (isXEmbedActive()) {
  45.118 -//             nativeRegisterAccelerator(stroke, strokes.size()-1);
  45.119 -//         }
  45.120 -    }
  45.121 -
  45.122 -    void unregisterAccelerator(AWTKeyStroke stroke) {
  45.123 -//         if (stroke == null) return;
  45.124 -//         if (isXEmbedActive()) {
  45.125 -//             int index = strokes.indexOf(stroke);
  45.126 -//             nativeUnregisterAccelerator(index);
  45.127 -//         }
  45.128 -    }
  45.129 -
  45.130 -    void notifyStarted() {
  45.131 -        // Register accelerators
  45.132 -//         int i = 0;
  45.133 -//         Iterator<AWTKeyStroke> iter = strokes.iterator();
  45.134 -//         while (iter.hasNext()) {
  45.135 -//             nativeRegisterAccelerator(iter.next(), i++);
  45.136 -//         }
  45.137 -
  45.138 -        updateDropTarget();
  45.139 -    }
  45.140 -
  45.141 -    native void traverseOut(boolean direction);
  45.142 -
  45.143 -    void handleFocusIn(int detail) {
  45.144 -        xembedLog.log(Level.FINE, "handleFocusIn {0}", new Object[]{Integer.valueOf(detail)});
  45.145 -        switch(detail) {
  45.146 -          case XEMBED_FOCUS_CURRENT:
  45.147 -              // Do nothing - just restore to the current value
  45.148 -              break;
  45.149 -          case XEMBED_FOCUS_FIRST:
  45.150 -              SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
  45.151 -                      public void run() {
  45.152 -                          Component comp = ((Container)target).getFocusTraversalPolicy().getFirstComponent((Container)target);
  45.153 -                          if (comp != null) {
  45.154 -                              comp.requestFocusInWindow();
  45.155 -                          }
  45.156 -                      }});
  45.157 -              break;
  45.158 -          case XEMBED_FOCUS_LAST:
  45.159 -              SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
  45.160 -                      public void run() {
  45.161 -                          Component comp = ((Container)target).getFocusTraversalPolicy().getLastComponent((Container)target);
  45.162 -                          if (comp != null) {
  45.163 -                              comp.requestFocusInWindow();
  45.164 -                          }
  45.165 -                      }});
  45.166 -              break;
  45.167 -        }
  45.168 -    }
  45.169 -    public void handleWindowFocusIn() {
  45.170 -        super.handleWindowFocusIn();
  45.171 -        xembedLog.fine("windowFocusIn");
  45.172 -    }
  45.173 -    public void handleWindowFocusOut(Window oppositeWindow) {
  45.174 -        super.handleWindowFocusOut(oppositeWindow);
  45.175 -        xembedLog.fine("windowFocusOut, opposite is null?:" + (oppositeWindow==null));
  45.176 -    }
  45.177 -
  45.178 -    native void pReshapePrivate(int x, int y, int w, int h);
  45.179 -
  45.180 -    public void setBoundsPrivate(int x, int y, int width, int height)
  45.181 -    {
  45.182 -        if (disposed)
  45.183 -        {
  45.184 -            return;
  45.185 -        }
  45.186 -
  45.187 -        // Should set paintPending before reshape to prevent
  45.188 -        // thread race between PaintEvent and setBounds
  45.189 -        // This part of the 4267393 fix proved to be unstable under solaris,
  45.190 -        // dissabled due to regressions 4418155, 4486762, 4490079
  45.191 -        paintPending = false; //checkNativePaintOnSetBounds(width, height);
  45.192 -
  45.193 -        pReshapePrivate(x, y, width, height);
  45.194 -
  45.195 -        if ((width != oldWidth) || (height != oldHeight))
  45.196 -        {
  45.197 -            SurfaceData oldData = surfaceData;
  45.198 -            if (oldData != null) {
  45.199 -                surfaceData = graphicsConfig.createSurfaceData(this);
  45.200 -                oldData.invalidate();
  45.201 -            }
  45.202 -            oldWidth = width;
  45.203 -            oldHeight = height;
  45.204 -        }
  45.205 -        validateSurface(width, height);
  45.206 -        serialNum++;
  45.207 -    }
  45.208 -
  45.209 -    public native Rectangle getBoundsPrivate();
  45.210 -
  45.211 -    @Override
  45.212 -    Rectangle constrainBounds(int x, int y, int width, int height) {
  45.213 -        // We don't constrain the bounds of the EmbeddedFrames
  45.214 -        return new Rectangle(x, y, width, height);
  45.215 -    }
  45.216 -}
    46.1 --- a/src/solaris/classes/sun/awt/motif/MFileDialogPeer.java	Wed Sep 17 13:45:37 2008 -0700
    46.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.3 @@ -1,300 +0,0 @@
    46.4 -/*
    46.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
    46.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.7 - *
    46.8 - * This code is free software; you can redistribute it and/or modify it
    46.9 - * under the terms of the GNU General Public License version 2 only, as
   46.10 - * published by the Free Software Foundation.  Sun designates this
   46.11 - * particular file as subject to the "Classpath" exception as provided
   46.12 - * by Sun in the LICENSE file that accompanied this code.
   46.13 - *
   46.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   46.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   46.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   46.17 - * version 2 for more details (a copy is included in the LICENSE file that
   46.18 - * accompanied this code).
   46.19 - *
   46.20 - * You should have received a copy of the GNU General Public License version
   46.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   46.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   46.23 - *
   46.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   46.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   46.26 - * have any questions.
   46.27 - */
   46.28 -package sun.awt.motif;
   46.29 -
   46.30 -import java.awt.*;
   46.31 -import java.awt.peer.*;
   46.32 -import java.io.*;
   46.33 -import java.awt.datatransfer.*;
   46.34 -import java.util.ArrayList;
   46.35 -import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
   46.36 -
   46.37 -public class MFileDialogPeer extends MDialogPeer implements FileDialogPeer {
   46.38 -    private FilenameFilter filter;
   46.39 -    private String[] NativeFilteredFiles;
   46.40 -    native void create(MComponentPeer parent);
   46.41 -    void create(MComponentPeer parent, Object arg) {
   46.42 -        create(parent);
   46.43 -    }
   46.44 -    public MFileDialogPeer(FileDialog target) {
   46.45 -        super(target);
   46.46 -        FileDialog      fdialog = (FileDialog)target;
   46.47 -        String          dir = fdialog.getDirectory();
   46.48 -        String          file = fdialog.getFile();
   46.49 -        FilenameFilter  filter = fdialog.getFilenameFilter();
   46.50 -
   46.51 -        insets = new Insets(0, 0, 0, 0);
   46.52 -        setDirectory(dir);
   46.53 -        if (file != null) {
   46.54 -            setFile(file);
   46.55 -        }
   46.56 -            setFilenameFilter(filter);
   46.57 -    }
   46.58 -    native void         pReshape(int x, int y, int width, int height);
   46.59 -    native void         pDispose();
   46.60 -    native void         pShow();
   46.61 -    native void         pHide();
   46.62 -    native void         setFileEntry(String dir, String file, String[] ffiles);
   46.63 -    native void insertReplaceFileDialogText(String l);
   46.64 -    public native void  setFont(Font f);
   46.65 -
   46.66 -    String getFilteredFile(String file) {
   46.67 -        if (file == null) {
   46.68 -            file = ((FileDialog)target).getFile();
   46.69 -        }
   46.70 -        String dir = ((FileDialog)target).getDirectory();
   46.71 -        if (dir == null) {
   46.72 -            dir = "./";
   46.73 -        }
   46.74 -        if (file == null) {
   46.75 -            file = "";
   46.76 -        }
   46.77 -        if (filter != null && !filter.accept(new File(dir), file)) {
   46.78 -            file = "";
   46.79 -        }
   46.80 -        return file;
   46.81 -    }
   46.82 -    // NOTE: This method is called by privileged threads.
   46.83 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   46.84 -    public void         handleSelected(final String file) {
   46.85 -        final FileDialog fileDialog = (FileDialog)target;
   46.86 -        MToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() {
   46.87 -            public void run() {
   46.88 -                int index = file.lastIndexOf(java.io.File.separatorChar);/*2509*//*ibm*/
   46.89 -                String dir;
   46.90 -
   46.91 -                if (index == -1) {
   46.92 -                    dir = "."+java.io.File.separator;
   46.93 -                    fileDialog.setFile(file);
   46.94 -                } else {
   46.95 -                    dir = file.substring(0, index + 1);
   46.96 -                    fileDialog.setFile(file.substring(index + 1));
   46.97 -                }
   46.98 -                fileDialog.setDirectory(dir);
   46.99 -                fileDialog.hide();
  46.100 -            }
  46.101 -        });
  46.102 -    } // handleSelected()
  46.103 -
  46.104 -    // NOTE: This method is called by privileged threads.
  46.105 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  46.106 -    public void         handleCancel() {
  46.107 -        final FileDialog fileDialog = (FileDialog)target;
  46.108 -        MToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() {
  46.109 -            public void run() {
  46.110 -                fileDialog.setFile(null);
  46.111 -                fileDialog.hide();
  46.112 -            }
  46.113 -        });
  46.114 -    } // handleCancel()
  46.115 -
  46.116 -    // NOTE: This method is called by privileged threads.
  46.117 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  46.118 -    public void         handleQuit() {
  46.119 -        final FileDialog fileDialog = (FileDialog)target;
  46.120 -        MToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() {
  46.121 -            public void run() {
  46.122 -                fileDialog.hide();
  46.123 -            }
  46.124 -        });
  46.125 -    } // handleQuit()
  46.126 -
  46.127 -    public  void setDirectory(String dir) {
  46.128 -        String file = ((FileDialog)target).getFile();
  46.129 -        setFileEntry((dir != null) ? dir : "./", (file != null) ? file
  46.130 -                     : "", null);
  46.131 -    }
  46.132 -
  46.133 -
  46.134 -    public  void setFile(String file) {
  46.135 -        String dir = ((FileDialog)target).getDirectory();
  46.136 -        if (dir == null) {
  46.137 -            dir = "./";
  46.138 -        }
  46.139 -        setFileEntry((dir != null) ? dir : "./", getFilteredFile(null), null);
  46.140 -    }
  46.141 -    class DirectoryFilter implements FilenameFilter {
  46.142 -        FilenameFilter userFilter;
  46.143 -        DirectoryFilter(FilenameFilter userFilter) {
  46.144 -            this.userFilter = userFilter;
  46.145 -        }
  46.146 -        public boolean accept(File parent, String name) {
  46.147 -            File toTest = new File(parent, name);
  46.148 -            if (toTest.isDirectory()) {
  46.149 -                return false;
  46.150 -            } else if (userFilter != null) {
  46.151 -                return userFilter.accept(parent, name);
  46.152 -            } else {
  46.153 -                return true;
  46.154 -            }
  46.155 -        }
  46.156 -    }
  46.157 -    public void doFilter(FilenameFilter filter, String dir) {
  46.158 -        String d = (dir == null) ? (((FileDialog)target).getDirectory()):(dir);
  46.159 -        String f = getFilteredFile(null);
  46.160 -        File df = new File((d != null) ? d : ".");
  46.161 -        String[] files = df.list(new DirectoryFilter(filter));
  46.162 -        String[] nffiles = NativeFilteredFiles;
  46.163 -
  46.164 -        // At this point we have two file lists.
  46.165 -        // The first one is a filtered list of files that we retrieve
  46.166 -        // by using Java code and Java filter.
  46.167 -        // The second one is a filtered list of files that we retrieve
  46.168 -        // by using the native code and native pattern.
  46.169 -        // We should find an intersection of these two lists. The result
  46.170 -        // will be exactly what we expect to see in setFileEntry.
  46.171 -        // For more details please see 4784704.
  46.172 -        if ( files != null ) {
  46.173 -            ArrayList filearr = new ArrayList();
  46.174 -            if (nffiles != null) {
  46.175 -                for (int j = 0; j < files.length; j++) {
  46.176 -                    for (int n = 0; n < nffiles.length; n++) {
  46.177 -                        if (files[j].equals(nffiles[n])) {
  46.178 -                            filearr.add(files[j]);
  46.179 -                            break;
  46.180 -                        }
  46.181 -                    }
  46.182 -                }
  46.183 -            }
  46.184 -            files = new String[filearr.size()];
  46.185 -            for (int i = 0; i < files.length; i++) {
  46.186 -                files[i] = (String)filearr.get(i);
  46.187 -            }
  46.188 -        }
  46.189 -        if (files == null || files.length == 0) {
  46.190 -            files = new String[1];
  46.191 -            files[0] = "";
  46.192 -        }
  46.193 -        setFileEntry((d != null) ? d : ".", (f != null) ? f : "", files);
  46.194 -    }
  46.195 -    private boolean proceedFiltering(final String dir, String[] nffiles,
  46.196 -                                     boolean isPrivileged)
  46.197 -    {
  46.198 -        // Transfer the native filtered file list to the doFilter method.
  46.199 -        NativeFilteredFiles = nffiles;
  46.200 -        // If we are not on the Toolkit thread we can call doFilter() directly.
  46.201 -        // If the filter is null no user code will be invoked
  46.202 -        if (!isPrivileged || filter == null) {
  46.203 -            try {
  46.204 -                doFilter(filter, dir);
  46.205 -                return true;
  46.206 -            } catch(Exception e) {
  46.207 -                e.printStackTrace();
  46.208 -                return false;
  46.209 -            }
  46.210 -        }
  46.211 -        // Otherwise we have to call user code on EvenDispatchThread
  46.212 -        final ToolkitThreadBlockedHandler priveleged_lock =
  46.213 -            MToolkitThreadBlockedHandler.getToolkitThreadBlockedHandler();
  46.214 -        final boolean[] finished = new boolean[1];
  46.215 -        final boolean[] result = new boolean[1];
  46.216 -        finished[0] = false;
  46.217 -        result[0] = false;
  46.218 -
  46.219 -
  46.220 -        // Use the same Toolkit blocking mechanism as in DnD.
  46.221 -        priveleged_lock.lock();
  46.222 -
  46.223 -        MToolkit.executeOnEventHandlerThread((FileDialog)target, new Runnable() {
  46.224 -            public void run() {
  46.225 -                priveleged_lock.lock();
  46.226 -                try {
  46.227 -                    doFilter(filter, dir);
  46.228 -                    result[0] = true;
  46.229 -                } catch (Exception e) {
  46.230 -                    e.printStackTrace();
  46.231 -                    result[0] = false;
  46.232 -                } finally {
  46.233 -                    finished[0] = true;
  46.234 -                    priveleged_lock.exit();
  46.235 -                    priveleged_lock.unlock();
  46.236 -                }
  46.237 -            }
  46.238 -        });
  46.239 -
  46.240 -        while (!finished[0]) {
  46.241 -            priveleged_lock.enter();
  46.242 -        }
  46.243 -
  46.244 -        priveleged_lock.unlock();
  46.245 -
  46.246 -        return result[0];
  46.247 -    }
  46.248 -
  46.249 -    public void setFilenameFilter(FilenameFilter filter) {
  46.250 -        this.filter = filter;
  46.251 -        FileDialog      fdialog = (FileDialog)target;
  46.252 -        String          dir = fdialog.getDirectory();
  46.253 -        String          file = fdialog.getFile();
  46.254 -        setFile(file);
  46.255 -        doFilter(filter, null);
  46.256 -    }
  46.257 -
  46.258 -    // Called from native widget when paste key is pressed and we
  46.259 -    // already own the selection (prevents Motif from hanging while
  46.260 -    // waiting for the selection)
  46.261 -    //
  46.262 -    public void pasteFromClipboard() {
  46.263 -        Clipboard clipboard = target.getToolkit().getSystemClipboard();
  46.264 -
  46.265 -        Transferable content = clipboard.getContents(this);
  46.266 -        if (content != null) {
  46.267 -            try {
  46.268 -                String data = (String)(content.getTransferData(DataFlavor.stringFlavor));
  46.269 -                insertReplaceFileDialogText(data);
  46.270 -            } catch (Exception e) {
  46.271 -            }
  46.272 -        }
  46.273 -    }
  46.274 -
  46.275 -// CAVEAT:
  46.276 -// Peer coalescing code turned over the fact that the following functions
  46.277 -// were being inherited from Dialog and were not implemented in awt_FileDialog.c
  46.278 -// Five methods decribed by the peer interface are at fault (setResizable, setTitle,
  46.279 -// toFront, toBack and handleFocusTraversalEvent).  Additionally show has to be overridden
  46.280 -// as it was necessary to add a show function in MDialogPeer for modality flag passing.
  46.281 -// As a result we were winding up in  awt_Dialog.c (now coalesced into awt_TopLevel).
  46.282 -// As Filedialogs are modal and its unclear to me that any of these functions
  46.283 -// can be called while the FD is on-screen let it go.  RJM.
  46.284 -    public void show() {
  46.285 -        // must have our own show or we wind up in pShow for Window. Bad. Very bad.
  46.286 -        setVisible(true);
  46.287 -        setFilenameFilter(filter);
  46.288 -    }
  46.289 -
  46.290 -    /**
  46.291 -     * MFileDialogPeer doesn't have native pData so we don't do restack on it
  46.292 -     * @see java.awt.peer.ContainerPeer#restack
  46.293 -     */
  46.294 -    public void restack() {
  46.295 -    }
  46.296 -
  46.297 -    /**
  46.298 -     * @see java.awt.peer.ContainerPeer#isRestackSupported
  46.299 -     */
  46.300 -    public boolean isRestackSupported() {
  46.301 -        return false;
  46.302 -    }
  46.303 -}
    47.1 --- a/src/solaris/classes/sun/awt/motif/MFramePeer.java	Wed Sep 17 13:45:37 2008 -0700
    47.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.3 @@ -1,511 +0,0 @@
    47.4 -/*
    47.5 - * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
    47.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    47.7 - *
    47.8 - * This code is free software; you can redistribute it and/or modify it
    47.9 - * under the terms of the GNU General Public License version 2 only, as
   47.10 - * published by the Free Software Foundation.  Sun designates this
   47.11 - * particular file as subject to the "Classpath" exception as provided
   47.12 - * by Sun in the LICENSE file that accompanied this code.
   47.13 - *
   47.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   47.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   47.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   47.17 - * version 2 for more details (a copy is included in the LICENSE file that
   47.18 - * accompanied this code).
   47.19 - *
   47.20 - * You should have received a copy of the GNU General Public License version
   47.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   47.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   47.23 - *
   47.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   47.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   47.26 - * have any questions.
   47.27 - */
   47.28 -package sun.awt.motif;
   47.29 -
   47.30 -import java.util.Vector;
   47.31 -import java.awt.*;
   47.32 -import java.awt.peer.*;
   47.33 -import java.awt.event.*;
   47.34 -import sun.awt.motif.MInputMethodControl;
   47.35 -import sun.awt.im.*;
   47.36 -import java.awt.image.ColorModel;
   47.37 -import java.awt.image.BufferedImage;
   47.38 -import java.awt.image.DataBuffer;
   47.39 -import java.awt.image.DataBufferInt;
   47.40 -import java.awt.image.DataBufferByte;
   47.41 -import java.awt.image.DataBufferUShort;
   47.42 -import java.awt.image.ImageObserver;
   47.43 -import java.awt.image.WritableRaster;
   47.44 -import sun.awt.image.ImageRepresentation;
   47.45 -import sun.awt.image.ToolkitImage;
   47.46 -
   47.47 -class MFramePeer extends MWindowPeer implements FramePeer, MInputMethodControl {
   47.48 -    static Vector allFrames = new Vector();
   47.49 -
   47.50 -    // XXX: Stub out for now.  Need to propagate to normal size hints.
   47.51 -    public void setMaximizedBounds(Rectangle b) {}
   47.52 -
   47.53 -    public void create(MComponentPeer parent, Object arg) {
   47.54 -        super.create( parent );
   47.55 -    }
   47.56 -
   47.57 -    MFramePeer(Frame target) {
   47.58 -        super();
   47.59 -        // set the window attributes for this Frame
   47.60 -        winAttr.nativeDecor = !target.isUndecorated();
   47.61 -        winAttr.initialFocus = true;
   47.62 -        winAttr.isResizable =  target.isResizable();
   47.63 -        winAttr.initialState = target.getState();
   47.64 -        winAttr.title = target.getTitle();
   47.65 -        winAttr.icon = target.getIconImage();
   47.66 -        if (winAttr.nativeDecor) {
   47.67 -            winAttr.decorations = winAttr.AWT_DECOR_ALL;
   47.68 -        } else {
   47.69 -            winAttr.decorations = winAttr.AWT_DECOR_NONE;
   47.70 -        }
   47.71 -
   47.72 -        // for input method windows, use minimal decorations
   47.73 -        if (target instanceof InputMethodWindow) {
   47.74 -            winAttr.initialFocus = false;
   47.75 -            winAttr.decorations = (winAttr.AWT_DECOR_TITLE | winAttr.AWT_DECOR_BORDER);
   47.76 -        }
   47.77 -
   47.78 -        // create and init native component
   47.79 -        init( target);
   47.80 -    if (winAttr.icon != null) {
   47.81 -        setIconImage(winAttr.icon);
   47.82 -    }
   47.83 -        allFrames.addElement(this);
   47.84 -    }
   47.85 -
   47.86 -    public void setTitle(String title) {
   47.87 -        pSetTitle(title);
   47.88 -    }
   47.89 -
   47.90 -    protected void disposeImpl() {
   47.91 -        allFrames.removeElement(this);
   47.92 -        super.disposeImpl();
   47.93 -    }
   47.94 -
   47.95 -    public void setMenuBar(MenuBar mb) {
   47.96 -        MMenuBarPeer mbpeer = (MMenuBarPeer) MToolkit.targetToPeer(mb);
   47.97 -        pSetMenuBar(mbpeer);
   47.98 -
   47.99 -        Rectangle r = target.bounds();
  47.100 -
  47.101 -        pReshape(r.x, r.y, r.width, r.height);
  47.102 -        if (target.isVisible()) {
  47.103 -            target.validate();
  47.104 -        }
  47.105 -    }
  47.106 -
  47.107 -    public void setIconImage(Image im) {
  47.108 -        int width;
  47.109 -        int height;
  47.110 -        GraphicsConfiguration defaultGC;
  47.111 -        if (im != null) {  // 4633887  Avoid Null pointer exception.
  47.112 -        if (im instanceof ToolkitImage) {
  47.113 -            ImageRepresentation ir = ((ToolkitImage)im).getImageRep();
  47.114 -            ir.reconstruct(ImageObserver.ALLBITS);
  47.115 -            width = ir.getWidth();
  47.116 -            height = ir.getHeight();
  47.117 -        }
  47.118 -        else {
  47.119 -            width = im.getWidth(null);
  47.120 -            height = im.getHeight(null);
  47.121 -        }
  47.122 -        if (pGetIconSize(width, height)) {
  47.123 -            //Icons are displayed using the default visual, so create image
  47.124 -            //using default GraphicsConfiguration
  47.125 -            defaultGC = getGraphicsConfiguration().getDevice().
  47.126 -                getDefaultConfiguration();
  47.127 -            ColorModel model = defaultGC.getColorModel();
  47.128 -            WritableRaster raster =
  47.129 -                model.createCompatibleWritableRaster(iconWidth, iconHeight);
  47.130 -            Image image = new BufferedImage(model, raster,
  47.131 -                                            model.isAlphaPremultiplied(),
  47.132 -                                            null);
  47.133 -
  47.134 -            // ARGB BufferedImage to hunt for transparent pixels
  47.135 -            BufferedImage bimage =
  47.136 -                new BufferedImage(iconWidth, iconHeight,
  47.137 -                                  BufferedImage.TYPE_INT_ARGB);
  47.138 -            ColorModel alphaCheck = bimage.getColorModel();
  47.139 -            Graphics g = image.getGraphics();
  47.140 -            Graphics big = bimage.getGraphics();
  47.141 -            try {
  47.142 -                g.drawImage(im, 0, 0, iconWidth, iconHeight, null);
  47.143 -                big.drawImage(im, 0, 0, iconWidth, iconHeight, null);
  47.144 -            } finally {
  47.145 -                g.dispose();
  47.146 -                big.dispose();
  47.147 -            }
  47.148 -
  47.149 -            DataBuffer db = ((BufferedImage)image).getRaster().getDataBuffer();
  47.150 -            DataBuffer bidb = bimage.getRaster().getDataBuffer();
  47.151 -            byte[] bytedata = null;
  47.152 -            int[] intdata = null;
  47.153 -            int bidbLen = bidb.getSize();
  47.154 -            int imgDataIdx;
  47.155 -            //Get native RGB value for window background color
  47.156 -            //Should work for byte as well as int
  47.157 -            int bgRGB = getNativeColor(SystemColor.window, defaultGC);
  47.158 -
  47.159 -            /* My first attempt at a solution to bug 4175560 was to use
  47.160 -             * the iconMask and iconPixmap attributes of Windows.
  47.161 -             * This worked fine on CDE/dtwm, however olwm displayed only
  47.162 -             * single color icons (white on background).  Instead, the
  47.163 -             * fix gets the default background window color and replaces
  47.164 -             * transparent pixels in the icon image with this color.  This
  47.165 -             * solutions works well with dtwm as well as olwm.
  47.166 -             */
  47.167 -
  47.168 -            for (imgDataIdx = 0; imgDataIdx < bidbLen; imgDataIdx++) {
  47.169 -                if (alphaCheck.getAlpha(bidb.getElem(imgDataIdx)) == 0 ) {
  47.170 -                    //Assuming single data bank
  47.171 -                    db.setElem(imgDataIdx, bgRGB);
  47.172 -                }
  47.173 -            }
  47.174 -            short[] ushortdata = null;
  47.175 -            if (db instanceof DataBufferByte) {
  47.176 -                // Pseudocolor data
  47.177 -                bytedata = ((DataBufferByte)db).getData();
  47.178 -            }
  47.179 -            else if (db instanceof DataBufferInt) {
  47.180 -                // Truecolor data
  47.181 -                intdata = ((DataBufferInt) db).getData();
  47.182 -            }
  47.183 -            else if (db instanceof DataBufferUShort) {
  47.184 -                // Truecolor data
  47.185 -                ushortdata = ((DataBufferUShort) db).getData();
  47.186 -            }
  47.187 -               pSetIconImage(bytedata, intdata, ushortdata,
  47.188 -                          iconWidth, iconHeight);
  47.189 -        }
  47.190 -        }
  47.191 -    }
  47.192 -
  47.193 -    native boolean pGetIconSize(int widthHint, int heightHint);
  47.194 -
  47.195 -    // [jk] added ushortData for 16-bpp displays
  47.196 -    native void pSetIconImage(byte[] byteData,
  47.197 -                              int[] intData,
  47.198 -                              short[] ushortData,
  47.199 -                              int iconWidth, int iconHeight);
  47.200 -
  47.201 -    // NOTE: This method may be called by privileged threads.
  47.202 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  47.203 -    public void handleIconify() {
  47.204 -        postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED));
  47.205 -    }
  47.206 -
  47.207 -    // NOTE: This method may be called by privileged threads.
  47.208 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  47.209 -    public void handleDeiconify() {
  47.210 -        postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED));
  47.211 -    }
  47.212 -
  47.213 -
  47.214 -    /**
  47.215 -     * Called to inform the Frame that it has moved.
  47.216 -     */
  47.217 -    // NOTE: This method may be called by privileged threads.
  47.218 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  47.219 -    public void handleMoved(int x, int y) {
  47.220 -        postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
  47.221 -    }
  47.222 -
  47.223 -    static final int CROSSHAIR_INSET = 5;
  47.224 -
  47.225 -    static final int BUTTON_Y = CROSSHAIR_INSET + 1;
  47.226 -    static final int BUTTON_W = 17;
  47.227 -    static final int BUTTON_H = 17;
  47.228 -
  47.229 -    static final int SYS_MENU_X = CROSSHAIR_INSET + 1;
  47.230 -    static final int SYS_MENU_CONTAINED_X = SYS_MENU_X + 5;
  47.231 -    static final int SYS_MENU_CONTAINED_Y = BUTTON_Y + 7;
  47.232 -    static final int SYS_MENU_CONTAINED_W = 8;
  47.233 -    static final int SYS_MENU_CONTAINED_H = 3;
  47.234 -
  47.235 -    static final int MAXIMIZE_X_DIFF = CROSSHAIR_INSET + BUTTON_W;
  47.236 -    static final int MAXIMIZE_CONTAINED_X_DIFF = MAXIMIZE_X_DIFF - 5;
  47.237 -    static final int MAXIMIZE_CONTAINED_Y = BUTTON_Y + 5;
  47.238 -    static final int MAXIMIZE_CONTAINED_W = 8;
  47.239 -    static final int MAXIMIZE_CONTAINED_H = 8;
  47.240 -
  47.241 -    static final int MINIMIZE_X_DIFF = MAXIMIZE_X_DIFF + BUTTON_W;
  47.242 -    static final int MINIMIZE_CONTAINED_X_DIFF = MINIMIZE_X_DIFF - 7;
  47.243 -    static final int MINIMIZE_CONTAINED_Y = BUTTON_Y + 7;
  47.244 -    static final int MINIMIZE_CONTAINED_W = 3;
  47.245 -    static final int MINIMIZE_CONTAINED_H = 3;
  47.246 -
  47.247 -    static final int TITLE_X = SYS_MENU_X + BUTTON_W;
  47.248 -    static final int TITLE_W_DIFF = BUTTON_W * 3 + CROSSHAIR_INSET * 2 - 1;
  47.249 -    static final int TITLE_MID_Y = BUTTON_Y + (BUTTON_H / 2);
  47.250 -
  47.251 -    static final int MENUBAR_X = CROSSHAIR_INSET + 1;
  47.252 -    static final int MENUBAR_Y = BUTTON_Y + BUTTON_H;
  47.253 -
  47.254 -    static final int HORIZ_RESIZE_INSET = CROSSHAIR_INSET + BUTTON_H;
  47.255 -    static final int VERT_RESIZE_INSET = CROSSHAIR_INSET + BUTTON_W;
  47.256 -
  47.257 -
  47.258 -    /*
  47.259 -     * Print the native component by rendering the Motif look ourselves.
  47.260 -     * We also explicitly print the MenuBar since a MenuBar isn't a subclass
  47.261 -     * of Component (and thus it has no "print" method which gets called by
  47.262 -     * default).
  47.263 -     */
  47.264 -    public void print(Graphics g) {
  47.265 -        super.print(g);
  47.266 -
  47.267 -        Frame f = (Frame)target;
  47.268 -        Insets finsets = f.getInsets();
  47.269 -        Dimension fsize = f.getSize();
  47.270 -
  47.271 -        Color bg = f.getBackground();
  47.272 -        Color fg = f.getForeground();
  47.273 -        Color highlight = bg.brighter();
  47.274 -        Color shadow = bg.darker();
  47.275 -
  47.276 -        // Well, we could query for the currently running window manager
  47.277 -        // and base the look on that, or we could just always do dtwm.
  47.278 -        // aim, tball, and levenson all agree we'll just do dtwm.
  47.279 -
  47.280 -        if (hasDecorations(MWindowAttributes.AWT_DECOR_BORDER)) {
  47.281 -
  47.282 -            // top outer -- because we'll most likely be drawing on white paper,
  47.283 -            // for aesthetic reasons, don't make any part of the outer border
  47.284 -            // pure white
  47.285 -            if (highlight.equals(Color.white)) {
  47.286 -                g.setColor(new Color(230, 230, 230));
  47.287 -            }
  47.288 -            else {
  47.289 -                g.setColor(highlight);
  47.290 -            }
  47.291 -            g.drawLine(0, 0, fsize.width, 0);
  47.292 -            g.drawLine(0, 1, fsize.width - 1, 1);
  47.293 -
  47.294 -            // left outer
  47.295 -            // if (highlight.equals(Color.white)) {
  47.296 -            //     g.setColor(new Color(230, 230, 230));
  47.297 -            // }
  47.298 -            // else {
  47.299 -            //     g.setColor(highlight);
  47.300 -            // }
  47.301 -            g.drawLine(0, 0, 0, fsize.height);
  47.302 -            g.drawLine(1, 0, 1, fsize.height - 1);
  47.303 -
  47.304 -            // bottom cross-hair
  47.305 -            g.setColor(highlight);
  47.306 -            g.drawLine(CROSSHAIR_INSET + 1, fsize.height - CROSSHAIR_INSET,
  47.307 -                       fsize.width - CROSSHAIR_INSET,
  47.308 -                       fsize.height - CROSSHAIR_INSET);
  47.309 -
  47.310 -            // right cross-hair
  47.311 -            // g.setColor(highlight);
  47.312 -            g.drawLine(fsize.width - CROSSHAIR_INSET, CROSSHAIR_INSET + 1,
  47.313 -                       fsize.width - CROSSHAIR_INSET,
  47.314 -                       fsize.height - CROSSHAIR_INSET);
  47.315 -
  47.316 -            // bottom outer
  47.317 -            g.setColor(shadow);
  47.318 -            g.drawLine(1, fsize.height, fsize.width, fsize.height);
  47.319 -            g.drawLine(2, fsize.height - 1, fsize.width, fsize.height - 1);
  47.320 -
  47.321 -            // right outer
  47.322 -            // g.setColor(shadow);
  47.323 -            g.drawLine(fsize.width, 1, fsize.width, fsize.height);
  47.324 -            g.drawLine(fsize.width - 1, 2, fsize.width - 1, fsize.height);
  47.325 -
  47.326 -            // top cross-hair
  47.327 -            // g.setColor(shadow);
  47.328 -            g.drawLine(CROSSHAIR_INSET, CROSSHAIR_INSET,
  47.329 -                       fsize.width - CROSSHAIR_INSET, CROSSHAIR_INSET);
  47.330 -
  47.331 -            // left cross-hair
  47.332 -            // g.setColor(shadow);
  47.333 -            g.drawLine(CROSSHAIR_INSET, CROSSHAIR_INSET, CROSSHAIR_INSET,
  47.334 -                   fsize.height - CROSSHAIR_INSET);
  47.335 -        }
  47.336 -
  47.337 -        if (hasDecorations(MWindowAttributes.AWT_DECOR_TITLE)) {
  47.338 -
  47.339 -            if (hasDecorations(MWindowAttributes.AWT_DECOR_MENU)) {
  47.340 -
  47.341 -                // system menu
  47.342 -                g.setColor(bg);
  47.343 -                g.fill3DRect(SYS_MENU_X, BUTTON_Y, BUTTON_W, BUTTON_H, true);
  47.344 -                g.fill3DRect(SYS_MENU_CONTAINED_X, SYS_MENU_CONTAINED_Y,
  47.345 -                             SYS_MENU_CONTAINED_W, SYS_MENU_CONTAINED_H, true);
  47.346 -            }
  47.347 -
  47.348 -            // title bar
  47.349 -            // g.setColor(bg);
  47.350 -            g.fill3DRect(TITLE_X, BUTTON_Y, fsize.width - TITLE_W_DIFF, BUTTON_H,
  47.351 -                         true);
  47.352 -
  47.353 -            if (hasDecorations(MWindowAttributes.AWT_DECOR_MINIMIZE)) {
  47.354 -
  47.355 -                // minimize button
  47.356 -                // g.setColor(bg);
  47.357 -                g.fill3DRect(fsize.width - MINIMIZE_X_DIFF, BUTTON_Y, BUTTON_W,
  47.358 -                             BUTTON_H, true);
  47.359 -                g.fill3DRect(fsize.width - MINIMIZE_CONTAINED_X_DIFF,
  47.360 -                             MINIMIZE_CONTAINED_Y, MINIMIZE_CONTAINED_W,
  47.361 -                             MINIMIZE_CONTAINED_H, true);
  47.362 -            }
  47.363 -
  47.364 -            if (hasDecorations(MWindowAttributes.AWT_DECOR_MAXIMIZE)) {
  47.365 -
  47.366 -                // maximize button
  47.367 -                // g.setColor(bg);
  47.368 -                g.fill3DRect(fsize.width - MAXIMIZE_X_DIFF, BUTTON_Y, BUTTON_W,
  47.369 -                             BUTTON_H, true);
  47.370 -                g.fill3DRect(fsize.width - MAXIMIZE_CONTAINED_X_DIFF,
  47.371 -                             MAXIMIZE_CONTAINED_Y, MAXIMIZE_CONTAINED_W,
  47.372 -                             MAXIMIZE_CONTAINED_H, true);
  47.373 -            }
  47.374 -
  47.375 -            // title bar text
  47.376 -            g.setColor(fg);
  47.377 -            Font sysfont = new Font(Font.SANS_SERIF, Font.PLAIN, 10);
  47.378 -            g.setFont(sysfont);
  47.379 -            FontMetrics sysfm = g.getFontMetrics();
  47.380 -            String ftitle = f.getTitle();
  47.381 -            g.drawString(ftitle,
  47.382 -                         ((TITLE_X + TITLE_X + fsize.width - TITLE_W_DIFF) / 2) -
  47.383 -                         (sysfm.stringWidth(ftitle) / 2),
  47.384 -                         TITLE_MID_Y + sysfm.getMaxDescent());
  47.385 -        }
  47.386 -
  47.387 -        if (f.isResizable() &&
  47.388 -            hasDecorations(MWindowAttributes.AWT_DECOR_RESIZEH)) {
  47.389 -
  47.390 -            // add resize cross hairs
  47.391 -
  47.392 -            // upper-left horiz (shadow)
  47.393 -            g.setColor(shadow);
  47.394 -            g.drawLine(1, HORIZ_RESIZE_INSET, CROSSHAIR_INSET,
  47.395 -                       HORIZ_RESIZE_INSET);
  47.396 -            // upper-left vert (shadow)
  47.397 -            // g.setColor(shadow);
  47.398 -            g.drawLine(VERT_RESIZE_INSET, 1, VERT_RESIZE_INSET, CROSSHAIR_INSET);
  47.399 -            // upper-right horiz (shadow)
  47.400 -            // g.setColor(shadow);
  47.401 -            g.drawLine(fsize.width - CROSSHAIR_INSET + 1, HORIZ_RESIZE_INSET,
  47.402 -                       fsize.width, HORIZ_RESIZE_INSET);
  47.403 -            // upper-right vert (shadow)
  47.404 -            // g.setColor(shadow);
  47.405 -            g.drawLine(fsize.width - VERT_RESIZE_INSET - 1, 2,
  47.406 -                       fsize.width - VERT_RESIZE_INSET - 1, CROSSHAIR_INSET + 1);
  47.407 -            // lower-left horiz (shadow)
  47.408 -            // g.setColor(shadow);
  47.409 -            g.drawLine(1, fsize.height - HORIZ_RESIZE_INSET - 1,
  47.410 -                       CROSSHAIR_INSET, fsize.height - HORIZ_RESIZE_INSET - 1);
  47.411 -            // lower-left vert (shadow)
  47.412 -            // g.setColor(shadow);
  47.413 -            g.drawLine(VERT_RESIZE_INSET, fsize.height - CROSSHAIR_INSET + 1,
  47.414 -                       VERT_RESIZE_INSET, fsize.height);
  47.415 -            // lower-right horiz (shadow)
  47.416 -            // g.setColor(shadow);
  47.417 -            g.drawLine(fsize.width - CROSSHAIR_INSET + 1,
  47.418 -                       fsize.height - HORIZ_RESIZE_INSET - 1, fsize.width,
  47.419 -                       fsize.height - HORIZ_RESIZE_INSET - 1);
  47.420 -            // lower-right vert (shadow)
  47.421 -            // g.setColor(shadow);
  47.422 -            g.drawLine(fsize.width - VERT_RESIZE_INSET - 1,
  47.423 -                       fsize.height - CROSSHAIR_INSET + 1,
  47.424 -                       fsize.width - VERT_RESIZE_INSET - 1, fsize.height);
  47.425 -
  47.426 -            // upper-left horiz (highlight)
  47.427 -            g.setColor(highlight);
  47.428 -            g.drawLine(2, HORIZ_RESIZE_INSET + 1, CROSSHAIR_INSET,
  47.429 -                       HORIZ_RESIZE_INSET + 1);
  47.430 -            // upper-left vert (highlight)
  47.431 -            // g.setColor(highlight);
  47.432 -            g.drawLine(VERT_RESIZE_INSET + 1, 2, VERT_RESIZE_INSET + 1,
  47.433 -                       CROSSHAIR_INSET);
  47.434 -            // upper-right horiz (highlight)
  47.435 -            // g.setColor(highlight);
  47.436 -            g.drawLine(fsize.width - CROSSHAIR_INSET + 1,
  47.437 -                       HORIZ_RESIZE_INSET + 1, fsize.width - 1,
  47.438 -                       HORIZ_RESIZE_INSET + 1);
  47.439 -            // upper-right vert (highlight)
  47.440 -            // g.setColor(highlight);
  47.441 -            g.drawLine(fsize.width - VERT_RESIZE_INSET, 2,
  47.442 -                       fsize.width - VERT_RESIZE_INSET, CROSSHAIR_INSET);
  47.443 -            // lower-left horiz (highlight)
  47.444 -            // g.setColor(highlight);
  47.445 -            g.drawLine(2, fsize.height - HORIZ_RESIZE_INSET, CROSSHAIR_INSET,
  47.446 -                       fsize.height - HORIZ_RESIZE_INSET);
  47.447 -            // lower-left vert (highlight)
  47.448 -            // g.setColor(highlight);
  47.449 -            g.drawLine(VERT_RESIZE_INSET + 1,
  47.450 -                       fsize.height - CROSSHAIR_INSET + 1,
  47.451 -                       VERT_RESIZE_INSET + 1, fsize.height - 1);
  47.452 -            // lower-right horiz (highlight)
  47.453 -            // g.setColor(highlight);
  47.454 -            g.drawLine(fsize.width - CROSSHAIR_INSET + 1,
  47.455 -                       fsize.height - HORIZ_RESIZE_INSET, fsize.width - 1,
  47.456 -                       fsize.height - HORIZ_RESIZE_INSET);
  47.457 -            // lower-right vert (highlight)
  47.458 -            // g.setColor(highlight);
  47.459 -            g.drawLine(fsize.width - VERT_RESIZE_INSET,
  47.460 -                       fsize.height - CROSSHAIR_INSET + 1,
  47.461 -                       fsize.width - VERT_RESIZE_INSET, fsize.height - 1);
  47.462 -        }
  47.463 -
  47.464 -        MenuBar mb = f.getMenuBar();
  47.465 -        if (mb != null) {
  47.466 -            MMenuBarPeer peer = (MMenuBarPeer) MToolkit.targetToPeer(mb);
  47.467 -            if (peer != null) {
  47.468 -                Insets insets = getInsets();
  47.469 -                Graphics ng = g.create();
  47.470 -                int menubarX = 0;
  47.471 -                int menubarY = 0;
  47.472 -                if (hasDecorations(MWindowAttributes.AWT_DECOR_BORDER)) {
  47.473 -                    menubarX += CROSSHAIR_INSET + 1;
  47.474 -                    menubarY += CROSSHAIR_INSET + 1;
  47.475 -                }
  47.476 -                if (hasDecorations(MWindowAttributes.AWT_DECOR_TITLE)) {
  47.477 -                    menubarY += BUTTON_H;
  47.478 -                }
  47.479 -                try {
  47.480 -                    ng.translate(menubarX, menubarY);
  47.481 -                    peer.print(ng);
  47.482 -                } finally {
  47.483 -                    ng.dispose();
  47.484 -                }
  47.485 -            }
  47.486 -        }
  47.487 -    }
  47.488 -
  47.489 -    // Saveunders are not done by Frame.
  47.490 -    void setSaveUnder(boolean state) {}
  47.491 -
  47.492 -    /* Returns the native paint should be posted after setting new size
  47.493 -     */
  47.494 -    public boolean checkNativePaintOnSetBounds(int width, int height) {
  47.495 -        // Fix for 4418155. Undecorated Frame does not repaint
  47.496 -        // automticaly if shrinking. Should not wait for Expose
  47.497 -        return ((Frame)target).isUndecorated() ?
  47.498 -            ((width > oldWidth) || (height > oldHeight)):
  47.499 -            ((width != oldWidth) || (height != oldHeight));
  47.500 -    }
  47.501 -
  47.502 -    public void setBoundsPrivate(int x, int y, int width, int height) {
  47.503 -        setBounds(x, y, width, height);
  47.504 -    }
  47.505 -
  47.506 -    public Rectangle getBoundsPrivate() {
  47.507 -        return getBounds();
  47.508 -    }
  47.509 -
  47.510 -    @Override
  47.511 -    final boolean isTargetUndecorated() {
  47.512 -        return ((Frame)target).isUndecorated();
  47.513 -    }
  47.514 -}
    48.1 --- a/src/solaris/classes/sun/awt/motif/MGlobalCursorManager.java	Wed Sep 17 13:45:37 2008 -0700
    48.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.3 @@ -1,118 +0,0 @@
    48.4 -/*
    48.5 - * Copyright 1999-2004 Sun Microsystems, Inc.  All Rights Reserved.
    48.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    48.7 - *
    48.8 - * This code is free software; you can redistribute it and/or modify it
    48.9 - * under the terms of the GNU General Public License version 2 only, as
   48.10 - * published by the Free Software Foundation.  Sun designates this
   48.11 - * particular file as subject to the "Classpath" exception as provided
   48.12 - * by Sun in the LICENSE file that accompanied this code.
   48.13 - *
   48.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   48.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   48.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   48.17 - * version 2 for more details (a copy is included in the LICENSE file that
   48.18 - * accompanied this code).
   48.19 - *
   48.20 - * You should have received a copy of the GNU General Public License version
   48.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   48.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   48.23 - *
   48.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   48.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   48.26 - * have any questions.
   48.27 - */
   48.28 -
   48.29 -package sun.awt.motif;
   48.30 -
   48.31 -import java.awt.*;
   48.32 -import sun.awt.GlobalCursorManager;
   48.33 -import sun.awt.GlobalCursorManager.*;
   48.34 -
   48.35 -public final class MGlobalCursorManager extends GlobalCursorManager {
   48.36 -
   48.37 -    static {
   48.38 -        cacheInit();
   48.39 -    }
   48.40 -
   48.41 -    private native static void cacheInit();
   48.42 -
   48.43 -    // cached nativeContainer
   48.44 -    private Component nativeContainer;
   48.45 -
   48.46 -
   48.47 -    /**
   48.48 -     * The MGlobalCursorManager is a singleton.
   48.49 -     */
   48.50 -    private static MGlobalCursorManager manager;
   48.51 -
   48.52 -
   48.53 -    static GlobalCursorManager getCursorManager() {
   48.54 -        if (manager == null) {
   48.55 -            manager = new MGlobalCursorManager();
   48.56 -        }
   48.57 -        return manager;
   48.58 -    }
   48.59 -
   48.60 -    /**
   48.61 -     * Should be called in response to a native mouse enter or native mouse
   48.62 -     * button released message. Should not be called during a mouse drag.
   48.63 -     */
   48.64 -    static void nativeUpdateCursor(Component heavy) {
   48.65 -        MGlobalCursorManager.getCursorManager().updateCursorLater(heavy);
   48.66 -    }
   48.67 -
   48.68 -
   48.69 -    protected void setCursor(Component comp, Cursor cursor, boolean useCache) {
   48.70 -        if (comp == null) {
   48.71 -            return;
   48.72 -        }
   48.73 -
   48.74 -        Cursor cur = useCache ? cursor : getCapableCursor(comp);
   48.75 -
   48.76 -        Component nc = useCache ? nativeContainer : getNativeContainer(comp);
   48.77 -
   48.78 -        // System.out.println(" set cursor="+cursor+"  on "+comp+"  new curs="+cur);
   48.79 -        if (nc != null && nc.isDisplayable()) {
   48.80 -            nativeContainer = nc;
   48.81 -            ((MComponentPeer)nc.getPeer()).pSetCursor(cur);
   48.82 -        }
   48.83 -    }
   48.84 -
   48.85 -    private Component getNativeContainer(Component comp) {
   48.86 -        while (comp != null && comp.isLightweight()) {
   48.87 -            comp = comp.getParent();
   48.88 -        }
   48.89 -        return comp;
   48.90 -    }
   48.91 -
   48.92 -    protected native void getCursorPos(Point p);
   48.93 -    protected native Component findHeavyweightUnderCursor();
   48.94 -
   48.95 -    /*
   48.96 -     * two native methods to call corresponding methods in Container and
   48.97 -     * Component
   48.98 -     */
   48.99 -    protected native Component findComponentAt(Container con, int x, int y);
  48.100 -    protected native Point getLocationOnScreen(Component com);
  48.101 -
  48.102 -    protected Component findHeavyweightUnderCursor(boolean useCache) {
  48.103 -        return findHeavyweightUnderCursor();
  48.104 -    }
  48.105 -
  48.106 -    private Cursor getCapableCursor(Component comp) {
  48.107 -        Component c = comp;
  48.108 -        while ((c != null) && !(c instanceof Window) &&
  48.109 -               c.isEnabled() && c.isVisible() && c.isDisplayable()) {
  48.110 -            c = c.getParent();
  48.111 -        }
  48.112 -        if (c instanceof Window) {
  48.113 -            return (c.isEnabled() && c.isVisible() && c.isDisplayable() && comp.isEnabled()) ?
  48.114 -                    comp.getCursor() :
  48.115 -                    Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
  48.116 -        } else if (c == null) {
  48.117 -            return null;
  48.118 -        }
  48.119 -        return getCapableCursor(c.getParent());
  48.120 -    }
  48.121 -}
    49.1 --- a/src/solaris/classes/sun/awt/motif/MInputMethod.java	Wed Sep 17 13:45:37 2008 -0700
    49.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.3 @@ -1,177 +0,0 @@
    49.4 -/*
    49.5 - * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
    49.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    49.7 - *
    49.8 - * This code is free software; you can redistribute it and/or modify it
    49.9 - * under the terms of the GNU General Public License version 2 only, as
   49.10 - * published by the Free Software Foundation.  Sun designates this
   49.11 - * particular file as subject to the "Classpath" exception as provided
   49.12 - * by Sun in the LICENSE file that accompanied this code.
   49.13 - *
   49.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   49.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   49.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   49.17 - * version 2 for more details (a copy is included in the LICENSE file that
   49.18 - * accompanied this code).
   49.19 - *
   49.20 - * You should have received a copy of the GNU General Public License version
   49.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   49.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   49.23 - *
   49.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   49.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   49.26 - * have any questions.
   49.27 - */
   49.28 -
   49.29 -package sun.awt.motif;
   49.30 -
   49.31 -import java.awt.AWTException;
   49.32 -import java.awt.Component;
   49.33 -import java.awt.Container;
   49.34 -import java.awt.Window;
   49.35 -import java.awt.peer.ComponentPeer;
   49.36 -import sun.awt.X11InputMethod;
   49.37 -import sun.awt.SunToolkit;
   49.38 -
   49.39 -/**
   49.40 - * Input Method Adapter for XIM (with Motif)
   49.41 - *
   49.42 - * @author JavaSoft International
   49.43 - */
   49.44 -public class MInputMethod extends X11InputMethod {
   49.45 -
   49.46 -    public MInputMethod() throws AWTException {
   49.47 -        super();
   49.48 -    }
   49.49 -
   49.50 -    protected boolean openXIM() {
   49.51 -        return openXIMNative();
   49.52 -    }
   49.53 -
   49.54 -    protected boolean createXIC() {
   49.55 -        MComponentPeer peer = (MComponentPeer)getPeer(clientComponentWindow);
   49.56 -        if (peer == null) {
   49.57 -            return false;
   49.58 -        }
   49.59 -        MComponentPeer tc = null;
   49.60 -        if (peer instanceof MInputMethodControl) {
   49.61 -            tc = ((MInputMethodControl)peer).getTextComponent();
   49.62 -        }
   49.63 -        if (!createXICNative(peer, tc)) {
   49.64 -            return false;
   49.65 -        }
   49.66 -        if (peer instanceof MInputMethodControl) {
   49.67 -            ((MInputMethodControl)peer).addInputMethod(this);
   49.68 -        }
   49.69 -        return true;
   49.70 -    }
   49.71 -
   49.72 -    protected void setXICFocus(ComponentPeer peer,
   49.73 -                                    boolean value, boolean active) {
   49.74 -        setXICFocusNative((MComponentPeer)peer, value, active);
   49.75 -    }
   49.76 -
   49.77 -    protected Container getParent(Component client) {
   49.78 -        // SECURITY: Use _NoClientCode(), because this thread may
   49.79 -        //           be privileged
   49.80 -        return MComponentPeer.getParent_NoClientCode(client);
   49.81 -    }
   49.82 -
   49.83 -    /**
   49.84 -     * Returns peer of the given client component. If the given client component
   49.85 -     * doesn't have peer, peer of the native container of the client is returned.
   49.86 -     */
   49.87 -    protected ComponentPeer getPeer(Component client) {
   49.88 -        MComponentPeer peer = (MComponentPeer)MToolkit.targetToPeer(client);
   49.89 -        if (peer != null)
   49.90 -            return peer;
   49.91 -
   49.92 -        Container nativeContainer = MToolkit.getNativeContainer(client);
   49.93 -        peer = (MComponentPeer)MToolkit.targetToPeer(nativeContainer);
   49.94 -        return peer;
   49.95 -    }
   49.96 -
   49.97 -    /**
   49.98 -     * Changes the status area configuration that is to be requested
   49.99 -     * by Frame or Dialog.
  49.100 -     */
  49.101 -    void configureStatus() {
  49.102 -        if (isDisposed()) {
  49.103 -            return;
  49.104 -        }
  49.105 -
  49.106 -        MComponentPeer peer = (MComponentPeer)getPeer((Window) clientComponentWindow);
  49.107 -        MComponentPeer tc = ((MInputMethodControl)peer).getTextComponent();
  49.108 -        if (tc != null) {
  49.109 -            configureStatusAreaNative(tc);
  49.110 -        }
  49.111 -    }
  49.112 -
  49.113 -    /*
  49.114 -     * Subclasses should override disposeImpl() instead of dispose(). Client
  49.115 -     * code should always invoke dispose(), never disposeImpl().
  49.116 -     */
  49.117 -    protected synchronized void disposeImpl() {
  49.118 -        if (clientComponentWindow != null) {
  49.119 -            MComponentPeer peer = (MComponentPeer)getPeer(clientComponentWindow);
  49.120 -            if (peer instanceof MInputMethodControl)
  49.121 -                ((MInputMethodControl)peer).removeInputMethod(this);
  49.122 -            clientComponentWindow = null;
  49.123 -        }
  49.124 -
  49.125 -        super.disposeImpl();
  49.126 -    }
  49.127 -
  49.128 -    /**
  49.129 -     * @see java.awt.im.spi.InputMethod#removeNotify
  49.130 -     */
  49.131 -    public synchronized void removeNotify() {
  49.132 -        if (MToolkit.targetToPeer(getClientComponent()) != null) {
  49.133 -            dispose();
  49.134 -        } else {
  49.135 -            // We do not have to dispose XICs in case of lightweight component.
  49.136 -            resetXIC();
  49.137 -        }
  49.138 -    }
  49.139 -
  49.140 -    /**
  49.141 -     * Changes the internal XIC configurations. This is required the
  49.142 -     * case that addition or elimination of text components has
  49.143 -     * happened in the containment hierarchy. This method is invoked
  49.144 -     * by Frame or Dialog.
  49.145 -     */
  49.146 -    synchronized void reconfigureXIC(MInputMethodControl control) {
  49.147 -        if (!isDisposed()) {
  49.148 -            // Some IM servers require to reset XIC before destroying
  49.149 -            // the XIC. I.e., Destroying XIC doesn't reset the internal
  49.150 -            // state of the IM server. endComposition() takes care of
  49.151 -            // resetting XIC and preedit synchronization. However,
  49.152 -            // there is no client at this point. It is assumed that
  49.153 -            // the previous client is still available for dispatching
  49.154 -            // committed text which maintains client's composition
  49.155 -            // context.
  49.156 -            endComposition();
  49.157 -            resetXICifneeded();
  49.158 -            reconfigureXICNative((MComponentPeer) control, control.getTextComponent());
  49.159 -        }
  49.160 -    }
  49.161 -
  49.162 -    protected void awtLock() {
  49.163 -        SunToolkit.awtLock();
  49.164 -    }
  49.165 -
  49.166 -    protected void awtUnlock() {
  49.167 -        SunToolkit.awtUnlock();
  49.168 -    }
  49.169 -
  49.170 -    /*
  49.171 -     * Native methods
  49.172 -     */
  49.173 -    private native boolean openXIMNative();
  49.174 -    private native boolean createXICNative(MComponentPeer peer, MComponentPeer tc);
  49.175 -    private native void reconfigureXICNative(MComponentPeer peer,
  49.176 -                                            MComponentPeer tc);
  49.177 -    private native void configureStatusAreaNative(MComponentPeer tc);
  49.178 -    private native void setXICFocusNative(MComponentPeer peer,
  49.179 -                                    boolean value, boolean active);
  49.180 -}
    50.1 --- a/src/solaris/classes/sun/awt/motif/MInputMethodControl.java	Wed Sep 17 13:45:37 2008 -0700
    50.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.3 @@ -1,73 +0,0 @@
    50.4 -/*
    50.5 - * Copyright 1997-2003 Sun Microsystems, Inc.  All Rights Reserved.
    50.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    50.7 - *
    50.8 - * This code is free software; you can redistribute it and/or modify it
    50.9 - * under the terms of the GNU General Public License version 2 only, as
   50.10 - * published by the Free Software Foundation.  Sun designates this
   50.11 - * particular file as subject to the "Classpath" exception as provided
   50.12 - * by Sun in the LICENSE file that accompanied this code.
   50.13 - *
   50.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   50.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   50.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   50.17 - * version 2 for more details (a copy is included in the LICENSE file that
   50.18 - * accompanied this code).
   50.19 - *
   50.20 - * You should have received a copy of the GNU General Public License version
   50.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   50.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   50.23 - *
   50.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   50.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   50.26 - * have any questions.
   50.27 - */
   50.28 -
   50.29 -package sun.awt.motif;
   50.30 -
   50.31 -import sun.awt.motif.MComponentPeer;
   50.32 -import sun.awt.motif.MInputMethod;
   50.33 -
   50.34 -/**
   50.35 - * An interface for controlling containment hierarchy configuration to
   50.36 - * keep track of existence of any TextArea or TextField and to manage
   50.37 - * input method status area.
   50.38 - *
   50.39 - * @auther      JavaSoft International
   50.40 - */
   50.41 -interface MInputMethodControl {
   50.42 -
   50.43 -    /**
   50.44 -     * Informs Frame or Dialog that a text component has been added to
   50.45 -     * the hierarchy.
   50.46 -     * @param   textComponentPeer       peer of the text component
   50.47 -     */
   50.48 -    void addTextComponent(MComponentPeer textComponentPeer);
   50.49 -
   50.50 -    /**
   50.51 -     * Informs Frame or Dialog that a text component has been removed
   50.52 -     * from the hierarchy.
   50.53 -     * @param textComponentPeer peer of the text component
   50.54 -     */
   50.55 -    void removeTextComponent(MComponentPeer textComponentPeer);
   50.56 -
   50.57 -    /**
   50.58 -     * Returns a text component peer in the containment hierarchy
   50.59 -     * to obtain the Motif status area information
   50.60 -     */
   50.61 -    MComponentPeer getTextComponent();
   50.62 -
   50.63 -    /**
   50.64 -     * Inform Frame or Dialog that an MInputMethod has been
   50.65 -     * constructed so that Frame and Dialog can invoke the method in
   50.66 -     * MInputMethod to reconfigure XICs.
   50.67 -     * @param   inputMethod     an MInputMethod instance
   50.68 -     */
   50.69 -    void addInputMethod(MInputMethod inputMethod);
   50.70 -
   50.71 -    /**
   50.72 -     * Inform Frame or Dialog that an X11InputMethod is being destroyed.
   50.73 -     * @param   inputMethod     an X11InputMethod instance
   50.74 -     */
   50.75 -    void removeInputMethod(MInputMethod inputMethod);
   50.76 -}
    51.1 --- a/src/solaris/classes/sun/awt/motif/MInputMethodDescriptor.java	Wed Sep 17 13:45:37 2008 -0700
    51.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.3 @@ -1,48 +0,0 @@
    51.4 -/*
    51.5 - * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
    51.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    51.7 - *
    51.8 - * This code is free software; you can redistribute it and/or modify it
    51.9 - * under the terms of the GNU General Public License version 2 only, as
   51.10 - * published by the Free Software Foundation.  Sun designates this
   51.11 - * particular file as subject to the "Classpath" exception as provided
   51.12 - * by Sun in the LICENSE file that accompanied this code.
   51.13 - *
   51.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   51.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   51.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   51.17 - * version 2 for more details (a copy is included in the LICENSE file that
   51.18 - * accompanied this code).
   51.19 - *
   51.20 - * You should have received a copy of the GNU General Public License version
   51.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   51.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   51.23 - *
   51.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   51.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   51.26 - * have any questions.
   51.27 - */
   51.28 -
   51.29 -
   51.30 -package sun.awt.motif;
   51.31 -
   51.32 -import java.awt.im.spi.InputMethod;
   51.33 -import sun.awt.X11InputMethodDescriptor;
   51.34 -
   51.35 -/**
   51.36 - * Provides sufficient information about an input method
   51.37 - * to enable selection and loading of that input method.
   51.38 - * The input method itself is only loaded when it is actually used.
   51.39 - *
   51.40 - * @since JDK1.3
   51.41 - */
   51.42 -
   51.43 -class MInputMethodDescriptor extends X11InputMethodDescriptor {
   51.44 -
   51.45 -    /**
   51.46 -     * @see java.awt.im.spi.InputMethodDescriptor#createInputMethod
   51.47 -     */
   51.48 -    public InputMethod createInputMethod() throws Exception {
   51.49 -        return new MInputMethod();
   51.50 -    }
   51.51 -}
    52.1 --- a/src/solaris/classes/sun/awt/motif/MLabelPeer.java	Wed Sep 17 13:45:37 2008 -0700
    52.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.3 @@ -1,104 +0,0 @@
    52.4 -/*
    52.5 - * Copyright 1995-1996 Sun Microsystems, Inc.  All Rights Reserved.
    52.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    52.7 - *
    52.8 - * This code is free software; you can redistribute it and/or modify it
    52.9 - * under the terms of the GNU General Public License version 2 only, as
   52.10 - * published by the Free Software Foundation.  Sun designates this
   52.11 - * particular file as subject to the "Classpath" exception as provided
   52.12 - * by Sun in the LICENSE file that accompanied this code.
   52.13 - *
   52.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   52.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   52.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   52.17 - * version 2 for more details (a copy is included in the LICENSE file that
   52.18 - * accompanied this code).
   52.19 - *
   52.20 - * You should have received a copy of the GNU General Public License version
   52.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   52.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   52.23 - *
   52.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   52.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   52.26 - * have any questions.
   52.27 - */
   52.28 -package sun.awt.motif;
   52.29 -
   52.30 -import java.awt.*;
   52.31 -import java.awt.peer.*;
   52.32 -
   52.33 -class MLabelPeer extends MComponentPeer implements LabelPeer {
   52.34 -    native void create(MComponentPeer parent);
   52.35 -
   52.36 -    public void initialize() {
   52.37 -        Label   l = (Label)target;
   52.38 -        String  txt;
   52.39 -        int     align;
   52.40 -
   52.41 -        if ((txt = l.getText()) != null) {
   52.42 -            setText(l.getText());
   52.43 -        }
   52.44 -        if ((align = l.getAlignment()) != Label.LEFT) {
   52.45 -            setAlignment(align);
   52.46 -        }
   52.47 -        super.initialize();
   52.48 -    }
   52.49 -
   52.50 -    MLabelPeer(Label target) {
   52.51 -        super(target);
   52.52 -    }
   52.53 -
   52.54 -    public Dimension getMinimumSize() {
   52.55 -        FontMetrics fm = getFontMetrics(target.getFont());
   52.56 -        String label = ((Label)target).getText();
   52.57 -        if (label == null) label = "";
   52.58 -        return new Dimension(fm.stringWidth(label) + 14,
   52.59 -                             fm.getHeight() + 8);
   52.60 -    }
   52.61 -
   52.62 -    public native void setText(String label);
   52.63 -    public native void setAlignment(int alignment);
   52.64 -
   52.65 -    /*
   52.66 -     * Print the native component by rendering the Motif look ourselves.
   52.67 -     */
   52.68 -    public void print(Graphics g) {
   52.69 -        Label l = (Label)target;
   52.70 -        Dimension d = l.size();
   52.71 -        Color bg = l.getBackground();
   52.72 -        Color fg = l.getForeground();
   52.73 -
   52.74 -        g.setColor(bg);
   52.75 -        g.fillRect(1, 1, d.width - 2, d.height - 2);
   52.76 -
   52.77 -        g.setColor(fg);
   52.78 -        g.setFont(l.getFont());
   52.79 -        FontMetrics fm = g.getFontMetrics();
   52.80 -        String lbl = l.getText();
   52.81 -
   52.82 -        switch (l.getAlignment()) {
   52.83 -          case Label.LEFT:
   52.84 -            g.drawString(lbl, 2,
   52.85 -                         (d.height + fm.getMaxAscent() - fm.getMaxDescent()) / 2);
   52.86 -            break;
   52.87 -          case Label.RIGHT:
   52.88 -            g.drawString(lbl, d.width - (fm.stringWidth(lbl) + 2),
   52.89 -                         (d.height + fm.getMaxAscent() - fm.getMaxDescent()) / 2);
   52.90 -            break;
   52.91 -          case Label.CENTER:
   52.92 -            g.drawString(lbl, (d.width - fm.stringWidth(lbl)) / 2,
   52.93 -                         (d.height + fm.getMaxAscent() - fm.getMaxDescent()) / 2);
   52.94 -            break;
   52.95 -        }
   52.96 -
   52.97 -        target.print(g);
   52.98 -    }
   52.99 -
  52.100 -    /**
  52.101 -     * DEPRECATED
  52.102 -     */
  52.103 -    public Dimension minimumSize() {
  52.104 -            return getMinimumSize();
  52.105 -    }
  52.106 -
  52.107 -}
    53.1 --- a/src/solaris/classes/sun/awt/motif/MListPeer.java	Wed Sep 17 13:45:37 2008 -0700
    53.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.3 @@ -1,390 +0,0 @@
    53.4 -/*
    53.5 - * Copyright 1995-2004 Sun Microsystems, Inc.  All Rights Reserved.
    53.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    53.7 - *
    53.8 - * This code is free software; you can redistribute it and/or modify it
    53.9 - * under the terms of the GNU General Public License version 2 only, as
   53.10 - * published by the Free Software Foundation.  Sun designates this
   53.11 - * particular file as subject to the "Classpath" exception as provided
   53.12 - * by Sun in the LICENSE file that accompanied this code.
   53.13 - *
   53.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   53.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   53.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   53.17 - * version 2 for more details (a copy is included in the LICENSE file that
   53.18 - * accompanied this code).
   53.19 - *
   53.20 - * You should have received a copy of the GNU General Public License version
   53.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   53.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   53.23 - *
   53.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   53.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   53.26 - * have any questions.
   53.27 - */
   53.28 -package sun.awt.motif;
   53.29 -
   53.30 -import java.awt.*;
   53.31 -import java.awt.peer.*;
   53.32 -import java.awt.event.ActionEvent;
   53.33 -import java.awt.event.ItemEvent;
   53.34 -import java.awt.event.MouseEvent;
   53.35 -import java.awt.event.MouseWheelEvent;
   53.36 -
   53.37 -class MListPeer extends MComponentPeer implements ListPeer {
   53.38 -    native void create(MComponentPeer parent);
   53.39 -
   53.40 -    void initialize() {
   53.41 -        List li = (List)target;
   53.42 -
   53.43 -        /* add any items that were already inserted in the target. */
   53.44 -        int  nitems = li.countItems();
   53.45 -        for (int i = 0; i < nitems; i++) {
   53.46 -            addItem(li.getItem(i), -1);
   53.47 -        }
   53.48 -
   53.49 -        /* set whether this list should allow multiple selections. */
   53.50 -        setMultipleSelections(li.allowsMultipleSelections());
   53.51 -
   53.52 -        /* make the visible position visible. */
   53.53 -        int index = li.getVisibleIndex();
   53.54 -        if (index >= 0) {
   53.55 -            makeVisible(index);
   53.56 -        }
   53.57 -
   53.58 -        /* select the item if necessary. */
   53.59 -        int sel[] = li.getSelectedIndexes();
   53.60 -        for (int i = 0 ; i < sel.length ; i++) {
   53.61 -            select(sel[i]);
   53.62 -        }
   53.63 -
   53.64 -        /* BugID 4060345 to avoid showing scrollbar in empty List */
   53.65 -        if (nitems == 0) {
   53.66 -            addItem(" ", 0);
   53.67 -            delItems(0, 0);
   53.68 -        }
   53.69 -        super.pSetScrollbarBackground(getParent_NoClientCode(li).getBackground());
   53.70 -
   53.71 -        if (!target.isBackgroundSet()) {
   53.72 -            target.setBackground(SystemColor.text);
   53.73 -        }
   53.74 -        if (!target.isForegroundSet()) {
   53.75 -            target.setForeground(SystemColor.textText);
   53.76 -        }
   53.77 -
   53.78 -        super.initialize();
   53.79 -    }
   53.80 -
   53.81 -    MListPeer(List target) {
   53.82 -        super(target);
   53.83 -    }
   53.84 -
   53.85 -    /* New method name for 1.1 */
   53.86 -    public void add(String item, int index) {
   53.87 -        addItem(item, index);
   53.88 -    }
   53.89 -
   53.90 -    /* New method name for 1.1 */
   53.91 -    public void removeAll() {
   53.92 -        clear();
   53.93 -    }
   53.94 -
   53.95 -    /* New method name for 1.1 */
   53.96 -    public void setMultipleMode (boolean b) {
   53.97 -        setMultipleSelections(b);
   53.98 -    }
   53.99 -
  53.100 -    /* New method name for 1.1 */
  53.101 -    public Dimension getPreferredSize(int rows) {
  53.102 -        return preferredSize(rows);
  53.103 -    }
  53.104 -
  53.105 -    /* New method name for 1.1 */
  53.106 -    public Dimension getMinimumSize(int rows) {
  53.107 -        return minimumSize(rows);
  53.108 -    }
  53.109 -
  53.110 -    public void setForeground(Color c) {
  53.111 -        pSetInnerForeground(c);
  53.112 -    }
  53.113 -
  53.114 -    public native void setBackground(Color c);
  53.115 -    public native void setMultipleSelections(boolean v);
  53.116 -    public native boolean isSelected(int index);
  53.117 -    public native void addItem(String item, int index);
  53.118 -    public native void delItems(int start, int end);
  53.119 -    public native void select(int index);
  53.120 -    public native void deselect(int index);
  53.121 -    public native void makeVisible(int index);
  53.122 -
  53.123 -    public void clear() {
  53.124 -        List l = (List)target;
  53.125 -        int count = l.countItems();
  53.126 -        if (count > 0) {
  53.127 -            delItems(0, count-1);
  53.128 -        }
  53.129 -    }
  53.130 -
  53.131 -    public int[] getSelectedIndexes() {
  53.132 -        List l = (List)target;
  53.133 -        int len = l.countItems();
  53.134 -        int sel[] = new int[len];
  53.135 -        int nsel = 0;
  53.136 -        for (int i = 0 ; i < len ; i++) {
  53.137 -            if (isSelected(i)) {
  53.138 -                sel[nsel++] = i;
  53.139 -            }
  53.140 -        }
  53.141 -        int selected[] = new int[nsel];
  53.142 -        System.arraycopy(sel, 0, selected, 0, nsel);
  53.143 -        return selected;
  53.144 -    }
  53.145 -
  53.146 -    // NOTE: This method may be called by privileged threads.
  53.147 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  53.148 -    public void action(int index, final long when, final int modifiers) {
  53.149 -        final List list = (List)target;
  53.150 -        final int selectIndex = index;
  53.151 -
  53.152 -        MToolkit.executeOnEventHandlerThread(list, new Runnable() {
  53.153 -            public void run() {
  53.154 -                list.select(selectIndex);
  53.155 -                postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
  53.156 -                                          list.getItem(selectIndex), when,
  53.157 -                                          modifiers));
  53.158 -            }
  53.159 -        });
  53.160 -    } // action()
  53.161 -
  53.162 -    // NOTE: This method may be called by privileged threads.
  53.163 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  53.164 -    public void handleListChanged(int index) {
  53.165 -        final MListPeer listPeer = this;
  53.166 -        final List list = (List)target;
  53.167 -        final int listIndex = index;
  53.168 -
  53.169 -        MToolkit.executeOnEventHandlerThread(list, new Runnable() {
  53.170 -            public void run() {
  53.171 -                int selected[] = listPeer.getSelectedIndexes();
  53.172 -                boolean isSelected = false;
  53.173 -
  53.174 -                for (int i=0; i < selected.length; i++) {
  53.175 -                    if (listIndex == selected[i]) {
  53.176 -                        isSelected = true;
  53.177 -                        break;
  53.178 -                    }
  53.179 -                }
  53.180 -                postEvent(new ItemEvent(list, ItemEvent.ITEM_STATE_CHANGED,
  53.181 -                                Integer.valueOf(listIndex),
  53.182 -                                isSelected? ItemEvent.SELECTED : ItemEvent.DESELECTED));
  53.183 -
  53.184 -            }
  53.185 -        });
  53.186 -    } // handleListChanged()
  53.187 -
  53.188 -    public Dimension minimumSize() {
  53.189 -        return minimumSize(4);
  53.190 -    }
  53.191 -
  53.192 -    public Dimension preferredSize(int v) {
  53.193 -        return minimumSize(v);
  53.194 -    }
  53.195 -
  53.196 -    public Dimension minimumSize(int v) {
  53.197 -        FontMetrics fm = getFontMetrics(((List)target).getFont());
  53.198 -        return new Dimension(SCROLLBAR + 2*MARGIN +
  53.199 -                             fm.stringWidth("0123456789abcde"),
  53.200 -                             ((fm.getHeight()+2*SPACE) * v) +
  53.201 -                             2*MARGIN);
  53.202 -    }
  53.203 -
  53.204 -    public boolean isFocusable() {
  53.205 -        return true;
  53.206 -    }
  53.207 -
  53.208 -    /*
  53.209 -     * Print the native component by rendering the Motif look ourselves.
  53.210 -     * ToDo(aim): needs to query native motif for more accurate size and
  53.211 -     * color information, selected items, and item offset.
  53.212 -     */
  53.213 -    final static int    MARGIN = 2;
  53.214 -    final static int    SPACE = 1;
  53.215 -    final static int    SCROLLBAR = 16;
  53.216 -    int fontHeight;
  53.217 -    int fontAscent;
  53.218 -    int fontLeading;
  53.219 -    int vval;
  53.220 -    int hval;
  53.221 -    int vmax;
  53.222 -    int hmax;
  53.223 -
  53.224 -    public void print(Graphics g) {
  53.225 -        List l = (List)target;
  53.226 -        Dimension d = l.size();
  53.227 -        Color bg = l.getBackground();
  53.228 -        Color fg = l.getForeground();
  53.229 -        int numItems = l.getItemCount();
  53.230 -        FontMetrics fm = getFontMetrics(l.getFont());
  53.231 -        int w, h;
  53.232 -        int vvis, hvis, vmin, hmin;
  53.233 -        int max = 0;
  53.234 -
  53.235 -        for (int i = 0; i < numItems; i++) {
  53.236 -            int len = fm.stringWidth(l.getItem(i));
  53.237 -            max = Math.max(max, len);
  53.238 -        }
  53.239 -
  53.240 -        fontHeight = fm.getHeight();
  53.241 -        fontAscent = fm.getAscent();
  53.242 -        fontLeading = fm.getLeading();
  53.243 -
  53.244 -        hmin = vmin = 0;
  53.245 -
  53.246 -        vvis = itemsInWindow(true);
  53.247 -        vmax = Math.max(numItems - vvis, 0);
  53.248 -        h = d.height - SCROLLBAR;
  53.249 -
  53.250 -        if (vmax != 0) {
  53.251 -            w = d.width - SCROLLBAR;
  53.252 -            hvis = w - ((2 * SPACE) + (2 * MARGIN));
  53.253 -            hmax = Math.max(max - hvis, 0);
  53.254 -        } else {
  53.255 -            w = d.width;
  53.256 -            hvis = w - ((2 * SPACE) + (2 * MARGIN));
  53.257 -            hmax = Math.max(max - hvis, 0);
  53.258 -        }
  53.259 -        if (hmax == 0) {
  53.260 -            h = d.height;
  53.261 -            vvis = itemsInWindow(false);
  53.262 -            vmax = Math.max(numItems - vvis, 0);
  53.263 -        }
  53.264 -        if (vmax == 0) {
  53.265 -            w = d.width;
  53.266 -            hvis = w - ((2 * SPACE) + (2 * MARGIN));
  53.267 -            hmax = Math.max(max - hvis, 0);
  53.268 -        }
  53.269 -
  53.270 -        hval = 0;
  53.271 -        vval = 0;
  53.272 -        /*
  53.273 -System.out.println("print List: "+d.width+"x"+d.height+" numItems="+numItems+
  53.274 -"max="+max+" vsb=("+vmin+".."+vmax+","+vval+","+vvis+
  53.275 -") hsb=("+hmin+".."+hmax+","+hval+","+hvis+")");
  53.276 -*/
  53.277 -
  53.278 -        g.setColor(bg);
  53.279 -        g.fillRect(0, 0, w, h);
  53.280 -
  53.281 -        if (hmax != 0) {
  53.282 -            int sbw = d.width - ((vmax == 0) ? 0 : SCROLLBAR);
  53.283 -            g.fillRect(1, d.height - SCROLLBAR - 3, sbw - 1, SCROLLBAR - 3);
  53.284 -            Graphics ng = g.create();
  53.285 -            try {
  53.286 -                ng.translate(0, d.height - (SCROLLBAR - 2));
  53.287 -                drawScrollbar(ng, bg, SCROLLBAR - 2, sbw,
  53.288 -                               hmin, hmax, hval, hvis, true);
  53.289 -            } finally {
  53.290 -                ng.dispose();
  53.291 -            }
  53.292 -        }
  53.293 -        if (vmax != 0) {
  53.294 -            int sbh = d.height - ((hmax == 0) ? 0 : SCROLLBAR);
  53.295 -            g.fillRect(d.width - SCROLLBAR - 3, 1, SCROLLBAR - 3, sbh - 1);
  53.296 -            Graphics ng = g.create();
  53.297 -            try {
  53.298 -                ng.translate(d.width - (SCROLLBAR - 2), 0);
  53.299 -                drawScrollbar(ng, bg, SCROLLBAR - 2, sbh,
  53.300 -                               vmin, vmax, vval, vvis, false);
  53.301 -            } finally {
  53.302 -                ng.dispose();
  53.303 -            }
  53.304 -        }
  53.305 -
  53.306 -        draw3DRect(g, bg, 0, 0, w - 1, h - 1, false);
  53.307 -
  53.308 -        if (numItems > 0) {
  53.309 -            int n = itemsInWindow(hmax != 0);
  53.310 -            int e = Math.min(numItems - 1, (vval + n) - 1);
  53.311 -            paintItems(g, bg, fg, vval, e);
  53.312 -        }
  53.313 -
  53.314 -        target.print(g);
  53.315 -    }
  53.316 -
  53.317 -    int itemsInWindow(boolean scrollbarVisible) {
  53.318 -        Dimension d = target.size();
  53.319 -        int h;
  53.320 -        if (scrollbarVisible) {
  53.321 -            h = d.height - ((2 * MARGIN) + SCROLLBAR);
  53.322 -        } else {
  53.323 -            h = d.height - 2*MARGIN;
  53.324 -        }
  53.325 -        int i = fontHeight - fontLeading;
  53.326 -        return h / (i + (2 * SPACE));
  53.327 -    }
  53.328 -
  53.329 -    void paintItem(Graphics g, Color bg, Color fg, int index, boolean isSelected) {
  53.330 -        List l = (List)target;
  53.331 -        Dimension d = l.size();
  53.332 -        int numItems = l.getItemCount();
  53.333 -        Color shadow = bg.darker();
  53.334 -
  53.335 -        if ((index < vval) || (index >= (vval + itemsInWindow(hmax != 0)))) {
  53.336 -            return;
  53.337 -        }
  53.338 -        int w = d.width - ((2 * MARGIN) + ((vmax != 0)? SCROLLBAR : 0));
  53.339 -        int h = (fontHeight - fontLeading);
  53.340 -        int htotal = h + (2 * SPACE);
  53.341 -        int index2y = MARGIN + (index * htotal) + SPACE;
  53.342 -        int y = index2y - (vval * htotal);
  53.343 -        int x = MARGIN + SPACE;
  53.344 -        Graphics ng = g.create();
  53.345 -        try {
  53.346 -            if (index > numItems - 1) {
  53.347 -                ng.setColor(bg);
  53.348 -                ng.fillRect(x - 2, y - 2, w, h + 4);
  53.349 -                return;
  53.350 -            }
  53.351 -            if (isSelected) {
  53.352 -                ng.setColor(shadow);
  53.353 -                ng.fillRect(x - 1, y - 1, w - 2, h + 2);
  53.354 -            } else {
  53.355 -                ng.setColor(bg);
  53.356 -                ng.fillRect(x - 1, y - 1, w - 2, h + 2);
  53.357 -            }
  53.358 -            ng.setColor(bg);
  53.359 -
  53.360 -            ng.drawRect(x - 2, y - 2, w - 1, h + 3);
  53.361 -            ng.setColor(fg);
  53.362 -            String str = (String)l.getItem(index);
  53.363 -            ng.clipRect(x, y, w - (2 * SPACE), h);
  53.364 -            ng.drawString(str, x - hval, y + fontAscent);
  53.365 -        } finally {
  53.366 -            ng.dispose();
  53.367 -        }
  53.368 -    }
  53.369 -
  53.370 -    void paintItems(Graphics g, Color bg, Color fg, int s, int e) {
  53.371 -        for (int i = s ; i <= e ; i++) {
  53.372 -          paintItem(g, bg, fg, i, false);
  53.373 -        }
  53.374 -    }
  53.375 -
  53.376 -    public boolean handlesWheelScrolling() {return true;}
  53.377 -
  53.378 -    public void handleEvent(AWTEvent e) {
  53.379 -        if (e.getID() == MouseEvent.MOUSE_WHEEL) {
  53.380 -            MouseWheelEvent mwe = (MouseWheelEvent)e;
  53.381 -            nativeHandleMouseWheel(mwe.getScrollType(),
  53.382 -                                   mwe.getScrollAmount(),
  53.383 -                                   mwe.getWheelRotation());
  53.384 -        }
  53.385 -        else {
  53.386 -            super.handleEvent(e);
  53.387 -        }
  53.388 -    }
  53.389 -
  53.390 -    native void nativeHandleMouseWheel(int scrollType,
  53.391 -                                       int scrollAmount,
  53.392 -                                       int wheelRotation);
  53.393 -}
    54.1 --- a/src/solaris/classes/sun/awt/motif/MMenuBarPeer.java	Wed Sep 17 13:45:37 2008 -0700
    54.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.3 @@ -1,192 +0,0 @@
    54.4 -/*
    54.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
    54.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    54.7 - *
    54.8 - * This code is free software; you can redistribute it and/or modify it
    54.9 - * under the terms of the GNU General Public License version 2 only, as
   54.10 - * published by the Free Software Foundation.  Sun designates this
   54.11 - * particular file as subject to the "Classpath" exception as provided
   54.12 - * by Sun in the LICENSE file that accompanied this code.
   54.13 - *
   54.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   54.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   54.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   54.17 - * version 2 for more details (a copy is included in the LICENSE file that
   54.18 - * accompanied this code).
   54.19 - *
   54.20 - * You should have received a copy of the GNU General Public License version
   54.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   54.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   54.23 - *
   54.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   54.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   54.26 - * have any questions.
   54.27 - */
   54.28 -package sun.awt.motif;
   54.29 -
   54.30 -import java.awt.*;
   54.31 -import java.awt.peer.*;
   54.32 -import sun.awt.*;
   54.33 -
   54.34 -public class MMenuBarPeer implements MenuBarPeer {
   54.35 -    long        pData;
   54.36 -    MenuBar     target;
   54.37 -    private X11GraphicsConfig   graphicsConfig=null;
   54.38 -
   54.39 -    private boolean disposed = false;
   54.40 -
   54.41 -    static {
   54.42 -        initIDs();
   54.43 -    }
   54.44 -
   54.45 -     /**
   54.46 -     * Initialize JNI field and method IDs for fields that may be accessed
   54.47 -       from C.
   54.48 -     */
   54.49 -    private static native void initIDs();
   54.50 -
   54.51 -    native void create(MFramePeer f);
   54.52 -
   54.53 -    public MMenuBarPeer(MenuBar target) {
   54.54 -        this.target = target;
   54.55 -        MFramePeer parent = (MFramePeer) MToolkit.targetToPeer(MMenuItemPeer.getParent_NoClientCode(target));
   54.56 -        create(parent);
   54.57 -    }
   54.58 -
   54.59 -    protected void finalize() throws Throwable {
   54.60 -        dispose();
   54.61 -        super.finalize();
   54.62 -    }
   54.63 -
   54.64 -    /*
   54.65 -     * Subclasses should override disposeImpl() instead of dispose(). Client
   54.66 -     * code should always invoke dispose(), never disposeImpl().
   54.67 -     */
   54.68 -    private native void pDispose();
   54.69 -    protected void disposeImpl() {
   54.70 -        MToolkit.targetDisposedPeer(target, this);
   54.71 -        pDispose();
   54.72 -    }
   54.73 -    public final void dispose() {
   54.74 -        boolean call_disposeImpl = false;
   54.75 -
   54.76 -        if (!disposed) {
   54.77 -            synchronized (this) {
   54.78 -                if (!disposed) {
   54.79 -                    disposed = call_disposeImpl = true;
   54.80 -                }
   54.81 -            }
   54.82 -        }
   54.83 -
   54.84 -        if (call_disposeImpl) {
   54.85 -            disposeImpl();
   54.86 -        }
   54.87 -    }
   54.88 -    public void addMenu(Menu m) {
   54.89 -    }
   54.90 -    public void delMenu(int index) {
   54.91 -    }
   54.92 -    public void addHelpMenu(Menu m) {
   54.93 -    }
   54.94 -
   54.95 -    static final int GAP = 10;
   54.96 -    static final int W_DIFF = (MFramePeer.CROSSHAIR_INSET + 1) * 2;
   54.97 -    static final int H_DIFF = MFramePeer.BUTTON_Y + MFramePeer.BUTTON_H;
   54.98 -
   54.99 -    /*
  54.100 -     * Print the native component by rendering the Motif look ourselves.
  54.101 -     * ToDo(aim): needs to query native motif for more appropriate size and
  54.102 -     * color information.
  54.103 -     */
  54.104 -    void print(Graphics g) {
  54.105 -        MenuBar mb = (MenuBar)target;
  54.106 -        Frame f = (Frame)MMenuItemPeer.getParent_NoClientCode(target);
  54.107 -        Dimension fd = f.size();
  54.108 -        Insets insets = f.insets();
  54.109 -
  54.110 -        /* Calculate menubar dimension. */
  54.111 -        int width = fd.width;
  54.112 -        int height = insets.top;
  54.113 -        if (f.getPeer() instanceof MFramePeer) {
  54.114 -            MFramePeer fpeer = (MFramePeer)f.getPeer();
  54.115 -            if (fpeer.hasDecorations(MWindowAttributes.AWT_DECOR_BORDER)) {
  54.116 -                width -= W_DIFF;
  54.117 -                height -= MFramePeer.BUTTON_Y;
  54.118 -            }
  54.119 -            if (fpeer.hasDecorations(MWindowAttributes.AWT_DECOR_MENU)) {
  54.120 -                height -= MFramePeer.BUTTON_H;
  54.121 -            }
  54.122 -        }
  54.123 -        Dimension d = new Dimension(width, height);
  54.124 -
  54.125 -        Shape oldClipArea = g.getClip();
  54.126 -        g.clipRect(0, 0, d.width, d.height);
  54.127 -
  54.128 -        Color bg = f.getBackground();
  54.129 -        Color fg = f.getForeground();
  54.130 -        Color highlight = bg.brighter();
  54.131 -        Color shadow = bg.darker();
  54.132 -
  54.133 -        // because we'll most likely be drawing on white paper,
  54.134 -        // for aesthetic reasons, don't make any part of the outer border
  54.135 -        // pure white
  54.136 -        if (highlight.equals(Color.white)) {
  54.137 -            g.setColor(new Color(230, 230, 230));
  54.138 -        }
  54.139 -        else {
  54.140 -            g.setColor(highlight);
  54.141 -        }
  54.142 -        g.drawLine(0, 0, d.width, 0);
  54.143 -        g.drawLine(1, 1, d.width - 1, 1);
  54.144 -        g.drawLine(0, 0, 0, d.height);
  54.145 -        g.drawLine(1, 1, 1, d.height - 1);
  54.146 -        g.setColor(shadow);
  54.147 -        g.drawLine(d.width, 1, d.width, d.height);
  54.148 -        g.drawLine(d.width - 1, 2, d.width - 1, d.height);
  54.149 -        g.drawLine(1, d.height, d.width, d.height);
  54.150 -        g.drawLine(2, d.height - 1, d.width, d.height - 1);
  54.151 -
  54.152 -        int x = GAP;
  54.153 -        int nitems = mb.countMenus();
  54.154 -
  54.155 -        Menu helpMenu = target.getHelpMenu();
  54.156 -
  54.157 -        for (int i = 0 ; i < nitems ; i++) {
  54.158 -            Menu mn = target.getMenu(i);
  54.159 -            String item = mn.getLabel();
  54.160 -            if (item == null) {
  54.161 -                item = "";
  54.162 -            }
  54.163 -            Font menuFont = mn.getFont();
  54.164 -            g.setFont(menuFont);
  54.165 -            FontMetrics menuMetrics = g.getFontMetrics();
  54.166 -            int y = (d.height / 2) + menuMetrics.getMaxDescent();
  54.167 -            int w = menuMetrics.stringWidth(item) + GAP * 2;
  54.168 -
  54.169 -            if (x >= d.width) {
  54.170 -                break;
  54.171 -            }
  54.172 -            if (mn.isEnabled()) {
  54.173 -                g.setColor(fg);
  54.174 -            }
  54.175 -            else {
  54.176 -                  // draw text as grayed out
  54.177 -                g.setColor(shadow);
  54.178 -            }
  54.179 -
  54.180 -            if (helpMenu == mn) {
  54.181 -                g.drawString(item, d.width - w + GAP, y);
  54.182 -            }
  54.183 -            else {
  54.184 -                g.drawString(item, x, y);
  54.185 -                x += w;
  54.186 -            }
  54.187 -        }
  54.188 -
  54.189 -        g.setClip(oldClipArea);
  54.190 -    }
  54.191 -
  54.192 -    // Needed for MenuComponentPeer.
  54.193 -    public void setFont(Font f) {
  54.194 -    }
  54.195 -}
    55.1 --- a/src/solaris/classes/sun/awt/motif/MMenuItemPeer.java	Wed Sep 17 13:45:37 2008 -0700
    55.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.3 @@ -1,190 +0,0 @@
    55.4 -/*
    55.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
    55.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    55.7 - *
    55.8 - * This code is free software; you can redistribute it and/or modify it
    55.9 - * under the terms of the GNU General Public License version 2 only, as
   55.10 - * published by the Free Software Foundation.  Sun designates this
   55.11 - * particular file as subject to the "Classpath" exception as provided
   55.12 - * by Sun in the LICENSE file that accompanied this code.
   55.13 - *
   55.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   55.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   55.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   55.17 - * version 2 for more details (a copy is included in the LICENSE file that
   55.18 - * accompanied this code).
   55.19 - *
   55.20 - * You should have received a copy of the GNU General Public License version
   55.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   55.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   55.23 - *
   55.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   55.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   55.26 - * have any questions.
   55.27 - */
   55.28 -package sun.awt.motif;
   55.29 -
   55.30 -import java.awt.*;
   55.31 -import java.awt.peer.*;
   55.32 -import java.awt.event.ActionEvent;
   55.33 -import sun.awt.AppContext;
   55.34 -
   55.35 -class MMenuItemPeer implements MenuItemPeer {
   55.36 -    long        pData;
   55.37 -    long        jniGlobalRef;
   55.38 -    boolean     isCheckbox = false;
   55.39 -    MenuItem    target;
   55.40 -    boolean     nativeCreated = false;
   55.41 -
   55.42 -    private boolean disposed = false;
   55.43 -
   55.44 -    static {
   55.45 -        initIDs();
   55.46 -    }
   55.47 -
   55.48 -    /**
   55.49 -     * Initialize JNI field and method IDs
   55.50 -     */
   55.51 -    private static native void initIDs();
   55.52 -
   55.53 -    native void createMenuItem(MMenuPeer parent);
   55.54 -
   55.55 -    void create(MMenuPeer parent) {
   55.56 -        if (parent.nativeCreated) {
   55.57 -            createMenuItem(parent);
   55.58 -            nativeCreated = true;
   55.59 -            setEnabled(target.isEnabled());
   55.60 -        }
   55.61 -    }
   55.62 -
   55.63 -    protected MMenuItemPeer() {
   55.64 -    }
   55.65 -
   55.66 -    MMenuItemPeer(MenuItem target) {
   55.67 -        this.target = target;
   55.68 -        MMenuPeer parent = (MMenuPeer) MToolkit.targetToPeer(getParent_NoClientCode(target));
   55.69 -        create(parent);
   55.70 -    }
   55.71 -
   55.72 -    static native MenuContainer getParent_NoClientCode(MenuComponent menuComponent);
   55.73 -
   55.74 -    protected void finalize() throws Throwable {
   55.75 -        dispose();
   55.76 -        super.finalize();
   55.77 -    }
   55.78 -
   55.79 -    public void setEnabled(boolean b) {
   55.80 -        if (b) {
   55.81 -            enable();
   55.82 -        } else {
   55.83 -            disable();
   55.84 -        }
   55.85 -    }
   55.86 -
   55.87 -    public void setLabel(String label) {
   55.88 -        if (!nativeCreated) {
   55.89 -            return;
   55.90 -        }
   55.91 -        pSetLabel(label);
   55.92 -        // Fix for bug 4234266 AWT component : MenuItem  throw NullPointer exception.
   55.93 -        MenuShortcut sc = target.getShortcut();
   55.94 -        setShortcut(sc != null ? sc.toString() : null );
   55.95 -    }
   55.96 -
   55.97 -    public void setShortcut(String shortCut) {
   55.98 -        if (!nativeCreated) {
   55.99 -            return;
  55.100 -        }
  55.101 -        pSetShortcut(shortCut);
  55.102 -    }
  55.103 -
  55.104 -    native void pSetLabel(String label);
  55.105 -    native void pSetShortcut(String shortCut);
  55.106 -
  55.107 -    /**
  55.108 -     * DEPRECATED but, for now, called by setEnabled(boolean).
  55.109 -     */
  55.110 -    public void enable() {
  55.111 -        if (!nativeCreated) {
  55.112 -            return;
  55.113 -        }
  55.114 -        pEnable();
  55.115 -    }
  55.116 -    native void pEnable();
  55.117 -
  55.118 -    /**
  55.119 -     * DEPRECATED but, for now, called by setEnabled(boolean).
  55.120 -     */
  55.121 -    public void disable() {
  55.122 -        if (!nativeCreated) {
  55.123 -            return;
  55.124 -        }
  55.125 -        pDisable();
  55.126 -    }
  55.127 -    native void pDisable();
  55.128 -
  55.129 -    private void destroyNativeWidgetImpl() {
  55.130 -        if (nativeCreated) {
  55.131 -            pDispose();
  55.132 -            nativeCreated = false;
  55.133 -        }
  55.134 -    }
  55.135 -
  55.136 -    void destroyNativeWidget() {
  55.137 -        // We do not need to synchronize this method because the caller
  55.138 -        // always holds the tree lock
  55.139 -
  55.140 -        destroyNativeWidgetImpl();
  55.141 -    }
  55.142 -
  55.143 -    /*
  55.144 -     * Subclasses should override disposeImpl() instead of dispose(). Client
  55.145 -     * code should always invoke dispose(), never disposeImpl().
  55.146 -     */
  55.147 -    protected void disposeImpl() {
  55.148 -        // Don't call destroyNativeWidget() because on a Menu, this will
  55.149 -        // cause a traversal of all the menu's MenuItems. This traversal was
  55.150 -        // already done once by java.awt.Menu.removeNotify().
  55.151 -
  55.152 -        destroyNativeWidgetImpl();
  55.153 -        MToolkit.targetDisposedPeer(target, this);
  55.154 -    }
  55.155 -    public final void dispose() {
  55.156 -        boolean call_disposeImpl = false;
  55.157 -
  55.158 -        if (!disposed) {
  55.159 -            synchronized (this) {
  55.160 -                if (!disposed) {
  55.161 -                    disposed = call_disposeImpl = true;
  55.162 -                }
  55.163 -            }
  55.164 -        }
  55.165 -
  55.166 -        if (call_disposeImpl) {
  55.167 -            disposeImpl();
  55.168 -        }
  55.169 -    }
  55.170 -
  55.171 -    native void pDispose();
  55.172 -
  55.173 -    void postEvent(AWTEvent event) {
  55.174 -        MToolkit.postEvent(MToolkit.targetToAppContext(target), event);
  55.175 -    }
  55.176 -
  55.177 -    // NOTE: This method may be called by privileged threads.
  55.178 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  55.179 -    public void action(final long when, final int modifiers) {
  55.180 -
  55.181 -        MToolkit.executeOnEventHandlerThread(target, new Runnable() {
  55.182 -            public void run() {
  55.183 -                postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
  55.184 -                                          target.getActionCommand(), when,
  55.185 -                                          modifiers));
  55.186 -            }
  55.187 -        });
  55.188 -    }
  55.189 -
  55.190 -    // Needed for MenuComponentPeer.
  55.191 -    public void setFont(Font f) {
  55.192 -    }
  55.193 -}
    56.1 --- a/src/solaris/classes/sun/awt/motif/MMenuPeer.java	Wed Sep 17 13:45:37 2008 -0700
    56.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.3 @@ -1,83 +0,0 @@
    56.4 -/*
    56.5 - * Copyright 1995-1999 Sun Microsystems, Inc.  All Rights Reserved.
    56.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    56.7 - *
    56.8 - * This code is free software; you can redistribute it and/or modify it
    56.9 - * under the terms of the GNU General Public License version 2 only, as
   56.10 - * published by the Free Software Foundation.  Sun designates this
   56.11 - * particular file as subject to the "Classpath" exception as provided
   56.12 - * by Sun in the LICENSE file that accompanied this code.
   56.13 - *
   56.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   56.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   56.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   56.17 - * version 2 for more details (a copy is included in the LICENSE file that
   56.18 - * accompanied this code).
   56.19 - *
   56.20 - * You should have received a copy of the GNU General Public License version
   56.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   56.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   56.23 - *
   56.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   56.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   56.26 - * have any questions.
   56.27 - */
   56.28 -package sun.awt.motif;
   56.29 -
   56.30 -import java.awt.*;
   56.31 -import java.awt.peer.*;
   56.32 -
   56.33 -public class MMenuPeer extends MMenuItemPeer implements MenuPeer {
   56.34 -    native void createMenu(MMenuBarPeer parent);
   56.35 -    native void createSubMenu(MMenuPeer parent);
   56.36 -
   56.37 -    void create(MMenuPeer parent) {
   56.38 -        if (parent.nativeCreated) {
   56.39 -            createSubMenu(parent);
   56.40 -            nativeCreated = true;
   56.41 -        }
   56.42 -    }
   56.43 -
   56.44 -    protected MMenuPeer() {
   56.45 -    }
   56.46 -
   56.47 -    public MMenuPeer(Menu target) {
   56.48 -        this.target = target;
   56.49 -        MenuContainer parent = getParent_NoClientCode(target);
   56.50 -
   56.51 -        if (parent instanceof MenuBar) {
   56.52 -            MMenuBarPeer mb = (MMenuBarPeer) MToolkit.targetToPeer(parent);
   56.53 -            createMenu(mb);
   56.54 -            nativeCreated = true;
   56.55 -        } else if (parent instanceof Menu) {
   56.56 -            MMenuPeer m = (MMenuPeer) MToolkit.targetToPeer(parent);
   56.57 -            create(m);
   56.58 -        } else {
   56.59 -            throw new IllegalArgumentException("unknown menu container class");
   56.60 -        }
   56.61 -    }
   56.62 -
   56.63 -    public void addSeparator() {
   56.64 -    }
   56.65 -    public void addItem(MenuItem item) {
   56.66 -    }
   56.67 -    public void delItem(int index) {
   56.68 -    }
   56.69 -
   56.70 -    void destroyNativeWidget() {
   56.71 -        // We do not need to synchronize this method because the caller
   56.72 -        // always holds the tree lock
   56.73 -
   56.74 -        if (nativeCreated) {
   56.75 -            Menu menu = (Menu) target;
   56.76 -            int nitems = menu.getItemCount();
   56.77 -            for (int i = 0 ; i < nitems ; i++) {
   56.78 -                MMenuItemPeer mipeer =
   56.79 -                    (MMenuItemPeer) MToolkit.targetToPeer(menu.getItem(i));
   56.80 -                mipeer.destroyNativeWidget();
   56.81 -            }
   56.82 -            super.destroyNativeWidget();
   56.83 -        }
   56.84 -    }
   56.85 -    native void pDispose();
   56.86 -}
    57.1 --- a/src/solaris/classes/sun/awt/motif/MMouseDragGestureRecognizer.java	Wed Sep 17 13:45:37 2008 -0700
    57.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.3 @@ -1,233 +0,0 @@
    57.4 -/*
    57.5 - * Copyright 1998-2003 Sun Microsystems, Inc.  All Rights Reserved.
    57.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    57.7 - *
    57.8 - * This code is free software; you can redistribute it and/or modify it
    57.9 - * under the terms of the GNU General Public License version 2 only, as
   57.10 - * published by the Free Software Foundation.  Sun designates this
   57.11 - * particular file as subject to the "Classpath" exception as provided
   57.12 - * by Sun in the LICENSE file that accompanied this code.
   57.13 - *
   57.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   57.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   57.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   57.17 - * version 2 for more details (a copy is included in the LICENSE file that
   57.18 - * accompanied this code).
   57.19 - *
   57.20 - * You should have received a copy of the GNU General Public License version
   57.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   57.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   57.23 - *
   57.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   57.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   57.26 - * have any questions.
   57.27 - */
   57.28 -
   57.29 -package sun.awt.motif;
   57.30 -
   57.31 -import java.awt.Toolkit;
   57.32 -import java.awt.Component;
   57.33 -
   57.34 -import java.awt.Point;
   57.35 -import java.awt.dnd.DnDConstants;
   57.36 -import java.awt.dnd.DragSource;
   57.37 -import java.awt.dnd.MouseDragGestureRecognizer;
   57.38 -import java.awt.dnd.DragGestureListener;
   57.39 -
   57.40 -import java.awt.event.InputEvent;
   57.41 -import java.awt.event.MouseEvent;
   57.42 -import java.awt.event.MouseListener;
   57.43 -import java.awt.event.MouseMotionListener;
   57.44 -
   57.45 -import java.lang.reflect.*;
   57.46 -
   57.47 -import sun.awt.dnd.SunDragSourceContextPeer;
   57.48 -
   57.49 -/**
   57.50 - * <p>
   57.51 - * This subclass of MouseDragGestureRecognizer defines a DragGestureRecognizer
   57.52 - * for Mouse based gestures on OSF/Motif.
   57.53 - * </p>
   57.54 - *
   57.55 - * @author Laurence P. G. Cable
   57.56 - *
   57.57 - * @see java.awt.dnd.DragGestureListener
   57.58 - * @see java.awt.dnd.DragGestureEvent
   57.59 - * @see java.awt.dnd.DragSource
   57.60 - */
   57.61 -
   57.62 -class MMouseDragGestureRecognizer extends MouseDragGestureRecognizer {
   57.63 -
   57.64 -    private static final long serialVersionUID = -841711780352520383L;
   57.65 -
   57.66 -    /*
   57.67 -     * constant for number of pixels hysterisis before drag is determined
   57.68 -     * to have started
   57.69 -     */
   57.70 -
   57.71 -    protected static int motionThreshold;
   57.72 -
   57.73 -
   57.74 -    protected static final int ButtonMask = InputEvent.BUTTON1_DOWN_MASK |
   57.75 -                                            InputEvent.BUTTON2_DOWN_MASK |
   57.76 -                                            InputEvent.BUTTON3_DOWN_MASK;
   57.77 -
   57.78 -    /**
   57.79 -     * construct a new MMouseDragGestureRecognizer
   57.80 -     *
   57.81 -     * @param ds  The DragSource for the Component c
   57.82 -     * @param c   The Component to observe
   57.83 -     * @param act The actions permitted for this Drag
   57.84 -     * @param dgl The DragGestureRecognizer to notify when a gesture is detected
   57.85 -     *
   57.86 -     */
   57.87 -
   57.88 -    protected MMouseDragGestureRecognizer(DragSource ds, Component c, int act, DragGestureListener dgl) {
   57.89 -        super(ds, c, act, dgl);
   57.90 -    }
   57.91 -
   57.92 -    /**
   57.93 -     * construct a new MMouseDragGestureRecognizer
   57.94 -     *
   57.95 -     * @param ds  The DragSource for the Component c
   57.96 -     * @param c   The Component to observe
   57.97 -     * @param act The actions permitted for this Drag
   57.98 -     */
   57.99 -
  57.100 -    protected MMouseDragGestureRecognizer(DragSource ds, Component c, int act) {
  57.101 -        this(ds, c, act, null);
  57.102 -    }
  57.103 -
  57.104 -    /**
  57.105 -     * construct a new MMouseDragGestureRecognizer
  57.106 -     *
  57.107 -     * @param ds  The DragSource for the Component c
  57.108 -     * @param c   The Component to observe
  57.109 -     */
  57.110 -
  57.111 -    protected MMouseDragGestureRecognizer(DragSource ds, Component c) {
  57.112 -        this(ds, c, DnDConstants.ACTION_NONE);
  57.113 -    }
  57.114 -
  57.115 -    /**
  57.116 -     * construct a new MMouseDragGestureRecognizer
  57.117 -     *
  57.118 -     * @param ds  The DragSource for the Component c
  57.119 -     */
  57.120 -
  57.121 -    protected MMouseDragGestureRecognizer(DragSource ds) {
  57.122 -        this(ds, null);
  57.123 -    }
  57.124 -
  57.125 -    /**
  57.126 -     * determine the drop action from the event
  57.127 -     */
  57.128 -
  57.129 -    protected int mapDragOperationFromModifiers(MouseEvent e) {
  57.130 -        int mods = e.getModifiersEx();
  57.131 -        int btns = mods & ButtonMask;
  57.132 -
  57.133 -        // Do not allow right mouse button drag since Motif DnD does not
  57.134 -        // terminate drag operation on right mouse button release.
  57.135 -        if (!(btns == InputEvent.BUTTON1_DOWN_MASK ||
  57.136 -              btns == InputEvent.BUTTON2_DOWN_MASK)) {
  57.137 -            return DnDConstants.ACTION_NONE;
  57.138 -        }
  57.139 -
  57.140 -        return
  57.141 -            SunDragSourceContextPeer.convertModifiersToDropAction(mods,
  57.142 -                                                                  getSourceActions());
  57.143 -    }
  57.144 -
  57.145 -    /**
  57.146 -     * Invoked when the mouse has been clicked on a component.
  57.147 -     */
  57.148 -
  57.149 -    public void mouseClicked(MouseEvent e) {
  57.150 -        // do nothing
  57.151 -    }
  57.152 -
  57.153 -    /**
  57.154 -     * Invoked when a mouse button has been pressed on a component.
  57.155 -     */
  57.156 -
  57.157 -    public void mousePressed(MouseEvent e) {
  57.158 -        events.clear();
  57.159 -
  57.160 -        if (mapDragOperationFromModifiers(e) != DnDConstants.ACTION_NONE) {
  57.161 -            try {
  57.162 -                motionThreshold = DragSource.getDragThreshold();
  57.163 -            } catch (Exception exc) {
  57.164 -                motionThreshold = 5;
  57.165 -            }
  57.166 -            appendEvent(e);
  57.167 -        }
  57.168 -    }
  57.169 -
  57.170 -    /**
  57.171 -     * Invoked when a mouse button has been released on a component.
  57.172 -     */
  57.173 -
  57.174 -    public void mouseReleased(MouseEvent e) {
  57.175 -        events.clear();
  57.176 -    }
  57.177 -
  57.178 -    /**
  57.179 -     * Invoked when the mouse enters a component.
  57.180 -     */
  57.181 -
  57.182 -    public void mouseEntered(MouseEvent e) {
  57.183 -        events.clear();
  57.184 -    }
  57.185 -
  57.186 -    /**
  57.187 -     * Invoked when the mouse exits a component.
  57.188 -     */
  57.189 -
  57.190 -    public void mouseExited(MouseEvent e) {
  57.191 -        if (!events.isEmpty()) { // gesture pending
  57.192 -            int dragAction = mapDragOperationFromModifiers(e);
  57.193 -
  57.194 -            if (dragAction == DnDConstants.ACTION_NONE) {
  57.195 -                events.clear();
  57.196 -            }
  57.197 -        }
  57.198 -    }
  57.199 -
  57.200 -    /**
  57.201 -     * Invoked when a mouse button is pressed on a component.
  57.202 -     */
  57.203 -
  57.204 -    public void mouseDragged(MouseEvent e) {
  57.205 -        if (!events.isEmpty()) { // gesture pending
  57.206 -            int dop = mapDragOperationFromModifiers(e);
  57.207 -
  57.208 -
  57.209 -            if (dop == DnDConstants.ACTION_NONE) {
  57.210 -                return;
  57.211 -            }
  57.212 -
  57.213 -            MouseEvent trigger = (MouseEvent)events.get(0);
  57.214 -
  57.215 -            Point      origin  = trigger.getPoint();
  57.216 -            Point      current = e.getPoint();
  57.217 -
  57.218 -            int        dx      = Math.abs(origin.x - current.x);
  57.219 -            int        dy      = Math.abs(origin.y - current.y);
  57.220 -
  57.221 -            if (dx > motionThreshold || dy > motionThreshold) {
  57.222 -                fireDragGestureRecognized(dop, ((MouseEvent)getTriggerEvent()).getPoint());
  57.223 -            } else
  57.224 -                appendEvent(e);
  57.225 -        }
  57.226 -    }
  57.227 -
  57.228 -    /**
  57.229 -     * Invoked when the mouse button has been moved on a component
  57.230 -     * (with no buttons no down).
  57.231 -     */
  57.232 -
  57.233 -    public void mouseMoved(MouseEvent e) {
  57.234 -        // do nothing
  57.235 -    }
  57.236 -}
    58.1 --- a/src/solaris/classes/sun/awt/motif/MPanelPeer.java	Wed Sep 17 13:45:37 2008 -0700
    58.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.3 @@ -1,201 +0,0 @@
    58.4 -/*
    58.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
    58.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    58.7 - *
    58.8 - * This code is free software; you can redistribute it and/or modify it
    58.9 - * under the terms of the GNU General Public License version 2 only, as
   58.10 - * published by the Free Software Foundation.  Sun designates this
   58.11 - * particular file as subject to the "Classpath" exception as provided
   58.12 - * by Sun in the LICENSE file that accompanied this code.
   58.13 - *
   58.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   58.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   58.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   58.17 - * version 2 for more details (a copy is included in the LICENSE file that
   58.18 - * accompanied this code).
   58.19 - *
   58.20 - * You should have received a copy of the GNU General Public License version
   58.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   58.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   58.23 - *
   58.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   58.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   58.26 - * have any questions.
   58.27 - */
   58.28 -package sun.awt.motif;
   58.29 -
   58.30 -import java.awt.*;
   58.31 -import java.awt.peer.*;
   58.32 -
   58.33 -import sun.awt.SunGraphicsCallback;
   58.34 -
   58.35 -class MPanelPeer extends MCanvasPeer implements PanelPeer {
   58.36 -
   58.37 -    MPanelPeer() {}
   58.38 -
   58.39 -    MPanelPeer(Component target) {
   58.40 -        super(target);
   58.41 -    }
   58.42 -
   58.43 -    MPanelPeer(Component target, Object arg) {
   58.44 -        super(target, arg);
   58.45 -    }
   58.46 -
   58.47 -    public Insets getInsets() {
   58.48 -        return new Insets(0, 0, 0, 0);
   58.49 -    }
   58.50 -
   58.51 -    public void paint(Graphics g) {
   58.52 -        super.paint(g);
   58.53 -        SunGraphicsCallback.PaintHeavyweightComponentsCallback.getInstance().
   58.54 -            runComponents(((Container)target).getComponents(), g,
   58.55 -                          SunGraphicsCallback.LIGHTWEIGHTS |
   58.56 -                          SunGraphicsCallback.HEAVYWEIGHTS);
   58.57 -    }
   58.58 -    public void print(Graphics g) {
   58.59 -        super.print(g);
   58.60 -        SunGraphicsCallback.PrintHeavyweightComponentsCallback.getInstance().
   58.61 -            runComponents(((Container)target).getComponents(), g,
   58.62 -                          SunGraphicsCallback.LIGHTWEIGHTS |
   58.63 -                          SunGraphicsCallback.HEAVYWEIGHTS);
   58.64 -    }
   58.65 -
   58.66 -    public void setBackground(Color c) {
   58.67 -        Component comp;
   58.68 -        int i;
   58.69 -
   58.70 -        Container cont = (Container) target;
   58.71 -        synchronized(target.getTreeLock()) {
   58.72 -            int n = cont.getComponentCount();
   58.73 -            for(i=0; i < n; i++) {
   58.74 -                comp = cont.getComponent(i);
   58.75 -                MComponentPeer peer = (MComponentPeer) MToolkit.targetToPeer(comp);
   58.76 -                if (peer != null) {
   58.77 -                    Color color = comp.getBackground();
   58.78 -                    if (color == null || color.equals(c)) {
   58.79 -                        peer.setBackground(c);
   58.80 -                        peer.pSetBackground(c);
   58.81 -                    }
   58.82 -                    if ((comp instanceof java.awt.List) ||
   58.83 -                           (comp instanceof java.awt.TextArea) ||
   58.84 -                           (comp instanceof java.awt.ScrollPane)) {
   58.85 -                        peer.pSetScrollbarBackground(c);
   58.86 -                    }
   58.87 -                }
   58.88 -            }
   58.89 -        }
   58.90 -        pSetBackground(c);
   58.91 -    }
   58.92 -
   58.93 -    public void setForeground(Color c) {
   58.94 -        Component comp;
   58.95 -        int i;
   58.96 -
   58.97 -        Container cont = (Container) target;
   58.98 -        synchronized(target.getTreeLock()) {
   58.99 -            int n = cont.getComponentCount();
  58.100 -            for(i=0; i < n; i++) {
  58.101 -                comp = cont.getComponent(i);
  58.102 -                MComponentPeer peer = (MComponentPeer) MToolkit.targetToPeer(comp);
  58.103 -                if (peer != null) {
  58.104 -                    Color color = comp.getForeground();
  58.105 -                    if (color == null || color.equals(c)) {
  58.106 -                        peer.setForeground(c);
  58.107 -                        peer.pSetForeground(c);
  58.108 -                    }
  58.109 -                    if ((comp instanceof java.awt.List) ||
  58.110 -                           (comp instanceof java.awt.TextArea) ||
  58.111 -                           (comp instanceof java.awt.ScrollPane)) {
  58.112 -                        peer.pSetInnerForeground(c);
  58.113 -                    }
  58.114 -                }
  58.115 -            }
  58.116 -        }
  58.117 -        pSetForeground(c);
  58.118 -    }
  58.119 -
  58.120 -    /**
  58.121 -     * DEPRECATED:  Replaced by getInsets().
  58.122 -     */
  58.123 -    public Insets insets() {
  58.124 -        return getInsets();
  58.125 -    }
  58.126 -
  58.127 -    /**
  58.128 -     * Recursive method that handles the propagation of the displayChanged
  58.129 -     * event into the entire hierarchy of peers.
  58.130 -     * Unlike on win32, on X we don't worry about handling on-the-fly
  58.131 -     * display settings changes, only windows being dragged across Xinerama
  58.132 -     * screens.  Thus, we only need to tell MCanvasPeers, not all
  58.133 -     * MComponentPeers.
  58.134 -     */
  58.135 -     private void recursiveDisplayChanged(Component c, int screenNum) {
  58.136 -        if (c instanceof Container) {
  58.137 -            Component children[] = ((Container)c).getComponents();
  58.138 -            for (int i = 0; i < children.length; ++i) {
  58.139 -                recursiveDisplayChanged(children[i], screenNum);
  58.140 -            }
  58.141 -        }
  58.142 -        ComponentPeer peer = c.getPeer();
  58.143 -        if (peer != null && peer instanceof MCanvasPeer) {
  58.144 -            MCanvasPeer mPeer = (MCanvasPeer)peer;
  58.145 -            mPeer.displayChanged(screenNum);
  58.146 -        }
  58.147 -    }
  58.148 -
  58.149 -    /*
  58.150 -     * Often up-called from a MWindowPeer instance.
  58.151 -     * Calls displayChanged() on all child canvas' peers.
  58.152 -     * Recurses into Container children to ensure all canvases
  58.153 -     * get the message.
  58.154 -     */
  58.155 -    public void displayChanged(int screenNum) {
  58.156 -       // Don't do super call because MWindowPeer has already updated its GC
  58.157 -
  58.158 -       Component children[] = ((Container)target).getComponents();
  58.159 -
  58.160 -       for (int i = 0; i < children.length; i++) {
  58.161 -           recursiveDisplayChanged(children[i], screenNum);
  58.162 -       }
  58.163 -   }
  58.164 -
  58.165 -    protected boolean shouldFocusOnClick() {
  58.166 -        // Return false if this container has children so in that case it won't
  58.167 -        // be focused. Return true otherwise.
  58.168 -        return ((Container)target).getComponentCount() == 0;
  58.169 -    }
  58.170 -
  58.171 -    private native void pEnsureIndex(ComponentPeer child, int index);
  58.172 -    private native void pRestack();
  58.173 -
  58.174 -    private int restack(Container cont, int ind) {
  58.175 -        for (int i = 0; i < cont.getComponentCount(); i++) {
  58.176 -            Component comp = cont.getComponent(i);
  58.177 -            if (!comp.isLightweight()) {
  58.178 -                if (comp.getPeer() != null) {
  58.179 -                    pEnsureIndex(comp.getPeer(), ind++);
  58.180 -                }
  58.181 -            }
  58.182 -            if (comp.isLightweight() && comp instanceof Container) {
  58.183 -                ind = restack((Container)comp, ind);
  58.184 -            }
  58.185 -        }
  58.186 -        return ind;
  58.187 -    }
  58.188 -
  58.189 -    /**
  58.190 -     * @see java.awt.peer.ContainerPeer#restack
  58.191 -     */
  58.192 -    public void restack() {
  58.193 -        Container cont = (Container)target;
  58.194 -        restack(cont, 0);
  58.195 -        pRestack();
  58.196 -    }
  58.197 -
  58.198 -    /**
  58.199 -     * @see java.awt.peer.ContainerPeer#isRestackSupported
  58.200 -     */
  58.201 -    public boolean isRestackSupported() {
  58.202 -        return true;
  58.203 -    }
  58.204 -}
    59.1 --- a/src/solaris/classes/sun/awt/motif/MPopupMenuPeer.java	Wed Sep 17 13:45:37 2008 -0700
    59.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.3 @@ -1,132 +0,0 @@
    59.4 -/*
    59.5 - * Copyright 1996-1998 Sun Microsystems, Inc.  All Rights Reserved.
    59.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    59.7 - *
    59.8 - * This code is free software; you can redistribute it and/or modify it
    59.9 - * under the terms of the GNU General Public License version 2 only, as
   59.10 - * published by the Free Software Foundation.  Sun designates this
   59.11 - * particular file as subject to the "Classpath" exception as provided
   59.12 - * by Sun in the LICENSE file that accompanied this code.
   59.13 - *
   59.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   59.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   59.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   59.17 - * version 2 for more details (a copy is included in the LICENSE file that
   59.18 - * accompanied this code).
   59.19 - *
   59.20 - * You should have received a copy of the GNU General Public License version
   59.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   59.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   59.23 - *
   59.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   59.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   59.26 - * have any questions.
   59.27 - */
   59.28 -package sun.awt.motif;
   59.29 -
   59.30 -import java.awt.*;
   59.31 -import java.awt.peer.*;
   59.32 -
   59.33 -public class MPopupMenuPeer extends MMenuPeer implements PopupMenuPeer {
   59.34 -
   59.35 -    static {
   59.36 -        initIDs();
   59.37 -    }
   59.38 -
   59.39 -    /* initialize the methodIDs of methods that may be accessed from C */
   59.40 -    private native static void initIDs();
   59.41 -
   59.42 -    native void createMenu(MComponentPeer parent);
   59.43 -
   59.44 -    void createPopupMenu() {
   59.45 -        if (MMenuItemPeer.getParent_NoClientCode(target) instanceof Component) {
   59.46 -            Component parent = (Component)getParent_NoClientCode(target);
   59.47 -            MComponentPeer parentPeer = (MComponentPeer) MToolkit.targetToPeer(parent);
   59.48 -            if (parentPeer == null) {
   59.49 -                // because the menu isn't a component (sigh) we first have to wait
   59.50 -                // for a failure to map the peer which should only happen for a
   59.51 -                // lightweight container, then find the actual native parent from
   59.52 -                // that component.
   59.53 -                parent = MToolkit.getNativeContainer(parent);
   59.54 -                parentPeer = (MComponentPeer) MToolkit.targetToPeer(parent);
   59.55 -            }
   59.56 -            createMenu(parentPeer);
   59.57 -            nativeCreated = true;
   59.58 -            createItems((Menu)target);
   59.59 -
   59.60 -        } else {
   59.61 -            throw new IllegalArgumentException("illegal popup menu container class");
   59.62 -        }
   59.63 -    }
   59.64 -
   59.65 -    void createItems(Menu target) {
   59.66 -        int nitems = target.getItemCount();
   59.67 -        MMenuPeer parent = (MMenuPeer)MToolkit.targetToPeer(target);
   59.68 -        for (int i = 0 ; i < nitems ; i++) {
   59.69 -            MenuItem mitem = target.getItem(i);
   59.70 -            MMenuItemPeer mipeer = (MMenuItemPeer)MToolkit.targetToPeer(mitem);
   59.71 -            mipeer.create(parent);
   59.72 -            if (mitem instanceof Menu) {
   59.73 -                createItems((Menu)mitem);
   59.74 -            }
   59.75 -        }
   59.76 -    }
   59.77 -
   59.78 -    public MPopupMenuPeer(PopupMenu target) {
   59.79 -        // Do NOT instantiate native widget until just before showing the
   59.80 -        // menu, else right mouse click will cause display to lock up
   59.81 -        // (because of passive grab in Motif)
   59.82 -        //
   59.83 -        this.target = target;
   59.84 -    }
   59.85 -
   59.86 -    native void pShow(Event evt, int x, int y, MComponentPeer origin);
   59.87 -
   59.88 -    public void show(Event evt) {
   59.89 -
   59.90 -        if (!nativeCreated)
   59.91 -            createPopupMenu();
   59.92 -
   59.93 -        Component origin = (Component)evt.target;
   59.94 -        MComponentPeer peer = (MComponentPeer) MToolkit.targetToPeer(origin);
   59.95 -        int x = evt.x;
   59.96 -        int y = evt.y;
   59.97 -        if (peer == null) {
   59.98 -            // A failure to map the peer should only happen for a
   59.99 -            // lightweight component, then find the actual native parent from
  59.100 -            // that component.  The event coorinates are going to have to be
  59.101 -            Component nativeOrigin = MToolkit.getNativeContainer(origin);
  59.102 -            peer = (MComponentPeer) MToolkit.targetToPeer(nativeOrigin);
  59.103 -
  59.104 -            // remove the event coordinates
  59.105 -            for (Component c = origin; c != nativeOrigin;
  59.106 -                              c = MComponentPeer.getParent_NoClientCode(c)) {
  59.107 -                Point p = c.getLocation();
  59.108 -                x += p.x;
  59.109 -                y += p.y;
  59.110 -            }
  59.111 -        }
  59.112 -        pShow(evt, x, y, peer);
  59.113 -    }
  59.114 -
  59.115 -    /**
  59.116 -     * This is the callback function called on the Motif thread by
  59.117 -     * Popup_popdownCB(Widget, XtPointer, XtPointer) in awt_PopupMenu.c.
  59.118 -     */
  59.119 -    // NOTE: This method may be called by privileged threads.
  59.120 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  59.121 -    private void destroyNativeWidgetAfterGettingTreeLock() {
  59.122 -
  59.123 -        MToolkit.executeOnEventHandlerThread(target, new Runnable() {
  59.124 -            public void run() {
  59.125 -
  59.126 -                Object treeLock = new Button().getTreeLock();
  59.127 -                synchronized (treeLock) {
  59.128 -                    destroyNativeWidget();
  59.129 -                }
  59.130 -            }
  59.131 -        });
  59.132 -    }
  59.133 -
  59.134 -    native void pDispose();
  59.135 -} // class MPopupMenuPeer
    60.1 --- a/src/solaris/classes/sun/awt/motif/MRobotPeer.java	Wed Sep 17 13:45:37 2008 -0700
    60.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.3 @@ -1,96 +0,0 @@
    60.4 -/*
    60.5 - * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
    60.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    60.7 - *
    60.8 - * This code is free software; you can redistribute it and/or modify it
    60.9 - * under the terms of the GNU General Public License version 2 only, as
   60.10 - * published by the Free Software Foundation.  Sun designates this
   60.11 - * particular file as subject to the "Classpath" exception as provided
   60.12 - * by Sun in the LICENSE file that accompanied this code.
   60.13 - *
   60.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   60.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   60.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   60.17 - * version 2 for more details (a copy is included in the LICENSE file that
   60.18 - * accompanied this code).
   60.19 - *
   60.20 - * You should have received a copy of the GNU General Public License version
   60.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   60.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   60.23 - *
   60.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   60.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   60.26 - * have any questions.
   60.27 - */
   60.28 -package sun.awt.motif;
   60.29 -
   60.30 -import java.awt.*;
   60.31 -import java.awt.peer.*;
   60.32 -import java.security.*;
   60.33 -import sun.awt.X11GraphicsConfig;
   60.34 -
   60.35 -class MRobotPeer implements RobotPeer {
   60.36 -    private X11GraphicsConfig   xgc = null;
   60.37 -    /*
   60.38 -     * native implementation uses some static shared data (pipes, processes)
   60.39 -     * so use a class lock to synchronize native method calls
   60.40 -     */
   60.41 -    static Object robotLock = new Object();
   60.42 -
   60.43 -    MRobotPeer(GraphicsConfiguration gc) {
   60.44 -        this.xgc = (X11GraphicsConfig)gc;
   60.45 -        setup();
   60.46 -    }
   60.47 -
   60.48 -    public void dispose() {
   60.49 -        // does nothing
   60.50 -    }
   60.51 -
   60.52 -    public void mouseMove(int x, int y) {
   60.53 -        mouseMoveImpl(xgc, x, y);
   60.54 -    }
   60.55 -
   60.56 -    public void mousePress(int buttons) {
   60.57 -        mousePressImpl(buttons);
   60.58 -    }
   60.59 -
   60.60 -    public void mouseRelease(int buttons) {
   60.61 -        mouseReleaseImpl(buttons);
   60.62 -    }
   60.63 -
   60.64 -    public void mouseWheel(int wheelAmt) {
   60.65 -    mouseWheelImpl(wheelAmt);
   60.66 -    }
   60.67 -
   60.68 -    public void keyPress(int keycode) {
   60.69 -        keyPressImpl(keycode);
   60.70 -    }
   60.71 -
   60.72 -    public void keyRelease(int keycode) {
   60.73 -        keyReleaseImpl(keycode);
   60.74 -    }
   60.75 -
   60.76 -    public int getRGBPixel(int x, int y) {
   60.77 -        int pixelArray[] = new int[1];
   60.78 -        getRGBPixelsImpl(xgc, x, y, 1, 1, pixelArray);
   60.79 -        return pixelArray[0];
   60.80 -    }
   60.81 -
   60.82 -    public int [] getRGBPixels(Rectangle bounds) {
   60.83 -        int pixelArray[] = new int[bounds.width*bounds.height];
   60.84 -        getRGBPixelsImpl(xgc, bounds.x, bounds.y, bounds.width, bounds.height, pixelArray);
   60.85 -        return pixelArray;
   60.86 -    }
   60.87 -
   60.88 -    private static native synchronized void setup();
   60.89 -
   60.90 -    private static native synchronized void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y);
   60.91 -    private static native synchronized void mousePressImpl(int buttons);
   60.92 -    private static native synchronized void mouseReleaseImpl(int buttons);
   60.93 -    private static native synchronized void mouseWheelImpl(int wheelAmt);
   60.94 -
   60.95 -    private static native synchronized void keyPressImpl(int keycode);
   60.96 -    private static native synchronized void keyReleaseImpl(int keycode);
   60.97 -
   60.98 -    private static native synchronized void getRGBPixelsImpl(X11GraphicsConfig xgc, int x, int y, int width, int height, int pixelArray[]);
   60.99 -}
    61.1 --- a/src/solaris/classes/sun/awt/motif/MScrollPanePeer.java	Wed Sep 17 13:45:37 2008 -0700
    61.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.3 @@ -1,411 +0,0 @@
    61.4 -/*
    61.5 - * Copyright 1996-2003 Sun Microsystems, Inc.  All Rights Reserved.
    61.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    61.7 - *
    61.8 - * This code is free software; you can redistribute it and/or modify it
    61.9 - * under the terms of the GNU General Public License version 2 only, as
   61.10 - * published by the Free Software Foundation.  Sun designates this
   61.11 - * particular file as subject to the "Classpath" exception as provided
   61.12 - * by Sun in the LICENSE file that accompanied this code.
   61.13 - *
   61.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   61.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   61.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   61.17 - * version 2 for more details (a copy is included in the LICENSE file that
   61.18 - * accompanied this code).
   61.19 - *
   61.20 - * You should have received a copy of the GNU General Public License version
   61.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   61.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   61.23 - *
   61.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   61.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   61.26 - * have any questions.
   61.27 - */
   61.28 -
   61.29 -package sun.awt.motif;
   61.30 -
   61.31 -import java.awt.*;
   61.32 -import java.awt.event.AdjustmentEvent;
   61.33 -import java.awt.peer.ScrollPanePeer;
   61.34 -
   61.35 -import java.util.logging.*;
   61.36 -
   61.37 -import sun.awt.PeerEvent;
   61.38 -
   61.39 -class MScrollPanePeer extends MPanelPeer implements ScrollPanePeer {
   61.40 -
   61.41 -    private static final Logger log = Logger.getLogger("sun.awt.motif.MScrollPanePeer");
   61.42 -
   61.43 -    final static int UNIT_INCREMENT = 0;
   61.44 -    final static int BLOCK_INCREMENT = 1;
   61.45 -
   61.46 -    boolean ignore;
   61.47 -
   61.48 -    native void create(MComponentPeer parent);
   61.49 -
   61.50 -    static {
   61.51 -        initIDs();
   61.52 -    }
   61.53 -
   61.54 -    /**
   61.55 -     * Initialize JNI field and method IDs
   61.56 -     */
   61.57 -    private static native void initIDs();
   61.58 -
   61.59 -    MScrollPanePeer(Component target) {
   61.60 -        init(target);
   61.61 -        scrollPaneInit();
   61.62 -    }
   61.63 -
   61.64 -    MScrollPanePeer(Component target, Object arg) {
   61.65 -        init(target, arg);
   61.66 -        scrollPaneInit();
   61.67 -    }
   61.68 -
   61.69 -    void scrollPaneInit() {
   61.70 -        ignore = false;
   61.71 -        ScrollPane sp = (ScrollPane)target;
   61.72 -        Adjustable vadj, hadj;
   61.73 -        if ((vadj = sp.getVAdjustable()) != null) {
   61.74 -            pSetIncrement(Adjustable.VERTICAL, UNIT_INCREMENT, vadj.getUnitIncrement());
   61.75 -        }
   61.76 -        if ((hadj = sp.getHAdjustable()) != null) {
   61.77 -            pSetIncrement(Adjustable.HORIZONTAL, UNIT_INCREMENT, hadj.getUnitIncrement());
   61.78 -        }
   61.79 -        super.pSetScrollbarBackground(sp.getBackground());
   61.80 -    }
   61.81 -
   61.82 -    public void setScrollChild(MComponentPeer child) {
   61.83 -        pSetScrollChild(child);
   61.84 -    }
   61.85 -
   61.86 -    public void setBackground(Color c) {
   61.87 -        super.setBackground(c);
   61.88 -        pSetScrollbarBackground(c);
   61.89 -    }
   61.90 -
   61.91 -    public void setForeground(Color c) {
   61.92 -        super.setForeground(c);
   61.93 -        pSetInnerForeground(c);
   61.94 -    }
   61.95 -
   61.96 -    native void pSetScrollChild(MComponentPeer child);
   61.97 -    native void pSetIncrement(int orient, int type, int incr);
   61.98 -    native int pGetScrollbarSpace(int orient);
   61.99 -    native int pGetBlockIncrement(int orient);
  61.100 -    native Insets pInsets(int w, int h, int childw, int childh);
  61.101 -    native int pGetShadow();
  61.102 -
  61.103 -    public int getHScrollbarHeight() {
  61.104 -        ScrollPane sp = (ScrollPane)target;
  61.105 -        if (sp.getScrollbarDisplayPolicy() == ScrollPane.SCROLLBARS_NEVER) {
  61.106 -            return 0;
  61.107 -        } else {
  61.108 -            return pGetScrollbarSpace(Adjustable.HORIZONTAL);
  61.109 -        }
  61.110 -    }
  61.111 -
  61.112 -    public int getVScrollbarWidth() {
  61.113 -        ScrollPane sp = (ScrollPane)target;
  61.114 -        if (sp.getScrollbarDisplayPolicy() == ScrollPane.SCROLLBARS_NEVER) {
  61.115 -            return 0;
  61.116 -        } else {
  61.117 -            return pGetScrollbarSpace(Adjustable.VERTICAL);
  61.118 -        }
  61.119 -    }
  61.120 -
  61.121 -    public Insets insets() {
  61.122 -        ScrollPane sp = (ScrollPane)target;
  61.123 -        Dimension d = sp.size();
  61.124 -        Dimension cd;
  61.125 -        Component c = getScrollChild();
  61.126 -        if (c != null) {
  61.127 -            cd = c.size();
  61.128 -        } else {
  61.129 -            cd = new Dimension(0, 0);
  61.130 -        }
  61.131 -        return pInsets(d.width, d.height, cd.width, cd.height);
  61.132 -    }
  61.133 -
  61.134 -    public void setUnitIncrement(Adjustable adj, int u) {
  61.135 -        ScrollPane sp = (ScrollPane)target;
  61.136 -        if (sp.getScrollbarDisplayPolicy() != ScrollPane.SCROLLBARS_NEVER) {
  61.137 -            pSetIncrement(adj.getOrientation(), UNIT_INCREMENT, u);
  61.138 -        }
  61.139 -    }
  61.140 -
  61.141 -    public void setValue(Adjustable adj, int v) {
  61.142 -        if (! ignore) {
  61.143 -            Point p;
  61.144 -            Component c = getScrollChild();
  61.145 -            if (c == null) {
  61.146 -                return;
  61.147 -            }
  61.148 -            p = c.getLocation();
  61.149 -            switch(adj.getOrientation()) {
  61.150 -            case Adjustable.VERTICAL:
  61.151 -                setScrollPosition(-(p.x), v);
  61.152 -                break;
  61.153 -            case Adjustable.HORIZONTAL:
  61.154 -                setScrollPosition(v, -(p.y));
  61.155 -                break;
  61.156 -            }
  61.157 -        }
  61.158 -    }
  61.159 -
  61.160 -    public native void setScrollPosition(int x, int y);
  61.161 -
  61.162 -    public void childResized(int w, int h) {
  61.163 -        // REMIND AIM:  May need to revisit this...
  61.164 -        if (((ScrollPane)target).getScrollbarDisplayPolicy() != ScrollPane.SCROLLBARS_NEVER) {
  61.165 -            ScrollPane sp = (ScrollPane)target;
  61.166 -            Adjustable vAdj = sp.getVAdjustable();
  61.167 -            Adjustable hAdj = sp.getHAdjustable();
  61.168 -            pSetIncrement(Scrollbar.VERTICAL, UNIT_INCREMENT, vAdj.getUnitIncrement());
  61.169 -            pSetIncrement(Scrollbar.HORIZONTAL, UNIT_INCREMENT, hAdj.getUnitIncrement());
  61.170 -            pSetIncrement(Scrollbar.VERTICAL, BLOCK_INCREMENT, vAdj.getBlockIncrement());
  61.171 -            pSetIncrement(Scrollbar.HORIZONTAL, BLOCK_INCREMENT, hAdj.getBlockIncrement());
  61.172 -        }
  61.173 -
  61.174 -    }
  61.175 -
  61.176 -    // NOTE: This method may be called by privileged threads.
  61.177 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  61.178 -    private void postScrollEvent(int orient, int type,
  61.179 -                                 int pos, boolean isAdjusting)
  61.180 -    {
  61.181 -        Runnable adjustor = new Adjustor(orient, type, pos, isAdjusting);
  61.182 -        MToolkit.executeOnEventHandlerThread(new ScrollEvent(target, adjustor));
  61.183 -    }
  61.184 -
  61.185 -    /**
  61.186 -     * This is used to change the adjustable on dispatch thread to
  61.187 -     * represent a change made in the native scrollbar.  Since the
  61.188 -     * change was reflected immediately at the native level,
  61.189 -     * notification from the adjustable is temporarily ignored.
  61.190 -     */
  61.191 -    class ScrollEvent extends PeerEvent {
  61.192 -        ScrollEvent(Object source, Runnable runnable) {
  61.193 -            super(source, runnable, 0L);
  61.194 -        }
  61.195 -
  61.196 -        public PeerEvent coalesceEvents(PeerEvent newEvent) {
  61.197 -            if (log.isLoggable(Level.FINEST)) {
  61.198 -                log.log(Level.FINEST, "ScrollEvent coalesced " + newEvent);
  61.199 -            }
  61.200 -            if (newEvent instanceof ScrollEvent) {
  61.201 -                return newEvent;
  61.202 -            }
  61.203 -            return null;
  61.204 -        }
  61.205 -    }
  61.206 -
  61.207 -    native void setTypedValue(ScrollPaneAdjustable adjustable, int value, int type);
  61.208 -
  61.209 -    /**
  61.210 -     * Runnable for the ScrollEvent that performs the adjustment.
  61.211 -     */
  61.212 -    class Adjustor implements Runnable {
  61.213 -        int orient;             // selects scrollbar
  61.214 -        int type;               // adjustment type
  61.215 -        int pos;                // new position (only used for absolute)
  61.216 -        boolean isAdjusting;    // isAdjusting status
  61.217 -
  61.218 -        Adjustor(int orient, int type, int pos, boolean isAdjusting) {
  61.219 -            this.orient = orient;
  61.220 -            this.type = type;
  61.221 -            this.pos = pos;
  61.222 -            this.isAdjusting = isAdjusting;
  61.223 -        }
  61.224 -
  61.225 -        public void run() {
  61.226 -            ScrollPane sp = (ScrollPane)MScrollPanePeer.this.target;
  61.227 -            ScrollPaneAdjustable adj = null;
  61.228 -
  61.229 -            // ScrollPaneAdjustable made public in 1.4, but
  61.230 -            // get[HV]Adjustable can't be declared to return
  61.231 -            // ScrollPaneAdjustable because it would break backward
  61.232 -            // compatibility -- hence the cast
  61.233 -
  61.234 -            if (orient == Adjustable.VERTICAL) {
  61.235 -                adj = (ScrollPaneAdjustable)sp.getVAdjustable();
  61.236 -            } else if (orient == Adjustable.HORIZONTAL) {
  61.237 -                adj = (ScrollPaneAdjustable)sp.getHAdjustable();
  61.238 -            } else {
  61.239 -                if (log.isLoggable(Level.FINE)) {
  61.240 -                    log.log(Level.FINE, "Assertion failed: unknown orient");
  61.241 -                }
  61.242 -            }
  61.243 -
  61.244 -            if (adj == null) {
  61.245 -                return;
  61.246 -            }
  61.247 -
  61.248 -            int newpos = adj.getValue();
  61.249 -            switch (type) {
  61.250 -              case AdjustmentEvent.UNIT_DECREMENT:
  61.251 -                  newpos -= adj.getUnitIncrement();
  61.252 -                  break;
  61.253 -              case AdjustmentEvent.UNIT_INCREMENT:
  61.254 -                  newpos += adj.getUnitIncrement();
  61.255 -                  break;
  61.256 -              case AdjustmentEvent.BLOCK_DECREMENT:
  61.257 -                  newpos -= adj.getBlockIncrement();
  61.258 -                  break;
  61.259 -              case AdjustmentEvent.BLOCK_INCREMENT:
  61.260 -                  newpos += adj.getBlockIncrement();
  61.261 -                  break;
  61.262 -              case AdjustmentEvent.TRACK:
  61.263 -                  newpos = this.pos;
  61.264 -                  break;
  61.265 -              default:
  61.266 -                  if (log.isLoggable(Level.FINE)) {
  61.267 -                      log.log(Level.FINE, "Assertion failed: unknown type");
  61.268 -                  }
  61.269 -                  return;
  61.270 -            }
  61.271 -
  61.272 -            // keep scroll position in acceptable range
  61.273 -            newpos = Math.max(adj.getMinimum(), newpos);
  61.274 -            newpos = Math.min(adj.getMaximum(), newpos);
  61.275 -
  61.276 -            // set value; this will synchronously fire an AdjustmentEvent
  61.277 -            try {
  61.278 -                MScrollPanePeer.this.ignore = true;
  61.279 -                adj.setValueIsAdjusting(isAdjusting);
  61.280 -
  61.281 -                // Fix for 4075484 - consider type information when creating AdjustmentEvent
  61.282 -                // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
  61.283 -                // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
  61.284 -                // Because ScrollPaneAdjustable is in another package we should call it through native code.
  61.285 -                setTypedValue(adj, newpos, type);
  61.286 -            } finally {
  61.287 -                MScrollPanePeer.this.ignore = false;
  61.288 -            }
  61.289 -        }
  61.290 -    } // class Adjustor
  61.291 -
  61.292 -
  61.293 -    private Component getScrollChild() {
  61.294 -        ScrollPane sp = (ScrollPane)target;
  61.295 -        Component child = null;
  61.296 -        try {
  61.297 -            child = sp.getComponent(0);
  61.298 -        } catch (ArrayIndexOutOfBoundsException e) {
  61.299 -            // do nothing.  in this case we return null
  61.300 -        }
  61.301 -        return child;
  61.302 -    }
  61.303 -
  61.304 -    final static int    MARGIN = 1;
  61.305 -    final static int    SCROLLBAR = 16;
  61.306 -    int hsbSpace;
  61.307 -    int vsbSpace;
  61.308 -    int vval;
  61.309 -    int hval;
  61.310 -    int vmax;
  61.311 -    int hmax;
  61.312 -    /*
  61.313 -     * Print the native component by rendering the Motif look ourselves.
  61.314 -     * ToDo(aim): needs to query native motif for more accurate size and
  61.315 -     * color information.
  61.316 -     */
  61.317 -    public void print(Graphics g) {
  61.318 -        ScrollPane sp = (ScrollPane)target;
  61.319 -        Dimension d = sp.size();
  61.320 -        Color bg = sp.getBackground();
  61.321 -        Color fg = sp.getForeground();
  61.322 -        Point p = sp.getScrollPosition();
  61.323 -        Component c = getScrollChild();
  61.324 -        Dimension cd;
  61.325 -        if (c != null) {
  61.326 -            cd = c.size();
  61.327 -        } else {
  61.328 -            cd = new Dimension(0, 0);
  61.329 -        }
  61.330 -        int sbDisplay = sp.getScrollbarDisplayPolicy();
  61.331 -        int vvis, hvis, vmin, hmin, vmax, hmax, vval, hval;
  61.332 -
  61.333 -        switch (sbDisplay) {
  61.334 -          case ScrollPane.SCROLLBARS_NEVER:
  61.335 -            hsbSpace = vsbSpace = 0;
  61.336 -            break;
  61.337 -          case ScrollPane.SCROLLBARS_ALWAYS:
  61.338 -            hsbSpace = vsbSpace = SCROLLBAR;
  61.339 -            break;
  61.340 -          case ScrollPane.SCROLLBARS_AS_NEEDED:
  61.341 -            hsbSpace = (cd.width <= (d.width - 2*MARGIN)? 0 : SCROLLBAR);
  61.342 -            vsbSpace = (cd.height <= (d.height - 2*MARGIN)? 0 : SCROLLBAR);
  61.343 -
  61.344 -            if (hsbSpace == 0 && vsbSpace != 0) {
  61.345 -                hsbSpace = (cd.width <= (d.width - SCROLLBAR - 2*MARGIN)? 0 : SCROLLBAR);
  61.346 -            }
  61.347 -            if (vsbSpace == 0 && hsbSpace != 0) {
  61.348 -                vsbSpace = (cd.height <= (d.height - SCROLLBAR - 2*MARGIN)? 0 : SCROLLBAR);
  61.349 -            }
  61.350 -        }
  61.351 -
  61.352 -        vvis = hvis = vmin = hmin = vmax = hmax = vval = hval = 0;
  61.353 -
  61.354 -        if (vsbSpace > 0) {
  61.355 -            vmin = 0;
  61.356 -            vvis = d.height - (2*MARGIN) - hsbSpace;
  61.357 -            vmax = Math.max(cd.height - vvis, 0);
  61.358 -            vval = p.y;
  61.359 -        }
  61.360 -        if (hsbSpace > 0) {
  61.361 -            hmin = 0;
  61.362 -            hvis = d.width - (2*MARGIN) - vsbSpace;
  61.363 -            hmax = Math.max(cd.width - hvis, 0);
  61.364 -            hval = p.x;
  61.365 -        }
  61.366 -
  61.367 -        // need to be careful to add the margins back in here because
  61.368 -        // we're drawing the margin border, after all!
  61.369 -        int w = d.width - vsbSpace;
  61.370 -        int h = d.height - hsbSpace;
  61.371 -
  61.372 -        g.setColor(bg);
  61.373 -        g.fillRect(0, 0, d.width, d.height);
  61.374 -
  61.375 -        if (hsbSpace > 0) {
  61.376 -            int sbw = d.width - vsbSpace;
  61.377 -            g.fillRect(1, d.height - SCROLLBAR - 3, sbw - 1, SCROLLBAR - 3);
  61.378 -            Graphics ng = g.create();
  61.379 -            try {
  61.380 -                ng.translate(0, d.height - (SCROLLBAR - 2));
  61.381 -                drawScrollbar(ng, bg, SCROLLBAR - 2, sbw,
  61.382 -                               hmin, hmax, hval, hvis, true);
  61.383 -            } finally {
  61.384 -                ng.dispose();
  61.385 -            }
  61.386 -        }
  61.387 -        if (vsbSpace > 0) {
  61.388 -            int sbh = d.height - hsbSpace;
  61.389 -            g.fillRect(d.width - SCROLLBAR - 3, 1, SCROLLBAR - 3, sbh - 1);
  61.390 -            Graphics ng = g.create();
  61.391 -            try {
  61.392 -                ng.translate(d.width - (SCROLLBAR - 2), 0);
  61.393 -                drawScrollbar(ng, bg, SCROLLBAR - 2, sbh,
  61.394 -                               vmin, vmax, vval, vvis, false);
  61.395 -            } finally {
  61.396 -                ng.dispose();
  61.397 -            }
  61.398 -        }
  61.399 -
  61.400 -        draw3DRect(g, bg, 0, 0, w - 1, h - 1, false);
  61.401 -
  61.402 -        target.print(g);
  61.403 -        sp.printComponents(g);
  61.404 -    }
  61.405 -
  61.406 -    /**
  61.407 -     * @see ContainerPeer#restack
  61.408 -     */
  61.409 -    public void restack() {
  61.410 -        // Since ScrollPane can only have one child its restacking does nothing.
  61.411 -        // Also, it is dangerous, since SP child is actually not a child of SP widget
  61.412 -        // but the child of SP content widget.
  61.413 -    }
  61.414 -}
    62.1 --- a/src/solaris/classes/sun/awt/motif/MScrollbarPeer.java	Wed Sep 17 13:45:37 2008 -0700
    62.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.3 @@ -1,187 +0,0 @@
    62.4 -/*
    62.5 - * Copyright 1995-2002 Sun Microsystems, Inc.  All Rights Reserved.
    62.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    62.7 - *
    62.8 - * This code is free software; you can redistribute it and/or modify it
    62.9 - * under the terms of the GNU General Public License version 2 only, as
   62.10 - * published by the Free Software Foundation.  Sun designates this
   62.11 - * particular file as subject to the "Classpath" exception as provided
   62.12 - * by Sun in the LICENSE file that accompanied this code.
   62.13 - *
   62.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   62.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   62.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   62.17 - * version 2 for more details (a copy is included in the LICENSE file that
   62.18 - * accompanied this code).
   62.19 - *
   62.20 - * You should have received a copy of the GNU General Public License version
   62.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   62.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   62.23 - *
   62.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   62.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   62.26 - * have any questions.
   62.27 - */
   62.28 -package sun.awt.motif;
   62.29 -
   62.30 -import java.awt.*;
   62.31 -import java.awt.peer.*;
   62.32 -import java.awt.event.AdjustmentEvent;
   62.33 -
   62.34 -class MScrollbarPeer extends MComponentPeer implements ScrollbarPeer {
   62.35 -    static {
   62.36 -        initIDs();
   62.37 -    }
   62.38 -
   62.39 -    private boolean inUpCall = false;
   62.40 -
   62.41 -    native void create(MComponentPeer parent);
   62.42 -
   62.43 -    MScrollbarPeer(Scrollbar target) {
   62.44 -        super(target);
   62.45 -    }
   62.46 -
   62.47 -    // Initialize JNI field and method IDs
   62.48 -    private static native void initIDs();
   62.49 -
   62.50 -    public native void pSetValues(int value, int visible, int minimum, int maximum);
   62.51 -    public native void setLineIncrement(int l);
   62.52 -    public native void setPageIncrement(int l);
   62.53 -
   62.54 -    /**
   62.55 -     * Returns default size of Motif scrollbar on the platform
   62.56 -     * Currently uses hardcoded values
   62.57 -     */
   62.58 -    int getDefaultDimension() {
   62.59 -        if (System.getProperty("os.name").equals("Linux")) {
   62.60 -            return 15;
   62.61 -        } else {
   62.62 -            return 19;
   62.63 -        }
   62.64 -    }
   62.65 -
   62.66 -    public Dimension getMinimumSize() {
   62.67 -        if (((Scrollbar)target).getOrientation() == Scrollbar.VERTICAL) {
   62.68 -            return new Dimension(getDefaultDimension(), 50);
   62.69 -        } else {
   62.70 -            return new Dimension(50, getDefaultDimension());
   62.71 -        }
   62.72 -    }
   62.73 -
   62.74 -    // NOTE: Callback methods are called by privileged threads.
   62.75 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   62.76 -
   62.77 -    private void postAdjustmentEvent(final int type, final int value,
   62.78 -                                     final boolean isAdjusting)
   62.79 -    {
   62.80 -        final Scrollbar sb = (Scrollbar)target;
   62.81 -        MToolkit.executeOnEventHandlerThread(sb, new Runnable() {
   62.82 -            public void run() {
   62.83 -                inUpCall = true;
   62.84 -                sb.setValueIsAdjusting(isAdjusting);
   62.85 -                sb.setValue(value);
   62.86 -                postEvent(new AdjustmentEvent(sb,
   62.87 -                                AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
   62.88 -                                type, value, isAdjusting));
   62.89 -                inUpCall = false;
   62.90 -            }
   62.91 -        });
   62.92 -    }
   62.93 -
   62.94 -    void lineUp(int value) {
   62.95 -        postAdjustmentEvent(AdjustmentEvent.UNIT_DECREMENT, value, false);
   62.96 -    }
   62.97 -
   62.98 -    void lineDown(int value) {
   62.99 -        postAdjustmentEvent(AdjustmentEvent.UNIT_INCREMENT, value, false);
  62.100 -    }
  62.101 -
  62.102 -    void pageUp(int value) {
  62.103 -        postAdjustmentEvent(AdjustmentEvent.BLOCK_DECREMENT, value, false);
  62.104 -    }
  62.105 -
  62.106 -    void pageDown(int value) {
  62.107 -        postAdjustmentEvent(AdjustmentEvent.BLOCK_INCREMENT, value, false);
  62.108 -    }
  62.109 -
  62.110 -    // SB_TOP/BOTTOM are mapped to tracking
  62.111 -    void warp(int value) {
  62.112 -        postAdjustmentEvent(AdjustmentEvent.TRACK, value, false);
  62.113 -    }
  62.114 -
  62.115 -    private boolean dragInProgress = false;
  62.116 -
  62.117 -    void drag(final int value) {
  62.118 -        if (!dragInProgress) {
  62.119 -            dragInProgress = true;
  62.120 -        }
  62.121 -        postAdjustmentEvent(AdjustmentEvent.TRACK, value, true);
  62.122 -    }
  62.123 -
  62.124 -    void dragEnd(final int value) {
  62.125 -        final Scrollbar sb = (Scrollbar)target;
  62.126 -
  62.127 -        if (!dragInProgress) {
  62.128 -            return;
  62.129 -        }
  62.130 -
  62.131 -        dragInProgress = false;
  62.132 -        MToolkit.executeOnEventHandlerThread(sb, new Runnable() {
  62.133 -            public void run() {
  62.134 -                // NB: notification only, no sb.setValue()
  62.135 -                // last TRACK event will have done it already
  62.136 -                inUpCall = true;
  62.137 -                sb.setValueIsAdjusting(false);
  62.138 -                postEvent(new AdjustmentEvent(sb,
  62.139 -                                AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
  62.140 -                                AdjustmentEvent.TRACK, value, false));
  62.141 -                inUpCall = false;
  62.142 -            }
  62.143 -        });
  62.144 -    }
  62.145 -
  62.146 -    /**
  62.147 -     * Set the value of the slider in the ScrollBar.
  62.148 -     */
  62.149 -    public void setValues(int value, int visible, int minimum, int maximum) {
  62.150 -        // Fix for BugTraq ID 4048060.  Prevent unnecessary redrawing
  62.151 -        // of the slider, when the slider is already in the correct
  62.152 -        // position.  Since the ScrollBar widget now receives the
  62.153 -        // ButtonRelease X event before the Java Adjustor event is
  62.154 -        // handled, the slider is already in the correct position and
  62.155 -        // does not need to be set again and redrawn, when processing
  62.156 -        // the Adjustor event.
  62.157 -        if (!inUpCall) {
  62.158 -            pSetValues(value, visible, minimum, maximum);
  62.159 -        }
  62.160 -    }
  62.161 -
  62.162 -    public void print(Graphics g) {
  62.163 -        Scrollbar sb = (Scrollbar)target;
  62.164 -        Dimension d = sb.size();
  62.165 -        Color bg = sb.getBackground();
  62.166 -
  62.167 -        boolean horiz = (sb.getOrientation() == Scrollbar.HORIZONTAL);
  62.168 -
  62.169 -        drawScrollbar(g, bg, horiz? d.height : d.width,
  62.170 -                          horiz? d.width : d.height,
  62.171 -                          sb.getMinimum(), sb.getMaximum(),
  62.172 -                          sb.getValue(), sb.getVisible(),
  62.173 -                          horiz);
  62.174 -
  62.175 -        target.print(g);
  62.176 -    }
  62.177 -
  62.178 -
  62.179 -    /**
  62.180 -     * DEPRECATED
  62.181 -     */
  62.182 -    public Dimension minimumSize() {
  62.183 -            return getMinimumSize();
  62.184 -    }
  62.185 -
  62.186 -    protected boolean shouldFocusOnClick() {
  62.187 -        // Changed in 1.4 - scroll bars are made focusable by mouse clicks.
  62.188 -        return true;
  62.189 -    }
  62.190 -}
    63.1 --- a/src/solaris/classes/sun/awt/motif/MTextAreaPeer.java	Wed Sep 17 13:45:37 2008 -0700
    63.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.3 @@ -1,555 +0,0 @@
    63.4 -/*
    63.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
    63.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    63.7 - *
    63.8 - * This code is free software; you can redistribute it and/or modify it
    63.9 - * under the terms of the GNU General Public License version 2 only, as
   63.10 - * published by the Free Software Foundation.  Sun designates this
   63.11 - * particular file as subject to the "Classpath" exception as provided
   63.12 - * by Sun in the LICENSE file that accompanied this code.
   63.13 - *
   63.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   63.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   63.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   63.17 - * version 2 for more details (a copy is included in the LICENSE file that
   63.18 - * accompanied this code).
   63.19 - *
   63.20 - * You should have received a copy of the GNU General Public License version
   63.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   63.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   63.23 - *
   63.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   63.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   63.26 - * have any questions.
   63.27 - */
   63.28 -
   63.29 -package sun.awt.motif;
   63.30 -
   63.31 -import java.awt.*;
   63.32 -import java.awt.peer.*;
   63.33 -import java.awt.event.TextEvent;
   63.34 -import java.awt.event.MouseEvent;
   63.35 -import java.awt.event.MouseWheelEvent;
   63.36 -import java.awt.datatransfer.*;
   63.37 -import java.io.BufferedReader;
   63.38 -import java.io.StringReader;
   63.39 -import java.io.IOException;
   63.40 -import java.util.Vector;
   63.41 -import java.awt.im.InputMethodRequests;
   63.42 -
   63.43 -
   63.44 -public class MTextAreaPeer extends MComponentPeer implements TextAreaPeer {
   63.45 -    native void pCreate(MComponentPeer parent);
   63.46 -
   63.47 -    private boolean firstChangeSkipped;
   63.48 -
   63.49 -    /**
   63.50 -     * Initialize JNI field and method IDs
   63.51 -     */
   63.52 -    private static native void initIDs();
   63.53 -
   63.54 -    static {
   63.55 -        initIDs();
   63.56 -    }
   63.57 -
   63.58 -    void create(MComponentPeer parent) {
   63.59 -        firstChangeSkipped = false;
   63.60 -        pCreate(parent);
   63.61 -    }
   63.62 -
   63.63 -    void initialize() {
   63.64 -        int start, end;
   63.65 -
   63.66 -        TextArea txt = (TextArea)target;
   63.67 -        String  text;
   63.68 -
   63.69 -        if ((text = txt.getText()) != null) {
   63.70 -            setText(text);
   63.71 -        }
   63.72 -
   63.73 -        start = txt.getSelectionStart();
   63.74 -        end = txt.getSelectionEnd();
   63.75 -
   63.76 -        if (end > start) {
   63.77 -            select(start, end);
   63.78 -        } else {
   63.79 -            setCaretPosition(start);
   63.80 -        }
   63.81 -
   63.82 -        super.pSetScrollbarBackground(getParent_NoClientCode(target).getBackground());
   63.83 -
   63.84 -        if (!target.isBackgroundSet()) {
   63.85 -            // This is a way to set the background color of the TextArea
   63.86 -            // without calling setBackground - go through native C code
   63.87 -            setTargetBackground(SystemColor.text);
   63.88 -        }
   63.89 -        if (!target.isForegroundSet()) {
   63.90 -            target.setForeground(SystemColor.textText);
   63.91 -        }
   63.92 -
   63.93 -        setEditable(txt.isEditable());
   63.94 -
   63.95 -//      oldSelectionStart = -1; // accessibility support
   63.96 -//      oldSelectionEnd = -1;   // accessibility support
   63.97 -
   63.98 -        super.initialize();
   63.99 -    }
  63.100 -
  63.101 -    public MTextAreaPeer(TextArea target) {
  63.102 -        super(target);
  63.103 -    }
  63.104 -
  63.105 -    public void setEditable(boolean editable) {
  63.106 -        pSetEditable(editable);
  63.107 -
  63.108 -        /* 4136955 - Calling setBackground() here works around an Xt
  63.109 -         * bug by forcing Xt to flush an internal widget cache
  63.110 -         */
  63.111 -        setBackground(target.getBackground());
  63.112 -    }
  63.113 -    public void setBackground(Color c) {
  63.114 -        setTextBackground(c);
  63.115 -    }
  63.116 -    public void setForeground(Color c) {
  63.117 -        pSetInnerForeground(c);
  63.118 -    }
  63.119 -
  63.120 -    native int getExtraWidth();
  63.121 -    native int getExtraHeight();
  63.122 -    public native void setTextBackground(Color c);
  63.123 -    public native void pSetEditable(boolean e);
  63.124 -    public native void select(int selStart, int selEnd);
  63.125 -    public native int getSelectionStart();
  63.126 -    public native int getSelectionEnd();
  63.127 -    public native void setText(String txt);
  63.128 -    public native String getText();
  63.129 -    public native void insert(String txt, int pos);
  63.130 -    public native void replaceRange(String txt, int start, int end);
  63.131 -    public native void setFont(Font f);
  63.132 -    public native void setCaretPosition(int pos);
  63.133 -    public native int getCaretPosition();
  63.134 -    public native void pSetCursor(Cursor c);
  63.135 -    native void pShow2();
  63.136 -    native void pMakeCursorVisible();
  63.137 -
  63.138 -
  63.139 -    public Dimension getMinimumSize() {
  63.140 -        return getMinimumSize(10, 60);
  63.141 -    }
  63.142 -    public Dimension getPreferredSize(int rows, int cols) {
  63.143 -        return getMinimumSize(rows, cols);
  63.144 -    }
  63.145 -    public Dimension getMinimumSize(int rows, int cols) {
  63.146 -        FontMetrics fm = getFontMetrics(target.getFont());
  63.147 -
  63.148 -        /* Calculate proper size for text area plus scrollbars.
  63.149 -         *   - Motif allows NO leading in its text areas ...
  63.150 -         *   - extra width and height counts everything outside the
  63.151 -         *     usable text space.
  63.152 -         * (bug 4103248, 4120310):
  63.153 -         *   - Motif uses maxAscent + maxDescent, not ascent + descent.
  63.154 -         */
  63.155 -        int colWidth = fm.charWidth('0');
  63.156 -        int rowHeight = fm.getMaxAscent() + fm.getMaxDescent();
  63.157 -        return new Dimension(cols * colWidth + getExtraWidth(),
  63.158 -                             rows * rowHeight + getExtraHeight());
  63.159 -    }
  63.160 -    public boolean isFocusable() {
  63.161 -        return true;
  63.162 -    }
  63.163 -
  63.164 -    // Called from native widget when paste key is pressed and we
  63.165 -    // already own the selection (prevents Motif from hanging while
  63.166 -    // waiting for the selection)
  63.167 -    //
  63.168 -    public void pasteFromClipboard() {
  63.169 -        Clipboard clipboard = target.getToolkit().getSystemClipboard();
  63.170 -
  63.171 -        Transferable content = clipboard.getContents(this);
  63.172 -        if (content != null) {
  63.173 -            try {
  63.174 -                String data = (String)(content.getTransferData(DataFlavor.stringFlavor));
  63.175 -                // fix for 4401853: to clear TextArea selection if null is pasted
  63.176 -                data = (data == null ? "" : data);
  63.177 -                replaceRange(data, getSelectionStart(), getSelectionEnd());
  63.178 -
  63.179 -            } catch (Exception e) {
  63.180 -            }
  63.181 -        }
  63.182 -    }
  63.183 -
  63.184 -    /*
  63.185 -     * Print the native component by rendering the Motif look ourselves.
  63.186 -     * ToDo(aim): needs to query native motif for more accurate size and
  63.187 -     * color information, the top/left text offsets, and selected text.
  63.188 -     */
  63.189 -    static final int MARGIN = 2;
  63.190 -    static final int BORDER = 1;
  63.191 -    static final int SCROLLBAR = 16;
  63.192 -    int fontHeight;
  63.193 -    int fontAscent;
  63.194 -    int fontLeading;
  63.195 -    int topLine = 0;
  63.196 -    int numLines = 0;
  63.197 -    int textLength = 0;
  63.198 -    Vector lines;
  63.199 -    int selStart = 0;
  63.200 -    int selEnd = 0;
  63.201 -    int movedRight = 0;
  63.202 -
  63.203 -    // the following vars are assigned in print() method
  63.204 -    transient boolean hscrollbar;
  63.205 -    transient boolean vscrollbar;
  63.206 -
  63.207 -    public void print(Graphics g) {
  63.208 -        TextArea area = (TextArea)target;
  63.209 -        Dimension d = area.size();
  63.210 -        Color bg = area.getBackground();
  63.211 -        Color fg = area.getForeground();
  63.212 -        FontMetrics fm = getFontMetrics(area.getFont());
  63.213 -        int vmin, vmax, vval, vvis;
  63.214 -        int hmin, hmax, hval, hvis;
  63.215 -        int max = 0;
  63.216 -
  63.217 -        /*
  63.218 -          Doesn't work right yet.
  63.219 -        selStart = area.getSelectionStart();
  63.220 -        selEnd = area.getSelectionEnd();
  63.221 -        */
  63.222 -
  63.223 -        // Figure out number of lines and max line length
  63.224 -        String text = area.getText();
  63.225 -        textLength = text.length();
  63.226 -        BufferedReader is = new BufferedReader(new StringReader(text));
  63.227 -        String line;
  63.228 -        int pos = 0;
  63.229 -        lines = new Vector();
  63.230 -        int sv = ((TextArea)target).getScrollbarVisibility();
  63.231 -        vscrollbar = (sv == TextArea.SCROLLBARS_BOTH ||
  63.232 -                sv == TextArea.SCROLLBARS_VERTICAL_ONLY);
  63.233 -        hscrollbar = (sv == TextArea.SCROLLBARS_BOTH ||
  63.234 -                sv == TextArea.SCROLLBARS_HORIZONTAL_ONLY);
  63.235 -        boolean wrap = !hscrollbar;
  63.236 -        int w = d.width - (vscrollbar ? SCROLLBAR : 0);
  63.237 -        int h = d.height - (hscrollbar ? SCROLLBAR : 0);
  63.238 -
  63.239 -        try {
  63.240 -            numLines = 0;
  63.241 -            while((line = is.readLine()) != null) {
  63.242 -                int len = fm.stringWidth(line);
  63.243 -                if (len > w && wrap) {
  63.244 -                   // need to do line wrapping
  63.245 -                   int start = 0;
  63.246 -                   int end = 0;
  63.247 -                   int string_length = line.length();
  63.248 -                   while (true) {
  63.249 -                       int line_width = 0;
  63.250 -                       end = start + 1; // at least one character per line
  63.251 -                       while (end < string_length) {
  63.252 -                               char c = line.charAt(end);
  63.253 -                               int cw = fm.charWidth(c);
  63.254 -                               if (line_width + cw + 10 > w) // +10?
  63.255 -                                       break;
  63.256 -                               line_width += cw;
  63.257 -                               end++;
  63.258 -                       }
  63.259 -                       // form a line from start to end (not including end)
  63.260 -                       String substr = line.substring(start, end);
  63.261 -                       // System.out.println("wrap line: " + substr);
  63.262 -                       TextLine tline = new TextLine();
  63.263 -                       tline.text = substr;
  63.264 -                       tline.pos = pos + start;
  63.265 -                       lines.addElement(tline);
  63.266 -                       start = end;
  63.267 -                       max = Math.max(max, len);
  63.268 -                       numLines ++;
  63.269 -                       if (end == string_length) {
  63.270 -                           // we have processed the whole string
  63.271 -                           pos += line.length() + 1; // +1 for the ending \n ?
  63.272 -                           break;
  63.273 -                       }
  63.274 -                   }
  63.275 -                } else {
  63.276 -                TextLine tline = new TextLine();
  63.277 -                tline.text = line;
  63.278 -                tline.pos = pos;
  63.279 -                lines.addElement(tline);
  63.280 -                pos += line.length() + 1;
  63.281 -
  63.282 -                max = Math.max(max, len);
  63.283 -                numLines++;
  63.284 -                }
  63.285 -            }
  63.286 -            is.close();
  63.287 -
  63.288 -        } catch (IOException e) {
  63.289 -        }
  63.290 -
  63.291 -
  63.292 -        fontHeight = fm.getHeight();
  63.293 -        fontAscent = fm.getAscent();
  63.294 -        fontLeading = fm.getLeading();
  63.295 -
  63.296 -        hmin = vmin = 0;
  63.297 -
  63.298 -        vvis = linesInWindow(true);
  63.299 -        vmax = Math.max(numLines - vvis, 0);
  63.300 -        vval = 0;
  63.301 -
  63.302 -        hvis = w - (2 * MARGIN);
  63.303 -        hmax = Math.max(max - hvis, 0);
  63.304 -        hval = 0;
  63.305 -
  63.306 -        g.setColor(bg);
  63.307 -        g.fillRect(BORDER, BORDER, w, h);
  63.308 -        if (vscrollbar)
  63.309 -        {
  63.310 -            int sbh = d.height - (hscrollbar ? SCROLLBAR : 0);
  63.311 -            g.fillRect(d.width - SCROLLBAR - 3, 1, SCROLLBAR - 3, sbh - 1);
  63.312 -            Graphics ng = g.create();
  63.313 -            try {
  63.314 -                ng.translate(d.width - (SCROLLBAR - 2), 0);
  63.315 -                drawScrollbar(ng, bg, SCROLLBAR - 2, sbh,
  63.316 -                              vmin, vmax, vval, vvis, false);
  63.317 -            } finally {
  63.318 -                ng.dispose();
  63.319 -            }
  63.320 -        }
  63.321 -        if (hscrollbar)
  63.322 -        {
  63.323 -            int sbw = d.width - (vscrollbar ? SCROLLBAR : 0);
  63.324 -            g.fillRect(1, d.height - SCROLLBAR - 3, sbw - 1, SCROLLBAR - 3);
  63.325 -            Graphics ng = g.create();
  63.326 -            try {
  63.327 -                ng.translate(0, d.height - (SCROLLBAR - 2));
  63.328 -                drawScrollbar(ng, bg, SCROLLBAR - 2, sbw,
  63.329 -                              hmin, hmax, hval, hvis, true);
  63.330 -            } finally {
  63.331 -                ng.dispose();
  63.332 -            }
  63.333 -        }
  63.334 -
  63.335 -        draw3DRect(g, bg, 0, 0, w - 1, h - 1, false);
  63.336 -
  63.337 -        if (text != null) {
  63.338 -            int l = linesInWindow(true);
  63.339 -            h = d.height - ((2 * MARGIN) + SCROLLBAR);
  63.340 -            int e = Math.min(numLines - 1, (topLine + l) - 1);
  63.341 -            paintLines(g, bg, fg, topLine, e);
  63.342 -        }
  63.343 -
  63.344 -
  63.345 -        target.print(g);
  63.346 -    }
  63.347 -
  63.348 -    int linesInWindow(boolean horizScrollbar) {
  63.349 -        Dimension d = target.size();
  63.350 -        int htotal = d.height - ((2 * MARGIN) + (horizScrollbar? SCROLLBAR : 0));
  63.351 -        return htotal / fontHeight;
  63.352 -    }
  63.353 -
  63.354 -    void paintLines(Graphics g, Color bg, Color fg, int s, int e) {
  63.355 -        Dimension d = target.size();
  63.356 -        int w = d.width - ((2 * BORDER) + (vscrollbar ? SCROLLBAR : 0));
  63.357 -        int h = d.height - ((2 * BORDER) + (hscrollbar ? SCROLLBAR : 0));
  63.358 -        int lm = linesInWindow(true) + topLine;
  63.359 -        s = Math.max(topLine, s);
  63.360 -        e = Math.min(e, lm - 1);
  63.361 -        Graphics ng = g.create();
  63.362 -        try {
  63.363 -            ng.clipRect(BORDER + MARGIN, MARGIN + BORDER, w - (2*MARGIN),
  63.364 -                        h - (2*MARGIN));
  63.365 -            ng.setFont(target.getFont());
  63.366 -            for (int i = s ; i <= e; i++) {
  63.367 -                paintLine(ng, bg, fg, i);
  63.368 -            }
  63.369 -        } finally {
  63.370 -            ng.dispose();
  63.371 -        }
  63.372 -    }
  63.373 -
  63.374 -    void paintLine(Graphics g, Color bg, Color fg, int lnr) {
  63.375 -        Dimension d = target.size();
  63.376 -        int l = linesInWindow(true);
  63.377 -
  63.378 -        if((lnr < topLine) || (lnr >= l + topLine)) {
  63.379 -            return;
  63.380 -        }
  63.381 -        int w = d.width - ((2 * BORDER) + (hscrollbar ? SCROLLBAR : 0));
  63.382 -        int y = MARGIN + fontLeading + ((lnr - topLine) * fontHeight);
  63.383 -        String text = ((TextLine)lines.elementAt(lnr)).text;
  63.384 -        int len = text.length();
  63.385 -
  63.386 -        if (lnr > numLines - 1) {
  63.387 -            g.setColor(bg);
  63.388 -            g.fillRect(BORDER, y - fontLeading, w, fontHeight);
  63.389 -            return;
  63.390 -        }
  63.391 -        int s = 0;
  63.392 -        int e = (lnr < numLines - 1) ? len : textLength;
  63.393 -        int xs = pos2x(selStart) - movedRight;
  63.394 -        int xe = pos2x(selEnd) - movedRight;
  63.395 -
  63.396 -        Color highlight = bg.brighter();
  63.397 -        if ((selStart < s) && (selEnd > e)) {
  63.398 -            g.setColor(highlight);
  63.399 -            g.fillRect(BORDER, y - fontLeading, w, fontHeight);
  63.400 -        } else {
  63.401 -            g.setColor(bg);
  63.402 -            g.fillRect(BORDER, y - fontLeading, w, fontHeight);
  63.403 -
  63.404 -            if ((selStart >= s) && (selStart <= e)) {
  63.405 -                g.setColor(highlight);
  63.406 -
  63.407 -                if (selEnd > e) {
  63.408 -                    g.fillRect(xs, y - fontLeading, (w + BORDER) - xs, fontHeight);
  63.409 -                } else if (selStart == selEnd) {
  63.410 -                  //g.fillRect(xs, y - fontLeading, 1, fontHeight);
  63.411 -                } else {
  63.412 -                    g.fillRect(xs, y - fontLeading, xe - xs, fontHeight);
  63.413 -                }
  63.414 -            } else if ((selEnd >= s) && (selEnd <= e)) {
  63.415 -                g.setColor(highlight);
  63.416 -                g.fillRect(BORDER, y - fontLeading, xe - BORDER, fontHeight);
  63.417 -            }
  63.418 -        }
  63.419 -        g.setColor(fg);
  63.420 -        g.drawString(text, MARGIN - movedRight, y + fontAscent);
  63.421 -    }
  63.422 -
  63.423 -    int pos2x(int pos) {
  63.424 -        FontMetrics fm = getFontMetrics(target.getFont());
  63.425 -        int widths[] = fm.getWidths();
  63.426 -        TextLine tl1 = (TextLine)lines.elementAt(0);
  63.427 -        TextLine tl2;
  63.428 -        int l = 0;
  63.429 -        for (int i = 0; i < lines.size() - 1; i++) {
  63.430 -            tl2 = (TextLine)lines.elementAt(i+1);
  63.431 -            if (pos >= tl1.pos && pos < tl2.pos) {
  63.432 -                l = i;
  63.433 -                break;
  63.434 -            }
  63.435 -            tl1 = tl2;
  63.436 -        }
  63.437 -        int x = MARGIN;
  63.438 -        for (int i = 0 ; i < (pos - tl1.pos - 1) ; i++) {
  63.439 -            x += widths[tl1.text.charAt(i)];
  63.440 -        }
  63.441 -        return x;
  63.442 -    }
  63.443 -
  63.444 -    /**
  63.445 -     * DEPRECATED
  63.446 -     */
  63.447 -    public void insertText(String txt, int pos) {
  63.448 -        insert(txt, pos);
  63.449 -    }
  63.450 -
  63.451 -    /**
  63.452 -     * DEPRECATED
  63.453 -     */
  63.454 -    public void replaceText(String txt, int start, int end) {
  63.455 -        replaceRange(txt, start, end);
  63.456 -    }
  63.457 -
  63.458 -    /**
  63.459 -     * DEPRECATED
  63.460 -     */
  63.461 -    public Dimension minimumSize() {
  63.462 -        return getMinimumSize();
  63.463 -    }
  63.464 -
  63.465 -    /**
  63.466 -     * DEPRECATED
  63.467 -     */
  63.468 -    public Dimension preferredSize(int rows, int cols) {
  63.469 -        return getPreferredSize(rows, cols);
  63.470 -    }
  63.471 -
  63.472 -    /**
  63.473 -     * DEPRECATED
  63.474 -     */
  63.475 -    public Dimension minimumSize(int rows, int cols) {
  63.476 -        return getMinimumSize(rows, cols);
  63.477 -    }
  63.478 -
  63.479 -    /*
  63.480 -     * Post a new TextEvent when the value of a text component changes.
  63.481 -     */
  63.482 -    public void valueChanged() {
  63.483 -        postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
  63.484 -    }
  63.485 -
  63.486 -    void pShow(){
  63.487 -      pShow2();
  63.488 -      notifyTextComponentChange(true);
  63.489 -    }
  63.490 -
  63.491 -    void pHide(){
  63.492 -      notifyTextComponentChange(false);
  63.493 -      super.pHide();
  63.494 -    }
  63.495 -
  63.496 -    void pDispose(){
  63.497 -      notifyTextComponentChange(false);
  63.498 -      super.pDispose();
  63.499 -    }
  63.500 -
  63.501 -    public boolean handlesWheelScrolling() {return true;}
  63.502 -
  63.503 -    public void handleEvent(AWTEvent e) {
  63.504 -        if (e.getID() == MouseEvent.MOUSE_WHEEL) {
  63.505 -            MouseWheelEvent mwe = (MouseWheelEvent)e;
  63.506 -            nativeHandleMouseWheel(mwe.getScrollType(),
  63.507 -                                   mwe.getScrollAmount(),
  63.508 -                                   mwe.getWheelRotation());
  63.509 -        }
  63.510 -        else {
  63.511 -            super.handleEvent(e);
  63.512 -        }
  63.513 -    }
  63.514 -
  63.515 -     public InputMethodRequests getInputMethodRequests() {
  63.516 -            return null;
  63.517 -      }
  63.518 -
  63.519 -
  63.520 -
  63.521 -    native void nativeHandleMouseWheel(int scrollType,
  63.522 -                                       int scrollAmount,
  63.523 -                                       int wheelRotation);
  63.524 -
  63.525 -    //
  63.526 -    // Accessibility support
  63.527 -    //
  63.528 -
  63.529 -
  63.530 -    // stub functions: to be fully implemented in a future release
  63.531 -    public int getIndexAtPoint(int x, int y) { return -1; }
  63.532 -    public Rectangle getCharacterBounds(int i) { return null; }
  63.533 -    public long filterEvents(long mask) { return 0; }
  63.534 -
  63.535 -/*  To be fully implemented in a future release
  63.536 -
  63.537 -    int oldSelectionStart;
  63.538 -    int oldSelectionEnd;
  63.539 -
  63.540 -    public native int getIndexAtPoint(int x, int y);
  63.541 -    public native Rectangle getCharacterBounds(int i);
  63.542 -    public native long filterEvents(long mask);
  63.543 -
  63.544 -    /**
  63.545 -     * Handle a change in the text selection endpoints
  63.546 -     * (Note: could be simply a change in the caret location)
  63.547 -     *
  63.548 -    public void selectionValuesChanged(int start, int end) {
  63.549 -        return;  // Need to write implementation of this.
  63.550 -    }
  63.551 -*/
  63.552 -}
  63.553 -
  63.554 -
  63.555 -class TextLine {
  63.556 -    String text;
  63.557 -    int pos;
  63.558 -}
    64.1 --- a/src/solaris/classes/sun/awt/motif/MTextFieldPeer.java	Wed Sep 17 13:45:37 2008 -0700
    64.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.3 @@ -1,356 +0,0 @@
    64.4 -/*
    64.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
    64.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    64.7 - *
    64.8 - * This code is free software; you can redistribute it and/or modify it
    64.9 - * under the terms of the GNU General Public License version 2 only, as
   64.10 - * published by the Free Software Foundation.  Sun designates this
   64.11 - * particular file as subject to the "Classpath" exception as provided
   64.12 - * by Sun in the LICENSE file that accompanied this code.
   64.13 - *
   64.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   64.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   64.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   64.17 - * version 2 for more details (a copy is included in the LICENSE file that
   64.18 - * accompanied this code).
   64.19 - *
   64.20 - * You should have received a copy of the GNU General Public License version
   64.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   64.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   64.23 - *
   64.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   64.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   64.26 - * have any questions.
   64.27 - */
   64.28 -
   64.29 -package sun.awt.motif;
   64.30 -
   64.31 -import java.awt.*;
   64.32 -import java.awt.peer.*;
   64.33 -import java.awt.datatransfer.*;
   64.34 -import java.awt.event.ActionEvent;
   64.35 -import java.awt.event.TextEvent;
   64.36 -import java.awt.im.InputMethodRequests;
   64.37 -
   64.38 -
   64.39 -public class MTextFieldPeer extends MComponentPeer implements TextFieldPeer {
   64.40 -    native void pCreate(MComponentPeer parent);
   64.41 -
   64.42 -    private boolean firstChangeSkipped;
   64.43 -
   64.44 -    /**
   64.45 -     * Initialize JNI field and method IDs
   64.46 -     */
   64.47 -    private static native void initIDs();
   64.48 -
   64.49 -    static {
   64.50 -        initIDs();
   64.51 -    }
   64.52 -
   64.53 -    void create(MComponentPeer parent) {
   64.54 -        firstChangeSkipped = false;
   64.55 -        pCreate(parent);
   64.56 -    }
   64.57 -
   64.58 -    void initialize() {
   64.59 -        int start, end;
   64.60 -
   64.61 -        TextField txt = (TextField)target;
   64.62 -
   64.63 -        setText(txt.getText());
   64.64 -        if (txt.echoCharIsSet()) {
   64.65 -            setEchoChar(txt.getEchoChar());
   64.66 -        }
   64.67 -
   64.68 -        start = txt.getSelectionStart();
   64.69 -        end = txt.getSelectionEnd();
   64.70 -
   64.71 -        if (end > start) {
   64.72 -            select(start, end);
   64.73 -        } else {
   64.74 -            setCaretPosition(start);
   64.75 -        }
   64.76 -
   64.77 -        if (!target.isBackgroundSet()) {
   64.78 -            // This is a way to set the background color of the TextArea
   64.79 -            // without calling setBackground - go through native C code
   64.80 -            setTargetBackground(SystemColor.text);
   64.81 -        }
   64.82 -        if (!target.isForegroundSet()) {
   64.83 -            target.setForeground(SystemColor.textText);
   64.84 -        }
   64.85 -
   64.86 -        setEditable(txt.isEditable());
   64.87 -
   64.88 -//      oldSelectionStart = -1; // accessibility support
   64.89 -//      oldSelectionEnd = -1;   // accessibility support
   64.90 -
   64.91 -        super.initialize();
   64.92 -    }
   64.93 -
   64.94 -    public MTextFieldPeer(TextField target) {
   64.95 -        super(target);
   64.96 -    }
   64.97 -
   64.98 -    public void setEditable(boolean editable) {
   64.99 -        pSetEditable(editable);
  64.100 -
  64.101 -        /* 4136955 - Calling setBackground() here works around an Xt
  64.102 -         * bug by forcing Xt to flush an internal widget cache
  64.103 -         */
  64.104 -        setBackground(target.getBackground());
  64.105 -    }
  64.106 -
  64.107 -    public native void pSetEditable(boolean editable);
  64.108 -    public native void select(int selStart, int selEnd);
  64.109 -    public native int getSelectionStart();
  64.110 -    public native int getSelectionEnd();
  64.111 -    public native void setText(String l);
  64.112 -    public native void insertReplaceText(String l);
  64.113 -    public native void preDispose();
  64.114 -    public native String getText();
  64.115 -    public native void setEchoChar(char c);
  64.116 -    public native void setFont(Font f);
  64.117 -    public native void setCaretPosition(int pos);
  64.118 -    public native int getCaretPosition();
  64.119 -
  64.120 -    // CDE/Motif defaults: margin=5, shadow=2, highlight=1 -- times 2.
  64.121 -    // Should have asked the widgets for correct values (see MTextAreaPeer).
  64.122 -    private static final int padding = 16;
  64.123 -
  64.124 -    public Dimension getMinimumSize() {
  64.125 -        FontMetrics fm = getFontMetrics(target.getFont());
  64.126 -        return new Dimension(fm.stringWidth(((TextField)target).getText())+20,
  64.127 -                             fm.getMaxDescent() + fm.getMaxAscent() + padding);
  64.128 -    }
  64.129 -
  64.130 -    public Dimension getPreferredSize(int cols) {
  64.131 -        return getMinimumSize(cols);
  64.132 -    }
  64.133 -
  64.134 -    public Dimension getMinimumSize(int cols) {
  64.135 -        FontMetrics fm = getFontMetrics(target.getFont());
  64.136 -        return new Dimension(fm.charWidth('0') * cols + 20,
  64.137 -                             fm.getMaxDescent() + fm.getMaxAscent() + padding);
  64.138 -    }
  64.139 -
  64.140 -    public boolean isFocusable() {
  64.141 -        return true;
  64.142 -    }
  64.143 -
  64.144 -    // NOTE: This method is called by privileged threads.
  64.145 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  64.146 -    public void action(final long when, final int modifiers) {
  64.147 -        MToolkit.executeOnEventHandlerThread(target, new Runnable() {
  64.148 -            public void run() {
  64.149 -                postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
  64.150 -                                          ((TextField)target).getText(), when,
  64.151 -                                          modifiers));
  64.152 -            }
  64.153 -        });
  64.154 -    }
  64.155 -
  64.156 -    protected void disposeImpl() {
  64.157 -        preDispose();
  64.158 -        super.disposeImpl();
  64.159 -    }
  64.160 -
  64.161 -    /*
  64.162 -     * Post a new TextEvent when the value of a text component changes.
  64.163 -     */
  64.164 -    public void valueChanged() {
  64.165 -        postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
  64.166 -    }
  64.167 -
  64.168 -    // Called from native widget when paste key is pressed and we
  64.169 -    // already own the selection (prevents Motif from hanging while
  64.170 -    // waiting for the selection)
  64.171 -    //
  64.172 -    // NOTE: This method is called by privileged threads.
  64.173 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  64.174 -    public void pasteFromClipboard() {
  64.175 -        Clipboard clipboard = target.getToolkit().getSystemClipboard();
  64.176 -
  64.177 -        Transferable content = clipboard.getContents(this);
  64.178 -        if (content != null) {
  64.179 -            try {
  64.180 -                String data = (String)(content.getTransferData(DataFlavor.stringFlavor));
  64.181 -                insertReplaceText(data);
  64.182 -
  64.183 -            } catch (Exception e) {
  64.184 -            }
  64.185 -        }
  64.186 -    }
  64.187 -
  64.188 -    /*
  64.189 -     * Print the native component by rendering the Motif look ourselves.
  64.190 -     * ToDo(aim): needs to query native motif for more accurate size and
  64.191 -     * color information, left text offset, and selected text.
  64.192 -     */
  64.193 -    public final static int BORDER = 2;
  64.194 -    public final static int MARGIN = 4;
  64.195 -
  64.196 -    public void print(Graphics g) {
  64.197 -        TextField txt = (TextField)target;
  64.198 -        Dimension d = txt.size();
  64.199 -        int w = d.width - (2 * BORDER);
  64.200 -        int h = d.height - (2 * BORDER);
  64.201 -        Color bg = txt.getBackground();
  64.202 -        Color fg = txt.getForeground();
  64.203 -        Color highlight = bg.brighter();
  64.204 -        String text = txt.getText();
  64.205 -        int moved = 0;
  64.206 -        int selStart = 0;
  64.207 -        int selEnd = 0;
  64.208 -
  64.209 -        g.setFont(txt.getFont());
  64.210 -        g.setColor(txt.isEditable() ? highlight : bg);
  64.211 -        g.fillRect(BORDER, BORDER, w, h);
  64.212 -
  64.213 -        g.setColor(bg);
  64.214 -        //g.drawRect(0, 0, d.width-1, d.height-1);
  64.215 -        draw3DRect(g, bg, 1, 1, d.width-3, d.height-3, false);
  64.216 -
  64.217 -        if (text != null) {
  64.218 -            g.clipRect(BORDER, MARGIN, w, d.height - (2 * MARGIN));
  64.219 -            FontMetrics fm = g.getFontMetrics();
  64.220 -
  64.221 -            w = d.width - BORDER;
  64.222 -            h = d.height - (2 * MARGIN);
  64.223 -            int xs = pos2x(selStart) - moved;
  64.224 -            int xe = pos2x(selEnd) - moved;
  64.225 -
  64.226 -            if ((xs < MARGIN) && (xe > w)) {
  64.227 -                g.setColor(highlight);
  64.228 -                g.fillRect(BORDER, MARGIN, w - BORDER, h);
  64.229 -            } else {
  64.230 -                g.setColor(bg);
  64.231 -                //g.fillRect(BORDER, MARGIN, w - BORDER, h);
  64.232 -
  64.233 -                if ((xs >= MARGIN) && (xs <= w)) {
  64.234 -                    g.setColor(highlight); // selected text
  64.235 -
  64.236 -                    if (xe > w) {
  64.237 -                        g.fillRect(xs, MARGIN, w - xs, h);
  64.238 -                    } else if (xs == xe) {
  64.239 -                      //g.fillRect(xs, MARGIN, 1, h);
  64.240 -                    } else {
  64.241 -                        g.fillRect(xs, MARGIN, xe - xs, h);
  64.242 -                    }
  64.243 -                } else if ((xe >= MARGIN) && (xe <= w)) {
  64.244 -                    g.setColor(highlight);
  64.245 -                    g.fillRect(BORDER, MARGIN, xe - BORDER, h);
  64.246 -                }
  64.247 -            }
  64.248 -           g.setColor(fg);
  64.249 -           int x = MARGIN - moved;
  64.250 -           char echoChar = txt.getEchoChar();
  64.251 -           if (echoChar == 0) {
  64.252 -               g.drawString(text, x, BORDER + MARGIN + fm.getMaxAscent());
  64.253 -           } else {
  64.254 -               char data[] = new char[text.length()];
  64.255 -               for (int i = 0 ; i < data.length ; i++) {
  64.256 -                   data[i] = echoChar;
  64.257 -               }
  64.258 -               g.drawChars(data, 0, data.length, x,
  64.259 -                           BORDER + MARGIN + fm.getMaxAscent());
  64.260 -
  64.261 -           }
  64.262 -        }
  64.263 -
  64.264 -        target.print(g);
  64.265 -    }
  64.266 -
  64.267 -    int pos2x(int pos) {
  64.268 -        TextField txt = (TextField)target;
  64.269 -        FontMetrics fm = getFontMetrics(txt.getFont());
  64.270 -        int x = MARGIN, widths[] = fm.getWidths();
  64.271 -        String text = txt.getText();
  64.272 -        char echoChar = txt.getEchoChar();
  64.273 -        if (echoChar == 0) {
  64.274 -            for (int i = 0 ; i < pos ; i++) {
  64.275 -                x += widths[text.charAt(i)];
  64.276 -            }
  64.277 -        } else {
  64.278 -            x += widths[echoChar] * pos;
  64.279 -        }
  64.280 -        return x;
  64.281 -    }
  64.282 -
  64.283 -    /**
  64.284 -     * DEPRECATED
  64.285 -     */
  64.286 -    public void setEchoCharacter(char c) {
  64.287 -        setEchoChar(c);
  64.288 -    }
  64.289 -
  64.290 -    /**
  64.291 -     * DEPRECATED
  64.292 -     */
  64.293 -    public Dimension minimumSize() {
  64.294 -        return getMinimumSize();
  64.295 -    }
  64.296 -
  64.297 -    /**
  64.298 -     * DEPRECATED
  64.299 -     */
  64.300 -    public Dimension minimumSize(int cols) {
  64.301 -        return getMinimumSize(cols);
  64.302 -    }
  64.303 -
  64.304 -    /**
  64.305 -     * DEPRECATED
  64.306 -     */
  64.307 -    public Dimension preferredSize(int cols) {
  64.308 -        return getPreferredSize(cols);
  64.309 -    }
  64.310 -    void pShow(){
  64.311 -      super.pShow();
  64.312 -      notifyTextComponentChange(true);
  64.313 -    }
  64.314 -
  64.315 -    void pHide(){
  64.316 -      notifyTextComponentChange(false);
  64.317 -      super.pHide();
  64.318 -    }
  64.319 -
  64.320 -    void pDispose(){
  64.321 -      notifyTextComponentChange(false);
  64.322 -      super.pDispose();
  64.323 -    }
  64.324 -
  64.325 -     public InputMethodRequests getInputMethodRequests() {
  64.326 -            return null;
  64.327 -      }
  64.328 -
  64.329 -
  64.330 -
  64.331 -    //
  64.332 -    // Accessibility support
  64.333 -    //
  64.334 -
  64.335 -    // stub functions: to be fully implemented in a future release
  64.336 -    public int getIndexAtPoint(int x, int y) { return -1; }
  64.337 -    public Rectangle getCharacterBounds(int i) { return null; }
  64.338 -    public long filterEvents(long mask) { return 0; }
  64.339 -
  64.340 -
  64.341 -/*  To be fully implemented in a future release
  64.342 -
  64.343 -    int oldSelectionStart;
  64.344 -    int oldSelectionEnd;
  64.345 -
  64.346 -    public native int getIndexAtPoint(int x, int y);
  64.347 -    public native Rectangle getCharacterBounds(int i);
  64.348 -    public native long filterEvents(long mask);
  64.349 -
  64.350 -    /**
  64.351 -     * Handle a change in the text selection endpoints
  64.352 -     * (Note: could be simply a change in the caret location)
  64.353 -     *
  64.354 -    public void selectionValuesChanged(int start, int end) {
  64.355 -        return;  // Need to write implemetation of this.
  64.356 -    }
  64.357 -*/
  64.358 -
  64.359 -}
    65.1 --- a/src/solaris/classes/sun/awt/motif/MToolkit.java	Wed Sep 17 13:45:37 2008 -0700
    65.2 +++ b/src/solaris/classes/sun/awt/motif/MToolkit.java	Fri Sep 19 19:38:12 2008 -0700
    65.3 @@ -60,12 +60,12 @@
    65.4  import java.awt.dnd.InvalidDnDOperationException;
    65.5  import java.awt.dnd.peer.DragSourceContextPeer;
    65.6  
    65.7 -import sun.awt.motif.MInputMethod;
    65.8 +//import sun.awt.motif.MInputMethod;
    65.9  import sun.awt.X11GraphicsConfig;
   65.10  import sun.awt.X11GraphicsEnvironment;
   65.11  import sun.awt.XSettings;
   65.12  
   65.13 -import sun.awt.motif.MDragSourceContextPeer;
   65.14 +//import sun.awt.motif.MDragSourceContextPeer;
   65.15  
   65.16  import sun.print.PrintJob2D;
   65.17  
   65.18 @@ -79,9 +79,9 @@
   65.19      private static final Logger log = Logger.getLogger("sun.awt.motif.MToolkit");
   65.20  
   65.21      // the system clipboard - CLIPBOARD selection
   65.22 -    X11Clipboard clipboard;
   65.23 +    //X11Clipboard clipboard;
   65.24      // the system selection - PRIMARY selection
   65.25 -    X11Clipboard selection;
   65.26 +    //X11Clipboard selection;
   65.27  
   65.28      // Dynamic Layout Resize client code setting
   65.29      protected static boolean dynamicLayoutSetting = false;
   65.30 @@ -130,7 +130,7 @@
   65.31              new GetBooleanAction("awt.dnd.motifdnd"))).booleanValue();
   65.32      }
   65.33  
   65.34 -    public static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.motif.MDataTransferer";
   65.35 +    //public static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.motif.MDataTransferer";
   65.36  
   65.37      public MToolkit() {
   65.38          super();
   65.39 @@ -150,7 +150,7 @@
   65.40              }
   65.41  
   65.42              init(mainClassName);
   65.43 -            SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
   65.44 +            //SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
   65.45  
   65.46              Thread toolkitThread = new Thread(this, "AWT-Motif");
   65.47              toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
   65.48 @@ -197,131 +197,152 @@
   65.49       */
   65.50  
   65.51      public ButtonPeer createButton(Button target) {
   65.52 -        ButtonPeer peer = new MButtonPeer(target);
   65.53 -        targetCreatedPeer(target, peer);
   65.54 -        return peer;
   65.55 +        //ButtonPeer peer = new MButtonPeer(target);
   65.56 +        //targetCreatedPeer(target, peer);
   65.57 +        //return peer;
   65.58 +        return null;
   65.59      }
   65.60  
   65.61      public TextFieldPeer createTextField(TextField target) {
   65.62 -        TextFieldPeer peer = new MTextFieldPeer(target);
   65.63 -        targetCreatedPeer(target, peer);
   65.64 -        return peer;
   65.65 +        //TextFieldPeer peer = new MTextFieldPeer(target);
   65.66 +        //targetCreatedPeer(target, peer);
   65.67 +        //return peer;
   65.68 +        return null;
   65.69      }
   65.70  
   65.71      public LabelPeer createLabel(Label target) {
   65.72 -        LabelPeer peer = new MLabelPeer(target);
   65.73 -        targetCreatedPeer(target, peer);
   65.74 -        return peer;
   65.75 +        //LabelPeer peer = new MLabelPeer(target);
   65.76 +        //targetCreatedPeer(target, peer);
   65.77 +        //return peer;
   65.78 +        return null;
   65.79      }
   65.80  
   65.81      public ListPeer createList(List target) {
   65.82 -        ListPeer peer = new MListPeer(target);
   65.83 -        targetCreatedPeer(target, peer);
   65.84 -        return peer;
   65.85 +        //ListPeer peer = new MListPeer(target);
   65.86 +        //targetCreatedPeer(target, peer);
   65.87 +        //return peer;
   65.88 +        return null;
   65.89      }
   65.90  
   65.91      public CheckboxPeer createCheckbox(Checkbox target) {
   65.92 -        CheckboxPeer peer = new MCheckboxPeer(target);
   65.93 -        targetCreatedPeer(target, peer);
   65.94 -        return peer;
   65.95 +        //CheckboxPeer peer = new MCheckboxPeer(target);
   65.96 +        //targetCreatedPeer(target, peer);
   65.97 +        //return peer;
   65.98 +        return null;
   65.99      }
  65.100  
  65.101      public ScrollbarPeer createScrollbar(Scrollbar target) {
  65.102 -        ScrollbarPeer peer = new MScrollbarPeer(target);
  65.103 -        targetCreatedPeer(target, peer);
  65.104 -        return peer;
  65.105 +        //ScrollbarPeer peer = new MScrollbarPeer(target);
  65.106 +        //targetCreatedPeer(target, peer);
  65.107 +        //return peer;
  65.108 +        return null;
  65.109      }
  65.110  
  65.111      public ScrollPanePeer createScrollPane(ScrollPane target) {
  65.112 -        ScrollPanePeer peer = new MScrollPanePeer(target);
  65.113 -        targetCreatedPeer(target, peer);
  65.114 -        return peer;
  65.115 +        //ScrollPanePeer peer = new MScrollPanePeer(target);
  65.116 +        //targetCreatedPeer(target, peer);
  65.117 +        //return peer;
  65.118 +        return null;
  65.119      }
  65.120  
  65.121      public TextAreaPeer createTextArea(TextArea target) {
  65.122 -        TextAreaPeer peer = new MTextAreaPeer(target);
  65.123 -        targetCreatedPeer(target, peer);
  65.124 -        return peer;
  65.125 +        //TextAreaPeer peer = new MTextAreaPeer(target);
  65.126 +        //targetCreatedPeer(target, peer);
  65.127 +        //return peer;
  65.128 +        return null;
  65.129      }
  65.130  
  65.131      public ChoicePeer createChoice(Choice target) {
  65.132 -        ChoicePeer peer = new MChoicePeer(target);
  65.133 -        targetCreatedPeer(target, peer);
  65.134 -        return peer;
  65.135 +        //ChoicePeer peer = new MChoicePeer(target);
  65.136 +        //targetCreatedPeer(target, peer);
  65.137 +        //return peer;
  65.138 +        return null;
  65.139      }
  65.140  
  65.141      public FramePeer  createFrame(Frame target) {
  65.142 -        FramePeer peer = new MFramePeer(target);
  65.143 -        targetCreatedPeer(target, peer);
  65.144 -        return peer;
  65.145 +        //FramePeer peer = new MFramePeer(target);
  65.146 +        //targetCreatedPeer(target, peer);
  65.147 +        //return peer;
  65.148 +        return null;
  65.149      }
  65.150  
  65.151      public CanvasPeer createCanvas(Canvas target) {
  65.152 -        CanvasPeer peer = (isXEmbedServerRequested() ? new MEmbedCanvasPeer(target) : new MCanvasPeer(target));
  65.153 -        targetCreatedPeer(target, peer);
  65.154 -        return peer;
  65.155 +        //CanvasPeer peer = (isXEmbedServerRequested() ? new MEmbedCanvasPeer(target) : new MCanvasPeer(target));
  65.156 +        //targetCreatedPeer(target, peer);
  65.157 +        //return peer;
  65.158 +        return null;
  65.159      }
  65.160  
  65.161      public PanelPeer createPanel(Panel target) {
  65.162 -        PanelPeer peer = new MPanelPeer(target);
  65.163 -        targetCreatedPeer(target, peer);
  65.164 -        return peer;
  65.165 +        //PanelPeer peer = new MPanelPeer(target);
  65.166 +        //targetCreatedPeer(target, peer);
  65.167 +        //return peer;
  65.168 +        return null;
  65.169      }
  65.170  
  65.171      public WindowPeer createWindow(Window target) {
  65.172 -        WindowPeer peer = new MWindowPeer(target);
  65.173 -        targetCreatedPeer(target, peer);
  65.174 -        return peer;
  65.175 +        //WindowPeer peer = new MWindowPeer(target);
  65.176 +        //targetCreatedPeer(target, peer);
  65.177 +        //return peer;
  65.178 +        return null;
  65.179      }
  65.180  
  65.181      public DialogPeer createDialog(Dialog target) {
  65.182 -        DialogPeer peer = new MDialogPeer(target);
  65.183 -        targetCreatedPeer(target, peer);
  65.184 -        return peer;
  65.185 +        //DialogPeer peer = new MDialogPeer(target);
  65.186 +        //targetCreatedPeer(target, peer);
  65.187 +        //return peer;
  65.188 +        return null;
  65.189      }
  65.190  
  65.191      public FileDialogPeer createFileDialog(FileDialog target) {
  65.192 -        FileDialogPeer peer = new MFileDialogPeer(target);
  65.193 -        targetCreatedPeer(target, peer);
  65.194 -        return peer;
  65.195 +        //FileDialogPeer peer = new MFileDialogPeer(target);
  65.196 +        //targetCreatedPeer(target, peer);
  65.197 +        //return peer;
  65.198 +        return null;
  65.199      }
  65.200  
  65.201      public MenuBarPeer createMenuBar(MenuBar target) {
  65.202 -        MenuBarPeer peer = new MMenuBarPeer(target);
  65.203 -        targetCreatedPeer(target, peer);
  65.204 -        return peer;
  65.205 +        //MenuBarPeer peer = new MMenuBarPeer(target);
  65.206 +        //targetCreatedPeer(target, peer);
  65.207 +        //return peer;
  65.208 +        return null;
  65.209      }
  65.210  
  65.211      public MenuPeer createMenu(Menu target) {
  65.212 -        MenuPeer peer = new MMenuPeer(target);
  65.213 -        targetCreatedPeer(target, peer);
  65.214 -        return peer;
  65.215 +        //MenuPeer peer = new MMenuPeer(target);
  65.216 +        //targetCreatedPeer(target, peer);
  65.217 +        //return peer;
  65.218 +        return null;
  65.219      }
  65.220  
  65.221      public PopupMenuPeer createPopupMenu(PopupMenu target) {
  65.222 -        PopupMenuPeer peer = new MPopupMenuPeer(target);
  65.223 -        targetCreatedPeer(target, peer);
  65.224 -        return peer;
  65.225 +        //PopupMenuPeer peer = new MPopupMenuPeer(target);
  65.226 +        //targetCreatedPeer(target, peer);
  65.227 +        //return peer;
  65.228 +        return null;
  65.229      }
  65.230  
  65.231      public MenuItemPeer createMenuItem(MenuItem target) {
  65.232 -        MenuItemPeer peer = new MMenuItemPeer(target);
  65.233 -        targetCreatedPeer(target, peer);
  65.234 -        return peer;
  65.235 +        //MenuItemPeer peer = new MMenuItemPeer(target);
  65.236 +        //targetCreatedPeer(target, peer);
  65.237 +        //return peer;
  65.238 +        return null;
  65.239      }
  65.240  
  65.241      public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) {
  65.242 -        CheckboxMenuItemPeer peer = new MCheckboxMenuItemPeer(target);
  65.243 -        targetCreatedPeer(target, peer);
  65.244 -        return peer;
  65.245 +        //CheckboxMenuItemPeer peer = new MCheckboxMenuItemPeer(target);
  65.246 +        //targetCreatedPeer(target, peer);
  65.247 +        //return peer;
  65.248 +        return null;
  65.249      }
  65.250  
  65.251 -    public MEmbeddedFramePeer createEmbeddedFrame(MEmbeddedFrame target)
  65.252 -    {
  65.253 -        MEmbeddedFramePeer peer = new MEmbeddedFramePeer(target);
  65.254 -        targetCreatedPeer(target, peer);
  65.255 -        return peer;
  65.256 -    }
  65.257 +    //public MEmbeddedFramePeer createEmbeddedFrame(MEmbeddedFrame target)
  65.258 +    //{
  65.259 +        //MEmbeddedFramePeer peer = new MEmbeddedFramePeer(target);
  65.260 +        //targetCreatedPeer(target, peer);
  65.261 +        //return peer;
  65.262 +    //    return null;
  65.263 +    //}
  65.264  
  65.265  
  65.266      public FontPeer getFontPeer(String name, int style){
  65.267 @@ -438,29 +459,31 @@
  65.268      public native void beep();
  65.269  
  65.270      public  Clipboard getSystemClipboard() {
  65.271 -        SecurityManager security = System.getSecurityManager();
  65.272 -        if (security != null) {
  65.273 -          security.checkSystemClipboardAccess();
  65.274 -        }
  65.275 -        synchronized (this) {
  65.276 -            if (clipboard == null) {
  65.277 -                clipboard = new X11Clipboard("System", "CLIPBOARD");
  65.278 -            }
  65.279 -        }
  65.280 -        return clipboard;
  65.281 +        //SecurityManager security = System.getSecurityManager();
  65.282 +        //if (security != null) {
  65.283 +        //  security.checkSystemClipboardAccess();
  65.284 +        //}
  65.285 +        //synchronized (this) {
  65.286 +        //    if (clipboard == null) {
  65.287 +        //        clipboard = new X11Clipboard("System", "CLIPBOARD");
  65.288 +        //    }
  65.289 +        //}
  65.290 +        //return clipboard;
  65.291 +        return null;
  65.292      }
  65.293  
  65.294      public Clipboard getSystemSelection() {
  65.295 -        SecurityManager security = System.getSecurityManager();
  65.296 -        if (security != null) {
  65.297 -            security.checkSystemClipboardAccess();
  65.298 -        }
  65.299 -        synchronized (this) {
  65.300 -            if (selection == null) {
  65.301 -                selection = new X11Clipboard("Selection", "PRIMARY");
  65.302 -            }
  65.303 -        }
  65.304 -        return selection;
  65.305 +        //SecurityManager security = System.getSecurityManager();
  65.306 +        //if (security != null) {
  65.307 +        //    security.checkSystemClipboardAccess();
  65.308 +        //}
  65.309 +        //synchronized (this) {
  65.310 +        //    if (selection == null) {
  65.311 +        //        selection = new X11Clipboard("Selection", "PRIMARY");
  65.312 +        //    }
  65.313 +        //}
  65.314 +        //return selection;
  65.315 +        return null;
  65.316      }
  65.317  
  65.318      public boolean getLockingKeyState(int key) {
  65.319 @@ -492,11 +515,12 @@
  65.320      }
  65.321  
  65.322      public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
  65.323 -        if (MToolkit.useMotifDnD()) {
  65.324 -            return MDragSourceContextPeer.createDragSourceContextPeer(dge);
  65.325 -        } else {
  65.326 -            return X11DragSourceContextPeer.createDragSourceContextPeer(dge);
  65.327 -        }
  65.328 +        //if (MToolkit.useMotifDnD()) {
  65.329 +        //    return MDragSourceContextPeer.createDragSourceContextPeer(dge);
  65.330 +        //} else {
  65.331 +        //    return X11DragSourceContextPeer.createDragSourceContextPeer(dge);
  65.332 +        //}
  65.333 +        return null;
  65.334      }
  65.335  
  65.336      public <T extends DragGestureRecognizer> T
  65.337 @@ -504,9 +528,9 @@
  65.338                                      DragSource ds, Component c, int srcActions,
  65.339                                      DragGestureListener dgl)
  65.340      {
  65.341 -        if (MouseDragGestureRecognizer.class.equals(abstractRecognizerClass))
  65.342 -            return (T)new MMouseDragGestureRecognizer(ds, c, srcActions, dgl);
  65.343 -        else
  65.344 +        //if (MouseDragGestureRecognizer.class.equals(abstractRecognizerClass))
  65.345 +        //    return (T)new MMouseDragGestureRecognizer(ds, c, srcActions, dgl);
  65.346 +        //else
  65.347              return null;
  65.348      }
  65.349  
  65.350 @@ -514,14 +538,14 @@
  65.351       * Returns a new input method adapter descriptor for native input methods.
  65.352       */
  65.353      public InputMethodDescriptor getInputMethodAdapterDescriptor() throws AWTException {
  65.354 -        return new MInputMethodDescriptor();
  65.355 +        return null; // return new MInputMethodDescriptor();
  65.356      }
  65.357  
  65.358      /**
  65.359       * Returns a style map for the input method highlight.
  65.360       */
  65.361      public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
  65.362 -        return MInputMethod.mapInputMethodHighlight(highlight);
  65.363 +        return null; //return MInputMethod.mapInputMethodHighlight(highlight);
  65.364      }
  65.365  
  65.366      /**
  65.367 @@ -529,15 +553,15 @@
  65.368       */
  65.369      public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
  65.370          throws IndexOutOfBoundsException {
  65.371 -        return new MCustomCursor(cursor, hotSpot, name);
  65.372 +        return null; //return new MCustomCursor(cursor, hotSpot, name);
  65.373      }
  65.374  
  65.375      /**
  65.376       * Returns the supported cursor size
  65.377       */
  65.378      public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
  65.379 -        return MCustomCursor.getBestCursorSize(
  65.380 -            java.lang.Math.max(1,preferredWidth), java.lang.Math.max(1,preferredHeight));
  65.381 +        return null; //MCustomCursor.getBestCursorSize(
  65.382 +            //java.lang.Math.max(1,preferredWidth), java.lang.Math.max(1,preferredHeight));
  65.383      }
  65.384  
  65.385      public int getMaximumCursorColors() {
  65.386 @@ -621,7 +645,8 @@
  65.387  
  65.388      public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
  65.389          /* 'target' is unused for now... */
  65.390 -        return new MRobotPeer(screen.getDefaultConfiguration());
  65.391 +        //return new MRobotPeer(screen.getDefaultConfiguration());
  65.392 +        return null;
  65.393      }
  65.394  
  65.395      static boolean useMotifDnD() {
    66.1 --- a/src/solaris/classes/sun/awt/motif/MWindowPeer.java	Wed Sep 17 13:45:37 2008 -0700
    66.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.3 @@ -1,602 +0,0 @@
    66.4 -/*
    66.5 - * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
    66.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    66.7 - *
    66.8 - * This code is free software; you can redistribute it and/or modify it
    66.9 - * under the terms of the GNU General Public License version 2 only, as
   66.10 - * published by the Free Software Foundation.  Sun designates this
   66.11 - * particular file as subject to the "Classpath" exception as provided
   66.12 - * by Sun in the LICENSE file that accompanied this code.
   66.13 - *
   66.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   66.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   66.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   66.17 - * version 2 for more details (a copy is included in the LICENSE file that
   66.18 - * accompanied this code).
   66.19 - *
   66.20 - * You should have received a copy of the GNU General Public License version
   66.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   66.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   66.23 - *
   66.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   66.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   66.26 - * have any questions.
   66.27 - */
   66.28 -package sun.awt.motif;
   66.29 -
   66.30 -import java.util.Vector;
   66.31 -import java.awt.*;
   66.32 -import java.awt.peer.*;
   66.33 -import java.awt.event.*;
   66.34 -import java.awt.image.BufferedImage;
   66.35 -import java.awt.image.DataBuffer;
   66.36 -import java.awt.image.DataBufferByte;
   66.37 -import java.awt.image.DataBufferInt;
   66.38 -import java.awt.image.ImageObserver;
   66.39 -import sun.awt.image.ImageRepresentation;
   66.40 -import sun.awt.motif.MInputMethod;
   66.41 -import sun.awt.motif.MInputMethodControl;
   66.42 -import sun.awt.im.*;
   66.43 -import sun.awt.DisplayChangedListener;
   66.44 -import sun.awt.SunToolkit;
   66.45 -import sun.awt.X11GraphicsDevice;
   66.46 -
   66.47 -class MWindowPeer extends MPanelPeer implements WindowPeer,
   66.48 -DisplayChangedListener {
   66.49 -
   66.50 -    Insets insets = new Insets( 0, 0, 0, 0 );
   66.51 -    MWindowAttributes winAttr;
   66.52 -    static Vector allWindows = new Vector();
   66.53 -    int         iconWidth  = -1;
   66.54 -    int         iconHeight = -1;
   66.55 -
   66.56 -    int dropTargetCount = 0;
   66.57 -    boolean alwaysOnTop;
   66.58 -
   66.59 -    native void pCreate(MComponentPeer parent, String targetClassName, boolean isFocusableWindow);
   66.60 -    native void pShow();
   66.61 -    native void pToFront();
   66.62 -    native void pShowModal(boolean isModal);
   66.63 -    native void pHide();
   66.64 -    native void pReshape(int x, int y, int width, int height);
   66.65 -    native void pDispose();
   66.66 -    native void pSetTitle(String title);
   66.67 -    public native void setState(int state);
   66.68 -    public native int getState();
   66.69 -
   66.70 -    public native void setResizable(boolean resizable);
   66.71 -    native void addTextComponentNative(MComponentPeer tc);
   66.72 -    native void removeTextComponentNative();
   66.73 -    native void pSetIMMOption(String option);
   66.74 -    native void pSetMenuBar(MMenuBarPeer mbpeer);
   66.75 -    native void setSaveUnder(boolean state);
   66.76 -
   66.77 -    native void registerX11DropTarget(Component target);
   66.78 -    native void unregisterX11DropTarget(Component target);
   66.79 -    native void updateAlwaysOnTop(boolean isAlwaysOnTop);
   66.80 -
   66.81 -    private static native void initIDs();
   66.82 -
   66.83 -    static {
   66.84 -        initIDs();
   66.85 -    }
   66.86 -
   66.87 -    // this function is privileged! do not change it to public!
   66.88 -    private static int getInset(final String name, final int def) {
   66.89 -        Integer tmp = (Integer) java.security.AccessController.doPrivileged(
   66.90 -            new sun.security.action.GetIntegerAction(name, def));
   66.91 -        return tmp.intValue();
   66.92 -    }
   66.93 -
   66.94 -    MWindowPeer() {
   66.95 -        insets = new Insets(0,0,0,0);
   66.96 -        winAttr = new MWindowAttributes();
   66.97 -    }
   66.98 -
   66.99 -    MWindowPeer(Window target) {
  66.100 -
  66.101 -        this();
  66.102 -        init(target);
  66.103 -
  66.104 -        allWindows.addElement(this);
  66.105 -    }
  66.106 -
  66.107 -    void create(MComponentPeer parent) {
  66.108 -        pCreate(parent, target.getClass().getName(), ((Window)target).isFocusableWindow());
  66.109 -    }
  66.110 -
  66.111 -    void init( Window target ) {
  66.112 -        if ( winAttr.nativeDecor == true ) {
  66.113 -            insets.top = getInset("awt.frame.topInset", -1);
  66.114 -            insets.left = getInset("awt.frame.leftInset", -1);
  66.115 -            insets.bottom = getInset("awt.frame.bottomInset", -1);
  66.116 -            insets.right = getInset("awt.frame.rightInset", -1);
  66.117 -        }
  66.118 -
  66.119 -        Rectangle bounds = target.getBounds();
  66.120 -        sysX = bounds.x;
  66.121 -        sysY = bounds.y;
  66.122 -        sysW = bounds.width;
  66.123 -        sysH = bounds.height;
  66.124 -
  66.125 -        super.init(target);
  66.126 -        InputMethodManager imm = InputMethodManager.getInstance();
  66.127 -        String menuString = imm.getTriggerMenuString();
  66.128 -        if (menuString != null)
  66.129 -        {
  66.130 -            pSetIMMOption(menuString);
  66.131 -        }
  66.132 -        pSetTitle(winAttr.title);
  66.133 -
  66.134 -        /*
  66.135 -         * For Windows and undecorated Frames and Dialogs this just
  66.136 -         * disables/enables resizing functions in the system menu.
  66.137 -         */
  66.138 -        setResizable(winAttr.isResizable);
  66.139 -
  66.140 -        setSaveUnder(true);
  66.141 -
  66.142 -        Font f = target.getFont();
  66.143 -        if (f == null) {
  66.144 -            f = defaultFont;
  66.145 -            target.setFont(f);
  66.146 -            setFont(f);
  66.147 -        }
  66.148 -        Color c = target.getBackground();
  66.149 -        if (c == null) {
  66.150 -            target.setBackground(SystemColor.window);
  66.151 -            setBackground(SystemColor.window);
  66.152 -        }
  66.153 -        c = target.getForeground();
  66.154 -        if (c == null) {
  66.155 -            target.setForeground(SystemColor.windowText);
  66.156 -            setForeground(SystemColor.windowText);
  66.157 -        }
  66.158 -        alwaysOnTop = ((Window)target).isAlwaysOnTop() && ((Window)target).isAlwaysOnTopSupported();
  66.159 -
  66.160 -        GraphicsConfiguration gc = getGraphicsConfiguration();
  66.161 -        ((X11GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this);
  66.162 -
  66.163 -    }
  66.164 -
  66.165 -    /* Support for multiple icons is not implemented in MAWT */
  66.166 -    public void updateIconImages() {
  66.167 -        if (this instanceof MFramePeer) {
  66.168 -            ((MFramePeer)this).setIconImage(((Frame)target).getIconImage());
  66.169 -        }
  66.170 -    }
  66.171 -
  66.172 -
  66.173 -    /* Not implemented in MAWT */
  66.174 -    public void updateMinimumSize() {
  66.175 -    }
  66.176 -
  66.177 -    protected void disposeImpl() {
  66.178 -        allWindows.removeElement(this);
  66.179 -        super.disposeImpl();
  66.180 -    }
  66.181 -
  66.182 -    public native void toBack();
  66.183 -
  66.184 -    public void setAlwaysOnTop(boolean alwaysOnTop) {
  66.185 -        this.alwaysOnTop = alwaysOnTop;
  66.186 -        updateAlwaysOnTop(alwaysOnTop);
  66.187 -    }
  66.188 -
  66.189 -    public void toFront() {
  66.190 -        if (target.isVisible()) {
  66.191 -            updateFocusableWindowState();
  66.192 -            pToFront();
  66.193 -        }
  66.194 -    }
  66.195 -
  66.196 -    public void updateFocusableWindowState() {
  66.197 -        setFocusableWindow(((Window)target).isFocusableWindow());
  66.198 -    }
  66.199 -    native void setFocusableWindow(boolean value);
  66.200 -
  66.201 -    public void setVisible( boolean b ) {
  66.202 -        if (b) {
  66.203 -            updateFocusableWindowState();
  66.204 -        }
  66.205 -        super.setVisible(b);
  66.206 -        updateAlwaysOnTop(alwaysOnTop);
  66.207 -    }
  66.208 -
  66.209 -    public Insets getInsets() {
  66.210 -        return insets;
  66.211 -    }
  66.212 -
  66.213 -    public void handleQuit() {
  66.214 -        postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING));
  66.215 -    }
  66.216 -
  66.217 -    // XXX: nasty WM, foul play.  spank WM author.
  66.218 -    public void handleDestroy() {
  66.219 -        final Window target = (Window)this.target;
  66.220 -        SunToolkit.executeOnEventHandlerThread(target,
  66.221 -                                               new Runnable() {
  66.222 -                                                   public void run() {
  66.223 -                                                       // This seems like the only reasonable thing we
  66.224 -                                                       // could do in this situation as the native window
  66.225 -                                                       // is already dead.
  66.226 -                                                       target.dispose();
  66.227 -                                                   }
  66.228 -                                               });
  66.229 -    }
  66.230 -
  66.231 -
  66.232 -    // NOTE: This method may be called by privileged threads.
  66.233 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  66.234 -    public void handleIconify() {
  66.235 -        postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED));
  66.236 -    }
  66.237 -
  66.238 -    // NOTE: This method may be called by privileged threads.
  66.239 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  66.240 -    public void handleDeiconify() {
  66.241 -        postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED));
  66.242 -    }
  66.243 -
  66.244 -    // NOTE: This method may be called by privileged threads.
  66.245 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  66.246 -    public void handleStateChange(int oldState, int newState) {
  66.247 -        postEvent(new WindowEvent((Window)target,
  66.248 -                                  WindowEvent.WINDOW_STATE_CHANGED,
  66.249 -                                  oldState, newState));
  66.250 -    }
  66.251 -
  66.252 -    /**
  66.253 -     * Called to inform the Window that its size has changed and it
  66.254 -     * should layout its children.
  66.255 -     */
  66.256 -    // NOTE: This method may be called by privileged threads.
  66.257 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  66.258 -    public void handleResize(int width, int height) {
  66.259 -        sysW = width;
  66.260 -        sysH = height;
  66.261 -
  66.262 -        // REMIND: Is this secure? Can client code subclass input method?
  66.263 -        if (!tcList.isEmpty() &&
  66.264 -            !imList.isEmpty()){
  66.265 -            int i;
  66.266 -            for (i = 0; i < imList.size(); i++){
  66.267 -                ((MInputMethod)imList.elementAt(i)).configureStatus();
  66.268 -            }
  66.269 -        }
  66.270 -        validateSurface(width, height);
  66.271 -        postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
  66.272 -    }
  66.273 -
  66.274 -
  66.275 -    /**
  66.276 -     * DEPRECATED:  Replaced by getInsets().
  66.277 -     */
  66.278 -    public Insets insets() {
  66.279 -        return getInsets();
  66.280 -    }
  66.281 -
  66.282 -    public void handleMoved(int x, int y) {
  66.283 -        sysX = x;
  66.284 -        sysY = y;
  66.285 -        postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
  66.286 -    }
  66.287 -
  66.288 -    private native AWTEvent wrapInSequenced(AWTEvent event);
  66.289 -
  66.290 -    // NOTE: This method may be called by privileged threads.
  66.291 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  66.292 -    public void handleWindowFocusIn() {
  66.293 -        WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
  66.294 -        /* wrap in Sequenced, then post*/
  66.295 -        postEvent(wrapInSequenced((AWTEvent) we));
  66.296 -    }
  66.297 -
  66.298 -    // NOTE: This method may be called by privileged threads.
  66.299 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  66.300 -    public void handleWindowFocusOut(Window oppositeWindow) {
  66.301 -        WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS,
  66.302 -                                         oppositeWindow);
  66.303 -        /* wrap in Sequenced, then post*/
  66.304 -        postEvent(wrapInSequenced((AWTEvent) we));
  66.305 -    }
  66.306 -
  66.307 -
  66.308 -// relocation of Imm stuff
  66.309 -    private Vector imList = new Vector();
  66.310 -    private Vector tcList = new Vector();
  66.311 -
  66.312 -    // NOTE: This method is called by privileged threads.
  66.313 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  66.314 -    void notifyIMMOptionChange(){
  66.315 -
  66.316 -        // REMIND: IS THIS SECURE??? CAN USER CODE SUBCLASS INPUTMETHODMGR???
  66.317 -        InputMethodManager.getInstance().notifyChangeRequest(target);
  66.318 -    }
  66.319 -
  66.320 -    public void addInputMethod(MInputMethod im) {
  66.321 -        if (!imList.contains(im))
  66.322 -            imList.addElement(im);
  66.323 -    }
  66.324 -
  66.325 -    public void removeInputMethod(MInputMethod im) {
  66.326 -        if (imList.contains(im))
  66.327 -            imList.removeElement(im);
  66.328 -    }
  66.329 -
  66.330 -    public void addTextComponent(MComponentPeer tc) {
  66.331 -        if (tcList.contains(tc))
  66.332 -            return;
  66.333 -        if (tcList.isEmpty()){
  66.334 -            addTextComponentNative(tc);
  66.335 -            if (!imList.isEmpty()) {
  66.336 -                for (int i = 0; i < imList.size(); i++) {
  66.337 -                    ((MInputMethod)imList.elementAt(i)).reconfigureXIC((MInputMethodControl)this);
  66.338 -                }
  66.339 -            }
  66.340 -            MToolkit.executeOnEventHandlerThread(target, new Runnable() {
  66.341 -                    public void run() {
  66.342 -                        synchronized(target.getTreeLock()) {
  66.343 -                            target.doLayout();
  66.344 -                        }
  66.345 -                    }
  66.346 -                });
  66.347 -        }
  66.348 -        tcList.addElement(tc);
  66.349 -
  66.350 -    }
  66.351 -
  66.352 -    public void removeTextComponent(MComponentPeer tc) {
  66.353 -        if (!tcList.contains(tc))
  66.354 -            return;
  66.355 -        tcList.removeElement(tc);
  66.356 -        if (tcList.isEmpty()){
  66.357 -            removeTextComponentNative();
  66.358 -            if (!imList.isEmpty()) {
  66.359 -                for (int i = 0; i < imList.size(); i++) {
  66.360 -                    ((MInputMethod)imList.elementAt(i)).reconfigureXIC((MInputMethodControl)this);
  66.361 -                }
  66.362 -            }
  66.363 -            target.doLayout();
  66.364 -        }
  66.365 -    }
  66.366 -
  66.367 -    public MComponentPeer getTextComponent() {
  66.368 -        if (!tcList.isEmpty()) {
  66.369 -            return (MComponentPeer)tcList.firstElement();
  66.370 -        } else {
  66.371 -            return null;
  66.372 -        }
  66.373 -    }
  66.374 -
  66.375 -    boolean hasDecorations(int decor) {
  66.376 -        if (!winAttr.nativeDecor) {
  66.377 -            return false;
  66.378 -        }
  66.379 -        else {
  66.380 -            int myDecor = winAttr.decorations;
  66.381 -            boolean hasBits = ((myDecor & decor) == decor);
  66.382 -            if ((myDecor & MWindowAttributes.AWT_DECOR_ALL) != 0)
  66.383 -                return !hasBits;
  66.384 -            else
  66.385 -                return hasBits;
  66.386 -        }
  66.387 -    }
  66.388 -
  66.389 -    /* Returns the native paint should be posted after setting new size
  66.390 -     */
  66.391 -    public boolean checkNativePaintOnSetBounds(int width, int height) {
  66.392 -        // Fix for 4418155. Window does not repaint
  66.393 -        // automticaly if shrinking. Should not wait for Expose
  66.394 -        return (width > oldWidth) || (height > oldHeight);
  66.395 -    }
  66.396 -
  66.397 -/* --- DisplayChangedListener Stuff --- */
  66.398 -
  66.399 -    native void resetTargetGC(Component target);
  66.400 -
  66.401 -    /* Xinerama
  66.402 -     * called to update our GC when dragged onto another screen
  66.403 -     */
  66.404 -    public void draggedToNewScreen(int screenNum) {
  66.405 -        final int finalScreenNum = screenNum;
  66.406 -
  66.407 -        SunToolkit.executeOnEventHandlerThread((Component)target, new Runnable()
  66.408 -            {
  66.409 -                public void run() {
  66.410 -                    displayChanged(finalScreenNum);
  66.411 -                }
  66.412 -            });
  66.413 -    }
  66.414 -
  66.415 -    /* Xinerama
  66.416 -     * called to update our GC when dragged onto another screen
  66.417 -     */
  66.418 -    public void displayChanged(int screenNum) {
  66.419 -        // update our GC
  66.420 -        resetLocalGC(screenNum);         /* upcall to MCanvasPeer */
  66.421 -        resetTargetGC(target);           /* call Window.resetGC() via native */
  66.422 -
  66.423 -        //propagate to children
  66.424 -        super.displayChanged(screenNum); /* upcall to MPanelPeer */
  66.425 -    }
  66.426 -
  66.427 -    /**
  66.428 -     * Helper method that executes the displayChanged(screen) method on
  66.429 -     * the event dispatch thread.  This method is used in the Xinerama case
  66.430 -     * and after display mode change events.
  66.431 -     */
  66.432 -    private void executeDisplayChangedOnEDT(int screenNum) {
  66.433 -        final int finalScreenNum = screenNum;
  66.434 -        Runnable dc = new Runnable() {
  66.435 -            public void run() {
  66.436 -                displayChanged(finalScreenNum);
  66.437 -            }
  66.438 -        };
  66.439 -        SunToolkit.executeOnEventHandlerThread((Component)target, dc);
  66.440 -    }
  66.441 -
  66.442 -    /**
  66.443 -     * From the DisplayChangedListener interface; called from
  66.444 -     * X11GraphicsDevice when the display mode has been changed.
  66.445 -     */
  66.446 -    public void displayChanged() {
  66.447 -        GraphicsConfiguration gc = getGraphicsConfiguration();
  66.448 -        int curScreenNum = ((X11GraphicsDevice)gc.getDevice()).getScreen();
  66.449 -        executeDisplayChangedOnEDT(curScreenNum);
  66.450 -    }
  66.451 -
  66.452 -    /**
  66.453 -     * From the DisplayChangedListener interface; top-levels do not need
  66.454 -     * to react to this event.
  66.455 -     */
  66.456 -    public void paletteChanged() {
  66.457 -    }
  66.458 -
  66.459 -    public synchronized void addDropTarget() {
  66.460 -        if (dropTargetCount == 0) {
  66.461 -            registerX11DropTarget(target);
  66.462 -        }
  66.463 -        dropTargetCount++;
  66.464 -    }
  66.465 -
  66.466 -    public synchronized void removeDropTarget() {
  66.467 -        dropTargetCount--;
  66.468 -        if (dropTargetCount == 0) {
  66.469 -            unregisterX11DropTarget(target);
  66.470 -        }
  66.471 -    }
  66.472 -
  66.473 -    protected synchronized void updateDropTarget() {
  66.474 -        if (dropTargetCount > 0) {
  66.475 -            unregisterX11DropTarget(target);
  66.476 -            registerX11DropTarget(target);
  66.477 -        }
  66.478 -    }
  66.479 -
  66.480 -    public boolean requestWindowFocus() {
  66.481 -        return false;
  66.482 -    }
  66.483 -
  66.484 -    public void setModalBlocked(Dialog blocker, boolean blocked) {
  66.485 -        // do nothing
  66.486 -    }
  66.487 -
  66.488 -    public void postUngrabEvent() {
  66.489 -        postEvent(new sun.awt.UngrabEvent((Window)target));
  66.490 -    }
  66.491 -
  66.492 -    boolean isOwnerOf(MComponentPeer child) {
  66.493 -        if (child == null) return false;
  66.494 -
  66.495 -        Component comp = child.target;
  66.496 -        while (comp != null && !(comp instanceof Window)) {
  66.497 -            comp = getParent_NoClientCode(comp);
  66.498 -        }
  66.499 -        if (!(comp instanceof Window)) {
  66.500 -            return false;
  66.501 -        }
  66.502 -
  66.503 -        while (comp != null && !(comp == target) && !(comp instanceof Dialog)) {
  66.504 -            comp = getParent_NoClientCode(comp);
  66.505 -        }
  66.506 -        return (comp == target);
  66.507 -    }
  66.508 -
  66.509 -    boolean processUngrabMouseEvent(MComponentPeer compPeer, int x_root, int y_root, int type) {
  66.510 -        switch (type) {
  66.511 -          case 4: // ButtonPress
  66.512 -              // Check that the target is the child of the grabbed
  66.513 -              // window or the child of one of the owned windows of
  66.514 -              // the grabbed window
  66.515 -              if (!isOwnerOf(compPeer)) {
  66.516 -                  postUngrabEvent();
  66.517 -                  return true;
  66.518 -              }
  66.519 -        }
  66.520 -        return false;
  66.521 -    }
  66.522 -
  66.523 -    private final boolean hasWarningWindow() {
  66.524 -        return ((Window)target).getWarningString() != null;
  66.525 -    }
  66.526 -
  66.527 -    // This method is overriden at Dialog and Frame peers.
  66.528 -    boolean isTargetUndecorated() {
  66.529 -        return true;
  66.530 -    }
  66.531 -
  66.532 -    private volatile int sysX = 0;
  66.533 -    private volatile int sysY = 0;
  66.534 -    private volatile int sysW = 0;
  66.535 -    private volatile int sysH = 0;
  66.536 -
  66.537 -    Rectangle constrainBounds(int x, int y, int width, int height) {
  66.538 -        // We don't restrict the setBounds() operation if the code is trusted.
  66.539 -        if (!hasWarningWindow()) {
  66.540 -            return new Rectangle(x, y, width, height);
  66.541 -        }
  66.542 -
  66.543 -        int newX = x;
  66.544 -        int newY = y;
  66.545 -        int newW = width;
  66.546 -        int newH = height;
  66.547 -
  66.548 -        GraphicsConfiguration gc = ((Window)target).getGraphicsConfiguration();
  66.549 -        Rectangle sB = gc.getBounds();
  66.550 -        Insets sIn = ((Window)target).getToolkit().getScreenInsets(gc);
  66.551 -
  66.552 -        int screenW = sB.width - sIn.left - sIn.right;
  66.553 -        int screenH = sB.height - sIn.top - sIn.bottom;
  66.554 -
  66.555 -        // If it's undecorated or is not currently visible,
  66.556 -        // then check each point is within the visible part of the screen
  66.557 -        if (!target.isVisible() || isTargetUndecorated()) {
  66.558 -            int screenX = sB.x + sIn.left;
  66.559 -            int screenY = sB.y + sIn.top;
  66.560 -
  66.561 -            // First make sure the size is withing the visible part of the screen
  66.562 -            if (newW > screenW) {
  66.563 -                newW = screenW;
  66.564 -            }
  66.565 -
  66.566 -            if (newH > screenH) {
  66.567 -                newH = screenH;
  66.568 -            }
  66.569 -
  66.570 -            // Tweak the location if needed
  66.571 -            if (newX < screenX) {
  66.572 -                newX = screenX;
  66.573 -            } else if (newX + newW > screenX + screenW) {
  66.574 -                newX = screenX + screenW - newW;
  66.575 -            }
  66.576 -
  66.577 -            if (newY < screenY) {
  66.578 -                newY = screenY;
  66.579 -            } else if (newY + newH > screenY + screenH) {
  66.580 -                newY = screenY + screenH - newH;
  66.581 -            }
  66.582 -        } else {
  66.583 -            int maxW = Math.max(screenW, sysW);
  66.584 -            int maxH = Math.max(screenH, sysH);
  66.585 -
  66.586 -            // Make sure the size is withing the visible part of the screen
  66.587 -            // OR is less that the current size of the window.
  66.588 -            if (newW > maxW) {
  66.589 -                newW = maxW;
  66.590 -            }
  66.591 -
  66.592 -            if (newH > maxH) {
  66.593 -                newH = maxH;
  66.594 -            }
  66.595 -        }
  66.596 -
  66.597 -        return new Rectangle(newX, newY, newW, newH);
  66.598 -    }
  66.599 -
  66.600 -    public void setBounds(int x, int y, int width, int height, int op) {
  66.601 -        Rectangle newBounds = constrainBounds(x, y, width, height);
  66.602 -        super.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height, op);
  66.603 -    }
  66.604 -
  66.605 -}
    67.1 --- a/src/solaris/classes/sun/awt/motif/X11Clipboard.java	Wed Sep 17 13:45:37 2008 -0700
    67.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.3 @@ -1,151 +0,0 @@
    67.4 -/*
    67.5 - * Copyright 1996-2003 Sun Microsystems, Inc.  All Rights Reserved.
    67.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    67.7 - *
    67.8 - * This code is free software; you can redistribute it and/or modify it
    67.9 - * under the terms of the GNU General Public License version 2 only, as
   67.10 - * published by the Free Software Foundation.  Sun designates this
   67.11 - * particular file as subject to the "Classpath" exception as provided
   67.12 - * by Sun in the LICENSE file that accompanied this code.
   67.13 - *
   67.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   67.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   67.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   67.17 - * version 2 for more details (a copy is included in the LICENSE file that
   67.18 - * accompanied this code).
   67.19 - *
   67.20 - * You should have received a copy of the GNU General Public License version
   67.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   67.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   67.23 - *
   67.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   67.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   67.26 - * have any questions.
   67.27 - */
   67.28 -
   67.29 -package sun.awt.motif;
   67.30 -
   67.31 -import java.awt.datatransfer.ClipboardOwner;
   67.32 -import java.awt.datatransfer.Transferable;
   67.33 -
   67.34 -import java.io.IOException;
   67.35 -
   67.36 -import java.security.AccessController;
   67.37 -
   67.38 -import sun.awt.datatransfer.SunClipboard;
   67.39 -import sun.awt.datatransfer.TransferableProxy;
   67.40 -import sun.awt.datatransfer.DataTransferer;
   67.41 -
   67.42 -import sun.security.action.GetIntegerAction;
   67.43 -
   67.44 -
   67.45 -/**
   67.46 - * A class which interfaces with the X11 selection service in order to support
   67.47 - * data transfer via Clipboard operations. Most of the work is provided by
   67.48 - * sun.awt.datatransfer.DataTransferer.
   67.49 - *
   67.50 - * @author Amy Fowler
   67.51 - * @author Roger Brinkley
   67.52 - * @author Danila Sinopalnikov
   67.53 - * @author Alexander Gerasimov
   67.54 - *
   67.55 - * @since JDK1.1
   67.56 - */
   67.57 -public class X11Clipboard extends SunClipboard implements X11SelectionHolder {
   67.58 -
   67.59 -    private final X11Selection clipboardSelection;
   67.60 -
   67.61 -    private static final Object classLock = new Object();
   67.62 -
   67.63 -    private static final int defaultPollInterval = 200;
   67.64 -
   67.65 -    private static int pollInterval;
   67.66 -
   67.67 -    private static int listenedClipboardsCount;
   67.68 -
   67.69 -    /**
   67.70 -     * Creates a system clipboard object.
   67.71 -     */
   67.72 -    public X11Clipboard(String name, String selectionName) {
   67.73 -        super(name);
   67.74 -        clipboardSelection = new X11Selection(selectionName, this);
   67.75 -    }
   67.76 -
   67.77 -    protected void setContentsNative(Transferable contents) {
   67.78 -        if (!clipboardSelection.getSelectionOwnership(contents, this)) {
   67.79 -            // Need to figure out how to inform owner the request failed...
   67.80 -            this.owner = null;
   67.81 -            this.contents = null;
   67.82 -        }
   67.83 -    }
   67.84 -
   67.85 -    public long getID() {
   67.86 -        return clipboardSelection.atom;
   67.87 -    }
   67.88 -
   67.89 -    // NOTE: This method may be called by privileged threads.
   67.90 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   67.91 -    public void lostSelectionOwnership() {
   67.92 -        lostOwnershipImpl();
   67.93 -    }
   67.94 -
   67.95 -    protected void clearNativeContext() {
   67.96 -        clipboardSelection.clearNativeContext();
   67.97 -    }
   67.98 -
   67.99 -    protected long[] getClipboardFormats() {
  67.100 -        return getClipboardFormats(getID());
  67.101 -    }
  67.102 -    private static native long[] getClipboardFormats(long clipboardID);
  67.103 -
  67.104 -    protected byte[] getClipboardData(long format)
  67.105 -          throws IOException {
  67.106 -        return getClipboardData(getID(), format);
  67.107 -    }
  67.108 -    private static native byte[] getClipboardData(long clipboardID, long format)
  67.109 -            throws IOException;
  67.110 -
  67.111 -
  67.112 -    // Called on the toolkit thread under awtLock.
  67.113 -    public void checkChange(long[] formats) {
  67.114 -        if (!clipboardSelection.isOwner()) {
  67.115 -            super.checkChange(formats);
  67.116 -        }
  67.117 -    }
  67.118 -
  67.119 -    void checkChangeHere(Transferable contents) {
  67.120 -        if (areFlavorListenersRegistered()) {
  67.121 -            super.checkChange(DataTransferer.getInstance().
  67.122 -                        getFormatsForTransferableAsArray(contents, flavorMap));
  67.123 -        }
  67.124 -    }
  67.125 -
  67.126 -    protected void registerClipboardViewerChecked() {
  67.127 -        if (pollInterval <= 0) {
  67.128 -            pollInterval = ((Integer)AccessController.doPrivileged(
  67.129 -                    new GetIntegerAction("awt.datatransfer.clipboard.poll.interval",
  67.130 -                                         defaultPollInterval))).intValue();
  67.131 -            if (pollInterval <= 0) {
  67.132 -                pollInterval = defaultPollInterval;
  67.133 -            }
  67.134 -        }
  67.135 -        synchronized (X11Clipboard.classLock) {
  67.136 -            if (listenedClipboardsCount++ == 0) {
  67.137 -                registerClipboardViewer(pollInterval);
  67.138 -            }
  67.139 -        }
  67.140 -    }
  67.141 -
  67.142 -    private native void registerClipboardViewer(int pollInterval);
  67.143 -
  67.144 -    protected void unregisterClipboardViewerChecked() {
  67.145 -        synchronized (X11Clipboard.classLock) {
  67.146 -            if (--listenedClipboardsCount == 0) {
  67.147 -                unregisterClipboardViewer();
  67.148 -            }
  67.149 -        }
  67.150 -    }
  67.151 -
  67.152 -    private native void unregisterClipboardViewer();
  67.153 -
  67.154 -}
    68.1 --- a/src/solaris/classes/sun/awt/motif/X11DragSourceContextPeer.java	Wed Sep 17 13:45:37 2008 -0700
    68.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.3 @@ -1,131 +0,0 @@
    68.4 -/*
    68.5 - * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
    68.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    68.7 - *
    68.8 - * This code is free software; you can redistribute it and/or modify it
    68.9 - * under the terms of the GNU General Public License version 2 only, as
   68.10 - * published by the Free Software Foundation.  Sun designates this
   68.11 - * particular file as subject to the "Classpath" exception as provided
   68.12 - * by Sun in the LICENSE file that accompanied this code.
   68.13 - *
   68.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   68.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   68.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   68.17 - * version 2 for more details (a copy is included in the LICENSE file that
   68.18 - * accompanied this code).
   68.19 - *
   68.20 - * You should have received a copy of the GNU General Public License version
   68.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   68.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   68.23 - *
   68.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   68.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   68.26 - * have any questions.
   68.27 - */
   68.28 -
   68.29 -package sun.awt.motif;
   68.30 -
   68.31 -import java.awt.Component;
   68.32 -import java.awt.Cursor;
   68.33 -import java.awt.Window;
   68.34 -
   68.35 -import java.awt.datatransfer.Transferable;
   68.36 -
   68.37 -import java.awt.dnd.DragSourceContext;
   68.38 -import java.awt.dnd.DragSourceDragEvent;
   68.39 -import java.awt.dnd.DragSourceDropEvent;
   68.40 -import java.awt.dnd.DragSourceEvent;
   68.41 -import java.awt.dnd.DragGestureEvent;
   68.42 -import java.awt.dnd.InvalidDnDOperationException;
   68.43 -
   68.44 -import java.awt.event.InputEvent;
   68.45 -
   68.46 -import java.util.Map;
   68.47 -
   68.48 -import sun.awt.SunToolkit;
   68.49 -
   68.50 -import sun.awt.dnd.SunDragSourceContextPeer;
   68.51 -import sun.awt.dnd.SunDropTargetContextPeer;
   68.52 -
   68.53 -/**
   68.54 - * The X11DragSourceContextPeer class is the class responsible for handling
   68.55 - * the interaction between the XDnD/Motif DnD subsystem and Java drag sources.
   68.56 - *
   68.57 - * @since 1.5
   68.58 - */
   68.59 -final class X11DragSourceContextPeer extends SunDragSourceContextPeer {
   68.60 -
   68.61 -    private static final X11DragSourceContextPeer theInstance =
   68.62 -        new X11DragSourceContextPeer(null);
   68.63 -
   68.64 -    /**
   68.65 -     * construct a new X11DragSourceContextPeer
   68.66 -     */
   68.67 -
   68.68 -    private X11DragSourceContextPeer(DragGestureEvent dge) {
   68.69 -        super(dge);
   68.70 -    }
   68.71 -
   68.72 -    static X11DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
   68.73 -        theInstance.setTrigger(dge);
   68.74 -        return theInstance;
   68.75 -    }
   68.76 -
   68.77 -    protected void startDrag(Transferable transferable,
   68.78 -                             long[] formats, Map formatMap) {
   68.79 -        Component component = getTrigger().getComponent();
   68.80 -        Component c = null;
   68.81 -        MWindowPeer wpeer = null;
   68.82 -
   68.83 -        for (c = component; c != null && !(c instanceof java.awt.Window);
   68.84 -             c = MComponentPeer.getParent_NoClientCode(c));
   68.85 -
   68.86 -        if (c instanceof Window) {
   68.87 -            wpeer = (MWindowPeer)c.getPeer();
   68.88 -        }
   68.89 -
   68.90 -        if (wpeer == null) {
   68.91 -            throw new InvalidDnDOperationException(
   68.92 -                "Cannot find top-level for the drag source component");
   68.93 -        }
   68.94 -
   68.95 -        startDrag(component,
   68.96 -                  wpeer,
   68.97 -                  transferable,
   68.98 -                  getTrigger().getTriggerEvent(),
   68.99 -                  getCursor(),
  68.100 -                  getCursor() == null ? 0 : getCursor().getType(),
  68.101 -                  getDragSourceContext().getSourceActions(),
  68.102 -                  formats,
  68.103 -                  formatMap);
  68.104 -
  68.105 -        /* This implementation doesn't use native context */
  68.106 -        setNativeContext(0);
  68.107 -
  68.108 -        SunDropTargetContextPeer.setCurrentJVMLocalSourceTransferable(transferable);
  68.109 -    }
  68.110 -
  68.111 -    /**
  68.112 -     * downcall into native code
  68.113 -     */
  68.114 -
  68.115 -    private native long startDrag(Component component,
  68.116 -                                  MWindowPeer wpeer,
  68.117 -                                  Transferable transferable,
  68.118 -                                  InputEvent nativeTrigger,
  68.119 -                                  Cursor c, int ctype, int actions,
  68.120 -                                  long[] formats, Map formatMap);
  68.121 -
  68.122 -    /**
  68.123 -     * set cursor
  68.124 -     */
  68.125 -
  68.126 -    public void setCursor(Cursor c) throws InvalidDnDOperationException {
  68.127 -        SunToolkit.awtLock();
  68.128 -        super.setCursor(c);
  68.129 -        SunToolkit.awtUnlock();
  68.130 -    }
  68.131 -
  68.132 -    protected native void setNativeCursor(long nativeCtxt, Cursor c, int cType);
  68.133 -
  68.134 -}
    69.1 --- a/src/solaris/classes/sun/awt/motif/X11DropTargetContextPeer.java	Wed Sep 17 13:45:37 2008 -0700
    69.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.3 @@ -1,167 +0,0 @@
    69.4 -/*
    69.5 - * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
    69.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    69.7 - *
    69.8 - * This code is free software; you can redistribute it and/or modify it
    69.9 - * under the terms of the GNU General Public License version 2 only, as
   69.10 - * published by the Free Software Foundation.  Sun designates this
   69.11 - * particular file as subject to the "Classpath" exception as provided
   69.12 - * by Sun in the LICENSE file that accompanied this code.
   69.13 - *
   69.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   69.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   69.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   69.17 - * version 2 for more details (a copy is included in the LICENSE file that
   69.18 - * accompanied this code).
   69.19 - *
   69.20 - * You should have received a copy of the GNU General Public License version
   69.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   69.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   69.23 - *
   69.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   69.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   69.26 - * have any questions.
   69.27 - */
   69.28 -
   69.29 -package sun.awt.motif;
   69.30 -
   69.31 -import java.awt.Component;
   69.32 -import java.awt.peer.ComponentPeer;
   69.33 -
   69.34 -import sun.awt.AppContext;
   69.35 -import sun.awt.SunToolkit;
   69.36 -
   69.37 -import sun.awt.dnd.SunDropTargetContextPeer;
   69.38 -import sun.awt.dnd.SunDropTargetEvent;
   69.39 -
   69.40 -/**
   69.41 - * The X11DropTargetContextPeer class is the class responsible for handling
   69.42 - * the interaction between the XDnD/Motif DnD subsystem and Java drop targets.
   69.43 - *
   69.44 - * @since 1.5
   69.45 - */
   69.46 -final class X11DropTargetContextPeer extends SunDropTargetContextPeer {
   69.47 -
   69.48 -    /*
   69.49 -     * A key to store a peer instance for an AppContext.
   69.50 -     */
   69.51 -    private static final Object DTCP_KEY = "DropTargetContextPeer";
   69.52 -
   69.53 -    private X11DropTargetContextPeer() {}
   69.54 -
   69.55 -    public static X11DropTargetContextPeer getPeer(AppContext appContext) {
   69.56 -        synchronized (_globalLock) {
   69.57 -            X11DropTargetContextPeer peer =
   69.58 -                (X11DropTargetContextPeer)appContext.get(DTCP_KEY);
   69.59 -            if (peer == null) {
   69.60 -                peer = new X11DropTargetContextPeer();
   69.61 -                appContext.put(DTCP_KEY, peer);
   69.62 -            }
   69.63 -
   69.64 -            return peer;
   69.65 -        }
   69.66 -    }
   69.67 -
   69.68 -    /*
   69.69 -     * Note:
   69.70 -     * the method can be called on the toolkit thread while holding AWT_LOCK.
   69.71 -     */
   69.72 -    private static void postDropTargetEventToPeer(final Component component,
   69.73 -                                                  final int x, final int y,
   69.74 -                                                  final int dropAction,
   69.75 -                                                  final int actions,
   69.76 -                                                  final long[] formats,
   69.77 -                                                  final long nativeCtxt,
   69.78 -                                                  final int eventID) {
   69.79 -
   69.80 -        AppContext appContext = SunToolkit.targetToAppContext(component);
   69.81 -        X11DropTargetContextPeer peer = getPeer(appContext);
   69.82 -
   69.83 -        peer.postDropTargetEvent(component, x, y, dropAction, actions, formats,
   69.84 -                                 nativeCtxt, eventID,
   69.85 -                                 !SunDropTargetContextPeer.DISPATCH_SYNC);
   69.86 -    }
   69.87 -
   69.88 -    protected void eventProcessed(SunDropTargetEvent e, int returnValue,
   69.89 -                                  boolean dispatcherDone) {
   69.90 -        /* If the event was not consumed, send a response to the source. */
   69.91 -        long ctxt = getNativeDragContext();
   69.92 -        if (ctxt != 0) {
   69.93 -            sendResponse(e.getID(), returnValue, ctxt, dispatcherDone,
   69.94 -                         e.isConsumed());
   69.95 -        }
   69.96 -    }
   69.97 -
   69.98 -    protected void doDropDone(boolean success, int dropAction,
   69.99 -                              boolean isLocal) {
  69.100 -        dropDone(getNativeDragContext(), success, dropAction);
  69.101 -    }
  69.102 -
  69.103 -    protected Object getNativeData(long format) {
  69.104 -        return getData(getNativeDragContext(), format);
  69.105 -    }
  69.106 -
  69.107 -    protected void processEnterMessage(SunDropTargetEvent event) {
  69.108 -        if (!processSunDropTargetEvent(event)) {
  69.109 -            super.processEnterMessage(event);
  69.110 -        }
  69.111 -    }
  69.112 -
  69.113 -    protected void processExitMessage(SunDropTargetEvent event) {
  69.114 -        if (!processSunDropTargetEvent(event)) {
  69.115 -            super.processExitMessage(event);
  69.116 -        }
  69.117 -    }
  69.118 -
  69.119 -    protected void processMotionMessage(SunDropTargetEvent event,
  69.120 -                                        boolean operationChanged) {
  69.121 -        if (!processSunDropTargetEvent(event)) {
  69.122 -            super.processMotionMessage(event, operationChanged);
  69.123 -        }
  69.124 -    }
  69.125 -
  69.126 -    protected void processDropMessage(SunDropTargetEvent event) {
  69.127 -        if (!processSunDropTargetEvent(event)) {
  69.128 -            super.processDropMessage(event);
  69.129 -        }
  69.130 -    }
  69.131 -
  69.132 -    // If source is an XEmbedCanvasPeer, passes the event to it for processing and
  69.133 -    // return true if the event is forwarded to the XEmbed child.
  69.134 -    // Otherwise, does nothing and return false.
  69.135 -    private boolean processSunDropTargetEvent(SunDropTargetEvent event) {
  69.136 -        Object source = event.getSource();
  69.137 -
  69.138 -        if (source instanceof Component) {
  69.139 -            ComponentPeer peer = ((Component)source).getPeer();
  69.140 -            if (peer instanceof MEmbedCanvasPeer) {
  69.141 -                MEmbedCanvasPeer mEmbedCanvasPeer = (MEmbedCanvasPeer)peer;
  69.142 -                /* The native context is the pointer to the XClientMessageEvent
  69.143 -                   structure. */
  69.144 -                long ctxt = getNativeDragContext();
  69.145 -
  69.146 -                /* If the event is not consumed, pass it to the
  69.147 -                   MEmbedCanvasPeer for processing. */
  69.148 -                if (!event.isConsumed()) {
  69.149 -                    // NOTE: ctxt can be zero at this point.
  69.150 -                    if (mEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
  69.151 -                                                               event.getID())) {
  69.152 -                        event.consume();
  69.153 -                        return true;
  69.154 -                    }
  69.155 -                }
  69.156 -            }
  69.157 -        }
  69.158 -
  69.159 -        return false;
  69.160 -    }
  69.161 -
  69.162 -    private native void sendResponse(int eventID, int returnValue,
  69.163 -                                     long nativeCtxt, boolean dispatcherDone,
  69.164 -                                     boolean consumed);
  69.165 -
  69.166 -    private native void dropDone(long nativeCtxt, boolean success,
  69.167 -                                 int dropAction);
  69.168 -
  69.169 -    private native Object getData(long nativeCtxt, long format);
  69.170 -}
    70.1 --- a/src/solaris/classes/sun/awt/motif/X11Selection.java	Wed Sep 17 13:45:37 2008 -0700
    70.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.3 @@ -1,203 +0,0 @@
    70.4 -/*
    70.5 - * Copyright 1996-2005 Sun Microsystems, Inc.  All Rights Reserved.
    70.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    70.7 - *
    70.8 - * This code is free software; you can redistribute it and/or modify it
    70.9 - * under the terms of the GNU General Public License version 2 only, as
   70.10 - * published by the Free Software Foundation.  Sun designates this
   70.11 - * particular file as subject to the "Classpath" exception as provided
   70.12 - * by Sun in the LICENSE file that accompanied this code.
   70.13 - *
   70.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   70.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   70.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   70.17 - * version 2 for more details (a copy is included in the LICENSE file that
   70.18 - * accompanied this code).
   70.19 - *
   70.20 - * You should have received a copy of the GNU General Public License version
   70.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   70.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   70.23 - *
   70.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   70.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   70.26 - * have any questions.
   70.27 - */
   70.28 -
   70.29 -package sun.awt.motif;
   70.30 -
   70.31 -import java.awt.Toolkit;
   70.32 -
   70.33 -import java.awt.datatransfer.Transferable;
   70.34 -import java.awt.datatransfer.FlavorMap;
   70.35 -import java.awt.datatransfer.DataFlavor;
   70.36 -import java.awt.datatransfer.SystemFlavorMap;
   70.37 -
   70.38 -import java.util.Map;
   70.39 -import java.util.SortedMap;
   70.40 -import java.util.Vector;
   70.41 -
   70.42 -import sun.awt.AppContext;
   70.43 -import sun.awt.SunToolkit;
   70.44 -
   70.45 -import sun.awt.datatransfer.DataTransferer;
   70.46 -
   70.47 -/*
   70.48 - * Implements a general interface to the X11 selection mechanism.
   70.49 - *
   70.50 - * @author Amy Fowler
   70.51 - * @author Roger Brinkley
   70.52 - * @author Danila Sinopalnikov
   70.53 - * @author Alexander Gerasimov
   70.54 - *
   70.55 - * @since JDK1.1
   70.56 - */
   70.57 -public class X11Selection {
   70.58 -
   70.59 -    static FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap();
   70.60 -
   70.61 -    static Vector selections;
   70.62 -
   70.63 -    long atom;
   70.64 -
   70.65 -    private X11Clipboard clipboard;
   70.66 -    private X11SelectionHolder holder;
   70.67 -    private Transferable contents;
   70.68 -
   70.69 -    private boolean disposed = false;
   70.70 -    private byte[] data = null;
   70.71 -    private boolean dataAvailable = false;
   70.72 -    private static final Object source = new Object();
   70.73 -
   70.74 -    static {
   70.75 -        // 4154170:  Need to ensure the the toolkit is initialized prior
   70.76 -        // to executing this initializer
   70.77 -        Toolkit toolkit = Toolkit.getDefaultToolkit();
   70.78 -
   70.79 -        selections = new Vector();
   70.80 -
   70.81 -        initIDs();
   70.82 -        init();
   70.83 -
   70.84 -    }
   70.85 -
   70.86 -    private static native void initIDs();
   70.87 -    static native void init();
   70.88 -
   70.89 -    public X11Selection(String name, X11Clipboard clipboard) {
   70.90 -        atom = ((MDataTransferer)DataTransferer.getInstance()).getAtomForTarget(name);
   70.91 -        selections.addElement(this);
   70.92 -        this.clipboard = clipboard;
   70.93 -    }
   70.94 -
   70.95 -    private static Object[] getSelectionsArray() {
   70.96 -        return selections.toArray();
   70.97 -    }
   70.98 -
   70.99 -   /*
  70.100 -    * methods for acting as selection provider
  70.101 -    */
  70.102 -    native boolean pGetSelectionOwnership(Object source,
  70.103 -                                          Transferable transferable,
  70.104 -                                          long[] formats,
  70.105 -                                          Map formatMap,
  70.106 -                                          X11SelectionHolder holder);
  70.107 -
  70.108 -    boolean getSelectionOwnership(Transferable contents,
  70.109 -                                  X11SelectionHolder holder) {
  70.110 -        SortedMap formatMap =
  70.111 -            DataTransferer.getInstance().getFormatsForTransferable
  70.112 -                (contents, DataTransferer.adaptFlavorMap(flavorMap));
  70.113 -        long[] formats =
  70.114 -            DataTransferer.getInstance().keysToLongArray(formatMap);
  70.115 -        SunToolkit.insertTargetMapping(source, AppContext.getAppContext());
  70.116 -
  70.117 -        /*
  70.118 -         * Update 'contents' and 'holder' fields in the native code under
  70.119 -         * AWTLock protection to prevent race with lostSelectionOwnership().
  70.120 -         */
  70.121 -        SunToolkit.awtLock();
  70.122 -        try {
  70.123 -            boolean isOwnerSet = pGetSelectionOwnership(source, contents, formats, formatMap,
  70.124 -                                                        holder);
  70.125 -            if (isOwnerSet) {
  70.126 -                clipboard.checkChangeHere(contents);
  70.127 -            }
  70.128 -            return isOwnerSet;
  70.129 -        } finally {
  70.130 -            SunToolkit.awtUnlock();
  70.131 -        }
  70.132 -    }
  70.133 -
  70.134 -    // To be MT-safe this method should be called under awtLock.
  70.135 -    boolean isOwner() {
  70.136 -        return holder != null;
  70.137 -    }
  70.138 -
  70.139 -    // NOTE: This method may be called by privileged threads.
  70.140 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  70.141 -    private void lostSelectionOwnership() {
  70.142 -        if (holder != null) {
  70.143 -            holder.lostSelectionOwnership();
  70.144 -            holder = null;
  70.145 -        }
  70.146 -        contents = null;
  70.147 -    }
  70.148 -
  70.149 -    native void clearNativeContext();
  70.150 -
  70.151 -    /*
  70.152 -     * Subclasses should override disposeImpl() instead of dispose(). Client
  70.153 -     * code should always invoke dispose(), never disposeImpl().
  70.154 -     */
  70.155 -    protected void disposeImpl() {
  70.156 -        selections.removeElement(this);
  70.157 -    }
  70.158 -
  70.159 -    public final void dispose() {
  70.160 -        boolean call_disposeImpl = false;
  70.161 -
  70.162 -        if (!disposed) {
  70.163 -            synchronized (this) {
  70.164 -                if (!disposed) {
  70.165 -                    disposed = call_disposeImpl = true;
  70.166 -                }
  70.167 -            }
  70.168 -        }
  70.169 -
  70.170 -        if (call_disposeImpl) {
  70.171 -            disposeImpl();
  70.172 -        }
  70.173 -    }
  70.174 -
  70.175 -    /**
  70.176 -     * Finds out all selections that have flavor listeners registered
  70.177 -     * and returns their atoms.
  70.178 -     * Upcall from native code.
  70.179 -     *
  70.180 -     * @return an array of selection atoms
  70.181 -     */
  70.182 -    private static long[] getSelectionAtomsToCheckChange() {
  70.183 -        Object[] sels = getSelectionsArray();
  70.184 -        long[] idArray = new long[sels.length];
  70.185 -        int count = 0;
  70.186 -
  70.187 -        for (int i = 0; i < sels.length; i++) {
  70.188 -            X11Clipboard clipboard = ((X11Selection)sels[i]).clipboard;
  70.189 -            if (clipboard.areFlavorListenersRegistered()) {
  70.190 -                idArray[count++] = clipboard.getID();
  70.191 -            }
  70.192 -        }
  70.193 -
  70.194 -        long[] atomArray = new long[count];
  70.195 -        System.arraycopy(idArray, 0, atomArray, 0, atomArray.length);
  70.196 -
  70.197 -        return atomArray;
  70.198 -    }
  70.199 -
  70.200 -    /**
  70.201 -     * Upcall from native code.
  70.202 -     */
  70.203 -    private void checkChange(long[] formats) {
  70.204 -        clipboard.checkChange(formats);
  70.205 -    }
  70.206 -}
    71.1 --- a/src/solaris/classes/sun/awt/motif/X11SelectionHolder.java	Wed Sep 17 13:45:37 2008 -0700
    71.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.3 @@ -1,33 +0,0 @@
    71.4 -/*
    71.5 - * Copyright 1996-1998 Sun Microsystems, Inc.  All Rights Reserved.
    71.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    71.7 - *
    71.8 - * This code is free software; you can redistribute it and/or modify it
    71.9 - * under the terms of the GNU General Public License version 2 only, as
   71.10 - * published by the Free Software Foundation.  Sun designates this
   71.11 - * particular file as subject to the "Classpath" exception as provided
   71.12 - * by Sun in the LICENSE file that accompanied this code.
   71.13 - *
   71.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   71.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   71.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   71.17 - * version 2 for more details (a copy is included in the LICENSE file that
   71.18 - * accompanied this code).
   71.19 - *
   71.20 - * You should have received a copy of the GNU General Public License version
   71.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   71.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   71.23 - *
   71.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   71.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   71.26 - * have any questions.
   71.27 - */
   71.28 -
   71.29 -package sun.awt.motif;
   71.30 -
   71.31 -interface X11SelectionHolder {
   71.32 -
   71.33 -    // NOTE: This method may be called by privileged threads.
   71.34 -    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   71.35 -    public void lostSelectionOwnership();
   71.36 -}
    72.1 --- a/src/solaris/native/sun/awt/awt_Button.c	Wed Sep 17 13:45:37 2008 -0700
    72.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.3 @@ -1,276 +0,0 @@
    72.4 -/*
    72.5 - * Copyright 1995-2001 Sun Microsystems, Inc.  All Rights Reserved.
    72.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    72.7 - *
    72.8 - * This code is free software; you can redistribute it and/or modify it
    72.9 - * under the terms of the GNU General Public License version 2 only, as
   72.10 - * published by the Free Software Foundation.  Sun designates this
   72.11 - * particular file as subject to the "Classpath" exception as provided
   72.12 - * by Sun in the LICENSE file that accompanied this code.
   72.13 - *
   72.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   72.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   72.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   72.17 - * version 2 for more details (a copy is included in the LICENSE file that
   72.18 - * accompanied this code).
   72.19 - *
   72.20 - * You should have received a copy of the GNU General Public License version
   72.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   72.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   72.23 - *
   72.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   72.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   72.26 - * have any questions.
   72.27 - */
   72.28 -
   72.29 -#ifdef HEADLESS
   72.30 -    #error This file should not be included in headless library
   72.31 -#endif
   72.32 -
   72.33 -#include "awt_p.h"
   72.34 -
   72.35 -#include <jni.h>
   72.36 -#include <jni_util.h>
   72.37 -#include "multi_font.h"
   72.38 -
   72.39 -#include "awt_Component.h"
   72.40 -
   72.41 -extern struct MComponentPeerIDs mComponentPeerIDs;
   72.42 -extern AwtGraphicsConfigDataPtr
   72.43 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   72.44 -
   72.45 -/*
   72.46 - * When the -jni switch is thrown, these headers can be deleted.
   72.47 - */
   72.48 -#include "java_awt_Button.h"
   72.49 -#include "sun_awt_motif_MButtonPeer.h"
   72.50 -#include "sun_awt_motif_MComponentPeer.h"
   72.51 -
   72.52 -/* fieldIDs for Button fields that may be accessed from C */
   72.53 -static struct ButtonIDs {
   72.54 -    jfieldID label;
   72.55 -} buttonIDs;
   72.56 -
   72.57 -static char emptyString[] = "";
   72.58 -
   72.59 -
   72.60 -/*
   72.61 - * Class:     java_awt_Button
   72.62 - * Method:    initIDs
   72.63 - * Signature: ()V
   72.64 - */
   72.65 -
   72.66 -/* This function gets called from the static initializer for Button.java
   72.67 -   to initialize the fieldIDs for fields that may be accessed from C */
   72.68 -
   72.69 -JNIEXPORT void JNICALL
   72.70 -Java_java_awt_Button_initIDs
   72.71 -  (JNIEnv *env, jclass cls)
   72.72 -{
   72.73 -    buttonIDs.label =
   72.74 -      (*env)->GetFieldID(env, cls, "label", "Ljava/lang/String;");
   72.75 -}
   72.76 -
   72.77 -/*
   72.78 - * client_data is MButtonPeer instance
   72.79 - */
   72.80 -static void
   72.81 -Button_callback (Widget w,
   72.82 -                 XtPointer client_data,
   72.83 -                 XmPushButtonCallbackStruct * call_data)
   72.84 -{
   72.85 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
   72.86 -    ConvertEventTimeAndModifiers converted;
   72.87 -
   72.88 -    awt_util_convertEventTimeAndModifiers(call_data->event, &converted);
   72.89 -
   72.90 -    JNU_CallMethodByName(env, NULL, (jobject)client_data, "action", "(JI)V",
   72.91 -                         converted.when, converted.modifiers);
   72.92 -    if ((*env)->ExceptionOccurred (env)) {
   72.93 -        (*env)->ExceptionDescribe (env);
   72.94 -        (*env)->ExceptionClear (env);
   72.95 -    }
   72.96 -}
   72.97 -
   72.98 -/*
   72.99 - * Class:     sun_awt_motif_MButtonPeer
  72.100 - * Method:    create
  72.101 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  72.102 - */
  72.103 -JNIEXPORT void JNICALL Java_sun_awt_motif_MButtonPeer_create
  72.104 -  (JNIEnv * env, jobject this, jobject parent)
  72.105 -{
  72.106 -    jobject target;
  72.107 -    jobject label;
  72.108 -    struct ComponentData *cdata;
  72.109 -    struct ComponentData *wdata;
  72.110 -    char *clabel;
  72.111 -    Pixel bg;
  72.112 -    XmString mfstr = NULL;
  72.113 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef (env, this);
  72.114 -    jobject font = awtJNI_GetFont (env, this);
  72.115 -    jboolean IsMultiFont = awtJNI_IsMultiFont (env, font);
  72.116 -    AwtGraphicsConfigDataPtr adata;
  72.117 -
  72.118 -    AWT_LOCK ();
  72.119 -
  72.120 -    if (JNU_IsNull (env, parent)) {
  72.121 -        JNU_ThrowNullPointerException (env, "NullPointerException");
  72.122 -        AWT_UNLOCK ();
  72.123 -
  72.124 -        return;
  72.125 -    }
  72.126 -    target = (*env)->GetObjectField (env, this, mComponentPeerIDs.target);
  72.127 -    wdata = (struct ComponentData *)
  72.128 -      JNU_GetLongFieldAsPtr(env, parent, mComponentPeerIDs.pData);
  72.129 -
  72.130 -    if (JNU_IsNull (env, target) || wdata == NULL) {
  72.131 -        JNU_ThrowNullPointerException (env, "NullPointerException");
  72.132 -        AWT_UNLOCK ();
  72.133 -
  72.134 -        return;
  72.135 -    }
  72.136 -    cdata = ZALLOC (ComponentData);
  72.137 -    if (cdata == NULL) {
  72.138 -        JNU_ThrowOutOfMemoryError (env, "OutOfMemoryError");
  72.139 -        AWT_UNLOCK ();
  72.140 -        return;
  72.141 -    }
  72.142 -    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.pData, cdata);
  72.143 -
  72.144 -    adata = copyGraphicsConfigToPeer(env, this);
  72.145 -
  72.146 -    XtVaGetValues (wdata->widget, XmNbackground, &bg, NULL);
  72.147 -
  72.148 -    label =
  72.149 -      (*env)->GetObjectField (env, target, buttonIDs.label);
  72.150 -
  72.151 -    if (IsMultiFont) {
  72.152 -        /*
  72.153 -         * We don't use makeCString() function here.
  72.154 -         * We create Motif multi-font compound string to display
  72.155 -         * unicode on the platform which is not spporting unicode.
  72.156 -         */
  72.157 -        if (JNU_IsNull (env, label) || ((*env)->GetStringLength (env, label) == 0)) {
  72.158 -            mfstr = XmStringCreateLocalized ("");
  72.159 -        } else {
  72.160 -            mfstr = awtJNI_MakeMultiFontString (env, label, font);
  72.161 -        }
  72.162 -
  72.163 -        cdata->widget = XtVaCreateManagedWidget
  72.164 -            ("", xmPushButtonWidgetClass,
  72.165 -             wdata->widget,
  72.166 -             XmNlabelString, mfstr,
  72.167 -             XmNrecomputeSize, False,
  72.168 -             XmNbackground, bg,
  72.169 -             XmNhighlightOnEnter, False,
  72.170 -             XmNshowAsDefault, 0,
  72.171 -             XmNdefaultButtonShadowThickness, 0,
  72.172 -             XmNmarginTop, 0,
  72.173 -             XmNmarginBottom, 0,
  72.174 -             XmNmarginLeft, 0,
  72.175 -             XmNmarginRight, 0,
  72.176 -             XmNuserData, (XtPointer) globalRef,
  72.177 -             XmNscreen, ScreenOfDisplay(awt_display,
  72.178 -                                        adata->awt_visInfo.screen),
  72.179 -             NULL);
  72.180 -        if (mfstr != NULL) {
  72.181 -            XmStringFree(mfstr);
  72.182 -            mfstr = NULL;
  72.183 -        }
  72.184 -
  72.185 -    } else {
  72.186 -        if (JNU_IsNull (env, label)) {
  72.187 -            clabel = emptyString;
  72.188 -        } else {
  72.189 -            clabel = (char *) JNU_GetStringPlatformChars (env, label, NULL);
  72.190 -            if (clabel == NULL) {        /* Exception? */
  72.191 -                AWT_UNLOCK ();
  72.192 -                return;
  72.193 -            }
  72.194 -        }
  72.195 -
  72.196 -        cdata->widget = XtVaCreateManagedWidget
  72.197 -            (clabel, xmPushButtonWidgetClass,
  72.198 -             wdata->widget,
  72.199 -             XmNrecomputeSize, False,
  72.200 -             XmNbackground, bg,
  72.201 -             XmNhighlightOnEnter, False,
  72.202 -             XmNshowAsDefault, 0,
  72.203 -             XmNdefaultButtonShadowThickness, 0,
  72.204 -             XmNmarginTop, 0,
  72.205 -             XmNmarginBottom, 0,
  72.206 -             XmNmarginLeft, 0,
  72.207 -             XmNmarginRight, 0,
  72.208 -             XmNuserData, (XtPointer) globalRef,
  72.209 -             XmNscreen, ScreenOfDisplay(awt_display,
  72.210 -                                        adata->awt_visInfo.screen),
  72.211 -             NULL);
  72.212 -
  72.213 -        if (clabel != emptyString) {
  72.214 -            JNU_ReleaseStringPlatformChars (env, label, (const char *) clabel);;
  72.215 -        }
  72.216 -    }
  72.217 -
  72.218 -    XtSetMappedWhenManaged (cdata->widget, False);
  72.219 -    XtAddCallback (cdata->widget,
  72.220 -                   XmNactivateCallback,
  72.221 -                   (XtCallbackProc) Button_callback,
  72.222 -                   (XtPointer) globalRef);
  72.223 -
  72.224 -    AWT_UNLOCK ();
  72.225 -}
  72.226 -
  72.227 -/*
  72.228 - * Class:     sun_awt_motif_MButtonPeer
  72.229 - * Method:    setLabel
  72.230 - * Signature: (Ljava/lang/String;)V
  72.231 - */
  72.232 -JNIEXPORT void JNICALL Java_sun_awt_motif_MButtonPeer_setLabel
  72.233 -  (JNIEnv * env, jobject this, jstring label)
  72.234 -{
  72.235 -    struct ComponentData *wdata;
  72.236 -    char *clabel;
  72.237 -    XmString xim;
  72.238 -
  72.239 -    AWT_LOCK ();
  72.240 -
  72.241 -    wdata = (struct ComponentData *)
  72.242 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  72.243 -
  72.244 -    if (wdata == NULL) {
  72.245 -        JNU_ThrowNullPointerException (env, "NullPointerException");
  72.246 -        AWT_UNLOCK ();
  72.247 -        return;
  72.248 -    }
  72.249 -    if (JNU_IsNull (env, label) || ((*env)->GetStringLength (env, label) == 0)) {
  72.250 -        xim = XmStringCreateLocalized ("");
  72.251 -    } else {
  72.252 -        jobject font = awtJNI_GetFont (env, this);
  72.253 -
  72.254 -        if (awtJNI_IsMultiFont (env, font)) {
  72.255 -            xim = awtJNI_MakeMultiFontString (env, label, font);
  72.256 -        } else {
  72.257 -            if (JNU_IsNull (env, label)) {
  72.258 -                clabel = emptyString;
  72.259 -            } else {
  72.260 -                clabel = (char *) JNU_GetStringPlatformChars (env, label, NULL);
  72.261 -
  72.262 -                if (clabel == NULL) {      /* Exception? */
  72.263 -                    AWT_UNLOCK ();
  72.264 -                    return;
  72.265 -                }
  72.266 -            }
  72.267 -
  72.268 -            xim = XmStringCreate (clabel, "labelFont");
  72.269 -
  72.270 -            if (clabel != emptyString) {
  72.271 -                JNU_ReleaseStringPlatformChars (env, label, (const char *) clabel);;
  72.272 -            }
  72.273 -        }
  72.274 -    }
  72.275 -
  72.276 -    XtVaSetValues (wdata->widget, XmNlabelString, xim, NULL);
  72.277 -    XmStringFree (xim);
  72.278 -    AWT_FLUSH_UNLOCK ();
  72.279 -}
    73.1 --- a/src/solaris/native/sun/awt/awt_Canvas.c	Wed Sep 17 13:45:37 2008 -0700
    73.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.3 @@ -1,130 +0,0 @@
    73.4 -/*
    73.5 - * Copyright 1995-2002 Sun Microsystems, Inc.  All Rights Reserved.
    73.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    73.7 - *
    73.8 - * This code is free software; you can redistribute it and/or modify it
    73.9 - * under the terms of the GNU General Public License version 2 only, as
   73.10 - * published by the Free Software Foundation.  Sun designates this
   73.11 - * particular file as subject to the "Classpath" exception as provided
   73.12 - * by Sun in the LICENSE file that accompanied this code.
   73.13 - *
   73.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   73.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   73.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   73.17 - * version 2 for more details (a copy is included in the LICENSE file that
   73.18 - * accompanied this code).
   73.19 - *
   73.20 - * You should have received a copy of the GNU General Public License version
   73.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   73.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   73.23 - *
   73.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   73.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   73.26 - * have any questions.
   73.27 - */
   73.28 -#ifdef HEADLESS
   73.29 -    #error This file should not be included in headless library
   73.30 -#endif
   73.31 -
   73.32 -#include "awt_p.h"
   73.33 -#include "java_awt_Canvas.h"
   73.34 -#include "sun_awt_motif_MCanvasPeer.h"
   73.35 -#include "sun_awt_motif_MComponentPeer.h"
   73.36 -#include "color.h"
   73.37 -#include "canvas.h"
   73.38 -#include "awt_util.h"
   73.39 -
   73.40 -#include "awt_Component.h"
   73.41 -#include "awt_GraphicsEnv.h"
   73.42 -
   73.43 -#include <jni.h>
   73.44 -#include <jni_util.h>
   73.45 -#include "multi_font.h"
   73.46 -
   73.47 -extern struct MComponentPeerIDs mComponentPeerIDs;
   73.48 -extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
   73.49 -extern AwtGraphicsConfigDataPtr
   73.50 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   73.51 -struct CanvasIDs mCanvasIDs;
   73.52 -
   73.53 -/*
   73.54 - * Class:     sun_awt_motif_MCanvasPeer
   73.55 - * Method:    create
   73.56 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
   73.57 - */
   73.58 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCanvasPeer_create
   73.59 -  (JNIEnv * env, jobject this, jobject parent)
   73.60 -{
   73.61 -    AwtGraphicsConfigDataPtr awtData;
   73.62 -
   73.63 -    struct CanvasData *wdata;
   73.64 -    struct CanvasData *cdata;
   73.65 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
   73.66 -
   73.67 -    AWT_LOCK();
   73.68 -    if (JNU_IsNull(env, parent)) {
   73.69 -        JNU_ThrowNullPointerException(env, "NullPointerException");
   73.70 -        AWT_UNLOCK();
   73.71 -        return;
   73.72 -    }
   73.73 -
   73.74 -    cdata = (struct CanvasData *)
   73.75 -        JNU_GetLongFieldAsPtr(env, parent, mComponentPeerIDs.pData);
   73.76 -    if (cdata == NULL) {
   73.77 -        JNU_ThrowNullPointerException(env, "NullPointerException");
   73.78 -        AWT_UNLOCK();
   73.79 -        return;
   73.80 -    }
   73.81 -
   73.82 -    wdata = ZALLOC(CanvasData);
   73.83 -    if (wdata == NULL) {
   73.84 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
   73.85 -        AWT_UNLOCK();
   73.86 -        return;
   73.87 -    }
   73.88 -    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.pData, wdata);
   73.89 -
   73.90 -    awtData = copyGraphicsConfigToPeer(env, this);
   73.91 -
   73.92 -    wdata->comp.widget = awt_canvas_create((XtPointer) globalRef,
   73.93 -                                           cdata->comp.widget,
   73.94 -                                           "",
   73.95 -                                           1, 1, False, NULL, awtData);
   73.96 -    XtVaSetValues(wdata->comp.widget,
   73.97 -                  XmNinsertPosition, awt_util_insertCallback,
   73.98 -                  NULL);
   73.99 -
  73.100 -    /* Add an event handler so that we can track focus change requests
  73.101 -       which will be initiated by Motif in response to ButtonPress events */
  73.102 -
  73.103 -    wdata->flags = 0;
  73.104 -    wdata->shell = cdata->shell;
  73.105 -
  73.106 -    AWT_UNLOCK();
  73.107 -}
  73.108 -
  73.109 -/*
  73.110 - * Class:     sun_awt_motif_MCanvasPeer
  73.111 - * Method:    resetTargetGC
  73.112 - * Signature: ()V
  73.113 - */
  73.114 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCanvasPeer_resetTargetGC
  73.115 -(JNIEnv * env, jobject this, jobject target)
  73.116 -{
  73.117 -    (*env)->CallVoidMethod(env, target, mCanvasIDs.setGCFromPeerMID);
  73.118 -}
  73.119 -
  73.120 -/*
  73.121 - * Class:     sun_awt_motif_MCanvasPeer
  73.122 - * Method:    initIDs
  73.123 - * Signature: ()V
  73.124 - */
  73.125 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCanvasPeer_initIDs
  73.126 -(JNIEnv * env, jclass cls)
  73.127 -{
  73.128 -    jclass canvasCls = (*env)->FindClass(env, "java/awt/Canvas");
  73.129 -    mCanvasIDs.setGCFromPeerMID =
  73.130 -     (*env)->GetMethodID(env, canvasCls, "setGCFromPeer","()V");
  73.131 -
  73.132 -    DASSERT(mCanvasIDs.setGCFromPeerMID);
  73.133 -}
    74.1 --- a/src/solaris/native/sun/awt/awt_Checkbox.c	Wed Sep 17 13:45:37 2008 -0700
    74.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    74.3 @@ -1,428 +0,0 @@
    74.4 -/*
    74.5 - * Copyright 1995-2002 Sun Microsystems, Inc.  All Rights Reserved.
    74.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    74.7 - *
    74.8 - * This code is free software; you can redistribute it and/or modify it
    74.9 - * under the terms of the GNU General Public License version 2 only, as
   74.10 - * published by the Free Software Foundation.  Sun designates this
   74.11 - * particular file as subject to the "Classpath" exception as provided
   74.12 - * by Sun in the LICENSE file that accompanied this code.
   74.13 - *
   74.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   74.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   74.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   74.17 - * version 2 for more details (a copy is included in the LICENSE file that
   74.18 - * accompanied this code).
   74.19 - *
   74.20 - * You should have received a copy of the GNU General Public License version
   74.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   74.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   74.23 - *
   74.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   74.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   74.26 - * have any questions.
   74.27 - */
   74.28 -
   74.29 -#ifdef HEADLESS
   74.30 -    #error This file should not be included in headless library
   74.31 -#endif
   74.32 -
   74.33 -#include "awt_p.h"
   74.34 -#include "sun_awt_motif_MComponentPeer.h"
   74.35 -#include "sun_awt_motif_MCheckboxPeer.h"
   74.36 -#include "java_awt_Checkbox.h"
   74.37 -#include "java_awt_CheckboxGroup.h"
   74.38 -
   74.39 -#include "awt_Component.h"
   74.40 -
   74.41 -#include "multi_font.h"
   74.42 -#include <jni.h>
   74.43 -#include <jni_util.h>
   74.44 -
   74.45 -extern struct MComponentPeerIDs mComponentPeerIDs;
   74.46 -extern AwtGraphicsConfigDataPtr
   74.47 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   74.48 -
   74.49 -/* fieldIDs for Checkbox fields that may be accessed from C */
   74.50 -static struct CheckboxIDs {
   74.51 -    jfieldID label;
   74.52 -} checkboxIDs;
   74.53 -
   74.54 -static char emptyString[] = "";
   74.55 -
   74.56 -
   74.57 -/*
   74.58 - * Class:     java_awt_Checkbox
   74.59 - * Method:    initIDs
   74.60 - * Signature: ()V
   74.61 - */
   74.62 -
   74.63 -/* This function gets called from the static initializer for Checkbox.java
   74.64 -   to initialize the fieldIDs for fields that may be accessed from C */
   74.65 -
   74.66 -JNIEXPORT void JNICALL
   74.67 -Java_java_awt_Checkbox_initIDs
   74.68 -  (JNIEnv *env, jclass cls)
   74.69 -{
   74.70 -    checkboxIDs.label =
   74.71 -      (*env)->GetFieldID(env, cls, "label", "Ljava/lang/String;");
   74.72 -}
   74.73 -
   74.74 -/*
   74.75 - * client_data is MCheckboxPeer instance pointer
   74.76 - */
   74.77 -static void
   74.78 -Toggle_callback(Widget w,
   74.79 -                XtPointer client_data,
   74.80 -                XmAnyCallbackStruct * call_data)
   74.81 -{
   74.82 -    Boolean state;
   74.83 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
   74.84 -
   74.85 -    XtVaGetValues(w, XmNset, &state, NULL);
   74.86 -
   74.87 -    JNU_CallMethodByName(env, NULL, (jobject) client_data, "action", "(Z)V", state);
   74.88 -    if ((*env)->ExceptionOccurred(env)) {
   74.89 -        (*env)->ExceptionDescribe(env);
   74.90 -        (*env)->ExceptionClear(env);
   74.91 -    }
   74.92 -}
   74.93 -
   74.94 -/*
   74.95 - * Class:     sun_awt_motif_MCheckboxPeer
   74.96 - * Method:    create
   74.97 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
   74.98 - */
   74.99 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCheckboxPeer_create
  74.100 -  (JNIEnv * env, jobject this, jobject parent)
  74.101 -{
  74.102 -    jobject target;
  74.103 -    struct ComponentData *bdata;
  74.104 -    struct ComponentData *wdata;
  74.105 -    char *clabel;
  74.106 -#define MAX_ARGC 10
  74.107 -    Arg args[MAX_ARGC];
  74.108 -    Cardinal argc;
  74.109 -    jobject label;
  74.110 -    XmString mfstr = NULL;
  74.111 -    jobject font = awtJNI_GetFont(env, this);
  74.112 -    jboolean isMultiFont = awtJNI_IsMultiFont(env, font);
  74.113 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
  74.114 -    AwtGraphicsConfigDataPtr adata;
  74.115 -    XmFontList fontlist = NULL;
  74.116 -    Dimension height;
  74.117 -    Boolean labelIsEmpty = FALSE;
  74.118 -
  74.119 -    AWT_LOCK();
  74.120 -
  74.121 -    if (JNU_IsNull(env, parent)) {
  74.122 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  74.123 -        AWT_UNLOCK();
  74.124 -
  74.125 -        return;
  74.126 -    }
  74.127 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  74.128 -    wdata = (struct ComponentData *)
  74.129 -      JNU_GetLongFieldAsPtr(env, parent, mComponentPeerIDs.pData);
  74.130 -
  74.131 -    if (JNU_IsNull(env, target) || wdata == NULL) {
  74.132 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  74.133 -        AWT_UNLOCK();
  74.134 -
  74.135 -        return;
  74.136 -    }
  74.137 -    bdata = ZALLOC(ComponentData);
  74.138 -    if (bdata == NULL) {
  74.139 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  74.140 -        AWT_UNLOCK();
  74.141 -
  74.142 -        return;
  74.143 -    }
  74.144 -    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.pData, bdata);
  74.145 -
  74.146 -    adata = copyGraphicsConfigToPeer(env, this);
  74.147 -
  74.148 -    argc = 0;
  74.149 -    XtSetArg(args[argc], XmNrecomputeSize, False);
  74.150 -    argc++;
  74.151 -    XtSetArg(args[argc], XmNvisibleWhenOff, True);
  74.152 -    argc++;
  74.153 -    XtSetArg(args[argc], XmNtraversalOn, True);
  74.154 -    argc++;
  74.155 -    XtSetArg(args[argc], XmNspacing, 0);
  74.156 -    argc++;
  74.157 -    XtSetArg(args[argc], XmNuserData, (XtPointer) globalRef);
  74.158 -    argc++;
  74.159 -    XtSetArg (args[argc], XmNscreen,
  74.160 -              ScreenOfDisplay(awt_display,
  74.161 -                              adata->awt_visInfo.screen));
  74.162 -    argc++;
  74.163 -
  74.164 -    label = (*env)->GetObjectField(env, target, checkboxIDs.label);
  74.165 -
  74.166 -    // fix for 4383735.
  74.167 -    // If the label is empty we need to set the indicator size
  74.168 -    // proportional to the size of the font.
  74.169 -    // kdm@sparc.spb.su
  74.170 -    if (JNU_IsNull(env, label) || ((*env)->GetStringLength(env, label) == 0)) {
  74.171 -        labelIsEmpty = TRUE;
  74.172 -        if (!JNU_IsNull(env, font)) {
  74.173 -            mfstr = XmStringCreateLocalized(" ");
  74.174 -            if (mfstr != NULL) {
  74.175 -                fontlist = awtJNI_GetFontList(env, font);
  74.176 -                if (fontlist != NULL) {
  74.177 -                    height = XmStringHeight(fontlist, mfstr);
  74.178 -                    XtSetArg(args[argc], XmNindicatorSize, height);
  74.179 -                    argc++;
  74.180 -                    XmFontListFree(fontlist);
  74.181 -                    fontlist = NULL;
  74.182 -                }
  74.183 -                XmStringFree(mfstr);
  74.184 -                mfstr = NULL;
  74.185 -            }
  74.186 -        }
  74.187 -    }
  74.188 -
  74.189 -    if (isMultiFont) {
  74.190 -        /*
  74.191 -         * We don't use makeCString() function here.
  74.192 -         * We create Motif multi-font compound string to display
  74.193 -         * unicode on the platform which is not spporting unicode.
  74.194 -         */
  74.195 -        if (labelIsEmpty) {
  74.196 -            mfstr = XmStringCreateLocalized("");
  74.197 -        } else {
  74.198 -            mfstr = awtJNI_MakeMultiFontString(env, label, font);
  74.199 -        }
  74.200 -
  74.201 -        XtSetArg(args[argc], XmNlabelString, mfstr);
  74.202 -        argc++;
  74.203 -
  74.204 -        DASSERT(!(argc > MAX_ARGC));
  74.205 -        bdata->widget = XmCreateToggleButton(wdata->widget, "", args, argc);
  74.206 -
  74.207 -        if (mfstr != NULL) {
  74.208 -            XmStringFree(mfstr);
  74.209 -            mfstr = NULL;
  74.210 -        }
  74.211 -    } else {
  74.212 -        if (labelIsEmpty) {
  74.213 -            clabel = emptyString;
  74.214 -        } else {
  74.215 -            clabel = (char *) JNU_GetStringPlatformChars(env, label, NULL);
  74.216 -
  74.217 -            if (clabel == NULL) {        /* Exception? */
  74.218 -                AWT_UNLOCK();
  74.219 -                return;
  74.220 -            }
  74.221 -        }
  74.222 -
  74.223 -        DASSERT(!(argc > MAX_ARGC));
  74.224 -        bdata->widget = XmCreateToggleButton(wdata->widget, clabel, args, argc);
  74.225 -
  74.226 -        if (clabel != emptyString) {
  74.227 -            JNU_ReleaseStringPlatformChars(env, label, (const char *) clabel);;
  74.228 -        }
  74.229 -    }
  74.230 -
  74.231 -    XtAddCallback(bdata->widget,
  74.232 -                  XmNvalueChangedCallback,
  74.233 -                  (XtCallbackProc) Toggle_callback,
  74.234 -                  (XtPointer) globalRef);
  74.235 -
  74.236 -    XtSetMappedWhenManaged(bdata->widget, False);
  74.237 -    XtManageChild(bdata->widget);
  74.238 -
  74.239 -    AWT_UNLOCK();
  74.240 -}
  74.241 -
  74.242 -/*
  74.243 - * Class:     sun_awt_motif_MCheckboxPeer
  74.244 - * Method:    setLabel
  74.245 - * Signature: (Ljava/lang/String;)V
  74.246 - */
  74.247 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCheckboxPeer_setLabel
  74.248 -  (JNIEnv * env, jobject this, jstring label)
  74.249 -{
  74.250 -    struct ComponentData *wdata;
  74.251 -    char *clabel;
  74.252 -    XmString xim;
  74.253 -    jobject font;
  74.254 -
  74.255 -    AWT_LOCK();
  74.256 -
  74.257 -    wdata = (struct ComponentData *)
  74.258 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  74.259 -    if (wdata == NULL) {
  74.260 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  74.261 -        AWT_UNLOCK();
  74.262 -        return;
  74.263 -    }
  74.264 -    if (JNU_IsNull(env, label) || ((*env)->GetStringLength(env, label) == 0)) {
  74.265 -        xim = XmStringCreateLocalized("");
  74.266 -    } else {
  74.267 -        font = awtJNI_GetFont(env, this);
  74.268 -
  74.269 -        if (awtJNI_IsMultiFont(env, font)) {
  74.270 -            xim = awtJNI_MakeMultiFontString(env, label, font);
  74.271 -        } else {
  74.272 -            clabel = (char *) JNU_GetStringPlatformChars(env, label, NULL);
  74.273 -
  74.274 -            if (clabel == NULL) {
  74.275 -                AWT_UNLOCK();
  74.276 -                return;
  74.277 -            }
  74.278 -            xim = XmStringCreate(clabel, "labelFont");
  74.279 -
  74.280 -            JNU_ReleaseStringPlatformChars(env, label, (const char *) clabel);;
  74.281 -        }
  74.282 -    }
  74.283 -
  74.284 -    XtVaSetValues(wdata->widget, XmNlabelString, xim, NULL);
  74.285 -    XmStringFree(xim);
  74.286 -    AWT_FLUSH_UNLOCK();
  74.287 -}
  74.288 -
  74.289 -/*
  74.290 - * Class:     sun_awt_motif_MCheckboxPeer
  74.291 - * Method:    pSetState
  74.292 - * Signature: (Z)V
  74.293 - */
  74.294 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCheckboxPeer_pSetState
  74.295 -  (JNIEnv * env, jobject this, jboolean state)
  74.296 -{
  74.297 -    struct ComponentData *bdata;
  74.298 -
  74.299 -    AWT_LOCK();
  74.300 -
  74.301 -    bdata = (struct ComponentData *)
  74.302 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  74.303 -
  74.304 -    if (bdata == NULL || bdata->widget == NULL) {
  74.305 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  74.306 -        AWT_UNLOCK();
  74.307 -        return;
  74.308 -    }
  74.309 -    XtVaSetValues(bdata->widget, XmNset, (Boolean) state, NULL);
  74.310 -    AWT_FLUSH_UNLOCK();
  74.311 -}
  74.312 -
  74.313 -/*
  74.314 - * Class:     sun_awt_motif_MCheckboxPeer
  74.315 - * Method:    pGetState
  74.316 - * Signature: ()Z
  74.317 - */
  74.318 -JNIEXPORT jboolean JNICALL Java_sun_awt_motif_MCheckboxPeer_pGetState
  74.319 -  (JNIEnv * env, jobject this)
  74.320 -{
  74.321 -    struct ComponentData *bdata;
  74.322 -    Boolean               state;
  74.323 -
  74.324 -    AWT_LOCK();
  74.325 -
  74.326 -    bdata = (struct ComponentData *)
  74.327 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  74.328 -
  74.329 -    if (bdata == NULL || bdata->widget == NULL) {
  74.330 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  74.331 -        AWT_UNLOCK();
  74.332 -        return JNI_FALSE;
  74.333 -    }
  74.334 -    XtVaGetValues(bdata->widget, XmNset, &state, NULL);
  74.335 -    AWT_FLUSH_UNLOCK();
  74.336 -    return ((state) ? JNI_TRUE : JNI_FALSE);
  74.337 -}
  74.338 -
  74.339 -
  74.340 -/*
  74.341 - * Class:     sun_awt_motif_MCheckboxPeer
  74.342 - * Method:    setCheckboxGroup
  74.343 - * Signature: (Ljava/awt/CheckboxGroup;)V
  74.344 - */
  74.345 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCheckboxPeer_setCheckboxGroup
  74.346 -  (JNIEnv * env, jobject this, jobject group)
  74.347 -{
  74.348 -    struct ComponentData *bdata;
  74.349 -
  74.350 -    AWT_LOCK();
  74.351 -
  74.352 -    bdata = (struct ComponentData *)
  74.353 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  74.354 -
  74.355 -    if (bdata == NULL || bdata->widget == NULL) {
  74.356 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  74.357 -        AWT_UNLOCK();
  74.358 -        return;
  74.359 -    }
  74.360 -    if (JNU_IsNull(env, group)) {
  74.361 -        XtVaSetValues(bdata->widget,
  74.362 -                      XmNindicatorType, XmN_OF_MANY,
  74.363 -                      NULL);
  74.364 -    } else {
  74.365 -        XtVaSetValues(bdata->widget,
  74.366 -                      XmNindicatorType, XmONE_OF_MANY,
  74.367 -                      NULL);
  74.368 -    }
  74.369 -
  74.370 -    AWT_FLUSH_UNLOCK();
  74.371 -}
  74.372 -
  74.373 -/*
  74.374 - * Class:     sun_awt_motif_MCheckboxPeer
  74.375 - * Method:    getIndicatorSize
  74.376 - * Signature: (V)I
  74.377 - */
  74.378 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MCheckboxPeer_getIndicatorSize
  74.379 -  (JNIEnv * env, jobject this)
  74.380 -{
  74.381 -    struct ComponentData *wdata;
  74.382 -    Dimension size;
  74.383 -
  74.384 -    AWT_LOCK();
  74.385 -
  74.386 -    wdata = (struct ComponentData *)
  74.387 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  74.388 -
  74.389 -    if (wdata == NULL || wdata->widget == NULL) {
  74.390 -        JNU_ThrowNullPointerException(env, "Null pData");
  74.391 -        AWT_UNLOCK();
  74.392 -        return 0;
  74.393 -    }
  74.394 -    XtVaGetValues(wdata->widget,
  74.395 -                  XmNindicatorSize, &size,
  74.396 -                  NULL);
  74.397 -
  74.398 -    AWT_FLUSH_UNLOCK();
  74.399 -
  74.400 -    return size;
  74.401 -}
  74.402 -
  74.403 -/*
  74.404 - * Class:     sun_awt_motif_MCheckboxPeer
  74.405 - * Method:    getSpacing
  74.406 - * Signature: (V)I
  74.407 - */
  74.408 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MCheckboxPeer_getSpacing
  74.409 -  (JNIEnv * env, jobject this)
  74.410 -{
  74.411 -    struct ComponentData *wdata;
  74.412 -    Dimension dim;
  74.413 -
  74.414 -    AWT_LOCK();
  74.415 -
  74.416 -    wdata = (struct ComponentData *)
  74.417 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  74.418 -
  74.419 -    if (wdata == NULL || wdata->widget == NULL) {
  74.420 -        JNU_ThrowNullPointerException(env, "Null pData");
  74.421 -        AWT_UNLOCK();
  74.422 -        return 0;
  74.423 -    }
  74.424 -    XtVaGetValues(wdata->widget,
  74.425 -                  XmNspacing, &dim,
  74.426 -                  NULL);
  74.427 -
  74.428 -    AWT_FLUSH_UNLOCK();
  74.429 -
  74.430 -    return dim;
  74.431 -}
    75.1 --- a/src/solaris/native/sun/awt/awt_Choice12.c	Wed Sep 17 13:45:37 2008 -0700
    75.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.3 @@ -1,843 +0,0 @@
    75.4 -/*
    75.5 - * Copyright 1995-2001 Sun Microsystems, Inc.  All Rights Reserved.
    75.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    75.7 - *
    75.8 - * This code is free software; you can redistribute it and/or modify it
    75.9 - * under the terms of the GNU General Public License version 2 only, as
   75.10 - * published by the Free Software Foundation.  Sun designates this
   75.11 - * particular file as subject to the "Classpath" exception as provided
   75.12 - * by Sun in the LICENSE file that accompanied this code.
   75.13 - *
   75.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   75.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   75.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   75.17 - * version 2 for more details (a copy is included in the LICENSE file that
   75.18 - * accompanied this code).
   75.19 - *
   75.20 - * You should have received a copy of the GNU General Public License version
   75.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   75.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   75.23 - *
   75.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   75.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   75.26 - * have any questions.
   75.27 - */
   75.28 -
   75.29 -#ifdef HEADLESS
   75.30 -    #error This file should not be included in headless library
   75.31 -#endif
   75.32 -
   75.33 -#include "awt_p.h"
   75.34 -#include "java_awt_Component.h"
   75.35 -#include "sun_awt_motif_MComponentPeer.h"
   75.36 -#include "sun_awt_motif_MChoicePeer.h"
   75.37 -
   75.38 -#include "awt_Component.h"
   75.39 -#include "awt_MToolkit.h"
   75.40 -
   75.41 -#include "multi_font.h"
   75.42 -#include <jni.h>
   75.43 -#include <jni_util.h>
   75.44 -#include <Xm/CascadeBG.h>
   75.45 -
   75.46 -extern struct ComponentIDs componentIDs;
   75.47 -extern struct ContainerIDs containerIDs;
   75.48 -extern struct MComponentPeerIDs mComponentPeerIDs;
   75.49 -extern AwtGraphicsConfigDataPtr
   75.50 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   75.51 -
   75.52 -static void geometry_hook(Widget wid, Widget hooked_widget, XtGeometryHookData call_data) {
   75.53 -    XtWidgetGeometry *request;
   75.54 -    JNIEnv *env;
   75.55 -    struct ChoiceData *cdata;
   75.56 -    struct WidgetInfo *winfo = NULL;
   75.57 -
   75.58 -    jobject target;
   75.59 -    jobject parent;
   75.60 -    jint y, height;
   75.61 -
   75.62 -    if ((call_data->widget == hooked_widget) &&
   75.63 -        (call_data->type == XtHpostGeometry) &&
   75.64 -        (call_data->result == XtGeometryYes)) {
   75.65 -
   75.66 -        request = call_data->request;
   75.67 -
   75.68 -        env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
   75.69 -        DASSERT(env != NULL);
   75.70 -
   75.71 -        winfo=findWidgetInfo(hooked_widget);
   75.72 -
   75.73 -        if (winfo != NULL && XmIsRowColumn(hooked_widget)) {
   75.74 -            target = (*env)->GetObjectField(env, (jobject)winfo->peer, mComponentPeerIDs.target);
   75.75 -            cdata = (struct ChoiceData *) JNU_GetLongFieldAsPtr(env, (jobject)winfo->peer, mComponentPeerIDs.pData);
   75.76 -            DASSERT(target != NULL);
   75.77 -            DASSERT(cdata != NULL && cdata->comp.widget != NULL)
   75.78 -            if (request->request_mode & CWHeight) {
   75.79 -                height = (*env)->GetIntField(env, target, componentIDs.height);
   75.80 -                if (request->height > 0 && request->height != height) {
   75.81 -                  parent = (*env)->CallObjectMethod(env, target, componentIDs.getParent);
   75.82 -                  if ((parent != NULL) && ((*env)->GetObjectField(env, parent, containerIDs.layoutMgr) != NULL)) {
   75.83 -                      y = cdata->bounds_y;
   75.84 -                      if (request->height < cdata->bounds_height) {
   75.85 -                          y += (cdata->bounds_height - request->height) / 2;
   75.86 -                      }
   75.87 -                      XtVaSetValues(hooked_widget, XmNy, y, NULL);
   75.88 -                      (*env)->SetIntField(env, target, componentIDs.y, y);
   75.89 -                  }
   75.90 -                  if (parent != NULL) {
   75.91 -                      (*env)->DeleteLocalRef(env, parent);
   75.92 -                  }
   75.93 -                }
   75.94 -                (*env)->SetIntField(env, target, componentIDs.height, request->height);
   75.95 -            }
   75.96 -            if (request->request_mode & CWWidth) {
   75.97 -                (*env)->SetIntField(env, target, componentIDs.width, request->width);
   75.98 -            }
   75.99 -            (*env)->DeleteLocalRef(env, target);
  75.100 -        }
  75.101 -    }
  75.102 -}
  75.103 -
  75.104 -static void
  75.105 -Choice_callback(Widget menu_item,
  75.106 -                jobject this,
  75.107 -                XmAnyCallbackStruct * cbs)
  75.108 -{
  75.109 -    intptr_t index;
  75.110 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  75.111 -
  75.112 -    XtVaGetValues(menu_item, XmNuserData, &index, NULL);
  75.113 -    /* index stored in user-data is 1-based instead of 0-based because */
  75.114 -    /* of a bug in XmNuserData */
  75.115 -    index--;
  75.116 -
  75.117 -    JNU_CallMethodByName(env, NULL, this, "action", "(I)V", (jint)index);
  75.118 -    if ((*env)->ExceptionOccurred(env)) {
  75.119 -        (*env)->ExceptionDescribe(env);
  75.120 -        (*env)->ExceptionClear(env);
  75.121 -    }
  75.122 -}
  75.123 -
  75.124 -static void  addItems
  75.125 -  (JNIEnv *env, jobject this, jstring *items, jsize nItems, jint index)
  75.126 -{
  75.127 -    char *citem = NULL;
  75.128 -    struct ChoiceData *odata;
  75.129 -    Widget bw;
  75.130 -#define MAX_ARGC 10
  75.131 -    Arg args[MAX_ARGC];
  75.132 -    Cardinal argc, argc1;
  75.133 -    jsize i;
  75.134 -    Pixel bg;
  75.135 -    Pixel fg;
  75.136 -    short cols;
  75.137 -    int32_t sheight;
  75.138 -    Dimension height;
  75.139 -    Widget *firstNewItem = NULL;
  75.140 -
  75.141 -    XmString mfstr = NULL;
  75.142 -    XmFontList fontlist = NULL;
  75.143 -    jobject font = awtJNI_GetFont(env, this);
  75.144 -    Boolean IsMultiFont = awtJNI_IsMultiFont(env, font);
  75.145 -
  75.146 -    if ((items == NULL) || (nItems == 0)) {
  75.147 -        return;
  75.148 -    }
  75.149 -
  75.150 -    AWT_LOCK();
  75.151 -
  75.152 -    odata = (struct ChoiceData *)
  75.153 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  75.154 -
  75.155 -    if (odata == NULL) {
  75.156 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.157 -        AWT_UNLOCK();
  75.158 -
  75.159 -        return;
  75.160 -    }
  75.161 -    if (odata->maxitems == 0 || (index + nItems) > odata->maxitems) {
  75.162 -        odata->maxitems = index + nItems + 20;
  75.163 -        if (odata->n_items > 0) {
  75.164 -            /* grow the list of items */
  75.165 -            odata->items = (Widget *)
  75.166 -                realloc((void *) (odata->items)
  75.167 -                        ,sizeof(Widget) * odata->maxitems);
  75.168 -        } else {
  75.169 -            odata->items = (Widget *) malloc(sizeof(Widget) * odata->maxitems);
  75.170 -        }
  75.171 -        if (odata->items == NULL) {
  75.172 -            JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  75.173 -            AWT_UNLOCK();
  75.174 -            return;
  75.175 -        }
  75.176 -    }
  75.177 -    XtVaGetValues(odata->comp.widget, XmNbackground, &bg, NULL);
  75.178 -    XtVaGetValues(odata->comp.widget, XmNforeground, &fg, NULL);
  75.179 -
  75.180 -    argc = 0;
  75.181 -    XtSetArg(args[argc], XmNbackground, bg);
  75.182 -    argc++;
  75.183 -    XtSetArg(args[argc], XmNforeground, fg);
  75.184 -    argc++;
  75.185 -
  75.186 -    firstNewItem = &(odata->items[index]);
  75.187 -    for (i = 0; i < nItems; i++) {
  75.188 -        argc1 = argc;
  75.189 -        if (IsMultiFont) {
  75.190 -            mfstr = awtJNI_MakeMultiFontString(env, items[i], font);
  75.191 -            fontlist = awtJNI_GetFontList(env, font);
  75.192 -            /* XXX: XmNuserData doesn't seem to work when passing in zero */
  75.193 -            /* so we increment the index before passing it in. */
  75.194 -            XtSetArg(args[argc1], XmNuserData, (XtPointer)((intptr_t)(index + i + 1)));
  75.195 -            argc1++;
  75.196 -            XtSetArg(args[argc1], XmNfontList, fontlist);
  75.197 -            argc1++;
  75.198 -            XtSetArg(args[argc1], XmNlabelString, mfstr);
  75.199 -            argc1++;
  75.200 -
  75.201 -            DASSERT(!(argc1 > MAX_ARGC));
  75.202 -
  75.203 -            bw = XmCreatePushButton(odata->menu, "", args, argc1);
  75.204 -
  75.205 -            /* Free resurces */
  75.206 -            if ( fontlist != NULL )
  75.207 -            {
  75.208 -                XmFontListFree(fontlist);
  75.209 -                fontlist = NULL;
  75.210 -            }
  75.211 -            if (mfstr != NULL) {
  75.212 -                XmStringFree(mfstr);
  75.213 -                mfstr = NULL;
  75.214 -            }
  75.215 -        } else {
  75.216 -            citem = (char *) JNU_GetStringPlatformChars(env, items[i], NULL);
  75.217 -            /* XXX: XmNuserData doesn't seem to work when passing in zero */
  75.218 -            /* so we increment the index before passing it in. */
  75.219 -            XtSetArg(args[argc1], XmNuserData, (XtPointer)((intptr_t)(index + i + 1)));
  75.220 -            argc1++;
  75.221 -            DASSERT(!(argc1> MAX_ARGC));
  75.222 -            bw = XmCreatePushButton(odata->menu, citem, args, argc1);
  75.223 -            JNU_ReleaseStringPlatformChars(env, items[i], (const char *) citem);
  75.224 -            citem = NULL;
  75.225 -        }
  75.226 -
  75.227 -         XtAddCallback(bw,
  75.228 -                       XmNactivateCallback,
  75.229 -                       (XtCallbackProc) Choice_callback,
  75.230 -                       (XtPointer) JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.jniGlobalRef));
  75.231 -        odata->items[index + i] = bw;
  75.232 -        odata->n_items++;
  75.233 -    }
  75.234 -
  75.235 -    XtManageChildren(firstNewItem, nItems);
  75.236 -
  75.237 -    sheight = DisplayHeight(awt_display, DefaultScreen(awt_display));
  75.238 -
  75.239 -    XtVaGetValues(odata->menu, XmNheight, &height, NULL);
  75.240 -
  75.241 -    while ( height > sheight ) {
  75.242 -        cols = ++odata->n_columns;
  75.243 -        XtVaSetValues(odata->menu, XmNnumColumns, cols, NULL);
  75.244 -        XtVaGetValues(odata->menu, XmNheight, &height, NULL);
  75.245 -    }
  75.246 -
  75.247 -    AWT_UNLOCK();
  75.248 -}
  75.249 -
  75.250 -/*
  75.251 - * Class:     sun_awt_motif_MChoicePeer
  75.252 - * Method:    create
  75.253 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  75.254 - */
  75.255 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_create
  75.256 -  (JNIEnv * env, jobject this, jobject parent)
  75.257 -{
  75.258 -    struct ChoiceData *odata;
  75.259 -    struct ComponentData *wdata;
  75.260 -#undef MAX_ARGC
  75.261 -#define MAX_ARGC 30
  75.262 -    Arg args[MAX_ARGC];
  75.263 -    Cardinal argc;
  75.264 -    Pixel bg;
  75.265 -    Pixel fg;
  75.266 -    Widget label;
  75.267 -    Widget button;
  75.268 -    Widget hookobj;
  75.269 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
  75.270 -    AwtGraphicsConfigDataPtr adata;
  75.271 -    jobject target;
  75.272 -    Dimension width = 0, height = 0;
  75.273 -    jclass clsDimension;
  75.274 -    jobject dimension;
  75.275 -    jobject peer;
  75.276 -
  75.277 -    AWT_LOCK();
  75.278 -
  75.279 -    if (JNU_IsNull(env, parent)) {
  75.280 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.281 -        return;
  75.282 -    }
  75.283 -
  75.284 -    adata = copyGraphicsConfigToPeer(env, this);
  75.285 -
  75.286 -    wdata = (struct ComponentData *)
  75.287 -        JNU_GetLongFieldAsPtr(env,parent,mComponentPeerIDs.pData);
  75.288 -
  75.289 -    if (wdata == NULL) {
  75.290 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.291 -        AWT_UNLOCK();
  75.292 -
  75.293 -        return;
  75.294 -    }
  75.295 -
  75.296 -    odata = ZALLOC(ChoiceData);
  75.297 -    if (odata == NULL) {
  75.298 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  75.299 -        AWT_UNLOCK();
  75.300 -        return;
  75.301 -    }
  75.302 -    JNU_SetLongFieldFromPtr(env,this,mComponentPeerIDs.pData,odata);
  75.303 -
  75.304 -    odata->items = NULL;
  75.305 -    odata->maxitems = 0;
  75.306 -    odata->n_items = 0;
  75.307 -    odata->n_columns = 1;
  75.308 -
  75.309 -    XtVaGetValues(wdata->widget, XmNbackground, &bg, NULL);
  75.310 -    XtVaGetValues(wdata->widget, XmNforeground, &fg, NULL);
  75.311 -
  75.312 -    argc = 0;
  75.313 -    XtSetArg(args[argc], XmNx, 0);
  75.314 -    argc++;
  75.315 -    XtSetArg(args[argc], XmNy, 0);
  75.316 -    argc++;
  75.317 -    XtSetArg(args[argc], XmNvisual, adata->awt_visInfo.visual);
  75.318 -    argc++;
  75.319 -    XtSetArg(args[argc], XmNbackground, bg);
  75.320 -    argc++;
  75.321 -    XtSetArg(args[argc], XmNforeground, fg);
  75.322 -    argc++;
  75.323 -
  75.324 -    XtSetArg(args[argc], XmNorientation, XmVERTICAL);
  75.325 -    argc++;
  75.326 -    XtSetArg(args[argc], XmNpacking, XmPACK_COLUMN);
  75.327 -    argc++;
  75.328 -    XtSetArg(args[argc], XmNnumColumns, (short)1);
  75.329 -    argc++;
  75.330 -    /* Fix for 4303064 by ibd@sparc.spb.su: pop-up shells will have
  75.331 -     * ancestor_sensitive False if the parent was insensitive when the shell
  75.332 -     * was created.  Since XtSetSensitive on the parent will not modify the
  75.333 -     * resource of the pop-up child, clients are advised to include a resource
  75.334 -     * specification of the form '*TransientShell.ancestorSensitive: True' in
  75.335 -     * the application defaults resource file or to otherwise ensure that the
  75.336 -     * parent is sensitive when creating pop-up shells.
  75.337 -     */
  75.338 -    XtSetArg(args[argc], XmNancestorSensitive, True);
  75.339 -    argc++;
  75.340 -
  75.341 -    DASSERT(!(argc > MAX_ARGC));
  75.342 -    odata->menu = XmCreatePulldownMenu(wdata->widget, "pulldown", args, argc);
  75.343 -
  75.344 -
  75.345 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  75.346 -    clsDimension = (*env)->FindClass(env, "java/awt/Dimension");
  75.347 -    dimension = JNU_CallMethodByName(env,
  75.348 -                                     NULL,
  75.349 -                                     this,
  75.350 -                                     "getPreferredSize",
  75.351 -                                     "()Ljava/awt/Dimension;").l;
  75.352 -    DASSERT(clsDimension != NULL);
  75.353 -    width  = (Dimension)((*env)->GetIntField(env, dimension, (*env)->GetFieldID(env, clsDimension, "width" , "I")));
  75.354 -    height = (Dimension)((*env)->GetIntField(env, dimension, (*env)->GetFieldID(env, clsDimension, "height", "I")));
  75.355 -
  75.356 -    argc = 0;
  75.357 -    XtSetArg(args[argc], XmNx, 0);
  75.358 -    argc++;
  75.359 -    XtSetArg(args[argc], XmNy, 0);
  75.360 -    argc++;
  75.361 -    XtSetArg(args[argc], XmNwidth, width);
  75.362 -    argc++;
  75.363 -    XtSetArg(args[argc], XmNheight, height);
  75.364 -    argc++;
  75.365 -    XtSetArg(args[argc], XmNmarginHeight, 0);
  75.366 -    argc++;
  75.367 -    XtSetArg(args[argc], XmNmarginWidth, 0);
  75.368 -    argc++;
  75.369 -    XtSetArg(args[argc], XmNrecomputeSize, False);
  75.370 -    argc++;
  75.371 -    XtSetArg(args[argc], XmNresizeHeight, False);
  75.372 -    argc++;
  75.373 -    XtSetArg(args[argc], XmNresizeWidth, False);
  75.374 -    argc++;
  75.375 -    XtSetArg(args[argc], XmNspacing, False);
  75.376 -    argc++;
  75.377 -    XtSetArg(args[argc], XmNborderWidth, 0);
  75.378 -    argc++;
  75.379 -    XtSetArg(args[argc], XmNnavigationType, XmTAB_GROUP);
  75.380 -    argc++;
  75.381 -    XtSetArg(args[argc], XmNtraversalOn, True);
  75.382 -    argc++;
  75.383 -    XtSetArg(args[argc], XmNorientation, XmVERTICAL);
  75.384 -    argc++;
  75.385 -    XtSetArg(args[argc], XmNadjustMargin, False);
  75.386 -    argc++;
  75.387 -    XtSetArg(args[argc], XmNbackground, bg);
  75.388 -    argc++;
  75.389 -    XtSetArg(args[argc], XmNforeground, fg);
  75.390 -    argc++;
  75.391 -    XtSetArg(args[argc], XmNsubMenuId, odata->menu);
  75.392 -    argc++;
  75.393 -    XtSetArg (args[argc], XmNscreen,
  75.394 -              ScreenOfDisplay(awt_display, adata->awt_visInfo.screen));
  75.395 -    argc++;
  75.396 -
  75.397 -    DASSERT(!(argc > MAX_ARGC));
  75.398 -    odata->comp.widget = XmCreateOptionMenu(wdata->widget, "", args, argc);
  75.399 -
  75.400 -    hookobj = XtHooksOfDisplay(XtDisplayOfObject(odata->comp.widget));
  75.401 -    XtAddCallback(hookobj,
  75.402 -                  XtNgeometryHook,
  75.403 -                  (XtCallbackProc) geometry_hook,
  75.404 -                  (XtPointer) odata->comp.widget);
  75.405 -
  75.406 -    label = XmOptionLabelGadget(odata->comp.widget);
  75.407 -    if (label != NULL) {
  75.408 -        XtUnmanageChild(label);
  75.409 -    }
  75.410 -    XtSetMappedWhenManaged(odata->comp.widget, False);
  75.411 -    XtManageChild(odata->comp.widget);
  75.412 -
  75.413 -    AWT_UNLOCK();
  75.414 -}
  75.415 -
  75.416 -/*
  75.417 - * Class:     sun_awt_motif_MChoicePeer
  75.418 - * Method:    addItem
  75.419 - * Signature: (Ljava/lang/String;I)V
  75.420 - */
  75.421 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_addItem
  75.422 -  (JNIEnv *env, jobject this, jstring item, jint index)
  75.423 -{
  75.424 -    if (JNU_IsNull(env, item)) {
  75.425 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.426 -        return;
  75.427 -    }
  75.428 -    addItems(env, this, &item, 1, index);
  75.429 -}
  75.430 -
  75.431 -/*
  75.432 - * Class:     sun_awt_motif_MChoicePeer
  75.433 - * Method:    pSelect
  75.434 - * Signature: (I)V
  75.435 - */
  75.436 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_pSelect
  75.437 -  (JNIEnv *env, jobject this, jint index, jboolean init)
  75.438 -{
  75.439 -    struct ChoiceData *odata;
  75.440 -
  75.441 -    AWT_LOCK();
  75.442 -
  75.443 -    odata = (struct ChoiceData *)
  75.444 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  75.445 -
  75.446 -    if (odata == NULL) {
  75.447 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.448 -        AWT_UNLOCK();
  75.449 -        return;
  75.450 -    }
  75.451 -    if (index > odata->n_items || index < 0) {
  75.452 -        JNU_ThrowIllegalArgumentException(env, "IllegalArgumentException");
  75.453 -        AWT_UNLOCK();
  75.454 -        return;
  75.455 -    }
  75.456 -    XtVaSetValues(odata->comp.widget,
  75.457 -                  XmNmenuHistory, odata->items[index],
  75.458 -                  NULL);
  75.459 -    AWT_UNLOCK();
  75.460 -}
  75.461 -
  75.462 -/*
  75.463 - * Class:     sun_awt_motif_MChoicePeer
  75.464 - * Method:    setFont
  75.465 - * Signature: (Ljava/awt/Font;)V
  75.466 - */
  75.467 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_setFont
  75.468 -  (JNIEnv *env, jobject this, jobject f)
  75.469 -{
  75.470 -    struct ChoiceData *cdata;
  75.471 -    struct FontData *fdata;
  75.472 -    XmFontList fontlist;
  75.473 -    char *err;
  75.474 -
  75.475 -    if (JNU_IsNull(env, f)) {
  75.476 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.477 -        return;
  75.478 -    }
  75.479 -    AWT_LOCK();
  75.480 -
  75.481 -    fdata = awtJNI_GetFontData(env, f, &err);
  75.482 -    if (fdata == NULL) {
  75.483 -        JNU_ThrowInternalError(env, err);
  75.484 -        AWT_UNLOCK();
  75.485 -        return;
  75.486 -    }
  75.487 -    cdata = (struct ChoiceData *)
  75.488 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  75.489 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  75.490 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.491 -        AWT_UNLOCK();
  75.492 -        return;
  75.493 -    }
  75.494 -    if (awtJNI_IsMultiFont(env, f)) {
  75.495 -        fontlist = awtJNI_GetFontList(env, f);
  75.496 -    } else {
  75.497 -        fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  75.498 -    }
  75.499 -
  75.500 -    if (fontlist != NULL) {
  75.501 -        jint i;
  75.502 -
  75.503 -        XtVaSetValues(cdata->comp.widget,
  75.504 -                      XmNfontList, fontlist,
  75.505 -                      NULL);
  75.506 -        XtVaSetValues(cdata->menu,
  75.507 -                      XmNfontList, fontlist,
  75.508 -                      NULL);
  75.509 -        for (i = 0; i < cdata->n_items; i++) {
  75.510 -            XtVaSetValues(cdata->items[i],
  75.511 -                          XmNfontList, fontlist,
  75.512 -                          NULL);
  75.513 -        }
  75.514 -
  75.515 -        XmFontListFree(fontlist);
  75.516 -    } else {
  75.517 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.518 -    }
  75.519 -    AWT_UNLOCK();
  75.520 -}
  75.521 -
  75.522 -/* Fix for bug 4326619 */
  75.523 -/*
  75.524 - * Class:     sun_awt_motif_MChoicePeer
  75.525 - * Method:    freeNativeData
  75.526 - * Signature: ()V
  75.527 - */
  75.528 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_freeNativeData
  75.529 -  (JNIEnv *env, jobject this)
  75.530 -{
  75.531 -    struct ChoiceData *cdata;
  75.532 -
  75.533 -    AWT_LOCK();
  75.534 -
  75.535 -    cdata = (struct ChoiceData *)
  75.536 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  75.537 -
  75.538 -    cdata->n_items = 0;
  75.539 -    free((void *)cdata->items);
  75.540 -    cdata->items = NULL;
  75.541 -    AWT_UNLOCK();
  75.542 -}
  75.543 -
  75.544 -/*
  75.545 - * Class:     sun_awt_motif_MChoicePeer
  75.546 - * Method:    setBackground
  75.547 - * Signature: (Ljava/awt/Color;)V
  75.548 - */
  75.549 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_setBackground
  75.550 -  (JNIEnv *env, jobject this, jobject c)
  75.551 -{
  75.552 -    struct ChoiceData *bdata;
  75.553 -    Pixel bg;
  75.554 -    Pixel fg;
  75.555 -    WidgetList children;
  75.556 -    Cardinal numChildren;
  75.557 -    int32_t i;
  75.558 -
  75.559 -    if (JNU_IsNull(env, c)) {
  75.560 -        JNU_ThrowNullPointerException(env, "NullPointerException: null color");
  75.561 -        return;
  75.562 -    }
  75.563 -    AWT_LOCK();
  75.564 -
  75.565 -    bdata = (struct ChoiceData *)
  75.566 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  75.567 -    if (bdata == NULL || bdata->comp.widget == NULL) {
  75.568 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.569 -        AWT_UNLOCK();
  75.570 -        return;
  75.571 -    }
  75.572 -    /* Get background color */
  75.573 -    bg = awtJNI_GetColor(env, c);
  75.574 -
  75.575 -    /*
  75.576 -       XmChangeColor(), in addtion to changing the background and
  75.577 -       selection colors, also changes the foreground color to be
  75.578 -       what it thinks should be. However, we want to use the color
  75.579 -       that gets set by setForeground() instead. We therefore need to
  75.580 -       save the current foreground color here, and then set it again
  75.581 -       after the XmChangeColor() occurs.
  75.582 -    */
  75.583 -    XtVaGetValues(bdata->comp.widget, XmNforeground, &fg, NULL);
  75.584 -
  75.585 -    /* Set color */
  75.586 -    XmChangeColor(bdata->comp.widget, bg);
  75.587 -    XtVaSetValues(bdata->comp.widget, XmNforeground, fg, NULL);
  75.588 -
  75.589 -    /*
  75.590 -     * The following recursion fixes a bug in Motif 2.1 that caused
  75.591 -     * black colored choice buttons (change has no effect on Motif 1.2).
  75.592 -     */
  75.593 -    XtVaGetValues(bdata->comp.widget,
  75.594 -                  XmNchildren, &children,
  75.595 -                  XmNnumChildren, &numChildren,
  75.596 -                  NULL);
  75.597 -    for (i = 0; i < numChildren; i++) {
  75.598 -        XmChangeColor(children[i], bg);
  75.599 -        XtVaSetValues(children[i], XmNforeground, fg, NULL);
  75.600 -    }
  75.601 -
  75.602 -
  75.603 -    XmChangeColor(bdata->menu, bg);
  75.604 -    XtVaSetValues(bdata->menu, XmNforeground, fg, NULL);
  75.605 -
  75.606 -    for (i = 0; i < bdata->n_items; i++) {
  75.607 -        XmChangeColor(bdata->items[i], bg);
  75.608 -        XtVaSetValues(bdata->items[i], XmNforeground, fg, NULL);
  75.609 -    }
  75.610 -    AWT_FLUSH_UNLOCK();
  75.611 -}
  75.612 -
  75.613 -/*
  75.614 - * Class:     sun_awt_motif_MChoicePeer
  75.615 - * Method:    setForeground
  75.616 - * Signature: (Ljava/awt/Color;)V
  75.617 - */
  75.618 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_setForeground
  75.619 -  (JNIEnv *env, jobject this, jobject c)
  75.620 -{
  75.621 -    struct ChoiceData *bdata;
  75.622 -    Pixel color;
  75.623 -    int32_t i;
  75.624 -
  75.625 -    if (JNU_IsNull(env, c)) {
  75.626 -        JNU_ThrowNullPointerException(env, "NullPointerException: null color");
  75.627 -        return;
  75.628 -    }
  75.629 -    AWT_LOCK();
  75.630 -
  75.631 -    bdata = (struct ChoiceData *)
  75.632 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  75.633 -    if (bdata == NULL || bdata->comp.widget == NULL) {
  75.634 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.635 -        AWT_UNLOCK();
  75.636 -        return;
  75.637 -    }
  75.638 -    color = awtJNI_GetColor(env, c);
  75.639 -
  75.640 -    XtVaSetValues(bdata->comp.widget, XmNforeground, color, NULL);
  75.641 -
  75.642 -    XtVaSetValues(bdata->menu, XmNforeground, color, NULL);
  75.643 -    for (i = 0; i < bdata->n_items; i++) {
  75.644 -        XtVaSetValues(bdata->items[i], XmNforeground, color, NULL);
  75.645 -    }
  75.646 -
  75.647 -    AWT_FLUSH_UNLOCK();
  75.648 -}
  75.649 -
  75.650 -/*
  75.651 - * Class:     sun_awt_motif_MChoicePeer
  75.652 - * Method:    pReshape
  75.653 - * Signature: (IIII)V
  75.654 - */
  75.655 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_pReshape
  75.656 -  (JNIEnv *env, jobject this, jint x, jint y, jint w, jint h)
  75.657 -{
  75.658 -    struct ChoiceData *cdata;
  75.659 -    Widget button;
  75.660 -    jobject target;
  75.661 -    Dimension width=0, height=0;
  75.662 -    Position new_y = 0;
  75.663 -
  75.664 -    AWT_LOCK();
  75.665 -
  75.666 -    cdata = (struct ChoiceData *)
  75.667 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  75.668 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  75.669 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.670 -        AWT_UNLOCK();
  75.671 -        return;
  75.672 -    }
  75.673 -
  75.674 -    button = XmOptionButtonGadget(cdata->comp.widget);
  75.675 -    cdata->bounds_y = y;
  75.676 -    cdata->bounds_height = h;
  75.677 -    awt_util_reshape(cdata->comp.widget, x, y, w, h);
  75.678 -    awt_util_reshape(button, x, y, w, h);
  75.679 -
  75.680 -    /* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
  75.681 -     * actual size
  75.682 -     */
  75.683 -    XtVaGetValues(cdata->comp.widget, XmNy, &new_y, NULL);
  75.684 -    XtVaGetValues(button, XmNwidth, &width, XmNheight, &height , NULL);
  75.685 -    awt_util_reshape(cdata->comp.widget, x, new_y, width, height);
  75.686 -
  75.687 -    AWT_FLUSH_UNLOCK();
  75.688 -}
  75.689 -
  75.690 -/*
  75.691 - * Class:     sun_awt_motif_MChoicePeer
  75.692 - * Method:    remove
  75.693 - * Signature: (I)V
  75.694 - */
  75.695 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_remove
  75.696 -  (JNIEnv *env, jobject this, jint index)
  75.697 -{
  75.698 -    struct ChoiceData *cdata;
  75.699 -    Widget selected;
  75.700 -    jint i;
  75.701 -    short cols;
  75.702 -    int32_t sheight;
  75.703 -    Dimension height;
  75.704 -
  75.705 -    AWT_LOCK();
  75.706 -
  75.707 -    cdata = (struct ChoiceData *)
  75.708 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  75.709 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  75.710 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.711 -        AWT_UNLOCK();
  75.712 -        return;
  75.713 -    }
  75.714 -    if (index < 0 || index > cdata->n_items) {
  75.715 -        JNU_ThrowIllegalArgumentException(env, "IllegalArgumentException");
  75.716 -        AWT_UNLOCK();
  75.717 -        return;
  75.718 -    }
  75.719 -    XtUnmanageChild(cdata->items[index]);
  75.720 -    awt_util_consumeAllXEvents(cdata->items[index]);
  75.721 -    awt_util_cleanupBeforeDestroyWidget(cdata->items[index]);
  75.722 -    XtDestroyWidget(cdata->items[index]);
  75.723 -    for (i = index; i < cdata->n_items-1; i++) {
  75.724 -        cdata->items[i] = cdata->items[i + 1];
  75.725 -        /* need to reset stored index value, (adding 1 to disambiguate it */
  75.726 -        /* from an arg list terminator)                                   */
  75.727 -        /* bug fix 4079027 robi.khan@eng                                  */
  75.728 -        XtVaSetValues(cdata->items[i],  XmNuserData, (XtPointer)((intptr_t)(i+1)), NULL);
  75.729 -    }
  75.730 -    cdata->items[cdata->n_items-1] = NULL;
  75.731 -    cdata->n_items--;
  75.732 -
  75.733 -    XtVaGetValues(cdata->menu, XmNheight, &height, NULL);
  75.734 -
  75.735 -    sheight = DisplayHeight(awt_display, DefaultScreen(awt_display));
  75.736 -    cols = cdata->n_columns;
  75.737 -
  75.738 -    if (cols >1) {
  75.739 -        /* first try to remove a column */
  75.740 -        cols = --cdata->n_columns;
  75.741 -        XtVaSetValues(cdata->menu, XmNnumColumns, cols, NULL);
  75.742 -
  75.743 -        /* then see if it fits, if not add it back */
  75.744 -        XtVaGetValues(cdata->menu, XmNheight, &height, NULL);
  75.745 -        if ( height > sheight ) {
  75.746 -            cols = ++cdata->n_columns;
  75.747 -            XtVaSetValues(cdata->menu, XmNnumColumns, cols, NULL);
  75.748 -        }
  75.749 -    }
  75.750 -
  75.751 -    AWT_UNLOCK();
  75.752 -}
  75.753 -
  75.754 -/*
  75.755 - * Class:     sun_awt_motif_MChoicePeer
  75.756 - * Method:    removeAll
  75.757 - * Signature: ()V
  75.758 - */
  75.759 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_removeAll
  75.760 -  (JNIEnv *env, jobject this)
  75.761 -{
  75.762 -    struct ChoiceData *cdata;
  75.763 -    Widget selected;
  75.764 -    jint i;
  75.765 -
  75.766 -    AWT_LOCK();
  75.767 -
  75.768 -    cdata = (struct ChoiceData *)
  75.769 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  75.770 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  75.771 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.772 -        AWT_UNLOCK();
  75.773 -        return;
  75.774 -    }
  75.775 -
  75.776 -    XtUnmanageChildren(cdata->items, cdata->n_items);
  75.777 -
  75.778 -    for (i = cdata->n_items-1; i >= 0; i--) {
  75.779 -        awt_util_consumeAllXEvents(cdata->items[i]);
  75.780 -        awt_util_cleanupBeforeDestroyWidget(cdata->items[i]);
  75.781 -        XtDestroyWidget(cdata->items[i]);
  75.782 -        cdata->items[i] = NULL;
  75.783 -    }
  75.784 -
  75.785 -    cdata->n_items = 0;
  75.786 -
  75.787 -    if (cdata->n_columns > 1) {
  75.788 -        cdata->n_columns = 1;
  75.789 -        XtVaSetValues(cdata->menu, XmNnumColumns, cdata->n_columns, NULL);
  75.790 -    }
  75.791 -
  75.792 -    AWT_UNLOCK();
  75.793 -}
  75.794 -
  75.795 -/*
  75.796 - * Class:     sun_awt_motif_MChoicePeer
  75.797 - * Method:    appendItems
  75.798 - * Signature: ([Ljava/lang/String;)V
  75.799 - */
  75.800 -JNIEXPORT void JNICALL Java_sun_awt_motif_MChoicePeer_appendItems
  75.801 -  (JNIEnv *env, jobject this, jarray items)
  75.802 -{
  75.803 -    struct ChoiceData *odata = NULL;
  75.804 -    jstring *strItems = NULL;
  75.805 -    jsize nItems, i; // MP
  75.806 -
  75.807 -    if (JNU_IsNull(env, items)) {
  75.808 -        return;
  75.809 -    }
  75.810 -    nItems  = (*env)->GetArrayLength(env, items);
  75.811 -    if (nItems == 0) {
  75.812 -        return;
  75.813 -    }
  75.814 -
  75.815 -    AWT_LOCK();
  75.816 -
  75.817 -    odata = (struct ChoiceData *)
  75.818 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  75.819 -
  75.820 -    if (odata == NULL) {
  75.821 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.822 -        goto cleanup;
  75.823 -    }
  75.824 -
  75.825 -    strItems = (jstring *) malloc(sizeof(jstring) * nItems);
  75.826 -    if (strItems == NULL) {
  75.827 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  75.828 -        goto cleanup;
  75.829 -    }
  75.830 -
  75.831 -    for (i = 0; i < nItems; i++) {
  75.832 -        strItems[i] = (jstring)(*env)->GetObjectArrayElement(env, items, i);
  75.833 -        if (JNU_IsNull(env, strItems[i])) {
  75.834 -            JNU_ThrowNullPointerException(env, "NullPointerException");
  75.835 -            goto cleanup;
  75.836 -        }
  75.837 -    }
  75.838 -
  75.839 -    addItems(env, this, strItems, nItems, odata->n_items);
  75.840 -
  75.841 -cleanup:
  75.842 -    if (strItems != NULL) {
  75.843 -        free(strItems);
  75.844 -    }
  75.845 -    AWT_UNLOCK();
  75.846 -}
    76.1 --- a/src/solaris/native/sun/awt/awt_Choice21.c	Wed Sep 17 13:45:37 2008 -0700
    76.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.3 @@ -1,764 +0,0 @@
    76.4 -/*
    76.5 - * Copyright 2001-2003 Sun Microsystems, Inc.  All Rights Reserved.
    76.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    76.7 - *
    76.8 - * This code is free software; you can redistribute it and/or modify it
    76.9 - * under the terms of the GNU General Public License version 2 only, as
   76.10 - * published by the Free Software Foundation.  Sun designates this
   76.11 - * particular file as subject to the "Classpath" exception as provided
   76.12 - * by Sun in the LICENSE file that accompanied this code.
   76.13 - *
   76.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   76.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   76.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   76.17 - * version 2 for more details (a copy is included in the LICENSE file that
   76.18 - * accompanied this code).
   76.19 - *
   76.20 - * You should have received a copy of the GNU General Public License version
   76.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   76.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   76.23 - *
   76.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   76.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   76.26 - * have any questions.
   76.27 - */
   76.28 -
   76.29 -#ifdef HEADLESS
   76.30 -    #error This file should not be included in headless library
   76.31 -#endif
   76.32 -
   76.33 -#if MOTIF_VERSION!=2
   76.34 -    #error This file should only be compiled with motif 2.1
   76.35 -#endif
   76.36 -
   76.37 -#include "awt_p.h"
   76.38 -#include "java_awt_Component.h"
   76.39 -#include "java_awt_AWTEvent.h"
   76.40 -#include "sun_awt_motif_MComponentPeer.h"
   76.41 -#include "sun_awt_motif_MChoicePeer.h"
   76.42 -
   76.43 -#include "awt_Component.h"
   76.44 -#include "canvas.h"
   76.45 -
   76.46 -#include "multi_font.h"
   76.47 -
   76.48 -#include <jni.h>
   76.49 -#include <jni_util.h>
   76.50 -#include <Xm/ComboBox.h>
   76.51 -
   76.52 -#define MAX_VISIBLE 10
   76.53 -
   76.54 -extern struct ComponentIDs componentIDs;
   76.55 -extern struct ContainerIDs containerIDs;
   76.56 -extern struct MComponentPeerIDs mComponentPeerIDs;
   76.57 -
   76.58 -extern AwtGraphicsConfigDataPtr
   76.59 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   76.60 -
   76.61 -/*
   76.62 -   setSelection
   76.63 -   Set the selected text on the XmTextField of the XmComboBox.
   76.64 -*/
   76.65 -static void
   76.66 -setSelection(JNIEnv *env,
   76.67 -              jobject this,
   76.68 -              Widget comboBox,
   76.69 -              jint index)
   76.70 -{
   76.71 -    jstring item = NULL;
   76.72 -    jobject target;
   76.73 -    Widget text=NULL;
   76.74 -
   76.75 -    AWT_LOCK();
   76.76 -    /* Get the java Choice component. */
   76.77 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
   76.78 -    if (target == NULL) {
   76.79 -        JNU_ThrowNullPointerException(env, "NullPointerException");
   76.80 -        AWT_UNLOCK();
   76.81 -        return;
   76.82 -    }
   76.83 -    /* Get the XmTextField widget in the XmComboBox. */
   76.84 -    text = XtNameToWidget(comboBox, "*Text");
   76.85 -    /* Get the selected Unicode string from the java Choice component. */
   76.86 -    item = (jstring) JNU_CallMethodByName(env, NULL,
   76.87 -        target, "getItem", "(I)Ljava/lang/String;", index).l;
   76.88 -    if ((*env)->ExceptionOccurred(env)) {
   76.89 -        (*env)->ExceptionDescribe(env);
   76.90 -        (*env)->ExceptionClear(env);
   76.91 -    }
   76.92 -    if (!JNU_IsNull(env, item)) {
   76.93 -        /* Convert the Unicode string to a multibyte string. */
   76.94 -        char *temp = (char *)JNU_GetStringPlatformChars(env, item, NULL);
   76.95 -        /* Assign the multibyte string to the XmTextField of the XmComboBox. */
   76.96 -        XmTextSetString(text, temp);
   76.97 -        JNU_ReleaseStringPlatformChars(env, item, (const char *)temp);
   76.98 -    }
   76.99 -    AWT_UNLOCK();
  76.100 -}
  76.101 -
  76.102 -extern Boolean skipNextNotifyWhileGrabbed;
  76.103 -extern Boolean skipNextFocusIn;
  76.104 -
  76.105 -static void
  76.106 -GrabShellPopup(Widget grab_shell,
  76.107 -                jobject this,
  76.108 -                XmAnyCallbackStruct * call_data)
  76.109 -{
  76.110 -    skipNextNotifyWhileGrabbed = True;
  76.111 -}
  76.112 -static void
  76.113 -GrabShellPopdown(Widget grab_shell,
  76.114 -                jobject this,
  76.115 -                XmAnyCallbackStruct * call_data)
  76.116 -{
  76.117 -    skipNextNotifyWhileGrabbed = True;
  76.118 -    skipNextFocusIn = True;
  76.119 -}
  76.120 -
  76.121 -static void
  76.122 -Choice_callback(Widget list,
  76.123 -                jobject this,
  76.124 -                XmAnyCallbackStruct * call_data)
  76.125 -{
  76.126 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  76.127 -    XmListCallbackStruct *cbs = (XmListCallbackStruct *)call_data;
  76.128 -    struct ChoiceData *cdata;
  76.129 -
  76.130 -
  76.131 -    AWT_LOCK();
  76.132 -    /* Get the Choice data. */
  76.133 -    cdata = (struct ChoiceData *)
  76.134 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  76.135 -    if (cdata == NULL) {
  76.136 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.137 -        AWT_UNLOCK();
  76.138 -        return;
  76.139 -    }
  76.140 -    setSelection(env, this, cdata->comp.widget, cbs->item_position - 1);
  76.141 -    /* Get the Choice data. */
  76.142 -    JNU_CallMethodByName(env, NULL,
  76.143 -        this, "action", "(I)V", cbs->item_position - 1);
  76.144 -    if ((*env)->ExceptionOccurred(env)) {
  76.145 -        (*env)->ExceptionDescribe(env);
  76.146 -        (*env)->ExceptionClear(env);
  76.147 -    }
  76.148 -    AWT_UNLOCK();
  76.149 -}
  76.150 -
  76.151 -static void
  76.152 -addItems(JNIEnv *env, jobject this,
  76.153 -    jstring *items, int32_t nItems, jint index)
  76.154 -{
  76.155 -    struct ChoiceData *cdata;
  76.156 -    int32_t i;
  76.157 -    Widget list;
  76.158 -    XmString mfstr = NULL;
  76.159 -    XmFontList fontlist = NULL;
  76.160 -    jobject font = awtJNI_GetFont(env, this);
  76.161 -    Boolean IsMultiFont = awtJNI_IsMultiFont(env, font);
  76.162 -
  76.163 -    if ((items == NULL) || (nItems == 0)) {
  76.164 -        return;
  76.165 -    }
  76.166 -
  76.167 -    AWT_LOCK();
  76.168 -
  76.169 -    cdata = (struct ChoiceData *)
  76.170 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  76.171 -
  76.172 -    if (cdata == NULL) {
  76.173 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.174 -        AWT_UNLOCK();
  76.175 -        return;
  76.176 -    }
  76.177 -
  76.178 -    for (i = 0; i < nItems; ++i) {
  76.179 -        char *temp = (char *)JNU_GetStringPlatformChars(env, items[i], NULL);
  76.180 -        mfstr = XmStringCreateLocalized(temp);
  76.181 -        JNU_ReleaseStringPlatformChars(env, items[i], (const char *)temp);
  76.182 -        XmComboBoxAddItem(cdata->comp.widget, mfstr, index + i + 1, FALSE);
  76.183 -
  76.184 -        if (mfstr != NULL) {
  76.185 -            XmStringFree(mfstr);
  76.186 -            mfstr = NULL;
  76.187 -        }
  76.188 -    }
  76.189 -
  76.190 -    cdata->n_items += nItems;
  76.191 -
  76.192 -    list = XtNameToWidget(cdata->comp.widget, "*List");
  76.193 -    XtVaSetValues(list,
  76.194 -                  XmNvisibleItemCount, min(MAX_VISIBLE, cdata->n_items),
  76.195 -                  NULL);
  76.196 -    AWT_UNLOCK();
  76.197 -}
  76.198 -
  76.199 -/*
  76.200 - * Class:     sun_awt_motif_MChoicePeer
  76.201 - * Method:    create
  76.202 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  76.203 - */
  76.204 -JNIEXPORT void JNICALL
  76.205 -Java_sun_awt_motif_MChoicePeer_create(JNIEnv * env, jobject this,
  76.206 -    jobject parent)
  76.207 -{
  76.208 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
  76.209 -
  76.210 -    struct ComponentData *wdata; /* parent's peer data */
  76.211 -    struct ChoiceData *cdata;    /* our own peer data */
  76.212 -    Widget list, text, list_shell;               /* components of drop dowwn list widget */
  76.213 -
  76.214 -    AwtGraphicsConfigDataPtr adata;
  76.215 -    Pixel fg, bg;                /* colors inherited from parent */
  76.216 -    Dimension width = 0, height = 0;
  76.217 -    jclass clsDimension;
  76.218 -    jobject dimension;
  76.219 -
  76.220 -#undef MAX_ARGC
  76.221 -#define MAX_ARGC 30
  76.222 -    Arg args[MAX_ARGC];
  76.223 -    int32_t argc;
  76.224 -
  76.225 -    AWT_LOCK();
  76.226 -
  76.227 -    if (JNU_IsNull(env, parent)) {
  76.228 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.229 -        return;
  76.230 -    }
  76.231 -
  76.232 -    /* get parent's peer data */
  76.233 -    wdata = (struct ComponentData *)JNU_GetLongFieldAsPtr(env,
  76.234 -                parent, mComponentPeerIDs.pData);
  76.235 -    if (wdata == NULL) {
  76.236 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.237 -        AWT_UNLOCK();
  76.238 -        return;
  76.239 -    }
  76.240 -
  76.241 -    /* create our own peer data */
  76.242 -    cdata = ZALLOC(ChoiceData);
  76.243 -    if (cdata == NULL) {
  76.244 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  76.245 -        AWT_UNLOCK();
  76.246 -        return;
  76.247 -    }
  76.248 -    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.pData, cdata);
  76.249 -
  76.250 -    /* get desired size */
  76.251 -    clsDimension = (*env)->FindClass(env, "java/awt/Dimension");
  76.252 -    DASSERT(clsDimension != NULL);
  76.253 -
  76.254 -    dimension = JNU_CallMethodByName(env, NULL,
  76.255 -                    this, "getPreferredSize", "()Ljava/awt/Dimension;").l;
  76.256 -    width  = (Dimension)((*env)->GetIntField(env, dimension,
  76.257 -                             (*env)->GetFieldID(env, clsDimension,
  76.258 -                                 "width" , "I")));
  76.259 -    height = (Dimension)((*env)->GetIntField(env, dimension,
  76.260 -                             (*env)->GetFieldID(env, clsDimension,
  76.261 -                                 "height", "I")));
  76.262 -
  76.263 -    /* Inherit visual/colors from parent component */
  76.264 -    XtVaGetValues(wdata->widget, XmNbackground, &bg, NULL);
  76.265 -    XtVaGetValues(wdata->widget, XmNforeground, &fg, NULL);
  76.266 -    adata = copyGraphicsConfigToPeer(env, this);
  76.267 -
  76.268 -    argc = 0;
  76.269 -    XtSetArg(args[argc], XmNuserData, (XtPointer)globalRef);            ++argc;
  76.270 -    XtSetArg(args[argc], XmNx, 0);                                      ++argc;
  76.271 -    XtSetArg(args[argc], XmNy, 0);                                      ++argc;
  76.272 -    XtSetArg(args[argc], XmNmarginHeight, 2);                           ++argc;
  76.273 -    XtSetArg(args[argc], XmNmarginWidth, 1);                            ++argc;
  76.274 -    XtSetArg(args[argc], XmNvisibleItemCount, 0);                       ++argc;
  76.275 -    XtSetArg(args[argc], XmNancestorSensitive, True);                   ++argc;
  76.276 -    /* Don't ding on key press */
  76.277 -    XtSetArg(args[argc], XmNverifyBell, False);                         ++argc;
  76.278 -    XtSetArg(args[argc], XmNvisual, adata->awt_visInfo.visual);         ++argc;
  76.279 -    XtSetArg(args[argc], XmNscreen,
  76.280 -             ScreenOfDisplay(awt_display, adata->awt_visInfo.screen));  ++argc;
  76.281 -    XtSetArg(args[argc], XmNbackground, bg);                            ++argc;
  76.282 -    XtSetArg(args[argc], XmNforeground, fg);                            ++argc;
  76.283 -
  76.284 -    DASSERT(!(argc > MAX_ARGC));
  76.285 -    cdata->comp.widget = XmCreateDropDownList(wdata->widget,
  76.286 -                                              "combobox", args, argc);
  76.287 -    cdata->n_items = 0;
  76.288 -
  76.289 -    list = XtNameToWidget(cdata->comp.widget, "*List");
  76.290 -    text = XtNameToWidget(cdata->comp.widget, "*Text");
  76.291 -    list_shell = XtNameToWidget(cdata->comp.widget, "*GrabShell");
  76.292 -    XtAddCallback(list_shell,
  76.293 -                  XmNpopupCallback,
  76.294 -                  (XtCallbackProc)GrabShellPopup,
  76.295 -                  globalRef);
  76.296 -    XtAddCallback(list_shell,
  76.297 -                  XmNpopdownCallback,
  76.298 -                  (XtCallbackProc)GrabShellPopdown,
  76.299 -                  globalRef);
  76.300 -
  76.301 -    /*
  76.302 -     * Bug 4477410:  Setting the width of the XmComboBox made the XmTextField
  76.303 -     * too small, cutting off the dropdown list knob on the right side. Set
  76.304 -     * the width of the TextField because it is the widget actually seen.
  76.305 -    */
  76.306 -    /* Set the width and height of the TextField widget. */
  76.307 -    XtVaSetValues(text,
  76.308 -                  XmNwidth, width,
  76.309 -                  XmNheight, height,
  76.310 -                  NULL);
  76.311 -
  76.312 -    XtAddCallback(list,
  76.313 -                  XmNbrowseSelectionCallback,
  76.314 -                  (XtCallbackProc)Choice_callback,
  76.315 -                  (XtPointer)globalRef);
  76.316 -
  76.317 -    XtAddEventHandler(text, FocusChangeMask, True,
  76.318 -                      awt_canvas_event_handler, globalRef);
  76.319 -
  76.320 -    awt_addWidget(text, cdata->comp.widget, globalRef,
  76.321 -                  java_awt_AWTEvent_KEY_EVENT_MASK
  76.322 -                  | java_awt_AWTEvent_MOUSE_EVENT_MASK
  76.323 -                  | java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK);
  76.324 -
  76.325 -    XtSetMappedWhenManaged(cdata->comp.widget, False);
  76.326 -    XtManageChild(cdata->comp.widget);
  76.327 -
  76.328 -    AWT_UNLOCK();
  76.329 -}
  76.330 -
  76.331 -/*
  76.332 - * Class:     sun_awt_motif_MChoicePeer
  76.333 - * Method:    pSelect
  76.334 - * Signature: (I)V
  76.335 - */
  76.336 -JNIEXPORT void JNICALL
  76.337 -Java_sun_awt_motif_MChoicePeer_pSelect(JNIEnv *env, jobject this,
  76.338 -    jint index, jboolean init)
  76.339 -{
  76.340 -    struct ChoiceData *cdata;
  76.341 -    Widget list;
  76.342 -
  76.343 -    AWT_LOCK();
  76.344 -
  76.345 -    cdata = (struct ChoiceData *)JNU_GetLongFieldAsPtr(env,
  76.346 -                this, mComponentPeerIDs.pData);
  76.347 -    if (cdata == NULL) {
  76.348 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.349 -        AWT_UNLOCK();
  76.350 -        return;
  76.351 -    }
  76.352 -
  76.353 -    list = XtNameToWidget(cdata->comp.widget, "*List");
  76.354 -
  76.355 -    XmListDeselectAllItems(list);
  76.356 -    XmListSelectPos(list, index + 1, False);
  76.357 -    setSelection(env, this, cdata->comp.widget, index);
  76.358 -    XmComboBoxUpdate(cdata->comp.widget);
  76.359 -
  76.360 -    AWT_UNLOCK();
  76.361 -}
  76.362 -
  76.363 -/*
  76.364 - * Class:     sun_awt_motif_MChoicePeer
  76.365 - * Method:    setFont
  76.366 - * Signature: (Ljava/awt/Font;)V
  76.367 - */
  76.368 -JNIEXPORT void JNICALL
  76.369 -Java_sun_awt_motif_MChoicePeer_setFont(JNIEnv *env, jobject this,
  76.370 -    jobject f)
  76.371 -{
  76.372 -    struct ChoiceData *cdata;
  76.373 -    struct FontData *fdata;
  76.374 -    XmFontList fontlist;
  76.375 -    Widget list;
  76.376 -    Widget text;
  76.377 -    char *err;
  76.378 -    XmFontListEntry fontentry;
  76.379 -    Position x=0, y=0;
  76.380 -
  76.381 -    if (JNU_IsNull(env, f)) {
  76.382 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.383 -        return;
  76.384 -    }
  76.385 -    AWT_LOCK();
  76.386 -
  76.387 -    fdata = awtJNI_GetFontData(env, f, &err);
  76.388 -    if (fdata == NULL) {
  76.389 -        JNU_ThrowInternalError(env, err);
  76.390 -        AWT_UNLOCK();
  76.391 -        return;
  76.392 -    }
  76.393 -
  76.394 -    cdata = (struct ChoiceData *)JNU_GetLongFieldAsPtr(env,
  76.395 -                this, mComponentPeerIDs.pData);
  76.396 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  76.397 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.398 -        AWT_UNLOCK();
  76.399 -        return;
  76.400 -    }
  76.401 -
  76.402 -    /* Make a fontset and set it. */
  76.403 -    if (awtJNI_IsMultiFont(env, f)) {
  76.404 -        if (fdata->xfs == NULL) {
  76.405 -            fdata->xfs = awtJNI_MakeFontSet(env, f);
  76.406 -        }
  76.407 -        if (fdata->xfs != NULL) {
  76.408 -            fontentry = XmFontListEntryCreate("labelFont",
  76.409 -                                              XmFONT_IS_FONTSET,
  76.410 -                                              (XtPointer) (fdata->xfs));
  76.411 -            fontlist = XmFontListAppendEntry(NULL, fontentry);
  76.412 -            /*
  76.413 -             * Some versions of motif have a bug in
  76.414 -             * XmFontListEntryFree() which causes it to free more than it
  76.415 -             * should.  Use XtFree() instead.  See O'Reilly's
  76.416 -             * Motif Reference Manual for more information.
  76.417 -             */
  76.418 -            XmFontListEntryFree(&fontentry);
  76.419 -        } else {
  76.420 -            fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  76.421 -        }
  76.422 -    } else {
  76.423 -        fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  76.424 -    }
  76.425 -    XtVaSetValues(cdata->comp.widget,
  76.426 -                  XmNfontList, fontlist,
  76.427 -                  NULL);
  76.428 -    list = XtNameToWidget(cdata->comp.widget, "*List");
  76.429 -    XtVaSetValues(list,
  76.430 -                  XmNfontList, fontlist,
  76.431 -                  NULL);
  76.432 -
  76.433 -    text = XtNameToWidget(cdata->comp.widget, "*Text");
  76.434 -    XtVaSetValues(text,
  76.435 -                  XmNfontList, fontlist,
  76.436 -                  NULL);
  76.437 -    XmFontListFree(fontlist);
  76.438 -    XtVaGetValues(cdata->comp.widget,
  76.439 -                  XmNx, &x,
  76.440 -                  XmNy, &y,
  76.441 -                  NULL);
  76.442 -    Java_sun_awt_motif_MChoicePeer_pReshape(env, this, x, y, 0, 0);
  76.443 -    AWT_UNLOCK();
  76.444 -}
  76.445 -
  76.446 -
  76.447 -/*
  76.448 - * Class:     sun_awt_motif_MChoicePeer
  76.449 - * Method:    freeNativeData
  76.450 - * Signature: ()V
  76.451 - */
  76.452 -JNIEXPORT void JNICALL
  76.453 -Java_sun_awt_motif_MChoicePeer_freeNativeData(JNIEnv *env, jobject this)
  76.454 -{
  76.455 -    /*
  76.456 -     * Fix for bug 4326619 - not necessary for Motif 2.1
  76.457 -     */
  76.458 -}
  76.459 -
  76.460 -
  76.461 -/*
  76.462 - * Class:     sun_awt_motif_MChoicePeer
  76.463 - * Method:    setBackground
  76.464 - * Signature: (Ljava/awt/Color;)V
  76.465 - */
  76.466 -JNIEXPORT void JNICALL
  76.467 -Java_sun_awt_motif_MChoicePeer_setBackground(JNIEnv *env, jobject this,
  76.468 -    jobject c)
  76.469 -{
  76.470 -    struct ChoiceData *cdata;
  76.471 -    Pixel bg;
  76.472 -    Pixel fg;
  76.473 -    int32_t i;
  76.474 -
  76.475 -    if (JNU_IsNull(env, c)) {
  76.476 -        JNU_ThrowNullPointerException(env, "NullPointerException: null color");
  76.477 -        return;
  76.478 -    }
  76.479 -    AWT_LOCK();
  76.480 -
  76.481 -    cdata = (struct ChoiceData *)
  76.482 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  76.483 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  76.484 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.485 -        AWT_UNLOCK();
  76.486 -        return;
  76.487 -    }
  76.488 -    /* Get background color */
  76.489 -    bg = awtJNI_GetColor(env, c);
  76.490 -
  76.491 -    /*
  76.492 -       XmChangeColor(), in addtion to changing the background and
  76.493 -       selection colors, also changes the foreground color to be
  76.494 -       what it thinks should be. However, we want to use the color
  76.495 -       that gets set by setForeground() instead. We therefore need to
  76.496 -       save the current foreground color here, and then set it again
  76.497 -       after the XmChangeColor() occurs.
  76.498 -    */
  76.499 -    XtVaGetValues(cdata->comp.widget, XmNforeground, &fg, NULL);
  76.500 -
  76.501 -    /* Set color */
  76.502 -    XmChangeColor(cdata->comp.widget, bg);
  76.503 -    XtVaSetValues(cdata->comp.widget, XmNforeground, fg, NULL);
  76.504 -
  76.505 -    AWT_FLUSH_UNLOCK();
  76.506 -}
  76.507 -
  76.508 -/*
  76.509 - * Class:     sun_awt_motif_MChoicePeer
  76.510 - * Method:    setForeground
  76.511 - * Signature: (Ljava/awt/Color;)V
  76.512 - */
  76.513 -JNIEXPORT void JNICALL
  76.514 -Java_sun_awt_motif_MChoicePeer_setForeground(JNIEnv *env, jobject this,
  76.515 -    jobject c)
  76.516 -{
  76.517 -    struct ChoiceData *cdata;
  76.518 -    Pixel color;
  76.519 -    int32_t i;
  76.520 -
  76.521 -    if (JNU_IsNull(env, c)) {
  76.522 -        JNU_ThrowNullPointerException(env, "NullPointerException: null color");
  76.523 -        return;
  76.524 -    }
  76.525 -    AWT_LOCK();
  76.526 -
  76.527 -    cdata = (struct ChoiceData *)
  76.528 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  76.529 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  76.530 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.531 -        AWT_UNLOCK();
  76.532 -        return;
  76.533 -    }
  76.534 -    color = awtJNI_GetColor(env, c);
  76.535 -
  76.536 -    XtVaSetValues(cdata->comp.widget, XmNforeground, color, NULL);
  76.537 -
  76.538 -    AWT_FLUSH_UNLOCK();
  76.539 -}
  76.540 -
  76.541 -/*
  76.542 - * Class:     sun_awt_motif_MChoicePeer
  76.543 - * Method:    pReshape
  76.544 - * Signature: (IIII)V
  76.545 - */
  76.546 -JNIEXPORT void JNICALL
  76.547 -Java_sun_awt_motif_MChoicePeer_pReshape(JNIEnv *env, jobject this,
  76.548 -    jint x, jint y, jint w, jint h)
  76.549 -{
  76.550 -    struct ChoiceData *cdata;
  76.551 -    Widget list;
  76.552 -    Dimension width = 0, height = 0;
  76.553 -    jclass clsDimension;
  76.554 -    jobject dimension;
  76.555 -    jobject target;
  76.556 -    Widget text=NULL;
  76.557 -
  76.558 -    AWT_LOCK();
  76.559 -
  76.560 -    cdata = (struct ChoiceData *)
  76.561 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  76.562 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  76.563 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.564 -        AWT_UNLOCK();
  76.565 -        return;
  76.566 -    }
  76.567 -
  76.568 -    if (w == 0) {
  76.569 -        /* Set the width and height of the TextField widget to the
  76.570 -         * PreferredSize, based on the font size.
  76.571 -        */
  76.572 -        clsDimension = (*env)->FindClass(env, "java/awt/Dimension");
  76.573 -        DASSERT(clsDimension != NULL);
  76.574 -        dimension = JNU_CallMethodByName(env, NULL,
  76.575 -                        this, "getPreferredSize", "()Ljava/awt/Dimension;").l;
  76.576 -        width  = (Dimension)((*env)->GetIntField(env, dimension,
  76.577 -                                 (*env)->GetFieldID(env, clsDimension,
  76.578 -                                     "width" , "I")));
  76.579 -        height = (Dimension)((*env)->GetIntField(env, dimension,
  76.580 -                                 (*env)->GetFieldID(env, clsDimension,
  76.581 -                                     "height", "I")));
  76.582 -    } else {
  76.583 -        /* Set the width and height of the TextField widget to the
  76.584 -         * given values. BorderLayout passes these values, for example.
  76.585 -        */
  76.586 -        width = w;
  76.587 -        height = h;
  76.588 -    }
  76.589 -    text = XtNameToWidget(cdata->comp.widget, "*Text");
  76.590 -    /*
  76.591 -     * Bug 4477410:  Setting the width of the XmComboBox made the XmTextField
  76.592 -     * too small, cutting off the dropdown list knob on the right side. Set
  76.593 -     * the width of the TextField because it is the widget actually seen.
  76.594 -    */
  76.595 -    XtVaSetValues(text,
  76.596 -                  XmNwidth, width,
  76.597 -                  XmNheight, height,
  76.598 -                  NULL);
  76.599 -
  76.600 -    awt_util_reshape(cdata->comp.widget, x, y, width, height);
  76.601 -
  76.602 -    list = XtNameToWidget(cdata->comp.widget, "*List");
  76.603 -
  76.604 -    XtVaSetValues(list, XmNwidth, width, NULL);
  76.605 -
  76.606 -    /* Set the width and height of the Choice component. */
  76.607 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  76.608 -    if (target == NULL) {
  76.609 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.610 -        AWT_UNLOCK();
  76.611 -        return;
  76.612 -    }
  76.613 -    (*env)->SetIntField(env, target, componentIDs.width, (jint)width);
  76.614 -    (*env)->SetIntField(env, target, componentIDs.height, (jint)height);
  76.615 -
  76.616 -    AWT_FLUSH_UNLOCK();
  76.617 -}
  76.618 -
  76.619 -
  76.620 -/*
  76.621 - * Class:     sun_awt_motif_MChoicePeer
  76.622 - * Method:    addItem
  76.623 - * Signature: (Ljava/lang/String;I)V
  76.624 - */
  76.625 -JNIEXPORT void JNICALL
  76.626 -Java_sun_awt_motif_MChoicePeer_addItem(JNIEnv *env, jobject this,
  76.627 -    jstring item, jint index)
  76.628 -{
  76.629 -    if (JNU_IsNull(env, item)) {
  76.630 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.631 -        return;
  76.632 -    }
  76.633 -    addItems(env, this, &item, 1, index);
  76.634 -}
  76.635 -
  76.636 -
  76.637 -/*
  76.638 - * Class:     sun_awt_motif_MChoicePeer
  76.639 - * Method:    appendItems
  76.640 - * Signature: ([Ljava/lang/String;)V
  76.641 - */
  76.642 -JNIEXPORT void JNICALL
  76.643 -Java_sun_awt_motif_MChoicePeer_appendItems(JNIEnv *env, jobject this,
  76.644 -    jarray items)
  76.645 -{
  76.646 -    struct ChoiceData *cdata = NULL;
  76.647 -    jstring *strItems = NULL;
  76.648 -    int32_t nItems, i;
  76.649 -
  76.650 -    if (JNU_IsNull(env, items)) {
  76.651 -        return;
  76.652 -    }
  76.653 -    nItems  = (*env)->GetArrayLength(env, items);
  76.654 -    if (nItems == 0) {
  76.655 -        return;
  76.656 -    }
  76.657 -
  76.658 -    AWT_LOCK();
  76.659 -
  76.660 -    cdata = (struct ChoiceData *)JNU_GetLongFieldAsPtr(env,
  76.661 -                this, mComponentPeerIDs.pData);
  76.662 -    if (cdata == NULL) {
  76.663 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.664 -        goto cleanup;
  76.665 -    }
  76.666 -
  76.667 -    strItems = (jstring *)malloc(sizeof(jstring) * nItems);
  76.668 -    if (strItems == NULL) {
  76.669 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.670 -        goto cleanup;
  76.671 -    }
  76.672 -
  76.673 -    for (i = 0; i < nItems; ++i) {
  76.674 -        strItems[i] = (jstring)(*env)->GetObjectArrayElement(env,
  76.675 -                                   items, (jsize)i);
  76.676 -        if (JNU_IsNull(env, strItems[i])) {
  76.677 -            JNU_ThrowNullPointerException(env, "NullPointerException");
  76.678 -            goto cleanup;
  76.679 -        }
  76.680 -    }
  76.681 -
  76.682 -    addItems(env, this, strItems, nItems, (jint)cdata->n_items);
  76.683 -
  76.684 -  cleanup:
  76.685 -    if (strItems != NULL) {
  76.686 -        free(strItems);
  76.687 -    }
  76.688 -    AWT_UNLOCK();
  76.689 -}
  76.690 -
  76.691 -
  76.692 -/*
  76.693 - * Class:     sun_awt_motif_MChoicePeer
  76.694 - * Method:    remove
  76.695 - * Signature: (I)V
  76.696 - */
  76.697 -JNIEXPORT void JNICALL
  76.698 -Java_sun_awt_motif_MChoicePeer_remove(JNIEnv *env, jobject this,
  76.699 -    jint index)
  76.700 -{
  76.701 -    struct ChoiceData *cdata;
  76.702 -    Widget list;
  76.703 -    Widget text=NULL;
  76.704 -
  76.705 -    AWT_LOCK();
  76.706 -
  76.707 -    cdata = (struct ChoiceData *)
  76.708 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  76.709 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  76.710 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.711 -        AWT_UNLOCK();
  76.712 -        return;
  76.713 -    }
  76.714 -
  76.715 -    XmComboBoxDeletePos(cdata->comp.widget, index + 1);
  76.716 -    --(cdata->n_items);
  76.717 -
  76.718 -    list = XtNameToWidget(cdata->comp.widget, "*List");
  76.719 -    XtVaSetValues(list, XmNvisibleItemCount, min(MAX_VISIBLE, cdata->n_items), NULL);
  76.720 -
  76.721 -    if (cdata->n_items == 0) {
  76.722 -        /* No item is selected, so clear the TextField. */
  76.723 -        text = XtNameToWidget(cdata->comp.widget, "*Text");
  76.724 -        XtVaSetValues(text, XmNvalue, "", NULL);
  76.725 -    }
  76.726 -
  76.727 -    AWT_UNLOCK();
  76.728 -}
  76.729 -
  76.730 -/*
  76.731 - * Class:     sun_awt_motif_MChoicePeer
  76.732 - * Method:    removeAll
  76.733 - * Signature: ()V
  76.734 - */
  76.735 -JNIEXPORT void JNICALL
  76.736 -Java_sun_awt_motif_MChoicePeer_removeAll(JNIEnv *env, jobject this)
  76.737 -{
  76.738 -    struct ChoiceData *cdata;
  76.739 -    int32_t i;
  76.740 -    Widget text=NULL;
  76.741 -    Widget list;
  76.742 -
  76.743 -    AWT_LOCK();
  76.744 -
  76.745 -    cdata = (struct ChoiceData *)
  76.746 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  76.747 -    if (cdata == NULL || cdata->comp.widget == NULL) {
  76.748 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  76.749 -        AWT_UNLOCK();
  76.750 -        return;
  76.751 -    }
  76.752 -
  76.753 -    for (i = cdata->n_items - 1; i >= 0; --i) {
  76.754 -        XmComboBoxDeletePos(cdata->comp.widget, i);
  76.755 -    }
  76.756 -    cdata->n_items = 0;
  76.757 -
  76.758 -    /* No item is selected, so clear the TextField. */
  76.759 -    text = XtNameToWidget(cdata->comp.widget, "*Text");
  76.760 -    XtVaSetValues(text, XmNvalue, "", NULL);
  76.761 -
  76.762 -    /* should set XmNvisibleItemCount to 1 as 0 is invalid value */
  76.763 -    list = XtNameToWidget(cdata->comp.widget, "*List");
  76.764 -    XtVaSetValues(list, XmNvisibleItemCount, 1, NULL);
  76.765 -
  76.766 -    AWT_UNLOCK();
  76.767 -}
    77.1 --- a/src/solaris/native/sun/awt/awt_Component.c	Wed Sep 17 13:45:37 2008 -0700
    77.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.3 @@ -1,1656 +0,0 @@
    77.4 -/*
    77.5 - * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
    77.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    77.7 - *
    77.8 - * This code is free software; you can redistribute it and/or modify it
    77.9 - * under the terms of the GNU General Public License version 2 only, as
   77.10 - * published by the Free Software Foundation.  Sun designates this
   77.11 - * particular file as subject to the "Classpath" exception as provided
   77.12 - * by Sun in the LICENSE file that accompanied this code.
   77.13 - *
   77.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   77.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   77.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   77.17 - * version 2 for more details (a copy is included in the LICENSE file that
   77.18 - * accompanied this code).
   77.19 - *
   77.20 - * You should have received a copy of the GNU General Public License version
   77.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   77.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   77.23 - *
   77.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   77.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   77.26 - * have any questions.
   77.27 - */
   77.28 -
   77.29 -#ifdef HEADLESS
   77.30 -#error This file should not be included in headless library
   77.31 -#endif
   77.32 -
   77.33 -#include "awt_p.h"
   77.34 -#include "canvas.h"
   77.35 -#include "awt_AWTEvent.h"
   77.36 -#include "VDrawingArea.h"
   77.37 -#include "awt_KeyboardFocusManager.h"
   77.38 -#include "awt_MToolkit.h"
   77.39 -#include "awt_TopLevel.h"
   77.40 -#include "java_awt_Color.h"
   77.41 -#include "java_awt_Cursor.h"
   77.42 -#include "java_awt_Font.h"
   77.43 -#include "java_awt_Point.h"
   77.44 -#include "java_awt_Component.h"
   77.45 -#include "java_awt_AWTEvent.h"
   77.46 -#include "java_awt_KeyboardFocusManager.h"
   77.47 -#include "java_awt_event_KeyEvent.h"
   77.48 -#include "java_awt_event_MouseEvent.h"
   77.49 -#include "sun_awt_motif_MComponentPeer.h"
   77.50 -
   77.51 -#include "multi_font.h"
   77.52 -#include "jni.h"
   77.53 -#include "jni_util.h"
   77.54 -#include <jawt.h>
   77.55 -#include <Xm/PrimitiveP.h>
   77.56 -#include <Xm/ManagerP.h>
   77.57 -#include <Xm/ComboBox.h>
   77.58 -
   77.59 -/* CanvasType widgets: Frame, Dialog, Window, Panel, Canvas,
   77.60 - *                     &  all lightweights (Component, Container)
   77.61 - */
   77.62 -#define IsCanvasTypeWidget(w) \
   77.63 -        XtIsSubclass(w, xmDrawingAreaWidgetClass) ||\
   77.64 -        XtIsSubclass(w, vDrawingAreaClass)
   77.65 -
   77.66 -
   77.67 -#include "awt_Component.h"
   77.68 -#include "awt_GraphicsEnv.h"
   77.69 -
   77.70 -#include "awt_AWTEvent.h"
   77.71 -#include "awt_Cursor.h"
   77.72 -
   77.73 -extern struct CursorIDs cursorIDs;
   77.74 -extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
   77.75 -extern struct KeyboardFocusManagerIDs keyboardFocusManagerIDs;
   77.76 -
   77.77 -/* fieldIDs for Component fields that may be accessed from C */
   77.78 -struct ComponentIDs componentIDs;
   77.79 -
   77.80 -/*
   77.81 - * Class:     java_awt_Component
   77.82 - * Method:    initIDs
   77.83 - * Signature: ()V
   77.84 - */
   77.85 -
   77.86 -/* This function gets called from the static initializer for Component.java
   77.87 -   to initialize the fieldIDs for fields that may be accessed from C */
   77.88 -
   77.89 -JNIEXPORT void JNICALL
   77.90 -Java_java_awt_Component_initIDs
   77.91 -(JNIEnv *env, jclass cls)
   77.92 -{
   77.93 -    jclass keyclass = NULL;
   77.94 -
   77.95 -    componentIDs.x = (*env)->GetFieldID(env, cls, "x", "I");
   77.96 -    componentIDs.y = (*env)->GetFieldID(env, cls, "y", "I");
   77.97 -    componentIDs.width = (*env)->GetFieldID(env, cls, "width", "I");
   77.98 -    componentIDs.height = (*env)->GetFieldID(env, cls, "height", "I");
   77.99 -    componentIDs.isPacked = (*env)->GetFieldID(env, cls, "isPacked", "Z");
  77.100 -    componentIDs.peer =
  77.101 -        (*env)->GetFieldID(env, cls, "peer", "Ljava/awt/peer/ComponentPeer;");
  77.102 -    componentIDs.background =
  77.103 -        (*env)->GetFieldID(env, cls, "background", "Ljava/awt/Color;");
  77.104 -    componentIDs.foreground =
  77.105 -        (*env)->GetFieldID(env, cls, "foreground", "Ljava/awt/Color;");
  77.106 -    componentIDs.graphicsConfig =
  77.107 -        (*env)->GetFieldID(env, cls, "graphicsConfig",
  77.108 -                           "Ljava/awt/GraphicsConfiguration;");
  77.109 -    componentIDs.name =
  77.110 -        (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;");
  77.111 -
  77.112 -    /* Use _NoClientCode() methods for trusted methods, so that we
  77.113 -     *  know that we are not invoking client code on trusted threads
  77.114 -     */
  77.115 -    componentIDs.getParent =
  77.116 -        (*env)->GetMethodID(env, cls, "getParent_NoClientCode",
  77.117 -                            "()Ljava/awt/Container;");
  77.118 -
  77.119 -    componentIDs.getLocationOnScreen =
  77.120 -        (*env)->GetMethodID(env, cls, "getLocationOnScreen_NoTreeLock",
  77.121 -                            "()Ljava/awt/Point;");
  77.122 -
  77.123 -    componentIDs.resetGCMID =
  77.124 -        (*env)->GetMethodID(env, cls, "resetGC", "()V");
  77.125 -
  77.126 -    keyclass = (*env)->FindClass(env, "java/awt/event/KeyEvent");
  77.127 -    DASSERT (keyclass != NULL);
  77.128 -
  77.129 -    componentIDs.isProxyActive =
  77.130 -        (*env)->GetFieldID(env, keyclass, "isProxyActive",
  77.131 -                           "Z");
  77.132 -
  77.133 -    componentIDs.appContext =
  77.134 -        (*env)->GetFieldID(env, cls, "appContext",
  77.135 -                           "Lsun/awt/AppContext;");
  77.136 -
  77.137 -    (*env)->DeleteLocalRef(env, keyclass);
  77.138 -
  77.139 -    DASSERT(componentIDs.resetGCMID);
  77.140 -}
  77.141 -
  77.142 -/* fieldIDs for MComponentPeer fields that may be accessed from C */
  77.143 -struct MComponentPeerIDs mComponentPeerIDs;
  77.144 -
  77.145 -/*
  77.146 - * Class:     sun_awt_motif_MComponentPeer
  77.147 - * Method:    initIDs
  77.148 - * Signature: ()V
  77.149 - */
  77.150 -
  77.151 -/* This function gets called from the static initializer for
  77.152 -   MComponentPeer.java to initialize the fieldIDs for fields that may
  77.153 -   be accessed from C */
  77.154 -
  77.155 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_initIDs
  77.156 -(JNIEnv *env, jclass cls)
  77.157 -{
  77.158 -    mComponentPeerIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J");
  77.159 -    mComponentPeerIDs.target =
  77.160 -        (*env)->GetFieldID(env, cls, "target", "Ljava/awt/Component;");
  77.161 -    mComponentPeerIDs.jniGlobalRef =
  77.162 -        (*env)->GetFieldID(env, cls, "jniGlobalRef", "J");
  77.163 -    mComponentPeerIDs.graphicsConfig =
  77.164 -        (*env)->GetFieldID(env, cls, "graphicsConfig",
  77.165 -                           "Lsun/awt/X11GraphicsConfig;");
  77.166 -    mComponentPeerIDs.drawState =
  77.167 -        (*env)->GetFieldID(env, cls, "drawState", "I");
  77.168 -    mComponentPeerIDs.isFocusableMID =
  77.169 -        (*env)->GetMethodID(env, cls, "isFocusable", "()Z");
  77.170 -}
  77.171 -
  77.172 -/* field and method IDs for java.awt.Container. */
  77.173 -struct ContainerIDs containerIDs;
  77.174 -
  77.175 -/*
  77.176 - * Class:     java_awt_Container
  77.177 - * Method:    initIDs
  77.178 - * Signature: ()V
  77.179 - */
  77.180 -/* This function gets called from the static initializer for java.awt.Container
  77.181 -   to initialize the fieldIDs for fields that may be accessed from C */
  77.182 -JNIEXPORT void JNICALL
  77.183 -Java_java_awt_Container_initIDs
  77.184 -(JNIEnv *env, jclass cls)
  77.185 -{
  77.186 -    containerIDs.layoutMgr =
  77.187 -        (*env)->GetFieldID(env, cls, "layoutMgr", "Ljava/awt/LayoutManager;");
  77.188 -
  77.189 -    containerIDs.getComponents =
  77.190 -        (*env)->GetMethodID(env, cls, "getComponents_NoClientCode",
  77.191 -                            "()[Ljava/awt/Component;");
  77.192 -    containerIDs.findComponentAt =
  77.193 -        (*env)->GetMethodID(env, cls, "findComponentAt",
  77.194 -                            "(IIZ)Ljava/awt/Component;");
  77.195 -}
  77.196 -
  77.197 -/*
  77.198 - * Fix for 4090493.  When Motif computes indicator size, it uses
  77.199 - * (effectively) XmTextExtents, so the size of the indicator depends
  77.200 - * on the text of the label.  The side effect is that if the label
  77.201 - * text is rendered using different platform fonts (for a single Java
  77.202 - * logical font) the display is inconsistent.  E.g. for 12pt font
  77.203 - * English label will have a check mark, while Japanese label will
  77.204 - * not, because underlying X11 fonts have different metrics.
  77.205 - *
  77.206 - * The fix is to override Motif calculations for the indicatorSize and
  77.207 - * compute it ourselves based on the font metrics for all the platform
  77.208 - * fonts given Java font maps onto.  Every time we set XmNfontList we
  77.209 - * should set XmNindicatorSize as well.
  77.210 - *
  77.211 - * The logic is in awt_computeIndicatorSize that just compute the
  77.212 - * arithmetic mean of platform fonts by now.  HIE should take a look
  77.213 - * at this.
  77.214 - */
  77.215 -
  77.216 -struct changeFontInfo {
  77.217 -    XmFontList fontList;        /* value to set */
  77.218 -    Boolean isMultiFont;        /* only need to compute for multifont */
  77.219 -    struct FontData *fontData;  /* need this to compute indicator size */
  77.220 -    Dimension indSize;          /* computed once by changeFont */
  77.221 -
  77.222 -    Boolean    initialized;
  77.223 -    Boolean    error;
  77.224 -    JNIEnv     *env;
  77.225 -    jobject    fObj;
  77.226 -};
  77.227 -
  77.228 -static void
  77.229 -changeFont(Widget w, void *info)
  77.230 -{
  77.231 -    struct changeFontInfo *f = (struct changeFontInfo *)info;
  77.232 -    WidgetClass widgetClass;
  77.233 -
  77.234 -    if (f->error)
  77.235 -        return;
  77.236 -
  77.237 -    /* Some widgets use no fonts - skip them! */
  77.238 -    /* Also skip the Text widgets, since they each have their own setFont. */
  77.239 -    widgetClass = XtClass(w);
  77.240 -    if (widgetClass == xmDrawingAreaWidgetClass    ||
  77.241 -        widgetClass == xmScrollBarWidgetClass      ||
  77.242 -        widgetClass == xmScrolledWindowWidgetClass ||
  77.243 -        widgetClass == xmComboBoxWidgetClass       ||
  77.244 -        widgetClass == xmTextWidgetClass           ||
  77.245 -        widgetClass == xmTextFieldWidgetClass)
  77.246 -        return;
  77.247 -
  77.248 -    if (!f->initialized) {
  77.249 -        struct FontData *fdata;
  77.250 -        char *err;
  77.251 -
  77.252 -        f->initialized = TRUE;
  77.253 -
  77.254 -        fdata = awtJNI_GetFontData(f->env, f->fObj, &err);
  77.255 -        if (fdata == NULL) {
  77.256 -            JNU_ThrowInternalError(f->env, err);
  77.257 -            f->error = TRUE;
  77.258 -            return;
  77.259 -        }
  77.260 -
  77.261 -        if (awtJNI_IsMultiFont(f->env, f->fObj)) {
  77.262 -            f->fontList = awtJNI_GetFontList(f->env, f->fObj);
  77.263 -            f->isMultiFont = TRUE;
  77.264 -        } else {
  77.265 -            f->fontList = XmFontListCreate(fdata->xfont, "labelFont");
  77.266 -            f->isMultiFont = FALSE;
  77.267 -        }
  77.268 -
  77.269 -        if (f->fontList == NULL) {
  77.270 -            JNU_ThrowNullPointerException(f->env, "NullPointerException");
  77.271 -            f->error = TRUE;
  77.272 -            return;
  77.273 -        }
  77.274 -    }
  77.275 -
  77.276 -    /* Fix for 4090493. */
  77.277 -    if (f->isMultiFont && XmIsToggleButton(w)) {
  77.278 -        Dimension indSize;
  77.279 -
  77.280 -        /* Compute indicator size if first time through.  Note that
  77.281 -           ToggleButtons that are children of menus live in different
  77.282 -           hierarchy (MenuComponent), so we don't check for this case
  77.283 -           here.  In fact, the only time the XmNfontList is set on
  77.284 -           MCheckboxMenuItemPeer widget is when it is created. */
  77.285 -        if (f->indSize == 0)
  77.286 -            f->indSize = awt_computeIndicatorSize(f->fontData);
  77.287 -
  77.288 -        XtVaSetValues(w, XmNfontList, f->fontList, NULL);
  77.289 -        if (f->indSize != MOTIF_XmINVALID_DIMENSION)
  77.290 -            XtVaSetValues(w, XmNindicatorSize, f->indSize, NULL);
  77.291 -    }
  77.292 -    else {                      /* usual case */
  77.293 -        XtVaSetValues(w, XmNfontList, f->fontList, NULL);
  77.294 -    }
  77.295 -}
  77.296 -
  77.297 -static void
  77.298 -changeForeground(Widget w, void *fg)
  77.299 -{
  77.300 -    XtVaSetValues(w, XmNforeground, fg, NULL);
  77.301 -}
  77.302 -
  77.303 -static void
  77.304 -changeBackground(Widget w, void *bg)
  77.305 -{
  77.306 -    Pixel fg;
  77.307 -
  77.308 -    XtVaGetValues(w, XmNforeground, &fg, NULL);
  77.309 -    XmChangeColor(w, (Pixel) bg);
  77.310 -    XtVaSetValues(w, XmNforeground, fg, NULL);
  77.311 -}
  77.312 -
  77.313 -// Sets widget's traversalOn property into value 'value'
  77.314 -void setTraversal(Widget w, Boolean value) {
  77.315 -    if (w == NULL) {
  77.316 -        return;
  77.317 -    }
  77.318 -    if (XmIsPrimitive(w)) {
  77.319 -        XmPrimitiveWidget prim = (XmPrimitiveWidget)w;
  77.320 -        prim->primitive.traversal_on = value;
  77.321 -    } else
  77.322 -        if (XmIsManager(w)) {
  77.323 -            XmManagerWidget man = (XmManagerWidget)w;
  77.324 -            man->manager.traversal_on = value;
  77.325 -        }
  77.326 -}
  77.327 -
  77.328 -
  77.329 -AwtGraphicsConfigDataPtr
  77.330 -getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this) {
  77.331 -    AwtGraphicsConfigDataPtr adata;
  77.332 -    jobject gc_object;
  77.333 -
  77.334 -    /* GraphicsConfiguration object of MComponentPeer */
  77.335 -    gc_object = (*env)->GetObjectField(env, this,
  77.336 -                                       mComponentPeerIDs.graphicsConfig);
  77.337 -
  77.338 -    if (gc_object != NULL) {
  77.339 -        adata = (AwtGraphicsConfigDataPtr)
  77.340 -            JNU_GetLongFieldAsPtr(env, gc_object,
  77.341 -                                  x11GraphicsConfigIDs.aData);
  77.342 -    } else {
  77.343 -        adata = getDefaultConfig(DefaultScreen(awt_display));
  77.344 -    }
  77.345 -
  77.346 -    return adata;
  77.347 -}
  77.348 -
  77.349 -AwtGraphicsConfigDataPtr
  77.350 -copyGraphicsConfigToPeer(JNIEnv *env, jobject this) {
  77.351 -
  77.352 -    jobject component_object, gc_object;
  77.353 -    AwtGraphicsConfigDataPtr adata;
  77.354 -
  77.355 -    /**
  77.356 -     * Copy the GraphicsConfiguration object from Component object to
  77.357 -     * MComponentPeer object.
  77.358 -     */
  77.359 -    component_object = (*env)->GetObjectField(env, this,
  77.360 -                                              mComponentPeerIDs.target);
  77.361 -    /* GraphicsConfiguration object of Component */
  77.362 -    gc_object = (JNU_CallMethodByName(env, NULL, component_object,
  77.363 -                                      "getGraphicsConfiguration",
  77.364 -                                      "()Ljava/awt/GraphicsConfiguration;")).l;
  77.365 -
  77.366 -    if (gc_object != NULL) {
  77.367 -        /* Set graphicsConfig field of MComponentPeer */
  77.368 -        (*env)->SetObjectField (env, this,
  77.369 -                                mComponentPeerIDs.graphicsConfig,
  77.370 -                                gc_object);
  77.371 -        adata = (AwtGraphicsConfigDataPtr)
  77.372 -            JNU_GetLongFieldAsPtr(env, gc_object,
  77.373 -                                  x11GraphicsConfigIDs.aData);
  77.374 -    } else {
  77.375 -        /* Component was not constructed with a GraphicsConfiguration
  77.376 -           object */
  77.377 -        adata = getDefaultConfig(DefaultScreen(awt_display));
  77.378 -    }
  77.379 -
  77.380 -    return adata;
  77.381 -}
  77.382 -
  77.383 -/*
  77.384 - * Class:     sun_awt_motif_MComponentPeer
  77.385 - * Method:    getNativeColor
  77.386 - * Signature  (Ljava/awt/Color;Ljava/awt/GraphicsConfiguration;)I
  77.387 - */
  77.388 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MComponentPeer_getNativeColor
  77.389 -(JNIEnv *env, jobject this, jobject color, jobject gc_object) {
  77.390 -    AwtGraphicsConfigDataPtr adata;
  77.391 -    adata = (AwtGraphicsConfigDataPtr) JNU_GetLongFieldAsPtr(env, gc_object,
  77.392 -                                                             x11GraphicsConfigIDs.aData);
  77.393 -    return awtJNI_GetColorForVis(env, color, adata);
  77.394 -}
  77.395 -
  77.396 -/*
  77.397 - * Class:     sun_awt_motif_MComponentPeer
  77.398 - * Method:    pInitialize
  77.399 - * Signature: ()V
  77.400 - */
  77.401 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pInitialize
  77.402 -(JNIEnv *env, jobject this)
  77.403 -{
  77.404 -    struct ComponentData *cdata;
  77.405 -    Widget parent;
  77.406 -    jobject target;
  77.407 -    jobject globalRef;
  77.408 -    EventMask xtMask;
  77.409 -    jlong awtMask = (jlong) 0;
  77.410 -    AwtGraphicsConfigDataPtr adata;
  77.411 -    Boolean initialTraversal = False;
  77.412 -
  77.413 -    globalRef = (jobject)
  77.414 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.jniGlobalRef);
  77.415 -
  77.416 -    adata = copyGraphicsConfigToPeer(env, this);
  77.417 -
  77.418 -    AWT_LOCK();
  77.419 -
  77.420 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  77.421 -
  77.422 -    cdata = (struct ComponentData *)
  77.423 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.424 -    if (JNU_IsNull(env, cdata) || (cdata == NULL)) {
  77.425 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.426 -        AWT_UNLOCK();
  77.427 -        return;
  77.428 -    }
  77.429 -    /* Allow FileDialog to have its own traversal policy because
  77.430 -     * it doesn't interfer with our.
  77.431 -     */
  77.432 -    if (XtIsSubclass(cdata->widget, xmFileSelectionBoxWidgetClass)) {
  77.433 -        initialTraversal = True;
  77.434 -    }
  77.435 -    XtVaSetValues(cdata->widget,
  77.436 -                  XmNx, (*env)->GetIntField(env, target, componentIDs.x),
  77.437 -                  XmNy, (*env)->GetIntField(env, target, componentIDs.y),
  77.438 -                  XmNvisual, adata->awt_visInfo.visual,
  77.439 -                  XmNscreen, ScreenOfDisplay(awt_display,
  77.440 -                                             adata->awt_visInfo.screen),
  77.441 -                  /**
  77.442 -                   * From now we keep all but the focus owner widget unable
  77.443 -                   * to receive focus. This will prevent Motif from unexpected
  77.444 -                   * focus transfers.
  77.445 -                   */
  77.446 -                  XmNtraversalOn, initialTraversal,
  77.447 -                  NULL);
  77.448 -
  77.449 -
  77.450 -    /* For all but canvas-style components, pre-process
  77.451 -     * mouse and keyboard events (which means posting them
  77.452 -     * to the Java EventQueue before dispatching them to Xt).
  77.453 -     * For canvas-style components ONLY pre-process mouse events
  77.454 -     * because the input-method currently relies on key events
  77.455 -     * being processed by Xt first.
  77.456 -     */
  77.457 -    awtMask = java_awt_AWTEvent_MOUSE_EVENT_MASK |
  77.458 -        java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK;
  77.459 -    xtMask = ExposureMask | FocusChangeMask;
  77.460 -
  77.461 -    if (!IsCanvasTypeWidget(cdata->widget)) {
  77.462 -        awtMask |= java_awt_AWTEvent_KEY_EVENT_MASK;
  77.463 -    } else {
  77.464 -        xtMask |= (KeyPressMask | KeyReleaseMask);
  77.465 -    }
  77.466 -    XtAddEventHandler(cdata->widget, xtMask,
  77.467 -                      True, awt_canvas_event_handler, globalRef);
  77.468 -
  77.469 -    awt_addWidget(cdata->widget, cdata->widget, globalRef, awtMask);
  77.470 -
  77.471 -    cdata->repaintPending = RepaintPending_NONE;
  77.472 -
  77.473 -    AWT_UNLOCK();
  77.474 -}
  77.475 -
  77.476 -/**
  77.477 - * Updates stacking order of X windows according to the order of children widgets in
  77.478 - * parent widget
  77.479 - */
  77.480 -void restack(Widget parent) {
  77.481 -    WidgetList children;
  77.482 -    int32_t num_children;
  77.483 -    Window *windows;
  77.484 -    int32_t num_windows = 0;
  77.485 -    int32_t i;
  77.486 -    XtVaGetValues(parent,
  77.487 -                  XmNnumChildren, &num_children,
  77.488 -                  XmNchildren, &children,
  77.489 -                  NULL);
  77.490 -
  77.491 -    windows = (Window *) XtMalloc(num_children * sizeof(Window));
  77.492 -    for (i = 0; i < num_children; i++) {
  77.493 -        if (XtIsRealized(children[i])) {
  77.494 -            windows[num_windows++] = XtWindow(children[i]);
  77.495 -        }
  77.496 -    }
  77.497 -    XRestackWindows(awt_display, windows, num_windows);
  77.498 -    XtFree((char *) windows);
  77.499 -}
  77.500 -
  77.501 -/*
  77.502 - * Class:     sun_awt_motif_MComponentPeer
  77.503 - * Method:    pShow
  77.504 - * Signature: ()V
  77.505 - */
  77.506 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pShow
  77.507 -(JNIEnv *env, jobject this)
  77.508 -{
  77.509 -    struct ComponentData *cdata;
  77.510 -
  77.511 -    AWT_LOCK();
  77.512 -    cdata = (struct ComponentData *)
  77.513 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.514 -    if (cdata == NULL || cdata->widget == NULL) {
  77.515 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.516 -        AWT_UNLOCK();
  77.517 -        return;
  77.518 -    }
  77.519 -
  77.520 -    awt_util_show(cdata->widget);
  77.521 -
  77.522 -    AWT_FLUSH_UNLOCK();
  77.523 -}
  77.524 -
  77.525 -/*
  77.526 - * Class:     sun_awt_motif_MComponentPeer
  77.527 - * Method:    pHide
  77.528 - * Signature: ()V
  77.529 - */
  77.530 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pHide
  77.531 -(JNIEnv *env, jobject this)
  77.532 -{
  77.533 -    struct ComponentData *cdata;
  77.534 -
  77.535 -    AWT_LOCK();
  77.536 -    cdata = (struct ComponentData *)
  77.537 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.538 -    if (cdata == NULL || cdata->widget == NULL) {
  77.539 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.540 -        AWT_UNLOCK();
  77.541 -        return;
  77.542 -    }
  77.543 -
  77.544 -    awt_util_hide(cdata->widget);
  77.545 -    AWT_FLUSH_UNLOCK();
  77.546 -}
  77.547 -
  77.548 -/*
  77.549 - * Class:     sun_awt_motif_MComponentPeer
  77.550 - * Method:    pEnable
  77.551 - * Signature: ()V
  77.552 - */
  77.553 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pEnable
  77.554 -(JNIEnv *env, jobject this)
  77.555 -{
  77.556 -    struct ComponentData *cdata;
  77.557 -
  77.558 -    AWT_LOCK();
  77.559 -    cdata = (struct ComponentData *)
  77.560 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.561 -    if (cdata == NULL || cdata->widget == NULL) {
  77.562 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.563 -        AWT_UNLOCK();
  77.564 -        return;
  77.565 -    }
  77.566 -    awt_util_enable(cdata->widget);
  77.567 -    AWT_UNLOCK();
  77.568 -}
  77.569 -
  77.570 -/*
  77.571 - * Class:     sun_awt_motif_MComponentPeer
  77.572 - * Method:    pDisable
  77.573 - * Signature: ()V
  77.574 - */
  77.575 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pDisable
  77.576 -(JNIEnv *env, jobject this)
  77.577 -{
  77.578 -    struct ComponentData *cdata;
  77.579 -
  77.580 -    AWT_LOCK();
  77.581 -    cdata = (struct ComponentData *)
  77.582 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.583 -    if (cdata == NULL || cdata->widget == NULL) {
  77.584 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.585 -        AWT_UNLOCK();
  77.586 -        return;
  77.587 -    }
  77.588 -    awt_util_disable(cdata->widget);
  77.589 -    AWT_FLUSH_UNLOCK();
  77.590 -}
  77.591 -
  77.592 -/*
  77.593 - * Class:     sun_awt_motif_MComponentPeer
  77.594 - * Method:    pReshape
  77.595 - * Signature: (IIII)V
  77.596 - */
  77.597 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pReshape
  77.598 -(JNIEnv *env, jobject this, jint x, jint y, jint w, jint h)
  77.599 -{
  77.600 -    struct ComponentData *cdata;
  77.601 -    jint drawState;
  77.602 -
  77.603 -    AWT_LOCK();
  77.604 -    cdata = (struct ComponentData *)
  77.605 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.606 -    if (cdata == NULL || cdata->widget == NULL) {
  77.607 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.608 -        AWT_UNLOCK();
  77.609 -        return;
  77.610 -    }
  77.611 -    /* Set the draw state */
  77.612 -    drawState = (*env)->GetIntField(env, this,
  77.613 -                                    mComponentPeerIDs.drawState);
  77.614 -    (*env)->SetIntField(env, this,
  77.615 -                        mComponentPeerIDs.drawState,
  77.616 -                        drawState | JAWT_LOCK_BOUNDS_CHANGED | JAWT_LOCK_CLIP_CHANGED);
  77.617 -    awt_util_reshape(cdata->widget, x, y, w, h);
  77.618 -
  77.619 -    AWT_FLUSH_UNLOCK();
  77.620 -}
  77.621 -
  77.622 -/*
  77.623 - * Class:     sun_awt_motif_MComponentPeer
  77.624 - * Method:    pDispose
  77.625 - * Signature: ()V
  77.626 - */
  77.627 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pDispose
  77.628 -(JNIEnv *env, jobject this)
  77.629 -{
  77.630 -    struct ComponentData *cdata;
  77.631 -
  77.632 -    AWT_LOCK();
  77.633 -    cdata = (struct ComponentData *)
  77.634 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.635 -    if (cdata == NULL || cdata->widget == NULL) {
  77.636 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.637 -        AWT_UNLOCK();
  77.638 -        return;
  77.639 -    }
  77.640 -
  77.641 -    XtUnmanageChild(cdata->widget);
  77.642 -
  77.643 -    awt_delWidget(cdata->widget);
  77.644 -    awt_util_consumeAllXEvents(cdata->widget);
  77.645 -    awt_util_cleanupBeforeDestroyWidget(cdata->widget);
  77.646 -    XtDestroyWidget(cdata->widget);
  77.647 -
  77.648 -    free((void *) cdata);
  77.649 -    (*env)->SetLongField(env,this,mComponentPeerIDs.pData, (int64_t) 0);
  77.650 -
  77.651 -    awtJNI_DeleteGlobalRef(env, this);
  77.652 -
  77.653 -    AWT_UNLOCK();
  77.654 -}
  77.655 -
  77.656 -/*
  77.657 - * Class:     sun_awt_motif_MComponentPeer
  77.658 - * Method:    pMakeCursorVisible
  77.659 - * Signature: ()V
  77.660 - */
  77.661 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible
  77.662 -(JNIEnv *env, jobject this)
  77.663 -{
  77.664 -    struct ComponentData *cdata;
  77.665 -
  77.666 -    AWT_LOCK();
  77.667 -    cdata = (struct ComponentData *)
  77.668 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.669 -    if (cdata == NULL || cdata->widget == NULL) {
  77.670 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.671 -        AWT_UNLOCK();
  77.672 -        return;
  77.673 -    }
  77.674 -    // need to change, may not be needed
  77.675 -    // awt_util_setCursor(cdata->widget, cdata->cursor);
  77.676 -
  77.677 -    AWT_FLUSH_UNLOCK();
  77.678 -}
  77.679 -
  77.680 -
  77.681 -/*
  77.682 - * Call with AWT_LOCK held.
  77.683 - */
  77.684 -static jobject
  77.685 -MComponentPeer_doGetLocationOnScreen(JNIEnv *env, jobject this)
  77.686 -{
  77.687 -    jobject point = NULL;
  77.688 -    struct ComponentData *cdata;
  77.689 -    int32_t x = 0, y = 0;
  77.690 -    Screen *widget_screen = NULL;
  77.691 -    Window child_ignored;
  77.692 -
  77.693 -    cdata = (struct ComponentData *)
  77.694 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  77.695 -    if (cdata == NULL || cdata->widget == NULL) {
  77.696 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.697 -        return NULL;
  77.698 -    }
  77.699 -    if (!XtIsRealized(cdata->widget)) {
  77.700 -        JNU_ThrowInternalError(env, "widget not visible on screen");
  77.701 -        return NULL;
  77.702 -    }
  77.703 -
  77.704 -    /* Translate the component to the screen coordinate system */
  77.705 -    XtVaGetValues(cdata->widget, XmNscreen, &widget_screen, NULL);
  77.706 -    XTranslateCoordinates(awt_display, XtWindow(cdata->widget),
  77.707 -                          XRootWindowOfScreen(widget_screen),
  77.708 -                          0, 0, &x, &y,
  77.709 -                          &child_ignored);
  77.710 -
  77.711 -    point = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
  77.712 -                                (jint)x, (jint)y);
  77.713 -    if (((*env)->ExceptionOccurred(env)) || JNU_IsNull(env, point)) {
  77.714 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.715 -        return NULL;
  77.716 -    }
  77.717 -
  77.718 -    return point;
  77.719 -}
  77.720 -
  77.721 -
  77.722 -/*
  77.723 - * Class:     sun_awt_motif_MComponentPeer
  77.724 - * Method:    pGetLocationOnScreen
  77.725 - * Signature: ()Ljava/awt/Point;
  77.726 - */
  77.727 -JNIEXPORT jobject JNICALL
  77.728 -Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen(JNIEnv *env,
  77.729 -                                                       jobject this)
  77.730 -{
  77.731 -    jobject point;
  77.732 -
  77.733 -    AWT_LOCK();
  77.734 -    point = MComponentPeer_doGetLocationOnScreen(env, this);
  77.735 -    AWT_UNLOCK();
  77.736 -    return point;
  77.737 -}
  77.738 -
  77.739 -
  77.740 -/*
  77.741 - * Class:     sun_awt_motif_MComponentPeer
  77.742 - * Method:    pGetLocationOnScreen
  77.743 - * Signature: (Ljava/awt/Window;Lsun/awt/motif/MWindowPeer;)Ljava/awt/Point;
  77.744 - */
  77.745 -JNIEXPORT jobject JNICALL
  77.746 -Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2(
  77.747 -    JNIEnv *env, jobject this, jobject wtarget, jobject wpeer)
  77.748 -{
  77.749 -    jobject point;
  77.750 -    struct ComponentData *cdata;
  77.751 -    struct FrameData *wdata;
  77.752 -    Screen *widget_screen = NULL;
  77.753 -    Window child_ignored;
  77.754 -    int32_t x = 0, y = 0;
  77.755 -
  77.756 -    AWT_LOCK();
  77.757 -
  77.758 -    wdata = (struct ComponentData *)
  77.759 -        JNU_GetLongFieldAsPtr(env, wpeer, mComponentPeerIDs.pData);
  77.760 -
  77.761 -    if (wdata == NULL || wdata->winData.comp.widget == NULL) {
  77.762 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.763 -        AWT_UNLOCK();
  77.764 -        return NULL;
  77.765 -    }
  77.766 -    if (!XtIsRealized(wdata->winData.comp.widget)) {
  77.767 -        JNU_ThrowInternalError(env, "widget not visible on screen");
  77.768 -        AWT_UNLOCK();
  77.769 -        return NULL;
  77.770 -    }
  77.771 -
  77.772 -    /*
  77.773 -     * Translate directly if the parent window is already adopted by WM.
  77.774 -     */
  77.775 -    if (wdata->configure_seen) {
  77.776 -        point = MComponentPeer_doGetLocationOnScreen(env, this);
  77.777 -        AWT_UNLOCK();
  77.778 -        return point;
  77.779 -    }
  77.780 -
  77.781 -    /*
  77.782 -     * We are called while the parent window is still not adopted by
  77.783 -     * WM (but may already be in the process of being reparented).
  77.784 -     * Translate to the parent and add parent target's (x,y) to avoid
  77.785 -     * racing with WM shuffling us into the final position.
  77.786 -     */
  77.787 -    cdata = (struct ComponentData *)
  77.788 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  77.789 -
  77.790 -    if (cdata == &wdata->winData.comp) { /* called for the window itself */
  77.791 -        x = y = 0;
  77.792 -    }
  77.793 -    else {
  77.794 -        if (cdata == NULL || cdata->widget == NULL) {
  77.795 -            JNU_ThrowNullPointerException(env, "NullPointerException");
  77.796 -            AWT_UNLOCK();
  77.797 -            return NULL;
  77.798 -        }
  77.799 -        if (!XtIsRealized(cdata->widget)) {
  77.800 -            JNU_ThrowInternalError(env, "widget not visible on screen");
  77.801 -            AWT_UNLOCK();
  77.802 -            return NULL;
  77.803 -        }
  77.804 -
  77.805 -        /* Translate to the outer canvas coordinate system first */
  77.806 -        XtVaGetValues(cdata->widget, XmNscreen, &widget_screen, NULL);
  77.807 -        XTranslateCoordinates(awt_display, XtWindow(cdata->widget),
  77.808 -                              XtWindow(wdata->winData.comp.widget),
  77.809 -                              0, 0, &x, &y,
  77.810 -                              &child_ignored);
  77.811 -    }
  77.812 -
  77.813 -    x += (*env)->GetIntField(env, wtarget, componentIDs.x);
  77.814 -    y += (*env)->GetIntField(env, wtarget, componentIDs.y);
  77.815 -
  77.816 -    point = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
  77.817 -                                (jint)x, (jint)y);
  77.818 -    if (((*env)->ExceptionOccurred(env)) || JNU_IsNull(env, point)) {
  77.819 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.820 -        AWT_UNLOCK();
  77.821 -        return NULL;
  77.822 -    }
  77.823 -
  77.824 -    AWT_UNLOCK();
  77.825 -    return point;
  77.826 -}
  77.827 -
  77.828 -
  77.829 -/*
  77.830 - * Class:     sun_awt_motif_MComponentPeer
  77.831 - * Method:    getParent_NoClientCode
  77.832 - * Signature: (Ljava/awt/Component)Ljava/awt/Container;
  77.833 - *
  77.834 - * NOTE: This method may be called by privileged threads.
  77.835 - *       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  77.836 - */
  77.837 -JNIEXPORT jobject JNICALL Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode
  77.838 -(JNIEnv *env, jclass thisClass, jobject component)
  77.839 -{
  77.840 -    jobject parent = NULL;
  77.841 -
  77.842 -    /* getParent is actually getParent_NoClientCode() */
  77.843 -    parent = (*env)->CallObjectMethod(env,component,componentIDs.getParent);
  77.844 -    DASSERT(!((*env)->ExceptionOccurred(env)));
  77.845 -    return parent;
  77.846 -}
  77.847 -
  77.848 -/*
  77.849 - * Class:     sun_awt_motif_MComponentPeer
  77.850 - * Method:    getComponents_NoClientCode
  77.851 - * Signature: (Ljava/awt/Container)[Ljava/awt/Component;
  77.852 - *               REMIND: Signature is incorrect for returned array value
  77.853 - *
  77.854 - * NOTE: This method may be called by privileged threads.
  77.855 - *       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
  77.856 - */
  77.857 -JNIEXPORT jobjectArray JNICALL Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode
  77.858 -(JNIEnv *env, jclass thisClass, jobject container)
  77.859 -{
  77.860 -    jobjectArray contents = NULL;
  77.861 -    contents = (*env)->CallObjectMethod(
  77.862 -        env, container, containerIDs.getComponents);
  77.863 -    DASSERT(!((*env)->ExceptionOccurred(env)));
  77.864 -    return contents;
  77.865 -}
  77.866 -
  77.867 -/*
  77.868 - * Class:     sun_awt_motif_MComponentPeer
  77.869 - * Method:    pSetForeground
  77.870 - * Signature: (Ljava/awt/Color;)V
  77.871 - */
  77.872 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetForeground
  77.873 -(JNIEnv *env, jobject this, jobject c)
  77.874 -{
  77.875 -    struct ComponentData *bdata;
  77.876 -    Pixel color;
  77.877 -    AwtGraphicsConfigDataPtr adata;
  77.878 -
  77.879 -    if (JNU_IsNull(env, c)) {
  77.880 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.881 -        return;
  77.882 -    }
  77.883 -    AWT_LOCK();
  77.884 -    bdata = (struct ComponentData *)
  77.885 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.886 -    if (bdata == NULL || bdata->widget == NULL) {
  77.887 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.888 -        AWT_UNLOCK();
  77.889 -        return;
  77.890 -    }
  77.891 -
  77.892 -    adata = getGraphicsConfigFromComponentPeer(env, this);
  77.893 -
  77.894 -    color = (Pixel) awtJNI_GetColorForVis (env, c, adata);
  77.895 -    XtVaSetValues(bdata->widget, XmNforeground, color, NULL);
  77.896 -    AWT_FLUSH_UNLOCK();
  77.897 -}
  77.898 -
  77.899 -/*
  77.900 - * Class:     sun_awt_motif_MComponentPeer
  77.901 - * Method:    pSetBackground
  77.902 - * Signature: (Ljava/awt/Color;)V
  77.903 - */
  77.904 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetBackground
  77.905 -(JNIEnv *env, jobject this, jobject c)
  77.906 -{
  77.907 -    struct ComponentData *bdata;
  77.908 -    Pixel color;
  77.909 -    Pixel fg;
  77.910 -    AwtGraphicsConfigDataPtr adata;
  77.911 -
  77.912 -    if (JNU_IsNull(env, c)) {
  77.913 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.914 -        return;
  77.915 -    }
  77.916 -    AWT_LOCK();
  77.917 -    bdata = (struct ComponentData *)
  77.918 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.919 -    if (bdata == NULL || bdata->widget == NULL) {
  77.920 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.921 -        AWT_UNLOCK();
  77.922 -        return;
  77.923 -    }
  77.924 -
  77.925 -    adata = getGraphicsConfigFromComponentPeer(env, this);
  77.926 -
  77.927 -    color = (Pixel) awtJNI_GetColorForVis (env, c, adata);
  77.928 -    XtVaGetValues(bdata->widget, XmNforeground, &fg, NULL);
  77.929 -    XmChangeColor(bdata->widget, color);
  77.930 -    XtVaSetValues(bdata->widget, XmNforeground, fg, NULL);
  77.931 -    AWT_FLUSH_UNLOCK();
  77.932 -}
  77.933 -
  77.934 -/*
  77.935 - * Class:     sun_awt_motif_MComponentPeer
  77.936 - * Method:    pSetScrollbarBackground
  77.937 - * Signature: (Ljava/awt/Color;)V
  77.938 - */
  77.939 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground
  77.940 -(JNIEnv *env, jobject this, jobject c)
  77.941 -{
  77.942 -    struct ComponentData *bdata;
  77.943 -    Pixel color;
  77.944 -    Pixel fg;
  77.945 -    int32_t                 i;
  77.946 -    WidgetList          wlist;
  77.947 -    Cardinal            wlen = 0;
  77.948 -
  77.949 -    /* This method propagates the specified background color to the scrollbars in the composite widget.
  77.950 -     * Used to set background scrollbar color in List, TextArea, ScrollPane to its parent.
  77.951 -     */
  77.952 -    if (JNU_IsNull(env, c)) {
  77.953 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.954 -        return;
  77.955 -    }
  77.956 -    AWT_LOCK();
  77.957 -    bdata = (struct ComponentData *)
  77.958 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  77.959 -    if (bdata == NULL || bdata->widget == NULL) {
  77.960 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  77.961 -        AWT_UNLOCK();
  77.962 -        return;
  77.963 -    }
  77.964 -    if (!XtIsComposite(bdata->widget)) {
  77.965 -        AWT_UNLOCK();
  77.966 -        return;
  77.967 -    }
  77.968 -    color = (Pixel) awtJNI_GetColor(env, c);
  77.969 -
  77.970 -    XtVaGetValues(bdata->widget,
  77.971 -                  XmNchildren, &wlist,
  77.972 -                  XmNnumChildren, &wlen,
  77.973 -                  NULL);
  77.974 -    if (wlen > 0) { /* this test doesn't make much sense, since wlen
  77.975 -                       is a Cardinal and cardinal is unsigned int... */
  77.976 -        for (i=0; i < wlen; i++) {
  77.977 -            if (XtIsSubclass(wlist[i], xmScrollBarWidgetClass)) {
  77.978 -                XtVaGetValues(wlist[i], XmNforeground, &fg, NULL);
  77.979 -                XmChangeColor(wlist[i], color);
  77.980 -                XtVaSetValues(wlist[i], XmNforeground, fg, NULL);
  77.981 -            }
  77.982 -        }
  77.983 -        XtVaGetValues(bdata->widget, XmNforeground, &fg, NULL);
  77.984 -        XmChangeColor(bdata->widget, color);
  77.985 -        XtVaSetValues(bdata->widget, XmNforeground, fg, NULL);
  77.986 -    }
  77.987 -
  77.988 -    AWT_FLUSH_UNLOCK();
  77.989 -}
  77.990 -
  77.991 -/*
  77.992 - * Class:     sun_awt_motif_MComponentPeer
  77.993 - * Method:    pSetInnerForeground
  77.994 - * Signature: (Ljava/awt/Color;)V
  77.995 - */
  77.996 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetInnerForeground
  77.997 -(JNIEnv *env, jobject this, jobject c)
  77.998 -{
  77.999 -    struct ComponentData *bdata;
 77.1000 -    Pixel color;
 77.1001 -
 77.1002 -    /* This method propagates the specified foreground color to all its children.
 77.1003 -     * It is called to set foreground color in List, TextArea, ScrollPane.
 77.1004 -     */
 77.1005 -    if (JNU_IsNull(env, c)) {
 77.1006 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 77.1007 -        return;
 77.1008 -    }
 77.1009 -    AWT_LOCK();
 77.1010 -    bdata = (struct ComponentData *)
 77.1011 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 77.1012 -    if (bdata == NULL || bdata->widget == NULL) {
 77.1013 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 77.1014 -        AWT_UNLOCK();
 77.1015 -        return;
 77.1016 -    }
 77.1017 -    color = awtJNI_GetColor(env, c);
 77.1018 -    awt_util_mapChildren(bdata->widget, changeForeground, 1, (void *) color);
 77.1019 -    AWT_FLUSH_UNLOCK();
 77.1020 -}
 77.1021 -
 77.1022 -/*
 77.1023 - * Class:     sun_awt_motif_MComponentPeer
 77.1024 - * Method:    pSetFont
 77.1025 - * Signature: (Ljava/awt/Font;)V
 77.1026 - */
 77.1027 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetFont
 77.1028 -(JNIEnv *env, jobject this, jobject f)
 77.1029 -{
 77.1030 -    struct ComponentData *cdata;
 77.1031 -
 77.1032 -    struct changeFontInfo finfo = { NULL, FALSE, NULL, 0,
 77.1033 -                                    FALSE, FALSE, NULL, NULL };
 77.1034 -
 77.1035 -    if (JNU_IsNull(env, f)) {
 77.1036 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 77.1037 -        return;
 77.1038 -    }
 77.1039 -    AWT_LOCK();
 77.1040 -
 77.1041 -    cdata = (struct ComponentData *)
 77.1042 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 77.1043 -    if (cdata == NULL || cdata->widget == NULL) {
 77.1044 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 77.1045 -        AWT_UNLOCK();
 77.1046 -        return;
 77.1047 -    }
 77.1048 -
 77.1049 -    finfo.env = env;
 77.1050 -    finfo.fObj = f;
 77.1051 -    awt_util_mapChildren(cdata->widget, changeFont, 1, (void *)&finfo);
 77.1052 -    if (!finfo.error && finfo.fontList != NULL) {
 77.1053 -        XmFontListFree(finfo.fontList);
 77.1054 -    }
 77.1055 -
 77.1056 -    AWT_FLUSH_UNLOCK();
 77.1057 -} /* MComponentPeer.pSetFont() */
 77.1058 -
 77.1059 -/*
 77.1060 - * Class:     sun_awt_motif_MComponentPeer
 77.1061 - * Method:    setTargetBackground
 77.1062 - * Signature: (Ljava/awt/Color;)V
 77.1063 - */
 77.1064 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_setTargetBackground
 77.1065 -(JNIEnv *env, jobject this, jobject c)
 77.1066 -{
 77.1067 -    jobject target = NULL;
 77.1068 -
 77.1069 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
 77.1070 -        return;
 77.1071 -    }
 77.1072 -
 77.1073 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
 77.1074 -    (*env)->SetObjectField(env, target, componentIDs.background, c);
 77.1075 -    (*env)->DeleteLocalRef(env, target);
 77.1076 -}
 77.1077 -
 77.1078 -/*
 77.1079 - * Class:     sun_awt_motif_MComponentPeer
 77.1080 - * Method:    pSetCursor
 77.1081 - * Signature: (Ljava/awt/Cursor;)V
 77.1082 - */
 77.1083 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_pSetCursor
 77.1084 -(JNIEnv *env, jobject this, jobject cursor)
 77.1085 -{
 77.1086 -    Cursor xcursor;
 77.1087 -    struct ComponentData *cdata;
 77.1088 -
 77.1089 -    AWT_LOCK();
 77.1090 -
 77.1091 -    cdata = (struct ComponentData *)
 77.1092 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
 77.1093 -    if (cdata == NULL || cdata->widget == NULL || JNU_IsNull(env, cursor)) {
 77.1094 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 77.1095 -        AWT_UNLOCK();
 77.1096 -        return;
 77.1097 -    }
 77.1098 -
 77.1099 -    awt_util_setCursor(cdata->widget, getCursor(env, cursor));
 77.1100 -
 77.1101 -    AWT_FLUSH_UNLOCK();
 77.1102 -}
 77.1103 -
 77.1104 -/*
 77.1105 - * Class:     sun_awt_motif_MComponentPeer
 77.1106 - * Method:    nativeHandleEvent
 77.1107 - * Signature: (Ljava/awt/AWTEvent;)V
 77.1108 - */
 77.1109 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_nativeHandleEvent
 77.1110 -(JNIEnv *env, jobject this, jobject event)
 77.1111 -{
 77.1112 -    extern void awt_modify_KeyEvent(JNIEnv *env, XEvent * xevent, jobject jevent);
 77.1113 -    jbyteArray array;
 77.1114 -    XEvent *xevent;
 77.1115 -    Widget widget = NULL;
 77.1116 -    Boolean consumed;
 77.1117 -
 77.1118 -    if (JNU_IsNull(env, event)) {
 77.1119 -        return;
 77.1120 -    }
 77.1121 -    AWT_LOCK();
 77.1122 -
 77.1123 -    consumed = (*env)->GetBooleanField(env, event, awtEventIDs.consumed);
 77.1124 -
 77.1125 -    /*
 77.1126 -     * Fix for bug 4280561
 77.1127 -     *
 77.1128 -     * If a menu is up, we must dispatch all XEvents, to allow
 77.1129 -     * mouse grabs to be released and prevent server hangs.
 77.1130 -     */
 77.1131 -    consumed = consumed && !awt_util_focusIsOnMenu(awt_display);
 77.1132 -
 77.1133 -    if (consumed) {
 77.1134 -        AWT_UNLOCK();
 77.1135 -        return;
 77.1136 -    }
 77.1137 -
 77.1138 -    array = (jbyteArray)(*env)->GetObjectField(env, event, awtEventIDs.bdata);
 77.1139 -    if (array == NULL) {
 77.1140 -        AWT_UNLOCK();
 77.1141 -        return;
 77.1142 -    }
 77.1143 -
 77.1144 -    xevent = (XEvent *)(*env)->GetByteArrayElements(env, array, NULL);
 77.1145 -    if (xevent == NULL) {
 77.1146 -        AWT_UNLOCK();
 77.1147 -        return;
 77.1148 -    }
 77.1149 -
 77.1150 -    switch ((*env)->GetIntField(env, event, awtEventIDs.id)) {
 77.1151 -      case java_awt_event_KeyEvent_KEY_RELEASED:
 77.1152 -      case java_awt_event_KeyEvent_KEY_PRESSED:
 77.1153 -          awt_modify_KeyEvent(env, xevent, event);
 77.1154 -          if ((*env)->GetBooleanField(env, event, componentIDs.isProxyActive) == JNI_TRUE) {
 77.1155 -              xevent->xany.send_event = SPECIAL_KEY_EVENT;
 77.1156 -          }
 77.1157 -          break;
 77.1158 -      default:
 77.1159 -          break;
 77.1160 -    }
 77.1161 -    widget = XtWindowToWidget(awt_display, xevent->xany.window);
 77.1162 -
 77.1163 -    if (!((widget == NULL) || (!XtIsObject(widget)) ||
 77.1164 -          (widget->core.being_destroyed))) {
 77.1165 -        /* Queue the event to be handled by the AWT-Motif thread */
 77.1166 -        if (!IsCanvasTypeWidget(widget)) {
 77.1167 -            awt_put_back_event(env, xevent);
 77.1168 -        }
 77.1169 -    }
 77.1170 -
 77.1171 -    (*env)->ReleaseByteArrayElements(env, array, (jbyte *)xevent, JNI_ABORT);
 77.1172 -    (*env)->DeleteLocalRef(env, array);
 77.1173 -
 77.1174 -    AWT_UNLOCK();
 77.1175 -    return;
 77.1176 -}
 77.1177 -
 77.1178 -// Returns the widget from parent's hierarchy which should be
 77.1179 -// used for focus operations. This widget is stored in WidgetInfo
 77.1180 -// structure and should be prepared by the appropriate component
 77.1181 -// type constructor
 77.1182 -Widget getFocusWidget(Widget parent) {
 77.1183 -    struct WidgetInfo * winfo = NULL;
 77.1184 -    DASSERT(parent != NULL);
 77.1185 -    if (parent == NULL) {
 77.1186 -        return NULL;
 77.1187 -    }
 77.1188 -    winfo = findWidgetInfo(parent);
 77.1189 -    if (winfo == NULL) {
 77.1190 -        return NULL;
 77.1191 -    }
 77.1192 -    return winfo->widget;
 77.1193 -}
 77.1194 -
 77.1195 -
 77.1196 -// Returns value of widget's traversalOn property
 77.1197 -Boolean getTraversal(Widget w) {
 77.1198 -    if (w == NULL) {
 77.1199 -        return False;
 77.1200 -    }
 77.1201 -    if (XmIsPrimitive(w)) {
 77.1202 -        XmPrimitiveWidget prim = (XmPrimitiveWidget)w;
 77.1203 -        return prim->primitive.traversal_on;
 77.1204 -    }
 77.1205 -    if (XmIsManager(w)) {
 77.1206 -        XmManagerWidget man = (XmManagerWidget)w;
 77.1207 -        return man->manager.traversal_on;
 77.1208 -    }
 77.1209 -    return False;
 77.1210 -}
 77.1211 -
 77.1212 -
 77.1213 -void processTree(Widget from, Widget to, Boolean action) {
 77.1214 -// Workhorse function that makes sure that the only widgets
 77.1215 -// which have traversalOn == true are the ones on the path from
 77.1216 -// shell to current focus widget. Function uses two widgets -
 77.1217 -// the one which is supposed to have focus currently(from) and
 77.1218 -// the one which will receive focus(to). Function disables and
 77.1219 -// enables the appropriate widgets so 'to' can become focus owner.
 77.1220 -    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 77.1221 -    int32_t count_from = 0, count_to = 0;
 77.1222 -    Widget parent_from = NULL, parent_to = NULL;
 77.1223 -    Widget * parents_from = NULL, * parents_to = NULL;
 77.1224 -    int32_t index = 0;
 77.1225 -
 77.1226 -    // Count amount of parents up the tree from widget
 77.1227 -    parent_from = from;
 77.1228 -    while (parent_from != NULL) {
 77.1229 -        parent_from = XtParent(parent_from);
 77.1230 -        count_from++;
 77.1231 -    }
 77.1232 -    parent_to = to;
 77.1233 -    while (parent_to != NULL) {
 77.1234 -        parent_to = XtParent(parent_to);
 77.1235 -        count_to++;
 77.1236 -    }
 77.1237 -
 77.1238 -    // Store all the parents in the list. Both list wittingly
 77.1239 -    // have common parts starting from the beginning. We need
 77.1240 -    // to find the end of this common part.
 77.1241 -    parents_from = (Widget*)malloc(count_from*sizeof(Widget*));
 77.1242 -    parents_to = (Widget*)malloc(count_to*sizeof(Widget*));
 77.1243 -    parent_from = from;
 77.1244 -    index = count_from;
 77.1245 -    while (parent_from != NULL) {
 77.1246 -        parents_from[index-1] = parent_from;
 77.1247 -        parent_from = XtParent(parent_from);
 77.1248 -        index--;
 77.1249 -    }
 77.1250 -    parent_to = to;
 77.1251 -    index = count_to;
 77.1252 -    while (parent_to != NULL) {
 77.1253 -        parents_to[index-1] = parent_to;
 77.1254 -        parent_to = XtParent(parent_to);
 77.1255 -        index--;
 77.1256 -    }
 77.1257 -
 77.1258 -    // Process parents list. Find common part which is usually doesn't
 77.1259 -    // require changes. At the exit of the cycle index will point
 77.1260 -    // to the first widget which requeires the change.
 77.1261 -
 77.1262 -    if (from != NULL && to != NULL) {
 77.1263 -        do {
 77.1264 -            if (index >= count_from-1 || index >= count_to-1) {
 77.1265 -                break;
 77.1266 -            }
 77.1267 -            if (parents_from[index] == parents_to[index])
 77.1268 -            {
 77.1269 -                if (XtIsShell(parents_from[index])) {
 77.1270 -                    index++;
 77.1271 -                    continue;
 77.1272 -                }
 77.1273 -                if (action) {
 77.1274 -                    if (getTraversal(parents_from[index])) {
 77.1275 -                        index++;
 77.1276 -                    } else {
 77.1277 -                        break;
 77.1278 -                    }
 77.1279 -                } else {
 77.1280 -                    index++;
 77.1281 -                }
 77.1282 -            } else {
 77.1283 -                break;
 77.1284 -            }
 77.1285 -        } while (True);
 77.1286 -    }
 77.1287 -
 77.1288 -
 77.1289 -    if (action) { // enable the tree starting from uncommon part till 'to'
 77.1290 -        if (to != NULL) {
 77.1291 -            while (index < count_to - 1) {
 77.1292 -                if (!getTraversal(parents_to[index])) {
 77.1293 -                    XtVaSetValues(parents_to[index], XmNtraversalOn, True, NULL);
 77.1294 -                }
 77.1295 -                index++;
 77.1296 -            }
 77.1297 -            XtVaSetValues(to, XmNtraversalOn, True, NULL);
 77.1298 -        }
 77.1299 -    } else if (from != NULL) {
 77.1300 -        // disable the tree starting from uncommon part to 'from'
 77.1301 -        if (parents_from[index] == parents_to[index]) {
 77.1302 -            if (index == count_from - 1) {
 77.1303 -                // 'from' is one of the parents of 'to' - no need
 77.1304 -                // to disable 'from'
 77.1305 -                goto skip_disable;
 77.1306 -            }
 77.1307 -            index++;
 77.1308 -        }
 77.1309 -        while (index < count_from - 1) {
 77.1310 -            if (!XmIsGadget(parents_from[index]) && !XtIsShell(parents_from[index])) {
 77.1311 -                setTraversal(parents_from[index], False);
 77.1312 -            }
 77.1313 -            index++;
 77.1314 -        }
 77.1315 -        if (!XmIsGadget(from)) {
 77.1316 -            setTraversal(parents_from[index], False);
 77.1317 -        }
 77.1318 -    }
 77.1319 -  skip_disable:
 77.1320 -    free(parents_from);
 77.1321 -    free(parents_to);
 77.1322 -}
 77.1323 -
 77.1324 -/*
 77.1325 - * Class:     sun_awt_motif_MComponentPeer
 77.1326 - * Method:    requestFocus
 77.1327 - * Signature: (Ljava/awt/Component;ZZJ)Z
 77.1328 - */
 77.1329 -JNIEXPORT jboolean JNICALL Java_sun_awt_motif_MComponentPeer__1requestFocus
 77.1330 -(JNIEnv *env, jobject this, jobject lightweightChild, jboolean temporary,
 77.1331 -     jboolean focusedWindowChangeAllowed, jlong time, jobject cause)
 77.1332 -{
 77.1333 -    struct ComponentData *bdata;
 77.1334 -    Boolean result;
 77.1335 -    jobject target;
 77.1336 -    jint retval;
 77.1337 -    Widget currentOwner = NULL;
 77.1338 -    jobject curPeer = NULL;
 77.1339 -    Widget shell;
 77.1340 -    Widget widgetToFocus = NULL;
 77.1341 -
 77.1342 -    AWT_LOCK();
 77.1343 -
 77.1344 -    bdata = (struct ComponentData *)
 77.1345 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 77.1346 -    if (bdata == NULL || bdata->widget == NULL) {
 77.1347 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 77.1348 -        AWT_UNLOCK();
 77.1349 -        return JNI_FALSE;
 77.1350 -    }
 77.1351 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
 77.1352 -        AWT_UNLOCK();
 77.1353 -        return JNI_FALSE;
 77.1354 -    }
 77.1355 -
 77.1356 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
 77.1357 -    /* Don't need to free target explicitly. That will happen automatically
 77.1358 -       when this function returns. */
 77.1359 -
 77.1360 -    if (target == NULL) {
 77.1361 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 77.1362 -        AWT_UNLOCK();
 77.1363 -        return JNI_FALSE;
 77.1364 -    }
 77.1365 -
 77.1366 -    /* The X11 implementation does not permit cross-Window focus transfers,
 77.1367 -       so always pass JNI_FALSE for that parameter. */
 77.1368 -    retval = (*env)->CallStaticIntMethod
 77.1369 -        (env, keyboardFocusManagerIDs.keyboardFocusManagerCls,
 77.1370 -         keyboardFocusManagerIDs.shouldNativelyFocusHeavyweightMID,
 77.1371 -         target, lightweightChild, temporary, JNI_FALSE, time, cause);
 77.1372 -
 77.1373 -    if (retval == java_awt_KeyboardFocusManager_SNFH_SUCCESS_HANDLED) {
 77.1374 -        AWT_UNLOCK();
 77.1375 -        (*env)->DeleteLocalRef(env, target);
 77.1376 -        return JNI_TRUE;
 77.1377 -    }
 77.1378 -    if (retval == java_awt_KeyboardFocusManager_SNFH_FAILURE) {
 77.1379 -        AWT_UNLOCK();
 77.1380 -        (*env)->DeleteLocalRef(env, target);
 77.1381 -        return JNI_FALSE;
 77.1382 -    }
 77.1383 -
 77.1384 -    DASSERT(retval == java_awt_KeyboardFocusManager_SNFH_SUCCESS_PROCEED);
 77.1385 -
 77.1386 -    shell = getShellWidget(bdata->widget);
 77.1387 -    currentOwner = XmGetFocusWidget(shell);
 77.1388 -
 77.1389 -    widgetToFocus = getFocusWidget(bdata->widget);
 77.1390 -
 77.1391 -    globalClearFocusPath(shell);
 77.1392 -
 77.1393 -    // Prepare widgets tree
 77.1394 -    processTree(currentOwner, widgetToFocus, False);
 77.1395 -    processTree(currentOwner, widgetToFocus, True);
 77.1396 -
 77.1397 -    /*
 77.1398 -      Fix for bug 4157017: replace XmProcessTraversal with
 77.1399 -      XtSetKeyboardFocus because XmProcessTraversal does not allow
 77.1400 -      focus to go to non-visible widgets.
 77.1401 -
 77.1402 -      (There is a corresponding change to awt_MToolkit.c:dispatchToWidget)
 77.1403 -
 77.1404 -      I found a last minute problem with this fix i.e. it broke the test
 77.1405 -      case for bug 4053856. XmProcessTraversal does something else (that
 77.1406 -      XtSetKeyboardFocus does not do) that stops this test case from
 77.1407 -      failing. So, as I do not have time to investigate, and having
 77.1408 -      both XmProcessTraversal and XtSetKeyboardFocus fixes 4157017 and
 77.1409 -      4053856 and should be harmless (reviewer agreed), we have both
 77.1410 -      below - XmProcessTraversal AND XtSetKeyboardFocus.
 77.1411 -    */
 77.1412 -    result = XmProcessTraversal(widgetToFocus, XmTRAVERSE_CURRENT);
 77.1413 -    if (!result)
 77.1414 -    {
 77.1415 -        Widget w = widgetToFocus;
 77.1416 -
 77.1417 -        shell = getShellWidget(w);
 77.1418 -        XtSetKeyboardFocus(shell, w);
 77.1419 -    }
 77.1420 -    /* end 4157017 */
 77.1421 -
 77.1422 -    // Because Motif focus callbacks are disabled we need to generate
 77.1423 -    // the required events by ourselves.
 77.1424 -    // First, check if the current focused widget has the entry in focus
 77.1425 -    // list. If not, add it because it is required for further processing
 77.1426 -    if (currentOwner != NULL) {
 77.1427 -        jobject last = NULL;
 77.1428 -        curPeer = findPeer(&currentOwner);
 77.1429 -        if (curPeer == NULL) {
 77.1430 -            currentOwner = findTopLevelByShell(currentOwner);
 77.1431 -            if (currentOwner != NULL) {
 77.1432 -                curPeer = findPeer(&currentOwner);
 77.1433 -            }
 77.1434 -        }
 77.1435 -        if (curPeer != NULL) {
 77.1436 -            curPeer = (*env)->GetObjectField(env, curPeer, mComponentPeerIDs.target);
 77.1437 -            if (focusList == NULL) {
 77.1438 -                awt_canvas_addToFocusListWithDuplicates(curPeer, JNI_TRUE);
 77.1439 -            } else {
 77.1440 -                last = (*env)->NewLocalRef(env, focusList->requestor);
 77.1441 -                if (!(*env)->IsSameObject(env, last, curPeer)) {
 77.1442 -                    awt_canvas_addToFocusList(curPeer);
 77.1443 -                }
 77.1444 -                if (!JNU_IsNull(env, last)) {
 77.1445 -                    (*env)->DeleteLocalRef(env, last);
 77.1446 -                }
 77.1447 -            }
 77.1448 -            (*env)->DeleteLocalRef(env, curPeer);
 77.1449 -        }
 77.1450 -    }
 77.1451 -    awt_canvas_addToFocusList(target);
 77.1452 -
 77.1453 -    // If new and current focus owners are the same do not generate FOCUS_LOST
 77.1454 -    // event because we don't expect it, but generate FOCUS_GAIN because we
 77.1455 -    // wait for it.
 77.1456 -    if ( currentOwner != NULL && !JNU_IsNull(env, curPeer) &&
 77.1457 -         !(*env)->IsSameObject(env, curPeer, target)) {
 77.1458 -        callFocusHandler(currentOwner, FocusOut, cause);
 77.1459 -    }
 77.1460 -    callFocusHandler(widgetToFocus, FocusIn, cause);
 77.1461 -    (*env)->DeleteLocalRef(env, target);
 77.1462 -
 77.1463 -    AWT_FLUSH_UNLOCK();
 77.1464 -    return JNI_TRUE;
 77.1465 -}
 77.1466 -
 77.1467 -Dimension
 77.1468 -awt_computeIndicatorSize(struct FontData *fdata)
 77.1469 -{
 77.1470 -    int32_t height;
 77.1471 -    int32_t acc;
 77.1472 -    int32_t i;
 77.1473 -
 77.1474 -    if (fdata == (struct FontData *) NULL)
 77.1475 -        return MOTIF_XmINVALID_DIMENSION;
 77.1476 -
 77.1477 -    /*
 77.1478 -     * If Java font maps into single platform font - there's no
 77.1479 -     * problem.  Let Motif use its usual calculations in this case.
 77.1480 -     */
 77.1481 -    if (fdata->charset_num == 1)
 77.1482 -        return MOTIF_XmINVALID_DIMENSION;
 77.1483 -
 77.1484 -    acc = 0;
 77.1485 -    for (i = 0; i < fdata->charset_num; ++i) {
 77.1486 -        XFontStruct *xfont = fdata->flist[i].xfont;
 77.1487 -        acc += xfont->ascent + xfont->descent;
 77.1488 -    }
 77.1489 -
 77.1490 -    height = acc / fdata->charset_num;
 77.1491 -    if (height < MOTIF_XmDEFAULT_INDICATOR_DIM)
 77.1492 -        height = MOTIF_XmDEFAULT_INDICATOR_DIM;
 77.1493 -
 77.1494 -    return height;
 77.1495 -}
 77.1496 -
 77.1497 -Dimension
 77.1498 -awt_adjustIndicatorSizeForMenu(Dimension indSize)
 77.1499 -{
 77.1500 -    if (indSize == 0 || indSize == MOTIF_XmINVALID_DIMENSION)
 77.1501 -        return MOTIF_XmINVALID_DIMENSION; /* let motif do the job */
 77.1502 -
 77.1503 -    /* Indicators in menus are smaller.
 77.1504 -       2/3 is a magic number from Motif internals. */
 77.1505 -    indSize = indSize * 2 / 3;
 77.1506 -    if (indSize < MOTIF_XmDEFAULT_INDICATOR_DIM)
 77.1507 -        indSize = MOTIF_XmDEFAULT_INDICATOR_DIM;
 77.1508 -
 77.1509 -    return indSize;
 77.1510 -}
 77.1511 -
 77.1512 -/*
 77.1513 - * Class:     sun_awt_motif_MComponentPeer
 77.1514 - * Method:    getWindow
 77.1515 - * Signature: (J)J
 77.1516 - */
 77.1517 -JNIEXPORT jlong JNICALL Java_sun_awt_motif_MComponentPeer_getWindow
 77.1518 -(JNIEnv *env, jobject this, jlong pData)
 77.1519 -{
 77.1520 -    jlong ret = (jlong)0;
 77.1521 -    struct ComponentData* cdata;
 77.1522 -    cdata = (struct ComponentData*)pData;
 77.1523 -    AWT_LOCK();
 77.1524 -    ret = (jlong)XtWindow(cdata->widget);
 77.1525 -    AWT_FLUSH_UNLOCK();
 77.1526 -    return ret;
 77.1527 -}
 77.1528 -
 77.1529 -/*
 77.1530 - * Class:     sun_awt_motif_MComponentPeer
 77.1531 - * Method:    restore_Focus
 77.1532 - * Signature: ()V
 77.1533 - */
 77.1534 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_restoreFocus
 77.1535 -(JNIEnv *env, jobject this)
 77.1536 -{
 77.1537 -    jobject focus_peer;
 77.1538 -    AWT_LOCK();
 77.1539 -
 77.1540 -    focus_peer = awt_canvas_getFocusOwnerPeer();
 77.1541 -    if (!JNU_IsNull(env, focus_peer)) {
 77.1542 -        struct ComponentData *bdata;
 77.1543 -        Boolean result;
 77.1544 -
 77.1545 -        bdata = (struct ComponentData *)
 77.1546 -            JNU_GetLongFieldAsPtr(env, focus_peer, mComponentPeerIDs.pData);
 77.1547 -        if (bdata != NULL) {
 77.1548 -            Widget widgetToFocus = getFocusWidget(bdata->widget);
 77.1549 -            result = XmProcessTraversal(widgetToFocus, XmTRAVERSE_CURRENT);
 77.1550 -            if (!result)
 77.1551 -            {
 77.1552 -                XtSetKeyboardFocus(getShellWidget(widgetToFocus), widgetToFocus);
 77.1553 -            }
 77.1554 -        }
 77.1555 -    }
 77.1556 -    (*env)->DeleteLocalRef(env, focus_peer);
 77.1557 -
 77.1558 -    AWT_UNLOCK();
 77.1559 -}
 77.1560 -
 77.1561 -JNIEXPORT jboolean JNICALL
 77.1562 -Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer(
 77.1563 -    JNIEnv * env, jclass cls, jobject heavyweight, jobject descendant,
 77.1564 -    jboolean temporary, jboolean focusedWindowChangeAllowed, jlong time)
 77.1565 -{
 77.1566 -    return (*env)->CallStaticBooleanMethod(env, keyboardFocusManagerIDs.keyboardFocusManagerCls,
 77.1567 -                                           keyboardFocusManagerIDs.processSynchronousTransferMID,
 77.1568 -                                           heavyweight, descendant, temporary,
 77.1569 -                                           focusedWindowChangeAllowed, time);
 77.1570 -}
 77.1571 -/*
 77.1572 - * Class:     sun_awt_motif_MComponentPeer
 77.1573 - * Method:    getNativeFocusedWindow
 77.1574 - * Signature: ()Ljava/awt/Window;
 77.1575 - */
 77.1576 -JNIEXPORT jobject JNICALL
 77.1577 -Java_sun_awt_motif_MComponentPeer_getNativeFocusedWindow
 77.1578 -(JNIEnv *env, jclass cls)
 77.1579 -{
 77.1580 -    jobject l_peer;
 77.1581 -
 77.1582 -    AWT_LOCK();
 77.1583 -    l_peer = awt_canvas_getFocusedWindowPeer();
 77.1584 -    AWT_UNLOCK();
 77.1585 -
 77.1586 -    return (l_peer != NULL)
 77.1587 -        ? (*env)->GetObjectField(env, l_peer, mComponentPeerIDs.target)
 77.1588 -        : NULL;
 77.1589 -}
 77.1590 -
 77.1591 -/**
 77.1592 - * Makes sure that child has correct index inside parent
 77.1593 - * Note: there was a short time when we were counting index in the
 77.1594 - * opposite order when it seemed that X and Java z-order notions
 77.1595 - * are different. Now we know they are not: last component is
 77.1596 - * painted first and appears below all other components with
 77.1597 - * smaller indices.
 77.1598 - */
 77.1599 -void ensureIndex(Widget parent, Widget child, int index) {
 77.1600 -    WidgetList children;
 77.1601 -    int32_t num_children;
 77.1602 -    int32_t i;
 77.1603 -
 77.1604 -    if (parent == NULL) {
 77.1605 -        return;
 77.1606 -    }
 77.1607 -    if (child == NULL) {
 77.1608 -        return;
 77.1609 -    }
 77.1610 -    XtVaGetValues(parent,
 77.1611 -                  XmNnumChildren, &num_children,
 77.1612 -                  XmNchildren, &children,
 77.1613 -                  NULL);
 77.1614 -    if (index < 0 || index >= num_children) {
 77.1615 -        return;
 77.1616 -    }
 77.1617 -    if (children[index] != child) {
 77.1618 -        for (i = 0; i < num_children; i++) {
 77.1619 -            if (children[i] == child) {
 77.1620 -                break;
 77.1621 -            }
 77.1622 -        }
 77.1623 -        if (i < num_children) {
 77.1624 -            Widget temp = children[index];
 77.1625 -            children[index] = child;
 77.1626 -            children[i] = temp;
 77.1627 -        }
 77.1628 -    }
 77.1629 -}
 77.1630 -
 77.1631 -JNIEXPORT void JNICALL
 77.1632 -Java_sun_awt_motif_MPanelPeer_pEnsureIndex(JNIEnv * env, jobject this, jobject child, jint index) {
 77.1633 -    struct ComponentData *cdata;
 77.1634 -    Widget w_parent, w_child;
 77.1635 -    AWT_LOCK();
 77.1636 -
 77.1637 -    cdata = (struct ComponentData *)
 77.1638 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
 77.1639 -    w_parent = cdata->widget;
 77.1640 -
 77.1641 -    cdata = (struct ComponentData *)
 77.1642 -        JNU_GetLongFieldAsPtr(env, child, mComponentPeerIDs.pData);
 77.1643 -    w_child = cdata->widget;
 77.1644 -    ensureIndex(w_parent, w_child, index);
 77.1645 -    AWT_UNLOCK();
 77.1646 -}
 77.1647 -
 77.1648 -JNIEXPORT void JNICALL
 77.1649 -Java_sun_awt_motif_MPanelPeer_pRestack(JNIEnv * env, jobject this) {
 77.1650 -    struct ComponentData *cdata;
 77.1651 -    Widget w_parent;
 77.1652 -    AWT_LOCK();
 77.1653 -
 77.1654 -    cdata = (struct ComponentData *)
 77.1655 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
 77.1656 -    w_parent = cdata->widget;
 77.1657 -    restack(w_parent);
 77.1658 -    AWT_UNLOCK();
 77.1659 -}
    78.1 --- a/src/solaris/native/sun/awt/awt_Cursor.c	Wed Sep 17 13:45:37 2008 -0700
    78.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.3 @@ -1,216 +0,0 @@
    78.4 -/*
    78.5 - * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
    78.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    78.7 - *
    78.8 - * This code is free software; you can redistribute it and/or modify it
    78.9 - * under the terms of the GNU General Public License version 2 only, as
   78.10 - * published by the Free Software Foundation.  Sun designates this
   78.11 - * particular file as subject to the "Classpath" exception as provided
   78.12 - * by Sun in the LICENSE file that accompanied this code.
   78.13 - *
   78.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   78.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   78.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   78.17 - * version 2 for more details (a copy is included in the LICENSE file that
   78.18 - * accompanied this code).
   78.19 - *
   78.20 - * You should have received a copy of the GNU General Public License version
   78.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   78.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   78.23 - *
   78.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   78.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   78.26 - * have any questions.
   78.27 - */
   78.28 -
   78.29 -#ifdef HEADLESS
   78.30 -    #error This file should not be included in headless library
   78.31 -#endif
   78.32 -
   78.33 -#include <Xm/Display.h>
   78.34 -#include "awt_Component.h"
   78.35 -#include "awt_Cursor.h"
   78.36 -#include "java_awt_Cursor.h"
   78.37 -#include <X11/cursorfont.h>
   78.38 -
   78.39 -#include "jni.h"
   78.40 -#include "jni_util.h"
   78.41 -
   78.42 -/* fieldIDs for Cursor fields that may be accessed from C */
   78.43 -struct CursorIDs cursorIDs;
   78.44 -extern struct MComponentPeerIDs mComponentPeerIDs;
   78.45 -
   78.46 -static jweak curComp = 0;
   78.47 -
   78.48 -/*
   78.49 - * Class:     java_awt_Cursor
   78.50 - * Method:    initIDs
   78.51 - * Signature: ()V
   78.52 - */
   78.53 -/*
   78.54 - * This function gets called from the static initializer for Cursor.java
   78.55 - * to initialize the fieldIDs for fields that may be accessed from C
   78.56 - */
   78.57 -JNIEXPORT void JNICALL
   78.58 -Java_java_awt_Cursor_initIDs(JNIEnv *env, jclass cls)
   78.59 -{
   78.60 -    cursorIDs.type = (*env)->GetFieldID(env, cls, "type", "I");
   78.61 -    cursorIDs.mSetPData = (*env)->GetMethodID(env, cls, "setPData", "(J)V");
   78.62 -    cursorIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J");
   78.63 -}
   78.64 -
   78.65 -/*
   78.66 - * A utility to retrieve cursor from java.awt.Cursor
   78.67 - * Create and save the cursor first if it is not yet
   78.68 - */
   78.69 -Cursor getCursor(JNIEnv *env, jobject jCur)
   78.70 -{
   78.71 -    int32_t cursorType = 0;
   78.72 -    Cursor  xcursor;
   78.73 -
   78.74 -    xcursor = (Cursor)(*env)->GetLongField(env, jCur, cursorIDs.pData);
   78.75 -
   78.76 -    if (xcursor != None) {
   78.77 -        return xcursor;
   78.78 -    }
   78.79 -
   78.80 -    cursorType = (*env)->GetIntField(env, jCur, cursorIDs.type);
   78.81 -
   78.82 -    DASSERT(cursorType != java_awt_Cursor_CUSTOM_CURSOR);
   78.83 -
   78.84 -    switch (cursorType) {
   78.85 -    case java_awt_Cursor_DEFAULT_CURSOR:
   78.86 -        cursorType = XC_left_ptr;
   78.87 -        break;
   78.88 -    case java_awt_Cursor_CROSSHAIR_CURSOR:
   78.89 -        cursorType = XC_crosshair;
   78.90 -        break;
   78.91 -    case java_awt_Cursor_TEXT_CURSOR:
   78.92 -        cursorType = XC_xterm;
   78.93 -        break;
   78.94 -    case java_awt_Cursor_WAIT_CURSOR:
   78.95 -        cursorType = XC_watch;
   78.96 -        break;
   78.97 -    case java_awt_Cursor_SW_RESIZE_CURSOR:
   78.98 -        cursorType = XC_bottom_left_corner;
   78.99 -        break;
  78.100 -    case java_awt_Cursor_NW_RESIZE_CURSOR:
  78.101 -        cursorType = XC_top_left_corner;
  78.102 -        break;
  78.103 -    case java_awt_Cursor_SE_RESIZE_CURSOR:
  78.104 -        cursorType = XC_bottom_right_corner;
  78.105 -        break;
  78.106 -    case java_awt_Cursor_NE_RESIZE_CURSOR:
  78.107 -        cursorType = XC_top_right_corner;
  78.108 -        break;
  78.109 -    case java_awt_Cursor_S_RESIZE_CURSOR:
  78.110 -        cursorType = XC_bottom_side;
  78.111 -        break;
  78.112 -    case java_awt_Cursor_N_RESIZE_CURSOR:
  78.113 -        cursorType = XC_top_side;
  78.114 -        break;
  78.115 -    case java_awt_Cursor_W_RESIZE_CURSOR:
  78.116 -        cursorType = XC_left_side;
  78.117 -        break;
  78.118 -    case java_awt_Cursor_E_RESIZE_CURSOR:
  78.119 -        cursorType = XC_right_side;
  78.120 -        break;
  78.121 -    case java_awt_Cursor_HAND_CURSOR:
  78.122 -        cursorType = XC_hand2;
  78.123 -        break;
  78.124 -    case java_awt_Cursor_MOVE_CURSOR:
  78.125 -        cursorType = XC_fleur;
  78.126 -        break;
  78.127 -    }
  78.128 -    xcursor = XCreateFontCursor(awt_display, cursorType);
  78.129 -
  78.130 -    (*env)->CallVoidMethod(env, jCur, cursorIDs.mSetPData, xcursor);
  78.131 -    return xcursor;
  78.132 -}
  78.133 -
  78.134 -/*
  78.135 - * Class:     java_awt_Cursor
  78.136 - * Method:    finalizeImpl
  78.137 - * Signature: ()V
  78.138 - */
  78.139 -JNIEXPORT void JNICALL
  78.140 -Java_java_awt_Cursor_finalizeImpl(JNIEnv *env, jclass clazz, jlong pData)
  78.141 -{
  78.142 -    Cursor xcursor;
  78.143 -
  78.144 -    xcursor = (Cursor)pData;
  78.145 -    if (xcursor != None) {
  78.146 -        AWT_LOCK();
  78.147 -        XFreeCursor(awt_display, xcursor);
  78.148 -        AWT_UNLOCK();
  78.149 -    }
  78.150 -}
  78.151 -
  78.152 -/*
  78.153 - *  normal replace : CACHE_UDPATE  => update curComp and updateCursor
  78.154 - *  not replace    : UPDATE_ONLY   => intact curComp but updateCursor
  78.155 - *  only replace   : CACHE_ONLY    => update curComp only, not updateCursor
  78.156 - *
  78.157 - *  This function should only be called under AWT_LOCK(). Otherwise
  78.158 - *  multithreaded access can corrupt the value of curComp variable.
  78.159 - */
  78.160 -void updateCursor(XPointer client_data, int32_t replace) {
  78.161 -
  78.162 -    static jclass globalCursorManagerClass = NULL;
  78.163 -    static jmethodID updateCursorID = NULL;
  78.164 -
  78.165 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  78.166 -    jobject peer = (jobject) client_data;
  78.167 -    jobject target;
  78.168 -
  78.169 -    if ((*env)->PushLocalFrame(env, 16) < 0)
  78.170 -        return;
  78.171 -
  78.172 -    target = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
  78.173 -    if (replace != UPDATE_ONLY) {
  78.174 -        if (!JNU_IsNull(env, curComp)) {
  78.175 -            (*env)->DeleteWeakGlobalRef(env, curComp);
  78.176 -        }
  78.177 -        curComp = (*env)->NewWeakGlobalRef(env, target);
  78.178 -        if (replace == CACHE_ONLY) {
  78.179 -            (*env)->PopLocalFrame(env, 0);
  78.180 -            return;
  78.181 -        }
  78.182 -    }
  78.183 -
  78.184 -    /* Initialize our java identifiers once. Checking before locking
  78.185 -     * is a huge performance win.
  78.186 -     */
  78.187 -    if (globalCursorManagerClass == NULL) {
  78.188 -        jobject sysClass = (*env)->FindClass(env, "sun/awt/motif/MGlobalCursorManager");
  78.189 -        if (sysClass != NULL) {
  78.190 -            /* Make this class 'sticky', we don't want it GC'd */
  78.191 -            globalCursorManagerClass = (*env)->NewGlobalRef(env, sysClass);
  78.192 -
  78.193 -            updateCursorID = (*env)->GetStaticMethodID(env,
  78.194 -                                                       globalCursorManagerClass,
  78.195 -                                                       "nativeUpdateCursor",
  78.196 -                                                       "(Ljava/awt/Component;)V"
  78.197 -                                                       );
  78.198 -        }
  78.199 -        if (JNU_IsNull(env, globalCursorManagerClass) || updateCursorID == NULL) {
  78.200 -            JNU_ThrowClassNotFoundException(env, "sun/awt/motif/MGlobalCursorManager");
  78.201 -            (*env)->PopLocalFrame(env, 0);
  78.202 -            return;
  78.203 -        }
  78.204 -    } /* globalCursorManagerClass == NULL*/
  78.205 -
  78.206 -    (*env)->CallStaticVoidMethod(env, globalCursorManagerClass,
  78.207 -                                 updateCursorID, target);
  78.208 -    DASSERT(!((*env)->ExceptionOccurred(env)));
  78.209 -    (*env)->PopLocalFrame(env, 0);
  78.210 -}
  78.211 -
  78.212 -/*
  78.213 - * Only call this function under AWT_LOCK(). Otherwise multithreaded
  78.214 - * access can corrupt the value of curComp variable.
  78.215 - */
  78.216 -jobject getCurComponent() {
  78.217 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  78.218 -    return (*env)->NewLocalRef(env, curComp);
  78.219 -}
    79.1 --- a/src/solaris/native/sun/awt/awt_DataTransferer.c	Wed Sep 17 13:45:37 2008 -0700
    79.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.3 @@ -1,1068 +0,0 @@
    79.4 -/*
    79.5 - * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
    79.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    79.7 - *
    79.8 - * This code is free software; you can redistribute it and/or modify it
    79.9 - * under the terms of the GNU General Public License version 2 only, as
   79.10 - * published by the Free Software Foundation.  Sun designates this
   79.11 - * particular file as subject to the "Classpath" exception as provided
   79.12 - * by Sun in the LICENSE file that accompanied this code.
   79.13 - *
   79.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   79.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   79.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   79.17 - * version 2 for more details (a copy is included in the LICENSE file that
   79.18 - * accompanied this code).
   79.19 - *
   79.20 - * You should have received a copy of the GNU General Public License version
   79.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   79.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   79.23 - *
   79.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   79.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   79.26 - * have any questions.
   79.27 - */
   79.28 -
   79.29 -#ifdef HEADLESS
   79.30 -    #error This file should not be included in headless library
   79.31 -#endif
   79.32 -
   79.33 -#include "awt_p.h"
   79.34 -#include <X11/Intrinsic.h>
   79.35 -#include <X11/Xutil.h>
   79.36 -
   79.37 -#include <sys/utsname.h>
   79.38 -
   79.39 -#include <jni.h>
   79.40 -#include <jni_util.h>
   79.41 -
   79.42 -#include "sun_awt_datatransfer_DataTransferer.h"
   79.43 -#include "sun_awt_motif_MDataTransferer.h"
   79.44 -
   79.45 -#include "awt_XmDnD.h"
   79.46 -#include "awt_DataTransferer.h"
   79.47 -
   79.48 -static jclass string;
   79.49 -
   79.50 -XContext awt_convertDataContext = 0;
   79.51 -
   79.52 -Atom XA_TARGETS;
   79.53 -
   79.54 -extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
   79.55 -
   79.56 -typedef enum {
   79.57 -    SelectionPending,
   79.58 -    SelectionSuccess,
   79.59 -    SelectionFailure,
   79.60 -    SelectionOwnerTimedOut
   79.61 -} SelectionStatus;
   79.62 -
   79.63 -/* Should only be accessed by the current owner of AWT_LOCK. */
   79.64 -static SelectionStatus globalSelectionStatus = SelectionPending;
   79.65 -
   79.66 -static SelectionStatus get_selection_status() {
   79.67 -    return globalSelectionStatus;
   79.68 -}
   79.69 -
   79.70 -static void set_selection_status(SelectionStatus status) {
   79.71 -    globalSelectionStatus = status;
   79.72 -}
   79.73 -
   79.74 -static void
   79.75 -selection_request_filter(Widget widget, XtPointer closure, XEvent *event,
   79.76 -                         Boolean *cont) {
   79.77 -    if (event->type == SelectionRequest) {
   79.78 -        Window awt_root_window = XtWindow(awt_root_shell);
   79.79 -        Atom selection = event->xselectionrequest.selection;
   79.80 -        Window owner = XGetSelectionOwner(event->xany.display, selection);
   79.81 -
   79.82 -        if (owner != awt_root_window) {
   79.83 -            XSelectionEvent notify;
   79.84 -
   79.85 -            notify.type = SelectionNotify;
   79.86 -            notify.display = event->xselectionrequest.display;
   79.87 -            notify.requestor = event->xselectionrequest.requestor;
   79.88 -            notify.selection = event->xselectionrequest.selection;
   79.89 -            notify.time = event->xselectionrequest.time;
   79.90 -            notify.target = event->xselectionrequest.target;
   79.91 -            notify.property = None;
   79.92 -
   79.93 -            XSendEvent(notify.display, notify.requestor, False,
   79.94 -                       (unsigned long)0, (XEvent*)&notify);
   79.95 -            *cont = False;
   79.96 -        }
   79.97 -    }
   79.98 -}
   79.99 -
  79.100 -/**
  79.101 - * global function to initialize this client as a Dynamic-only app.
  79.102 - *
  79.103 - * gets called once during toolkit initialization.
  79.104 - */
  79.105 -
  79.106 -void awt_initialize_DataTransferer() {
  79.107 -    JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  79.108 -    jclass stringClassLocal = NULL;
  79.109 -
  79.110 -    DASSERT(string == NULL);
  79.111 -
  79.112 -    stringClassLocal = (*env)->FindClass(env, "java/lang/String");
  79.113 -
  79.114 -    if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.115 -        (*env)->ExceptionDescribe(env);
  79.116 -        (*env)->ExceptionClear(env);
  79.117 -        DASSERT(False);
  79.118 -    }
  79.119 -
  79.120 -    if (JNU_IsNull(env, stringClassLocal)) return;
  79.121 -
  79.122 -    string = (*env)->NewGlobalRef(env, stringClassLocal); /* never freed! */
  79.123 -    (*env)->DeleteLocalRef(env, stringClassLocal);
  79.124 -
  79.125 -    if (JNU_IsNull(env, string)) {
  79.126 -        JNU_ThrowOutOfMemoryError(env, "");
  79.127 -        return;
  79.128 -    }
  79.129 -
  79.130 -    DASSERT(awt_convertDataContext == 0);
  79.131 -    awt_convertDataContext = XUniqueContext();
  79.132 -    DASSERT(awt_convertDataContext != 0);
  79.133 -
  79.134 -    /*
  79.135 -     * Fixes for 4513976 and 4818143.
  79.136 -     */
  79.137 -    XtAppSetSelectionTimeout(awt_appContext,
  79.138 -            JNU_CallStaticMethodByName(env, NULL, "sun/awt/UNIXToolkit",
  79.139 -                                       "getDatatransferTimeout", "()I").i);
  79.140 -
  79.141 -    /*
  79.142 -     * Xt selection machinery doesn't respond to SelectionRequests if the
  79.143 -     * event arrives on a widget that is not the current selection owner.
  79.144 -     * This can happen if XtDisownSelection was called when SelectionRequest was
  79.145 -     * already on the native queue.
  79.146 -     * If the requestor is another JVM, it hangs for the selection timeout
  79.147 -     * as SelectionNotify is never sent.
  79.148 -     * We install an event handler that filters out SelectionRequests if the
  79.149 -     * awt_root_shell is not the current selection owner.
  79.150 -     */
  79.151 -    XtAddEventHandler(awt_root_shell, (EventMask)0, True,
  79.152 -                      selection_request_filter, NULL);
  79.153 -
  79.154 -    XA_TARGETS = XInternAtom(awt_display, "TARGETS", False);
  79.155 -}
  79.156 -
  79.157 -/*
  79.158 - * Single routine to convert to target FILE_NAME or _DT_FILENAME
  79.159 - */
  79.160 -Boolean
  79.161 -convertFileType(jbyteArray data, Atom * type, XtPointer * value,
  79.162 -                unsigned long *length, int32_t *format)
  79.163 -{
  79.164 -    /*
  79.165 -     * Convert the internal representation to an File Name.
  79.166 -     * The data passed is an array of
  79.167 -     * null separated bytes. Each series of bytes is a string
  79.168 -     * that is then converted to an XString which are then put
  79.169 -     * into an XStringList and put into an XTextProperty for
  79.170 -     * usage in other programs.
  79.171 -     *
  79.172 -     * It would be desireable to have dataConvert to this conversion
  79.173 -     * but it isn't possible to return a byte array that represents
  79.174 -     * the XTextProperty.
  79.175 -     */
  79.176 -
  79.177 -    JNIEnv*       env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  79.178 -    jboolean      isCopy=JNI_FALSE;
  79.179 -    XTextProperty tp;
  79.180 -    jsize         len;
  79.181 -    jsize         strings = 0;
  79.182 -    jsize         i;
  79.183 -    char**        stringList;
  79.184 -    Status        s;
  79.185 -    jbyte*        bytes;
  79.186 -    char*         start;
  79.187 -    size_t        slen;
  79.188 -    char*         utf;
  79.189 -
  79.190 -    if ((*env)->PushLocalFrame(env, 16) < 0) {
  79.191 -        return False;
  79.192 -    }
  79.193 -
  79.194 -    /* convert the data to an Array of Byte Elements */
  79.195 -    bytes = (*env)->GetByteArrayElements(env, data, &isCopy);
  79.196 -    if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.197 -        (*env)->ExceptionDescribe(env);
  79.198 -        (*env)->ExceptionClear(env);
  79.199 -        (*env)->PopLocalFrame(env, NULL);
  79.200 -        return False;
  79.201 -    }
  79.202 -
  79.203 -    if (JNU_IsNull(env, bytes)) {
  79.204 -        (*env)->PopLocalFrame(env, NULL);
  79.205 -        return False;
  79.206 -    }
  79.207 -
  79.208 -    /* Get the length of the area */
  79.209 -    len = (*env)->GetArrayLength(env, data);
  79.210 -    if (len == 0) {
  79.211 -        (*env)->ReleaseByteArrayElements(env, data, bytes, JNI_ABORT);
  79.212 -        (*env)->PopLocalFrame(env, NULL);
  79.213 -        return False;
  79.214 -    }
  79.215 -
  79.216 -    /*
  79.217 -     * determine the number of lists. The byteArray is null separated list of
  79.218 -     * strings.
  79.219 -     */
  79.220 -    for (i = 0; i < len; i++) {
  79.221 -        if (bytes[i] == '\0') {
  79.222 -            strings++;
  79.223 -        }
  79.224 -    }
  79.225 -
  79.226 -    /* Allocate an X11 string list */
  79.227 -    stringList = (char **)XtCalloc(strings, sizeof(char *));
  79.228 -    if (stringList == (char**)NULL) {
  79.229 -        (*env)->ReleaseByteArrayElements(env, data, bytes, JNI_ABORT);
  79.230 -        (*env)->PopLocalFrame(env, NULL);
  79.231 -        return False;
  79.232 -    }
  79.233 -
  79.234 -    for (i = 0; i < strings; i++) {
  79.235 -        if (i == 0) {
  79.236 -            start = (char*)bytes;
  79.237 -        } else {
  79.238 -            start = (char*)&bytes[slen];
  79.239 -        }
  79.240 -
  79.241 -        /*
  79.242 -         * if start is a NULL we're at the end of the list
  79.243 -         * We'll just a have null entry on the end of the list
  79.244 -         */
  79.245 -        if (start[0] == '\0') {
  79.246 -            stringList[i] = NULL;
  79.247 -            continue;
  79.248 -        }
  79.249 -        slen = strlen(start) + 1;
  79.250 -
  79.251 -        stringList[i] = (char*)XtCalloc(slen, sizeof(char));
  79.252 -
  79.253 -        if (stringList[i] == (char *)NULL) {
  79.254 -            jsize j;
  79.255 -
  79.256 -            (*env)->ReleaseByteArrayElements(env, data, bytes, JNI_ABORT);
  79.257 -
  79.258 -            for (j = 0; j < i; j++) {
  79.259 -                XtFree((void *)stringList[j]);
  79.260 -            }
  79.261 -
  79.262 -            (*env)->PopLocalFrame(env, NULL);
  79.263 -
  79.264 -            return False;
  79.265 -        }
  79.266 -
  79.267 -        memcpy((void *)stringList[i], (const void*)start, slen);
  79.268 -    }
  79.269 -
  79.270 -    (*env)->ReleaseByteArrayElements(env, data, bytes, JNI_ABORT);
  79.271 -    s = XStringListToTextProperty(stringList, strings, &tp);
  79.272 -
  79.273 -    /* free the strings that were created */
  79.274 -    for (i = 0; i < strings; i++) {
  79.275 -        if (stringList[i] != NULL) {
  79.276 -            XtFree((void*)stringList[i]);
  79.277 -        }
  79.278 -    }
  79.279 -
  79.280 -    XtFree((void*)stringList);
  79.281 -
  79.282 -    if (s == 0) {
  79.283 -        (*env)->PopLocalFrame(env, NULL);
  79.284 -        return False;
  79.285 -    }
  79.286 -
  79.287 -    *value = (XtPointer)XtCalloc(tp.nitems, sizeof(char));
  79.288 -
  79.289 -    if (*value == (XtPointer)NULL) {
  79.290 -        XFree((void*)tp.value);
  79.291 -
  79.292 -        (*env)->PopLocalFrame(env, NULL);
  79.293 -
  79.294 -        return False;
  79.295 -    }
  79.296 -
  79.297 -    memcpy((void *)(*value), (const void *)tp.value, tp.nitems);
  79.298 -
  79.299 -    XFree((void*)tp.value);
  79.300 -
  79.301 -    *length = tp.nitems;
  79.302 -    *type   = tp.encoding;
  79.303 -    *format = tp.format;
  79.304 -    (*env)->PopLocalFrame(env, NULL);
  79.305 -    return True;
  79.306 -}
  79.307 -
  79.308 -/*
  79.309 - * Class:     sun_awt_motif_MDataTransferer
  79.310 - * Method:    getAtomForTarget
  79.311 - * Signature: (Ljava/lang/String;)J
  79.312 - */
  79.313 -
  79.314 -JNIEXPORT jlong JNICALL
  79.315 -Java_sun_awt_motif_MDataTransferer_getAtomForTarget(JNIEnv *env,
  79.316 -                                                    jclass cls,
  79.317 -                                                    jstring targetString)
  79.318 -{
  79.319 -    Atom target;
  79.320 -    char *target_str;
  79.321 -
  79.322 -    if (JNU_IsNull(env, targetString)) {
  79.323 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  79.324 -        return -1;
  79.325 -    }
  79.326 -    target_str = (char *) JNU_GetStringPlatformChars(env, targetString, NULL);
  79.327 -
  79.328 -    AWT_LOCK();
  79.329 -
  79.330 -    target = XInternAtom(awt_display, target_str, False);
  79.331 -
  79.332 -    AWT_UNLOCK();
  79.333 -
  79.334 -    JNU_ReleaseStringPlatformChars(env, targetString,
  79.335 -                                   (const char *) target_str);
  79.336 -    return target;
  79.337 -}
  79.338 -
  79.339 -/*
  79.340 - * Class:     sun_awt_motif_MDataTransferer
  79.341 - * Method:    getTargetNameForAtom
  79.342 - * Signature: (J)Ljava/lang/String;
  79.343 - */
  79.344 -
  79.345 -JNIEXPORT jstring JNICALL
  79.346 -Java_sun_awt_motif_MDataTransferer_getTargetNameForAtom(JNIEnv *env,
  79.347 -                                                        jclass cls,
  79.348 -                                                        jlong atom)
  79.349 -{
  79.350 -    jstring targetString;
  79.351 -    char *name;
  79.352 -
  79.353 -    AWT_LOCK();
  79.354 -
  79.355 -    name = XGetAtomName(awt_display, (Atom) atom);
  79.356 -
  79.357 -    if (name == NULL) {
  79.358 -        JNU_ThrowNullPointerException(env, "Failed to retrieve atom name.");
  79.359 -        AWT_UNLOCK();
  79.360 -        return NULL;
  79.361 -    }
  79.362 -
  79.363 -    targetString = (*env)->NewStringUTF(env, (const char *)name);
  79.364 -
  79.365 -    if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.366 -        (*env)->ExceptionDescribe(env);
  79.367 -        (*env)->ExceptionClear(env);
  79.368 -        XFree (name);
  79.369 -        AWT_UNLOCK();
  79.370 -        return NULL;
  79.371 -    }
  79.372 -
  79.373 -    if (JNU_IsNull(env, targetString)) {
  79.374 -        JNU_ThrowNullPointerException(env, "Failed to create a string.");
  79.375 -        XFree (name);
  79.376 -        AWT_UNLOCK();
  79.377 -        return NULL;
  79.378 -    }
  79.379 -
  79.380 -    XFree (name);
  79.381 -
  79.382 -    AWT_UNLOCK();
  79.383 -    return targetString;
  79.384 -}
  79.385 -
  79.386 -/*
  79.387 - * Class:     sun_awt_datatransfer_DataTransferer
  79.388 - * Method:    dragQueryFile
  79.389 - * Signature: ([B)[Ljava/lang/String;
  79.390 - *
  79.391 - * This method converts a byte array that came from File most likely from a
  79.392 - * drag operation into a String array.
  79.393 - */
  79.394 -
  79.395 -JNIEXPORT jobjectArray JNICALL
  79.396 -Java_sun_awt_motif_MDataTransferer_dragQueryFile
  79.397 -    (JNIEnv *env, jobject this, jbyteArray bytes)
  79.398 -{
  79.399 -    XTextProperty tp;
  79.400 -    jbyte         *value;
  79.401 -
  79.402 -    char**        strings  = (char **)NULL;
  79.403 -    int32_t       nstrings = 0;
  79.404 -    jobject       filenames;
  79.405 -    jobject       ret = NULL;
  79.406 -    int32_t       i;
  79.407 -    jsize         len;
  79.408 -    jboolean      isCopy=JNI_FALSE;
  79.409 -
  79.410 -    /*
  79.411 -     * If the length of the byte array is 0 just return a null
  79.412 -     */
  79.413 -    len = (*env)->GetArrayLength(env, bytes);
  79.414 -    if (len == 0) {
  79.415 -        return NULL;
  79.416 -    }
  79.417 -
  79.418 -    value = (*env)->GetByteArrayElements(env, bytes, &isCopy);
  79.419 -    if (JNU_IsNull(env, value)) {
  79.420 -        return NULL;
  79.421 -    }
  79.422 -
  79.423 -    AWT_LOCK();
  79.424 -
  79.425 -    tp.encoding = XInternAtom(awt_display, "STRING", False);
  79.426 -    tp.value    = (unsigned char *)value;
  79.427 -    tp.nitems   = len;
  79.428 -    tp.format   = 8;
  79.429 -
  79.430 -    /*
  79.431 -     * Convert the byte stream into a list of X11 strings
  79.432 -     */
  79.433 -    if (XTextPropertyToStringList(&tp, &strings, &nstrings) == 0 ||
  79.434 -        nstrings == 0)
  79.435 -        {
  79.436 -            (*env)->ReleaseByteArrayElements(env, bytes, value, JNI_ABORT);
  79.437 -            AWT_UNLOCK();
  79.438 -            return NULL;
  79.439 -        }
  79.440 -
  79.441 -    (*env)->ReleaseByteArrayElements(env, bytes, value, JNI_ABORT);
  79.442 -
  79.443 -    filenames = (*env)->NewObjectArray(env, nstrings, string, NULL);
  79.444 -
  79.445 -    if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.446 -        (*env)->ExceptionDescribe(env);
  79.447 -        (*env)->ExceptionClear(env);
  79.448 -        goto wayout;
  79.449 -    }
  79.450 -
  79.451 -    if (JNU_IsNull(env, filenames)) {
  79.452 -        goto wayout;
  79.453 -    }
  79.454 -
  79.455 -    /*
  79.456 -     * Actuall conversion code per X11 String
  79.457 -     */
  79.458 -    for (i = 0; i < nstrings; i++) {
  79.459 -        jstring string = (*env)->NewStringUTF(env,
  79.460 -                                              (const char *)strings[i]);
  79.461 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.462 -            (*env)->ExceptionDescribe(env);
  79.463 -            (*env)->ExceptionClear(env);
  79.464 -            goto wayout;
  79.465 -        }
  79.466 -
  79.467 -        if (JNU_IsNull(env, string)) {
  79.468 -            goto wayout;
  79.469 -        }
  79.470 -
  79.471 -        (*env)->SetObjectArrayElement(env, filenames, i, string);
  79.472 -
  79.473 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.474 -            (*env)->ExceptionDescribe(env);
  79.475 -            (*env)->ExceptionClear(env);
  79.476 -            goto wayout;
  79.477 -        }
  79.478 -
  79.479 -        (*env)->DeleteLocalRef(env, string);
  79.480 -    }
  79.481 -
  79.482 -    ret = filenames;
  79.483 - wayout:
  79.484 -    /*
  79.485 -     * Clean up and return
  79.486 -     */
  79.487 -    XFreeStringList(strings);
  79.488 -    AWT_UNLOCK();
  79.489 -    return ret;
  79.490 -}
  79.491 -
  79.492 -DECLARE_JAVA_CLASS(dataTransfererClazz, "sun/awt/datatransfer/DataTransferer")
  79.493 -
  79.494 -/**
  79.495 - * Returns a local reference to the singleton DataTransferer instance.
  79.496 - * The caller should delete the reference when done.
  79.497 - */
  79.498 -static jobject
  79.499 -get_data_transferer(JNIEnv* env) {
  79.500 -    jobject transferer = NULL;
  79.501 -
  79.502 -    DECLARE_STATIC_OBJECT_JAVA_METHOD(getInstanceMethodID, dataTransfererClazz,
  79.503 -                                     "getInstance",
  79.504 -                                     "()Lsun/awt/datatransfer/DataTransferer;");
  79.505 -
  79.506 -    transferer = (*env)->CallStaticObjectMethod(env, clazz, getInstanceMethodID);
  79.507 -
  79.508 -    if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.509 -        (*env)->ExceptionDescribe(env);
  79.510 -        (*env)->ExceptionClear(env);
  79.511 -    }
  79.512 -
  79.513 -    DASSERT(!JNU_IsNull(env, transferer));
  79.514 -
  79.515 -    return transferer;
  79.516 -}
  79.517 -
  79.518 -static jobject
  79.519 -call_convertData(JNIEnv* env, jobject source, jobject contents, jlong format,
  79.520 -                 jobject formatMap) {
  79.521 -    jobject transferer = get_data_transferer(env);
  79.522 -    jobject ret = NULL;
  79.523 -    DECLARE_OBJECT_JAVA_METHOD(convertDataMethodID, dataTransfererClazz,
  79.524 -                               "convertData",
  79.525 -                               "(Ljava/lang/Object;Ljava/awt/datatransfer/Transferable;JLjava/util/Map;Z)[B");
  79.526 -
  79.527 -    ret = (*env)->CallObjectMethod(env, transferer, convertDataMethodID,
  79.528 -                                   source, contents, format, formatMap,
  79.529 -                                   awt_currentThreadIsPrivileged(env));
  79.530 -
  79.531 -    if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.532 -        (*env)->ExceptionDescribe(env);
  79.533 -        (*env)->ExceptionClear(env);
  79.534 -    }
  79.535 -
  79.536 -    (*env)->DeleteLocalRef(env, transferer);
  79.537 -
  79.538 -    return ret;
  79.539 -}
  79.540 -
  79.541 -static void
  79.542 -process_convert_data_requests() {
  79.543 -    JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_4);
  79.544 -    jobject transferer = get_data_transferer(env);
  79.545 -
  79.546 -    DECLARE_VOID_JAVA_METHOD(processDataConversionRequestsMethodID,
  79.547 -                             dataTransfererClazz,
  79.548 -                             "processDataConversionRequests",
  79.549 -                             "()V");
  79.550 -
  79.551 -    (*env)->CallVoidMethod(env, transferer,
  79.552 -                           processDataConversionRequestsMethodID);
  79.553 -
  79.554 -    if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.555 -        (*env)->ExceptionDescribe(env);
  79.556 -        (*env)->ExceptionClear(env);
  79.557 -    }
  79.558 -
  79.559 -    (*env)->DeleteLocalRef(env, transferer);
  79.560 -}
  79.561 -
  79.562 -Boolean
  79.563 -awt_convertData(Widget w, Atom * selection, Atom * target, Atom * type,
  79.564 -                XtPointer * value, unsigned long *length, int32_t *format) {
  79.565 -    JNIEnv*  env  = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  79.566 -    Display* dpy = XtDisplay(w);
  79.567 -    awt_convertDataCallbackStruct* structPtr = NULL;
  79.568 -
  79.569 -    if (XFindContext(dpy, *selection, awt_convertDataContext,
  79.570 -                     (XPointer*)&structPtr) == XCNOMEM || structPtr == NULL) {
  79.571 -        return False;
  79.572 -    }
  79.573 -
  79.574 -    if ((*env)->PushLocalFrame(env, 2) < 0) {
  79.575 -        (*env)->ExceptionDescribe(env);
  79.576 -        (*env)->ExceptionClear(env);
  79.577 -        return False;
  79.578 -    }
  79.579 -
  79.580 -    if (*target == XA_TARGETS) {
  79.581 -        jlongArray formats = structPtr->formats;
  79.582 -        jsize      count;
  79.583 -        jlong*     targets;
  79.584 -        jboolean   isCopy;
  79.585 -
  79.586 -#ifndef _LP64 /* Atom and jlong are different sizes in the 32-bit build */
  79.587 -        Atom*      aValue;
  79.588 -        jlong*     saveTargets;
  79.589 -        jsize      i;
  79.590 -#endif
  79.591 -
  79.592 -        if (JNU_IsNull(env, formats)) {
  79.593 -            (*env)->PopLocalFrame(env, NULL);
  79.594 -            return False;
  79.595 -        }
  79.596 -
  79.597 -        count = (*env)->GetArrayLength(env, formats);
  79.598 -        if (count == 0) {
  79.599 -            (*env)->PopLocalFrame(env, NULL);
  79.600 -            return False;
  79.601 -        }
  79.602 -
  79.603 -        targets = (*env)->GetLongArrayElements(env, formats, &isCopy);
  79.604 -
  79.605 -        *type = XA_ATOM;
  79.606 -        *format = 32;
  79.607 -
  79.608 -#ifdef _LP64
  79.609 -        *value = XtMalloc(count * sizeof(Atom));
  79.610 -        memcpy((void *)*value, (void *)targets, count * sizeof(Atom));
  79.611 -#else
  79.612 -        *value = aValue = (Atom *)XtMalloc(count * sizeof(Atom));
  79.613 -        saveTargets = targets;
  79.614 -        for (i = 0; i < count; i++, aValue++, targets++) {
  79.615 -            *aValue = (Atom)*targets;
  79.616 -        }
  79.617 -        targets = saveTargets;
  79.618 -#endif
  79.619 -        (*env)->ReleaseLongArrayElements(env, formats, targets, JNI_ABORT);
  79.620 -
  79.621 -        *length = count;
  79.622 -
  79.623 -    } else if (*target == XInternAtom(dpy, _XA_DELETE, False)) {
  79.624 -
  79.625 -        /*
  79.626 -         * acknowledge the DELETE target here ... the "delete" semantic
  79.627 -         * of move will take place after the drop is complete.
  79.628 -         */
  79.629 -
  79.630 -        *type   = XInternAtom(dpy, _XA_NULL, False);
  79.631 -        *length = 0;
  79.632 -        *value  = (XtPointer)NULL;
  79.633 -        /* Uninitialized format can cause crash in Xt conversion code. */
  79.634 -        *format = 8;
  79.635 -    } else if (*target == XInternAtom(dpy, _XA_HOSTNAME, False)) {
  79.636 -        struct utsname name;
  79.637 -        XTextProperty  tp;
  79.638 -
  79.639 -        uname(&name);
  79.640 -
  79.641 -        if (!XStringListToTextProperty((char **)&name.nodename, 1, &tp)) {
  79.642 -            (*env)->PopLocalFrame(env, NULL);
  79.643 -            return False;
  79.644 -        }
  79.645 -
  79.646 -        *value = (XtPointer)XtCalloc(tp.nitems, sizeof(char));
  79.647 -
  79.648 -        memcpy((void *)*value, (const void *)tp.value, tp.nitems);
  79.649 -
  79.650 -        XFree((void *)tp.value);
  79.651 -
  79.652 -        *type   = tp.encoding;
  79.653 -        *length = tp.nitems + 1;
  79.654 -        *format = tp.format;
  79.655 -    } else if (*target == XInternAtom(dpy, _XA_FILENAME, False) ||
  79.656 -               *target == XInternAtom(dpy, _DT_FILENAME, False)) {
  79.657 -
  79.658 -        /*
  79.659 -         * Convert the internal representation to an File Name.
  79.660 -         * The data returned from dataConvert is a an array of
  79.661 -         * null separated bytes. Each series of bytes is a string
  79.662 -         * that is then converted to an XString which are then put
  79.663 -         * into an XStringList and put into an XTextProperty for
  79.664 -         * usage in other programs.
  79.665 -         *
  79.666 -         * It would be desireable to have dataConvert to this conversion
  79.667 -         * but it isn't possible to return a byte array that represents
  79.668 -         * the XTextProperty.
  79.669 -         */
  79.670 -        jbyteArray    data;
  79.671 -
  79.672 -        /*
  79.673 -         * Fix for 4513976.
  79.674 -         * Type None should be used instead of XT_CONVERT_FAIL
  79.675 -         * to report conversion failure.
  79.676 -         */
  79.677 -        /*  assume forthcoming error */
  79.678 -        *type   = None;
  79.679 -        *value  = (XtPointer)NULL;
  79.680 -        *length = 0;
  79.681 -        *format = 8;
  79.682 -
  79.683 -        data = call_convertData(env, structPtr->source, structPtr->transferable,
  79.684 -                                (jlong)*target, structPtr->formatMap);
  79.685 -
  79.686 -        /* error test */
  79.687 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.688 -            (*env)->ExceptionDescribe(env);
  79.689 -            (*env)->ExceptionClear(env);
  79.690 -            (*env)->PopLocalFrame(env, NULL);
  79.691 -            return False;
  79.692 -        }
  79.693 -        if (JNU_IsNull(env, data)) {
  79.694 -            (*env)->PopLocalFrame(env, NULL);
  79.695 -            return False;
  79.696 -        }
  79.697 -
  79.698 -        if (convertFileType(data, type, value, length, format) == False) {
  79.699 -            (*env)->PopLocalFrame(env, NULL);
  79.700 -            return False;
  79.701 -        }
  79.702 -    } else {
  79.703 -        jbyteArray bytes = NULL;
  79.704 -        jbyte*     copy = NULL;
  79.705 -
  79.706 -        /*
  79.707 -         * Fix for 4513976.
  79.708 -         * Type None should be used instead of XT_CONVERT_FAIL
  79.709 -         * to report conversion failure.
  79.710 -         */
  79.711 -        *type   = None; /* assume forthcoming error */
  79.712 -        *value  = (XtPointer)NULL;
  79.713 -        *length = 0;
  79.714 -        *format = 8;
  79.715 -
  79.716 -        bytes = call_convertData(env, structPtr->source, structPtr->transferable,
  79.717 -                                 (jlong)*target, structPtr->formatMap);
  79.718 -
  79.719 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.720 -            (*env)->ExceptionDescribe(env);
  79.721 -            (*env)->ExceptionClear(env);
  79.722 -            (*env)->PopLocalFrame(env, NULL);
  79.723 -            return False;
  79.724 -        }
  79.725 -
  79.726 -        if (bytes == NULL) {
  79.727 -            (*env)->PopLocalFrame(env, NULL);
  79.728 -            return False;
  79.729 -        } else {
  79.730 -            jsize len = (*env)->GetArrayLength(env, bytes);
  79.731 -
  79.732 -            if (len == 0) {
  79.733 -                *type   = *target;
  79.734 -                *format = 8;
  79.735 -                (*env)->PopLocalFrame(env, NULL);
  79.736 -                return True;
  79.737 -            }
  79.738 -
  79.739 -            copy = (jbyte*)XtCalloc(1, len * sizeof(jbyte));
  79.740 -            if (copy == (jbyte*)NULL) {
  79.741 -                JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  79.742 -                (*env)->PopLocalFrame(env, NULL);
  79.743 -                return False;
  79.744 -            }
  79.745 -
  79.746 -            (*env)->GetByteArrayRegion(env, (jbyteArray)bytes, 0, len, copy);
  79.747 -
  79.748 -            if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.749 -                (*env)->ExceptionDescribe(env);
  79.750 -                (*env)->ExceptionClear(env);
  79.751 -                XtFree((void *)copy);
  79.752 -                (*env)->PopLocalFrame(env, NULL);
  79.753 -                return False;
  79.754 -            }
  79.755 -
  79.756 -            *value  = (XtPointer)copy;
  79.757 -            *type   = *target;
  79.758 -            *length = len;
  79.759 -            *format = 8;
  79.760 -        }
  79.761 -    }
  79.762 -
  79.763 -    (*env)->PopLocalFrame(env, NULL);
  79.764 -    return True;
  79.765 -}
  79.766 -
  79.767 -
  79.768 -jlongArray
  79.769 -getSelectionTargetsHelper(JNIEnv* env, XtPointer value, unsigned long length)
  79.770 -{
  79.771 -    Atom* targets = (Atom*)value;
  79.772 -    jlongArray targetArray = NULL;
  79.773 -    jlong* checkedTargets = NULL;
  79.774 -    size_t count = 0, i = 0, j = 0;
  79.775 -
  79.776 -    /* Get rid of zero atoms if there are any. */
  79.777 -    for (; i < length; i++) {
  79.778 -        if (targets[i] != 0) {
  79.779 -            count++;
  79.780 -        }
  79.781 -    }
  79.782 -    checkedTargets = calloc(count, sizeof(jlong));
  79.783 -    if (checkedTargets == NULL) {
  79.784 -        JNU_ThrowOutOfMemoryError(env, "");
  79.785 -        (*env)->ExceptionDescribe(env);
  79.786 -        (*env)->ExceptionClear(env);
  79.787 -    } else {
  79.788 -        for (i = 0; i < length; i++) {
  79.789 -            if (targets[i] != 0) {
  79.790 -                checkedTargets[j++] = targets[i];
  79.791 -            }
  79.792 -        }
  79.793 -
  79.794 -        DASSERT(j == count);
  79.795 -
  79.796 -        if ((*env)->EnsureLocalCapacity(env, 1) >= 0) {
  79.797 -
  79.798 -            targetArray = (*env)->NewLongArray(env, count);
  79.799 -
  79.800 -            if (!JNU_IsNull(env, targetArray)) {
  79.801 -                (*env)->SetLongArrayRegion(env, targetArray, 0, count,
  79.802 -                                           checkedTargets);
  79.803 -
  79.804 -                if ((*env)->ExceptionCheck(env)) {
  79.805 -                    (*env)->ExceptionDescribe(env);
  79.806 -                    (*env)->ExceptionClear(env);
  79.807 -
  79.808 -                    (*env)->DeleteLocalRef(env, targetArray);
  79.809 -                    targetArray = NULL;
  79.810 -                }
  79.811 -            }
  79.812 -        }
  79.813 -        free(checkedTargets);
  79.814 -    }
  79.815 -
  79.816 -    return targetArray;
  79.817 -}
  79.818 -
  79.819 -static void
  79.820 -get_selection_targets_callback(Widget w, XtPointer client_data, Atom* selection,
  79.821 -                               Atom* type, XtPointer value,
  79.822 -                               unsigned long* length, int32_t* format) {
  79.823 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  79.824 -    jobject* pReturnArray = (jobject*)client_data;
  79.825 -    SelectionStatus status = SelectionFailure;
  79.826 -
  79.827 -    /*
  79.828 -     * It is highly unlikely that TARGETS will ever be passed even though that
  79.829 -     * was what was requested. However, XA_ATOM ("ATOM") is likely.
  79.830 -     * Actually they are the same so treat them as such. See XToolKit
  79.831 -     * Intrinsic Manual on XtSelectionCallbackProc for more details on type.
  79.832 -     */
  79.833 -    if (*type == XA_TARGETS || *type == XA_ATOM) {
  79.834 -        jlongArray targetArray = getSelectionTargetsHelper(env, value, *length);
  79.835 -        if (!JNU_IsNull(env, targetArray)) {
  79.836 -            *pReturnArray = (*env)->NewGlobalRef(env, targetArray);
  79.837 -            status = SelectionSuccess;
  79.838 -            (*env)->DeleteLocalRef(env, targetArray);
  79.839 -        }
  79.840 -    } else if (*type == XT_CONVERT_FAIL) {
  79.841 -        status = SelectionOwnerTimedOut;
  79.842 -    } else {
  79.843 -        /*
  79.844 -         * A part of the fix for 4259272.
  79.845 -         * Actually Xt Intrinsics says about XtSelectionCallback that
  79.846 -         * "if there is no owner for the specified selection, or that owner
  79.847 -         * cannot convert the selected data to the requested type, then this
  79.848 -         * callback is called with value NULL and length zero".
  79.849 -         * But we report success if type is not TARGETS, XA_ATOM or XT_CONVERT_FAIL,
  79.850 -         * and we should not change this behaviour. We just return zero-length
  79.851 -         * array instead of null, because null denotes that we could not get
  79.852 -         * selection targets at the time of tracking changes of available on
  79.853 -         * the selection data flavors.
  79.854 -         */
  79.855 -        jlongArray targetArray = (*env)->NewLongArray(env, 0);
  79.856 -        *pReturnArray = (*env)->NewGlobalRef(env, targetArray);
  79.857 -        /*
  79.858 -         * Fix for 4655996.
  79.859 -         * Report success if there is no owner for this selection or the owner
  79.860 -         * fails to provide target types.
  79.861 -         */
  79.862 -        status = SelectionSuccess;
  79.863 -        (*env)->DeleteLocalRef(env, targetArray);
  79.864 -    }
  79.865 -
  79.866 -    if (value != NULL) {
  79.867 -        XtFree(value);
  79.868 -        value = NULL;
  79.869 -    }
  79.870 -
  79.871 -    set_selection_status(status);
  79.872 -}
  79.873 -
  79.874 -static void
  79.875 -get_selection_data_callback(Widget w, XtPointer client_data, Atom * selection,
  79.876 -                            Atom * type, XtPointer value, unsigned long *length,
  79.877 -                            int32_t *format) {
  79.878 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  79.879 -    jobject* pData = (jobject*)client_data;
  79.880 -    SelectionStatus status = SelectionFailure;
  79.881 -
  79.882 -    if (*type == XT_CONVERT_FAIL) {
  79.883 -        status = SelectionOwnerTimedOut;
  79.884 -    } else if (*type != None) {
  79.885 -        if ((*env)->EnsureLocalCapacity(env, 1) >= 0) {
  79.886 -            jsize size = (*length <= INT_MAX) ? *length : INT_MAX;
  79.887 -            jbyteArray array = (*env)->NewByteArray(env, size);
  79.888 -
  79.889 -            if (!JNU_IsNull(env, array)) {
  79.890 -                (*env)->SetByteArrayRegion(env, array, 0, size, (jbyte*)value);
  79.891 -                if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
  79.892 -                    (*env)->ExceptionDescribe(env);
  79.893 -                    (*env)->ExceptionClear(env);
  79.894 -                } else {
  79.895 -                    *pData = (*env)->NewGlobalRef(env, array);
  79.896 -                    status = SelectionSuccess;
  79.897 -                }
  79.898 -
  79.899 -                (*env)->DeleteLocalRef(env, array);
  79.900 -            }
  79.901 -        }
  79.902 -    }
  79.903 -
  79.904 -    if (value != NULL) {
  79.905 -        XtFree(value);
  79.906 -        value = NULL;
  79.907 -    }
  79.908 -
  79.909 -    set_selection_status(status);
  79.910 -}
  79.911 -
  79.912 -static int32_t
  79.913 -wait_for_selection_event(void *data) {
  79.914 -    process_convert_data_requests();
  79.915 -    return get_selection_status() != SelectionPending;
  79.916 -}
  79.917 -
  79.918 -jlongArray
  79.919 -get_selection_targets(JNIEnv *env, Atom selection, Time time_stamp) {
  79.920 -    jlongArray ret     = NULL;
  79.921 -    jlongArray targets = NULL;
  79.922 -    SelectionStatus status = SelectionPending;
  79.923 -
  79.924 -    AWT_LOCK();
  79.925 -
  79.926 -    XtAppSetSelectionTimeout(awt_appContext,
  79.927 -            JNU_CallStaticMethodByName(env, NULL, "sun/awt/UNIXToolkit",
  79.928 -                                       "getDatatransferTimeout", "()I").i);
  79.929 -
  79.930 -    set_selection_status(SelectionPending);
  79.931 -    XtGetSelectionValue(awt_root_shell, selection, XA_TARGETS,
  79.932 -                        get_selection_targets_callback, (XtPointer)&targets,
  79.933 -                        time_stamp);
  79.934 -
  79.935 -    awt_MToolkit_modalWait(wait_for_selection_event, NULL);
  79.936 -    status = get_selection_status();
  79.937 -
  79.938 -    AWT_FLUSH_UNLOCK();
  79.939 -
  79.940 -    if (!JNU_IsNull(env, targets)) {
  79.941 -        ret = (*env)->NewLocalRef(env, targets);
  79.942 -        (*env)->DeleteGlobalRef(env, targets);
  79.943 -    }
  79.944 -
  79.945 -    switch (status) {
  79.946 -    case SelectionSuccess:
  79.947 -        break;
  79.948 -    case SelectionFailure:
  79.949 -        JNU_ThrowByName(env, "java/lang/IllegalStateException",
  79.950 -                        "Failed to get selection targets");
  79.951 -        break;
  79.952 -    case SelectionOwnerTimedOut:
  79.953 -        // return an empty array of targets if the selection owner timed out
  79.954 -        ret = (*env)->NewLongArray(env, 0);
  79.955 -        break;
  79.956 -    default:
  79.957 -        JNU_ThrowByName(env, "java/lang/IllegalStateException",
  79.958 -                        "Unexpected selection status");
  79.959 -        break;
  79.960 -    }
  79.961 -
  79.962 -    return ret;
  79.963 -}
  79.964 -
  79.965 -jbyteArray
  79.966 -get_selection_data(JNIEnv *env, Atom selection, Atom target, Time time_stamp) {
  79.967 -    jbyteArray ret    = NULL;
  79.968 -    jbyteArray data   = NULL;
  79.969 -    SelectionStatus status = SelectionPending;
  79.970 -
  79.971 -    AWT_LOCK();
  79.972 -
  79.973 -    XtAppSetSelectionTimeout(awt_appContext,
  79.974 -            JNU_CallStaticMethodByName(env, NULL, "sun/awt/UNIXToolkit",
  79.975 -                                       "getDatatransferTimeout", "()I").i);
  79.976 -
  79.977 -    set_selection_status(SelectionPending);
  79.978 -    XtGetSelectionValue(awt_root_shell, selection, target,
  79.979 -                        get_selection_data_callback,
  79.980 -                        (XtPointer)&data, time_stamp);
  79.981 -
  79.982 -    awt_MToolkit_modalWait(wait_for_selection_event, NULL);
  79.983 -    status = get_selection_status();
  79.984 -
  79.985 -    AWT_FLUSH_UNLOCK();
  79.986 -
  79.987 -    if (!JNU_IsNull(env, data)) {
  79.988 -        ret = (*env)->NewLocalRef(env, data);
  79.989 -        (*env)->DeleteGlobalRef(env, data);
  79.990 -    }
  79.991 -
  79.992 -    switch (status) {
  79.993 -    case SelectionSuccess:
  79.994 -        break;
  79.995 -    case SelectionFailure:
  79.996 -        JNU_ThrowIOException(env, "Failed to get selection data");
  79.997 -        break;
  79.998 -    case SelectionOwnerTimedOut:
  79.999 -        JNU_ThrowIOException(env, "Selection owner timed out");
 79.1000 -        break;
 79.1001 -    default:
 79.1002 -        JNU_ThrowIOException(env, "Unexpected selection status");
 79.1003 -        break;
 79.1004 -    }
 79.1005 -
 79.1006 -    return ret;
 79.1007 -}
 79.1008 -
 79.1009 -void
 79.1010 -awt_cleanupConvertDataContext(JNIEnv *env, Atom selectionAtom) {
 79.1011 -    awt_convertDataCallbackStruct* structPtr = NULL;
 79.1012 -
 79.1013 -    if (XFindContext(awt_display, selectionAtom, awt_convertDataContext,
 79.1014 -                     (XPointer*)&structPtr) == 0 && structPtr != NULL) {
 79.1015 -
 79.1016 -        (*env)->DeleteGlobalRef(env, structPtr->source);
 79.1017 -        (*env)->DeleteGlobalRef(env, structPtr->transferable);
 79.1018 -        (*env)->DeleteGlobalRef(env, structPtr->formatMap);
 79.1019 -        (*env)->DeleteGlobalRef(env, structPtr->formats);
 79.1020 -        free(structPtr);
 79.1021 -    }
 79.1022 -    /*
 79.1023 -     * Xlib Programming Manual says that it is better to erase
 79.1024 -     * the current entry with XDeleteContext() before XSaveContext().
 79.1025 -     */
 79.1026 -    XDeleteContext(awt_display, selectionAtom, awt_convertDataContext);
 79.1027 -    if (XSaveContext(awt_display, selectionAtom, awt_convertDataContext,
 79.1028 -                     (XPointer)NULL) == XCNOMEM) {
 79.1029 -        JNU_ThrowInternalError(env, "XError");
 79.1030 -        (*env)->ExceptionDescribe(env);
 79.1031 -        (*env)->ExceptionClear(env);
 79.1032 -    }
 79.1033 -}
 79.1034 -
 79.1035 -static Bool exitSecondaryLoop = True;
 79.1036 -
 79.1037 -/*
 79.1038 - * This predicate procedure allows the Toolkit thread to process specific events
 79.1039 - * while it is blocked waiting for the event dispatch thread to process
 79.1040 - * a SunDropTargetEvent. We need this to prevent deadlock when the client code
 79.1041 - * processing SunDropTargetEvent sets or gets the contents of the system
 79.1042 - * clipboard/selection. In this case the event dispatch thread waits for the
 79.1043 - * Toolkit thread to process PropertyNotify or SelectionNotify events.
 79.1044 - */
 79.1045 -static Bool
 79.1046 -secondary_loop_event(Display* dpy, XEvent* event, char* arg) {
 79.1047 -    return (event->type == SelectionNotify ||
 79.1048 -            event->type == SelectionClear  ||
 79.1049 -            event->type == PropertyNotify) ? True : False;
 79.1050 -}
 79.1051 -
 79.1052 -
 79.1053 -JNIEXPORT void JNICALL
 79.1054 -Java_sun_awt_motif_MToolkitThreadBlockedHandler_enter(JNIEnv *env, jobject this) {
 79.1055 -    DASSERT(exitSecondaryLoop && awt_currentThreadIsPrivileged(env));
 79.1056 -    exitSecondaryLoop = False;
 79.1057 -    while (!exitSecondaryLoop) {
 79.1058 -        XEvent event;
 79.1059 -        while (XCheckIfEvent(awt_display, &event, secondary_loop_event, NULL)) {
 79.1060 -            XtDispatchEvent(&event);
 79.1061 -        }
 79.1062 -        AWT_WAIT(AWT_DND_POLL_INTERVAL);
 79.1063 -    }
 79.1064 -}
 79.1065 -
 79.1066 -JNIEXPORT void JNICALL
 79.1067 -Java_sun_awt_motif_MToolkitThreadBlockedHandler_exit(JNIEnv *env, jobject this) {
 79.1068 -    DASSERT(!exitSecondaryLoop && !awt_currentThreadIsPrivileged(env));
 79.1069 -    exitSecondaryLoop = True;
 79.1070 -    AWT_NOTIFY_ALL();
 79.1071 -}
    80.1 --- a/src/solaris/native/sun/awt/awt_DataTransferer.h	Wed Sep 17 13:45:37 2008 -0700
    80.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.3 @@ -1,275 +0,0 @@
    80.4 -/*
    80.5 - * Copyright 2000-2004 Sun Microsystems, Inc.  All Rights Reserved.
    80.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    80.7 - *
    80.8 - * This code is free software; you can redistribute it and/or modify it
    80.9 - * under the terms of the GNU General Public License version 2 only, as
   80.10 - * published by the Free Software Foundation.  Sun designates this
   80.11 - * particular file as subject to the "Classpath" exception as provided
   80.12 - * by Sun in the LICENSE file that accompanied this code.
   80.13 - *
   80.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   80.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   80.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   80.17 - * version 2 for more details (a copy is included in the LICENSE file that
   80.18 - * accompanied this code).
   80.19 - *
   80.20 - * You should have received a copy of the GNU General Public License version
   80.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   80.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   80.23 - *
   80.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   80.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   80.26 - * have any questions.
   80.27 - */
   80.28 -
   80.29 -#ifndef AWT_DATATRANSFERER_H
   80.30 -#define AWT_DATATRANSFERER_H
   80.31 -
   80.32 -#include <X11/Intrinsic.h>
   80.33 -#include <inttypes.h>
   80.34 -
   80.35 -#define _XA_DELETE          "DELETE"
   80.36 -#define _XA_FILENAME        "FILE_NAME"
   80.37 -#define _XA_HOSTNAME        "HOST_NAME"
   80.38 -#define _XA_NULL            "NULL"
   80.39 -#define _DT_FILENAME        "_DT_NETFILE"
   80.40 -
   80.41 -#define AWT_DND_POLL_INTERVAL ((unsigned long)250) /* milliseconds */
   80.42 -
   80.43 -typedef struct {
   80.44 -    jobject    source;
   80.45 -    jobject    transferable;
   80.46 -    jobject    formatMap;
   80.47 -    jlongArray formats;
   80.48 -} awt_convertDataCallbackStruct;
   80.49 -
   80.50 -extern XContext awt_convertDataContext; /* XContext is not 64 bits */
   80.51 -
   80.52 -extern Atom XA_TARGETS;
   80.53 -
   80.54 -/*
   80.55 - * Single routine to convert to target FILE_NAME or _DT_FILENAME
   80.56 - */
   80.57 -Boolean
   80.58 -convertFileType(jbyteArray data, Atom * type, XtPointer * value,
   80.59 -                unsigned long *length, int32_t *format);
   80.60 -
   80.61 -Boolean
   80.62 -awt_convertData(Widget w, Atom * selection, Atom * target, Atom * type,
   80.63 -                XtPointer * value, unsigned long *length, int32_t *format);
   80.64 -
   80.65 -jlongArray
   80.66 -get_selection_targets(JNIEnv *env, Atom selection, Time time_stamp);
   80.67 -
   80.68 -jlongArray
   80.69 -getSelectionTargetsHelper(JNIEnv* env, XtPointer value, unsigned long length);
   80.70 -
   80.71 -jbyteArray
   80.72 -get_selection_data(JNIEnv *env, Atom selection, Atom format, Time time_stamp);
   80.73 -
   80.74 -void
   80.75 -awt_cleanupConvertDataContext(JNIEnv *env, Atom selectionAtom);
   80.76 -
   80.77 -/*
   80.78 - * NOTE: You need these macros only if you take care of performance, since they
   80.79 - * provide proper caching. Otherwise you can use JNU_CallMethodByName etc.
   80.80 - */
   80.81 -
   80.82 -/*
   80.83 - * This macro defines a function which returns the class for the specified
   80.84 - * class name with proper caching and error handling.
   80.85 - */
   80.86 -#define DECLARE_JAVA_CLASS(javaclazz, name)                                    \
   80.87 -static jclass                                                                  \
   80.88 -get_ ## javaclazz(JNIEnv* env) {                                               \
   80.89 -    static jclass javaclazz = NULL;                                            \
   80.90 -                                                                               \
   80.91 -    if (JNU_IsNull(env, javaclazz)) {                                          \
   80.92 -        jclass javaclazz ## Local = (*env)->FindClass(env, name);              \
   80.93 -                                                                               \
   80.94 -        if (!JNU_IsNull(env, javaclazz ## Local)) {                            \
   80.95 -            javaclazz = (jclass)(*env)->NewGlobalRef(env, javaclazz ## Local); \
   80.96 -            (*env)->DeleteLocalRef(env, javaclazz ## Local);                   \
   80.97 -            if (JNU_IsNull(env, javaclazz)) {                                  \
   80.98 -                JNU_ThrowOutOfMemoryError(env, "");                            \
   80.99 -            }                                                                  \
  80.100 -        }                                                                      \
  80.101 -                                                                               \
  80.102 -        if (!JNU_IsNull(env, ((*env)->ExceptionOccurred(env)))) {              \
  80.103 -            (*env)->ExceptionDescribe(env);                                    \
  80.104 -            (*env)->ExceptionClear(env);                                       \
  80.105 -        }                                                                      \
  80.106 -    }                                                                          \
  80.107 -                                                                               \
  80.108 -    DASSERT(!JNU_IsNull(env, javaclazz));                                      \
  80.109 -                                                                               \
  80.110 -    return javaclazz;                                                          \
  80.111 -}
  80.112 -
  80.113 -/*
  80.114 - * The following macros defines blocks of code which retrieve a method of the
  80.115 - * specified class identified with the specified name and signature.
  80.116 - * The specified class should be previously declared with DECLARE_JAVA_CLASS.
  80.117 - * These macros should be placed at the beginning of a block, after definition
  80.118 - * of local variables, but before the code begins.
  80.119 - */
  80.120 -#define DECLARE_VOID_JAVA_METHOD(method, javaclazz, name, signature)           \
  80.121 -    static jmethodID method = NULL;                                            \
  80.122 -                                                                               \
  80.123 -    if (JNU_IsNull(env, method)) {                                             \
  80.124 -        jclass clazz = get_ ## javaclazz(env);                                 \
  80.125 -                                                                               \
  80.126 -        if (JNU_IsNull(env, clazz)) {                                          \
  80.127 -            return;                                                            \
  80.128 -        }                                                                      \
  80.129 -                                                                               \
  80.130 -        method = (*env)->GetMethodID(env, clazz, name, signature);             \
  80.131 -                                                                               \
  80.132 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {                         \
  80.133 -            (*env)->ExceptionDescribe(env);                                    \
  80.134 -            (*env)->ExceptionClear(env);                                       \
  80.135 -        }                                                                      \
  80.136 -                                                                               \
  80.137 -        if (JNU_IsNull(env, method)) {                                         \
  80.138 -            DASSERT(False);                                                    \
  80.139 -            return;                                                            \
  80.140 -        }                                                                      \
  80.141 -    }
  80.142 -
  80.143 -#define DECLARE_BOOLEAN_JAVA_METHOD(method, javaclazz, name, signature)        \
  80.144 -    static jmethodID method = NULL;                                            \
  80.145 -                                                                               \
  80.146 -    if (JNU_IsNull(env, method)) {                                             \
  80.147 -        jclass clazz = get_ ## javaclazz(env);                                 \
  80.148 -                                                                               \
  80.149 -        if (JNU_IsNull(env, clazz)) {                                          \
  80.150 -            return False;                                                      \
  80.151 -        }                                                                      \
  80.152 -                                                                               \
  80.153 -        method = (*env)->GetMethodID(env, clazz, name, signature);             \
  80.154 -                                                                               \
  80.155 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {                         \
  80.156 -            (*env)->ExceptionDescribe(env);                                    \
  80.157 -            (*env)->ExceptionClear(env);                                       \
  80.158 -        }                                                                      \
  80.159 -                                                                               \
  80.160 -        if (JNU_IsNull(env, method)) {                                         \
  80.161 -            DASSERT(False);                                                    \
  80.162 -            return False;                                                      \
  80.163 -        }                                                                      \
  80.164 -    }
  80.165 -
  80.166 -#define DECLARE_JINT_JAVA_METHOD(method, javaclazz, name, signature)           \
  80.167 -    static jmethodID method = NULL;                                            \
  80.168 -                                                                               \
  80.169 -    if (JNU_IsNull(env, method)) {                                             \
  80.170 -        jclass clazz = get_ ## javaclazz(env);                                 \
  80.171 -                                                                               \
  80.172 -        if (JNU_IsNull(env, clazz)) {                                          \
  80.173 -            return java_awt_dnd_DnDConstants_ACTION_NONE;                      \
  80.174 -        }                                                                      \
  80.175 -                                                                               \
  80.176 -        method = (*env)->GetMethodID(env, clazz, name, signature);             \
  80.177 -                                                                               \
  80.178 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {                         \
  80.179 -            (*env)->ExceptionDescribe(env);                                    \
  80.180 -            (*env)->ExceptionClear(env);                                       \
  80.181 -        }                                                                      \
  80.182 -                                                                               \
  80.183 -        if (JNU_IsNull(env, method)) {                                         \
  80.184 -            DASSERT(False);                                                    \
  80.185 -            return java_awt_dnd_DnDConstants_ACTION_NONE;                      \
  80.186 -        }                                                                      \
  80.187 -    }
  80.188 -
  80.189 -#define DECLARE_OBJECT_JAVA_METHOD(method, javaclazz, name, signature)         \
  80.190 -    static jmethodID method = NULL;                                            \
  80.191 -                                                                               \
  80.192 -    if (JNU_IsNull(env, method)) {                                             \
  80.193 -        jclass clazz = get_ ## javaclazz(env);                                 \
  80.194 -                                                                               \
  80.195 -        if (JNU_IsNull(env, clazz)) {                                          \
  80.196 -            return NULL;                                                       \
  80.197 -        }                                                                      \
  80.198 -                                                                               \
  80.199 -        method = (*env)->GetMethodID(env, clazz, name, signature);             \
  80.200 -                                                                               \
  80.201 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {                         \
  80.202 -            (*env)->ExceptionDescribe(env);                                    \
  80.203 -            (*env)->ExceptionClear(env);                                       \
  80.204 -        }                                                                      \
  80.205 -                                                                               \
  80.206 -        if (JNU_IsNull(env, method)) {                                         \
  80.207 -            DASSERT(False);                                                    \
  80.208 -            return NULL;                                                       \
  80.209 -        }                                                                      \
  80.210 -    }
  80.211 -
  80.212 -#define DECLARE_STATIC_OBJECT_JAVA_METHOD(method, javaclazz, name, signature)  \
  80.213 -    static jmethodID method = NULL;                                            \
  80.214 -    jclass clazz = get_ ## javaclazz(env);                                     \
  80.215 -                                                                               \
  80.216 -    if (JNU_IsNull(env, clazz)) {                                              \
  80.217 -        return NULL;                                                           \
  80.218 -    }                                                                          \
  80.219 -                                                                               \
  80.220 -    if (JNU_IsNull(env, method)) {                                             \
  80.221 -        method = (*env)->GetStaticMethodID(env, clazz, name, signature);       \
  80.222 -                                                                               \
  80.223 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {                         \
  80.224 -            (*env)->ExceptionDescribe(env);                                    \
  80.225 -            (*env)->ExceptionClear(env);                                       \
  80.226 -        }                                                                      \
  80.227 -                                                                               \
  80.228 -        if (JNU_IsNull(env, method)) {                                         \
  80.229 -            DASSERT(False);                                                    \
  80.230 -            return NULL;                                                       \
  80.231 -        }                                                                      \
  80.232 -    }
  80.233 -
  80.234 -#define DECLARE_STATIC_VOID_JAVA_METHOD(method, javaclazz, name, signature)    \
  80.235 -    static jmethodID method = NULL;                                            \
  80.236 -    jclass clazz = get_ ## javaclazz(env);                                     \
  80.237 -                                                                               \
  80.238 -    if (JNU_IsNull(env, clazz)) {                                              \
  80.239 -        return;                                                                \
  80.240 -    }                                                                          \
  80.241 -                                                                               \
  80.242 -    if (JNU_IsNull(env, method)) {                                             \
  80.243 -        method = (*env)->GetStaticMethodID(env, clazz, name, signature);       \
  80.244 -                                                                               \
  80.245 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {                         \
  80.246 -            (*env)->ExceptionDescribe(env);                                    \
  80.247 -            (*env)->ExceptionClear(env);                                       \
  80.248 -        }                                                                      \
  80.249 -                                                                               \
  80.250 -        if (JNU_IsNull(env, method)) {                                         \
  80.251 -            DASSERT(False);                                                    \
  80.252 -            return;                                                            \
  80.253 -        }                                                                      \
  80.254 -    }
  80.255 -
  80.256 -#define DECLARE_STATIC_JINT_JAVA_METHOD(method, javaclazz, name, signature)    \
  80.257 -    static jmethodID method = NULL;                                            \
  80.258 -    jclass clazz = get_ ## javaclazz(env);                                     \
  80.259 -                                                                               \
  80.260 -    if (JNU_IsNull(env, clazz)) {                                              \
  80.261 -        return java_awt_dnd_DnDConstants_ACTION_NONE;                          \
  80.262 -    }                                                                          \
  80.263 -                                                                               \
  80.264 -    if (JNU_IsNull(env, method)) {                                             \
  80.265 -        method = (*env)->GetStaticMethodID(env, clazz, name, signature);       \
  80.266 -                                                                               \
  80.267 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {                         \
  80.268 -            (*env)->ExceptionDescribe(env);                                    \
  80.269 -            (*env)->ExceptionClear(env);                                       \
  80.270 -        }                                                                      \
  80.271 -                                                                               \
  80.272 -        if (JNU_IsNull(env, method)) {                                         \
  80.273 -            DASSERT(False);                                                    \
  80.274 -            return java_awt_dnd_DnDConstants_ACTION_NONE;                      \
  80.275 -        }                                                                      \
  80.276 -    }
  80.277 -
  80.278 -#endif /* AWT_DATATRANSFERER_H */
    81.1 --- a/src/solaris/native/sun/awt/awt_DrawingSurface.c	Wed Sep 17 13:45:37 2008 -0700
    81.2 +++ b/src/solaris/native/sun/awt/awt_DrawingSurface.c	Fri Sep 19 19:38:12 2008 -0700
    81.3 @@ -29,7 +29,7 @@
    81.4  
    81.5  #include "awt_p.h"
    81.6  #include "java_awt_Component.h"
    81.7 -#include "sun_awt_motif_MComponentPeer.h"
    81.8 +//#include "sun_awt_motif_MComponentPeer.h"
    81.9  
   81.10  #include "awt_Component.h"
   81.11  
    82.1 --- a/src/solaris/native/sun/awt/awt_FileDialog.c	Wed Sep 17 13:45:37 2008 -0700
    82.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.3 @@ -1,925 +0,0 @@
    82.4 -/*
    82.5 - * Copyright 1995-2004 Sun Microsystems, Inc.  All Rights Reserved.
    82.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    82.7 - *
    82.8 - * This code is free software; you can redistribute it and/or modify it
    82.9 - * under the terms of the GNU General Public License version 2 only, as
   82.10 - * published by the Free Software Foundation.  Sun designates this
   82.11 - * particular file as subject to the "Classpath" exception as provided
   82.12 - * by Sun in the LICENSE file that accompanied this code.
   82.13 - *
   82.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   82.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   82.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   82.17 - * version 2 for more details (a copy is included in the LICENSE file that
   82.18 - * accompanied this code).
   82.19 - *
   82.20 - * You should have received a copy of the GNU General Public License version
   82.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   82.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   82.23 - *
   82.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   82.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   82.26 - * have any questions.
   82.27 - */
   82.28 -
   82.29 -#ifdef HEADLESS
   82.30 -    #error This file should not be included in headless library
   82.31 -#endif
   82.32 -
   82.33 -#include "awt_p.h"
   82.34 -#include <Xm/AtomMgr.h>
   82.35 -#include <Xm/Protocols.h>
   82.36 -#include <sys/param.h>
   82.37 -#include <string.h>
   82.38 -#include <stdlib.h>
   82.39 -#include "awt_p.h"
   82.40 -#include "java_awt_FileDialog.h"
   82.41 -#include "java_awt_event_MouseWheelEvent.h"
   82.42 -#include "sun_awt_motif_MFileDialogPeer.h"
   82.43 -#include "sun_awt_motif_MComponentPeer.h"
   82.44 -#include "multi_font.h"
   82.45 -
   82.46 -#include "awt_Component.h"
   82.47 -
   82.48 -#include <jni.h>
   82.49 -#include <jni_util.h>
   82.50 -#include <Xm/FileSB.h>
   82.51 -
   82.52 -#define MAX_DIR_PATH_LEN    1024
   82.53 -
   82.54 -extern void Text_handlePaste(Widget w, XtPointer client_data, XEvent * event,
   82.55 -                             Boolean * cont);
   82.56 -
   82.57 -extern struct MComponentPeerIDs mComponentPeerIDs;
   82.58 -
   82.59 -extern AwtGraphicsConfigDataPtr
   82.60 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   82.61 -
   82.62 -/* fieldIDs for FileDialog fields and methods that may be accessed from C */
   82.63 -static struct FileDialogIDs {
   82.64 -    jfieldID mode;
   82.65 -    jfieldID file;
   82.66 -} fileDialogIDs;
   82.67 -
   82.68 -/* the field to store the default search procedure */
   82.69 -static XmSearchProc DefaultSearchProc = NULL;
   82.70 -
   82.71 -/* mouse wheel handler for scrolling */
   82.72 -void File_handleWheel(Widget w, XtPointer client_data, XEvent* event, Boolean* cont);
   82.73 -
   82.74 -/*
   82.75 - * Class:     java_awt_FileDialog
   82.76 - * Method:    initIDs
   82.77 - * Signature: ()V
   82.78 - */
   82.79 -
   82.80 -/* This function gets called from the static initializer for FileDialog.java
   82.81 -   to initialize the fieldIDs for fields that may be accessed from C */
   82.82 -
   82.83 -JNIEXPORT void JNICALL
   82.84 -Java_java_awt_FileDialog_initIDs
   82.85 -  (JNIEnv *env, jclass cls)
   82.86 -{
   82.87 -    fileDialogIDs.mode = (*env)->GetFieldID(env, cls, "mode", "I");
   82.88 -    fileDialogIDs.file =
   82.89 -      (*env)->GetFieldID(env, cls, "file", "Ljava/lang/String;");
   82.90 -
   82.91 -    DASSERT(fileDialogIDs.mode != NULL);
   82.92 -    DASSERT(fileDialogIDs.file != NULL);
   82.93 -}
   82.94 -
   82.95 -/*
   82.96 - * client_data is MFileDialogPeer instance pointer
   82.97 - */
   82.98 -static void
   82.99 -FileDialog_OK(Widget w,
  82.100 -              void *client_data,
  82.101 -              XmFileSelectionBoxCallbackStruct * call_data)
  82.102 -{
  82.103 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  82.104 -    jobject this = (jobject) client_data;
  82.105 -    struct FrameData *fdata;
  82.106 -    char *file;
  82.107 -    jstring jstr;
  82.108 -    XmStringContext   stringContext;
  82.109 -    XmStringDirection direction;
  82.110 -    XmStringCharSet   charset;
  82.111 -    Boolean           separator;
  82.112 -
  82.113 -    fdata = (struct FrameData *)JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.114 -
  82.115 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0)
  82.116 -        return;
  82.117 -
  82.118 -    if (!XmStringInitContext(&stringContext, call_data->value))
  82.119 -        return;
  82.120 -
  82.121 -    if (!XmStringGetNextSegment(stringContext, &file, &charset,
  82.122 -                                &direction, &separator))
  82.123 -        file = NULL;
  82.124 -
  82.125 -    if (file == NULL)
  82.126 -        jstr = NULL;
  82.127 -    else
  82.128 -        jstr = JNU_NewStringPlatform(env, (const char *) file);
  82.129 -
  82.130 -    if (jstr != 0) {
  82.131 -        JNU_CallMethodByName(env, NULL, this, "handleSelected",
  82.132 -                             "(Ljava/lang/String;)V", jstr);
  82.133 -        (*env)->DeleteLocalRef(env, jstr);
  82.134 -    }
  82.135 -    if ((*env)->ExceptionOccurred(env)) {
  82.136 -        (*env)->ExceptionDescribe(env);
  82.137 -        (*env)->ExceptionClear(env);
  82.138 -    }
  82.139 -
  82.140 -    XmStringFreeContext(stringContext);
  82.141 -    if (file != NULL)
  82.142 -        XtFree(file);
  82.143 -}
  82.144 -
  82.145 -/*
  82.146 - * client_data is MFileDialogPeer instance pointer
  82.147 - */
  82.148 -static void
  82.149 -FileDialog_CANCEL(Widget w,
  82.150 -                  void *client_data,
  82.151 -                  XmFileSelectionBoxCallbackStruct * call_data)
  82.152 -{
  82.153 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  82.154 -    jobject this = (jobject) client_data;
  82.155 -    struct FrameData *fdata;
  82.156 -
  82.157 -    fdata = (struct FrameData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.158 -
  82.159 -    JNU_CallMethodByName(env, NULL, (jobject) client_data, "handleCancel", "()V");
  82.160 -    if ((*env)->ExceptionOccurred(env)) {
  82.161 -        (*env)->ExceptionDescribe(env);
  82.162 -        (*env)->ExceptionClear(env);
  82.163 -    }
  82.164 -}
  82.165 -
  82.166 -
  82.167 -/*
  82.168 - * client_data is MFileDialogPeer instance pointer
  82.169 - */
  82.170 -static void
  82.171 -FileDialog_quit(Widget w,
  82.172 -                XtPointer client_data,
  82.173 -                XtPointer call_data)
  82.174 -{
  82.175 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  82.176 -
  82.177 -    JNU_CallMethodByName(env, NULL, (jobject) client_data, "handleQuit", "()V");
  82.178 -    if ((*env)->ExceptionOccurred(env)) {
  82.179 -        (*env)->ExceptionDescribe(env);
  82.180 -        (*env)->ExceptionClear(env);
  82.181 -    }
  82.182 -}
  82.183 -
  82.184 -static void
  82.185 -setDeleteCallback(jobject this, struct FrameData *wdata)
  82.186 -{
  82.187 -    Atom xa_WM_DELETE_WINDOW;
  82.188 -    Atom xa_WM_PROTOCOLS;
  82.189 -
  82.190 -    XtVaSetValues(wdata->winData.shell,
  82.191 -                  XmNdeleteResponse, XmDO_NOTHING,
  82.192 -                  NULL);
  82.193 -    xa_WM_DELETE_WINDOW = XmInternAtom(XtDisplay(wdata->winData.shell),
  82.194 -                                       "WM_DELETE_WINDOW", False);
  82.195 -    xa_WM_PROTOCOLS = XmInternAtom(XtDisplay(wdata->winData.shell),
  82.196 -                                   "WM_PROTOCOLS", False);
  82.197 -
  82.198 -    XmAddProtocolCallback(wdata->winData.shell,
  82.199 -                          xa_WM_PROTOCOLS,
  82.200 -                          xa_WM_DELETE_WINDOW,
  82.201 -                          FileDialog_quit, (XtPointer) this);
  82.202 -}
  82.203 -
  82.204 -void
  82.205 -setFSBDirAndFile(Widget w, char *dir, char *file,
  82.206 -                 XmString *ffiles, int count)
  82.207 -{
  82.208 -    Widget textField, list;
  82.209 -    char dirbuf[MAX_DIR_PATH_LEN];
  82.210 -    XmString xim, item;
  82.211 -    size_t lastSelect;
  82.212 -
  82.213 -    dirbuf[0] = (char) '\0';
  82.214 -
  82.215 -    if (dir != NULL && strlen(dir) < MAX_DIR_PATH_LEN)
  82.216 -        strcpy(dirbuf, dir);
  82.217 -
  82.218 -    /* -----> make sure dir ends in '/' */
  82.219 -    if (dirbuf[0] != (char) '\0') {
  82.220 -        if (dirbuf[strlen(dirbuf) - 1] != (char) '/')
  82.221 -            strcat(dirbuf, "/");
  82.222 -    } else {
  82.223 -        getcwd(dirbuf, MAX_DIR_PATH_LEN - 16);
  82.224 -        strcat(dirbuf, "/");
  82.225 -    }
  82.226 -
  82.227 -    strcat(dirbuf, "[^.]*");
  82.228 -    xim = XmStringCreate(dirbuf, XmSTRING_DEFAULT_CHARSET);
  82.229 -    XtVaSetValues(w, XmNdirMask, xim, NULL);
  82.230 -
  82.231 -    if (ffiles != NULL)
  82.232 -      XtVaSetValues(w,
  82.233 -                    XmNfileListItems, (count > 0) ? ffiles : NULL,
  82.234 -                    XmNfileListItemCount, count,
  82.235 -                    XmNlistUpdated, True, NULL);
  82.236 -
  82.237 -    XmStringFree(xim);
  82.238 -
  82.239 -    /*
  82.240 -     * Select the filename from the filelist if it exists.
  82.241 -     */
  82.242 -
  82.243 -    textField = XmFileSelectionBoxGetChild(w, XmDIALOG_TEXT);
  82.244 -    list = XmFileSelectionBoxGetChild(w, XmDIALOG_LIST);
  82.245 -
  82.246 -    if (textField != 0 && file != 0) {
  82.247 -        lastSelect = strlen(file);
  82.248 -        XtVaSetValues(textField, XmNvalue, file, NULL);
  82.249 -        XmTextFieldSetSelection(textField, 0, lastSelect, CurrentTime);
  82.250 -
  82.251 -        item = XmStringCreateLocalized(file);
  82.252 -        XmListSelectItem(list, item, NULL);
  82.253 -        XmStringFree(item);
  82.254 -    }
  82.255 -}
  82.256 -
  82.257 -static void
  82.258 -changeBackground(Widget w, void *bg)
  82.259 -{
  82.260 -    /*
  82.261 -    ** This is a work-around for bug 4325443, caused by motif bug 4345559,
  82.262 -    ** XmCombobox dosn't return all children, so give it some help ...
  82.263 -    */
  82.264 -    Widget grabShell;
  82.265 -    grabShell = XtNameToWidget(w, "GrabShell");
  82.266 -    if (grabShell != NULL) {
  82.267 -        awt_util_mapChildren(grabShell, changeBackground, 0, (void *) bg);
  82.268 -    }
  82.269 -
  82.270 -    XmChangeColor(w, (Pixel) bg);
  82.271 -}
  82.272 -
  82.273 -void
  82.274 -ourSearchProc(Widget w, XtPointer p) {
  82.275 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  82.276 -    struct FrameData *wdata;
  82.277 -    XtPointer peer;
  82.278 -    jobject this;
  82.279 -    jboolean res;
  82.280 -    char * dir = NULL;
  82.281 -    jstring dir_o;
  82.282 -    int32_t i, filecount = 0;
  82.283 -    XmString * filelist = NULL;
  82.284 -    jobjectArray nffiles = NULL;
  82.285 -    jclass clazz = NULL;
  82.286 -    jstring jfilename = NULL;
  82.287 -    char * cfilename = NULL;
  82.288 -    XmFileSelectionBoxCallbackStruct * vals = (XmFileSelectionBoxCallbackStruct *)p;
  82.289 -
  82.290 -    XtVaGetValues(w, XmNuserData, &peer, NULL);
  82.291 -    this = (jobject)peer;
  82.292 -    if (JNU_IsNull(env, this) ) {
  82.293 -        return;
  82.294 -    }
  82.295 -    wdata = (struct FrameData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.296 -    if (wdata == 0 ||
  82.297 -        wdata->winData.comp.widget == 0 ||
  82.298 -        wdata->winData.shell == 0 || p == NULL ) {
  82.299 -        return;
  82.300 -    }
  82.301 -
  82.302 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
  82.303 -        return;
  82.304 -    }
  82.305 -
  82.306 -    if (DefaultSearchProc != NULL) {
  82.307 -        /* Unmap the widget temporary. If it takes a long time to generate
  82.308 -           the list items some visual artifacts may be caused. However,
  82.309 -           we need to do this to have the widget that works as we expect.
  82.310 -         */
  82.311 -        XtSetMappedWhenManaged(w, False);
  82.312 -        /* Call the default Motif search procedure to take the
  82.313 -           native filtered file list.
  82.314 -         */
  82.315 -        DefaultSearchProc(w, vals);
  82.316 -        XtSetMappedWhenManaged(w, True);
  82.317 -        XtVaGetValues(w,
  82.318 -                      XmNlistItemCount, &filecount,
  82.319 -                      XmNlistItems, &filelist,
  82.320 -                      NULL);
  82.321 -        /* We need to construct the new String array to pass it to
  82.322 -           the Java code.
  82.323 -         */
  82.324 -        clazz = (*env)->FindClass(env, "java/lang/String");
  82.325 -        /* It is ok if filecount is 0. */
  82.326 -        nffiles = (*env)->NewObjectArray(env, filecount, clazz, NULL);
  82.327 -        if (JNU_IsNull(env, nffiles)) {
  82.328 -            nffiles = NULL;
  82.329 -            JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  82.330 -        } else {
  82.331 -            for (i = 0; i < filecount; i++) {
  82.332 -                DASSERT(filelist[i] != NULL);
  82.333 -
  82.334 -                XmStringGetLtoR(filelist[i], XmFONTLIST_DEFAULT_TAG, &cfilename);
  82.335 -                jfilename = JNU_NewStringPlatform(env, cfilename);
  82.336 -
  82.337 -                if (JNU_IsNull(env, jfilename)) {
  82.338 -                    XtFree(cfilename);
  82.339 -                    nffiles = NULL;
  82.340 -                    JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  82.341 -                    break;
  82.342 -                }
  82.343 -
  82.344 -                (*env)->SetObjectArrayElement(env, nffiles, i, jfilename);
  82.345 -
  82.346 -                (*env)->DeleteLocalRef(env, jfilename);
  82.347 -                XtFree(cfilename);
  82.348 -            }
  82.349 -        }
  82.350 -    }
  82.351 -
  82.352 -    XmStringGetLtoR(vals->dir, XmFONTLIST_DEFAULT_TAG, &dir);
  82.353 -    dir_o = JNU_NewStringPlatform(env, dir);
  82.354 -    res = JNU_CallMethodByName(env, NULL, this,
  82.355 -                               "proceedFiltering",
  82.356 -                               "(Ljava/lang/String;[Ljava/lang/String;Z)Z",
  82.357 -                               dir_o, nffiles,
  82.358 -                               awt_currentThreadIsPrivileged(env)).z;
  82.359 -
  82.360 -    if ((*env)->ExceptionOccurred(env)) {
  82.361 -        (*env)->ExceptionDescribe(env);
  82.362 -        (*env)->ExceptionClear(env);
  82.363 -    }
  82.364 -
  82.365 -    XtVaSetValues(w,
  82.366 -                  XmNlistUpdated, res,
  82.367 -                  NULL);
  82.368 -    (*env)->DeleteLocalRef(env, dir_o);
  82.369 -    free(dir);
  82.370 -}
  82.371 -
  82.372 -/*
  82.373 - * Class:     sun_awt_motif_MFileDialogPeer
  82.374 - * Method:    create
  82.375 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  82.376 - */
  82.377 -JNIEXPORT void JNICALL Java_sun_awt_motif_MFileDialogPeer_create
  82.378 -  (JNIEnv *env, jobject this, jobject parent)
  82.379 -{
  82.380 -    struct FrameData *fdata;
  82.381 -    struct CanvasData *wdata;
  82.382 -    int32_t argc;
  82.383 -#define MAX_ARGC 20
  82.384 -    Arg args[MAX_ARGC];
  82.385 -    Widget child, textField, dirList, fileList;
  82.386 -    XmString xim;
  82.387 -    Pixel bg;
  82.388 -    jobject target;
  82.389 -    jstring file;
  82.390 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
  82.391 -    AwtGraphicsConfigDataPtr adata;
  82.392 -#ifndef NOMODALFIX
  82.393 -    extern void awt_shellPoppedUp(Widget shell, XtPointer c, XtPointer d);
  82.394 -    extern void awt_shellPoppedDown(Widget shell, XtPointer c, XtPointer d);
  82.395 -#endif NOMODALFIX
  82.396 -
  82.397 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  82.398 -
  82.399 -    if (JNU_IsNull(env, parent) || JNU_IsNull(env, target)) {
  82.400 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.401 -        return;
  82.402 -    }
  82.403 -    AWT_LOCK();
  82.404 -
  82.405 -    adata = copyGraphicsConfigToPeer(env, this);
  82.406 -
  82.407 -    wdata = (struct CanvasData *) JNU_GetLongFieldAsPtr(env,parent,mComponentPeerIDs.pData);
  82.408 -
  82.409 -    fdata = ZALLOC(FrameData);
  82.410 -    JNU_SetLongFieldFromPtr(env,this,mComponentPeerIDs.pData,fdata);
  82.411 -
  82.412 -    if (fdata == NULL) {
  82.413 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  82.414 -        AWT_UNLOCK();
  82.415 -        return;
  82.416 -    }
  82.417 -    XtVaGetValues(wdata->comp.widget, XmNbackground, &bg, NULL);
  82.418 -
  82.419 -    /*
  82.420 -     * XXX: this code uses FrameData but doesn't bother to init a lot
  82.421 -     * of its memebers.  This confuses the hell out of the code in
  82.422 -     * awt_TopLevel.c that gets passes such half-inited FrameData.
  82.423 -     */
  82.424 -    fdata->decor = MWM_DECOR_ALL;
  82.425 -
  82.426 -    argc = 0;
  82.427 -    XtSetArg(args[argc], XmNmustMatch, False);
  82.428 -    argc++;
  82.429 -    XtSetArg(args[argc], XmNautoUnmanage, False);
  82.430 -    argc++;
  82.431 -    XtSetArg(args[argc], XmNbackground, bg);
  82.432 -    argc++;
  82.433 -    XtSetArg(args[argc], XmNvisual, adata->awt_visInfo.visual);
  82.434 -    argc++;
  82.435 -    XtSetArg(args[argc], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
  82.436 -    argc++;
  82.437 -    XtSetArg (args[argc], XmNscreen,
  82.438 -              ScreenOfDisplay(awt_display, adata->awt_visInfo.screen));
  82.439 -    argc++;
  82.440 -    XtSetArg(args[argc], XmNuserData, (XtPointer)globalRef);
  82.441 -    argc++;
  82.442 -    XtSetArg(args[argc], XmNresizePolicy, XmRESIZE_NONE);
  82.443 -    argc++;
  82.444 -
  82.445 -    XtSetArg(args[argc], XmNbuttonFontList,  getMotifFontList());
  82.446 -    argc++;
  82.447 -    XtSetArg(args[argc], XmNlabelFontList,   getMotifFontList());
  82.448 -    argc++;
  82.449 -    XtSetArg(args[argc], XmNtextFontList,    getMotifFontList());
  82.450 -    argc++;
  82.451 -
  82.452 -    DASSERT(!(argc > MAX_ARGC));
  82.453 -
  82.454 -    fdata->winData.comp.widget = XmCreateFileSelectionDialog(wdata->shell,
  82.455 -                                                             "",
  82.456 -                                                             args,
  82.457 -                                                             argc);
  82.458 -    fdata->winData.shell = XtParent(fdata->winData.comp.widget);
  82.459 -    awt_util_mapChildren(fdata->winData.shell, changeBackground, 0,
  82.460 -                         (void *) bg);
  82.461 -    child = XmFileSelectionBoxGetChild(fdata->winData.comp.widget,
  82.462 -                                       XmDIALOG_HELP_BUTTON);
  82.463 -
  82.464 -    /* We should save a pointer to the default search procedure
  82.465 -       to do some things that we cannot do else. For instance,
  82.466 -       apply the native pattern.
  82.467 -     */
  82.468 -    XtVaGetValues(fdata->winData.comp.widget,
  82.469 -                  XmNfileSearchProc, &DefaultSearchProc,
  82.470 -                  NULL);
  82.471 -    XtVaSetValues(fdata->winData.comp.widget,
  82.472 -                  XmNfileSearchProc, ourSearchProc,
  82.473 -                  NULL);
  82.474 -
  82.475 -    /*
  82.476 -     * Get textfield in FileDialog.
  82.477 -     */
  82.478 -    textField = XmFileSelectionBoxGetChild(fdata->winData.comp.widget,
  82.479 -                                           XmDIALOG_TEXT);
  82.480 -    if (child != NULL) {
  82.481 -        /*
  82.482 -         * Workaround for Bug Id 4415659.
  82.483 -         * If the dialog child is unmanaged before the dialog is managed,
  82.484 -         * the Motif drop site hierarchy may be broken if we associate
  82.485 -         * a drop target with the dialog before it is shown.
  82.486 -         */
  82.487 -        XtSetMappedWhenManaged(fdata->winData.shell, False);
  82.488 -        XtManageChild(fdata->winData.comp.widget);
  82.489 -        XtUnmanageChild(fdata->winData.comp.widget);
  82.490 -        XtSetMappedWhenManaged(fdata->winData.shell, True);
  82.491 -        XtUnmanageChild(child);
  82.492 -    }
  82.493 -    if (!awtJNI_IsMultiFont(env, awtJNI_GetFont(env, this))) {
  82.494 -        /* This process should not be done other than English language
  82.495 -           locale. */
  82.496 -        child = XmFileSelectionBoxGetChild(fdata->winData.comp.widget,
  82.497 -                                           XmDIALOG_DEFAULT_BUTTON);
  82.498 -        if (child != NULL) {
  82.499 -            XmString xim;
  82.500 -
  82.501 -            switch ((*env)->GetIntField(env, target, fileDialogIDs.mode)) {
  82.502 -                case java_awt_FileDialog_LOAD:
  82.503 -                    xim = XmStringCreate("Open", "labelFont");
  82.504 -                    XtVaSetValues(child, XmNlabelString, xim, NULL);
  82.505 -                    XmStringFree(xim);
  82.506 -                    break;
  82.507 -
  82.508 -                case java_awt_FileDialog_SAVE:
  82.509 -                    xim = XmStringCreate("Save", "labelFont");
  82.510 -                    XtVaSetValues(child, XmNlabelString, xim, NULL);
  82.511 -                    XmStringFree(xim);
  82.512 -                    break;
  82.513 -
  82.514 -                default:
  82.515 -                    break;
  82.516 -            }
  82.517 -        }
  82.518 -    }
  82.519 -    XtAddCallback(fdata->winData.comp.widget,
  82.520 -                  XmNokCallback,
  82.521 -                  (XtCallbackProc) FileDialog_OK,
  82.522 -                  (XtPointer) globalRef);
  82.523 -    XtAddCallback(fdata->winData.comp.widget,
  82.524 -                  XmNcancelCallback,
  82.525 -                  (XtCallbackProc) FileDialog_CANCEL,
  82.526 -                  (XtPointer) globalRef);
  82.527 -
  82.528 -#ifndef NOMODALFIX
  82.529 -    XtAddCallback(fdata->winData.shell,
  82.530 -                      XtNpopupCallback,
  82.531 -                      awt_shellPoppedUp,
  82.532 -                      NULL);
  82.533 -    XtAddCallback(fdata->winData.shell,
  82.534 -                      XtNpopdownCallback,
  82.535 -                      awt_shellPoppedDown,
  82.536 -                      NULL);
  82.537 -#endif NOMODALFIX
  82.538 -
  82.539 -    setDeleteCallback(globalRef, fdata);
  82.540 -
  82.541 -    if (textField != NULL)  {
  82.542 -        /*
  82.543 -         * Insert event handler to correctly process cut/copy/paste keys
  82.544 -         * such that interaction with our own clipboard mechanism will work
  82.545 -         * properly.
  82.546 -         *
  82.547 -         * The Text_handlePaste() event handler is also used by both
  82.548 -         * TextField/TextArea.
  82.549 -         */
  82.550 -        XtInsertEventHandler(textField,
  82.551 -                         KeyPressMask,
  82.552 -                         False, Text_handlePaste, (XtPointer) globalRef,
  82.553 -                         XtListHead);
  82.554 -    }
  82.555 -
  82.556 -    /* To get wheel scrolling, we add an event handler to the directory list and
  82.557 -     * file list widgets to handle mouse wheels */
  82.558 -    dirList = XmFileSelectionBoxGetChild(fdata->winData.comp.widget, XmDIALOG_DIR_LIST);
  82.559 -    if (dirList != NULL) {
  82.560 -        XtAddEventHandler(dirList, ButtonPressMask, False, File_handleWheel,
  82.561 -                          (XtPointer) globalRef);
  82.562 -    }
  82.563 -
  82.564 -    fileList = XmFileSelectionBoxGetChild(fdata->winData.comp.widget, XmDIALOG_LIST);
  82.565 -    if (fileList != NULL) {
  82.566 -        XtAddEventHandler(fileList, ButtonPressMask, False, File_handleWheel,
  82.567 -                          (XtPointer) globalRef);
  82.568 -    }
  82.569 -
  82.570 -    file = (*env)->GetObjectField(env, target, fileDialogIDs.file);
  82.571 -    if (JNU_IsNull(env, file)) {
  82.572 -        setFSBDirAndFile(fdata->winData.comp.widget, ".", "", NULL, -1);
  82.573 -    } else {
  82.574 -        char *fileString;
  82.575 -
  82.576 -        fileString = (char *) JNU_GetStringPlatformChars(env, file, NULL);
  82.577 -        setFSBDirAndFile(fdata->winData.comp.widget, ".", fileString, NULL, -1);
  82.578 -        JNU_ReleaseStringPlatformChars(env, file, (const char *) fileString);
  82.579 -    }
  82.580 -    AWT_UNLOCK();
  82.581 -}
  82.582 -
  82.583 -/* Event handler for making scrolling happen when the mouse wheel is rotated */
  82.584 -void File_handleWheel(Widget w, XtPointer client_data, XEvent* event, Boolean* cont) {
  82.585 -    unsigned int btn;
  82.586 -    Widget scrolledWindow = NULL;
  82.587 -
  82.588 -    /* only registered for ButtonPress, so don't need to check event type  */
  82.589 -    btn = event->xbutton.button;
  82.590 -    /* wheel up and wheel down show up as button 4 and 5, respectively */
  82.591 -    if (btn == 4 || btn == 5) {
  82.592 -        scrolledWindow = XtParent(w);
  82.593 -        if (scrolledWindow == NULL) {
  82.594 -            return;
  82.595 -        }
  82.596 -        awt_util_do_wheel_scroll(scrolledWindow,
  82.597 -                             java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL,
  82.598 -                             3,
  82.599 -                             btn == 4 ? -1 : 1);
  82.600 -    }
  82.601 -}
  82.602 -
  82.603 -
  82.604 -/*
  82.605 - * Class:     sun_awt_motif_MFileDialogPeer
  82.606 - * Method:    pReshape
  82.607 - * Signature: (IIII)V
  82.608 - */
  82.609 -JNIEXPORT void JNICALL Java_sun_awt_motif_MFileDialogPeer_pReshape
  82.610 -  (JNIEnv *env, jobject this, jint x, jint y, jint w, jint h)
  82.611 -{
  82.612 -    struct FrameData *wdata;
  82.613 -
  82.614 -    AWT_LOCK();
  82.615 -    wdata = (struct FrameData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.616 -    if (wdata == NULL || wdata->winData.shell == NULL) {
  82.617 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.618 -        AWT_UNLOCK();
  82.619 -        return;
  82.620 -    }
  82.621 -    /* GES: AVH's hack from awt_util.c:
  82.622 -     * Motif ignores attempts to move a toplevel window to 0,0.
  82.623 -     * Instead we set the position to 1,1. The expected value is
  82.624 -     * returned by Frame.getBounds() since it uses the internally
  82.625 -     * held rectangle rather than querying the peer.
  82.626 -     */
  82.627 -
  82.628 -    if ((x == 0) && (y == 0)) {
  82.629 -        XtVaSetValues(wdata->winData.shell, XmNx, 1, XmNy, 1, NULL);
  82.630 -    }
  82.631 -    XtVaSetValues(wdata->winData.shell,
  82.632 -                  XtNx, (XtArgVal) x,
  82.633 -                  XtNy, (XtArgVal) y,
  82.634 -                  NULL);
  82.635 -
  82.636 -    AWT_FLUSH_UNLOCK();
  82.637 -}
  82.638 -
  82.639 -/*
  82.640 - * Class:     sun_awt_motif_MFileDialogPeer
  82.641 - * Method:    pDispose
  82.642 - * Signature: ()V
  82.643 - */
  82.644 -JNIEXPORT void JNICALL Java_sun_awt_motif_MFileDialogPeer_pDispose
  82.645 -  (JNIEnv *env, jobject this)
  82.646 -{
  82.647 -    struct FrameData *wdata;
  82.648 -
  82.649 -    AWT_LOCK();
  82.650 -    wdata = (struct FrameData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.651 -    if (wdata == NULL ||
  82.652 -        wdata->winData.comp.widget == NULL ||
  82.653 -        wdata->winData.shell == NULL) {
  82.654 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.655 -        AWT_UNLOCK();
  82.656 -        return;
  82.657 -    }
  82.658 -    XtUnmanageChild(wdata->winData.shell);
  82.659 -    awt_util_consumeAllXEvents(wdata->winData.shell);
  82.660 -    XtDestroyWidget(wdata->winData.shell);
  82.661 -    free((void *) wdata);
  82.662 -    JNU_SetLongFieldFromPtr(env,this,mComponentPeerIDs.pData,NULL);
  82.663 -    awtJNI_DeleteGlobalRef(env, this);
  82.664 -
  82.665 -    AWT_UNLOCK();
  82.666 -}
  82.667 -
  82.668 -/*
  82.669 - * Class:     sun_awt_motif_MFileDialogPeer
  82.670 - * Method:    pShow
  82.671 - * Signature: ()V
  82.672 - */
  82.673 -JNIEXPORT void JNICALL Java_sun_awt_motif_MFileDialogPeer_pShow
  82.674 -  (JNIEnv *env, jobject this)
  82.675 -{
  82.676 -    struct FrameData *wdata;
  82.677 -    XmString dirMask = NULL;
  82.678 -
  82.679 -    AWT_LOCK();
  82.680 -    wdata = (struct FrameData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.681 -    if (wdata == NULL ||
  82.682 -        wdata->winData.comp.widget == NULL ||
  82.683 -        wdata->winData.shell == NULL) {
  82.684 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.685 -        AWT_UNLOCK();
  82.686 -        return;
  82.687 -    }
  82.688 -    XtManageChild(wdata->winData.comp.widget);
  82.689 -
  82.690 -    AWT_FLUSH_UNLOCK();
  82.691 -}
  82.692 -
  82.693 -/*
  82.694 - * Class:     sun_awt_motif_MFileDialogPeer
  82.695 - * Method:    pHide
  82.696 - * Signature: ()V
  82.697 - */
  82.698 -JNIEXPORT void JNICALL Java_sun_awt_motif_MFileDialogPeer_pHide
  82.699 -  (JNIEnv *env, jobject this)
  82.700 -{
  82.701 -    struct FrameData *wdata;
  82.702 -
  82.703 -    AWT_LOCK();
  82.704 -    wdata = (struct FrameData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.705 -    if (wdata == NULL ||
  82.706 -        wdata->winData.comp.widget == NULL ||
  82.707 -        wdata->winData.shell == NULL) {
  82.708 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.709 -        AWT_UNLOCK();
  82.710 -        return;
  82.711 -    }
  82.712 -    if (XtIsManaged(wdata->winData.comp.widget)) {
  82.713 -        XtUnmanageChild(wdata->winData.comp.widget);
  82.714 -    }
  82.715 -
  82.716 -    AWT_FLUSH_UNLOCK();
  82.717 -}
  82.718 -
  82.719 -/*
  82.720 - * Class:     sun_awt_motif_MFileDialogPeer
  82.721 - * Method:    setFileEntry
  82.722 - * Signature: (Ljava/lang/String;Ljava/lang/String;)V
  82.723 - */
  82.724 -JNIEXPORT void JNICALL Java_sun_awt_motif_MFileDialogPeer_setFileEntry
  82.725 -  (JNIEnv *env, jobject this, jstring dir, jstring file, jobjectArray ffiles)
  82.726 -{
  82.727 -    struct ComponentData *cdata;
  82.728 -    char *cdir;
  82.729 -    char *cfile;
  82.730 -    char *cf;
  82.731 -    struct FrameData *wdata;
  82.732 -    int32_t length, i;
  82.733 -    XmString * files = NULL;
  82.734 -    jstring jf;
  82.735 -
  82.736 -    AWT_LOCK();
  82.737 -    wdata = (struct FrameData *)
  82.738 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.739 -    if (wdata == NULL || wdata->winData.comp.widget == NULL) {
  82.740 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.741 -        return;
  82.742 -    }
  82.743 -
  82.744 -    cdir = (JNU_IsNull(env, dir))
  82.745 -               ? NULL
  82.746 -               : (char *) JNU_GetStringPlatformChars(env, dir, NULL);
  82.747 -
  82.748 -    cfile = (JNU_IsNull(env, file))
  82.749 -               ? NULL
  82.750 -               : (char *) JNU_GetStringPlatformChars(env, file, NULL);
  82.751 -
  82.752 -    if (ffiles != NULL) {
  82.753 -        length = (*env)->GetArrayLength(env, ffiles);
  82.754 -        files = (XmString*)calloc(length, sizeof(XmString));
  82.755 -
  82.756 -        for (i = 0; i < length; i++) {
  82.757 -            jf = (jstring)(*env)->GetObjectArrayElement(env, ffiles, i);
  82.758 -            cf = (char *) JNU_GetStringPlatformChars(env, jf, NULL);
  82.759 -
  82.760 -            if ((*env)->GetStringLength(env, jf) == 0 && length == 1) {
  82.761 -              length = 0;
  82.762 -              files[0] = NULL;
  82.763 -            }
  82.764 -            else
  82.765 -              files[i] = XmStringCreateLocalized(cf);
  82.766 -
  82.767 -            if (cf)
  82.768 -                JNU_ReleaseStringPlatformChars(env, jf, (const char *) cf);
  82.769 -        }
  82.770 -
  82.771 -        setFSBDirAndFile(wdata->winData.comp.widget, (cdir) ? cdir : "",
  82.772 -                         (cfile) ? cfile : "", files, length);
  82.773 -        while(i > 0) {
  82.774 -            XmStringFree(files[--i]);
  82.775 -        }
  82.776 -        if (files != NULL) {
  82.777 -            free(files);
  82.778 -        }
  82.779 -    }
  82.780 -    else
  82.781 -      setFSBDirAndFile(wdata->winData.comp.widget, (cdir) ? cdir : "",
  82.782 -                       (cfile) ? cfile : "", NULL, -1);
  82.783 -
  82.784 -    if (cdir) {
  82.785 -        JNU_ReleaseStringPlatformChars(env, dir, (const char *) cdir);
  82.786 -    }
  82.787 -
  82.788 -    if (cfile) {
  82.789 -        JNU_ReleaseStringPlatformChars(env, file, (const char *) cfile);
  82.790 -    }
  82.791 -
  82.792 -    AWT_FLUSH_UNLOCK();
  82.793 -}
  82.794 -
  82.795 -static void
  82.796 -changeFont(Widget w, void *fontList)
  82.797 -{
  82.798 -    XtVaSetValues(w, XmNfontList, fontList, NULL);
  82.799 -}
  82.800 -
  82.801 -/*
  82.802 - * Class:     sun_awt_motif_MFileDialogPeer
  82.803 - * Method:    setFont
  82.804 - * Signature: (Ljava/awt/Font;)V
  82.805 - */
  82.806 -JNIEXPORT void JNICALL Java_sun_awt_motif_MFileDialogPeer_setFont
  82.807 -  (JNIEnv *env, jobject this, jobject f)
  82.808 -{
  82.809 -    struct ComponentData *tdata;
  82.810 -    struct FontData *fdata;
  82.811 -    XmFontListEntry fontentry;
  82.812 -    XmFontList fontlist;
  82.813 -    char *err;
  82.814 -
  82.815 -    if (JNU_IsNull(env, f)) {
  82.816 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.817 -        return;
  82.818 -    }
  82.819 -    AWT_LOCK();
  82.820 -    fdata = awtJNI_GetFontData(env, f, &err);
  82.821 -    if (fdata == NULL) {
  82.822 -        JNU_ThrowInternalError(env, err);
  82.823 -        AWT_UNLOCK();
  82.824 -        return;
  82.825 -    }
  82.826 -    tdata = (struct ComponentData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.827 -    if (tdata == NULL || tdata->widget == NULL) {
  82.828 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.829 -        AWT_UNLOCK();
  82.830 -        return;
  82.831 -    }
  82.832 -    if (awtJNI_IsMultiFont(env, f)) {
  82.833 -        if (fdata->xfs == NULL) {
  82.834 -            fdata->xfs = awtJNI_MakeFontSet(env, f);
  82.835 -        }
  82.836 -        if (fdata->xfs != NULL) {
  82.837 -            fontentry = XmFontListEntryCreate("labelFont",
  82.838 -                                              XmFONT_IS_FONTSET,
  82.839 -                                              (XtPointer) (fdata->xfs));
  82.840 -            fontlist = XmFontListAppendEntry(NULL, fontentry);
  82.841 -            /*
  82.842 -             * Some versions of motif have a bug in
  82.843 -             * XmFontListEntryFree() which causes it to free more than it
  82.844 -             * should.  Use XtFree() instead.  See O'Reilly's
  82.845 -             * Motif Reference Manual for more information.
  82.846 -             */
  82.847 -            XmFontListEntryFree(&fontentry);
  82.848 -        } else {
  82.849 -            fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  82.850 -        }
  82.851 -    } else {
  82.852 -        fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  82.853 -    }
  82.854 -
  82.855 -    if (fontlist != NULL) {
  82.856 -     /* setting the fontlist in the FileSelectionBox is not good enough --
  82.857 -        you have to set the resource for all the descendants individually */
  82.858 -        awt_util_mapChildren(tdata->widget, changeFont, 1, (void *)fontlist);
  82.859 -        XmFontListFree(fontlist);
  82.860 -    } else {
  82.861 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.862 -    }
  82.863 -
  82.864 -    AWT_UNLOCK();
  82.865 -}
  82.866 -
  82.867 -/*
  82.868 - * Class:     sun_awt_motif_MFileDialogPeer
  82.869 - * Method:    insertReplaceFileDialogText
  82.870 - * Signature: (Ljava/lang/String;)V
  82.871 - */
  82.872 -JNIEXPORT void JNICALL Java_sun_awt_motif_MFileDialogPeer_insertReplaceFileDialogText
  82.873 -  (JNIEnv *env, jobject this, jstring l)
  82.874 -{
  82.875 -    struct ComponentData *cdata;
  82.876 -    char *cl;
  82.877 -    XmTextPosition start, end;
  82.878 -    Widget textField;
  82.879 -    jobject font;
  82.880 -
  82.881 -    /*
  82.882 -     * Replaces the text in the FileDialog's textfield with the passed
  82.883 -     * string.
  82.884 -     */
  82.885 -
  82.886 -    AWT_LOCK();
  82.887 -    cdata = (struct ComponentData *)
  82.888 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  82.889 -    if (cdata == NULL || cdata->widget == NULL) {
  82.890 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  82.891 -        AWT_UNLOCK();
  82.892 -        return;
  82.893 -    }
  82.894 -
  82.895 -    textField = XmFileSelectionBoxGetChild(cdata->widget, XmDIALOG_TEXT);
  82.896 -
  82.897 -    if (textField == NULL)  {
  82.898 -        JNU_ThrowNullPointerException(env, "Null TextField in FileDialog");
  82.899 -        AWT_UNLOCK();
  82.900 -        return;
  82.901 -    }
  82.902 -
  82.903 -    font = awtJNI_GetFont(env, this);
  82.904 -
  82.905 -    if (JNU_IsNull(env, l)) {
  82.906 -        cl = NULL;
  82.907 -    } else {
  82.908 -        /*
  82.909 -         * We use makePlatformCString() to convert unicode to EUC here,
  82.910 -         * although output only components (Label/Button/Menu..)
  82.911 -         * is not using make/allocCString() functions anymore.
  82.912 -         * Because Motif TextFiled widget does not support multi-font
  82.913 -         * compound string.
  82.914 -         */
  82.915 -
  82.916 -        cl = (char *) JNU_GetStringPlatformChars(env, l, NULL);
  82.917 -    }
  82.918 -
  82.919 -    if (!XmTextGetSelectionPosition(textField, &start, &end)) {
  82.920 -        start = end = XmTextGetInsertionPosition(textField);
  82.921 -    }
  82.922 -    XmTextReplace(textField, start, end, cl);
  82.923 -
  82.924 -    if (cl != NULL && cl !="") {
  82.925 -        JNU_ReleaseStringPlatformChars(env, l, cl);
  82.926 -    }
  82.927 -    AWT_FLUSH_UNLOCK();
  82.928 -}
    83.1 --- a/src/solaris/native/sun/awt/awt_GlobalCursorManager.c	Wed Sep 17 13:45:37 2008 -0700
    83.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.3 @@ -1,127 +0,0 @@
    83.4 -/*
    83.5 - * Copyright 1999-2001 Sun Microsystems, Inc.  All Rights Reserved.
    83.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    83.7 - *
    83.8 - * This code is free software; you can redistribute it and/or modify it
    83.9 - * under the terms of the GNU General Public License version 2 only, as
   83.10 - * published by the Free Software Foundation.  Sun designates this
   83.11 - * particular file as subject to the "Classpath" exception as provided
   83.12 - * by Sun in the LICENSE file that accompanied this code.
   83.13 - *
   83.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   83.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   83.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   83.17 - * version 2 for more details (a copy is included in the LICENSE file that
   83.18 - * accompanied this code).
   83.19 - *
   83.20 - * You should have received a copy of the GNU General Public License version
   83.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   83.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   83.23 - *
   83.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   83.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   83.26 - * have any questions.
   83.27 - */
   83.28 -#ifdef HEADLESS
   83.29 -    #error This file should not be included in headless library
   83.30 -#endif
   83.31 -
   83.32 -#include "awt_p.h"
   83.33 -#include "awt_Component.h"
   83.34 -#include "sun_awt_motif_MComponentPeer.h"
   83.35 -
   83.36 -#include "jni.h"
   83.37 -#include "jni_util.h"
   83.38 -
   83.39 -static jfieldID xID;
   83.40 -static jfieldID yID;
   83.41 -
   83.42 -extern struct MComponentPeerIDs mComponentPeerIDs;
   83.43 -extern struct ComponentIDs componentIDs;
   83.44 -extern struct ContainerIDs containerIDs;
   83.45 -extern jobject getCurComponent();
   83.46 -
   83.47 -/*
   83.48 - * Class:     sun_awt_motif_MGlobalCursorManager
   83.49 - * Method:    cacheInit
   83.50 - * Signature: ()V
   83.51 - */
   83.52 -JNIEXPORT void JNICALL Java_sun_awt_motif_MGlobalCursorManager_cacheInit
   83.53 -  (JNIEnv *env, jclass cls)
   83.54 -{
   83.55 -    jclass clsDimension = (*env)->FindClass(env, "java/awt/Point");
   83.56 -    xID = (*env)->GetFieldID(env, clsDimension, "x", "I");
   83.57 -    yID = (*env)->GetFieldID(env, clsDimension, "y", "I");
   83.58 -}
   83.59 -
   83.60 -/*
   83.61 - * Class:     sun_awt_motif_MGlobalCursorManager
   83.62 - * Method:    getCursorPos
   83.63 - * Signature: (Ljava/awt/Point;)Ljava/awt/Component
   83.64 - */
   83.65 -JNIEXPORT void JNICALL Java_sun_awt_motif_MGlobalCursorManager_getCursorPos
   83.66 -  (JNIEnv *env, jobject this, jobject point)
   83.67 -{
   83.68 -    Window root, rw, cw;
   83.69 -    int32_t rx, ry, x, y;
   83.70 -    uint32_t kbs;
   83.71 -
   83.72 -    AWT_LOCK();
   83.73 -    root = RootWindow(awt_display, DefaultScreen(awt_display));
   83.74 -    XQueryPointer(awt_display, root, &rw, &cw, &rx, &ry, &x, &y, &kbs);
   83.75 -
   83.76 -    (*env)->SetIntField(env, point, xID, rx);
   83.77 -    (*env)->SetIntField(env, point, yID, ry);
   83.78 -    AWT_FLUSH_UNLOCK();
   83.79 -}
   83.80 -
   83.81 -/*
   83.82 - * Class:     sun_awt_motif_MGlobalCursorManager
   83.83 - * Method:    getCursorPos
   83.84 - * Signature: ()Ljava/awt/Component
   83.85 - */
   83.86 -JNIEXPORT jobject JNICALL Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor
   83.87 -  (JNIEnv *env, jobject this)
   83.88 -{
   83.89 -        jobject target;
   83.90 -
   83.91 -    AWT_LOCK();
   83.92 -        target = getCurComponent();
   83.93 -    AWT_FLUSH_UNLOCK();
   83.94 -        return target;
   83.95 -}
   83.96 -
   83.97 -/*
   83.98 - * Class:     sun_awt_motif_MGlobalCursorManager
   83.99 - * Method:    getLocationOnScreen
  83.100 - * Signature: (Ljava/awt/Component;)Ljava/awt/Point
  83.101 - */
  83.102 -JNIEXPORT jobject JNICALL Java_sun_awt_motif_MGlobalCursorManager_getLocationOnScreen
  83.103 -  (JNIEnv *env, jobject this, jobject component)
  83.104 -{
  83.105 -    jobject point =
  83.106 -        (*env)->CallObjectMethod(env, component,
  83.107 -                                 componentIDs.getLocationOnScreen);
  83.108 -    return point;
  83.109 -}
  83.110 -
  83.111 -/*
  83.112 - * Class:     sun_awt_motif_MGlobalCursorManager
  83.113 - * Method:    findComponentAt
  83.114 - * Signature: (Ljava/awt/Container;II)Ljava/awt/Component
  83.115 - */
  83.116 -JNIEXPORT jobject JNICALL
  83.117 -Java_sun_awt_motif_MGlobalCursorManager_findComponentAt
  83.118 -    (JNIEnv *env, jobject this, jobject container, jint x, jint y)
  83.119 -{
  83.120 -    /*
  83.121 -     * Call private version of Container.findComponentAt with the following
  83.122 -     * flag set: ignoreEnabled = false (i.e., don't return or recurse into
  83.123 -     * disabled Components).
  83.124 -     * NOTE: it may return a JRootPane's glass pane as the target Component.
  83.125 -     */
  83.126 -    jobject component =
  83.127 -        (*env)->CallObjectMethod(env, container, containerIDs.findComponentAt,
  83.128 -                                 x, y, JNI_FALSE);
  83.129 -    return component;
  83.130 -}
    84.1 --- a/src/solaris/native/sun/awt/awt_KeyboardFocusManager.c	Wed Sep 17 13:45:37 2008 -0700
    84.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.3 @@ -1,175 +0,0 @@
    84.4 -/*
    84.5 - * Copyright 2000-2003 Sun Microsystems, Inc.  All Rights Reserved.
    84.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    84.7 - *
    84.8 - * This code is free software; you can redistribute it and/or modify it
    84.9 - * under the terms of the GNU General Public License version 2 only, as
   84.10 - * published by the Free Software Foundation.  Sun designates this
   84.11 - * particular file as subject to the "Classpath" exception as provided
   84.12 - * by Sun in the LICENSE file that accompanied this code.
   84.13 - *
   84.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   84.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   84.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   84.17 - * version 2 for more details (a copy is included in the LICENSE file that
   84.18 - * accompanied this code).
   84.19 - *
   84.20 - * You should have received a copy of the GNU General Public License version
   84.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   84.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   84.23 - *
   84.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   84.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   84.26 - * have any questions.
   84.27 - */
   84.28 -#ifdef HEADLESS
   84.29 -    #error This file should not be included in headless library
   84.30 -#endif
   84.31 -
   84.32 -#include "awt_p.h"
   84.33 -#include "jni.h"
   84.34 -#include "jni_util.h"
   84.35 -
   84.36 -#include "awt_KeyboardFocusManager.h"
   84.37 -#include "java_awt_KeyboardFocusManager.h"
   84.38 -#include "java_awt_event_FocusEvent.h"
   84.39 -#include "awt_Component.h"
   84.40 -#include "canvas.h"
   84.41 -#include "awt_MToolkit.h"
   84.42 -
   84.43 -extern struct MComponentPeerIDs mComponentPeerIDs;
   84.44 -
   84.45 -struct KeyboardFocusManagerIDs keyboardFocusManagerIDs;
   84.46 -
   84.47 -/*
   84.48 - * Class:     java_awt_KeyboardFocusManager
   84.49 - * Method:    initIDs
   84.50 - * Signature: ()V
   84.51 - */
   84.52 -JNIEXPORT void JNICALL
   84.53 -Java_java_awt_KeyboardFocusManager_initIDs
   84.54 -    (JNIEnv *env, jclass cls)
   84.55 -{
   84.56 -    jclass keyclass = NULL;
   84.57 -
   84.58 -    keyboardFocusManagerIDs.keyboardFocusManagerCls = (jclass)
   84.59 -        (*env)->NewGlobalRef(env, cls);
   84.60 -    keyboardFocusManagerIDs.shouldNativelyFocusHeavyweightMID =
   84.61 -        (*env)->GetStaticMethodID(env, cls, "shouldNativelyFocusHeavyweight",
   84.62 -            "(Ljava/awt/Component;Ljava/awt/Component;ZZJLsun/awt/CausedFocusEvent$Cause;)I");
   84.63 -    keyboardFocusManagerIDs.heavyweightButtonDownMID =
   84.64 -        (*env)->GetStaticMethodID(env, cls, "heavyweightButtonDown",
   84.65 -            "(Ljava/awt/Component;J)V");
   84.66 -    keyboardFocusManagerIDs.heavyweightButtonDownZMID =
   84.67 -        (*env)->GetStaticMethodID(env, cls, "heavyweightButtonDown",
   84.68 -            "(Ljava/awt/Component;JZ)V");
   84.69 -    keyboardFocusManagerIDs.markClearGlobalFocusOwnerMID =
   84.70 -        (*env)->GetStaticMethodID(env, cls, "markClearGlobalFocusOwner",
   84.71 -                                  "()Ljava/awt/Window;");
   84.72 -
   84.73 -    keyboardFocusManagerIDs.processSynchronousTransferMID =
   84.74 -        (*env)->GetStaticMethodID(env, cls, "processSynchronousLightweightTransfer",
   84.75 -                                  "(Ljava/awt/Component;Ljava/awt/Component;ZZJ)Z");
   84.76 -
   84.77 -    keyclass = (*env)->FindClass(env, "java/awt/event/KeyEvent");
   84.78 -    DASSERT (keyclass != NULL);
   84.79 -
   84.80 -    keyboardFocusManagerIDs.isProxyActive =
   84.81 -        (*env)->GetFieldID(env, keyclass, "isProxyActive",
   84.82 -                           "Z");
   84.83 -
   84.84 -    (*env)->DeleteLocalRef(env, keyclass);
   84.85 -
   84.86 -    DASSERT(keyboardFocusManagerIDs.keyboardFocusManagerCls != NULL);
   84.87 -    DASSERT(keyboardFocusManagerIDs.shouldNativelyFocusHeavyweightMID !=
   84.88 -            NULL);
   84.89 -    DASSERT(keyboardFocusManagerIDs.heavyweightButtonDownMID != NULL);
   84.90 -    DASSERT(keyboardFocusManagerIDs.heavyweightButtonDownZMID != NULL);
   84.91 -    DASSERT(keyboardFocusManagerIDs.markClearGlobalFocusOwnerMID != NULL);
   84.92 -    DASSERT(keyboardFocusManagerIDs.processSynchronousTransferMID != NULL);
   84.93 -}
   84.94 -
   84.95 -/*
   84.96 - * Class:     java_awt_KeyboardFocusManager
   84.97 - * Method:    getNativeFocusOwner
   84.98 - * Signature: ()Ljava/awt/Component;
   84.99 - */
  84.100 -JNIEXPORT jobject JNICALL
  84.101 -Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner
  84.102 -    (JNIEnv *env, jclass cls)
  84.103 -{
  84.104 -    jobject l_peer;
  84.105 -
  84.106 -    AWT_LOCK();
  84.107 -    l_peer = awt_canvas_getFocusOwnerPeer();
  84.108 -    AWT_UNLOCK();
  84.109 -
  84.110 -    return (l_peer != NULL)
  84.111 -        ? (*env)->GetObjectField(env, l_peer, mComponentPeerIDs.target)
  84.112 -        : NULL;
  84.113 -}
  84.114 -
  84.115 -/*
  84.116 - * Class:     java_awt_KeyboardFocusManager
  84.117 - * Method:    getNativeFocusedWindow
  84.118 - * Signature: ()Ljava/awt/Window;
  84.119 - */
  84.120 -JNIEXPORT jobject JNICALL
  84.121 -Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow
  84.122 -    (JNIEnv *env, jclass cls)
  84.123 -{
  84.124 -    jobject l_peer;
  84.125 -
  84.126 -    AWT_LOCK();
  84.127 -    l_peer = awt_canvas_getFocusedWindowPeer();
  84.128 -    AWT_UNLOCK();
  84.129 -
  84.130 -    return (l_peer != NULL)
  84.131 -        ? (*env)->GetObjectField(env, l_peer, mComponentPeerIDs.target)
  84.132 -        : NULL;
  84.133 -}
  84.134 -
  84.135 -/*
  84.136 - * Class:     java_awt_KeyboardFocusManager
  84.137 - * Method:    clearGlobalFocusOwner
  84.138 - * Signature: ()V
  84.139 - */
  84.140 -JNIEXPORT void JNICALL
  84.141 -Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner
  84.142 -    (JNIEnv *env, jobject self, jobject activeWindow)
  84.143 -{
  84.144 -  /* Redirect focus to the focus proxy of the active Window. The effect
  84.145 -     we want is for the active Window to remain active, but for none of
  84.146 -     its children to be the focus owner. AWT maintains state to know
  84.147 -     that any key events delivered after this call (but before focus is
  84.148 -     re-established elsewhere) get ignored. */
  84.149 -
  84.150 -    Widget proxy;
  84.151 -
  84.152 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
  84.153 -        return;
  84.154 -    }
  84.155 -
  84.156 -    AWT_LOCK();
  84.157 -
  84.158 -    if (activeWindow != NULL) {
  84.159 -        // Setting focus owner to proxy will be equivalent to having
  84.160 -        // null focus owner in Java layer while we will still be
  84.161 -        // able to receive key events.
  84.162 -        proxy = findWindowsProxy(activeWindow, env);
  84.163 -
  84.164 -        if (proxy != NULL) {
  84.165 -            Widget curFocusWidget = XmGetFocusWidget(proxy);
  84.166 -            if (curFocusWidget != NULL) {
  84.167 -                callFocusHandler(curFocusWidget, FocusOut, NULL);
  84.168 -            }
  84.169 -
  84.170 -            // Disable all but proxy widgets
  84.171 -            processTree(curFocusWidget, proxy, False);
  84.172 -
  84.173 -            XmProcessTraversal(proxy, XmTRAVERSE_CURRENT);
  84.174 -        }
  84.175 -    }
  84.176 -
  84.177 -    AWT_UNLOCK();
  84.178 -}
    85.1 --- a/src/solaris/native/sun/awt/awt_Label.c	Wed Sep 17 13:45:37 2008 -0700
    85.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.3 @@ -1,212 +0,0 @@
    85.4 -/*
    85.5 - * Copyright 1995-2001 Sun Microsystems, Inc.  All Rights Reserved.
    85.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    85.7 - *
    85.8 - * This code is free software; you can redistribute it and/or modify it
    85.9 - * under the terms of the GNU General Public License version 2 only, as
   85.10 - * published by the Free Software Foundation.  Sun designates this
   85.11 - * particular file as subject to the "Classpath" exception as provided
   85.12 - * by Sun in the LICENSE file that accompanied this code.
   85.13 - *
   85.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   85.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   85.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   85.17 - * version 2 for more details (a copy is included in the LICENSE file that
   85.18 - * accompanied this code).
   85.19 - *
   85.20 - * You should have received a copy of the GNU General Public License version
   85.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   85.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   85.23 - *
   85.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   85.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   85.26 - * have any questions.
   85.27 - */
   85.28 -
   85.29 -#ifdef HEADLESS
   85.30 -    #error This file should not be included in headless library
   85.31 -#endif
   85.32 -
   85.33 -#include "awt_p.h"
   85.34 -#include "java_awt_Color.h"
   85.35 -#include "java_awt_Font.h"
   85.36 -#include "java_awt_Label.h"
   85.37 -#include "sun_awt_motif_MLabelPeer.h"
   85.38 -#include "sun_awt_motif_MComponentPeer.h"
   85.39 -
   85.40 -#include "awt_Component.h"
   85.41 -
   85.42 -#include "multi_font.h"
   85.43 -#include <jni.h>
   85.44 -#include <jni_util.h>
   85.45 -
   85.46 -extern struct MComponentPeerIDs mComponentPeerIDs;
   85.47 -extern AwtGraphicsConfigDataPtr
   85.48 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   85.49 -
   85.50 -static char emptyString[] = "";
   85.51 -
   85.52 -
   85.53 -/*
   85.54 - * Class:     sun_awt_motif_MLabelPeer
   85.55 - * Method:    create
   85.56 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
   85.57 - */
   85.58 -JNIEXPORT void JNICALL Java_sun_awt_motif_MLabelPeer_create
   85.59 -  (JNIEnv *env, jobject this, jobject parent)
   85.60 -{
   85.61 -    struct ComponentData *cdata;
   85.62 -    struct ComponentData *wdata;
   85.63 -    jobject target;
   85.64 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
   85.65 -    AwtGraphicsConfigDataPtr adata;
   85.66 -    AWT_LOCK();
   85.67 -
   85.68 -    if (JNU_IsNull(env, parent)) {
   85.69 -        JNU_ThrowNullPointerException(env, "NullPointerException");
   85.70 -        AWT_UNLOCK();
   85.71 -
   85.72 -        return;
   85.73 -    }
   85.74 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
   85.75 -    wdata = (struct ComponentData *)
   85.76 -        JNU_GetLongFieldAsPtr(env, parent, mComponentPeerIDs.pData);
   85.77 -
   85.78 -    if (JNU_IsNull(env, target) || wdata == NULL) {
   85.79 -        JNU_ThrowNullPointerException(env, "NullPointerException");
   85.80 -        AWT_UNLOCK();
   85.81 -
   85.82 -        return;
   85.83 -    }
   85.84 -    cdata = ZALLOC(ComponentData);
   85.85 -    if (cdata == NULL) {
   85.86 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
   85.87 -        AWT_UNLOCK();
   85.88 -        return;
   85.89 -    }
   85.90 -    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.pData,cdata);
   85.91 -
   85.92 -    adata = copyGraphicsConfigToPeer(env, this);
   85.93 -
   85.94 -    cdata->widget = XtVaCreateManagedWidget("",
   85.95 -                                            xmLabelWidgetClass, wdata->widget,
   85.96 -                                            XmNhighlightThickness, 0,
   85.97 -                                            XmNalignment, XmALIGNMENT_BEGINNING,
   85.98 -                                            XmNrecomputeSize, False,
   85.99 -                                            XmNuserData, (XtPointer) globalRef,
  85.100 -                                            XmNtraversalOn, True,
  85.101 -                                            XmNscreen,
  85.102 -                                            ScreenOfDisplay(awt_display,
  85.103 -                                               adata->awt_visInfo.screen),
  85.104 -                                            XmNfontList, getMotifFontList(),
  85.105 -                                            NULL);
  85.106 -    XtSetMappedWhenManaged(cdata->widget, False);
  85.107 -    AWT_UNLOCK();
  85.108 -}
  85.109 -
  85.110 -/*
  85.111 - * Class:     sun_awt_motif_MLabelPeer
  85.112 - * Method:    setText
  85.113 - * Signature: (Ljava/lang/String;)V
  85.114 - */
  85.115 -JNIEXPORT void JNICALL Java_sun_awt_motif_MLabelPeer_setText
  85.116 -  (JNIEnv *env, jobject this, jstring label)
  85.117 -{
  85.118 -    char *clabel = NULL;
  85.119 -    char *clabelEnd;
  85.120 -    struct ComponentData *cdata;
  85.121 -    XmString xim = NULL;
  85.122 -    jobject font;
  85.123 -    Boolean isMultiFont;
  85.124 -
  85.125 -    AWT_LOCK();
  85.126 -
  85.127 -    font = awtJNI_GetFont(env, this);
  85.128 -    isMultiFont = awtJNI_IsMultiFont(env, font);
  85.129 -
  85.130 -    cdata = (struct ComponentData *)
  85.131 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  85.132 -    if (cdata == NULL || cdata->widget == NULL) {
  85.133 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  85.134 -        AWT_UNLOCK();
  85.135 -        return;
  85.136 -    }
  85.137 -    if (JNU_IsNull(env, label)) {
  85.138 -        clabel = emptyString;
  85.139 -    } else {
  85.140 -        if (isMultiFont) {
  85.141 -            if ((*env)->GetStringLength(env, label) <= 0) {
  85.142 -                xim = XmStringCreateLocalized("");
  85.143 -            } else {
  85.144 -                xim = awtJNI_MakeMultiFontString(env, label, font);
  85.145 -            }
  85.146 -        } else {
  85.147 -            clabel = (char *) JNU_GetStringPlatformChars(env, label, NULL);
  85.148 -
  85.149 -            /* scan for any \n's and terminate the string at that point */
  85.150 -            clabelEnd = strchr(clabel, '\n');
  85.151 -            if (clabelEnd != NULL) {
  85.152 -                *clabelEnd = '\0';
  85.153 -            }
  85.154 -        }
  85.155 -    }
  85.156 -
  85.157 -    if (!isMultiFont) {
  85.158 -        xim = XmStringCreate(clabel, "labelFont");
  85.159 -    }
  85.160 -    XtVaSetValues(cdata->widget, XmNlabelString, xim, NULL);
  85.161 -
  85.162 -    if (!isMultiFont) {
  85.163 -        /* Must test for "" too! */
  85.164 -        if (clabel != NULL && (*clabel != '\0')) {
  85.165 -            JNU_ReleaseStringPlatformChars(env, label, (const char *) clabel);
  85.166 -        }
  85.167 -    }
  85.168 -    XmStringFree(xim);
  85.169 -    AWT_FLUSH_UNLOCK();
  85.170 -}
  85.171 -
  85.172 -/*
  85.173 - * Class:     sun_awt_motif_MLabelPeer
  85.174 - * Method:    setAlignment
  85.175 - * Signature: (I)V
  85.176 - */
  85.177 -JNIEXPORT void JNICALL Java_sun_awt_motif_MLabelPeer_setAlignment
  85.178 -  (JNIEnv *env, jobject this, jint alignment)
  85.179 -{
  85.180 -    struct ComponentData *cdata;
  85.181 -
  85.182 -    AWT_LOCK();
  85.183 -
  85.184 -    cdata = (struct ComponentData *)
  85.185 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  85.186 -    if (cdata == NULL || cdata->widget == NULL) {
  85.187 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  85.188 -        AWT_UNLOCK();
  85.189 -        return;
  85.190 -    }
  85.191 -    switch (alignment) {
  85.192 -        case java_awt_Label_LEFT:
  85.193 -            XtVaSetValues(cdata->widget,
  85.194 -                          XmNalignment, XmALIGNMENT_BEGINNING,
  85.195 -                          NULL);
  85.196 -            break;
  85.197 -
  85.198 -        case java_awt_Label_CENTER:
  85.199 -            XtVaSetValues(cdata->widget,
  85.200 -                          XmNalignment, XmALIGNMENT_CENTER,
  85.201 -                          NULL);
  85.202 -            break;
  85.203 -
  85.204 -        case java_awt_Label_RIGHT:
  85.205 -            XtVaSetValues(cdata->widget,
  85.206 -                          XmNalignment, XmALIGNMENT_END,
  85.207 -                          NULL);
  85.208 -            break;
  85.209 -
  85.210 -        default:
  85.211 -            break;
  85.212 -    }
  85.213 -
  85.214 -    AWT_FLUSH_UNLOCK();
  85.215 -}
    86.1 --- a/src/solaris/native/sun/awt/awt_List.c	Wed Sep 17 13:45:37 2008 -0700
    86.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.3 @@ -1,600 +0,0 @@
    86.4 -/*
    86.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
    86.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    86.7 - *
    86.8 - * This code is free software; you can redistribute it and/or modify it
    86.9 - * under the terms of the GNU General Public License version 2 only, as
   86.10 - * published by the Free Software Foundation.  Sun designates this
   86.11 - * particular file as subject to the "Classpath" exception as provided
   86.12 - * by Sun in the LICENSE file that accompanied this code.
   86.13 - *
   86.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   86.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   86.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   86.17 - * version 2 for more details (a copy is included in the LICENSE file that
   86.18 - * accompanied this code).
   86.19 - *
   86.20 - * You should have received a copy of the GNU General Public License version
   86.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   86.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   86.23 - *
   86.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   86.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   86.26 - * have any questions.
   86.27 - */
   86.28 -
   86.29 -#ifdef HEADLESS
   86.30 -    #error This file should not be included in headless library
   86.31 -#endif
   86.32 -
   86.33 -#include "awt_p.h"
   86.34 -#include "java_awt_List.h"
   86.35 -#include "java_awt_AWTEvent.h"
   86.36 -#include "sun_awt_motif_MListPeer.h"
   86.37 -#include "sun_awt_motif_MComponentPeer.h"
   86.38 -#include "java_awt_event_MouseWheelEvent.h"
   86.39 -#include "canvas.h"
   86.40 -
   86.41 -#include "awt_Component.h"
   86.42 -
   86.43 -#include "multi_font.h"
   86.44 -#include <jni.h>
   86.45 -#include <jni_util.h>
   86.46 -
   86.47 -extern struct MComponentPeerIDs mComponentPeerIDs;
   86.48 -extern struct ComponentIDs componentIDs;
   86.49 -extern AwtGraphicsConfigDataPtr
   86.50 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   86.51 -
   86.52 -
   86.53 -/*
   86.54 - * client_data = MListPeer instance
   86.55 - */
   86.56 -static void
   86.57 -Slist_callback(Widget w, XtPointer client_data, XtPointer call_data)
   86.58 -{
   86.59 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
   86.60 -    XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
   86.61 -
   86.62 -    switch (cbs->reason) {
   86.63 -        case XmCR_DEFAULT_ACTION: {
   86.64 -            ConvertEventTimeAndModifiers converted;
   86.65 -
   86.66 -            awt_util_convertEventTimeAndModifiers(cbs->event, &converted);
   86.67 -
   86.68 -            if (cbs->event->type == KeyPress) {
   86.69 -                /* When Default action comes from keyboard, no notification
   86.70 -                 * is given by motif that a selection has been made, even
   86.71 -                 * though, internally, the item will now be selected regardless
   86.72 -                 * of whether or not it was previously selected.  ( on mouse
   86.73 -                 * generated DEFAULT ACTIONS the XmCR_BROWSE_SELECT is
   86.74 -                 * generated first ).
   86.75 -                 */
   86.76 -                JNU_CallMethodByName(env, NULL, (jobject) client_data
   86.77 -                                     ,"handleListChanged"
   86.78 -                                     ,"(I)V"
   86.79 -                                     ,(cbs->item_position - 1));
   86.80 -                if ((*env)->ExceptionOccurred(env)) {
   86.81 -                    (*env)->ExceptionDescribe(env);
   86.82 -                    (*env)->ExceptionClear(env);
   86.83 -                }
   86.84 -            }
   86.85 -
   86.86 -            JNU_CallMethodByName(env, NULL, (jobject) client_data
   86.87 -                                 ,"action"
   86.88 -                                 ,"(IJI)V"
   86.89 -                                 ,(cbs->item_position - 1)
   86.90 -                                 ,converted.when
   86.91 -                                 ,converted.modifiers);
   86.92 -            if ((*env)->ExceptionOccurred(env)) {
   86.93 -                (*env)->ExceptionDescribe(env);
   86.94 -                (*env)->ExceptionClear(env);
   86.95 -            }
   86.96 -            break;
   86.97 -        }
   86.98 -        case XmCR_BROWSE_SELECT:
   86.99 -            JNU_CallMethodByName(env, NULL, (jobject) client_data
  86.100 -                                 ,"handleListChanged"
  86.101 -                                 ,"(I)V"
  86.102 -                                 ,(cbs->item_position - 1));
  86.103 -            if ((*env)->ExceptionOccurred(env)) {
  86.104 -                (*env)->ExceptionDescribe(env);
  86.105 -                (*env)->ExceptionClear(env);
  86.106 -            }
  86.107 -            break;
  86.108 -
  86.109 -        case XmCR_MULTIPLE_SELECT:
  86.110 -            JNU_CallMethodByName(env, NULL, (jobject) client_data
  86.111 -                                 ,"handleListChanged"
  86.112 -                                 ,"(I)V"
  86.113 -                                 ,(cbs->item_position - 1));
  86.114 -            if ((*env)->ExceptionOccurred(env)) {
  86.115 -                (*env)->ExceptionDescribe(env);
  86.116 -                (*env)->ExceptionClear(env);
  86.117 -            }
  86.118 -            break;
  86.119 -
  86.120 -        default:
  86.121 -            break;
  86.122 -    }
  86.123 -}
  86.124 -
  86.125 -/*
  86.126 - * Class:     sun_awt_motif_MListPeer
  86.127 - * Method:    create
  86.128 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  86.129 - */
  86.130 -JNIEXPORT void JNICALL Java_sun_awt_motif_MListPeer_create
  86.131 -  (JNIEnv *env, jobject this, jobject parent)
  86.132 -{
  86.133 -    Cardinal argc;
  86.134 -#define MAX_ARGC 40
  86.135 -    Arg args[MAX_ARGC];
  86.136 -    struct ComponentData *wdata;
  86.137 -    struct ListData *sdata;
  86.138 -    Pixel bg;
  86.139 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
  86.140 -    AwtGraphicsConfigDataPtr adata;
  86.141 -
  86.142 -    AWT_LOCK();
  86.143 -
  86.144 -    adata = copyGraphicsConfigToPeer(env, this);
  86.145 -
  86.146 -    if (JNU_IsNull(env, parent)) {
  86.147 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.148 -        AWT_UNLOCK();
  86.149 -
  86.150 -        return;
  86.151 -    }
  86.152 -    wdata = (struct ComponentData *) JNU_GetLongFieldAsPtr(env,parent,mComponentPeerIDs.pData);
  86.153 -
  86.154 -    if (wdata == NULL) {
  86.155 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.156 -        AWT_UNLOCK();
  86.157 -        return;
  86.158 -    }
  86.159 -    sdata = (struct ListData *) calloc(1, sizeof(struct ListData));
  86.160 -
  86.161 -    JNU_SetLongFieldFromPtr(env,this,mComponentPeerIDs.pData,sdata);
  86.162 -    if (sdata == NULL) {
  86.163 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  86.164 -        AWT_UNLOCK();
  86.165 -        return;
  86.166 -    }
  86.167 -    XtVaGetValues(wdata->widget, XmNbackground, &bg, NULL);
  86.168 -    argc = 0;
  86.169 -    XtSetArg(args[argc], XmNrecomputeSize, False);
  86.170 -    argc++;
  86.171 -    XtSetArg(args[argc], XmNbackground, bg);
  86.172 -    argc++;
  86.173 -    XtSetArg(args[argc], XmNlistSizePolicy, XmCONSTANT);
  86.174 -    argc++;
  86.175 -    XtSetArg(args[argc], XmNx, 0);
  86.176 -    argc++;
  86.177 -    XtSetArg(args[argc], XmNy, 0);
  86.178 -    argc++;
  86.179 -    XtSetArg(args[argc], XmNmarginTop, 0);
  86.180 -    argc++;
  86.181 -    XtSetArg(args[argc], XmNmarginBottom, 0);
  86.182 -    argc++;
  86.183 -    XtSetArg(args[argc], XmNmarginLeft, 0);
  86.184 -    argc++;
  86.185 -    XtSetArg(args[argc], XmNmarginRight, 0);
  86.186 -    argc++;
  86.187 -    XtSetArg(args[argc], XmNmarginHeight, 0);
  86.188 -    argc++;
  86.189 -    XtSetArg(args[argc], XmNmarginWidth, 0);
  86.190 -    argc++;
  86.191 -    XtSetArg(args[argc], XmNlistMarginHeight, 0);
  86.192 -    argc++;
  86.193 -    XtSetArg(args[argc], XmNlistMarginWidth, 0);
  86.194 -    argc++;
  86.195 -    XtSetArg(args[argc], XmNscrolledWindowMarginWidth, 0);
  86.196 -    argc++;
  86.197 -    XtSetArg(args[argc], XmNscrolledWindowMarginHeight, 0);
  86.198 -    argc++;
  86.199 -    XtSetArg(args[argc], XmNuserData, (XtPointer) globalRef);
  86.200 -    argc++;
  86.201 -    XtSetArg (args[argc], XmNscreen,
  86.202 -              ScreenOfDisplay(awt_display,
  86.203 -                              adata->awt_visInfo.screen));
  86.204 -    argc++;
  86.205 -
  86.206 -    DASSERT(!(argc > MAX_ARGC));
  86.207 -    sdata->list = XmCreateScrolledList(wdata->widget,
  86.208 -                                       "slist",
  86.209 -                                       args,
  86.210 -                                       argc);
  86.211 -
  86.212 -    sdata->comp.widget = XtParent(sdata->list);
  86.213 -    XtSetMappedWhenManaged(sdata->comp.widget, False);
  86.214 -    XtAddCallback(sdata->list,
  86.215 -                  XmNdefaultActionCallback,
  86.216 -                  Slist_callback,
  86.217 -                  (XtPointer) globalRef);
  86.218 -    XtAddEventHandler(sdata->list, FocusChangeMask,
  86.219 -                      True, awt_canvas_event_handler, globalRef);
  86.220 -
  86.221 -    awt_addWidget(sdata->list, sdata->comp.widget, globalRef,
  86.222 -                  java_awt_AWTEvent_KEY_EVENT_MASK |
  86.223 -                  java_awt_AWTEvent_MOUSE_EVENT_MASK |
  86.224 -                  java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK);
  86.225 -
  86.226 -    XtManageChild(sdata->list);
  86.227 -    XtManageChild(sdata->comp.widget);
  86.228 -
  86.229 -    AWT_UNLOCK();
  86.230 -}
  86.231 -
  86.232 -/*
  86.233 - * Class:     sun_awt_motif_MListPeer
  86.234 - * Method:    setMultipleSelections
  86.235 - * Signature: (Z)V
  86.236 - */
  86.237 -JNIEXPORT void JNICALL Java_sun_awt_motif_MListPeer_setMultipleSelections
  86.238 -  (JNIEnv *env, jobject this, jboolean v)
  86.239 -{
  86.240 -    struct ListData *sdata;
  86.241 -    jobject globalRef;
  86.242 -    int32_t selPos;
  86.243 -    Boolean selected;
  86.244 -
  86.245 -    AWT_LOCK();
  86.246 -
  86.247 -    sdata = (struct ListData *)
  86.248 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  86.249 -    if (sdata == NULL) {
  86.250 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.251 -        AWT_UNLOCK();
  86.252 -        return;
  86.253 -    }
  86.254 -    globalRef = (jobject)
  86.255 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.jniGlobalRef);
  86.256 -    if (v == JNI_FALSE) {
  86.257 -        XtVaSetValues(sdata->list,
  86.258 -                      XmNselectionPolicy, XmBROWSE_SELECT,
  86.259 -                      NULL);
  86.260 -        XtRemoveCallback(sdata->list,
  86.261 -                         XmNmultipleSelectionCallback,
  86.262 -                         Slist_callback,
  86.263 -                         (XtPointer) globalRef);
  86.264 -        XtAddCallback(sdata->list,
  86.265 -                      XmNbrowseSelectionCallback,
  86.266 -                      Slist_callback,
  86.267 -                      (XtPointer) globalRef);
  86.268 -
  86.269 -        // If we change the selection mode from multiple to single
  86.270 -        // we need to decide what the item should be selected:
  86.271 -        // If a selected item has the location cursor, only that
  86.272 -        // item will remain selected.  If no selected item has the
  86.273 -        // location cursor, all items will be deselected.
  86.274 -        selPos = XmListGetKbdItemPos(sdata->list);
  86.275 -        selected = XmListPosSelected(sdata->list, selPos);
  86.276 -        XmListDeselectAllItems(sdata->list);
  86.277 -        if (selected) {
  86.278 -            Java_sun_awt_motif_MListPeer_select(env, this, selPos-1);
  86.279 -        }
  86.280 -
  86.281 -    } else {
  86.282 -        XtVaSetValues(sdata->list,
  86.283 -                      XmNselectionPolicy, XmMULTIPLE_SELECT,
  86.284 -                      NULL);
  86.285 -        XtRemoveCallback(sdata->list,
  86.286 -                         XmNbrowseSelectionCallback,
  86.287 -                         Slist_callback,
  86.288 -                         (XtPointer) globalRef);
  86.289 -        XtAddCallback(sdata->list,
  86.290 -                      XmNmultipleSelectionCallback,
  86.291 -                      Slist_callback,
  86.292 -                      (XtPointer) globalRef);
  86.293 -    }
  86.294 -    AWT_UNLOCK();
  86.295 -}
  86.296 -
  86.297 -/*
  86.298 - * Class:     sun_awt_motif_MListPeer
  86.299 - * Method:    setBackground
  86.300 - * Signature: (Ljava/awt/Color;)V
  86.301 - */
  86.302 -
  86.303 -JNIEXPORT void JNICALL Java_sun_awt_motif_MListPeer_setBackground
  86.304 -  (JNIEnv *env, jobject this, jobject c)
  86.305 -{
  86.306 -    struct ListData *ldata;
  86.307 -    Pixel color;
  86.308 -
  86.309 -    if (JNU_IsNull(env, c)) {
  86.310 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.311 -        return;
  86.312 -    }
  86.313 -    AWT_LOCK();
  86.314 -    ldata = (struct ListData *)
  86.315 -        JNU_GetLongFieldAsPtr(env,this, mComponentPeerIDs.pData);
  86.316 -    if (ldata == NULL || ldata->list == NULL) {
  86.317 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.318 -        AWT_UNLOCK();
  86.319 -        return;
  86.320 -    }
  86.321 -    color = awtJNI_GetColor(env, c);
  86.322 -    XtVaSetValues(ldata->list,
  86.323 -                  XmNbackground, color,
  86.324 -                  NULL);
  86.325 -    AWT_FLUSH_UNLOCK();
  86.326 -}
  86.327 -
  86.328 -/*
  86.329 - * Class:     sun_awt_motif_MListPeer
  86.330 - * Method:    isSelected
  86.331 - * Signature: (I)Z
  86.332 - */
  86.333 -JNIEXPORT jboolean JNICALL Java_sun_awt_motif_MListPeer_isSelected
  86.334 -  (JNIEnv *env, jobject this, jint pos)
  86.335 -{
  86.336 -    struct ListData *sdata;
  86.337 -
  86.338 -    AWT_LOCK();
  86.339 -
  86.340 -    sdata = (struct ListData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  86.341 -    if (sdata == NULL) {
  86.342 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.343 -        AWT_UNLOCK();
  86.344 -        return JNI_FALSE;
  86.345 -    }
  86.346 -    pos++;
  86.347 -    if (XmListPosSelected(sdata->list, pos) == True) {
  86.348 -        AWT_UNLOCK();
  86.349 -        return JNI_TRUE;
  86.350 -    } else {
  86.351 -        AWT_UNLOCK();
  86.352 -        return JNI_FALSE;
  86.353 -    }
  86.354 -}
  86.355 -
  86.356 -/*
  86.357 - * Class:     sun_awt_motif_MListPeer
  86.358 - * Method:    addItem
  86.359 - * Signature: (Ljava/lang/String;I)V
  86.360 - */
  86.361 -JNIEXPORT void JNICALL Java_sun_awt_motif_MListPeer_addItem
  86.362 -  (JNIEnv *env, jobject this, jstring item, jint index)
  86.363 -{
  86.364 -    XmString im;
  86.365 -    struct ListData *sdata;
  86.366 -    jobject font;
  86.367 -
  86.368 -    /*
  86.369 -     * Note:
  86.370 -     * There used to be code in this function to fix:
  86.371 -     *  4067355 size of listbox depends on when pack() is called (solaris)
  86.372 -     * The fix (for jdk1.1.7) involved unmapping the List widget before the add
  86.373 -     * is done and resizing/remapping it after the add. This causes significant
  86.374 -     * performance degradation if addItem() is called a lot. A bug was filed
  86.375 -     * on this performance problem: 4117288
  86.376 -     * The fix was backed out after testing that:
  86.377 -     *  - the problem reported in 4067355 was no longer reproducible
  86.378 -     *  - the performance problem is gone
  86.379 -     */
  86.380 -
  86.381 -    AWT_LOCK();
  86.382 -    if (JNU_IsNull(env, item)) {
  86.383 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.384 -        AWT_UNLOCK();
  86.385 -        return;
  86.386 -    }
  86.387 -    sdata = (struct ListData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  86.388 -    if (sdata == NULL) {
  86.389 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.390 -        AWT_UNLOCK();
  86.391 -        return;
  86.392 -    }
  86.393 -    font = awtJNI_GetFont(env, this);
  86.394 -
  86.395 -    if (awtJNI_IsMultiFont(env, font)) {
  86.396 -        im = awtJNI_MakeMultiFontString(env, item, font);
  86.397 -    } else {
  86.398 -        char *temp;
  86.399 -
  86.400 -        temp = (char *) JNU_GetStringPlatformChars(env, item, NULL);
  86.401 -        im = XmStringCreateLocalized(temp);
  86.402 -        JNU_ReleaseStringPlatformChars(env, item, (const char *)temp);
  86.403 -    }
  86.404 -
  86.405 -    /* motif uses 1-based indeces for the list operations with 0 */
  86.406 -    /* referring to the last item on the list. Thus if index is -1 */
  86.407 -    /* then we'll get the right effect of adding to the end of the */
  86.408 -    /* list. */
  86.409 -    index++;
  86.410 -
  86.411 -    XmListAddItemUnselected(sdata->list, im, index);
  86.412 -    XmStringFree(im);
  86.413 -
  86.414 -    AWT_UNLOCK();
  86.415 -}
  86.416 -
  86.417 -/*
  86.418 - * Class:     sun_awt_motif_MListPeer
  86.419 - * Method:    delItems
  86.420 - * Signature: (II)V
  86.421 - */
  86.422 -JNIEXPORT void JNICALL Java_sun_awt_motif_MListPeer_delItems
  86.423 -  (JNIEnv *env, jobject this, jint start, jint end)
  86.424 -{
  86.425 -    struct ListData *sdata;
  86.426 -    Boolean was_mapped;
  86.427 -    jobject target;
  86.428 -    Position width, height;
  86.429 -    int32_t itemCount;
  86.430 -
  86.431 -    AWT_LOCK();
  86.432 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  86.433 -    if (JNU_IsNull(env, target)) {
  86.434 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.435 -        AWT_UNLOCK();
  86.436 -        return;
  86.437 -    }
  86.438 -    sdata = (struct ListData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  86.439 -    if (sdata == NULL) {
  86.440 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.441 -        AWT_UNLOCK();
  86.442 -        return;
  86.443 -    }
  86.444 -    /* [jk] catch bogus indexes (Sun bug) */
  86.445 -    XtVaGetValues(sdata->list, XmNitemCount, &itemCount, NULL);
  86.446 -    if (itemCount == 0) {
  86.447 -        AWT_UNLOCK();
  86.448 -        return;
  86.449 -    }
  86.450 -    if (start > itemCount) {
  86.451 -        start = itemCount;
  86.452 -    }
  86.453 -    if (end > itemCount) {
  86.454 -        end = itemCount;
  86.455 -    }
  86.456 -    start++;
  86.457 -    end++;
  86.458 -
  86.459 -    XtVaGetValues(sdata->comp.widget, XmNmappedWhenManaged, &was_mapped, NULL);
  86.460 -
  86.461 -    /* If it was visible, then make it invisible while we update */
  86.462 -    if (was_mapped) {
  86.463 -      XtSetMappedWhenManaged(sdata->comp.widget, False);
  86.464 -    }
  86.465 -
  86.466 -    if (start == end) {
  86.467 -        XmListDeletePos(sdata->list, start);
  86.468 -    } else {
  86.469 -        XmListDeleteItemsPos(sdata->list, end - start + 1, start);
  86.470 -    }
  86.471 -
  86.472 -    width = (*env)->GetIntField(env, target, componentIDs.width);
  86.473 -    height = (*env)->GetIntField(env, target, componentIDs.height);
  86.474 -    XtVaSetValues(sdata->comp.widget,
  86.475 -                  XmNwidth, (width > 1) ? width-1 : 1,
  86.476 -                  XmNheight, (height > 1) ? height-1 : 1,
  86.477 -                  NULL);
  86.478 -    XtVaSetValues(sdata->comp.widget,
  86.479 -                  XmNwidth, (width > 0) ? width : 1,
  86.480 -                  XmNheight, (height > 0) ? height : 1,
  86.481 -                  NULL);
  86.482 -    /* If it was visible, then make it visible again once updated */
  86.483 -    if (was_mapped) {
  86.484 -        XtSetMappedWhenManaged(sdata->comp.widget, True);
  86.485 -    }
  86.486 -
  86.487 -
  86.488 -    AWT_UNLOCK();
  86.489 -}
  86.490 -
  86.491 -/*
  86.492 - * Class:     sun_awt_motif_MListPeer
  86.493 - * Method:    pSelect
  86.494 - * Signature: (I)V
  86.495 - */
  86.496 -JNIEXPORT void JNICALL Java_sun_awt_motif_MListPeer_select
  86.497 -  (JNIEnv *env, jobject this, jint pos)
  86.498 -{
  86.499 -    struct ListData *sdata;
  86.500 -
  86.501 -    AWT_LOCK();
  86.502 -    sdata = (struct ListData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  86.503 -    if (sdata == NULL) {
  86.504 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.505 -        AWT_UNLOCK();
  86.506 -        return;
  86.507 -    }
  86.508 -    pos++;
  86.509 -    XmListSelectPos(sdata->list, pos, False);
  86.510 -    AWT_UNLOCK();
  86.511 -}
  86.512 -
  86.513 -/*
  86.514 - * Class:     sun_awt_motif_MListPeer
  86.515 - * Method:    pDeselect
  86.516 - * Signature: (I)V
  86.517 - */
  86.518 -JNIEXPORT void JNICALL Java_sun_awt_motif_MListPeer_deselect
  86.519 -  (JNIEnv *env, jobject this, jint pos)
  86.520 -{
  86.521 -    struct ListData *sdata;
  86.522 -
  86.523 -    AWT_LOCK();
  86.524 -    sdata = (struct ListData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  86.525 -    if (sdata == NULL) {
  86.526 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.527 -        AWT_UNLOCK();
  86.528 -        return;
  86.529 -    }
  86.530 -    pos++;
  86.531 -    XmListDeselectPos(sdata->list, pos);
  86.532 -    AWT_UNLOCK();
  86.533 -}
  86.534 -
  86.535 -/*
  86.536 - * Class:     sun_awt_motif_MListPeer
  86.537 - * Method:    makeVisible
  86.538 - * Signature: (I)V
  86.539 - */
  86.540 -JNIEXPORT void JNICALL Java_sun_awt_motif_MListPeer_makeVisible
  86.541 -  (JNIEnv *env, jobject this, jint pos)
  86.542 -{
  86.543 -    int32_t top, visible;
  86.544 -    struct ListData *sdata;
  86.545 -
  86.546 -    AWT_LOCK();
  86.547 -    sdata = (struct ListData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  86.548 -    if (sdata == NULL) {
  86.549 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.550 -        AWT_UNLOCK();
  86.551 -        return;
  86.552 -    }
  86.553 -    XtVaGetValues(sdata->list,
  86.554 -                  XmNtopItemPosition, &top,
  86.555 -                  XmNvisibleItemCount, &visible,
  86.556 -                  NULL);
  86.557 -    pos++;
  86.558 -    if (pos < top) {
  86.559 -        XmListSetPos(sdata->list, pos);
  86.560 -    } else {
  86.561 -        XmListSetBottomPos(sdata->list, pos);
  86.562 -    }
  86.563 -
  86.564 -    AWT_UNLOCK();
  86.565 -}
  86.566 -
  86.567 -/*
  86.568 - * Class:     sun_awt_motif_MListPeer
  86.569 - * Method:    nativeHandleMouseWheel
  86.570 - * Signature: (III)V
  86.571 - */
  86.572 -JNIEXPORT void JNICALL Java_sun_awt_motif_MListPeer_nativeHandleMouseWheel
  86.573 -  (JNIEnv *env, jobject this, jint scrollType, jint scrollAmt, jint wheelAmt)
  86.574 -{
  86.575 -    struct ListData *ldata;
  86.576 -    Widget list = NULL;
  86.577 -    Widget scroll = NULL;
  86.578 -
  86.579 -    AWT_LOCK();
  86.580 -    ldata = (struct ListData *)
  86.581 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  86.582 -    if (ldata == NULL || ldata->comp.widget == NULL) {
  86.583 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  86.584 -        AWT_UNLOCK();
  86.585 -        return;
  86.586 -    }
  86.587 -    // get the List widget
  86.588 -    list = ldata->list;
  86.589 -    if (list == NULL) {
  86.590 -        AWT_UNLOCK();
  86.591 -        return;
  86.592 -    }
  86.593 -
  86.594 -    // get the ScrolledWindow
  86.595 -    scroll = XtParent(list);
  86.596 -    if (scroll == NULL) {
  86.597 -        AWT_UNLOCK();
  86.598 -        return;
  86.599 -    }
  86.600 -
  86.601 -    awt_util_do_wheel_scroll(scroll, scrollType, scrollAmt, wheelAmt);
  86.602 -    AWT_UNLOCK();
  86.603 -}
    87.1 --- a/src/solaris/native/sun/awt/awt_MToolkit.c	Wed Sep 17 13:45:37 2008 -0700
    87.2 +++ b/src/solaris/native/sun/awt/awt_MToolkit.c	Fri Sep 19 19:38:12 2008 -0700
    87.3 @@ -48,7 +48,7 @@
    87.4  
    87.5  /* JNI field and method ids */
    87.6  #include "awt_Component.h"
    87.7 -#include "awt_Cursor.h"
    87.8 +//#include "awt_Cursor.h"
    87.9  #include "awt_MenuComponent.h"
   87.10  #include "awt_TopLevel.h"
   87.11  #include "canvas.h"
    88.1 --- a/src/solaris/native/sun/awt/awt_Menu.c	Wed Sep 17 13:45:37 2008 -0700
    88.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.3 @@ -1,407 +0,0 @@
    88.4 -/*
    88.5 - * Copyright 1995-2004 Sun Microsystems, Inc.  All Rights Reserved.
    88.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    88.7 - *
    88.8 - * This code is free software; you can redistribute it and/or modify it
    88.9 - * under the terms of the GNU General Public License version 2 only, as
   88.10 - * published by the Free Software Foundation.  Sun designates this
   88.11 - * particular file as subject to the "Classpath" exception as provided
   88.12 - * by Sun in the LICENSE file that accompanied this code.
   88.13 - *
   88.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   88.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   88.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   88.17 - * version 2 for more details (a copy is included in the LICENSE file that
   88.18 - * accompanied this code).
   88.19 - *
   88.20 - * You should have received a copy of the GNU General Public License version
   88.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   88.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   88.23 - *
   88.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   88.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   88.26 - * have any questions.
   88.27 - */
   88.28 -
   88.29 -#ifdef HEADLESS
   88.30 -    #error This file should not be included in headless library
   88.31 -#endif
   88.32 -
   88.33 -#include "awt_p.h"
   88.34 -#include "color.h"
   88.35 -#include "java_awt_Menu.h"
   88.36 -#include "sun_awt_motif_MMenuPeer.h"
   88.37 -#include "java_awt_MenuBar.h"
   88.38 -#include "sun_awt_motif_MMenuBarPeer.h"
   88.39 -
   88.40 -#include "awt_MenuBar.h"
   88.41 -#include "awt_MenuComponent.h"
   88.42 -#include "awt_MenuItem.h"
   88.43 -#include "awt_Menu.h"
   88.44 -
   88.45 -#include "multi_font.h"
   88.46 -#include <jni.h>
   88.47 -#include <jni_util.h>
   88.48 -#include <Xm/CascadeBP.h>
   88.49 -
   88.50 -extern struct MenuComponentIDs menuComponentIDs;
   88.51 -extern struct MenuItemIDs menuItemIDs;
   88.52 -extern struct MMenuItemPeerIDs mMenuItemPeerIDs;
   88.53 -extern struct MMenuBarPeerIDs mMenuBarPeerIDs;
   88.54 -
   88.55 -struct MenuIDs menuIDs;
   88.56 -
   88.57 -/*
   88.58 - * Class:     java_awt_Menu
   88.59 - * Method:    initIDs
   88.60 - * Signature: ()V
   88.61 - */
   88.62 -
   88.63 -/* This function gets called from the static initializer for
   88.64 -   Menu.java to initialize the fieldIDs for fields that may
   88.65 -   be accessed from C */
   88.66 -
   88.67 -JNIEXPORT void JNICALL Java_java_awt_Menu_initIDs
   88.68 -  (JNIEnv *env, jclass cls)
   88.69 -{
   88.70 -    menuIDs.tearOff = (*env)->GetFieldID(env, cls, "tearOff", "Z");
   88.71 -    menuIDs.isHelpMenu = (*env)->GetFieldID(env, cls, "isHelpMenu", "Z");
   88.72 -}
   88.73 -
   88.74 -/*
   88.75 - * Fix for Bug Traq 4251941 - segfault after double tear-off and close
   88.76 - * Removes the lost callback from menu item on tear-off control re-creation.
   88.77 - * Only for internal use, to be used from awtTearOffActivatedCallback
   88.78 - */
   88.79 -static void awtTearOffShellDestroy(Widget widget, XtPointer closure, XtPointer data) {
   88.80 -    if (widget != NULL ) {
   88.81 -        XtSetKeyboardFocus(widget, NULL);
   88.82 -    }
   88.83 -}
   88.84 -
   88.85 -/*
   88.86 - * Fix for Bug Traq 4251941 - segfault after double tear-off and close
   88.87 - * This callback is added to menu after the creation.
   88.88 - * It adds the destroy callback awtTearOffShellDestroy to remove the lost focus callback on destroy
   88.89 - */
   88.90 -static void awtTearOffActivatedCallback(Widget widget, XtPointer closure, XtPointer data) {
   88.91 -    Widget shell;
   88.92 -    shell = XtParent(widget);
   88.93 -    if (shell != NULL && XtClass(shell) == transientShellWidgetClass) {
   88.94 -        XtAddCallback(shell, XtNdestroyCallback, awtTearOffShellDestroy, widget);
   88.95 -    }
   88.96 -}
   88.97 -
   88.98 -extern Boolean skipNextNotifyWhileGrabbed;
   88.99 -
  88.100 -static void
  88.101 -Menu_popDownCB(Widget w, XtPointer client_data, XtPointer calldata)
  88.102 -{
  88.103 -    skipNextNotifyWhileGrabbed = True;
  88.104 -}
  88.105 -
  88.106 -
  88.107 -
  88.108 -/*
  88.109 - * this is a MMenuPeer instance
  88.110 - */
  88.111 -static void
  88.112 -awtJNI_CreateMenu(JNIEnv * env, jobject this, Widget menuParent)
  88.113 -{
  88.114 -    int32_t argc;
  88.115 -#define MAX_ARGC 10
  88.116 -    Arg args[MAX_ARGC];
  88.117 -    char *ctitle = NULL;
  88.118 -    struct MenuData *mdata;
  88.119 -    struct FontData *fdata;
  88.120 -    Pixel bg;
  88.121 -    Pixel fg;
  88.122 -    XmFontList fontlist = NULL;
  88.123 -    Widget tearOff;
  88.124 -    XmString mfstr = NULL;
  88.125 -    XmString str = NULL;
  88.126 -    jobject target;
  88.127 -    jobject targetFont;
  88.128 -    jobject label;
  88.129 -    jobject font;
  88.130 -    jboolean IsMultiFont;
  88.131 -    jboolean isTearOff;
  88.132 -
  88.133 -    /* perhaps this is unncessary, if awtJNI_CreateMenu is only called
  88.134 -     * from a native method.
  88.135 -     */
  88.136 -    if ((*env)->PushLocalFrame(env, (jint)16) < (jint)0) {
  88.137 -        return;
  88.138 -    }
  88.139 -
  88.140 -    fdata = NULL;
  88.141 -
  88.142 -    target = (*env)->GetObjectField(env, this, mMenuItemPeerIDs.target);
  88.143 -    if (JNU_IsNull(env, target)) {
  88.144 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  88.145 -        (*env)->PopLocalFrame(env, NULL);
  88.146 -        return;
  88.147 -    }
  88.148 -    font = JNU_CallMethodByName(env, NULL, target, "getFont_NoClientCode",
  88.149 -                                "()Ljava/awt/Font;").l;
  88.150 -
  88.151 -    mdata = ZALLOC(MenuData);
  88.152 -    JNU_SetLongFieldFromPtr(env, this, mMenuItemPeerIDs.pData, mdata);
  88.153 -    if (mdata == NULL) {
  88.154 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  88.155 -        (*env)->PopLocalFrame(env, NULL);
  88.156 -        return;
  88.157 -    }
  88.158 -    targetFont = (*env)->GetObjectField(env, target, menuComponentIDs.font);
  88.159 -    if (!JNU_IsNull(env, targetFont) &&
  88.160 -        (fdata = awtJNI_GetFontData(env, targetFont, NULL)) != NULL) {
  88.161 -        IsMultiFont = awtJNI_IsMultiFont(env, targetFont);
  88.162 -    } else {
  88.163 -        IsMultiFont = awtJNI_IsMultiFont(env, font);
  88.164 -    }
  88.165 -
  88.166 -    label = (*env)->GetObjectField(env, target, menuItemIDs.label);
  88.167 -    if (JNU_IsNull(env, label)) {
  88.168 -        mfstr = XmStringCreateLocalized("");
  88.169 -        ctitle = "";
  88.170 -    } else {
  88.171 -        if (IsMultiFont) {
  88.172 -            mfstr = awtJNI_MakeMultiFontString(env, label, font);
  88.173 -        } else {
  88.174 -            ctitle = (char *) JNU_GetStringPlatformChars(env, label, NULL);
  88.175 -        }
  88.176 -    }
  88.177 -
  88.178 -    XtVaGetValues(menuParent, XmNbackground, &bg, NULL);
  88.179 -    XtVaGetValues(menuParent, XmNforeground, &fg, NULL);
  88.180 -
  88.181 -    argc = 0;
  88.182 -    XtSetArg(args[argc], XmNbackground, bg);
  88.183 -    argc++;
  88.184 -    XtSetArg(args[argc], XmNforeground, fg);
  88.185 -    argc++;
  88.186 -
  88.187 -    XtSetArg(args[argc], XmNlabelFontList,   getMotifFontList());
  88.188 -    argc++;
  88.189 -    XtSetArg(args[argc], XmNbuttonFontList,  getMotifFontList());
  88.190 -    argc++;
  88.191 -
  88.192 -    isTearOff = (*env)->GetBooleanField(env, target, menuIDs.tearOff);
  88.193 -
  88.194 -    if (isTearOff) {
  88.195 -        XtSetArg(args[argc], XmNtearOffModel, XmTEAR_OFF_ENABLED);
  88.196 -        argc++;
  88.197 -    }
  88.198 -
  88.199 -    if (IsMultiFont) {
  88.200 -        DASSERT(!(argc > MAX_ARGC));
  88.201 -        mdata->itemData.comp.widget = XmCreatePulldownMenu(menuParent,
  88.202 -                                                           "",
  88.203 -                                                           args,
  88.204 -                                                           argc);
  88.205 -    } else {
  88.206 -        DASSERT(!(argc > MAX_ARGC));
  88.207 -        mdata->itemData.comp.widget = XmCreatePulldownMenu(menuParent,
  88.208 -                                                           ctitle,
  88.209 -                                                           args,
  88.210 -                                                           argc);
  88.211 -    }
  88.212 -    awt_addMenuWidget(mdata->itemData.comp.widget);
  88.213 -
  88.214 -    if (isTearOff) {
  88.215 -        tearOff = XmGetTearOffControl(mdata->itemData.comp.widget);
  88.216 -        XtVaSetValues(tearOff,
  88.217 -                      XmNbackground, bg,
  88.218 -                      XmNforeground, fg,
  88.219 -                      XmNhighlightColor, fg,
  88.220 -                      NULL);
  88.221 -        XtAddCallback(mdata->itemData.comp.widget, XmNtearOffMenuActivateCallback,
  88.222 -                      awtTearOffActivatedCallback, NULL);
  88.223 -    }
  88.224 -    argc = 0;
  88.225 -    XtSetArg(args[argc], XmNsubMenuId, mdata->itemData.comp.widget);
  88.226 -    argc++;
  88.227 -
  88.228 -    if (IsMultiFont) {
  88.229 -        XtSetArg(args[argc], XmNlabelString, mfstr);
  88.230 -    } else {
  88.231 -        str = XmStringCreate(ctitle, XmSTRING_DEFAULT_CHARSET);
  88.232 -        XtSetArg(args[argc], XmNlabelString, str);
  88.233 -    }
  88.234 -    argc++;
  88.235 -    XtSetArg(args[argc], XmNbackground, bg);
  88.236 -    argc++;
  88.237 -    XtSetArg(args[argc], XmNforeground, fg);
  88.238 -    argc++;
  88.239 -
  88.240 -    if (!JNU_IsNull(env, targetFont) && (fdata != NULL)) {
  88.241 -        if (IsMultiFont) {
  88.242 -            fontlist = awtJNI_GetFontList(env, targetFont);
  88.243 -        } else {
  88.244 -            fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  88.245 -        }
  88.246 -        XtSetArg(args[argc], XmNfontList, fontlist);
  88.247 -        argc++;
  88.248 -    } else {
  88.249 -        if (IsMultiFont) {
  88.250 -            fontlist = awtJNI_GetFontList(env, font);
  88.251 -            XtSetArg(args[argc], XmNfontList, fontlist);
  88.252 -            argc++;
  88.253 -        }
  88.254 -    }
  88.255 -
  88.256 -    if (IsMultiFont) {
  88.257 -        DASSERT(!(argc > MAX_ARGC));
  88.258 -        mdata->comp.widget = XmCreateCascadeButton(menuParent, "", args, argc);
  88.259 -    } else {
  88.260 -        DASSERT(!(argc > MAX_ARGC));
  88.261 -        mdata->comp.widget = XmCreateCascadeButton(menuParent, ctitle, args, argc);
  88.262 -    }
  88.263 -
  88.264 -    if ((*env)->GetBooleanField(env, target, menuIDs.isHelpMenu)) {
  88.265 -        XtVaSetValues(menuParent,
  88.266 -                      XmNmenuHelpWidget, mdata->comp.widget,
  88.267 -                      NULL);
  88.268 -    }
  88.269 -
  88.270 -    /**
  88.271 -     * Add callback to MenuShell of the menu so we know when
  88.272 -     * menu pops down. mdata->itemData.comp.widget is RowColumn,
  88.273 -     * its parent - MenuShell.
  88.274 -     */
  88.275 -    XtAddCallback(XtParent(mdata->itemData.comp.widget), XtNpopdownCallback,
  88.276 -                  Menu_popDownCB,
  88.277 -                  (XtPointer)
  88.278 -                  JNU_GetLongFieldAsPtr(env, this,
  88.279 -                                        mMenuItemPeerIDs.jniGlobalRef));
  88.280 -
  88.281 -    /*
  88.282 -     * Free resources
  88.283 -     */
  88.284 -    if (!JNU_IsNull(env, targetFont)) {
  88.285 -        XmFontListFree(fontlist);
  88.286 -    }
  88.287 -
  88.288 -    if (mfstr != NULL) {
  88.289 -      XmStringFree(mfstr);
  88.290 -      mfstr = NULL;
  88.291 -    }
  88.292 -
  88.293 -    if (str) {
  88.294 -      XmStringFree(str);
  88.295 -      str = NULL;
  88.296 -    }
  88.297 -
  88.298 -    XtManageChild(mdata->comp.widget);
  88.299 -    XtSetSensitive(mdata->comp.widget,
  88.300 -                   (*env)->GetBooleanField(env, target, menuItemIDs.enabled) ?
  88.301 -                   True : False);
  88.302 -
  88.303 -    if (ctitle != NULL && ctitle != "") {
  88.304 -        JNU_ReleaseStringPlatformChars(env, label, (const char *) ctitle);
  88.305 -    }
  88.306 -    (*env)->PopLocalFrame(env, NULL);
  88.307 -}
  88.308 -
  88.309 -
  88.310 -/*
  88.311 - * Class:     sun_awt_motif_MMenuPeer
  88.312 - * Method:    createMenu
  88.313 - * Signature: (Lsun/awt/motif/MMenuBarPeer;)V
  88.314 - */
  88.315 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuPeer_createMenu
  88.316 -  (JNIEnv *env, jobject this, jobject parent)
  88.317 -{
  88.318 -    struct ComponentData *mbdata;
  88.319 -    AwtGraphicsConfigDataPtr adata;
  88.320 -
  88.321 -    AWT_LOCK();
  88.322 -    if (JNU_IsNull(env, parent)) {
  88.323 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  88.324 -        AWT_UNLOCK();
  88.325 -        return;
  88.326 -    }
  88.327 -    mbdata = (struct ComponentData *)
  88.328 -        JNU_GetLongFieldAsPtr(env, parent, mMenuBarPeerIDs.pData);
  88.329 -    if (mbdata == NULL) {
  88.330 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  88.331 -        AWT_UNLOCK();
  88.332 -        return;
  88.333 -    }
  88.334 -
  88.335 -    awtJNI_CreateMenu(env, this, mbdata->widget);
  88.336 -
  88.337 -    AWT_UNLOCK();
  88.338 -}
  88.339 -
  88.340 -/*
  88.341 - * Class:     sun_awt_motif_MMenuPeer
  88.342 - * Method:    createSubMenu
  88.343 - * Signature: (Lsun/awt/motif/MMenuPeer;)V
  88.344 - */
  88.345 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuPeer_createSubMenu
  88.346 -(JNIEnv *env, jobject this, jobject parent)
  88.347 -{
  88.348 -    struct MenuData *mpdata;
  88.349 -    AwtGraphicsConfigDataPtr adata;
  88.350 -
  88.351 -    AWT_LOCK();
  88.352 -    if (JNU_IsNull(env, parent)) {
  88.353 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  88.354 -        AWT_UNLOCK();
  88.355 -        return;
  88.356 -    }
  88.357 -    mpdata = (struct MenuData *)
  88.358 -        JNU_GetLongFieldAsPtr(env, parent, mMenuItemPeerIDs.pData);
  88.359 -    if (mpdata == NULL) {
  88.360 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  88.361 -        AWT_UNLOCK();
  88.362 -        return;
  88.363 -    }
  88.364 -
  88.365 -    awtJNI_CreateMenu(env, this, mpdata->itemData.comp.widget);
  88.366 -
  88.367 -    AWT_UNLOCK();
  88.368 -}
  88.369 -
  88.370 -/*
  88.371 - * Class:     sun_awt_motif_MMenuPeer
  88.372 - * Method:    pDispose
  88.373 - * Signature: ()V
  88.374 - */
  88.375 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuPeer_pDispose
  88.376 -  (JNIEnv *env, jobject this)
  88.377 -{
  88.378 -    struct MenuData *mdata;
  88.379 -    Widget parent;
  88.380 -    Boolean isParentManaged = False;
  88.381 -
  88.382 -    AWT_LOCK();
  88.383 -
  88.384 -    mdata = (struct MenuData *)
  88.385 -        JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  88.386 -    if (mdata == NULL) {
  88.387 -        AWT_UNLOCK();
  88.388 -        return;
  88.389 -    }
  88.390 -    awt_delMenuWidget(mdata->itemData.comp.widget);
  88.391 -    XtUnmanageChild(mdata->comp.widget);
  88.392 -    awt_util_consumeAllXEvents(mdata->itemData.comp.widget);
  88.393 -    awt_util_consumeAllXEvents(mdata->comp.widget);
  88.394 -
  88.395 -    parent = XtParent(mdata->itemData.comp.widget);
  88.396 -    if (parent != NULL && XtIsManaged(parent)) {
  88.397 -        isParentManaged = True;
  88.398 -        XtUnmanageChild(parent);
  88.399 -    }
  88.400 -
  88.401 -    XtDestroyWidget(mdata->itemData.comp.widget);
  88.402 -
  88.403 -    if (isParentManaged) {
  88.404 -        XtManageChild(parent);
  88.405 -    }
  88.406 -
  88.407 -    XtDestroyWidget(mdata->comp.widget);
  88.408 -    free((void *) mdata);
  88.409 -    AWT_UNLOCK();
  88.410 -}
    89.1 --- a/src/solaris/native/sun/awt/awt_Menu.h	Wed Sep 17 13:45:37 2008 -0700
    89.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.3 @@ -1,32 +0,0 @@
    89.4 -/*
    89.5 - * Copyright 1998 Sun Microsystems, Inc.  All Rights Reserved.
    89.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    89.7 - *
    89.8 - * This code is free software; you can redistribute it and/or modify it
    89.9 - * under the terms of the GNU General Public License version 2 only, as
   89.10 - * published by the Free Software Foundation.  Sun designates this
   89.11 - * particular file as subject to the "Classpath" exception as provided
   89.12 - * by Sun in the LICENSE file that accompanied this code.
   89.13 - *
   89.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   89.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   89.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   89.17 - * version 2 for more details (a copy is included in the LICENSE file that
   89.18 - * accompanied this code).
   89.19 - *
   89.20 - * You should have received a copy of the GNU General Public License version
   89.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   89.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   89.23 - *
   89.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   89.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   89.26 - * have any questions.
   89.27 - */
   89.28 -
   89.29 -#include <jni_util.h>
   89.30 -
   89.31 -/* fieldIDs for Menu fields that may be accessed from C */
   89.32 -struct MenuIDs {
   89.33 -    jfieldID tearOff;
   89.34 -    jfieldID isHelpMenu;
   89.35 -};
    90.1 --- a/src/solaris/native/sun/awt/awt_MenuBar.c	Wed Sep 17 13:45:37 2008 -0700
    90.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.3 @@ -1,198 +0,0 @@
    90.4 -/*
    90.5 - * Copyright 1995-2004 Sun Microsystems, Inc.  All Rights Reserved.
    90.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    90.7 - *
    90.8 - * This code is free software; you can redistribute it and/or modify it
    90.9 - * under the terms of the GNU General Public License version 2 only, as
   90.10 - * published by the Free Software Foundation.  Sun designates this
   90.11 - * particular file as subject to the "Classpath" exception as provided
   90.12 - * by Sun in the LICENSE file that accompanied this code.
   90.13 - *
   90.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   90.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   90.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   90.17 - * version 2 for more details (a copy is included in the LICENSE file that
   90.18 - * accompanied this code).
   90.19 - *
   90.20 - * You should have received a copy of the GNU General Public License version
   90.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   90.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   90.23 - *
   90.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   90.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   90.26 - * have any questions.
   90.27 - */
   90.28 -#ifdef HEADLESS
   90.29 -    #error This file should not be included in headless library
   90.30 -#endif
   90.31 -
   90.32 -#include "awt_p.h"
   90.33 -#include "java_awt_MenuBar.h"
   90.34 -#include "sun_awt_motif_MMenuBarPeer.h"
   90.35 -#include "java_awt_Menu.h"
   90.36 -#include "java_awt_Frame.h"
   90.37 -#include "sun_awt_motif_MFramePeer.h"
   90.38 -
   90.39 -#include "awt_GraphicsEnv.h"
   90.40 -#include "awt_MenuBar.h"
   90.41 -#include "awt_Component.h"
   90.42 -
   90.43 -#include <jni.h>
   90.44 -#include <jni_util.h>
   90.45 -
   90.46 -extern struct MComponentPeerIDs mComponentPeerIDs;
   90.47 -extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
   90.48 -struct MMenuBarPeerIDs mMenuBarPeerIDs;
   90.49 -
   90.50 -/*
   90.51 - * Class:     sun_awt_motif_MMenuBarPeer
   90.52 - * Method:    initIDs
   90.53 - * Signature: ()V
   90.54 - */
   90.55 -
   90.56 -/* This function gets called from the static initializer for MMenuBarPeer.java
   90.57 -   to initialize the fieldIDs fields that may be accessed from C */
   90.58 -JNIEXPORT void JNICALL
   90.59 -Java_sun_awt_motif_MMenuBarPeer_initIDs
   90.60 -  (JNIEnv *env, jclass cls)
   90.61 -{
   90.62 -  mMenuBarPeerIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J");
   90.63 -  mMenuBarPeerIDs.graphicsConfig =
   90.64 -      (*env)->GetFieldID(env, cls, "graphicsConfig",
   90.65 -                         "Lsun/awt/X11GraphicsConfig;");
   90.66 -}
   90.67 -
   90.68 -static AwtGraphicsConfigDataPtr
   90.69 -copyGraphicsConfigToMenuBarPeer(
   90.70 -JNIEnv *env, jobject frame, jobject thisMenuBar) {
   90.71 -
   90.72 -    jobject gc_object;
   90.73 -    AwtGraphicsConfigDataPtr adata;
   90.74 -
   90.75 -    /* GraphicsConfiguration object of Component */
   90.76 -    gc_object = (*env)->GetObjectField(env, frame,
   90.77 -                                       mComponentPeerIDs.graphicsConfig);
   90.78 -
   90.79 -    if (gc_object != NULL) {
   90.80 -        /* Set graphicsConfig field of MComponentPeer */
   90.81 -        (*env)->SetObjectField (env, thisMenuBar,
   90.82 -                                mMenuBarPeerIDs.graphicsConfig,
   90.83 -                                gc_object);
   90.84 -        adata = (AwtGraphicsConfigDataPtr)
   90.85 -            JNU_GetLongFieldAsPtr(env, gc_object,
   90.86 -                                  x11GraphicsConfigIDs.aData);
   90.87 -    } else {
   90.88 -        /* Component was not constructed with a GraphicsConfiguration
   90.89 -           object */
   90.90 -        adata = getDefaultConfig(DefaultScreen(awt_display));
   90.91 -    }
   90.92 -
   90.93 -    return adata;
   90.94 -}
   90.95 -
   90.96 -AwtGraphicsConfigDataPtr
   90.97 -getGraphicsConfigFromMenuBarPeer(JNIEnv *env, jobject menubarPeer) {
   90.98 -
   90.99 -    jobject gc_object;
  90.100 -    AwtGraphicsConfigDataPtr adata;
  90.101 -
  90.102 -    /* GraphicsConfiguration object of Component */
  90.103 -    gc_object = (*env)->GetObjectField(env, menubarPeer,
  90.104 -                                       mMenuBarPeerIDs.graphicsConfig);
  90.105 -
  90.106 -    if (gc_object != NULL) {
  90.107 -        adata = (AwtGraphicsConfigDataPtr)
  90.108 -            JNU_GetLongFieldAsPtr(env, gc_object,
  90.109 -                                  x11GraphicsConfigIDs.aData);
  90.110 -    } else {
  90.111 -        adata = getDefaultConfig(DefaultScreen(awt_display));
  90.112 -    }
  90.113 -
  90.114 -    return adata;
  90.115 -}
  90.116 -
  90.117 -/*
  90.118 - * Class:     sun_awt_motif_MMenuBarPeer
  90.119 - * Method:    create
  90.120 - * Signature: (Lsun/awt/motif/MFramePeer;)V
  90.121 - */
  90.122 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuBarPeer_create
  90.123 -  (JNIEnv * env, jobject this, jobject frame)
  90.124 -{
  90.125 -#define MAX_ARGC 20
  90.126 -    Arg args[MAX_ARGC];
  90.127 -    int32_t argc;
  90.128 -    struct ComponentData *mdata;
  90.129 -    struct FrameData *wdata;
  90.130 -    Pixel bg;
  90.131 -    Pixel fg;
  90.132 -    AwtGraphicsConfigDataPtr adata;
  90.133 -
  90.134 -    if (JNU_IsNull(env, frame)) {
  90.135 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  90.136 -        return;
  90.137 -    }
  90.138 -    AWT_LOCK();
  90.139 -    wdata = (struct FrameData *)
  90.140 -        JNU_GetLongFieldAsPtr(env, frame, mComponentPeerIDs.pData);
  90.141 -    mdata = ZALLOC(ComponentData);
  90.142 -
  90.143 -    if (wdata == NULL || mdata == NULL) {
  90.144 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  90.145 -        AWT_UNLOCK();
  90.146 -        return;
  90.147 -    }
  90.148 -    JNU_SetLongFieldFromPtr(env, this, mMenuBarPeerIDs.pData, mdata);
  90.149 -
  90.150 -    adata = copyGraphicsConfigToMenuBarPeer(env, frame, this);
  90.151 -
  90.152 -    XtVaGetValues(wdata->winData.comp.widget,
  90.153 -                  XmNbackground, &bg,
  90.154 -                  XmNforeground, &fg,
  90.155 -                  NULL);
  90.156 -
  90.157 -    argc = 0;
  90.158 -    XtSetArg(args[argc], XmNbackground, bg);
  90.159 -    argc++;
  90.160 -    XtSetArg(args[argc], XmNforeground, fg);
  90.161 -    argc++;
  90.162 -    XtSetArg (args[argc], XmNscreen,
  90.163 -              ScreenOfDisplay(awt_display,
  90.164 -                              adata->awt_visInfo.screen));
  90.165 -    argc++;
  90.166 -
  90.167 -    DASSERT(!(argc > MAX_ARGC));
  90.168 -    mdata->widget = XmCreateMenuBar(wdata->mainWindow, "menu_bar", args, argc);
  90.169 -    awt_addMenuWidget(mdata->widget);
  90.170 -    XtSetMappedWhenManaged(mdata->widget, False);
  90.171 -    XtManageChild(mdata->widget);
  90.172 -    AWT_UNLOCK();
  90.173 -}
  90.174 -
  90.175 -/*
  90.176 - * Class:     sun_awt_motif_MMenuBarPeer
  90.177 - * Method:    dispose
  90.178 - * Signature: ()V
  90.179 - */
  90.180 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuBarPeer_pDispose
  90.181 -  (JNIEnv * env, jobject this)
  90.182 -{
  90.183 -    struct ComponentData *mdata;
  90.184 -
  90.185 -    AWT_LOCK();
  90.186 -
  90.187 -    /*hania LOOK HERE does this make sense? look at original code */
  90.188 -    mdata = (struct ComponentData *)
  90.189 -        JNU_GetLongFieldAsPtr(env, this, mMenuBarPeerIDs.pData);
  90.190 -    if (mdata == NULL) {
  90.191 -        AWT_UNLOCK();
  90.192 -        return;
  90.193 -    }
  90.194 -    awt_delMenuWidget(mdata->widget);
  90.195 -    XtUnmanageChild(mdata->widget);
  90.196 -    awt_util_consumeAllXEvents(mdata->widget);
  90.197 -    XtDestroyWidget(mdata->widget);
  90.198 -    free((void *) mdata);
  90.199 -    (*env)->SetLongField(env, this, mMenuBarPeerIDs.pData, (jlong)0);
  90.200 -    AWT_UNLOCK();
  90.201 -}
    91.1 --- a/src/solaris/native/sun/awt/awt_MenuBar.h	Wed Sep 17 13:45:37 2008 -0700
    91.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.3 @@ -1,30 +0,0 @@
    91.4 -/*
    91.5 - * Copyright 1998-1999 Sun Microsystems, Inc.  All Rights Reserved.
    91.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    91.7 - *
    91.8 - * This code is free software; you can redistribute it and/or modify it
    91.9 - * under the terms of the GNU General Public License version 2 only, as
   91.10 - * published by the Free Software Foundation.  Sun designates this
   91.11 - * particular file as subject to the "Classpath" exception as provided
   91.12 - * by Sun in the LICENSE file that accompanied this code.
   91.13 - *
   91.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   91.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   91.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   91.17 - * version 2 for more details (a copy is included in the LICENSE file that
   91.18 - * accompanied this code).
   91.19 - *
   91.20 - * You should have received a copy of the GNU General Public License version
   91.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   91.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   91.23 - *
   91.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   91.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   91.26 - * have any questions.
   91.27 - */
   91.28 -
   91.29 -/* fieldIDs for MMenuBarPeer fields that may be accessed from C */
   91.30 -struct MMenuBarPeerIDs {
   91.31 -  jfieldID pData;
   91.32 -  jfieldID graphicsConfig;
   91.33 -};
    92.1 --- a/src/solaris/native/sun/awt/awt_MenuComponent.c	Wed Sep 17 13:45:37 2008 -0700
    92.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.3 @@ -1,48 +0,0 @@
    92.4 -/*
    92.5 - * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
    92.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    92.7 - *
    92.8 - * This code is free software; you can redistribute it and/or modify it
    92.9 - * under the terms of the GNU General Public License version 2 only, as
   92.10 - * published by the Free Software Foundation.  Sun designates this
   92.11 - * particular file as subject to the "Classpath" exception as provided
   92.12 - * by Sun in the LICENSE file that accompanied this code.
   92.13 - *
   92.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   92.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   92.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   92.17 - * version 2 for more details (a copy is included in the LICENSE file that
   92.18 - * accompanied this code).
   92.19 - *
   92.20 - * You should have received a copy of the GNU General Public License version
   92.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   92.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   92.23 - *
   92.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   92.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   92.26 - * have any questions.
   92.27 - */
   92.28 -
   92.29 -#ifdef HEADLESS
   92.30 -    #error This file should not be included in headless library
   92.31 -#endif
   92.32 -
   92.33 -#include "java_awt_MenuComponent.h"
   92.34 -#include "jni_util.h"
   92.35 -
   92.36 -#include "awt_MenuComponent.h"
   92.37 -
   92.38 -struct MenuComponentIDs menuComponentIDs;
   92.39 -
   92.40 -
   92.41 -JNIEXPORT void JNICALL
   92.42 -Java_java_awt_MenuComponent_initIDs(JNIEnv *env, jclass cls)
   92.43 -{
   92.44 -    menuComponentIDs.font =
   92.45 -      (*env)->GetFieldID(env, cls, "font", "Ljava/awt/Font;");
   92.46 -    menuComponentIDs.appContext =
   92.47 -      (*env)->GetFieldID(env, cls, "appContext", "Lsun/awt/AppContext;");
   92.48 -    menuComponentIDs.getParent =
   92.49 -      (*env)->GetMethodID(
   92.50 -          env, cls, "getParent_NoClientCode", "()Ljava/awt/MenuContainer;");
   92.51 -}
    93.1 --- a/src/solaris/native/sun/awt/awt_MenuItem.c	Wed Sep 17 13:45:37 2008 -0700
    93.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.3 @@ -1,654 +0,0 @@
    93.4 -/*
    93.5 - * Copyright 1995-2004 Sun Microsystems, Inc.  All Rights Reserved.
    93.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    93.7 - *
    93.8 - * This code is free software; you can redistribute it and/or modify it
    93.9 - * under the terms of the GNU General Public License version 2 only, as
   93.10 - * published by the Free Software Foundation.  Sun designates this
   93.11 - * particular file as subject to the "Classpath" exception as provided
   93.12 - * by Sun in the LICENSE file that accompanied this code.
   93.13 - *
   93.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   93.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   93.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   93.17 - * version 2 for more details (a copy is included in the LICENSE file that
   93.18 - * accompanied this code).
   93.19 - *
   93.20 - * You should have received a copy of the GNU General Public License version
   93.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   93.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   93.23 - *
   93.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   93.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   93.26 - * have any questions.
   93.27 - */
   93.28 -
   93.29 -#ifdef HEADLESS
   93.30 -    #error This file should not be included in headless library
   93.31 -#endif
   93.32 -
   93.33 -#include "awt_p.h"
   93.34 -#include <Xm/Separator.h>
   93.35 -#include "java_awt_MenuItem.h"
   93.36 -#include "sun_awt_motif_MMenuItemPeer.h"
   93.37 -#include "sun_awt_motif_MCheckboxMenuItemPeer.h"
   93.38 -#include "java_awt_Menu.h"
   93.39 -#include "sun_awt_motif_MMenuPeer.h"
   93.40 -
   93.41 -#include "awt_MenuComponent.h"
   93.42 -#include "awt_MenuItem.h"
   93.43 -
   93.44 -#include "multi_font.h"
   93.45 -#include <jni.h>
   93.46 -#include <jni_util.h>
   93.47 -#include <jlong.h>
   93.48 -
   93.49 -extern struct MenuComponentIDs menuComponentIDs;
   93.50 -
   93.51 -/* fieldIDs for MenuItem fields that may be accessed from C */
   93.52 -struct MenuItemIDs menuItemIDs;
   93.53 -
   93.54 -/*
   93.55 - * Class:     java_awt_MenuItem
   93.56 - * Method:    initIDs
   93.57 - * Signature: ()V
   93.58 - */
   93.59 -
   93.60 -/* This function gets called from the static initializer for
   93.61 -   MenuItem.java to initialize the fieldIDs for fields that may
   93.62 -   be accessed from C */
   93.63 -
   93.64 -JNIEXPORT void JNICALL Java_java_awt_MenuItem_initIDs
   93.65 -  (JNIEnv *env, jclass cls)
   93.66 -{
   93.67 -    menuItemIDs.label =
   93.68 -      (*env)->GetFieldID(env, cls, "label", "Ljava/lang/String;");
   93.69 -    menuItemIDs.enabled =
   93.70 -      (*env)->GetFieldID(env, cls, "enabled", "Z");
   93.71 -    menuItemIDs.shortcut =
   93.72 -      (*env)->GetFieldID(env, cls, "shortcut", "Ljava/awt/MenuShortcut;");
   93.73 -}
   93.74 -
   93.75 -/* fieldIDs for MMenuItemPeer fields that may be accessed from C */
   93.76 -struct MMenuItemPeerIDs mMenuItemPeerIDs;
   93.77 -
   93.78 -/*
   93.79 - * Class:     sun_awt_motif_MMenuItemPeer
   93.80 - * Method:    initIDs
   93.81 - * Signature: ()V
   93.82 - */
   93.83 -
   93.84 -/* This function gets called from the static initializer for
   93.85 -   MMenuItemPeer.java to initialize the fieldIDs for fields that may
   93.86 -   be accessed from C */
   93.87 -
   93.88 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuItemPeer_initIDs
   93.89 -  (JNIEnv *env, jclass cls)
   93.90 -{
   93.91 -    mMenuItemPeerIDs.target =
   93.92 -      (*env)->GetFieldID(env, cls, "target", "Ljava/awt/MenuItem;");
   93.93 -    mMenuItemPeerIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J");
   93.94 -    mMenuItemPeerIDs.isCheckbox =
   93.95 -      (*env)->GetFieldID(env, cls, "isCheckbox", "Z");
   93.96 -    mMenuItemPeerIDs.jniGlobalRef =
   93.97 -      (*env)->GetFieldID(env, cls, "jniGlobalRef", "J");
   93.98 -}
   93.99 -
  93.100 -/*
  93.101 - * Class:     sun_awt_motif_MMenuItemPeer
  93.102 - * Method:    getParent_NoClientCode
  93.103 - * Signature: (Ljava/awt/MenuComponent;)Ljava/awt/MenuContainer;
  93.104 - *
  93.105 - * Gets the MenuContainer parent of this object, without executing client
  93.106 - * code (e.g., no code in subclasses will be executed).
  93.107 - */
  93.108 -JNIEXPORT jobject JNICALL Java_sun_awt_motif_MMenuItemPeer_getParent_1NoClientCode
  93.109 -  (JNIEnv *env, jclass thisClass, jobject menuComponent)
  93.110 -{
  93.111 -    jobject parent = NULL;
  93.112 -
  93.113 -    /* getParent is actually getParent_NoClientCode() */
  93.114 -    parent = (*env)->CallObjectMethod(
  93.115 -                        env,menuComponent,menuComponentIDs.getParent);
  93.116 -    DASSERT(!((*env)->ExceptionOccurred(env)));
  93.117 -    return parent;
  93.118 -}
  93.119 -
  93.120 -/*
  93.121 - *  client_data is MMenuItemPeer instance pointer
  93.122 - */
  93.123 -static void
  93.124 -MenuItem_selected(Widget w, XtPointer client_data, XmAnyCallbackStruct * s)
  93.125 -{
  93.126 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  93.127 -    jobject this = (jobject) client_data;
  93.128 -    ConvertEventTimeAndModifiers converted;
  93.129 -
  93.130 -    awt_util_convertEventTimeAndModifiers(s->event, &converted);
  93.131 -
  93.132 -    if ((*env)->GetBooleanField(env, this, mMenuItemPeerIDs.isCheckbox)) {
  93.133 -        jboolean state;
  93.134 -        struct MenuItemData *mdata;
  93.135 -
  93.136 -        mdata = (struct MenuItemData *)
  93.137 -          JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  93.138 -
  93.139 -        if (mdata != NULL) {
  93.140 -            XtVaGetValues(mdata->comp.widget, XmNset, &state, NULL);
  93.141 -
  93.142 -            JNU_CallMethodByName(env, NULL, this
  93.143 -                                 ,"action"
  93.144 -                                 ,"(JIZ)V"
  93.145 -                                 ,converted.when, converted.modifiers,
  93.146 -                                 state);
  93.147 -            if ((*env)->ExceptionOccurred(env)) {
  93.148 -                (*env)->ExceptionDescribe(env);
  93.149 -                (*env)->ExceptionClear(env);
  93.150 -            }
  93.151 -        }
  93.152 -    } else {
  93.153 -        JNU_CallMethodByName(env, NULL, this, "action", "(JI)V",
  93.154 -                             converted.when, converted.modifiers);
  93.155 -        if ((*env)->ExceptionOccurred(env)) {
  93.156 -            (*env)->ExceptionDescribe(env);
  93.157 -            (*env)->ExceptionClear(env);
  93.158 -        }
  93.159 -    }
  93.160 -}
  93.161 -
  93.162 -/*
  93.163 - * Class:     sun_awt_motif_MMenuItemPeer
  93.164 - * Method:    createMenuItem
  93.165 - * Signature: (Lsun/awt/motif/MMenuPeer;)V
  93.166 - *
  93.167 - * ASSUMES: This function is never called by a privileged thread
  93.168 - */
  93.169 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuItemPeer_createMenuItem(
  93.170 -JNIEnv *env, jobject this, jobject parent)
  93.171 -{
  93.172 -    int32_t argc;
  93.173 -#define MAX_ARGC 20
  93.174 -    Arg args[MAX_ARGC];
  93.175 -    char *clabel;
  93.176 -    struct MenuData *menuData;
  93.177 -    struct MenuItemData *mdata;
  93.178 -    struct FontData *fdata;
  93.179 -    Pixel bg;
  93.180 -    Pixel fg;
  93.181 -    XmFontList fontlist = NULL;
  93.182 -    jobject target;
  93.183 -    jobject targetFont;
  93.184 -    XmString mfstr = NULL;
  93.185 -    XmString shortcut_str = NULL;
  93.186 -    XmString str = NULL;
  93.187 -    jobject font;
  93.188 -    jobject shortcut;
  93.189 -    jboolean IsMultiFont;
  93.190 -    jboolean isCheckbox;
  93.191 -    jstring label;
  93.192 -    jobject globalRef = (*env)->NewGlobalRef(env, this);
  93.193 -    const jchar *unicodeLabel = NULL;
  93.194 -    jsize unicodeLabelLen = 0;
  93.195 -    jboolean isCopy = JNI_FALSE;
  93.196 -
  93.197 -    // We call client code on this thread, so it must *NOT* be privileged
  93.198 -    DASSERT(!awt_currentThreadIsPrivileged(env));
  93.199 -
  93.200 -    JNU_SetLongFieldFromPtr(env, this, mMenuItemPeerIDs.jniGlobalRef,
  93.201 -                            globalRef);
  93.202 -
  93.203 -    fdata = NULL;
  93.204 -
  93.205 -    fflush(stderr);
  93.206 -    target =
  93.207 -      (*env)->GetObjectField(env, this, mMenuItemPeerIDs.target);
  93.208 -    if (JNU_IsNull(env, target)) {
  93.209 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  93.210 -        return;
  93.211 -    }
  93.212 -    font = JNU_CallMethodByName(env, NULL, target, "getFont_NoClientCode",
  93.213 -                                "()Ljava/awt/Font;").l;
  93.214 -
  93.215 -    if (JNU_IsNull(env, parent)) {
  93.216 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  93.217 -        return;
  93.218 -    }
  93.219 -    AWT_LOCK();
  93.220 -    menuData = (struct MenuData *)
  93.221 -      JNU_GetLongFieldAsPtr(env, parent, mMenuItemPeerIDs.pData);
  93.222 -
  93.223 -    targetFont =
  93.224 -      (*env)->GetObjectField(env, target, menuComponentIDs.font);
  93.225 -    if (!JNU_IsNull(env, targetFont) &&
  93.226 -        (fdata = awtJNI_GetFontData(env, targetFont, NULL)) != NULL) {
  93.227 -        IsMultiFont = awtJNI_IsMultiFont(env, targetFont);
  93.228 -    } else {
  93.229 -        IsMultiFont = awtJNI_IsMultiFont(env, font);
  93.230 -    }
  93.231 -
  93.232 -    label = (*env)->GetObjectField(env, target, menuItemIDs.label);
  93.233 -    if (JNU_IsNull(env, label) || ((*env)->GetStringLength (env, label) == 0)) {
  93.234 -        mfstr = XmStringCreateLocalized("");
  93.235 -        clabel = "";
  93.236 -    } else {
  93.237 -        if (IsMultiFont) {
  93.238 -            mfstr = awtJNI_MakeMultiFontString(env, label, font);
  93.239 -        } else {
  93.240 -            mfstr = XmStringCreateLocalized("");
  93.241 -        }
  93.242 -        clabel = (char *) JNU_GetStringPlatformChars(env, label, NULL);
  93.243 -    }
  93.244 -
  93.245 -    mdata = ZALLOC(MenuItemData);
  93.246 -    JNU_SetLongFieldFromPtr(env, this, mMenuItemPeerIDs.pData, mdata);
  93.247 -
  93.248 -    argc = 0;
  93.249 -    XtSetArg(args[argc], XmNbackground, &bg);
  93.250 -    argc++;
  93.251 -    XtSetArg(args[argc], XmNforeground, &fg);
  93.252 -    argc++;
  93.253 -    XtGetValues(menuData->itemData.comp.widget, args, argc);
  93.254 -
  93.255 -    argc = 0;
  93.256 -    XtSetArg(args[argc], XmNbackground, bg);
  93.257 -    argc++;
  93.258 -    XtSetArg(args[argc], XmNforeground, fg);
  93.259 -    argc++;
  93.260 -
  93.261 -    /* check if the label is "-" but don't use strcmp(clabel, "-") because
  93.262 -     * the high-order bytes in the unicode characters are not present in
  93.263 -     * the C string (bugid 4099695)
  93.264 -     */
  93.265 -    if (!JNU_IsNull(env, label)) {
  93.266 -        unicodeLabel = (*env)->GetStringChars(env, label, &isCopy);
  93.267 -        unicodeLabelLen = (*env)->GetStringLength(env, label);
  93.268 -    }
  93.269 -    if ((unicodeLabel != NULL) && (unicodeLabel[0] == '-') &&
  93.270 -        (unicodeLabelLen == 1)) {
  93.271 -        DASSERT(!(argc > MAX_ARGC));
  93.272 -        mdata->comp.widget = XmCreateSeparator(menuData->itemData.comp.widget,
  93.273 -                                               "", args, argc);
  93.274 -    } else {
  93.275 -        if (IsMultiFont) {
  93.276 -            XtSetArg(args[argc], XmNlabelString, mfstr);
  93.277 -        } else {
  93.278 -            str = XmStringCreate(clabel, XmSTRING_DEFAULT_CHARSET);
  93.279 -            XtSetArg(args[argc], XmNlabelString, str);
  93.280 -        }
  93.281 -        argc++;
  93.282 -
  93.283 -        shortcut =
  93.284 -          (*env)->GetObjectField(env, target, menuItemIDs.shortcut);
  93.285 -        if (!JNU_IsNull(env, shortcut)) {
  93.286 -            jstring shortcutText;
  93.287 -            char *text = "";
  93.288 -
  93.289 -            shortcutText = JNU_CallMethodByName(env, NULL, shortcut,
  93.290 -                                                "toString",
  93.291 -                                                "()Ljava/lang/String;").l;
  93.292 -
  93.293 -            if (!JNU_IsNull(env, shortcutText)) {
  93.294 -                text = (char *) JNU_GetStringPlatformChars(env, shortcutText, NULL);
  93.295 -            }
  93.296 -            shortcut_str = XmStringCreate(text, XmSTRING_DEFAULT_CHARSET);
  93.297 -            XtSetArg(args[argc], XmNacceleratorText, shortcut_str);
  93.298 -
  93.299 -            argc++;
  93.300 -
  93.301 -            if (!JNU_IsNull(env, shortcutText)) {
  93.302 -                JNU_ReleaseStringPlatformChars(env, shortcutText, (const char *) text);
  93.303 -            }
  93.304 -        }
  93.305 -        if (!JNU_IsNull(env, targetFont) && (fdata != NULL)) {
  93.306 -            if (IsMultiFont) {
  93.307 -                fontlist = awtJNI_GetFontList(env, targetFont);
  93.308 -            } else {
  93.309 -                fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  93.310 -            }
  93.311 -            XtSetArg(args[argc], XmNfontList, fontlist);
  93.312 -            argc++;
  93.313 -        } else {
  93.314 -            if (IsMultiFont) {
  93.315 -                fontlist = awtJNI_GetFontList(env, font);
  93.316 -                XtSetArg(args[argc], XmNfontList, fontlist);
  93.317 -                argc++;
  93.318 -            }
  93.319 -        }
  93.320 -
  93.321 -        isCheckbox =
  93.322 -          (*env)->GetBooleanField(env, this, mMenuItemPeerIDs.isCheckbox);
  93.323 -        if (isCheckbox) {
  93.324 -            /* Fix for 4090493 */
  93.325 -            if (IsMultiFont) {
  93.326 -                /* FontData that correspond to XmNfontList we just set */
  93.327 -                struct FontData *fdataForIndSize;
  93.328 -                Dimension indSize;
  93.329 -                if (!JNU_IsNull(env, targetFont) && (fdata != NULL)) {
  93.330 -                    fdataForIndSize = fdata;
  93.331 -                }
  93.332 -                else {
  93.333 -                fdataForIndSize = awtJNI_GetFontData(env, font, NULL);
  93.334 -                }
  93.335 -                indSize = awt_adjustIndicatorSizeForMenu(awt_computeIndicatorSize(fdataForIndSize));
  93.336 -                if (indSize != MOTIF_XmINVALID_DIMENSION) {
  93.337 -                    XtSetArg(args[argc], XmNindicatorSize, indSize); argc++;
  93.338 -                }
  93.339 -            }
  93.340 -            /* End of fix for 4090493 */
  93.341 -            XtSetArg(args[argc], XmNset, False);
  93.342 -            argc++;
  93.343 -            XtSetArg(args[argc], XmNvisibleWhenOff, True);
  93.344 -            argc++;
  93.345 -
  93.346 -            DASSERT(!(argc > MAX_ARGC));
  93.347 -            mdata->comp.widget = XmCreateToggleButton(menuData->itemData.comp.widget,
  93.348 -                                                      clabel,
  93.349 -                                                      args,
  93.350 -                                                      argc);
  93.351 -        } else {
  93.352 -            DASSERT(!(argc > MAX_ARGC));
  93.353 -            mdata->comp.widget = XmCreatePushButton(menuData->itemData.comp.widget,
  93.354 -                                                    clabel,
  93.355 -                                                    args,
  93.356 -                                                    argc);
  93.357 -        }
  93.358 -        XtAddCallback(mdata->comp.widget,
  93.359 -                      ((isCheckbox) ? XmNvalueChangedCallback : XmNactivateCallback),
  93.360 -                      (XtCallbackProc) MenuItem_selected,
  93.361 -                      (XtPointer) globalRef);
  93.362 -
  93.363 -        XtSetSensitive(mdata->comp.widget,
  93.364 -          (*env)->GetBooleanField(env, target, menuItemIDs.enabled) ?
  93.365 -                       True : False);
  93.366 -
  93.367 -
  93.368 -        if (!JNU_IsNull(env, targetFont)) {
  93.369 -            XmFontListFree(fontlist);
  93.370 -        }
  93.371 -    }
  93.372 -
  93.373 -    if (clabel && (clabel != "")) {
  93.374 -        JNU_ReleaseStringPlatformChars(env, label, clabel);
  93.375 -    }
  93.376 -
  93.377 -    /*
  93.378 -     * Free up resources after we have created the widget
  93.379 -     */
  93.380 -    if (mfstr != NULL) {
  93.381 -      XmStringFree(mfstr);
  93.382 -      mfstr = NULL;
  93.383 -    }
  93.384 -    if (str) {
  93.385 -      XmStringFree(str);
  93.386 -      str = NULL;
  93.387 -    }
  93.388 -    if (shortcut_str) {
  93.389 -      XmStringFree(shortcut_str);
  93.390 -      shortcut_str = NULL;
  93.391 -    }
  93.392 -    if (isCopy == JNI_TRUE) {
  93.393 -        (*env)->ReleaseStringChars(env, label, unicodeLabel);
  93.394 -    }
  93.395 -
  93.396 -    XtManageChild(mdata->comp.widget);
  93.397 -    AWT_UNLOCK();
  93.398 -}
  93.399 -
  93.400 -/*
  93.401 - * Class:     sun_awt_motif_MMenuItemPeer
  93.402 - * Method:    pSetLabel
  93.403 - * Signature: (Ljava/lang/String;)V
  93.404 - */
  93.405 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuItemPeer_pSetLabel
  93.406 -(JNIEnv *env, jobject this, jstring label)
  93.407 -{
  93.408 -    struct ComponentData *wdata;
  93.409 -    char *clabel;
  93.410 -    XmString xim;
  93.411 -
  93.412 -    AWT_LOCK();
  93.413 -    wdata = (struct ComponentData *)
  93.414 -        JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  93.415 -    if (wdata == NULL) {
  93.416 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  93.417 -        AWT_UNLOCK();
  93.418 -        return;
  93.419 -    }
  93.420 -    if (JNU_IsNull(env, label) || ((*env)->GetStringLength (env, label) == 0)) {
  93.421 -        xim = XmStringCreateLocalized("");
  93.422 -    } else {
  93.423 -        jobject font;
  93.424 -        jobject target;
  93.425 -
  93.426 -        target = (*env)->GetObjectField(env, this, mMenuItemPeerIDs.target);
  93.427 -        if (JNU_IsNull(env, target)) {
  93.428 -            JNU_ThrowNullPointerException(env, "NullPointerException");
  93.429 -            AWT_UNLOCK();
  93.430 -            return;
  93.431 -        }
  93.432 -        font = JNU_CallMethodByName(env, NULL, target, "getFont_NoClientCode",
  93.433 -                                    "()Ljava/awt/Font;").l;
  93.434 -
  93.435 -        if (awtJNI_IsMultiFont(env, font)) {
  93.436 -            xim = awtJNI_MakeMultiFontString(env, label, font);
  93.437 -        } else {
  93.438 -            clabel = (char *) JNU_GetStringPlatformChars(env, label, NULL);
  93.439 -            xim = XmStringCreate(clabel, "labelFont");
  93.440 -            JNU_ReleaseStringPlatformChars(env, label, clabel);
  93.441 -        }
  93.442 -    }
  93.443 -    XtUnmanageChild(wdata->widget);
  93.444 -    XtVaSetValues(wdata->widget, XmNlabelString, xim, NULL);
  93.445 -    XtManageChild(wdata->widget);
  93.446 -    XmStringFree(xim);
  93.447 -    AWT_UNLOCK();
  93.448 -}
  93.449 -
  93.450 -
  93.451 -/*
  93.452 - * Class:     sun_awt_motif_MMenuItemPeer
  93.453 - * Method:    pSetShortCut
  93.454 - * Signature: (Ljava/lang/String;)V
  93.455 - */
  93.456 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuItemPeer_pSetShortcut
  93.457 -(JNIEnv *env, jobject this, jstring shortcut)
  93.458 -{
  93.459 -    struct ComponentData *wdata;
  93.460 -    char *cshortcut;
  93.461 -    XmString xim;
  93.462 -
  93.463 -
  93.464 -    AWT_LOCK();
  93.465 -    wdata = (struct ComponentData *)
  93.466 -        JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  93.467 -    if (wdata == NULL) {
  93.468 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  93.469 -        AWT_UNLOCK();
  93.470 -        return;
  93.471 -    }
  93.472 -    if (JNU_IsNull(env, shortcut)) {
  93.473 -        xim = XmStringCreateLocalized("");
  93.474 -    } else {
  93.475 -        jobject font;
  93.476 -        jobject target;
  93.477 -
  93.478 -        target = (*env)->GetObjectField(env, this, mMenuItemPeerIDs.target);
  93.479 -        if (JNU_IsNull(env, target)) {
  93.480 -            JNU_ThrowNullPointerException(env, "NullPointerException");
  93.481 -            AWT_UNLOCK();
  93.482 -            return;
  93.483 -        }
  93.484 -        font = JNU_CallMethodByName(env, NULL, target, "getFont_NoClientCode",
  93.485 -                                    "()Ljava/awt/Font;").l;
  93.486 -
  93.487 -        if (awtJNI_IsMultiFont(env, font)) {
  93.488 -            xim = awtJNI_MakeMultiFontString(env, shortcut, font);
  93.489 -        } else {
  93.490 -            cshortcut = (char *) JNU_GetStringPlatformChars(env, shortcut, NULL);
  93.491 -            xim = XmStringCreate(cshortcut, "labelFont");
  93.492 -            JNU_ReleaseStringPlatformChars(env, shortcut, cshortcut);
  93.493 -        }
  93.494 -    }
  93.495 -
  93.496 -    XtUnmanageChild(wdata->widget);
  93.497 -    XtVaSetValues(wdata->widget, XmNacceleratorText, xim, NULL);
  93.498 -    XtManageChild(wdata->widget);
  93.499 -    XmStringFree(xim);
  93.500 -    AWT_UNLOCK();
  93.501 -}
  93.502 -
  93.503 -
  93.504 -/*
  93.505 - * Class:     sun_awt_motif_MMenuItemPeer
  93.506 - * Method:    pEnable
  93.507 - * Signature: ()V
  93.508 - */
  93.509 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuItemPeer_pEnable
  93.510 -(JNIEnv *env, jobject this)
  93.511 -{
  93.512 -    struct MenuItemData *mdata;
  93.513 -
  93.514 -    AWT_LOCK();
  93.515 -
  93.516 -    mdata = (struct MenuItemData *)
  93.517 -        JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  93.518 -
  93.519 -    if (mdata == NULL) {
  93.520 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  93.521 -        AWT_UNLOCK();
  93.522 -        return;
  93.523 -    }
  93.524 -    XtSetSensitive(mdata->comp.widget, True);
  93.525 -    AWT_UNLOCK();
  93.526 -}
  93.527 -
  93.528 -/*
  93.529 - * Class:     sun_awt_motif_MMenuItemPeer
  93.530 - * Method:    pDisable
  93.531 - * Signature: ()V
  93.532 - */
  93.533 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuItemPeer_pDisable
  93.534 -(JNIEnv *env, jobject this)
  93.535 -{
  93.536 -    struct MenuItemData *mdata;
  93.537 -
  93.538 -    AWT_LOCK();
  93.539 -
  93.540 -    mdata = (struct MenuItemData *)
  93.541 -        JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  93.542 -
  93.543 -    if (mdata == NULL) {
  93.544 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  93.545 -        AWT_UNLOCK();
  93.546 -        return;
  93.547 -    }
  93.548 -    XtSetSensitive(mdata->comp.widget, False);
  93.549 -    AWT_UNLOCK();
  93.550 -}
  93.551 -
  93.552 -/*
  93.553 - * Class:     sun_awt_motif_MMenuItemPeer
  93.554 - * Method:    pDispose
  93.555 - * Signature: ()V
  93.556 - */
  93.557 -JNIEXPORT void JNICALL Java_sun_awt_motif_MMenuItemPeer_pDispose
  93.558 -(JNIEnv *env, jobject this)
  93.559 -{
  93.560 -    struct MenuItemData *mdata;
  93.561 -    Widget parent;
  93.562 -    Boolean isParentManaged = False;
  93.563 -
  93.564 -    AWT_LOCK();
  93.565 -
  93.566 -    mdata = (struct MenuItemData *)
  93.567 -        JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  93.568 -
  93.569 -    if (mdata != NULL) {
  93.570 -        /* Fix for 4280561:Workspace freezes, does not respond to mouse clicks
  93.571 -        **
  93.572 -        ** this really helps a lot of Fujitsu problems, take down a popup
  93.573 -        ** menu when removing items, on windows you could never get here, since
  93.574 -        ** the show() of a popup menu puts it in a menu loop where further
  93.575 -        ** events are processed in that loop, its like a modal dialog show,
  93.576 -        ** in that it dosn't return till it comes down.
  93.577 -        ** in X - future xevents will be dispatched immeadiatly, but some
  93.578 -        ** may be still waiting on the java queue - which can cause them to be
  93.579 -        ** dispatched out of order (sometimes hanging system !)
  93.580 -        */
  93.581 -        /* note: should realy only take down if XtParent(mdata->comp.widget)
  93.582 -        ** is the activePopup (in awt_PopupMenu.c) but ...
  93.583 -        */
  93.584 -        {
  93.585 -            removePopupMenus();
  93.586 -        }
  93.587 -        XtUnmanageChild(mdata->comp.widget);
  93.588 -        awt_util_consumeAllXEvents(mdata->comp.widget);
  93.589 -
  93.590 -        parent = XtParent(mdata->comp.widget);
  93.591 -        if (parent != NULL && XtIsManaged(parent)) {
  93.592 -            isParentManaged = True;
  93.593 -            XtUnmanageChild(parent);
  93.594 -        }
  93.595 -
  93.596 -        XtDestroyWidget(mdata->comp.widget);
  93.597 -
  93.598 -        if (isParentManaged) {
  93.599 -            XtManageChild(parent);
  93.600 -        }
  93.601 -
  93.602 -        free((void *) mdata);
  93.603 -        (*env)->SetLongField(env, this, mMenuItemPeerIDs.pData, (jlong)0);
  93.604 -        awtJNI_DeleteGlobalMenuRef(env, this);
  93.605 -    }
  93.606 -    AWT_UNLOCK();
  93.607 -}
  93.608 -
  93.609 -/*
  93.610 - * Class:     sun_awt_motif_MCheckboxMenuItemPeer
  93.611 - * Method:    pSetState
  93.612 - * Signature: (Z)V
  93.613 - */
  93.614 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCheckboxMenuItemPeer_pSetState
  93.615 -  (JNIEnv *env, jobject this, jboolean state)
  93.616 -{
  93.617 -    struct MenuItemData *mdata;
  93.618 -
  93.619 -    AWT_LOCK();
  93.620 -
  93.621 -    mdata = (struct MenuItemData *)
  93.622 -        JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  93.623 -
  93.624 -    if (mdata == NULL) {
  93.625 -        JNU_ThrowNullPointerException(env, "menuitem data is null");
  93.626 -        AWT_UNLOCK();
  93.627 -        return;
  93.628 -    }
  93.629 -    XtVaSetValues(mdata->comp.widget, XmNset, (Boolean)state, NULL);
  93.630 -    AWT_UNLOCK();
  93.631 -}
  93.632 -
  93.633 -/*
  93.634 - * Class:     sun_awt_motif_MCheckboxMenuItemPeer
  93.635 - * Method:    getState
  93.636 - * Signature: ()Z
  93.637 - */
  93.638 -JNIEXPORT jboolean JNICALL Java_sun_awt_motif_MCheckboxMenuItemPeer_getState
  93.639 -  (JNIEnv *env, jobject this)
  93.640 -{
  93.641 -    struct MenuItemData *mdata;
  93.642 -    Boolean             state;
  93.643 -
  93.644 -    AWT_LOCK();
  93.645 -
  93.646 -    mdata = (struct MenuItemData *)
  93.647 -      (*env)->GetLongField(env, this, mMenuItemPeerIDs.pData);
  93.648 -
  93.649 -    if (mdata == NULL) {
  93.650 -        JNU_ThrowNullPointerException(env, "menuitem data is null");
  93.651 -        AWT_UNLOCK();
  93.652 -        return JNI_FALSE;
  93.653 -    }
  93.654 -    XtVaGetValues(mdata->comp.widget, XmNset, &state, NULL);
  93.655 -    AWT_UNLOCK();
  93.656 -    return ((state) ? JNI_TRUE : JNI_FALSE);
  93.657 -}
    94.1 --- a/src/solaris/native/sun/awt/awt_PopupMenu.c	Wed Sep 17 13:45:37 2008 -0700
    94.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.3 @@ -1,491 +0,0 @@
    94.4 -/*
    94.5 - * Copyright 1996-2004 Sun Microsystems, Inc.  All Rights Reserved.
    94.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    94.7 - *
    94.8 - * This code is free software; you can redistribute it and/or modify it
    94.9 - * under the terms of the GNU General Public License version 2 only, as
   94.10 - * published by the Free Software Foundation.  Sun designates this
   94.11 - * particular file as subject to the "Classpath" exception as provided
   94.12 - * by Sun in the LICENSE file that accompanied this code.
   94.13 - *
   94.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   94.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   94.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   94.17 - * version 2 for more details (a copy is included in the LICENSE file that
   94.18 - * accompanied this code).
   94.19 - *
   94.20 - * You should have received a copy of the GNU General Public License version
   94.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   94.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   94.23 - *
   94.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   94.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   94.26 - * have any questions.
   94.27 - */
   94.28 -
   94.29 -#ifdef HEADLESS
   94.30 -    #error This file should not be included in headless library
   94.31 -#endif
   94.32 -
   94.33 -#include "awt_p.h"
   94.34 -#include <Xm/Separator.h>
   94.35 -#include <Xm/MenuShell.h>
   94.36 -#include <Xm/RowColumn.h>
   94.37 -#include "color.h"
   94.38 -#include "java_awt_PopupMenu.h"
   94.39 -#include "java_awt_Component.h"
   94.40 -#include "java_awt_Event.h"
   94.41 -#include "sun_awt_motif_MPopupMenuPeer.h"
   94.42 -#include "sun_awt_motif_MComponentPeer.h"
   94.43 -
   94.44 -#include "awt_PopupMenu.h"
   94.45 -#include "awt_MenuItem.h"
   94.46 -#include "awt_Component.h"
   94.47 -#include "awt_MenuComponent.h"
   94.48 -#include "awt_Menu.h"
   94.49 -#include "awt_Event.h"
   94.50 -
   94.51 -#include "multi_font.h"
   94.52 -#include <jni.h>
   94.53 -#include <jni_util.h>
   94.54 -
   94.55 -extern struct MMenuItemPeerIDs mMenuItemPeerIDs;
   94.56 -extern struct MComponentPeerIDs mComponentPeerIDs;
   94.57 -extern struct MenuComponentIDs menuComponentIDs;
   94.58 -extern struct MenuItemIDs menuItemIDs;
   94.59 -extern struct MenuIDs menuIDs;
   94.60 -extern AwtGraphicsConfigDataPtr
   94.61 -getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject parentPeer);
   94.62 -extern Boolean keyboardGrabbed;
   94.63 -Boolean poppingDown = False;
   94.64 -
   94.65 -struct MPopupMenuPeerIDs mPopupMenuPeerIDs;
   94.66 -
   94.67 -static Widget activePopup;
   94.68 -
   94.69 -void removePopupMenus() {
   94.70 -    if (activePopup != NULL &&
   94.71 -        XtIsManaged(activePopup))
   94.72 -    {
   94.73 -            XtUnmanageChild(activePopup);
   94.74 -            activePopup = NULL;
   94.75 -    }
   94.76 -}
   94.77 -
   94.78 -Boolean awtMenuIsActive() {
   94.79 -    return ((activePopup != NULL) || (awt_util_focusIsOnMenu(awt_display)));
   94.80 -}
   94.81 -
   94.82 -struct ClientDataStruct {
   94.83 -    struct ComponentData *wdata;
   94.84 -    jobject mMenuItemPeerIDs;
   94.85 -};
   94.86 -
   94.87 -/*
   94.88 - * Class:     sun_awt_motif_MPopupMenuPeer
   94.89 - * Method:    initIDs
   94.90 - * Signature: ()V
   94.91 - */
   94.92 -
   94.93 -/* This function gets called from the static initializer for
   94.94 -   MPopupMenuPeer.java to initialize the methodIDs for methods that may
   94.95 -   be accessed from C */
   94.96 -
   94.97 -JNIEXPORT void JNICALL Java_sun_awt_motif_MPopupMenuPeer_initIDs
   94.98 -  (JNIEnv *env, jclass cls)
   94.99 -{
  94.100 -    mPopupMenuPeerIDs.destroyNativeWidgetAfterGettingTreeLock =
  94.101 -        (*env)->GetMethodID(env, cls,
  94.102 -                            "destroyNativeWidgetAfterGettingTreeLock", "()V");
  94.103 -}
  94.104 -
  94.105 -extern Boolean skipNextNotifyWhileGrabbed;
  94.106 -
  94.107 -static void
  94.108 -Popup_popUpCB(Widget w, XtPointer client_data, XtPointer calldata)
  94.109 -{
  94.110 -    skipNextNotifyWhileGrabbed = True;
  94.111 -}
  94.112 -/*
  94.113 - * client_data is MPopupMenuPeer instance
  94.114 - */
  94.115 -static void
  94.116 -Popup_popdownCB(Widget w, XtPointer client_data, XtPointer calldata)
  94.117 -{
  94.118 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  94.119 -    jobject target = NULL;
  94.120 -
  94.121 -    /*
  94.122 -     * Fix for 4394847. Due to the race keyboard remains grabbed after menu
  94.123 -     * was disposed. Clear the grab status here instead of processOneEvent.
  94.124 -     */
  94.125 -    poppingDown = True;
  94.126 -    keyboardGrabbed = False;
  94.127 -    skipNextNotifyWhileGrabbed = True;
  94.128 -
  94.129 -    XtRemoveCallback(w, XtNpopdownCallback,
  94.130 -                     Popup_popdownCB, (XtPointer) client_data);
  94.131 -
  94.132 -    (*env)->CallVoidMethod(env, (jobject) client_data,
  94.133 -        mPopupMenuPeerIDs.destroyNativeWidgetAfterGettingTreeLock);
  94.134 -
  94.135 -    if ((*env)->ExceptionOccurred(env)) {
  94.136 -        (*env)->ExceptionDescribe(env);
  94.137 -        (*env)->ExceptionClear(env);
  94.138 -    }
  94.139 -}
  94.140 -
  94.141 -/*
  94.142 - * Class:     sun_awt_motif_MPopupMenuPeer
  94.143 - * Method:    createMenu
  94.144 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  94.145 - */
  94.146 -JNIEXPORT void JNICALL Java_sun_awt_motif_MPopupMenuPeer_createMenu
  94.147 -  (JNIEnv *env, jobject this, jobject parent)
  94.148 -{
  94.149 -    struct ComponentData *wdata;
  94.150 -    struct MenuData *mdata;
  94.151 -    struct FontData *fdata;
  94.152 -    char *ctitle = NULL;
  94.153 -    int32_t argc;
  94.154 -#define MAX_ARGC 10
  94.155 -    Arg args[MAX_ARGC];
  94.156 -    Pixel bg;
  94.157 -    Pixel fg;
  94.158 -    XmFontList fontlist = NULL;
  94.159 -    XmString mfstr = NULL;
  94.160 -    jobject font;
  94.161 -    jobject target;
  94.162 -    jobject targetFont;
  94.163 -    jobject label;
  94.164 -    jboolean IsMultiFont;
  94.165 -    jboolean tearOff;
  94.166 -    jobject globalRef = (*env)->NewGlobalRef(env, this);
  94.167 -    AwtGraphicsConfigDataPtr adata;
  94.168 -
  94.169 -    JNU_SetLongFieldFromPtr(env, this,
  94.170 -                            mMenuItemPeerIDs.jniGlobalRef, globalRef);
  94.171 -
  94.172 -
  94.173 -    AWT_LOCK();
  94.174 -
  94.175 -    if (JNU_IsNull(env, parent)) {
  94.176 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  94.177 -        AWT_UNLOCK();
  94.178 -        return;
  94.179 -    }
  94.180 -    target =
  94.181 -      (*env)->GetObjectField(env, this, mMenuItemPeerIDs.target);
  94.182 -    wdata = (struct ComponentData *)
  94.183 -      JNU_GetLongFieldAsPtr(env, parent, mComponentPeerIDs.pData);
  94.184 -
  94.185 -    if (wdata == NULL || JNU_IsNull(env, target)) {
  94.186 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  94.187 -        AWT_UNLOCK();
  94.188 -        return;
  94.189 -    }
  94.190 -    mdata = ZALLOC(MenuData);
  94.191 -    if (mdata == NULL) {
  94.192 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  94.193 -        AWT_UNLOCK();
  94.194 -        return;
  94.195 -    }
  94.196 -    JNU_SetLongFieldFromPtr(env, this, mMenuItemPeerIDs.pData, mdata);
  94.197 -
  94.198 -    adata = getGraphicsConfigFromComponentPeer(env, parent);
  94.199 -
  94.200 -    /*
  94.201 -     * Why are these different?
  94.202 -     */
  94.203 -    font = JNU_CallMethodByName(env, NULL, target, "getFont_NoClientCode",
  94.204 -                                "()Ljava/awt/Font;").l;
  94.205 -    targetFont =
  94.206 -      (*env)->GetObjectField(env, target, menuComponentIDs.font);
  94.207 -    if (!JNU_IsNull(env, targetFont) &&
  94.208 -        (fdata = awtJNI_GetFontData(env, targetFont, NULL)) != NULL) {
  94.209 -        IsMultiFont = awtJNI_IsMultiFont(env, targetFont);
  94.210 -    } else {
  94.211 -        IsMultiFont = awtJNI_IsMultiFont(env, font);
  94.212 -    }
  94.213 -
  94.214 -    label = (*env)->GetObjectField(env, target, menuItemIDs.label);
  94.215 -    if (JNU_IsNull(env, label)) {
  94.216 -        mfstr = XmStringCreateLocalized("");
  94.217 -        ctitle = "";
  94.218 -    } else {
  94.219 -        if (IsMultiFont) {
  94.220 -            mfstr = awtJNI_MakeMultiFontString(env, label, font);
  94.221 -        } else {
  94.222 -            ctitle = (char *) JNU_GetStringPlatformChars(env, label, NULL);
  94.223 -        }
  94.224 -    }
  94.225 -
  94.226 -    XtVaGetValues(wdata->widget, XmNbackground, &bg, NULL);
  94.227 -    XtVaGetValues(wdata->widget, XmNforeground, &fg, NULL);
  94.228 -
  94.229 -    argc = 0;
  94.230 -    XtSetArg(args[argc], XmNbackground, bg);
  94.231 -    argc++;
  94.232 -    XtSetArg(args[argc], XmNforeground, fg);
  94.233 -    argc++;
  94.234 -    tearOff = (*env)->GetBooleanField(env, target, menuIDs.tearOff);
  94.235 -    if (tearOff) {
  94.236 -        XtSetArg(args[argc], XmNtearOffModel, XmTEAR_OFF_ENABLED);
  94.237 -        argc++;
  94.238 -    }
  94.239 -    if (!JNU_IsNull(env, targetFont)
  94.240 -        && (fdata = awtJNI_GetFontData(env, targetFont, NULL)) != NULL) {
  94.241 -        if (IsMultiFont) {
  94.242 -            fontlist = awtJNI_GetFontList(env, targetFont);
  94.243 -        } else {
  94.244 -            fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  94.245 -        }
  94.246 -
  94.247 -        XtSetArg(args[argc], XmNfontList, fontlist);
  94.248 -        argc++;
  94.249 -    } else {
  94.250 -        if (IsMultiFont) {
  94.251 -            fontlist = awtJNI_GetFontList(env, font);
  94.252 -            XtSetArg(args[argc], XmNfontList, fontlist);
  94.253 -            argc++;
  94.254 -        }
  94.255 -    }
  94.256 -
  94.257 -    XtSetArg(args[argc], XmNvisual, adata->awt_visInfo.visual);
  94.258 -    argc++;
  94.259 -    XtSetArg (args[argc], XmNscreen,
  94.260 -              ScreenOfDisplay(awt_display,
  94.261 -                              adata->awt_visInfo.screen));
  94.262 -    argc++;
  94.263 -
  94.264 -    if (IsMultiFont) {
  94.265 -        DASSERT(!(argc > MAX_ARGC));
  94.266 -        mdata->itemData.comp.widget = XmCreatePopupMenu(wdata->widget,
  94.267 -                                                        "",
  94.268 -                                                        args,
  94.269 -                                                        argc);
  94.270 -    } else {
  94.271 -        DASSERT(!(argc > MAX_ARGC));
  94.272 -        mdata->itemData.comp.widget = XmCreatePopupMenu(wdata->widget,
  94.273 -                                                        ctitle,
  94.274 -                                                        args,
  94.275 -                                                        argc);
  94.276 -    }
  94.277 -    awt_addMenuWidget(mdata->itemData.comp.widget);
  94.278 -
  94.279 -    /*
  94.280 -     * Fix for bug 4180147 -
  94.281 -     * screen can be frozen when interacting with MB3 using AWT on Motif
  94.282 -     */
  94.283 -    XtUngrabButton(wdata->widget, AnyButton, AnyModifier);
  94.284 -    XtUngrabPointer(wdata->widget, CurrentTime);
  94.285 -
  94.286 -    /* fix for bug #4169155: Popup menus get a leading separator on Motif
  94.287 -       system.
  94.288 -       Additional check that title string is not empty*/
  94.289 -    if (!JNU_IsNull(env, label) &&
  94.290 -        (*env)->GetStringUTFLength( env, label) != (jsize)0 ) {
  94.291 -        if (IsMultiFont) {
  94.292 -            XtVaCreateManagedWidget("",
  94.293 -                                    xmLabelWidgetClass,
  94.294 -                                    mdata->itemData.comp.widget,
  94.295 -                                    XmNfontList, fontlist,
  94.296 -                                    XmNlabelString, mfstr,
  94.297 -                                    XmNbackground, bg,
  94.298 -                                    XmNforeground, fg,
  94.299 -                                    XmNhighlightColor, fg,
  94.300 -                                    NULL);
  94.301 -            XmStringFree(mfstr);
  94.302 -        } else {
  94.303 -            XmString xmstr = XmStringCreateLocalized(ctitle);
  94.304 -
  94.305 -            XtVaCreateManagedWidget(ctitle,
  94.306 -                                    xmLabelWidgetClass,
  94.307 -                                    mdata->itemData.comp.widget,
  94.308 -                                    XmNlabelString, xmstr,
  94.309 -                                    XmNbackground, bg,
  94.310 -                                    XmNforeground, fg,
  94.311 -                                    XmNhighlightColor, fg,
  94.312 -                                    NULL);
  94.313 -            XmStringFree(xmstr);
  94.314 -            JNU_ReleaseStringPlatformChars(env, label, (const char *) ctitle);
  94.315 -        }
  94.316 -        /* Create separator */
  94.317 -        XtVaCreateManagedWidget("",
  94.318 -                                xmSeparatorWidgetClass,
  94.319 -                                mdata->itemData.comp.widget,
  94.320 -                                XmNbackground, bg,
  94.321 -                                XmNforeground, fg,
  94.322 -                                NULL);
  94.323 -    }
  94.324 -    if (tearOff) {
  94.325 -        Widget tearOffWidget = XmGetTearOffControl(mdata->itemData.comp.widget);
  94.326 -
  94.327 -        XtVaSetValues(tearOffWidget,
  94.328 -                      XmNbackground, bg,
  94.329 -                      XmNforeground, fg,
  94.330 -                      XmNhighlightColor, fg,
  94.331 -                      NULL);
  94.332 -    }
  94.333 -    mdata->comp.widget = mdata->itemData.comp.widget;
  94.334 -
  94.335 -    if (!JNU_IsNull(env, targetFont)) {
  94.336 -        XmFontListFree(fontlist);
  94.337 -    }
  94.338 -    XtSetSensitive(mdata->comp.widget,
  94.339 -      ((*env)->GetBooleanField(env, target, menuItemIDs.enabled) ?
  94.340 -       True : False));
  94.341 -
  94.342 -    AWT_UNLOCK();
  94.343 -}
  94.344 -
  94.345 -/*
  94.346 - * Class:     sun_awt_motif_MPopupMenuPeer
  94.347 - * Method:    pShow
  94.348 - * Signature: (Ljava/awt/Event;IILsun/awt/motif/MComponentPeer;)V
  94.349 - */
  94.350 -JNIEXPORT void JNICALL Java_sun_awt_motif_MPopupMenuPeer_pShow
  94.351 -  (JNIEnv *env, jobject this, jobject event, jint x, jint y, jobject origin)
  94.352 -{
  94.353 -    struct MenuData *mdata;
  94.354 -    struct ComponentData *wdata;
  94.355 -    XButtonEvent *bevent;
  94.356 -    XButtonEvent *newEvent = NULL;
  94.357 -    void *data;
  94.358 -
  94.359 -    AWT_LOCK();
  94.360 -
  94.361 -    mdata = (struct MenuData *)
  94.362 -      JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  94.363 -    if (mdata == NULL || JNU_IsNull(env, event)) {
  94.364 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  94.365 -        AWT_UNLOCK();
  94.366 -        return;
  94.367 -    }
  94.368 -
  94.369 -    wdata = (struct ComponentData *)
  94.370 -        JNU_GetLongFieldAsPtr(env, origin, mComponentPeerIDs.pData);
  94.371 -
  94.372 -    if ( wdata == NULL || wdata->widget == NULL ) { /* 425598 */
  94.373 -        JNU_ThrowNullPointerException(env, "NullPointerException"); /* 425598 */
  94.374 -        AWT_UNLOCK(); /* 425598 */
  94.375 -        return; /* 425598 */
  94.376 -    } /* 425598 */
  94.377 -
  94.378 -    if (!XtIsRealized(wdata->widget)) {
  94.379 -        JNU_ThrowInternalError(env, "widget not visible on screen");
  94.380 -        AWT_UNLOCK();
  94.381 -        return;
  94.382 -    }
  94.383 -
  94.384 -    /*
  94.385 -     * Fix for BugTraq ID 4186663 - Pural PopupMenus appear at the same time.
  94.386 -     * If another popup is currently visible hide it.
  94.387 -     */
  94.388 -    if (activePopup != NULL &&
  94.389 -        activePopup != mdata->comp.widget &&
  94.390 -        XtIsObject(activePopup) &&
  94.391 -        XtIsManaged(activePopup)) {
  94.392 -            removePopupMenus();
  94.393 -    }
  94.394 -
  94.395 -    /* If the raw x event is not available, then we must use an unfortunate
  94.396 -     * round-trip call to XTranslateCoordiates to get the root coordinates.
  94.397 -     */
  94.398 -    data = JNU_GetLongFieldAsPtr(env, event, eventIDs.data);
  94.399 -    if (data == NULL || ((XEvent *) data)->type != ButtonPress) {
  94.400 -        int32_t rx, ry;
  94.401 -        Window root, win;
  94.402 -
  94.403 -        root = RootWindowOfScreen(XtScreen(wdata->widget));
  94.404 -        XTranslateCoordinates(awt_display,
  94.405 -                              XtWindow(wdata->widget),
  94.406 -                              root,
  94.407 -                              (int32_t) x, (int32_t) y,
  94.408 -                              &rx, &ry,
  94.409 -                              &win);
  94.410 -        /*
  94.411 -                printf("translated coords %d,%d to root %d,%d\n", x, y, rx, ry);
  94.412 -        */
  94.413 -
  94.414 -        newEvent = (XButtonEvent *) malloc(sizeof(XButtonEvent));
  94.415 -        newEvent->type = ButtonPress;
  94.416 -        newEvent->display = awt_display;
  94.417 -        newEvent->window = XtWindow(wdata->widget);
  94.418 -        newEvent->time = awt_util_getCurrentServerTime();
  94.419 -        newEvent->x = (int32_t) x;
  94.420 -        newEvent->y = (int32_t) y;
  94.421 -        newEvent->x_root = rx;
  94.422 -        newEvent->y_root = ry;
  94.423 -        bevent = newEvent;
  94.424 -
  94.425 -    } else {
  94.426 -        bevent = (XButtonEvent *) data;
  94.427 -    }
  94.428 -
  94.429 -    XtAddCallback(XtParent(mdata->comp.widget), XtNpopdownCallback,
  94.430 -                  Popup_popdownCB,
  94.431 -                  (XtPointer)
  94.432 -                  JNU_GetLongFieldAsPtr(env, this,
  94.433 -                                        mMenuItemPeerIDs.jniGlobalRef));
  94.434 -
  94.435 -    XtAddCallback(XtParent(mdata->comp.widget), XtNpopupCallback,
  94.436 -                  Popup_popUpCB,
  94.437 -                  (XtPointer)
  94.438 -                  JNU_GetLongFieldAsPtr(env, this,
  94.439 -                                        mMenuItemPeerIDs.jniGlobalRef));
  94.440 -
  94.441 -
  94.442 -    XmMenuPosition(mdata->comp.widget, bevent);
  94.443 -    XtManageChild(mdata->comp.widget);
  94.444 -
  94.445 -    /*
  94.446 -     * Fix for BugTraq ID 4186663 - Pural PopupMenus appear at the same time.
  94.447 -     * Store the pointer to the currently showing popup.
  94.448 -     */
  94.449 -    activePopup = mdata->comp.widget;
  94.450 -
  94.451 -    if (newEvent) {
  94.452 -        free((void *) newEvent);
  94.453 -    }
  94.454 -    AWT_UNLOCK();
  94.455 -}
  94.456 -
  94.457 -/*
  94.458 - * Class:     sun_awt_motif_MPopupMenuPeer
  94.459 - * Method:    pDispose
  94.460 - * Signature: ()V
  94.461 - */
  94.462 -JNIEXPORT void JNICALL Java_sun_awt_motif_MPopupMenuPeer_pDispose
  94.463 -  (JNIEnv *env, jobject this)
  94.464 -{
  94.465 -    struct MenuData *mdata;
  94.466 -
  94.467 -    AWT_LOCK();
  94.468 -
  94.469 -    mdata = (struct MenuData *)
  94.470 -      JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.pData);
  94.471 -
  94.472 -    if (mdata == NULL) {
  94.473 -        AWT_UNLOCK();
  94.474 -        return;
  94.475 -    }
  94.476 -    /*
  94.477 -     * Fix for BugTraq ID 4186663 - Pural PopupMenus appear at the same time.
  94.478 -     * Clear the pointer to the currently showing popup.
  94.479 -     */
  94.480 -    if (activePopup == mdata->comp.widget) {
  94.481 -        activePopup = NULL;
  94.482 -    }
  94.483 -    awt_delMenuWidget(mdata->itemData.comp.widget);
  94.484 -    XtUnmanageChild(mdata->comp.widget);
  94.485 -    awt_util_consumeAllXEvents(mdata->comp.widget);
  94.486 -    XtDestroyWidget(mdata->comp.widget);
  94.487 -    free((void *) mdata);
  94.488 -    (*env)->SetLongField(env, this, mMenuItemPeerIDs.pData, (jlong)0);
  94.489 -
  94.490 -    awtJNI_DeleteGlobalMenuRef(env, this);
  94.491 -
  94.492 -    poppingDown = False;
  94.493 -    AWT_UNLOCK();
  94.494 -}
    95.1 --- a/src/solaris/native/sun/awt/awt_Robot.c	Wed Sep 17 13:45:37 2008 -0700
    95.2 +++ b/src/solaris/native/sun/awt/awt_Robot.c	Fri Sep 19 19:38:12 2008 -0700
    95.3 @@ -204,14 +204,8 @@
    95.4  
    95.5  /*********************************************************************************************/
    95.6  
    95.7 -#ifdef XAWT
    95.8 -#define FUNC_NAME(name) Java_sun_awt_X11_XRobotPeer_ ## name
    95.9 -#else
   95.10 -#define FUNC_NAME(name) Java_sun_awt_motif_MRobotPeer_ ## name
   95.11 -#endif
   95.12 -
   95.13  JNIEXPORT void JNICALL
   95.14 -FUNC_NAME(setup) (JNIEnv * env, jclass cls) {
   95.15 +Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls) {
   95.16      int32_t xtestAvailable;
   95.17  
   95.18      DTRACE_PRINTLN("RobotPeer: setup()");
   95.19 @@ -232,7 +226,7 @@
   95.20  }
   95.21  
   95.22  JNIEXPORT void JNICALL
   95.23 -FUNC_NAME(getRGBPixelsImpl)( JNIEnv *env,
   95.24 +Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env,
   95.25                               jclass cls,
   95.26                               jobject xgc,
   95.27                               jint x,
   95.28 @@ -295,7 +289,7 @@
   95.29  }
   95.30  
   95.31  JNIEXPORT void JNICALL
   95.32 -FUNC_NAME(keyPressImpl) (JNIEnv *env,
   95.33 +Java_sun_awt_X11_XRobotPeer_keyPressImpl (JNIEnv *env,
   95.34                           jclass cls,
   95.35                           jint keycode) {
   95.36  
   95.37 @@ -315,7 +309,7 @@
   95.38  }
   95.39  
   95.40  JNIEXPORT void JNICALL
   95.41 -FUNC_NAME(keyReleaseImpl) (JNIEnv *env,
   95.42 +Java_sun_awt_X11_XRobotPeer_keyReleaseImpl (JNIEnv *env,
   95.43                             jclass cls,
   95.44                             jint keycode) {
   95.45      AWT_LOCK();
   95.46 @@ -333,7 +327,7 @@
   95.47  }
   95.48  
   95.49  JNIEXPORT void JNICALL
   95.50 -FUNC_NAME(mouseMoveImpl) (JNIEnv *env,
   95.51 +Java_sun_awt_X11_XRobotPeer_mouseMoveImpl (JNIEnv *env,
   95.52                            jclass cls,
   95.53                            jobject xgc,
   95.54                            jint root_x,
   95.55 @@ -355,7 +349,7 @@
   95.56  }
   95.57  
   95.58  JNIEXPORT void JNICALL
   95.59 -FUNC_NAME(mousePressImpl) (JNIEnv *env,
   95.60 +Java_sun_awt_X11_XRobotPeer_mousePressImpl (JNIEnv *env,
   95.61                             jclass cls,
   95.62                             jint buttonMask) {
   95.63      AWT_LOCK();
   95.64 @@ -379,7 +373,7 @@
   95.65  }
   95.66  
   95.67  JNIEXPORT void JNICALL
   95.68 -FUNC_NAME(mouseReleaseImpl) (JNIEnv *env,
   95.69 +Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl (JNIEnv *env,
   95.70                               jclass cls,
   95.71                               jint buttonMask) {
   95.72      AWT_LOCK();
   95.73 @@ -403,7 +397,7 @@
   95.74  }
   95.75  
   95.76  JNIEXPORT void JNICALL
   95.77 -FUNC_NAME(mouseWheelImpl) (JNIEnv *env,
   95.78 +Java_sun_awt_X11_XRobotPeer_mouseWheelImpl (JNIEnv *env,
   95.79                             jclass cls,
   95.80                             jint wheelAmt) {
   95.81  /* Mouse wheel is implemented as a button press of button 4 and 5, so it */
    96.1 --- a/src/solaris/native/sun/awt/awt_ScrollPane.c	Wed Sep 17 13:45:37 2008 -0700
    96.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.3 @@ -1,927 +0,0 @@
    96.4 -/*
    96.5 - * Copyright 1996-2002 Sun Microsystems, Inc.  All Rights Reserved.
    96.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    96.7 - *
    96.8 - * This code is free software; you can redistribute it and/or modify it
    96.9 - * under the terms of the GNU General Public License version 2 only, as
   96.10 - * published by the Free Software Foundation.  Sun designates this
   96.11 - * particular file as subject to the "Classpath" exception as provided
   96.12 - * by Sun in the LICENSE file that accompanied this code.
   96.13 - *
   96.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   96.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   96.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   96.17 - * version 2 for more details (a copy is included in the LICENSE file that
   96.18 - * accompanied this code).
   96.19 - *
   96.20 - * You should have received a copy of the GNU General Public License version
   96.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   96.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   96.23 - *
   96.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   96.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   96.26 - * have any questions.
   96.27 - */
   96.28 -
   96.29 -#ifdef HEADLESS
   96.30 -    #error This file should not be included in headless library
   96.31 -#endif
   96.32 -
   96.33 -#include "awt_p.h"
   96.34 -
   96.35 -#include "java_awt_Adjustable.h"
   96.36 -#include "java_awt_Insets.h"
   96.37 -#include "java_awt_ScrollPane.h"
   96.38 -#include "java_awt_event_AdjustmentEvent.h"
   96.39 -#include "sun_awt_motif_MComponentPeer.h"
   96.40 -#include "sun_awt_motif_MScrollPanePeer.h"
   96.41 -#include "java_awt_AWTEvent.h"
   96.42 -
   96.43 -#include "awt_Component.h"
   96.44 -#include "canvas.h"
   96.45 -
   96.46 -#include <jni.h>
   96.47 -#include <jni_util.h>
   96.48 -#include <Xm/ScrolledWP.h>
   96.49 -
   96.50 -extern struct MComponentPeerIDs mComponentPeerIDs;
   96.51 -extern AwtGraphicsConfigDataPtr
   96.52 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   96.53 -
   96.54 -/* fieldIDs for ScrollPane fields that may be accessed from C */
   96.55 -static struct ScrollPaneIDs {
   96.56 -    jfieldID scrollbarDisplayPolicy;
   96.57 -} scrollPaneIDs;
   96.58 -
   96.59 -/*
   96.60 - * Class:     java_awt_ScrollPane
   96.61 - * Method:    initIDs
   96.62 - * Signature: ()V
   96.63 - */
   96.64 -
   96.65 -/* This function gets called from the static initializer for
   96.66 -   ScrollPane.java to initialize the fieldIDs for fields that may
   96.67 -   be accessed from C */
   96.68 -
   96.69 -JNIEXPORT void JNICALL Java_java_awt_ScrollPane_initIDs
   96.70 -  (JNIEnv *env, jclass cls)
   96.71 -{
   96.72 -    scrollPaneIDs.scrollbarDisplayPolicy =
   96.73 -      (*env)->GetFieldID(env, cls, "scrollbarDisplayPolicy", "I");
   96.74 -}
   96.75 -
   96.76 -/* fieldIDs for MScrollPanePeer fields that may be accessed from C */
   96.77 -static struct MScrollPanePeerIDs {
   96.78 -    jmethodID postScrollEventID;
   96.79 -} mScrollPanePeerIDs;
   96.80 -
   96.81 -/*
   96.82 - * Class:     sun_awt_motif_MScrollPanePeer
   96.83 - * Method:    initIDs
   96.84 - * Signature: ()V
   96.85 - */
   96.86 -
   96.87 -/* This function gets called from the static initializer for
   96.88 -   MScrollPanePeer.java to initialize the fieldIDs for fields that may
   96.89 -   be accessed from C */
   96.90 -
   96.91 -JNIEXPORT void JNICALL Java_sun_awt_motif_MScrollPanePeer_initIDs
   96.92 -  (JNIEnv *env, jclass cls)
   96.93 -{
   96.94 -    mScrollPanePeerIDs.postScrollEventID =
   96.95 -        (*env)->GetMethodID(env, cls, "postScrollEvent", "(IIIZ)V");
   96.96 -}
   96.97 -
   96.98 -static void
   96.99 -dump_scroll_attrs(Widget scrollbar)
  96.100 -{
  96.101 -    unsigned char orient;
  96.102 -    int32_t value, size, incr, pIncr, max, min;
  96.103 -
  96.104 -    XtVaGetValues(scrollbar,
  96.105 -                  XmNvalue, &value,
  96.106 -                  XmNincrement, &incr,
  96.107 -                  XmNpageIncrement, &pIncr,
  96.108 -                  XmNsliderSize, &size,
  96.109 -                  XmNmaximum, &max,
  96.110 -                  XmNminimum, &min,
  96.111 -                  XmNorientation, &orient,
  96.112 -                  NULL);
  96.113 -
  96.114 -    jio_fprintf(stdout, "%s: min=%d max=%d slider-size=%d incr=%d pageIncr=%d value = %d\n",
  96.115 -                orient == XmVERTICAL ? "VSB" : "HSB", min, max, size,
  96.116 -                incr, pIncr, value);
  96.117 -}
  96.118 -
  96.119 -
  96.120 -/*
  96.121 - * client_data is MScrollPanePeer instance
  96.122 - */
  96.123 -static void
  96.124 -postScrollEvent(jint jorient, jobject peer, XmScrollBarCallbackStruct *scroll)
  96.125 -{
  96.126 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  96.127 -
  96.128 -    jint jscrollcode;
  96.129 -    jboolean jadjusting = JNI_FALSE;
  96.130 -
  96.131 -    switch (scroll->reason) {
  96.132 -      case XmCR_DECREMENT:
  96.133 -          jscrollcode = java_awt_event_AdjustmentEvent_UNIT_DECREMENT;
  96.134 -          break;
  96.135 -      case XmCR_INCREMENT:
  96.136 -          jscrollcode = java_awt_event_AdjustmentEvent_UNIT_INCREMENT;
  96.137 -          break;
  96.138 -      case XmCR_PAGE_DECREMENT:
  96.139 -          jscrollcode = java_awt_event_AdjustmentEvent_BLOCK_DECREMENT;
  96.140 -          break;
  96.141 -      case XmCR_PAGE_INCREMENT:
  96.142 -          jscrollcode = java_awt_event_AdjustmentEvent_BLOCK_INCREMENT;
  96.143 -          break;
  96.144 -      case XmCR_DRAG:
  96.145 -          jscrollcode = java_awt_event_AdjustmentEvent_TRACK;
  96.146 -          jadjusting = JNI_TRUE;
  96.147 -          break;
  96.148 -      case XmCR_VALUE_CHANGED:  /* drag finished */
  96.149 -      case XmCR_TO_TOP:
  96.150 -      case XmCR_TO_BOTTOM:
  96.151 -          jscrollcode = java_awt_event_AdjustmentEvent_TRACK;
  96.152 -          break;
  96.153 -      default:
  96.154 -          DASSERT(FALSE);
  96.155 -          return;
  96.156 -    }
  96.157 -
  96.158 -    (*env)->CallVoidMethod(env, peer,  mScrollPanePeerIDs.postScrollEventID,
  96.159 -        jorient, jscrollcode, (jint)scroll->value, jadjusting);
  96.160 -
  96.161 -    if ((*env)->ExceptionOccurred(env)) {
  96.162 -        (*env)->ExceptionDescribe(env);
  96.163 -        (*env)->ExceptionClear(env);
  96.164 -    }
  96.165 -}
  96.166 -
  96.167 -/*
  96.168 - * client_data is MScrollPanePeer instance
  96.169 - */
  96.170 -static void
  96.171 -ScrollPane_scrollV(Widget w, XtPointer client_data, XtPointer call_data)
  96.172 -{
  96.173 -    postScrollEvent(java_awt_Adjustable_VERTICAL, (jobject)client_data,
  96.174 -                    (XmScrollBarCallbackStruct *)call_data);
  96.175 -}
  96.176 -
  96.177 -/*
  96.178 - * client_data is MScrollPanePeer instance
  96.179 - */
  96.180 -static void
  96.181 -ScrollPane_scrollH(Widget w, XtPointer client_data, XtPointer call_data)
  96.182 -{
  96.183 -    postScrollEvent(java_awt_Adjustable_HORIZONTAL, (jobject)client_data,
  96.184 -                    (XmScrollBarCallbackStruct *)call_data);
  96.185 -}
  96.186 -
  96.187 -
  96.188 -typedef XmNavigability (*NavigableCallback) (Widget);
  96.189 -
  96.190 -NavigableCallback oldClipNavigable = NULL;
  96.191 -Boolean clipCallbackInitialized = False;
  96.192 -XmNavigability MyClipNavigable(Widget wid) {
  96.193 -    // We've installed this function for ClipWindow
  96.194 -    if (XmIsClipWindow(wid)) {
  96.195 -        // To be able to request focus on ClipWindow by call
  96.196 -        // XmProcessTraversal(, XmTRAVERSE_CURRENT) we need to make
  96.197 -        // it return XmCONTROL_NAVIGABLE. Default implementation returns
  96.198 -        // DESCENDANTS_TAB_NAVIGABLE which doesn't allow this.
  96.199 -        return XmCONTROL_NAVIGABLE;
  96.200 -    }
  96.201 -    if (oldClipNavigable) {
  96.202 -        return oldClipNavigable(wid);
  96.203 -    }
  96.204 -    // this will never happen
  96.205 -    return XmCONTROL_NAVIGABLE;
  96.206 -}
  96.207 -
  96.208 -const char * ScrollPaneManagerName = "ScrolledWindowClipWindow";
  96.209 -NavigableCallback oldManagerNavigable = NULL;
  96.210 -Boolean managerCallbackInitialized = False;
  96.211 -XmNavigability MyManagerNavigable(Widget wid) {
  96.212 -    // We've installed this function for Manager
  96.213 -    // with the name ScrollPaneManagerName
  96.214 -    if (XmIsManager(wid)
  96.215 -        && ( XtName(wid) != NULL && strcmp(XtName(wid), ScrollPaneManagerName) == 0) )
  96.216 -    {
  96.217 -        // To be able to request focus on Manager by call
  96.218 -        // XmProcessTraversal(, XmTRAVERSE_CURRENT) we need to make
  96.219 -        // it return XmCONTROL_NAVIGABLE. Default implementation returns
  96.220 -        // DESCENDANTS_TAB_NAVIGABLE which doesn't allow this.
  96.221 -        return XmCONTROL_NAVIGABLE;
  96.222 -    }
  96.223 -    if (oldManagerNavigable) {
  96.224 -        return oldManagerNavigable(wid);
  96.225 -    }
  96.226 -    // this will never happen
  96.227 -    return XmCONTROL_NAVIGABLE;
  96.228 -}
  96.229 -
  96.230 -/*
  96.231 - * Class:     sun_awt_motif_MScrollPanePeer
  96.232 - * Method:    create
  96.233 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  96.234 - */
  96.235 -JNIEXPORT void JNICALL Java_sun_awt_motif_MScrollPanePeer_create
  96.236 -  (JNIEnv *env, jobject this, jobject parent)
  96.237 -{
  96.238 -    int32_t argc;
  96.239 -#define MAX_ARGC 40
  96.240 -    Arg args[MAX_ARGC];
  96.241 -    struct ComponentData *wdata;
  96.242 -    struct ComponentData *sdata;
  96.243 -    jobject target;
  96.244 -    Pixel bg;
  96.245 -    Widget vsb, hsb;
  96.246 -    jint sbDisplay;
  96.247 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
  96.248 -    AwtGraphicsConfigDataPtr adata;
  96.249 -
  96.250 -    AWT_LOCK();
  96.251 -
  96.252 -    if (JNU_IsNull(env, parent)) {
  96.253 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  96.254 -        AWT_UNLOCK();
  96.255 -
  96.256 -        return;
  96.257 -    }
  96.258 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  96.259 -    wdata = (struct ComponentData *)
  96.260 -      JNU_GetLongFieldAsPtr(env,parent,mComponentPeerIDs.pData);
  96.261 -
  96.262 -    if (JNU_IsNull(env, target) || wdata == NULL) {
  96.263 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  96.264 -        AWT_UNLOCK();
  96.265 -
  96.266 -        return;
  96.267 -    }
  96.268 -    sdata = ZALLOC(ComponentData);
  96.269 -    JNU_SetLongFieldFromPtr(env,this,mComponentPeerIDs.pData,sdata);
  96.270 -
  96.271 -    if (sdata == NULL) {
  96.272 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  96.273 -        AWT_UNLOCK();
  96.274 -        return;
  96.275 -    }
  96.276 -    XtVaGetValues(wdata->widget, XmNbackground, &bg, NULL);
  96.277 -
  96.278 -    adata = copyGraphicsConfigToPeer(env, this);
  96.279 -
  96.280 -    argc = 0;
  96.281 -
  96.282 -    sbDisplay =
  96.283 -      (*env)->GetIntField(env, target, scrollPaneIDs.scrollbarDisplayPolicy);
  96.284 -
  96.285 -    XtSetArg(args[argc], XmNuserData, (XtPointer) globalRef);
  96.286 -    argc++;
  96.287 -
  96.288 -
  96.289 -    if (sbDisplay == java_awt_ScrollPane_SCROLLBARS_NEVER) {
  96.290 -        DASSERT(!(argc > MAX_ARGC));
  96.291 -        sdata->widget = XtCreateWidget(ScrollPaneManagerName,
  96.292 -                                       xmManagerWidgetClass, wdata->widget,
  96.293 -                                       args, argc);
  96.294 -
  96.295 -        {
  96.296 -            // To be able to request focus on Manager by call
  96.297 -            // XmProcessTraversal(, XmTRAVERSE_CURRENT) we need to make
  96.298 -            // it return XmCONTROL_NAVIGABLE from widgetNavigable callback.
  96.299 -            // Default implementation returns DESCENDANTS_TAB_NAVIGABLE
  96.300 -            // which doesn't allow this.
  96.301 -            if (!managerCallbackInitialized) {
  96.302 -                XmBaseClassExt *er;
  96.303 -                WidgetClass wc;
  96.304 -                managerCallbackInitialized = True;
  96.305 -                wc = (WidgetClass) &xmManagerClassRec;
  96.306 -                er = _XmGetBaseClassExtPtr(wc, XmQmotif);
  96.307 -                oldManagerNavigable = (*er)->widgetNavigable;
  96.308 -                (*er)->widgetNavigable = MyManagerNavigable;
  96.309 -            }
  96.310 -        }
  96.311 -    }
  96.312 -    else
  96.313 -    {
  96.314 -        XtSetArg(args[argc], XmNscrollingPolicy, XmAUTOMATIC);
  96.315 -        argc++;
  96.316 -        XtSetArg(args[argc], XmNvisualPolicy, XmCONSTANT);
  96.317 -        argc++;
  96.318 -        if (sbDisplay == java_awt_ScrollPane_SCROLLBARS_ALWAYS) {
  96.319 -            DASSERT(!(argc > MAX_ARGC));
  96.320 -            XtSetArg(args[argc], XmNscrollBarDisplayPolicy, XmSTATIC);
  96.321 -            argc++;
  96.322 -        } else {
  96.323 -            XtSetArg(args[argc], XmNscrollBarDisplayPolicy, XmAS_NEEDED);
  96.324 -            argc++;
  96.325 -        }
  96.326 -
  96.327 -        XtSetArg(args[argc], XmNspacing, 0);
  96.328 -        argc++;
  96.329 -        XtSetArg (args[argc], XmNscreen,
  96.330 -                  ScreenOfDisplay(awt_display,
  96.331 -                                  adata->awt_visInfo.screen));
  96.332 -        argc++;
  96.333 -
  96.334 -        DASSERT(!(argc > MAX_ARGC));
  96.335 -        sdata->widget = XmCreateScrolledWindow(wdata->widget, "scroller", args, argc);
  96.336 -
  96.337 -        XtVaGetValues(sdata->widget,
  96.338 -                      XmNverticalScrollBar, &vsb,
  96.339 -                      XmNhorizontalScrollBar, &hsb,
  96.340 -                      NULL);
  96.341 -
  96.342 -        if (vsb != NULL) {
  96.343 -            XtAddCallback(vsb, XmNincrementCallback, ScrollPane_scrollV, (XtPointer) globalRef);
  96.344 -            XtAddCallback(vsb, XmNdecrementCallback, ScrollPane_scrollV, (XtPointer) globalRef);
  96.345 -            XtAddCallback(vsb, XmNpageIncrementCallback, ScrollPane_scrollV, (XtPointer) globalRef);
  96.346 -            XtAddCallback(vsb, XmNpageDecrementCallback, ScrollPane_scrollV, (XtPointer) globalRef);
  96.347 -            XtAddCallback(vsb, XmNtoTopCallback, ScrollPane_scrollV, (XtPointer) globalRef);
  96.348 -            XtAddCallback(vsb, XmNtoBottomCallback, ScrollPane_scrollV, (XtPointer) globalRef);
  96.349 -            XtAddCallback(vsb, XmNvalueChangedCallback, ScrollPane_scrollV, (XtPointer) globalRef);
  96.350 -            XtAddCallback(vsb, XmNdragCallback, ScrollPane_scrollV, (XtPointer) globalRef);
  96.351 -
  96.352 -            XtVaSetValues(vsb, XmNhighlightThickness, 0, NULL);
  96.353 -        }
  96.354 -        if (hsb != NULL) {
  96.355 -            XtAddCallback(hsb, XmNincrementCallback, ScrollPane_scrollH, (XtPointer) globalRef);
  96.356 -            XtAddCallback(hsb, XmNdecrementCallback, ScrollPane_scrollH, (XtPointer) globalRef);
  96.357 -            XtAddCallback(hsb, XmNpageIncrementCallback, ScrollPane_scrollH, (XtPointer) globalRef);
  96.358 -            XtAddCallback(hsb, XmNpageDecrementCallback, ScrollPane_scrollH, (XtPointer) globalRef);
  96.359 -            XtAddCallback(hsb, XmNtoTopCallback, ScrollPane_scrollH, (XtPointer) globalRef);
  96.360 -            XtAddCallback(hsb, XmNtoBottomCallback, ScrollPane_scrollH, (XtPointer) globalRef);
  96.361 -            XtAddCallback(hsb, XmNvalueChangedCallback, ScrollPane_scrollH, (XtPointer) globalRef);
  96.362 -            XtAddCallback(hsb, XmNdragCallback, ScrollPane_scrollH, (XtPointer) globalRef);
  96.363 -
  96.364 -            XtVaSetValues(hsb, XmNhighlightThickness, 0, NULL);
  96.365 -        }
  96.366 -        {
  96.367 -            /**
  96.368 -             * Fix for 4033837 - ScrollPane doesn't generate mouse, focus, key events
  96.369 -             * If ScrollPane created with ALWAYS or AS_NEEDED scrollbars policy then
  96.370 -             * the upper widget is ClipWindow. We should install callbacks on it to
  96.371 -             * receive event notifications.
  96.372 -             */
  96.373 -            Widget clip = XtNameToWidget(sdata->widget, "*ClipWindow");
  96.374 -            if (clip != NULL) {
  96.375 -                // To be able to request focus on Manager by call
  96.376 -                // XmProcessTraversal(, XmTRAVERSE_CURRENT) we need to make
  96.377 -                // it return XmCONTROL_NAVIGABLE from widgetNavigable callback.
  96.378 -                // Default implementation returns DESCENDANTS_TAB_NAVIGABLE
  96.379 -                // which doesn't allow this.
  96.380 -                if (!clipCallbackInitialized) {
  96.381 -                    XmBaseClassExt *er;
  96.382 -                    clipCallbackInitialized = True;
  96.383 -                    er = _XmGetBaseClassExtPtr(XtClass(clip), XmQmotif);
  96.384 -                    oldClipNavigable = (*er)->widgetNavigable;
  96.385 -                    (*er)->widgetNavigable = MyClipNavigable;
  96.386 -                }
  96.387 -                awt_addWidget(clip, sdata->widget, globalRef, java_awt_AWTEvent_MOUSE_EVENT_MASK |
  96.388 -                              java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK | java_awt_AWTEvent_KEY_EVENT_MASK);
  96.389 -            }
  96.390 -        }
  96.391 -        {
  96.392 -            /**
  96.393 -             * Fix for 4033837 - ScrollPane with ALWAYS doesn't have scrollbars visible
  96.394 -             * It seems to be the bug in Motif, the workaround is to add empty child.
  96.395 -             * User child will replace it when needed. This doesn't work if child had been
  96.396 -             * removed.
  96.397 -             */
  96.398 -            if (sbDisplay == java_awt_ScrollPane_SCROLLBARS_ALWAYS) {
  96.399 -                Widget darea = NULL;
  96.400 -                argc = 0;
  96.401 -                XtSetArg(args[argc], XmNwidth, 1);
  96.402 -                argc++;
  96.403 -                XtSetArg(args[argc], XmNheight, 1);
  96.404 -                argc++;
  96.405 -                XtSetArg(args[argc], XmNmarginWidth, 0);
  96.406 -                argc++;
  96.407 -                XtSetArg(args[argc], XmNmarginHeight, 0);
  96.408 -                argc++;
  96.409 -                XtSetArg(args[argc], XmNspacing, 0);
  96.410 -                argc++;
  96.411 -                XtSetArg(args[argc], XmNresizePolicy, XmRESIZE_NONE);
  96.412 -                argc++;
  96.413 -                darea = XmCreateDrawingArea(sdata->widget, "null_child", args, argc);
  96.414 -
  96.415 -                XmScrolledWindowSetAreas(sdata->widget, NULL, NULL, darea);
  96.416 -                XtSetMappedWhenManaged(darea, False);
  96.417 -                XtManageChild(darea);
  96.418 -            }
  96.419 -        }
  96.420 -
  96.421 -    }
  96.422 -
  96.423 -    XtSetMappedWhenManaged(sdata->widget, False);
  96.424 -    XtManageChild(sdata->widget);
  96.425 -
  96.426 -    AWT_UNLOCK();
  96.427 -}
  96.428 -
  96.429 -/*
  96.430 - * Class:     sun_awt_motif_MScrollPanePeer
  96.431 - * Method:    pSetScrollChild
  96.432 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  96.433 - */
  96.434 -JNIEXPORT void JNICALL Java_sun_awt_motif_MScrollPanePeer_pSetScrollChild
  96.435 -  (JNIEnv *env, jobject this, jobject child)
  96.436 -{
  96.437 -    struct ComponentData *cdata;
  96.438 -    struct ComponentData *sdata;
  96.439 -    jobject target;
  96.440 -
  96.441 -    AWT_LOCK();
  96.442 -
  96.443 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  96.444 -
  96.445 -    if (JNU_IsNull(env, child) || JNU_IsNull(env, target)) {
  96.446 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  96.447 -        AWT_UNLOCK();
  96.448 -
  96.449 -        return;
  96.450 -    }
  96.451 -    cdata = (struct ComponentData *)
  96.452 -        JNU_GetLongFieldAsPtr(env,child,mComponentPeerIDs.pData);
  96.453 -    sdata = (struct ComponentData *)
  96.454 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  96.455 -
  96.456 -    if (sdata == NULL || cdata == NULL || sdata->widget == NULL || cdata->widget == NULL) {
  96.457 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  96.458 -        AWT_UNLOCK();
  96.459 -
  96.460 -        return;
  96.461 -    }
  96.462 -    if ((*env)->GetIntField(env, target, scrollPaneIDs.scrollbarDisplayPolicy)
  96.463 -        == java_awt_ScrollPane_SCROLLBARS_NEVER) {
  96.464 -        /* Do Nothing */
  96.465 -    } else {
  96.466 -        XmScrolledWindowSetAreas(sdata->widget, NULL, NULL, cdata->widget);
  96.467 -        /*
  96.468 -          XtInsertEventHandler(cdata->widget, StructureNotifyMask, FALSE,
  96.469 -          child_event_handler, sdata->widget, XtListHead);
  96.470 -        */
  96.471 -    }
  96.472 -
  96.473 -    AWT_UNLOCK();
  96.474 -}
  96.475 -
  96.476 -/*
  96.477 - * Class:     sun_awt_motif_MScrollPanePeer
  96.478 - * Method:    pSetIncrement
  96.479 - * Signature: (III)V
  96.480 - */
  96.481 -JNIEXPORT void JNICALL Java_sun_awt_motif_MScrollPanePeer_pSetIncrement
  96.482 -  (JNIEnv *env, jobject this, jint orient, jint incrType, jint incr)
  96.483 -{
  96.484 -    struct ComponentData *sdata;
  96.485 -    Widget scrollbar = NULL;
  96.486 -
  96.487 -    AWT_LOCK();
  96.488 -
  96.489 -    sdata = (struct ComponentData *)
  96.490 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  96.491 -
  96.492 -    if (sdata == NULL || sdata->widget == NULL) {
  96.493 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  96.494 -        AWT_UNLOCK();
  96.495 -        return;
  96.496 -    }
  96.497 -    if (!XtIsSubclass(sdata->widget, xmScrolledWindowWidgetClass)) {
  96.498 -        AWT_UNLOCK();
  96.499 -        return;
  96.500 -    }
  96.501 -    if (orient == java_awt_Adjustable_VERTICAL) {
  96.502 -        XtVaGetValues(sdata->widget,
  96.503 -                      XmNverticalScrollBar, &scrollbar,
  96.504 -                      NULL);
  96.505 -    } else {
  96.506 -        XtVaGetValues(sdata->widget,
  96.507 -                      XmNhorizontalScrollBar, &scrollbar,
  96.508 -                      NULL);
  96.509 -    }
  96.510 -
  96.511 -    if (scrollbar != NULL) {
  96.512 -        if (incrType == sun_awt_motif_MScrollPanePeer_UNIT_INCREMENT) {
  96.513 -            XtVaSetValues(scrollbar,
  96.514 -                          XmNincrement, (XtArgVal) incr,
  96.515 -                          NULL);
  96.516 -
  96.517 -        } else {
  96.518 -            /* BLOCK_INCREMENT */
  96.519 -            XtVaSetValues(scrollbar,
  96.520 -                          XmNpageIncrement, (XtArgVal) incr,
  96.521 -                          NULL);
  96.522 -        }
  96.523 -    }
  96.524 -    AWT_FLUSH_UNLOCK();
  96.525 -}
  96.526 -
  96.527 -/*
  96.528 - * Class:     sun_awt_motif_MScrollPanePeer
  96.529 - * Method:    pGetScrollbarSpace
  96.530 - * Signature: (I)I
  96.531 - */
  96.532 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MScrollPanePeer_pGetScrollbarSpace
  96.533 -  (JNIEnv *env, jobject this, jint orient)
  96.534 -{
  96.535 -    struct ComponentData *sdata;
  96.536 -    Widget scrollbar;
  96.537 -    Dimension thickness = 0;
  96.538 -    Dimension space = 0;
  96.539 -    Dimension highlight = 0;
  96.540 -
  96.541 -    AWT_LOCK();
  96.542 -
  96.543 -    sdata = (struct ComponentData *)
  96.544 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  96.545 -    if (sdata == NULL || sdata->widget == NULL) {
  96.546 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  96.547 -        AWT_UNLOCK();
  96.548 -        return 0;
  96.549 -    }
  96.550 -    if (orient == java_awt_Adjustable_VERTICAL) {
  96.551 -        XtVaGetValues(sdata->widget,
  96.552 -                      XmNverticalScrollBar, &scrollbar,
  96.553 -                      XmNspacing, &space,
  96.554 -                      NULL);
  96.555 -        XtVaGetValues(scrollbar,
  96.556 -                      XmNwidth, &thickness,
  96.557 -                      XmNhighlightThickness, &highlight,
  96.558 -                      NULL);
  96.559 -    } else {
  96.560 -        XtVaGetValues(sdata->widget,
  96.561 -                      XmNhorizontalScrollBar, &scrollbar,
  96.562 -                      XmNspacing, &space,
  96.563 -                      NULL);
  96.564 -        XtVaGetValues(scrollbar,
  96.565 -                      XmNheight, &thickness,
  96.566 -                      XmNhighlightThickness, &highlight,
  96.567 -                      NULL);
  96.568 -    }
  96.569 -
  96.570 -    AWT_UNLOCK();
  96.571 -    return (jint) (thickness + space + 2 * highlight);
  96.572 -}
  96.573 -
  96.574 -/*
  96.575 - * Class:     sun_awt_motif_MScrollPanePeer
  96.576 - * Method:    pGetBlockIncrement
  96.577 - * Signature: (I)I
  96.578 - */
  96.579 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MScrollPanePeer_pGetBlockIncrement
  96.580 -  (JNIEnv *env, jobject this, jint orient)
  96.581 -{
  96.582 -    int32_t pageIncr = 0;
  96.583 -    struct ComponentData *sdata;
  96.584 -    Widget scrollbar;
  96.585 -
  96.586 -    AWT_LOCK();
  96.587 -
  96.588 -    sdata = (struct ComponentData *)
  96.589 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  96.590 -    if (sdata == NULL || sdata->widget == NULL) {
  96.591 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  96.592 -        AWT_UNLOCK();
  96.593 -        return 0;
  96.594 -    }
  96.595 -    if (orient == java_awt_Adjustable_VERTICAL) {
  96.596 -
  96.597 -        XtVaGetValues(sdata->widget,
  96.598 -                      XmNverticalScrollBar, &scrollbar,
  96.599 -                      NULL);
  96.600 -        XtVaGetValues(scrollbar,
  96.601 -                      XmNpageIncrement, &pageIncr,
  96.602 -                      NULL);
  96.603 -    } else {
  96.604 -
  96.605 -        XtVaGetValues(sdata->widget,
  96.606 -                      XmNhorizontalScrollBar, &scrollbar,
  96.607 -                      NULL);
  96.608 -        XtVaGetValues(scrollbar,
  96.609 -                      XmNpageIncrement, &pageIncr,
  96.610 -                      NULL);
  96.611 -    }
  96.612 -
  96.613 -    AWT_UNLOCK();
  96.614 -    return (jint) (pageIncr);
  96.615 -}
  96.616 -
  96.617 -/*
  96.618 - * Class:     sun_awt_motif_MScrollPanePeer
  96.619 - * Method:    pInsets
  96.620 - * Signature: (IIII)Ljava/awt/Insets;
  96.621 - */
  96.622 -JNIEXPORT jobject JNICALL Java_sun_awt_motif_MScrollPanePeer_pInsets
  96.623 -  (JNIEnv *env, jobject this, jint width, jint height, jint childWidth, jint childHeight)
  96.624 -{
  96.625 -    struct ComponentData *sdata;
  96.626 -    jobject target;
  96.627 -    jobject insets = NULL;
  96.628 -    Widget hsb, vsb;
  96.629 -    Dimension hsbThickness, hsbHighlight, hsbSpace = 0,
  96.630 -              vsbThickness, vsbHighlight, vsbSpace = 0,
  96.631 -              space, border, shadow, hMargin, vMargin;
  96.632 -    unsigned char placement;
  96.633 -    Boolean hsbVisible, vsbVisible;
  96.634 -    jint sbDisplay;
  96.635 -    int32_t top, left, right, bottom;
  96.636 -    jclass clazz;
  96.637 -    jmethodID mid;
  96.638 -
  96.639 -    AWT_LOCK();
  96.640 -
  96.641 -    sdata = (struct ComponentData *)
  96.642 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  96.643 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  96.644 -
  96.645 -    if (JNU_IsNull(env, target) || sdata == NULL || sdata->widget == NULL)
  96.646 -    {
  96.647 -        JNU_ThrowNullPointerException(env, "sdata is NULL");
  96.648 -        AWT_UNLOCK();
  96.649 -        return 0;
  96.650 -    }
  96.651 -    sbDisplay =
  96.652 -      (*env)->GetIntField(env, target, scrollPaneIDs.scrollbarDisplayPolicy);
  96.653 -
  96.654 -    /* REMIND: investigate caching these values rather than querying for
  96.655 -     * them each time.
  96.656 -     */
  96.657 -
  96.658 -    if (sbDisplay == java_awt_ScrollPane_SCROLLBARS_NEVER) {
  96.659 -        XtVaGetValues(sdata->widget,
  96.660 -                      XmNshadowThickness, &shadow,
  96.661 -                      NULL);
  96.662 -        space = border = hMargin = vMargin = 0;
  96.663 -
  96.664 -    } else {
  96.665 -        XtVaGetValues(sdata->widget,
  96.666 -                      XmNverticalScrollBar, &vsb,
  96.667 -                      XmNhorizontalScrollBar, &hsb,
  96.668 -                      XmNscrollBarPlacement, &placement,
  96.669 -                      XmNspacing, &space,
  96.670 -                      XmNshadowThickness, &shadow,
  96.671 -                      XmNscrolledWindowMarginHeight, &vMargin,
  96.672 -                      XmNscrolledWindowMarginWidth, &hMargin,
  96.673 -                      XmNborderWidth, &border,
  96.674 -                      NULL);
  96.675 -
  96.676 -        XtVaGetValues(vsb,
  96.677 -                      XmNwidth, &vsbThickness,
  96.678 -                      XmNhighlightThickness, &vsbHighlight,
  96.679 -                      NULL);
  96.680 -
  96.681 -        XtVaGetValues(hsb,
  96.682 -                      XmNheight, &hsbThickness,
  96.683 -                      XmNhighlightThickness, &hsbHighlight,
  96.684 -                      NULL);
  96.685 -
  96.686 -        hsbSpace = hsbThickness + space + hsbHighlight;
  96.687 -        vsbSpace = vsbThickness + space + vsbHighlight;
  96.688 -
  96.689 -/*
  96.690 -  XtVaGetValues(clip,
  96.691 -  XmNwidth, &clipw, XmNheight, &cliph,
  96.692 -  XmNx, &clipx, XmNy, &clipy,
  96.693 -  NULL);
  96.694 -  printf("insets: spacing=%d shadow=%d swMarginH=%d swMarginW=%d border=%d ; \
  96.695 -  vsb=%d vsbHL=%d ; hsb=%d hsbHL=%d ; %dx%d ->clip=%d,%d %dx%d\n",
  96.696 -  space, shadow, vMargin, hMargin, border,
  96.697 -  vsbThickness, vsbHighlight, hsbThickness, hsbHighlight,
  96.698 -  w, h, clipx, clipy, clipw, cliph);
  96.699 -*/
  96.700 -    }
  96.701 -
  96.702 -    /* We unfortunately have to use the size parameters to determine
  96.703 -     * whether or not "as needed" scrollbars are currently present or
  96.704 -     * not because we can't necessarily rely on getting valid geometry
  96.705 -     * values straight from the Motif widgets until they are mapped. :(
  96.706 -     */
  96.707 -    switch (sbDisplay) {
  96.708 -        case java_awt_ScrollPane_SCROLLBARS_NEVER:
  96.709 -            vsbVisible = hsbVisible = FALSE;
  96.710 -            break;
  96.711 -
  96.712 -        case java_awt_ScrollPane_SCROLLBARS_ALWAYS:
  96.713 -            vsbVisible = hsbVisible = TRUE;
  96.714 -            break;
  96.715 -
  96.716 -        case java_awt_ScrollPane_SCROLLBARS_AS_NEEDED:
  96.717 -        default:
  96.718 -            vsbVisible = hsbVisible = FALSE;
  96.719 -            if (childWidth > width - 2 * shadow) {
  96.720 -                hsbVisible = TRUE;
  96.721 -            }
  96.722 -            if (childHeight > height - 2 * shadow) {
  96.723 -                vsbVisible = TRUE;
  96.724 -            }
  96.725 -            if (!hsbVisible && vsbVisible && childWidth > width - 2 * shadow - vsbSpace) {
  96.726 -                hsbVisible = TRUE;
  96.727 -            } else if (!vsbVisible && hsbVisible && childHeight > height - 2 * shadow - hsbSpace) {
  96.728 -                vsbVisible = TRUE;
  96.729 -            }
  96.730 -    }
  96.731 -
  96.732 -    top = bottom = shadow + vMargin;
  96.733 -    left = right = shadow + hMargin;
  96.734 -
  96.735 -    if (sbDisplay != java_awt_ScrollPane_SCROLLBARS_NEVER) {
  96.736 -        switch (placement) {
  96.737 -            case XmBOTTOM_RIGHT:
  96.738 -                bottom += (hsbVisible ? hsbSpace : (vsbVisible ? vsbHighlight : 0));
  96.739 -                right += (vsbVisible ? vsbSpace : (hsbVisible ? hsbHighlight : 0));
  96.740 -                top += (vsbVisible ? vsbHighlight : 0);
  96.741 -                left += (hsbVisible ? hsbHighlight : 0);
  96.742 -                break;
  96.743 -
  96.744 -            case XmBOTTOM_LEFT:
  96.745 -                bottom += (hsbVisible ? hsbSpace : (vsbVisible ? vsbHighlight : 0));
  96.746 -                left += (vsbVisible ? hsbSpace : (hsbVisible ? hsbHighlight : 0));
  96.747 -                top += (vsbVisible ? vsbHighlight : 0);
  96.748 -                right += (hsbVisible ? hsbHighlight : 0);
  96.749 -                break;
  96.750 -
  96.751 -            case XmTOP_RIGHT:
  96.752 -                top += (hsbVisible ? hsbSpace : (vsbVisible ? vsbHighlight : 0));
  96.753 -                right += (vsbVisible ? vsbSpace : (hsbVisible ? hsbHighlight : 0));
  96.754 -                bottom += (vsbVisible ? vsbHighlight : 0);
  96.755 -                left += (hsbVisible ? hsbHighlight : 0);
  96.756 -                break;
  96.757 -
  96.758 -            case XmTOP_LEFT:
  96.759 -                top += (hsbVisible ? hsbSpace : (vsbVisible ? vsbHighlight : 0));
  96.760 -                left += (vsbVisible ? vsbSpace : (hsbVisible ? hsbHighlight : 0));
  96.761 -                bottom += (vsbVisible ? vsbHighlight : 0);
  96.762 -                right += (hsbVisible ? hsbHighlight : 0);
  96.763 -        }
  96.764 -    }
  96.765 -    /* Deadlock prevention:
  96.766 -     * don't hold the toolkit lock while invoking constructor.
  96.767 -     */
  96.768 -    AWT_UNLOCK();
  96.769 -
  96.770 -    clazz = (*env)->FindClass(env, "java/awt/Insets");
  96.771 -    mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
  96.772 -    if (mid != NULL) {
  96.773 -        insets = (*env)->NewObject(env, clazz, mid,
  96.774 -                                   (jint) top,
  96.775 -                                   (jint) left,
  96.776 -                                   (jint) bottom,
  96.777 -                                   (jint) right);
  96.778 -
  96.779 -    }
  96.780 -    /* This should catch both method not found and error exceptions */
  96.781 -    if ((*env)->ExceptionOccurred(env)) {
  96.782 -        (*env)->ExceptionDescribe(env);
  96.783 -        (*env)->ExceptionClear(env);
  96.784 -    }
  96.785 -    if (JNU_IsNull(env, insets)) {
  96.786 -        JNU_ThrowNullPointerException(env, "NullPointerException: insets constructor failed");
  96.787 -    }
  96.788 -    return insets;
  96.789 -}
  96.790 -
  96.791 -/*
  96.792 - * Class:     sun_awt_motif_MScrollPanePeer
  96.793 - * Method:    setScrollPosition
  96.794 - * Signature: (II)V
  96.795 - */
  96.796 -JNIEXPORT void JNICALL Java_sun_awt_motif_MScrollPanePeer_setScrollPosition
  96.797 -  (JNIEnv *env, jobject this, jint x, jint y)
  96.798 -{
  96.799 -    struct ComponentData *sdata;
  96.800 -    jobject target;
  96.801 -    Widget hsb, vsb;
  96.802 -    int32_t size, incr, pIncr;
  96.803 -
  96.804 -    AWT_LOCK();
  96.805 -
  96.806 -    sdata = (struct ComponentData *)
  96.807 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  96.808 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  96.809 -
  96.810 -    if (JNU_IsNull(env, target) || sdata == NULL || sdata->widget == NULL)
  96.811 -    {
  96.812 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  96.813 -        AWT_UNLOCK();
  96.814 -        return;
  96.815 -    }
  96.816 -    if ((*env)->GetIntField(env, target, scrollPaneIDs.scrollbarDisplayPolicy)
  96.817 -        == java_awt_ScrollPane_SCROLLBARS_NEVER) {
  96.818 -        WidgetList children;
  96.819 -        Cardinal numChildren;
  96.820 -
  96.821 -        XtVaGetValues(sdata->widget,
  96.822 -                      XmNchildren, &children,
  96.823 -                      XmNnumChildren, &numChildren,
  96.824 -                      NULL);
  96.825 -
  96.826 -        if (numChildren < 1) {
  96.827 -            JNU_ThrowNullPointerException(env, "NullPointerException");
  96.828 -            AWT_UNLOCK();
  96.829 -            return;
  96.830 -        }
  96.831 -        XtMoveWidget(children[0], (Position) -x, (Position) -y);
  96.832 -    } else {
  96.833 -        int32_t sb_min = 0;
  96.834 -        int32_t sb_max = 0;
  96.835 -        XtVaGetValues(sdata->widget,
  96.836 -                      XmNhorizontalScrollBar, &hsb,
  96.837 -                      XmNverticalScrollBar, &vsb,
  96.838 -                      NULL);
  96.839 -
  96.840 -        if (vsb) {
  96.841 -            XtVaGetValues(vsb,
  96.842 -                          XmNincrement, &incr,
  96.843 -                          XmNpageIncrement, &pIncr,
  96.844 -                          XmNsliderSize, &size,
  96.845 -                          XmNminimum, &sb_min,
  96.846 -                          XmNmaximum, &sb_max,
  96.847 -                          NULL);
  96.848 -            /* Bug 4208972, 4275934 : Do range checking for scroll bar value. */
  96.849 -            if (y < sb_min)
  96.850 -                y = sb_min;
  96.851 -            if (y > (sb_max - size))
  96.852 -                y = sb_max - size;
  96.853 -            XmScrollBarSetValues(vsb, (int32_t) y, size, incr, pIncr, TRUE);
  96.854 -        }
  96.855 -        if (hsb) {
  96.856 -            XtVaGetValues(hsb,
  96.857 -                          XmNincrement, &incr,
  96.858 -                          XmNpageIncrement, &pIncr,
  96.859 -                          XmNsliderSize, &size,
  96.860 -                          XmNminimum, &sb_min,
  96.861 -                          XmNmaximum, &sb_max,
  96.862 -                          NULL);
  96.863 -            /* Bug 4208972, 4275934 : Do range checking for scroll bar value. */
  96.864 -            if (x < sb_min)
  96.865 -                x = sb_min;
  96.866 -            if (x > (sb_max - size))
  96.867 -                x = sb_max - size;
  96.868 -            XmScrollBarSetValues(hsb, (int32_t) x, size, incr, pIncr, TRUE);
  96.869 -        }
  96.870 -    }
  96.871 -    AWT_FLUSH_UNLOCK();
  96.872 -}
  96.873 -
  96.874 -
  96.875 -/*
  96.876 - * Class:     sun_awt_motif_MScrollPanePeer
  96.877 - * Method:    pGetShadow
  96.878 - * Signature: ()I
  96.879 - */
  96.880 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MScrollPanePeer_pGetShadow(
  96.881 -                       JNIEnv *env, jobject this) {
  96.882 -    struct ComponentData *sdata;
  96.883 -    jobject target;
  96.884 -    Dimension shadow=0 ;
  96.885 -
  96.886 -    AWT_LOCK() ;
  96.887 -    sdata = (struct ComponentData *)
  96.888 -    (*env)->GetLongField(env,this,mComponentPeerIDs.pData);
  96.889 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  96.890 -
  96.891 -    if (JNU_IsNull(env, target) || sdata == NULL || sdata->widget == NULL)
  96.892 -    {
  96.893 -        JNU_ThrowNullPointerException(env, "sdata is NULL");
  96.894 -        AWT_UNLOCK();
  96.895 -        return 0;
  96.896 -    }
  96.897 -
  96.898 -    XtVaGetValues(sdata->widget,
  96.899 -        XmNshadowThickness,
  96.900 -        &shadow,
  96.901 -        NULL);
  96.902 -
  96.903 -    AWT_UNLOCK() ;
  96.904 -
  96.905 -    return((jint)shadow) ;
  96.906 -}
  96.907 -
  96.908 -/*
  96.909 - * Class:     sun_awt_motif_MScrollPanePeer
  96.910 - * Method:    setTypedValue
  96.911 - * Signature: (Ljava/awt/ScrollPaneAdjustable;II)V
  96.912 - */
  96.913 -JNIEXPORT void JNICALL
  96.914 -Java_sun_awt_motif_MScrollPanePeer_setTypedValue(JNIEnv *env, jobject peer, jobject adjustable, jint value, jint type)
  96.915 -{
  96.916 -    static jmethodID setTypedValueMID = 0;
  96.917 -    if (setTypedValueMID == NULL) {
  96.918 -        jclass clazz = (*env)->FindClass(env, "java/awt/ScrollPaneAdjustable");
  96.919 -        if ((*env)->ExceptionOccurred(env)) {
  96.920 -            (*env)->ExceptionDescribe(env);
  96.921 -            (*env)->ExceptionClear(env);
  96.922 -            return;
  96.923 -        }
  96.924 -        setTypedValueMID = (*env)->GetMethodID(env, clazz, "setTypedValue", "(II)V");
  96.925 -        (*env)->DeleteLocalRef(env, clazz);
  96.926 -
  96.927 -        DASSERT(setTypedValueMID != NULL);
  96.928 -    }
  96.929 -    (*env)->CallVoidMethod(env, adjustable, setTypedValueMID, value, type);
  96.930 -}
    97.1 --- a/src/solaris/native/sun/awt/awt_Scrollbar.c	Wed Sep 17 13:45:37 2008 -0700
    97.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    97.3 @@ -1,440 +0,0 @@
    97.4 -/*
    97.5 - * Copyright 1995-2004 Sun Microsystems, Inc.  All Rights Reserved.
    97.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    97.7 - *
    97.8 - * This code is free software; you can redistribute it and/or modify it
    97.9 - * under the terms of the GNU General Public License version 2 only, as
   97.10 - * published by the Free Software Foundation.  Sun designates this
   97.11 - * particular file as subject to the "Classpath" exception as provided
   97.12 - * by Sun in the LICENSE file that accompanied this code.
   97.13 - *
   97.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   97.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   97.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   97.17 - * version 2 for more details (a copy is included in the LICENSE file that
   97.18 - * accompanied this code).
   97.19 - *
   97.20 - * You should have received a copy of the GNU General Public License version
   97.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   97.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   97.23 - *
   97.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   97.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   97.26 - * have any questions.
   97.27 - */
   97.28 -
   97.29 -#ifdef HEADLESS
   97.30 -    #error This file should not be included in headless library
   97.31 -#endif
   97.32 -
   97.33 -#include "awt_p.h"
   97.34 -#include "java_awt_Scrollbar.h"
   97.35 -#include "java_awt_event_MouseEvent.h"
   97.36 -#include "sun_awt_motif_MScrollbarPeer.h"
   97.37 -#include "sun_awt_motif_MComponentPeer.h"
   97.38 -
   97.39 -#include "awt_Component.h"
   97.40 -#include "canvas.h"
   97.41 -
   97.42 -#include <jni.h>
   97.43 -#include <jni_util.h>
   97.44 -#include "multi_font.h"
   97.45 -
   97.46 -
   97.47 -extern struct MComponentPeerIDs mComponentPeerIDs;
   97.48 -extern AwtGraphicsConfigDataPtr
   97.49 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   97.50 -
   97.51 -/* fieldIDs for java.awt.Scrollbar fields that may be accessed from C */
   97.52 -static struct ScrollbarIDs {
   97.53 -    jfieldID orientation;
   97.54 -    jfieldID visibleAmount;
   97.55 -    jfieldID lineIncrement;
   97.56 -    jfieldID pageIncrement;
   97.57 -    jfieldID value;
   97.58 -    jfieldID minimum;
   97.59 -    jfieldID maximum;
   97.60 -} targetIDs;
   97.61 -
   97.62 -/* MScrollbarPeer callback methods */
   97.63 -static struct {
   97.64 -    jmethodID lineUp;
   97.65 -    jmethodID lineDown;
   97.66 -    jmethodID pageUp;
   97.67 -    jmethodID pageDown;
   97.68 -    jmethodID drag;
   97.69 -    jmethodID dragEnd;
   97.70 -    jmethodID warp;
   97.71 -} peerIDs;
   97.72 -
   97.73 -
   97.74 -
   97.75 -/*
   97.76 - * Class:     java_awt_ScrollBar
   97.77 - * Method:    initIDs
   97.78 - * Signature: ()V
   97.79 - */
   97.80 -
   97.81 -/* This function gets called from the static initializer for
   97.82 -   Scrollbar.java to initialize the fieldIDs for fields that may
   97.83 -   be accessed from C */
   97.84 -
   97.85 -JNIEXPORT void JNICALL
   97.86 -Java_java_awt_Scrollbar_initIDs(JNIEnv *env, jclass cls)
   97.87 -{
   97.88 -    targetIDs.orientation =
   97.89 -      (*env)->GetFieldID(env, cls, "orientation", "I");
   97.90 -    targetIDs.visibleAmount =
   97.91 -      (*env)->GetFieldID(env, cls, "visibleAmount", "I");
   97.92 -    targetIDs.lineIncrement =
   97.93 -      (*env)->GetFieldID(env, cls, "lineIncrement", "I");
   97.94 -    targetIDs.pageIncrement =
   97.95 -      (*env)->GetFieldID(env, cls, "pageIncrement", "I");
   97.96 -    targetIDs.value =
   97.97 -      (*env)->GetFieldID(env, cls, "value", "I");
   97.98 -    targetIDs.minimum =
   97.99 -      (*env)->GetFieldID(env, cls, "minimum", "I");
  97.100 -    targetIDs.maximum =
  97.101 -      (*env)->GetFieldID(env, cls, "maximum", "I");
  97.102 -}
  97.103 -
  97.104 -
  97.105 -/*
  97.106 - * Class:     sun_awt_motif_MComponentPeer
  97.107 - * Method:    initIDs
  97.108 - * Signature: ()V
  97.109 - */
  97.110 -
  97.111 -/* This function gets called from the static initializer for
  97.112 -   MScrollbarPeer to initialize the JNI ids for fields and methods
  97.113 -   that may be accessed from C */
  97.114 -
  97.115 -JNIEXPORT void JNICALL
  97.116 -Java_sun_awt_motif_MScrollbarPeer_initIDs(JNIEnv *env, jclass cls)
  97.117 -{
  97.118 -    peerIDs.lineUp =
  97.119 -        (*env)->GetMethodID(env, cls, "lineUp",   "(I)V");
  97.120 -    peerIDs.lineDown =
  97.121 -        (*env)->GetMethodID(env, cls, "lineDown", "(I)V");
  97.122 -    peerIDs.pageUp =
  97.123 -        (*env)->GetMethodID(env, cls, "pageUp",   "(I)V");
  97.124 -    peerIDs.pageDown =
  97.125 -        (*env)->GetMethodID(env, cls, "pageDown", "(I)V");
  97.126 -    peerIDs.drag =
  97.127 -        (*env)->GetMethodID(env, cls, "drag",     "(I)V");
  97.128 -    peerIDs.dragEnd =
  97.129 -        (*env)->GetMethodID(env, cls, "dragEnd",  "(I)V");
  97.130 -    peerIDs.warp =
  97.131 -        (*env)->GetMethodID(env, cls, "warp",     "(I)V");
  97.132 -}
  97.133 -
  97.134 -/*
  97.135 - * Call peer.jcallback(value)
  97.136 - */
  97.137 -static void
  97.138 -DoJavaCallback(jobject peer, jmethodID jcallback, jint value)
  97.139 -{
  97.140 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  97.141 -    (*env)->CallVoidMethod(env, peer, jcallback, value);
  97.142 -    if ((*env)->ExceptionOccurred(env)) {
  97.143 -        (*env)->ExceptionDescribe(env);
  97.144 -        (*env)->ExceptionClear(env);
  97.145 -    }
  97.146 -}
  97.147 -
  97.148 -
  97.149 -static void /* XtCallbackProc */
  97.150 -decrementCallback(Widget w, jobject peer,
  97.151 -    XmScrollBarCallbackStruct *scroll)
  97.152 -{
  97.153 -    DASSERT(scroll->reason == XmCR_DECREMENT);
  97.154 -    DoJavaCallback(peer, peerIDs.lineUp, scroll->value);
  97.155 -}
  97.156 -
  97.157 -static void /* XtCallbackProc */
  97.158 -incrementCallback(Widget w, jobject peer,
  97.159 -    XmScrollBarCallbackStruct *scroll)
  97.160 -{
  97.161 -    DASSERT(scroll->reason == XmCR_INCREMENT);
  97.162 -    DoJavaCallback(peer, peerIDs.lineDown, scroll->value);
  97.163 -}
  97.164 -
  97.165 -static void /* XtCallbackProc */
  97.166 -pageDecrementCallback(Widget w, jobject peer,
  97.167 -    XmScrollBarCallbackStruct *scroll)
  97.168 -{
  97.169 -    DASSERT(scroll->reason == XmCR_PAGE_DECREMENT);
  97.170 -    DoJavaCallback(peer, peerIDs.pageUp, scroll->value);
  97.171 -}
  97.172 -
  97.173 -static void /* XtCallbackProc */
  97.174 -pageIncrementCallback(Widget w, jobject peer,
  97.175 -    XmScrollBarCallbackStruct *scroll)
  97.176 -{
  97.177 -    DASSERT(scroll->reason == XmCR_PAGE_INCREMENT);
  97.178 -    DoJavaCallback(peer, peerIDs.pageDown, scroll->value);
  97.179 -}
  97.180 -
  97.181 -static void /* XtCallbackProc */
  97.182 -dragCallback(Widget w, jobject peer,
  97.183 -    XmScrollBarCallbackStruct *scroll)
  97.184 -{
  97.185 -    DASSERT(scroll->reason == XmCR_DRAG);
  97.186 -    DoJavaCallback(peer, peerIDs.drag, scroll->value);
  97.187 -}
  97.188 -
  97.189 -static void /* XtCallbackProc */
  97.190 -dragEndCallback(Widget w, jobject peer,
  97.191 -    XmScrollBarCallbackStruct *scroll)
  97.192 -{
  97.193 -    DASSERT(scroll->reason == XmCR_VALUE_CHANGED);
  97.194 -    DoJavaCallback(peer, peerIDs.dragEnd, scroll->value);
  97.195 -}
  97.196 -
  97.197 -static void /* XtCallbackProc */
  97.198 -toTopCallback(Widget w, jobject peer,
  97.199 -    XmScrollBarCallbackStruct *scroll)
  97.200 -{
  97.201 -    DASSERT(scroll->reason == XmCR_TO_TOP);
  97.202 -    DoJavaCallback(peer, peerIDs.warp, scroll->value);
  97.203 -}
  97.204 -
  97.205 -static void /* XtCallbackProc */
  97.206 -toBottomCallback(Widget w, jobject peer,
  97.207 -    XmScrollBarCallbackStruct *scroll)
  97.208 -{
  97.209 -    DASSERT(scroll->reason == XmCR_TO_BOTTOM);
  97.210 -    DoJavaCallback(peer, peerIDs.warp, scroll->value);
  97.211 -}
  97.212 -
  97.213 -
  97.214 -/*
  97.215 - * Class:     sun_awt_motif_MScrollbarPeer
  97.216 - * Method:    create
  97.217 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  97.218 - */
  97.219 -JNIEXPORT void JNICALL
  97.220 -Java_sun_awt_motif_MScrollbarPeer_create(JNIEnv *env, jobject this,
  97.221 -    jobject parent)
  97.222 -{
  97.223 -    Widget w;
  97.224 -
  97.225 -    jobject target;
  97.226 -    XtPointer globalRef = (XtPointer) /* jobject */
  97.227 -        awtJNI_CreateAndSetGlobalRef(env, this);
  97.228 -
  97.229 -    struct ComponentData *pdata; /* for parent     */
  97.230 -    struct ComponentData *sdata; /* for scrollbar */
  97.231 -    AwtGraphicsConfigDataPtr adata;
  97.232 -
  97.233 -    int32_t value, visible, minimum, maximum;
  97.234 -    int32_t lineIncrement, pageIncrement;
  97.235 -    Pixel bg;
  97.236 -
  97.237 -#define MAX_ARGC 20
  97.238 -    Arg args[MAX_ARGC];
  97.239 -    int32_t argc = 0;
  97.240 -
  97.241 -
  97.242 -    AWT_LOCK();
  97.243 -
  97.244 -    if (JNU_IsNull(env, parent)) {
  97.245 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  97.246 -        AWT_UNLOCK();
  97.247 -        return;
  97.248 -    }
  97.249 -
  97.250 -    pdata = (struct ComponentData *)
  97.251 -        JNU_GetLongFieldAsPtr(env, parent, mComponentPeerIDs.pData);
  97.252 -
  97.253 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  97.254 -
  97.255 -    if (JNU_IsNull(env, target) || pdata == NULL) {
  97.256 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  97.257 -        AWT_UNLOCK();
  97.258 -        return;
  97.259 -    }
  97.260 -
  97.261 -
  97.262 -    switch ((*env)->GetIntField(env, target, targetIDs.orientation)) {
  97.263 -      case java_awt_Scrollbar_HORIZONTAL:
  97.264 -          XtSetArg(args[argc], XmNorientation, XmHORIZONTAL);
  97.265 -          argc++;
  97.266 -          break;
  97.267 -
  97.268 -      case java_awt_Scrollbar_VERTICAL:
  97.269 -          XtSetArg(args[argc], XmNorientation, XmVERTICAL);
  97.270 -          argc++;
  97.271 -          break;
  97.272 -
  97.273 -      default:
  97.274 -          JNU_ThrowIllegalArgumentException(env, "bad scrollbar orientation");
  97.275 -          AWT_UNLOCK();
  97.276 -          return;
  97.277 -    }
  97.278 -
  97.279 -    adata = copyGraphicsConfigToPeer(env, this);
  97.280 -    XtVaGetValues(pdata->widget, XmNbackground, &bg, NULL);
  97.281 -
  97.282 -    visible = (int32_t) (*env)->GetIntField(env, target, targetIDs.visibleAmount);
  97.283 -    value   = (int32_t) (*env)->GetIntField(env, target, targetIDs.value);
  97.284 -    minimum = (int32_t) (*env)->GetIntField(env, target, targetIDs.minimum);
  97.285 -    maximum = (int32_t) (*env)->GetIntField(env, target, targetIDs.maximum);
  97.286 -    lineIncrement =
  97.287 -              (int32_t) (*env)->GetIntField(env, target, targetIDs.lineIncrement);
  97.288 -    pageIncrement =
  97.289 -              (int32_t) (*env)->GetIntField(env, target, targetIDs.pageIncrement);
  97.290 -
  97.291 -    /*
  97.292 -     * Sanity check.  Scrollbar.setValues should have taken care.
  97.293 -     */
  97.294 -    DASSERT(maximum > minimum);
  97.295 -    DASSERT(visible <= maximum - minimum);
  97.296 -    DASSERT(visible >= 1);
  97.297 -    DASSERT(value >= minimum);
  97.298 -    DASSERT(value <= maximum - visible);
  97.299 -
  97.300 -    XtSetArg(args[argc], XmNx,             0);                  argc++;
  97.301 -    XtSetArg(args[argc], XmNy,             0);                  argc++;
  97.302 -    XtSetArg(args[argc], XmNvalue,         value);              argc++;
  97.303 -    XtSetArg(args[argc], XmNsliderSize,    visible);            argc++;
  97.304 -    XtSetArg(args[argc], XmNminimum,       minimum);            argc++;
  97.305 -    XtSetArg(args[argc], XmNmaximum,       maximum);            argc++;
  97.306 -    XtSetArg(args[argc], XmNincrement,     lineIncrement);      argc++;
  97.307 -    XtSetArg(args[argc], XmNpageIncrement, pageIncrement);      argc++;
  97.308 -    XtSetArg(args[argc], XmNbackground,    bg);                 argc++;
  97.309 -    XtSetArg(args[argc], XmNrecomputeSize, False);              argc++;
  97.310 -    XtSetArg(args[argc], XmNuserData,      globalRef);          argc++;
  97.311 -    XtSetArg(args[argc], XmNscreen,
  97.312 -                             ScreenOfDisplay(awt_display,
  97.313 -                                 adata->awt_visInfo.screen));   argc++;
  97.314 -
  97.315 -    DASSERT(argc <= MAX_ARGC);  /* sanity check */
  97.316 -
  97.317 -    sdata = ZALLOC(ComponentData);
  97.318 -    if (sdata == NULL) {
  97.319 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  97.320 -        AWT_UNLOCK();
  97.321 -        return;
  97.322 -    }
  97.323 -
  97.324 -    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.pData, sdata);
  97.325 -
  97.326 -    sdata->widget = w =
  97.327 -        XmCreateScrollBar(pdata->widget, "scrollbar", args, argc);
  97.328 -
  97.329 -    XtAddCallback(w, XmNdecrementCallback,
  97.330 -        (XtCallbackProc)decrementCallback, globalRef);
  97.331 -    XtAddCallback(w, XmNincrementCallback,
  97.332 -        (XtCallbackProc)incrementCallback, globalRef);
  97.333 -    XtAddCallback(w, XmNpageDecrementCallback,
  97.334 -        (XtCallbackProc)pageDecrementCallback, globalRef);
  97.335 -    XtAddCallback(w, XmNpageIncrementCallback,
  97.336 -        (XtCallbackProc)pageIncrementCallback, globalRef);
  97.337 -    XtAddCallback(w, XmNtoTopCallback,
  97.338 -        (XtCallbackProc)toTopCallback, globalRef);
  97.339 -    XtAddCallback(w, XmNtoBottomCallback,
  97.340 -        (XtCallbackProc)toBottomCallback, globalRef);
  97.341 -    XtAddCallback(w, XmNdragCallback,
  97.342 -        (XtCallbackProc)dragCallback, globalRef);
  97.343 -    XtAddCallback(w, XmNvalueChangedCallback,
  97.344 -        (XtCallbackProc)dragEndCallback, globalRef);
  97.345 -
  97.346 -    /* Set up workaround for the continuous scrolling bug */
  97.347 -    XtAddEventHandler(w, ButtonReleaseMask, False,
  97.348 -        awt_motif_Scrollbar_ButtonReleaseHandler, NULL);
  97.349 -
  97.350 -    /* Fix for 4955950. ButtonRelease & MotionNotify should be handled as well */
  97.351 -    XtAddEventHandler(w, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
  97.352 -                      False, awt_canvas_event_handler, globalRef);
  97.353 -
  97.354 -    XtSetMappedWhenManaged(w, False);
  97.355 -    XtManageChild(w);
  97.356 -
  97.357 -    AWT_UNLOCK();
  97.358 -}
  97.359 -
  97.360 -/*
  97.361 - * Class:     sun_awt_motif_MScrollbarPeer
  97.362 - * Method:    pSetValues
  97.363 - * Signature: (IIII)V
  97.364 - */
  97.365 -JNIEXPORT void JNICALL
  97.366 -Java_sun_awt_motif_MScrollbarPeer_pSetValues(JNIEnv *env, jobject this,
  97.367 -    jint value, jint visible, jint minimum, jint maximum)
  97.368 -{
  97.369 -    struct ComponentData *sdata;
  97.370 -
  97.371 -    AWT_LOCK();
  97.372 -
  97.373 -    sdata = (struct ComponentData *)
  97.374 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  97.375 -    if (sdata == NULL) {
  97.376 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  97.377 -        AWT_UNLOCK();
  97.378 -        return;
  97.379 -    }
  97.380 -    /* pass in visible for sliderSize since Motif will calculate the */
  97.381 -    /* slider's size for us. */
  97.382 -    XtVaSetValues(sdata->widget,
  97.383 -                  XmNminimum, minimum,
  97.384 -                  XmNmaximum, maximum,
  97.385 -                  XmNvalue, value,
  97.386 -                  XmNsliderSize, visible,
  97.387 -                  NULL);
  97.388 -    AWT_FLUSH_UNLOCK();
  97.389 -}
  97.390 -
  97.391 -
  97.392 -/*
  97.393 - * Class:     sun_awt_motif_MScrollbarPeer
  97.394 - * Method:    setLineIncrement
  97.395 - * Signature: (I)V
  97.396 - */
  97.397 -JNIEXPORT void JNICALL
  97.398 -Java_sun_awt_motif_MScrollbarPeer_setLineIncrement(JNIEnv *env, jobject this,
  97.399 -    jint value)
  97.400 -{
  97.401 -    struct ComponentData *sdata;
  97.402 -
  97.403 -    AWT_LOCK();
  97.404 -
  97.405 -    sdata = (struct ComponentData *)
  97.406 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  97.407 -    if (sdata == NULL) {
  97.408 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  97.409 -        AWT_UNLOCK();
  97.410 -        return;
  97.411 -    }
  97.412 -    XtVaSetValues(sdata->widget,
  97.413 -                  XmNincrement, value,
  97.414 -                  NULL);
  97.415 -    AWT_FLUSH_UNLOCK();
  97.416 -}
  97.417 -
  97.418 -
  97.419 -/*
  97.420 - * Class:     sun_awt_motif_MScrollbarPeer
  97.421 - * Method:    setPageIncrement
  97.422 - * Signature: (I)V
  97.423 - */
  97.424 -JNIEXPORT void JNICALL
  97.425 -Java_sun_awt_motif_MScrollbarPeer_setPageIncrement(JNIEnv *env, jobject this,
  97.426 -    jint value)
  97.427 -{
  97.428 -    struct ComponentData *sdata;
  97.429 -
  97.430 -    AWT_LOCK();
  97.431 -
  97.432 -    sdata = (struct ComponentData *)
  97.433 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  97.434 -    if (sdata == NULL) {
  97.435 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  97.436 -        AWT_UNLOCK();
  97.437 -        return;
  97.438 -    }
  97.439 -    XtVaSetValues(sdata->widget,
  97.440 -                  XmNpageIncrement, value,
  97.441 -                  NULL);
  97.442 -    AWT_FLUSH_UNLOCK();
  97.443 -}
    98.1 --- a/src/solaris/native/sun/awt/awt_Selection.c	Wed Sep 17 13:45:37 2008 -0700
    98.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    98.3 @@ -1,508 +0,0 @@
    98.4 -/*
    98.5 - * Copyright 1996-2003 Sun Microsystems, Inc.  All Rights Reserved.
    98.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    98.7 - *
    98.8 - * This code is free software; you can redistribute it and/or modify it
    98.9 - * under the terms of the GNU General Public License version 2 only, as
   98.10 - * published by the Free Software Foundation.  Sun designates this
   98.11 - * particular file as subject to the "Classpath" exception as provided
   98.12 - * by Sun in the LICENSE file that accompanied this code.
   98.13 - *
   98.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   98.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   98.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   98.17 - * version 2 for more details (a copy is included in the LICENSE file that
   98.18 - * accompanied this code).
   98.19 - *
   98.20 - * You should have received a copy of the GNU General Public License version
   98.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   98.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   98.23 - *
   98.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   98.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   98.26 - * have any questions.
   98.27 - */
   98.28 -
   98.29 -#ifdef HEADLESS
   98.30 -    #error This file should not be included in headless library
   98.31 -#endif
   98.32 -
   98.33 -#include "awt_p.h"
   98.34 -#include "awt_DataTransferer.h"
   98.35 -#include "java_awt_datatransfer_Transferable.h"
   98.36 -#include "java_awt_datatransfer_DataFlavor.h"
   98.37 -#include "sun_awt_motif_X11Selection.h"
   98.38 -#include "sun_awt_motif_X11Clipboard.h"
   98.39 -#include <X11/Intrinsic.h>
   98.40 -#include <X11/Xatom.h>
   98.41 -#include <inttypes.h>
   98.42 -
   98.43 -#include <jni.h>
   98.44 -#include <jni_util.h>
   98.45 -
   98.46 -/* fieldIDs for X11Selection fields that may be accessed from C */
   98.47 -static struct X11SelectionIDs {
   98.48 -    jfieldID holder;
   98.49 -    jfieldID atom;
   98.50 -    jfieldID contents;
   98.51 -    jfieldID selections;
   98.52 -} x11SelectionIDs;
   98.53 -
   98.54 -DECLARE_JAVA_CLASS(selectionClazz, "sun/awt/motif/X11Selection")
   98.55 -
   98.56 -static jobject
   98.57 -call_getSelectionsArray(JNIEnv* env) {
   98.58 -    DECLARE_STATIC_OBJECT_JAVA_METHOD(getSelectionsArray, selectionClazz,
   98.59 -                                    "getSelectionsArray", "()[Ljava/lang/Object;")
   98.60 -    DASSERT(!JNU_IsNull(env, getSelectionsArray));
   98.61 -    return (*env)->CallStaticObjectMethod(env, clazz, getSelectionsArray);
   98.62 -}
   98.63 -
   98.64 -static void
   98.65 -call_checkChange(JNIEnv* env, jobject jselection, jlongArray targetArray)
   98.66 -{
   98.67 -    DECLARE_VOID_JAVA_METHOD(checkChangeMID, selectionClazz,
   98.68 -                             "checkChange", "([J)V")
   98.69 -    DASSERT(!JNU_IsNull(env, jselection));
   98.70 -
   98.71 -    (*env)->CallVoidMethod(env, jselection, checkChangeMID, targetArray);
   98.72 -}
   98.73 -
   98.74 -static jlongArray
   98.75 -call_getSelectionAtomsToCheckChange(JNIEnv* env)
   98.76 -{
   98.77 -    DECLARE_STATIC_OBJECT_JAVA_METHOD(getSelectionAtomsToCheckChangeMID,
   98.78 -            selectionClazz, "getSelectionAtomsToCheckChange", "()[J")
   98.79 -
   98.80 -    return (jlongArray)(*env)->CallStaticObjectMethod(env,
   98.81 -            get_selectionClazz(env), getSelectionAtomsToCheckChangeMID);
   98.82 -
   98.83 -}
   98.84 -
   98.85 -
   98.86 -/*
   98.87 - * Class:     sun_awt_motif_X11Selection
   98.88 - * Method:    initIDs
   98.89 - * Signature: ()V
   98.90 - */
   98.91 -/* This function gets called from the static initializer for
   98.92 -   X11Selection.java to initialize the fieldIDs for fields that may
   98.93 -   be accessed from C */
   98.94 -JNIEXPORT void JNICALL Java_sun_awt_motif_X11Selection_initIDs
   98.95 -    (JNIEnv *env, jclass cls)
   98.96 -{
   98.97 -    x11SelectionIDs.holder = (*env)->
   98.98 -        GetFieldID(env, cls, "holder","Lsun/awt/motif/X11SelectionHolder;");
   98.99 -    x11SelectionIDs.atom = (*env)->GetFieldID(env, cls, "atom", "J");
  98.100 -    x11SelectionIDs.contents = (*env)->
  98.101 -        GetFieldID(env, cls, "contents",
  98.102 -                   "Ljava/awt/datatransfer/Transferable;");
  98.103 -    x11SelectionIDs.selections = (*env)->
  98.104 -        GetStaticFieldID(env, cls, "selections", "Ljava/util/Vector;");
  98.105 -}
  98.106 -
  98.107 -/*
  98.108 - * Class:     sun_awt_motif_X11Selection
  98.109 - * Method:    init
  98.110 - * Signature: ()V
  98.111 - */
  98.112 -JNIEXPORT void JNICALL Java_sun_awt_motif_X11Selection_init
  98.113 -    (JNIEnv *env, jclass this)
  98.114 -{
  98.115 -    AWT_LOCK();
  98.116 -
  98.117 -    AWT_UNLOCK();
  98.118 -}
  98.119 -
  98.120 -static jobject
  98.121 -getX11Selection(JNIEnv * env, Atom atom)
  98.122 -{
  98.123 -    jobjectArray selections;
  98.124 -    jsize selectionCount, i;
  98.125 -    jobject selection;
  98.126 -    jobject returnSelection = NULL;
  98.127 -
  98.128 -    selections = (jobjectArray)call_getSelectionsArray(env);
  98.129 -
  98.130 -    if (JNU_IsNull(env, selections)) {
  98.131 -        return NULL;
  98.132 -    }
  98.133 -
  98.134 -    selectionCount = (*env)->GetArrayLength(env, selections);
  98.135 -
  98.136 -    for (i = 0; i < selectionCount; i++) {
  98.137 -        selection = (*env)->GetObjectArrayElement(env, selections, i);
  98.138 -        if ((*env)->ExceptionCheck(env)) {
  98.139 -            (*env)->ExceptionDescribe(env);
  98.140 -            (*env)->ExceptionClear(env);
  98.141 -            break;
  98.142 -        }
  98.143 -        if (JNU_IsNull(env, selection)) {
  98.144 -            break;
  98.145 -        }
  98.146 -        if ((*env)->GetLongField(env, selection, x11SelectionIDs.atom) == atom) {
  98.147 -            returnSelection = selection;
  98.148 -        } else {
  98.149 -            (*env)->DeleteLocalRef(env, selection);
  98.150 -        }
  98.151 -    }
  98.152 -
  98.153 -    (*env)->DeleteLocalRef(env, selections);
  98.154 -
  98.155 -    return returnSelection;
  98.156 -}
  98.157 -
  98.158 -Boolean
  98.159 -awtJNI_isSelectionOwner(JNIEnv * env, char *sel_str)
  98.160 -{
  98.161 -    Atom selection;
  98.162 -    jobject x11sel;
  98.163 -
  98.164 -    selection = XInternAtom(awt_display, sel_str, False);
  98.165 -
  98.166 -    x11sel = getX11Selection(env, selection);
  98.167 -    if (!JNU_IsNull(env, x11sel)) {
  98.168 -        jobject holder;
  98.169 -
  98.170 -        holder = (*env)->GetObjectField(env, x11sel, x11SelectionIDs.holder);
  98.171 -        if (!JNU_IsNull(env, holder)) {
  98.172 -            return TRUE;
  98.173 -        }
  98.174 -    }
  98.175 -    return FALSE;
  98.176 -}
  98.177 -
  98.178 -static void losingSelectionOwnership(Widget w, Atom * selection);
  98.179 -
  98.180 -void
  98.181 -awtJNI_notifySelectionLost(JNIEnv * env, char *sel_str)
  98.182 -{
  98.183 -    Atom selection;
  98.184 -
  98.185 -    selection = XInternAtom(awt_display, sel_str, False);
  98.186 -    losingSelectionOwnership(NULL, &selection);
  98.187 -}
  98.188 -
  98.189 -static void
  98.190 -losingSelectionOwnership(Widget w, Atom * selection)
  98.191 -{
  98.192 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  98.193 -    jobject this = getX11Selection(env, *selection);
  98.194 -
  98.195 -    /*
  98.196 -     * SECURITY: OK to call this on privileged thread - peer does
  98.197 -     *         not call into client code
  98.198 -     */
  98.199 -    JNU_CallMethodByName(env, NULL, this, "lostSelectionOwnership", "()V");
  98.200 -    if ((*env)->ExceptionOccurred(env)) {
  98.201 -        (*env)->ExceptionDescribe(env);
  98.202 -        (*env)->ExceptionClear(env);
  98.203 -    }
  98.204 -    /*
  98.205 -     * Fix for 4692059.
  98.206 -     * The native context is cleaned up on the event dispatch thread after the
  98.207 -     * references to the current contents and owner are cleared.
  98.208 -     */
  98.209 -}
  98.210 -
  98.211 -/*
  98.212 - * Class:     sun_awt_motif_X11Selection
  98.213 - * Method:    pGetSelectionOwnership
  98.214 - * Signature: (Ljava/lang/Object;Ljava/awt/datatransfer/Transferable;[JLjava/util/Map;Lsun/awt/motif/X11SelectionHolder;)Z
  98.215 - */
  98.216 -JNIEXPORT jboolean JNICALL
  98.217 -Java_sun_awt_motif_X11Selection_pGetSelectionOwnership(JNIEnv *env,
  98.218 -                                                       jobject this,
  98.219 -                                                       jobject source,
  98.220 -                                                       jobject transferable,
  98.221 -                                                       jlongArray formats,
  98.222 -                                                       jobject formatMap,
  98.223 -                                                       jobject holder)
  98.224 -{
  98.225 -    Boolean gotit = False;
  98.226 -    Atom selection = (Atom)(*env)->GetLongField(env, this,
  98.227 -                                                x11SelectionIDs.atom);
  98.228 -    awt_convertDataCallbackStruct* structPtr = NULL;
  98.229 -    Time time = CurrentTime;
  98.230 -
  98.231 -    AWT_LOCK();
  98.232 -
  98.233 -    time = awt_util_getCurrentServerTime();
  98.234 -
  98.235 -    (*env)->SetObjectField(env, this, x11SelectionIDs.holder, NULL);
  98.236 -    (*env)->SetObjectField(env, this, x11SelectionIDs.contents, NULL);
  98.237 -
  98.238 -    gotit = XtOwnSelection(awt_root_shell, selection, time, awt_convertData,
  98.239 -                           losingSelectionOwnership, NULL);
  98.240 -
  98.241 -    if (gotit) {
  98.242 -        if (XFindContext(awt_display, selection, awt_convertDataContext,
  98.243 -                         (XPointer*)&structPtr) == 0 && structPtr != NULL) {
  98.244 -            (*env)->DeleteGlobalRef(env, structPtr->source);
  98.245 -            (*env)->DeleteGlobalRef(env, structPtr->transferable);
  98.246 -            (*env)->DeleteGlobalRef(env, structPtr->formatMap);
  98.247 -            (*env)->DeleteGlobalRef(env, structPtr->formats);
  98.248 -            memset(structPtr, 0, sizeof(awt_convertDataCallbackStruct));
  98.249 -        } else {
  98.250 -            XDeleteContext(awt_display, selection, awt_convertDataContext);
  98.251 -
  98.252 -            structPtr = calloc(1, sizeof(awt_convertDataCallbackStruct));
  98.253 -
  98.254 -            if (structPtr == NULL) {
  98.255 -                XtDisownSelection(awt_root_shell, selection, time);
  98.256 -                AWT_UNLOCK();
  98.257 -                JNU_ThrowOutOfMemoryError(env, "");
  98.258 -                return JNI_FALSE;
  98.259 -            }
  98.260 -
  98.261 -            if (XSaveContext(awt_display, selection, awt_convertDataContext,
  98.262 -                             (XPointer)structPtr) == XCNOMEM) {
  98.263 -                XtDisownSelection(awt_root_shell, selection, time);
  98.264 -                free(structPtr);
  98.265 -                AWT_UNLOCK();
  98.266 -                JNU_ThrowInternalError(env, "Failed to save context data for selection.");
  98.267 -                return JNI_FALSE;
  98.268 -            }
  98.269 -        }
  98.270 -
  98.271 -        structPtr->source = (*env)->NewGlobalRef(env, source);
  98.272 -        structPtr->transferable = (*env)->NewGlobalRef(env, transferable);
  98.273 -        structPtr->formatMap = (*env)->NewGlobalRef(env, formatMap);
  98.274 -        structPtr->formats = (*env)->NewGlobalRef(env, formats);
  98.275 -
  98.276 -        if (JNU_IsNull(env, structPtr->source) ||
  98.277 -            JNU_IsNull(env, structPtr->transferable) ||
  98.278 -            JNU_IsNull(env, structPtr->formatMap) ||
  98.279 -            JNU_IsNull(env, structPtr->formats)) {
  98.280 -
  98.281 -            if (!JNU_IsNull(env, structPtr->source)) {
  98.282 -                (*env)->DeleteGlobalRef(env, structPtr->source);
  98.283 -            }
  98.284 -            if (!JNU_IsNull(env, structPtr->transferable)) {
  98.285 -                (*env)->DeleteGlobalRef(env, structPtr->transferable);
  98.286 -            }
  98.287 -            if (!JNU_IsNull(env, structPtr->formatMap)) {
  98.288 -                (*env)->DeleteGlobalRef(env, structPtr->formatMap);
  98.289 -            }
  98.290 -            if (!JNU_IsNull(env, structPtr->formats)) {
  98.291 -                (*env)->DeleteGlobalRef(env, structPtr->formats);
  98.292 -            }
  98.293 -            XtDisownSelection(awt_root_shell, selection, time);
  98.294 -            XDeleteContext(awt_display, selection, awt_convertDataContext);
  98.295 -            free(structPtr);
  98.296 -            AWT_UNLOCK();
  98.297 -            JNU_ThrowOutOfMemoryError(env, "");
  98.298 -            return JNI_FALSE;
  98.299 -        }
  98.300 -
  98.301 -        (*env)->SetObjectField(env, this, x11SelectionIDs.holder, holder);
  98.302 -        (*env)->SetObjectField(env, this, x11SelectionIDs.contents, transferable);
  98.303 -    }
  98.304 -    AWT_UNLOCK();
  98.305 -
  98.306 -    return (gotit ? JNI_TRUE : JNI_FALSE);
  98.307 -}
  98.308 -
  98.309 -/*
  98.310 - * Class:     sun_awt_motif_X11Selection
  98.311 - * Method:    clearNativeContext
  98.312 - * Signature: ()V
  98.313 - */
  98.314 -JNIEXPORT void JNICALL
  98.315 -Java_sun_awt_motif_X11Selection_clearNativeContext(JNIEnv *env, jobject this) {
  98.316 -    Atom selection = (Atom)(*env)->GetLongField(env, this,
  98.317 -                                                x11SelectionIDs.atom);
  98.318 -
  98.319 -    AWT_LOCK();
  98.320 -
  98.321 -    XtDisownSelection(awt_root_shell, selection, CurrentTime);
  98.322 -    awt_cleanupConvertDataContext(env, selection);
  98.323 -
  98.324 -    AWT_UNLOCK();
  98.325 -}
  98.326 -
  98.327 -
  98.328 -static void
  98.329 -getSelectionTargetsToCheckChange(Widget w, XtPointer client_data,
  98.330 -        Atom * selection, Atom * type, XtPointer value, unsigned long *length,
  98.331 -        int32_t *format)
  98.332 -{
  98.333 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  98.334 -    size_t count = 0, i = 0, j = 0;
  98.335 -    jlongArray targetArray = NULL;
  98.336 -
  98.337 -    // Should keep this in sync with getSelectionTargets() so that
  98.338 -    // this function yields non-null targetArray iff
  98.339 -    // getSelectionTargets() yields SelectionSuccess.
  98.340 -    if (*type == XA_TARGETS || *type == XA_ATOM) {
  98.341 -        targetArray = getSelectionTargetsHelper(env, value, *length);
  98.342 -    } else if (*type != XT_CONVERT_FAIL) {
  98.343 -        targetArray = (*env)->NewLongArray(env, 0);
  98.344 -    }
  98.345 -
  98.346 -    if (value != NULL) {
  98.347 -        XtFree(value);
  98.348 -        value = NULL;
  98.349 -    }
  98.350 -
  98.351 -    {
  98.352 -        jobject jselection = getX11Selection(env, *selection);
  98.353 -        call_checkChange(env, jselection, targetArray);
  98.354 -        if ((*env)->ExceptionCheck(env)) {
  98.355 -            (*env)->ExceptionDescribe(env);
  98.356 -            (*env)->ExceptionClear(env);
  98.357 -        }
  98.358 -        (*env)->DeleteLocalRef(env, targetArray);
  98.359 -        (*env)->DeleteLocalRef(env, jselection);
  98.360 -    }
  98.361 -}
  98.362 -
  98.363 -
  98.364 -static Atom _XA_JAVA_TIME_PROPERTY_ATOM_CHECK_SELECTION_CHANGE_ON_TIMEOUT = 0;
  98.365 -
  98.366 -static void
  98.367 -checkSelectionChangeOnTimeout(XtPointer client_data, XtIntervalId* id)
  98.368 -{
  98.369 -    // We don't call XtGetSelectionValue(..., TARGETS, ..., awt_util_getCurrentServerTime())
  98.370 -    // here because awt_util_getCurrentServerTime() may block toolkit therad for a while
  98.371 -    // whereas the current function is called very often at regular intervals.
  98.372 -    // Instead we call XtGetSelectionValue(..., XtLastTimestampProcessed(awt_display))
  98.373 -    // in the property change event handler wherein we have got an up-to-date timestamp.
  98.374 -
  98.375 -    XChangeProperty(awt_display, XtWindow(awt_root_shell),
  98.376 -                    _XA_JAVA_TIME_PROPERTY_ATOM_CHECK_SELECTION_CHANGE_ON_TIMEOUT,
  98.377 -                    XA_ATOM, 32, PropModeAppend, (unsigned char *)"", 0);
  98.378 -    XFlush(awt_display);
  98.379 -}
  98.380 -
  98.381 -
  98.382 -static unsigned long selectionPollInterval;
  98.383 -
  98.384 -static void
  98.385 -propertyChangeEventHandlerToSelectionCheck
  98.386 -(Widget w, XtPointer client_data, XEvent* event, Boolean* continue_to_dispatch)
  98.387 -{
  98.388 -    JNIEnv *env;
  98.389 -    jlongArray jselectionAtoms;
  98.390 -
  98.391 -    if (event->type != PropertyNotify || event->xproperty.atom !=
  98.392 -            _XA_JAVA_TIME_PROPERTY_ATOM_CHECK_SELECTION_CHANGE_ON_TIMEOUT) {
  98.393 -        return;
  98.394 -    }
  98.395 -
  98.396 -    env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  98.397 -    jselectionAtoms = call_getSelectionAtomsToCheckChange(env);
  98.398 -
  98.399 -    DASSERT(!JNU_IsNull(env, jselectionAtoms));
  98.400 -    if ((*env)->ExceptionCheck(env)) {
  98.401 -        (*env)->ExceptionDescribe(env);
  98.402 -        (*env)->ExceptionClear(env);
  98.403 -    } else {
  98.404 -        jsize len = (*env)->GetArrayLength(env, jselectionAtoms);
  98.405 -        jlong* selectionAtomsNative =
  98.406 -                (*env)->GetLongArrayElements(env, jselectionAtoms, NULL);
  98.407 -        if (!JNU_IsNull(env, selectionAtomsNative)) {
  98.408 -            jsize i = 0;
  98.409 -            for (i = 0; i < len; i++) {
  98.410 -                XtGetSelectionValue(awt_root_shell, (Atom)selectionAtomsNative[i], XA_TARGETS,
  98.411 -                                    getSelectionTargetsToCheckChange, (XtPointer)NULL,
  98.412 -                                    XtLastTimestampProcessed(awt_display));
  98.413 -            }
  98.414 -            (*env)->ReleaseLongArrayElements(env, jselectionAtoms,
  98.415 -                                             selectionAtomsNative, JNI_ABORT);
  98.416 -        }
  98.417 -    }
  98.418 -
  98.419 -    // Reschedule the timer callback.
  98.420 -    XtAppAddTimeOut(awt_appContext, selectionPollInterval,
  98.421 -                    checkSelectionChangeOnTimeout, client_data);
  98.422 -}
  98.423 -
  98.424 -
  98.425 -static BOOL isClipboardViewerRegistered = FALSE;
  98.426 -
  98.427 -/*
  98.428 - * Class:     sun_awt_motif_X11Clipboard
  98.429 - * Method:    registerClipboardViewer
  98.430 - * Signature: (I)V
  98.431 - */
  98.432 -JNIEXPORT void JNICALL
  98.433 -Java_sun_awt_motif_X11Clipboard_registerClipboardViewer(JNIEnv *env, jobject self,
  98.434 -                                                        jint pollInterval)
  98.435 -{
  98.436 -    AWT_LOCK();
  98.437 -
  98.438 -    if (isClipboardViewerRegistered) {
  98.439 -        AWT_UNLOCK();
  98.440 -        return;
  98.441 -    }
  98.442 -
  98.443 -    if (_XA_JAVA_TIME_PROPERTY_ATOM_CHECK_SELECTION_CHANGE_ON_TIMEOUT == 0) {
  98.444 -        _XA_JAVA_TIME_PROPERTY_ATOM_CHECK_SELECTION_CHANGE_ON_TIMEOUT =
  98.445 -                XInternAtom(awt_display,
  98.446 -                            "_SUNW_JAVA_AWT_TIME_CHECK_SELECTION_CHANGE_ON_TIMEOUT",
  98.447 -                            False);
  98.448 -    }
  98.449 -
  98.450 -    XtAddEventHandler(awt_root_shell, PropertyChangeMask, False,
  98.451 -                      propertyChangeEventHandlerToSelectionCheck, NULL);
  98.452 -
  98.453 -    selectionPollInterval = pollInterval;
  98.454 -
  98.455 -    XtAppAddTimeOut(awt_appContext, selectionPollInterval,
  98.456 -                    checkSelectionChangeOnTimeout, (XtPointer)NULL);
  98.457 -
  98.458 -    isClipboardViewerRegistered = TRUE;
  98.459 -
  98.460 -    AWT_UNLOCK();
  98.461 -}
  98.462 -
  98.463 -/*
  98.464 - * Class:     sun_awt_motif_X11Clipboard
  98.465 - * Method:    unregisterClipboardViewer
  98.466 - * Signature: ()V
  98.467 - */
  98.468 -JNIEXPORT void JNICALL
  98.469 -Java_sun_awt_motif_X11Clipboard_unregisterClipboardViewer(JNIEnv *env, jobject self)
  98.470 -{
  98.471 -    AWT_LOCK();
  98.472 -
  98.473 -    if (!isClipboardViewerRegistered) {
  98.474 -        AWT_UNLOCK();
  98.475 -        return;
  98.476 -    }
  98.477 -
  98.478 -    XtRemoveEventHandler(awt_root_shell, PropertyChangeMask, False,
  98.479 -                         propertyChangeEventHandlerToSelectionCheck, NULL);
  98.480 -
  98.481 -    isClipboardViewerRegistered = FALSE;
  98.482 -
  98.483 -    AWT_UNLOCK();
  98.484 -}
  98.485 -
  98.486 -
  98.487 -/*
  98.488 - * Class:     sun_awt_motif_X11Clipboard
  98.489 - * Method:    getClipboardFormats
  98.490 - * Signature: (J)[J
  98.491 - */
  98.492 -JNIEXPORT jlongArray JNICALL
  98.493 -Java_sun_awt_motif_X11Clipboard_getClipboardFormats
  98.494 -    (JNIEnv *env, jclass cls, jlong selectionAtom)
  98.495 -{
  98.496 -    Time time_stamp = awt_util_getCurrentServerTime();
  98.497 -    return get_selection_targets(env, selectionAtom, time_stamp);
  98.498 -}
  98.499 -
  98.500 -/*
  98.501 - * Class:     sun_awt_motif_X11Clipboard
  98.502 - * Method:    getClipboardData
  98.503 - * Signature: (JJ)[B
  98.504 - */
  98.505 -JNIEXPORT jbyteArray JNICALL
  98.506 -Java_sun_awt_motif_X11Clipboard_getClipboardData
  98.507 -    (JNIEnv *env, jclass cls, jlong selectionAtom, jlong format)
  98.508 -{
  98.509 -    Time time_stamp = awt_util_getCurrentServerTime();
  98.510 -    return get_selection_data(env, selectionAtom, format, time_stamp);
  98.511 -}
    99.1 --- a/src/solaris/native/sun/awt/awt_TextArea.c	Wed Sep 17 13:45:37 2008 -0700
    99.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    99.3 @@ -1,1003 +0,0 @@
    99.4 -/*
    99.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
    99.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    99.7 - *
    99.8 - * This code is free software; you can redistribute it and/or modify it
    99.9 - * under the terms of the GNU General Public License version 2 only, as
   99.10 - * published by the Free Software Foundation.  Sun designates this
   99.11 - * particular file as subject to the "Classpath" exception as provided
   99.12 - * by Sun in the LICENSE file that accompanied this code.
   99.13 - *
   99.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   99.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   99.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   99.17 - * version 2 for more details (a copy is included in the LICENSE file that
   99.18 - * accompanied this code).
   99.19 - *
   99.20 - * You should have received a copy of the GNU General Public License version
   99.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   99.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   99.23 - *
   99.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   99.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
   99.26 - * have any questions.
   99.27 - */
   99.28 -
   99.29 -#ifdef HEADLESS
   99.30 -    #error This file should not be included in headless library
   99.31 -#endif
   99.32 -
   99.33 -#include "awt_p.h"
   99.34 -#include "canvas.h"
   99.35 -#include "java_awt_TextArea.h"
   99.36 -#include "java_awt_Cursor.h"
   99.37 -#include "java_awt_Component.h"
   99.38 -#include "java_awt_Color.h"
   99.39 -#include "java_awt_AWTEvent.h"
   99.40 -#include "java_awt_Font.h"
   99.41 -#include "java_awt_event_MouseWheelEvent.h"
   99.42 -#include "sun_awt_motif_MTextAreaPeer.h"
   99.43 -#include "sun_awt_motif_MComponentPeer.h"
   99.44 -
   99.45 -#include "awt_Component.h"
   99.46 -#include "awt_Cursor.h"
   99.47 -#include "awt_TextArea.h"
   99.48 -
   99.49 -#include <jni.h>
   99.50 -#include <jni_util.h>
   99.51 -#include "multi_font.h"
   99.52 -
   99.53 -extern struct MComponentPeerIDs mComponentPeerIDs;
   99.54 -extern struct CursorIDs cursorIDs;
   99.55 -extern AwtGraphicsConfigDataPtr
   99.56 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
   99.57 -struct TextAreaIDs textAreaIDs;
   99.58 -struct MTextAreaPeerIDs mTextAreaPeerIDs;
   99.59 -
   99.60 -/*
   99.61 - * Class:     java_awt_TextArea
   99.62 - * Method:    initIDs
   99.63 - * Signature: ()V
   99.64 - */
   99.65 -
   99.66 -/* This function gets called from the static initializer for TextArea.java
   99.67 -   to initialize the fieldIDs for fields that may be accessed from C */
   99.68 -
   99.69 -JNIEXPORT void JNICALL
   99.70 -Java_java_awt_TextArea_initIDs
   99.71 -  (JNIEnv *env, jclass cls)
   99.72 -{
   99.73 -    textAreaIDs.scrollbarVisibility =
   99.74 -      (*env)->GetFieldID(env, cls, "scrollbarVisibility", "I");
   99.75 -}
   99.76 -
   99.77 -/*
   99.78 - * Class:     sun_awt_motif_MTextAreaPeer
   99.79 - * Method:    initIDs
   99.80 - * Signature: ()V
   99.81 - */
   99.82 -
   99.83 -/* This function gets called from the static initializer for
   99.84 -   MTextAreaPeer.java to initialize the fieldIDs for fields that may
   99.85 -   be accessed from C */
   99.86 -JNIEXPORT void JNICALL
   99.87 -Java_sun_awt_motif_MTextAreaPeer_initIDs
   99.88 -  (JNIEnv *env, jclass cls)
   99.89 -{
   99.90 -    mTextAreaPeerIDs.firstChangeSkipped =
   99.91 -      (*env)->GetFieldID(env, cls, "firstChangeSkipped", "Z");
   99.92 -}
   99.93 -
   99.94 -/*
   99.95 - * client_data is MTextAreaPeer instance
   99.96 - */
   99.97 -void
   99.98 -TextArea_valueChanged(Widget w, XtPointer client_data, XtPointer call_data)
   99.99 -{
  99.100 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  99.101 -    jboolean skipped;
  99.102 -
  99.103 -    skipped = (*env)->GetBooleanField(env, (jobject) client_data,
  99.104 -                                      mTextAreaPeerIDs.firstChangeSkipped);
  99.105 -    if (!(*env)->ExceptionOccurred(env)) {
  99.106 -        if (skipped == JNI_FALSE) {
  99.107 -            (*env)->SetBooleanField(env, (jobject) client_data,
  99.108 -                                    mTextAreaPeerIDs.firstChangeSkipped,
  99.109 -                                    JNI_TRUE);
  99.110 -        } else {
  99.111 -            JNU_CallMethodByName(env, NULL, (jobject) client_data,
  99.112 -                                 "valueChanged", "()V");
  99.113 -        }
  99.114 -    }
  99.115 -
  99.116 -    if ((*env)->ExceptionOccurred(env)) {
  99.117 -        (*env)->ExceptionDescribe(env);
  99.118 -        (*env)->ExceptionClear(env);
  99.119 -    }
  99.120 -}
  99.121 -
  99.122 -extern void Text_handlePaste(Widget w, XtPointer client_data, XEvent * event,
  99.123 -                             Boolean * cont);
  99.124 -
  99.125 -/*
  99.126 - * Class:     sun_awt_motif_MTextAreaPeer
  99.127 - * Method:    pCreate
  99.128 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
  99.129 - */
  99.130 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_pCreate
  99.131 -  (JNIEnv *env, jobject this, jobject parent)
  99.132 -{
  99.133 -    struct TextAreaData *tdata;
  99.134 -#define MAX_ARGC 30
  99.135 -    Arg args[MAX_ARGC];
  99.136 -    int32_t argc;
  99.137 -    struct ComponentData *wdata;
  99.138 -    jobject target;
  99.139 -    Pixel bg;
  99.140 -    int32_t sbVisibility;
  99.141 -    Boolean wordWrap = False, hsb = False, vsb = False;
  99.142 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
  99.143 -    AwtGraphicsConfigDataPtr adata;
  99.144 -    char *nonEmptyText = "* will never be shown *";
  99.145 -
  99.146 -    AWT_LOCK();
  99.147 -
  99.148 -    adata = copyGraphicsConfigToPeer(env, this);
  99.149 -
  99.150 -    if (JNU_IsNull(env, parent)) {
  99.151 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.152 -        AWT_UNLOCK();
  99.153 -        return;
  99.154 -    }
  99.155 -    wdata = (struct ComponentData *)
  99.156 -        JNU_GetLongFieldAsPtr(env,parent,mComponentPeerIDs.pData);
  99.157 -    if (wdata == NULL) {
  99.158 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.159 -        AWT_UNLOCK();
  99.160 -        return;
  99.161 -    }
  99.162 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
  99.163 -
  99.164 -    tdata = ZALLOC(TextAreaData);
  99.165 -    JNU_SetLongFieldFromPtr(env,this,mComponentPeerIDs.pData,tdata);
  99.166 -
  99.167 -    if (tdata == NULL) {
  99.168 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
  99.169 -        AWT_UNLOCK();
  99.170 -        return;
  99.171 -    }
  99.172 -    XtVaGetValues(wdata->widget, XmNbackground, &bg, NULL);
  99.173 -
  99.174 -    sbVisibility = (*env)->GetIntField(env, target,
  99.175 -                                       textAreaIDs.scrollbarVisibility);
  99.176 -    switch (sbVisibility) {
  99.177 -        case java_awt_TextArea_SCROLLBARS_NONE:
  99.178 -            wordWrap = True;
  99.179 -            hsb = False;
  99.180 -            vsb = False;
  99.181 -            break;
  99.182 -
  99.183 -        case java_awt_TextArea_SCROLLBARS_VERTICAL_ONLY:
  99.184 -            wordWrap = True;
  99.185 -            hsb = False;
  99.186 -            vsb = True;
  99.187 -            break;
  99.188 -
  99.189 -        case java_awt_TextArea_SCROLLBARS_HORIZONTAL_ONLY:
  99.190 -            wordWrap = False;
  99.191 -            hsb = True;
  99.192 -            vsb = False;
  99.193 -            break;
  99.194 -
  99.195 -        default:
  99.196 -        case java_awt_TextArea_SCROLLBARS_BOTH:
  99.197 -            wordWrap = False;
  99.198 -            hsb = True;
  99.199 -            vsb = True;
  99.200 -            break;
  99.201 -    }
  99.202 -
  99.203 -    argc = 0;
  99.204 -    XtSetArg(args[argc], XmNrecomputeSize, False);
  99.205 -    argc++;
  99.206 -    XtSetArg(args[argc], XmNx, 0);
  99.207 -    argc++;
  99.208 -    XtSetArg(args[argc], XmNy, 0);
  99.209 -    argc++;
  99.210 -    XtSetArg(args[argc], XmNbackground, bg);
  99.211 -    argc++;
  99.212 -    XtSetArg(args[argc], XmNeditMode, XmMULTI_LINE_EDIT);
  99.213 -    argc++;
  99.214 -    XtSetArg(args[argc], XmNwordWrap, wordWrap);
  99.215 -    argc++;
  99.216 -    XtSetArg(args[argc], XmNscrollHorizontal, hsb);
  99.217 -    argc++;
  99.218 -    XtSetArg(args[argc], XmNscrollVertical, vsb);
  99.219 -    argc++;
  99.220 -    XtSetArg(args[argc], XmNmarginHeight, 2);
  99.221 -    argc++;
  99.222 -    XtSetArg(args[argc], XmNmarginWidth, 2);
  99.223 -    argc++;
  99.224 -    XtSetArg(args[argc], XmNuserData, (XtPointer) globalRef);
  99.225 -    argc++;
  99.226 -    XtSetArg (args[argc], XmNscreen,
  99.227 -              ScreenOfDisplay(awt_display,
  99.228 -                              adata->awt_visInfo.screen));
  99.229 -    argc++;
  99.230 -    XtSetArg(args[argc], XmNfontList, getMotifFontList());
  99.231 -    argc++;
  99.232 -
  99.233 -    /* Initialize with a non-empty text, so the
  99.234 -     * TextArea_valueChanged callback will be called
  99.235 -     * even if the following conditions are true:
  99.236 -     * 1. TextArea constructed with an empty initial text.
  99.237 -     * 2. setText() with an empty argument is called
  99.238 -     *    immediately after the TextArea component is created.
  99.239 -     * For more details please see #4028580.
  99.240 -     */
  99.241 -    XtSetArg(args[argc], XmNvalue, nonEmptyText);
  99.242 -    argc++;
  99.243 -
  99.244 -    DASSERT(!(argc > MAX_ARGC));
  99.245 -    tdata->txt = XmCreateScrolledText(wdata->widget, "textA",
  99.246 -                                      args, argc);
  99.247 -    tdata->comp.widget = XtParent(tdata->txt);
  99.248 -
  99.249 -    /* Bug 4208972. Give the ScrolledWindow a minimum size. */
  99.250 -    XtVaSetValues(tdata->comp.widget,
  99.251 -        XmNwidth,  1,
  99.252 -        XmNheight, 1, NULL);
  99.253 -
  99.254 -    XtSetMappedWhenManaged(tdata->comp.widget, False);
  99.255 -    XtManageChild(tdata->txt);
  99.256 -    XtManageChild(tdata->comp.widget);
  99.257 -
  99.258 -    XtAddCallback(tdata->txt,
  99.259 -                  XmNvalueChangedCallback,
  99.260 -                  TextArea_valueChanged,
  99.261 -                  (XtPointer) globalRef);
  99.262 -
  99.263 -    XtAddEventHandler(tdata->txt, FocusChangeMask,
  99.264 -                      True, awt_canvas_event_handler, globalRef);
  99.265 -
  99.266 -    XtInsertEventHandler(tdata->txt,
  99.267 -                         KeyPressMask,
  99.268 -                         False, Text_handlePaste, (XtPointer) globalRef,
  99.269 -                         XtListHead);
  99.270 -
  99.271 -    awt_addWidget(tdata->txt, tdata->comp.widget, globalRef,
  99.272 -                  java_awt_AWTEvent_KEY_EVENT_MASK |
  99.273 -                  java_awt_AWTEvent_MOUSE_EVENT_MASK |
  99.274 -                  java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK);
  99.275 -    /*
  99.276 -     * Fix for BugTraq ID 4349615.
  99.277 -     * Unregister Motif drop site to prevent it from crash
  99.278 -     * when dropping java objects.
  99.279 -     */
  99.280 -    XmDropSiteUnregister(tdata->txt);
  99.281 -
  99.282 -    AWT_UNLOCK();
  99.283 -}
  99.284 -
  99.285 -/*
  99.286 - * Class:     sun_awt_motif_MTextAreaPeer
  99.287 - * Method:    getExtraWidth
  99.288 - * Signature: ()I
  99.289 - */
  99.290 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MTextAreaPeer_getExtraWidth
  99.291 -  (JNIEnv *env, jobject this)
  99.292 -{
  99.293 -    struct TextAreaData *tdata;
  99.294 -    Dimension spacing, shadowThickness, textMarginWidth, sbWidth;
  99.295 -    Widget verticalScrollBar;
  99.296 -
  99.297 -    AWT_LOCK();
  99.298 -
  99.299 -    tdata = (struct TextAreaData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.300 -
  99.301 -    if (tdata == NULL || tdata->txt == NULL) {
  99.302 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.303 -        AWT_UNLOCK();
  99.304 -        return 0;
  99.305 -    }
  99.306 -    XtVaGetValues(tdata->txt, XmNmarginWidth, &textMarginWidth, NULL);
  99.307 -    XtVaGetValues(tdata->comp.widget,
  99.308 -                  XmNspacing, &spacing,
  99.309 -                  XmNverticalScrollBar, &verticalScrollBar,
  99.310 -                  NULL);
  99.311 -    if (verticalScrollBar != NULL) {
  99.312 -        /* Assumption:  shadowThickness same for scrollbars and text area */
  99.313 -        XtVaGetValues(verticalScrollBar,
  99.314 -                      XmNwidth, &sbWidth,
  99.315 -                      XmNshadowThickness, &shadowThickness,
  99.316 -                      NULL);
  99.317 -    } else {
  99.318 -        sbWidth = 0;
  99.319 -        shadowThickness = 0;
  99.320 -    }
  99.321 -
  99.322 -    AWT_UNLOCK();
  99.323 -
  99.324 -    return (jint) (sbWidth + spacing + 2 * textMarginWidth + 4 * shadowThickness);
  99.325 -}
  99.326 -
  99.327 -/*
  99.328 - * Class:     sun_awt_motif_MTextAreaPeer
  99.329 - * Method:    getExtraHeight
  99.330 - * Signature: ()I
  99.331 - */
  99.332 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MTextAreaPeer_getExtraHeight
  99.333 -  (JNIEnv *env, jobject this)
  99.334 -{
  99.335 -    struct TextAreaData *tdata;
  99.336 -    Dimension spacing, shadowThickness, textMarginHeight, sbHeight;
  99.337 -    Dimension sbShadowThickness, highlightThickness, sbHighlightThickness;
  99.338 -    int32_t height;
  99.339 -    Widget horizontalScrollBar;
  99.340 -
  99.341 -    AWT_LOCK();
  99.342 -
  99.343 -    tdata = (struct TextAreaData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.344 -
  99.345 -    if (tdata == NULL || tdata->txt == NULL) {
  99.346 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.347 -        AWT_UNLOCK();
  99.348 -        return 0;
  99.349 -    }
  99.350 -
  99.351 -    XtVaGetValues(tdata->txt, XmNmarginHeight, &textMarginHeight,
  99.352 -                              XmNshadowThickness, &shadowThickness,
  99.353 -                              XmNhighlightThickness, &highlightThickness, NULL);
  99.354 -    height = 2 * (textMarginHeight + shadowThickness + highlightThickness);
  99.355 -
  99.356 -    XtVaGetValues(tdata->comp.widget,
  99.357 -                  XmNspacing, &spacing,
  99.358 -                  XmNhorizontalScrollBar, &horizontalScrollBar,
  99.359 -                  NULL);
  99.360 -
  99.361 -    if (horizontalScrollBar != NULL) {
  99.362 -        XtVaGetValues(horizontalScrollBar,
  99.363 -                      XmNshadowThickness, &sbShadowThickness,
  99.364 -                      XmNhighlightThickness, &sbHighlightThickness,
  99.365 -                      XmNheight, &sbHeight,
  99.366 -                      NULL);
  99.367 -        height += sbHeight + spacing
  99.368 -                + 2 * (sbShadowThickness + sbHighlightThickness);
  99.369 -    }
  99.370 -
  99.371 -    AWT_UNLOCK();
  99.372 -
  99.373 -    return (jint)height;
  99.374 -}
  99.375 -
  99.376 -/*
  99.377 - * Class:     sun_awt_motif_MTextAreaPeer
  99.378 - * Method:    setTextBackground
  99.379 - * Signature: (Ljava/awt/Color;)V
  99.380 - */
  99.381 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_setTextBackground
  99.382 -  (JNIEnv *env, jobject this, jobject c)
  99.383 -{
  99.384 -    struct TextAreaData *tdata;
  99.385 -    Pixel color;
  99.386 -
  99.387 -    AWT_LOCK();
  99.388 -
  99.389 -    tdata = (struct TextAreaData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.390 -
  99.391 -    if (tdata == NULL || tdata->txt == NULL || JNU_IsNull(env, c)) {
  99.392 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.393 -        AWT_UNLOCK();
  99.394 -        return;
  99.395 -    }
  99.396 -    color = awtJNI_GetColor(env, c);
  99.397 -    XtVaSetValues(tdata->txt,
  99.398 -                  XmNbackground, color,
  99.399 -                  NULL);
  99.400 -
  99.401 -    AWT_FLUSH_UNLOCK();
  99.402 -}
  99.403 -
  99.404 -/*
  99.405 - * Class:     sun_awt_motif_MTextAreaPeer
  99.406 - * Method:    pSetEditable
  99.407 - * Signature: (Z)V
  99.408 - */
  99.409 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_pSetEditable
  99.410 -  (JNIEnv *env, jobject this, jboolean editable)
  99.411 -{
  99.412 -    struct TextAreaData *tdata;
  99.413 -
  99.414 -    AWT_LOCK();
  99.415 -
  99.416 -    tdata = (struct TextAreaData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.417 -
  99.418 -    if (tdata == NULL || tdata->txt == NULL) {
  99.419 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.420 -        AWT_UNLOCK();
  99.421 -        return;
  99.422 -    }
  99.423 -    XtVaSetValues(tdata->txt,
  99.424 -                  XmNeditable, (editable ? True : False),
  99.425 -                  XmNcursorPositionVisible, (editable ? True : False),
  99.426 -                  NULL);
  99.427 -
  99.428 -    AWT_FLUSH_UNLOCK();
  99.429 -}
  99.430 -
  99.431 -/*
  99.432 - * Class:     sun_awt_motif_MTextAreaPeer
  99.433 - * Method:    select
  99.434 - * Signature: (II)V
  99.435 - */
  99.436 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_select
  99.437 -  (JNIEnv *env, jobject this, jint start, jint end)
  99.438 -{
  99.439 -    struct TextAreaData *tdata;
  99.440 -
  99.441 -    AWT_LOCK();
  99.442 -
  99.443 -    tdata = (struct TextAreaData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.444 -
  99.445 -    if (tdata == NULL || tdata->txt == NULL) {
  99.446 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.447 -        AWT_UNLOCK();
  99.448 -        return;
  99.449 -    }
  99.450 -    XmTextSetSelection(tdata->txt, (XmTextPosition) start, (XmTextPosition) end, 0);
  99.451 -    AWT_FLUSH_UNLOCK();
  99.452 -}
  99.453 -
  99.454 -/*
  99.455 - * Class:     sun_awt_motif_MTextAreaPeer
  99.456 - * Method:    getSelectionStart
  99.457 - * Signature: ()I
  99.458 - */
  99.459 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MTextAreaPeer_getSelectionStart
  99.460 -  (JNIEnv *env, jobject this)
  99.461 -{
  99.462 -    struct TextAreaData *tdata;
  99.463 -    XmTextPosition start, end, pos;
  99.464 -
  99.465 -    AWT_LOCK();
  99.466 -
  99.467 -    tdata = (struct TextAreaData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.468 -
  99.469 -    if (tdata == NULL || tdata->txt == NULL) {
  99.470 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.471 -        AWT_UNLOCK();
  99.472 -        return 0;
  99.473 -    }
  99.474 -    if (XmTextGetSelectionPosition(tdata->txt, &start, &end) &&
  99.475 -                                             (start != end)) {
  99.476 -        pos = start;
  99.477 -    } else {
  99.478 -        pos = XmTextGetInsertionPosition(tdata->txt);
  99.479 -    }
  99.480 -    AWT_UNLOCK();
  99.481 -
  99.482 -    return (jint) pos;
  99.483 -}
  99.484 -
  99.485 -/*
  99.486 - * Class:     sun_awt_motif_MTextAreaPeer
  99.487 - * Method:    getSelectionEnd
  99.488 - * Signature: ()I
  99.489 - */
  99.490 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MTextAreaPeer_getSelectionEnd
  99.491 -  (JNIEnv *env, jobject this)
  99.492 -{
  99.493 -    struct TextAreaData *tdata;
  99.494 -    XmTextPosition start, end, pos;
  99.495 -
  99.496 -    AWT_LOCK();
  99.497 -
  99.498 -    tdata = (struct TextAreaData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.499 -    if (tdata == NULL || tdata->txt == NULL) {
  99.500 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.501 -        AWT_UNLOCK();
  99.502 -        return 0;
  99.503 -    }
  99.504 -    if (XmTextGetSelectionPosition(tdata->txt, &start, &end) &&
  99.505 -                                             (start != end)) {
  99.506 -        pos = end;
  99.507 -    } else {
  99.508 -        pos = XmTextGetInsertionPosition(tdata->txt);
  99.509 -    }
  99.510 -    AWT_UNLOCK();
  99.511 -
  99.512 -    return (jint) pos;
  99.513 -}
  99.514 -
  99.515 -/*
  99.516 - * Class:     sun_awt_motif_MTextAreaPeer
  99.517 - * Method:    setText
  99.518 - * Signature: (Ljava/lang/String;)V
  99.519 - */
  99.520 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_setText
  99.521 -  (JNIEnv *env, jobject this, jstring txt)
  99.522 -{
  99.523 -    struct TextAreaData *tdata;
  99.524 -    char *cTxt;
  99.525 -    jobject font = awtJNI_GetFont(env, this);
  99.526 -
  99.527 -    if (JNU_IsNull(env, txt)) {
  99.528 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.529 -        return;
  99.530 -    }
  99.531 -    AWT_LOCK();
  99.532 -
  99.533 -    tdata = (struct TextAreaData *)
  99.534 -      JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.535 -    if (tdata == NULL || tdata->txt == NULL) {
  99.536 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.537 -        AWT_UNLOCK();
  99.538 -        return;
  99.539 -    }
  99.540 -    cTxt = (char *) JNU_GetStringPlatformChars(env, txt, NULL);
  99.541 -
  99.542 -    if (cTxt == NULL) {
  99.543 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.544 -        AWT_UNLOCK();
  99.545 -        return;
  99.546 -    }
  99.547 -    XtVaSetValues(tdata->txt, XmNvalue, cTxt, NULL);
  99.548 -
  99.549 -    if (cTxt != NULL) {
  99.550 -        JNU_ReleaseStringPlatformChars(env, txt, cTxt);
  99.551 -    }
  99.552 -    AWT_FLUSH_UNLOCK();
  99.553 -}
  99.554 -
  99.555 -/*
  99.556 - * Class:     sun_awt_motif_MTextAreaPeer
  99.557 - * Method:    getText
  99.558 - * Signature: ()Ljava/lang/String;
  99.559 - */
  99.560 -JNIEXPORT jstring JNICALL Java_sun_awt_motif_MTextAreaPeer_getText
  99.561 -  (JNIEnv *env, jobject this)
  99.562 -{
  99.563 -    struct TextAreaData *tdata;
  99.564 -    char *cTxt;
  99.565 -    jstring rval;
  99.566 -    jobject font = awtJNI_GetFont(env, this);
  99.567 -
  99.568 -    AWT_LOCK();
  99.569 -
  99.570 -    tdata = (struct TextAreaData *)
  99.571 -      JNU_GetLongFieldAsPtr(env,this, mComponentPeerIDs.pData);
  99.572 -    if (tdata == NULL || tdata->txt == NULL) {
  99.573 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.574 -        AWT_UNLOCK();
  99.575 -        return NULL;
  99.576 -    }
  99.577 -    cTxt = XmTextGetString(tdata->txt);
  99.578 -
  99.579 -    rval = JNU_NewStringPlatform(env, (const char *) cTxt);
  99.580 -
  99.581 -    XtFree(cTxt);
  99.582 -
  99.583 -    AWT_UNLOCK();
  99.584 -
  99.585 -    return rval;
  99.586 -}
  99.587 -
  99.588 -/*
  99.589 - * Class:     sun_awt_motif_MTextAreaPeer
  99.590 - * Method:    insert
  99.591 - * Signature: (Ljava/lang/String;I)V
  99.592 - */
  99.593 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_insert
  99.594 -  (JNIEnv *env, jobject this, jstring txt, jint pos)
  99.595 -{
  99.596 -    struct TextAreaData *tdata;
  99.597 -    char *cTxt;
  99.598 -    jobject font = awtJNI_GetFont(env, this);
  99.599 -
  99.600 -    if (JNU_IsNull(env, txt)) {
  99.601 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.602 -        return;
  99.603 -    }
  99.604 -    AWT_LOCK();
  99.605 -    tdata = (struct TextAreaData *)
  99.606 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  99.607 -    if (tdata == NULL || tdata->txt == NULL) {
  99.608 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.609 -        AWT_UNLOCK();
  99.610 -        return;
  99.611 -    }
  99.612 -    cTxt = (char *) JNU_GetStringPlatformChars(env, txt, NULL);
  99.613 -
  99.614 -    if (cTxt == NULL) {
  99.615 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.616 -        AWT_UNLOCK();
  99.617 -        return;
  99.618 -    }
  99.619 -    XmTextInsert(tdata->txt, (XmTextPosition) pos, cTxt);
  99.620 -
  99.621 -    if (cTxt != NULL) {
  99.622 -        JNU_ReleaseStringPlatformChars(env, txt, cTxt);
  99.623 -    }
  99.624 -    AWT_FLUSH_UNLOCK();
  99.625 -}
  99.626 -
  99.627 -/*
  99.628 - * Class:     sun_awt_motif_MTextAreaPeer
  99.629 - * Method:    replaceRange
  99.630 - * Signature: (Ljava/lang/String;II)V
  99.631 - */
  99.632 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_replaceRange
  99.633 -  (JNIEnv *env, jobject this, jstring txt, jint start, jint end)
  99.634 -{
  99.635 -    struct TextAreaData *tdata;
  99.636 -    char *cTxt;
  99.637 -    jobject font = awtJNI_GetFont(env, this);
  99.638 -
  99.639 -    if (JNU_IsNull(env, txt)) {
  99.640 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.641 -        return;
  99.642 -    }
  99.643 -    AWT_LOCK();
  99.644 -    tdata = (struct TextAreaData *)
  99.645 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  99.646 -    if (tdata == NULL || tdata->txt == NULL) {
  99.647 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.648 -        AWT_UNLOCK();
  99.649 -        return;
  99.650 -    }
  99.651 -    cTxt = (char *) JNU_GetStringPlatformChars(env, txt, NULL);
  99.652 -
  99.653 -    if (cTxt == NULL) {
  99.654 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.655 -        AWT_UNLOCK();
  99.656 -        return;
  99.657 -    }
  99.658 -    XmTextReplace(tdata->txt,
  99.659 -                  (XmTextPosition) start,
  99.660 -                  (XmTextPosition) end,
  99.661 -                  cTxt);
  99.662 -
  99.663 -    if (cTxt != NULL) {
  99.664 -        JNU_ReleaseStringPlatformChars(env, txt, cTxt);
  99.665 -    }
  99.666 -    AWT_FLUSH_UNLOCK();
  99.667 -}
  99.668 -
  99.669 -/*
  99.670 - * Class:     sun_awt_motif_MTextAreaPeer
  99.671 - * Method:    setFont
  99.672 - * Signature: (Ljava/awt/Font;)V
  99.673 - */
  99.674 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_setFont
  99.675 -  (JNIEnv *env, jobject this, jobject f)
  99.676 -{
  99.677 -    struct TextAreaData *tdata;
  99.678 -    struct FontData *fdata;
  99.679 -    XmFontList fontlist;
  99.680 -    char *err;
  99.681 -    XmFontListEntry fontentry;
  99.682 -
  99.683 -    if (JNU_IsNull(env, f)) {
  99.684 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.685 -        return;
  99.686 -    }
  99.687 -    AWT_LOCK();
  99.688 -
  99.689 -    fdata = awtJNI_GetFontData(env, f, &err);
  99.690 -    if (fdata == NULL) {
  99.691 -        JNU_ThrowInternalError(env, err);
  99.692 -        AWT_UNLOCK();
  99.693 -        return;
  99.694 -    }
  99.695 -    tdata = (struct TextAreaData *)
  99.696 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  99.697 -    if (tdata == NULL || tdata->comp.widget == NULL) {
  99.698 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.699 -        AWT_UNLOCK();
  99.700 -        return;
  99.701 -    }
  99.702 -    if (awtJNI_IsMultiFont(env, f)) {
  99.703 -        if (fdata->xfs == NULL) {
  99.704 -            fdata->xfs = awtJNI_MakeFontSet(env, f);
  99.705 -        }
  99.706 -        if (fdata->xfs != NULL) {
  99.707 -            fontentry = XmFontListEntryCreate("labelFont",
  99.708 -                                              XmFONT_IS_FONTSET,
  99.709 -                                              (XtPointer) (fdata->xfs));
  99.710 -            fontlist = XmFontListAppendEntry(NULL, fontentry);
  99.711 -            /*
  99.712 -             * Some versions of motif have a bug in
  99.713 -             * XmFontListEntryFree() which causes it to free more than it
  99.714 -             * should.  Use XtFree() instead.  See O'Reilly's
  99.715 -             * Motif Reference Manual for more information.
  99.716 -             */
  99.717 -            XmFontListEntryFree(&fontentry);
  99.718 -
  99.719 -        } else {
  99.720 -            fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  99.721 -        }
  99.722 -    } else {
  99.723 -        fontlist = XmFontListCreate(fdata->xfont, "labelFont");
  99.724 -    }
  99.725 -
  99.726 -    if (fontlist != NULL) {
  99.727 -        Dimension textw, texth;
  99.728 -        Dimension w, h;
  99.729 -
  99.730 -        XtVaGetValues(tdata->txt,
  99.731 -                      XmNwidth, &textw,
  99.732 -                      XmNheight, &texth,
  99.733 -                      NULL);
  99.734 -        XtVaGetValues(tdata->comp.widget,
  99.735 -                      XmNwidth, &w,
  99.736 -                      XmNheight, &h,
  99.737 -                      NULL);
  99.738 -
  99.739 -        /* Must set width/height when we set the font, else
  99.740 -         * Motif resets the text to a single row.
  99.741 -         */
  99.742 -        XtVaSetValues(tdata->txt,
  99.743 -                      XmNfontList, fontlist,
  99.744 -                      XmNwidth, textw,
  99.745 -                      XmNheight, texth,
  99.746 -                      NULL);
  99.747 -        XtVaSetValues(tdata->comp.widget,
  99.748 -                      XmNwidth, w,
  99.749 -                      XmNheight, h,
  99.750 -                      NULL);
  99.751 -
  99.752 -        XmFontListFree(fontlist);
  99.753 -    } else {
  99.754 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.755 -    }
  99.756 -
  99.757 -    AWT_UNLOCK();
  99.758 -}
  99.759 -
  99.760 -/*
  99.761 - * Class:     sun_awt_motif_MTextAreaPeer
  99.762 - * Method:    setCaretPosition
  99.763 - * Signature: (I)V
  99.764 - */
  99.765 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_setCaretPosition
  99.766 -  (JNIEnv *env, jobject this, jint pos)
  99.767 -{
  99.768 -    struct TextAreaData *tdata;
  99.769 -
  99.770 -    AWT_LOCK();
  99.771 -
  99.772 -    tdata = (struct TextAreaData *)
  99.773 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  99.774 -
  99.775 -    if (tdata == NULL || tdata->txt == NULL) {
  99.776 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.777 -        AWT_UNLOCK();
  99.778 -        return;
  99.779 -    }
  99.780 -    XmTextSetInsertionPosition(tdata->txt, (XmTextPosition) pos);
  99.781 -
  99.782 -    AWT_FLUSH_UNLOCK();
  99.783 -}
  99.784 -
  99.785 -/*
  99.786 - * Class:     sun_awt_motif_MTextAreaPeer
  99.787 - * Method:    getCaretPosition
  99.788 - * Signature: ()I
  99.789 - */
  99.790 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MTextAreaPeer_getCaretPosition
  99.791 -  (JNIEnv *env, jobject this)
  99.792 -{
  99.793 -    struct TextAreaData *tdata;
  99.794 -    XmTextPosition pos;
  99.795 -
  99.796 -    AWT_LOCK();
  99.797 -
  99.798 -    tdata = (struct TextAreaData *)
  99.799 -      JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  99.800 -
  99.801 -    if (tdata == NULL || tdata->txt == NULL) {
  99.802 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.803 -        AWT_UNLOCK();
  99.804 -        return 0;
  99.805 -    }
  99.806 -    pos = XmTextGetInsertionPosition(tdata->txt);
  99.807 -
  99.808 -    AWT_UNLOCK();
  99.809 -
  99.810 -    return (jint) pos;
  99.811 -}
  99.812 -
  99.813 -/*
  99.814 - * Class:     sun_awt_motif_MTextAreaPeer
  99.815 - * Method:    pShow
  99.816 - * Signature: ()V
  99.817 - */
  99.818 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_pShow2
  99.819 -  (JNIEnv *env, jobject this)
  99.820 -{
  99.821 -    struct TextAreaData *tdata;
  99.822 -
  99.823 -    AWT_LOCK();
  99.824 -    tdata = (struct TextAreaData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.825 -    if (tdata == NULL || tdata->comp.widget == NULL) {
  99.826 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.827 -        AWT_UNLOCK();
  99.828 -        return;
  99.829 -    }
  99.830 -
  99.831 -    awt_util_show(tdata->comp.widget);
  99.832 -    AWT_FLUSH_UNLOCK();
  99.833 -}
  99.834 -
  99.835 -
  99.836 -/*
  99.837 - * Class:     sun_awt_motif_MTextAreaPeer
  99.838 - * Method:    pMakeCursorVisible
  99.839 - * Signature: ()V
  99.840 - */
  99.841 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_pMakeCursorVisible
  99.842 -  (JNIEnv *env, jobject this)
  99.843 -{
  99.844 -    struct TextAreaData *tdata;
  99.845 -
  99.846 -    AWT_LOCK();
  99.847 -    tdata = (struct TextAreaData *) JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
  99.848 -    if (tdata == NULL || tdata->comp.widget == NULL) {
  99.849 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.850 -        AWT_UNLOCK();
  99.851 -        return;
  99.852 -    }
  99.853 -
  99.854 -    AWT_FLUSH_UNLOCK();
  99.855 -}
  99.856 -
  99.857 -/*
  99.858 - * Class:     sun_awt_motif_MTextAreaPeer
  99.859 - * Method:    pSetCursor
  99.860 - * Signature: (L/java/awt/Cursor;)V
  99.861 - */
  99.862 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_pSetCursor
  99.863 -  (JNIEnv *env, jobject this, jobject cursor)
  99.864 -{
  99.865 -    Cursor xcursor;
  99.866 -    struct TextAreaData         *tdata;
  99.867 -
  99.868 -    AWT_LOCK();
  99.869 -    tdata = (struct TextAreaData *)
  99.870 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  99.871 -    if (tdata == NULL || tdata->comp.widget == NULL || JNU_IsNull(env, cursor)) {
  99.872 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.873 -        AWT_UNLOCK();
  99.874 -        return;
  99.875 -    }
  99.876 -
  99.877 -    awt_util_setCursor(tdata->txt, getCursor(env, cursor));
  99.878 -
  99.879 -    AWT_FLUSH_UNLOCK();
  99.880 -}
  99.881 -
  99.882 -/*
  99.883 - * Class:     sun_awt_motif_MTextAreaPeer
  99.884 - * Method:    nativeHandleMouseWheel
  99.885 - * Signature: (III)V
  99.886 - */
  99.887 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextAreaPeer_nativeHandleMouseWheel
  99.888 -  (JNIEnv *env, jobject this, jint scrollType, jint scrollAmt, jint wheelAmt)
  99.889 -{
  99.890 -    struct TextAreaData         *tdata;
  99.891 -    Widget text = NULL;
  99.892 -    Widget scroll = NULL;
  99.893 -
  99.894 -    AWT_LOCK();
  99.895 -    tdata = (struct TextAreaData *)
  99.896 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
  99.897 -    if (tdata == NULL || tdata->comp.widget == NULL) {
  99.898 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.899 -        AWT_UNLOCK();
  99.900 -        return;
  99.901 -    }
  99.902 -    // get the Text widget
  99.903 -    text = tdata->txt;
  99.904 -    if (text == NULL) {
  99.905 -        AWT_UNLOCK();
  99.906 -        return;
  99.907 -    }
  99.908 -
  99.909 -    // get the ScrolledWindow
  99.910 -    scroll = XtParent(text);
  99.911 -    if (scroll == NULL) {
  99.912 -        AWT_UNLOCK();
  99.913 -        return;
  99.914 -    }
  99.915 -
  99.916 -    awt_util_do_wheel_scroll(scroll, scrollType, scrollAmt, wheelAmt);
  99.917 -    AWT_UNLOCK();
  99.918 -}
  99.919 -
  99.920 -
  99.921 -
  99.922 -/*  To be fully implemented in a future release
  99.923 - *
  99.924 - * Class:     sun_awt_windows_MTextAreaPeer
  99.925 - * Method:    getIndexAtPoint
  99.926 - * Signature: (II)I
  99.927 - *
  99.928 -JNIEXPORT jint JNICALL
  99.929 -Java_sun_awt_motif_MTextAreaPeer_getIndexAtPoint(JNIEnv *env, jobject self,
  99.930 - jint x, jint y)
  99.931 -{
  99.932 -    struct TextAreaData *tdata;
  99.933 -    XmTextPosition pos;
  99.934 -
  99.935 -    AWT_LOCK();
  99.936 -
  99.937 -    tdata = (struct TextAreaData *)
  99.938 -        JNU_GetLongFieldAsPtr(env,self,mComponentPeerIDs.pData);
  99.939 -
  99.940 -    if (tdata == NULL || tdata->txt == NULL) {
  99.941 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.942 -        AWT_UNLOCK();
  99.943 -        return -1;
  99.944 -    }
  99.945 -    pos = XmTextXYToPos(tdata->txt, x, y);
  99.946 -    AWT_UNLOCK();
  99.947 -
  99.948 -    return (jint) pos;
  99.949 -}
  99.950 -*/
  99.951 -
  99.952 -/*  To be fully implemented in a future release
  99.953 - *
  99.954 - * Class:     sun_awt_windows_MTextAreaPeer
  99.955 - * Method:    getCharacterBounds
  99.956 - * Signature: (I)Ljava/awt/Rectangle;
  99.957 - *
  99.958 -JNIEXPORT jobject JNICALL
  99.959 -Java_sun_awt_motif_MTextAreaPeer_getCharacterBounds(JNIEnv *env, jobject self, jint i)
  99.960 -{
  99.961 -#define Text_FontAscent(tfg)                   (((XmTextWidget)(tfg)) -> \
  99.962 -                                           text.output->data->font_ascent)
  99.963 -#define Text_FontDescent(tfg)                  (((XmTextWidget)(tfg)) -> \
  99.964 -                                           text.output->data->font_descent)
  99.965 -
  99.966 -    struct TextAreaData *tdata;
  99.967 -    jobject rect=NULL;
  99.968 -    Position x=0, y=0;
  99.969 -    Position next_x=0, next_y=0;
  99.970 -    int32_t w=0, h=0;
  99.971 -
  99.972 -    AWT_LOCK();
  99.973 -
  99.974 -    tdata = (struct TextAreaData *)
  99.975 -        JNU_GetLongFieldAsPtr(env,self,mComponentPeerIDs.pData);
  99.976 -
  99.977 -    if (tdata == NULL || tdata->txt == NULL) {
  99.978 -        JNU_ThrowNullPointerException(env, "NullPointerException");
  99.979 -        AWT_UNLOCK();
  99.980 -        return (jobject) NULL;
  99.981 -    }
  99.982 -
  99.983 -    XmTextPosToXY(tdata->txt, i, &x, &y);
  99.984 -    y -= Text_FontAscent(tdata->txt);
  99.985 -    XmTextPosToXY(tdata->txt, i+1, &next_x, &next_y);
  99.986 -    w = next_x - x;
  99.987 -    h = Text_FontAscent(tdata->txt) + Text_FontDescent(tdata->txt);
  99.988 -
  99.989 -    AWT_UNLOCK();
  99.990 -
  99.991 -    if (w>0) {
  99.992 -        jclass clazz;
  99.993 -        jmethodID mid;
  99.994 -
  99.995 -        clazz = (*env)->FindClass(env, "java/awt/Rectangle");
  99.996 -        mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
  99.997 -        if (mid != NULL) {
  99.998 -            rect = (*env)->NewObject(env, clazz, mid, x, y, w, h);
  99.999 -            if ((*env)->ExceptionOccurred(env)) {
 99.1000 -                return (jobject) NULL;
 99.1001 -            }
 99.1002 -        }
 99.1003 -    }
 99.1004 -    return rect;
 99.1005 -}
 99.1006 -*/
   100.1 --- a/src/solaris/native/sun/awt/awt_TextArea.h	Wed Sep 17 13:45:37 2008 -0700
   100.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   100.3 @@ -1,36 +0,0 @@
   100.4 -/*
   100.5 - * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
   100.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   100.7 - *
   100.8 - * This code is free software; you can redistribute it and/or modify it
   100.9 - * under the terms of the GNU General Public License version 2 only, as
  100.10 - * published by the Free Software Foundation.  Sun designates this
  100.11 - * particular file as subject to the "Classpath" exception as provided
  100.12 - * by Sun in the LICENSE file that accompanied this code.
  100.13 - *
  100.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  100.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  100.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  100.17 - * version 2 for more details (a copy is included in the LICENSE file that
  100.18 - * accompanied this code).
  100.19 - *
  100.20 - * You should have received a copy of the GNU General Public License version
  100.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  100.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  100.23 - *
  100.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  100.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  100.26 - * have any questions.
  100.27 - */
  100.28 -
  100.29 -#include "jni_util.h"
  100.30 -
  100.31 -/* fieldIDs for TextArea fields that may be accessed from C */
  100.32 -static struct TextAreaIDs {
  100.33 -    jfieldID scrollbarVisibility;
  100.34 -};
  100.35 -
  100.36 -/* fieldIDs for MTextAreaPeer fields that may be accessed from C */
  100.37 -struct MTextAreaPeerIDs {
  100.38 -    jfieldID firstChangeSkipped;
  100.39 -};
   101.1 --- a/src/solaris/native/sun/awt/awt_TextField.c	Wed Sep 17 13:45:37 2008 -0700
   101.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   101.3 @@ -1,989 +0,0 @@
   101.4 -/*
   101.5 - * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
   101.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   101.7 - *
   101.8 - * This code is free software; you can redistribute it and/or modify it
   101.9 - * under the terms of the GNU General Public License version 2 only, as
  101.10 - * published by the Free Software Foundation.  Sun designates this
  101.11 - * particular file as subject to the "Classpath" exception as provided
  101.12 - * by Sun in the LICENSE file that accompanied this code.
  101.13 - *
  101.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  101.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  101.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  101.17 - * version 2 for more details (a copy is included in the LICENSE file that
  101.18 - * accompanied this code).
  101.19 - *
  101.20 - * You should have received a copy of the GNU General Public License version
  101.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  101.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  101.23 - *
  101.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  101.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  101.26 - * have any questions.
  101.27 - */
  101.28 -
  101.29 -#ifdef HEADLESS
  101.30 -    #error This file should not be included in headless library
  101.31 -#endif
  101.32 -
  101.33 -#include <Xm/VirtKeys.h>
  101.34 -
  101.35 -#include "awt_p.h"
  101.36 -#include "java_awt_TextField.h"
  101.37 -#include "java_awt_Color.h"
  101.38 -#include "java_awt_AWTEvent.h"
  101.39 -#include "java_awt_Font.h"
  101.40 -#include "java_awt_Canvas.h"
  101.41 -#include "sun_awt_motif_MComponentPeer.h"
  101.42 -#include "sun_awt_motif_MCanvasPeer.h"
  101.43 -#include "sun_awt_motif_MTextFieldPeer.h"
  101.44 -
  101.45 -#include "awt_Component.h"
  101.46 -#include "awt_TextField.h"
  101.47 -
  101.48 -#include "multi_font.h"
  101.49 -#include <jni.h>
  101.50 -#include <jni_util.h>
  101.51 -#include <Xm/DropSMgr.h>
  101.52 -#include <Xm/TextFP.h>  /* Motif TextField private header. */
  101.53 -
  101.54 -
  101.55 -#define ECHO_BUFFER_LEN 1024
  101.56 -
  101.57 -extern struct MComponentPeerIDs mComponentPeerIDs;
  101.58 -extern AwtGraphicsConfigDataPtr
  101.59 -    copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
  101.60 -struct TextFieldIDs textFieldIDs;
  101.61 -struct MTextFieldPeerIDs mTextFieldPeerIDs;
  101.62 -
  101.63 -/*
  101.64 - * Class:     java_awt_TextField
  101.65 - * Method:    initIDs
  101.66 - * Signature: ()V
  101.67 - */
  101.68 -
  101.69 -/* This function gets called from the static initializer for TextField.java
  101.70 -   to initialize the fieldIDs for fields that may be accessed from C */
  101.71 -
  101.72 -JNIEXPORT void JNICALL
  101.73 -Java_java_awt_TextField_initIDs
  101.74 -  (JNIEnv *env, jclass cls)
  101.75 -{
  101.76 -    textFieldIDs.echoChar =
  101.77 -      (*env)->GetFieldID(env, cls, "echoChar", "C");
  101.78 -}
  101.79 -
  101.80 -/*
  101.81 - * Class:     sun_awt_motif_MTextFieldPeer
  101.82 - * Method:    initIDs
  101.83 - * Signature: ()V
  101.84 - */
  101.85 -
  101.86 -/* This function gets called from the static initializer for
  101.87 -   MTextFieldPeer.java to initialize the fieldIDs for fields that may
  101.88 -   be accessed from C */
  101.89 -
  101.90 -JNIEXPORT void JNICALL
  101.91 -Java_sun_awt_motif_MTextFieldPeer_initIDs
  101.92 -  (JNIEnv *env, jclass cls)
  101.93 -{
  101.94 -    mTextFieldPeerIDs.firstChangeSkipped =
  101.95 -      (*env)->GetFieldID(env, cls, "firstChangeSkipped", "Z");
  101.96 -}
  101.97 -
  101.98 -static void
  101.99 -echoChar(Widget text_w, XtPointer unused, XmTextVerifyCallbackStruct * cbs)
 101.100 -{
 101.101 -    size_t len;
 101.102 -    int32_t c;
 101.103 -    char *val;
 101.104 -    struct DPos *dp;
 101.105 -    int32_t ret;
 101.106 -    jobject globalRef;
 101.107 -    int32_t i, numbytes;
 101.108 -
 101.109 -    struct TextFieldData *tdata;
 101.110 -
 101.111 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 101.112 -
 101.113 -    /*
 101.114 -     * Get the echoContextID from the globalRef which is stored in
 101.115 -     * the XmNuserData resource for the widget.
 101.116 -     */
 101.117 -    XtVaGetValues(text_w,XmNuserData,&globalRef,NULL);
 101.118 -
 101.119 -    tdata = (struct TextFieldData *)
 101.120 -      (*env)->GetLongField(env,globalRef,mComponentPeerIDs.pData);
 101.121 -
 101.122 -    ret = XFindContext(XtDisplay(text_w), (XID)text_w, tdata->echoContextID,
 101.123 -                       (XPointer *)&dp);
 101.124 -    if ((ret != 0) || (dp == NULL)) {
 101.125 -        /* no context found or DPos is NULL - shouldn't happen */
 101.126 -        return;
 101.127 -    }
 101.128 -
 101.129 -    c = dp->echoC;
 101.130 -    val = (char *) (dp->data);
 101.131 -
 101.132 -    len = strlen(val);
 101.133 -    if (cbs->text->ptr == NULL) {
 101.134 -        if (cbs->text->length == 0 && cbs->startPos == 0) {
 101.135 -            val[0] = '\0';
 101.136 -            return;
 101.137 -        } else if (cbs->startPos == (len - 1)) {
 101.138 -            /* handle deletion */
 101.139 -            cbs->endPos = strlen(val);
 101.140 -            val[cbs->startPos] = '\0';
 101.141 -            return;
 101.142 -        } else {
 101.143 -            /* disable deletes anywhere but at the end */
 101.144 -            cbs->doit = False;
 101.145 -            return;
 101.146 -        }
 101.147 -    }
 101.148 -    if (cbs->startPos != len) {
 101.149 -        /* disable "paste" or inserts into the middle */
 101.150 -        cbs->doit = False;
 101.151 -        return;
 101.152 -    }
 101.153 -    /* append the value typed in */
 101.154 -    if ((cbs->endPos + cbs->text->length) > ECHO_BUFFER_LEN) {
 101.155 -        val = realloc(val, cbs->endPos + cbs->text->length + 10);
 101.156 -    }
 101.157 -    strncat(val, cbs->text->ptr, cbs->text->length);
 101.158 -    val[cbs->endPos + cbs->text->length] = '\0';
 101.159 -
 101.160 -    /* modify the output to be the echo character */
 101.161 -    for (len = 0, i = 0; len < cbs->text->length; i++) {
 101.162 -        /* Write one echo character for each multibyte character. */
 101.163 -        numbytes = mblen(cbs->text->ptr + len, cbs->text->length - len);
 101.164 -        cbs->text->ptr[i] = (char) c;
 101.165 -        len += numbytes;
 101.166 -    }
 101.167 -    cbs->text->length = i;
 101.168 -}
 101.169 -
 101.170 -/*
 101.171 - * Event handler used by both TextField/TextArea to correctly process
 101.172 - * cut/copy/paste keys such that interaction with our own
 101.173 - * clipboard mechanism will work properly.
 101.174 - *
 101.175 - * client_data is MTextFieldPeer instance
 101.176 - */
 101.177 -void
 101.178 -Text_handlePaste(Widget w, XtPointer client_data, XEvent * event, Boolean * cont)
 101.179 -{
 101.180 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 101.181 -    KeySym keysym;
 101.182 -    Modifiers mods;
 101.183 -
 101.184 -    /* Any event handlers which take peer instance pointers as
 101.185 -     * client_data should check to ensure the widget has not been
 101.186 -     * marked as destroyed as a result of a dispose() call on the peer
 101.187 -     * (which can result in the peer instance pointer already haven
 101.188 -     * been gc'd by the time this event is processed)
 101.189 -     */
 101.190 -    if (event->type != KeyPress || w->core.being_destroyed) {
 101.191 -        return;
 101.192 -    }
 101.193 -
 101.194 -    XtTranslateKeycode(event->xkey.display, (KeyCode) event->xkey.keycode,
 101.195 -                       event->xkey.state, &mods, &keysym);
 101.196 -
 101.197 -    /* Should be a temporary fix for 4052132 if a cleaner fix is found later */
 101.198 -    if ((event->xkey.state & ControlMask) && (keysym == 'v' || keysym == 'V'))
 101.199 -        keysym = osfXK_Paste;
 101.200 -    if ((event->xkey.state & ShiftMask) && (keysym == osfXK_Insert))
 101.201 -        keysym = osfXK_Paste;
 101.202 -
 101.203 -    switch (keysym) {
 101.204 -        case osfXK_Paste:
 101.205 -            /* If we own the selection, then paste the data directly */
 101.206 -            if (awtJNI_isSelectionOwner(env, "CLIPBOARD")) {
 101.207 -                JNU_CallMethodByName(env, NULL, (jobject) client_data,
 101.208 -                                     "pasteFromClipboard", "()V");
 101.209 -                if ((*env)->ExceptionOccurred(env)) {
 101.210 -                    (*env)->ExceptionDescribe(env);
 101.211 -                    (*env)->ExceptionClear(env);
 101.212 -                }
 101.213 -                *cont = FALSE;
 101.214 -            }
 101.215 -            break;
 101.216 -
 101.217 -        case osfXK_Cut:
 101.218 -        case osfXK_Copy:
 101.219 -            /* For some reason if we own the selection, our loseSelection
 101.220 -             * callback is not automatically called on cut/paste from
 101.221 -             * text widgets.
 101.222 -             */
 101.223 -            if (awtJNI_isSelectionOwner(env, "CLIPBOARD")) {
 101.224 -                awtJNI_notifySelectionLost(env, "CLIPBOARD");
 101.225 -            }
 101.226 -            break;
 101.227 -        default:
 101.228 -            break;
 101.229 -    }
 101.230 -}
 101.231 -
 101.232 -/*
 101.233 - * client_data is MTextFieldPeer instance
 101.234 - */
 101.235 -void
 101.236 -TextField_valueChanged(Widget w, XtPointer client_data, XtPointer call_data)
 101.237 -{
 101.238 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 101.239 -    jboolean skipped;
 101.240 -
 101.241 -    skipped = (*env)->GetBooleanField(env, (jobject) client_data,
 101.242 -                                      mTextFieldPeerIDs.firstChangeSkipped);
 101.243 -    if (!(*env)->ExceptionOccurred(env)) {
 101.244 -        if (skipped == JNI_FALSE) {
 101.245 -            (*env)->SetBooleanField(env, (jobject) client_data,
 101.246 -                                    mTextFieldPeerIDs.firstChangeSkipped,
 101.247 -                                    JNI_TRUE);
 101.248 -        } else {
 101.249 -            JNU_CallMethodByName(env, NULL, (jobject) client_data,
 101.250 -                                 "valueChanged", "()V");
 101.251 -        }
 101.252 -    }
 101.253 -
 101.254 -    if ((*env)->ExceptionOccurred(env)) {
 101.255 -        (*env)->ExceptionDescribe(env);
 101.256 -        (*env)->ExceptionClear(env);
 101.257 -    }
 101.258 -}
 101.259 -
 101.260 -/*
 101.261 - * client_data is MTextFieldPeer instance
 101.262 - */
 101.263 -static void
 101.264 -TextField_action(Widget w, XtPointer client_data, XmAnyCallbackStruct * s)
 101.265 -{
 101.266 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 101.267 -    ConvertEventTimeAndModifiers converted;
 101.268 -
 101.269 -    awt_util_convertEventTimeAndModifiers(s->event, &converted);
 101.270 -
 101.271 -    JNU_CallMethodByName(env, NULL, (jobject) client_data, "action", "(JI)V",
 101.272 -                         converted.when, converted.modifiers);
 101.273 -    if ((*env)->ExceptionOccurred(env)) {
 101.274 -        (*env)->ExceptionDescribe(env);
 101.275 -        (*env)->ExceptionClear(env);
 101.276 -    }
 101.277 -}
 101.278 -
 101.279 -/*
 101.280 - * Class:     sun_awt_motif_MTextFieldPeer
 101.281 - * Method:    pCreate
 101.282 - * Signature: (Lsun/awt/motif/MComponentPeer;)V
 101.283 - */
 101.284 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextFieldPeer_pCreate
 101.285 -  (JNIEnv *env, jobject this, jobject parent)
 101.286 -{
 101.287 -    struct ComponentData *wdata;
 101.288 -    struct TextFieldData *tdata;
 101.289 -
 101.290 -    jobject globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
 101.291 -    AwtGraphicsConfigDataPtr adata;
 101.292 -
 101.293 -    AWT_LOCK();
 101.294 -
 101.295 -    adata = copyGraphicsConfigToPeer(env, this);
 101.296 -
 101.297 -    if (JNU_IsNull(env, parent)) {
 101.298 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.299 -        AWT_UNLOCK();
 101.300 -        return;
 101.301 -    }
 101.302 -    wdata = (struct ComponentData *)
 101.303 -        JNU_GetLongFieldAsPtr(env,parent,mComponentPeerIDs.pData);
 101.304 -    if (wdata == NULL) {
 101.305 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.306 -        AWT_UNLOCK();
 101.307 -        return;
 101.308 -    }
 101.309 -    tdata = ZALLOC(TextFieldData);
 101.310 -    if (tdata == NULL) {
 101.311 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
 101.312 -        AWT_UNLOCK();
 101.313 -        return;
 101.314 -    }
 101.315 -    JNU_SetLongFieldFromPtr(env,this,mComponentPeerIDs.pData,tdata);
 101.316 -
 101.317 -    tdata->comp.widget = XtVaCreateManagedWidget("textfield",
 101.318 -                                                 xmTextFieldWidgetClass,
 101.319 -                                                 wdata->widget,
 101.320 -                                                 XmNrecomputeSize, False,
 101.321 -                                                 XmNhighlightThickness, 1,
 101.322 -                                                 XmNshadowThickness, 2,
 101.323 -                                                 XmNuserData, (XtPointer) globalRef,
 101.324 -                                                 XmNscreen,
 101.325 -                                                 ScreenOfDisplay(awt_display,
 101.326 -                                                   adata->awt_visInfo.screen),
 101.327 -                                                 XmNfontList, getMotifFontList(),
 101.328 -                                                 NULL);
 101.329 -    tdata->echoContextIDInit = FALSE;
 101.330 -
 101.331 -    XtSetMappedWhenManaged(tdata->comp.widget, False);
 101.332 -    XtAddCallback(tdata->comp.widget,
 101.333 -                  XmNactivateCallback,
 101.334 -                  (XtCallbackProc) TextField_action,
 101.335 -                  (XtPointer) globalRef);
 101.336 -    XtAddCallback(tdata->comp.widget,
 101.337 -                  XmNvalueChangedCallback,
 101.338 -                  (XtCallbackProc) TextField_valueChanged,
 101.339 -                  (XtPointer) globalRef);
 101.340 -    XtInsertEventHandler(tdata->comp.widget,
 101.341 -                         KeyPressMask,
 101.342 -                         False, Text_handlePaste, (XtPointer) globalRef,
 101.343 -                         XtListHead);
 101.344 -    /*
 101.345 -     * Fix for BugTraq ID 4349615.
 101.346 -     * Unregister Motif drop site to prevent it from crash
 101.347 -     * when dropping java objects.
 101.348 -     */
 101.349 -    XmDropSiteUnregister(tdata->comp.widget);
 101.350 -
 101.351 -    AWT_UNLOCK();
 101.352 -}
 101.353 -
 101.354 -/*
 101.355 - * Class     sun_awt_motif_MTextFieldPeer
 101.356 - * Method:    pSetEditable
 101.357 - * Signature: (Z)V
 101.358 - */
 101.359 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextFieldPeer_pSetEditable
 101.360 -  (JNIEnv *env, jobject this, jboolean editable)
 101.361 -{
 101.362 -    struct TextFieldData *tdata;
 101.363 -
 101.364 -    AWT_LOCK();
 101.365 -    tdata = (struct TextFieldData *)
 101.366 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.367 -
 101.368 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.369 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.370 -        AWT_UNLOCK();
 101.371 -        return;
 101.372 -    }
 101.373 -    XtVaSetValues(tdata->comp.widget,
 101.374 -                  XmNeditable, (editable ? True : False),
 101.375 -                  XmNcursorPositionVisible, (editable ? True : False),
 101.376 -                  NULL);
 101.377 -    AWT_FLUSH_UNLOCK();
 101.378 -}
 101.379 -
 101.380 -/*
 101.381 - * Class:     sun_awt_motif_MTextFieldPeer
 101.382 - * Method:    select
 101.383 - * Signature: (II)V
 101.384 - */
 101.385 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextFieldPeer_select
 101.386 -  (JNIEnv *env, jobject this, jint start, jint end)
 101.387 -{
 101.388 -    struct TextFieldData *tdata;
 101.389 -
 101.390 -    AWT_LOCK();
 101.391 -
 101.392 -    tdata = (struct TextFieldData *)
 101.393 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.394 -
 101.395 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.396 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.397 -        AWT_UNLOCK();
 101.398 -        return;
 101.399 -    }
 101.400 -    XmTextSetSelection(tdata->comp.widget, (XmTextPosition) start, (XmTextPosition) end, 0);
 101.401 -    AWT_FLUSH_UNLOCK();
 101.402 -}
 101.403 -
 101.404 -/*
 101.405 - * Class:     sun_awt_motif_MTextFieldPeer
 101.406 - * Method:    getSelectionStart
 101.407 - * Signature: ()I
 101.408 - */
 101.409 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MTextFieldPeer_getSelectionStart
 101.410 -  (JNIEnv *env, jobject this)
 101.411 -{
 101.412 -    struct TextFieldData *tdata;
 101.413 -    XmTextPosition start, end, pos;
 101.414 -
 101.415 -    AWT_LOCK();
 101.416 -
 101.417 -    tdata = (struct TextFieldData *)
 101.418 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.419 -
 101.420 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.421 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.422 -        AWT_UNLOCK();
 101.423 -        return 0;
 101.424 -    }
 101.425 -    if (XmTextGetSelectionPosition(tdata->comp.widget, &start, &end) &&
 101.426 -                                                (start != end)) {
 101.427 -        pos = start;
 101.428 -    } else {
 101.429 -        pos = XmTextGetInsertionPosition(tdata->comp.widget);
 101.430 -    }
 101.431 -    AWT_UNLOCK();
 101.432 -
 101.433 -    return (jint) pos;
 101.434 -}
 101.435 -
 101.436 -/*
 101.437 - * Class:     sun_awt_motif_MTextFieldPeer
 101.438 - * Method:    getSelectionEnd
 101.439 - * Signature: ()I
 101.440 - */
 101.441 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MTextFieldPeer_getSelectionEnd
 101.442 -  (JNIEnv *env, jobject this)
 101.443 -{
 101.444 -    struct TextFieldData *tdata;
 101.445 -    XmTextPosition start, end, pos;
 101.446 -
 101.447 -    AWT_LOCK();
 101.448 -
 101.449 -    tdata = (struct TextFieldData *)
 101.450 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.451 -
 101.452 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.453 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.454 -        AWT_UNLOCK();
 101.455 -        return 0;
 101.456 -    }
 101.457 -    if (XmTextGetSelectionPosition(tdata->comp.widget, &start, &end) &&
 101.458 -                                                 (start != end)) {
 101.459 -        pos = end;
 101.460 -    } else {
 101.461 -        pos = XmTextGetInsertionPosition(tdata->comp.widget);
 101.462 -    }
 101.463 -    AWT_UNLOCK();
 101.464 -
 101.465 -    return (jint) pos;
 101.466 -}
 101.467 -
 101.468 -/*
 101.469 - * Class:     sun_awt_motif_MTextFieldPeer
 101.470 - * Method:    setText
 101.471 - * Signature: (Ljava/lang/String;)V
 101.472 - */
 101.473 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextFieldPeer_setText
 101.474 -  (JNIEnv *env, jobject this, jstring l)
 101.475 -{
 101.476 -    struct TextFieldData *tdata;
 101.477 -    char *cl;
 101.478 -    jobject target;
 101.479 -
 101.480 -    AWT_LOCK();
 101.481 -
 101.482 -    tdata = (struct TextFieldData *)
 101.483 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.484 -
 101.485 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.486 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.487 -        AWT_UNLOCK();
 101.488 -        return;
 101.489 -    }
 101.490 -    if (JNU_IsNull(env, l)) {
 101.491 -        cl = "";
 101.492 -    } else {
 101.493 -        /*
 101.494 -         * Note: Motif TextField widgets do not support multi-font
 101.495 -         * compound strings.
 101.496 -         */
 101.497 -        cl = (char *) JNU_GetStringPlatformChars(env, l, NULL);
 101.498 -    }
 101.499 -
 101.500 -    /* Fix for bug 4084454 : setText appears in clear */
 101.501 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
 101.502 -    if ((*env)->GetCharField(env, target, textFieldIDs.echoChar) != 0) {
 101.503 -        XtVaSetValues(tdata->comp.widget,
 101.504 -                      XmNvalue, "", NULL);
 101.505 -        XmTextFieldInsert(tdata->comp.widget,0,cl);
 101.506 -        XmTextSetInsertionPosition(tdata->comp.widget,
 101.507 -                                   (XmTextPosition) strlen(cl));
 101.508 -    }
 101.509 -    else {
 101.510 -        XtVaSetValues(tdata->comp.widget,
 101.511 -                      XmNvalue, cl,
 101.512 -                      NULL);
 101.513 -    }
 101.514 -    /*
 101.515 -     * Fix for BugTraq Id 4185654 - TextField.setText(<String>) incorrect justification
 101.516 -     * Comment out the next line.
 101.517 -     */
 101.518 -    /* XmTextSetInsertionPosition(tdata->comp.widget,
 101.519 -     *                            (XmTextPosition) strlen(cl));
 101.520 -     */
 101.521 -
 101.522 -    if (cl != NULL && cl != "") {
 101.523 -        JNU_ReleaseStringPlatformChars(env, l, cl);
 101.524 -    }
 101.525 -    AWT_FLUSH_UNLOCK();
 101.526 -}
 101.527 -
 101.528 -/*
 101.529 - * Class:     sun_awt_motif_MTextFieldPeer
 101.530 - * Method:    insertReplaceText
 101.531 - * Signature: (Ljava/lang/String;)V
 101.532 - */
 101.533 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextFieldPeer_insertReplaceText
 101.534 -  (JNIEnv *env, jobject this, jstring l)
 101.535 -{
 101.536 -    struct TextFieldData *tdata;
 101.537 -    char *cl;
 101.538 -    XmTextPosition start, end;
 101.539 -
 101.540 -    AWT_LOCK();
 101.541 -
 101.542 -    tdata = (struct TextFieldData *)
 101.543 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.544 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.545 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.546 -        AWT_UNLOCK();
 101.547 -        return;
 101.548 -    }
 101.549 -
 101.550 -    if (JNU_IsNull(env, l)) {
 101.551 -        cl = "";
 101.552 -    } else {
 101.553 -        /*
 101.554 -         * Note: Motif TextField widgets do not support multi-font
 101.555 -         * compound strings.
 101.556 -         */
 101.557 -        cl = (char *) JNU_GetStringPlatformChars(env, l, NULL);
 101.558 -    }
 101.559 -
 101.560 -    if (!XmTextGetSelectionPosition(tdata->comp.widget, &start, &end)) {
 101.561 -        start = end = XmTextGetInsertionPosition(tdata->comp.widget);
 101.562 -    }
 101.563 -    XmTextReplace(tdata->comp.widget, start, end, cl);
 101.564 -
 101.565 -    if (cl != NULL && cl != "") {
 101.566 -        JNU_ReleaseStringPlatformChars(env, l, cl);
 101.567 -    }
 101.568 -    AWT_FLUSH_UNLOCK();
 101.569 -}
 101.570 -
 101.571 -/*
 101.572 - * Class:     sun_awt_motif_MTextFieldPeer
 101.573 - * Method:    preDispose
 101.574 - * Signature: ()V
 101.575 - */
 101.576 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextFieldPeer_preDispose
 101.577 -  (JNIEnv *env, jobject this)
 101.578 -{
 101.579 -    struct TextFieldData *tdata;
 101.580 -    struct DPos *dp;
 101.581 -    jobject target;
 101.582 -    int32_t ret;
 101.583 -
 101.584 -    AWT_LOCK();
 101.585 -
 101.586 -    tdata = (struct TextFieldData *)
 101.587 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.588 -
 101.589 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.590 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.591 -        AWT_UNLOCK();
 101.592 -        return;
 101.593 -    }
 101.594 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
 101.595 -
 101.596 -    if ((*env)->GetCharField(env, target, textFieldIDs.echoChar) != 0) {
 101.597 -        ret = XFindContext(XtDisplay(tdata->comp.widget), (XID)(tdata->comp.widget),
 101.598 -                           tdata->echoContextID, (XPointer *)&dp);
 101.599 -        if ((ret == 0) && dp != NULL) {
 101.600 -
 101.601 -            /* Remove the X context associated with this textfield's
 101.602 -             * echo character. BugId #4225734
 101.603 -             */
 101.604 -            XDeleteContext(XtDisplay(tdata->comp.widget),
 101.605 -                           (XID)(tdata->comp.widget),
 101.606 -                           tdata->echoContextID);
 101.607 -
 101.608 -            tdata->echoContextIDInit = FALSE;
 101.609 -
 101.610 -            /* Free up the space allocated for the echo character data. */
 101.611 -            if (dp->data) {
 101.612 -                free(dp->data);
 101.613 -            }
 101.614 -            free(dp);
 101.615 -        }
 101.616 -    }
 101.617 -
 101.618 -    AWT_UNLOCK();
 101.619 -}
 101.620 -
 101.621 -/*
 101.622 - * Class:     sun_awt_motif_MTextFieldPeer
 101.623 - * Method:    getText
 101.624 - * Signature: ()Ljava/lang/String;
 101.625 - */
 101.626 -JNIEXPORT jstring JNICALL Java_sun_awt_motif_MTextFieldPeer_getText
 101.627 -  (JNIEnv *env, jobject this)
 101.628 -{
 101.629 -    struct TextFieldData *tdata;
 101.630 -    char *val;
 101.631 -    struct DPos *dp;
 101.632 -    jobject target;
 101.633 -    int32_t ret;
 101.634 -    jstring returnVal;
 101.635 -
 101.636 -    AWT_LOCK();
 101.637 -    tdata = (struct TextFieldData *)
 101.638 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.639 -
 101.640 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.641 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.642 -        AWT_UNLOCK();
 101.643 -        return NULL;
 101.644 -    }
 101.645 -
 101.646 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
 101.647 -
 101.648 -    if ((*env)->GetCharField(env, target, textFieldIDs.echoChar) != 0) {
 101.649 -        ret = XFindContext(XtDisplay(tdata->comp.widget), (XID)tdata->comp.widget,
 101.650 -                           tdata->echoContextID, (XPointer *)&dp);
 101.651 -        if ((ret == 0) && (dp != NULL)) {
 101.652 -            val = (char *)(dp->data);
 101.653 -        } else {
 101.654 -            val = "";
 101.655 -        }
 101.656 -    } else {
 101.657 -        XtVaGetValues(tdata->comp.widget, XmNvalue, &val, NULL);
 101.658 -    }
 101.659 -    AWT_UNLOCK();
 101.660 -
 101.661 -    returnVal = JNU_NewStringPlatform(env, (const char *) val);
 101.662 -    if ((*env)->GetCharField(env, target, textFieldIDs.echoChar) == 0) {
 101.663 -        free(val);
 101.664 -    }
 101.665 -    return returnVal;
 101.666 -}
 101.667 -
 101.668 -/*
 101.669 - * Class:     sun_awt_motif_MTextFieldPeer
 101.670 - * Method:    setEchoChar
 101.671 - * Signature: (C)V
 101.672 - */
 101.673 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextFieldPeer_setEchoChar
 101.674 -  (JNIEnv *env, jobject this, jchar c)
 101.675 -{
 101.676 -    char *val;
 101.677 -    char *cval;
 101.678 -    struct TextFieldData *tdata;
 101.679 -    struct DPos *dp;
 101.680 -    int32_t i;
 101.681 -    size_t len;
 101.682 -    int32_t ret;
 101.683 -
 101.684 -    AWT_LOCK();
 101.685 -    tdata = (struct TextFieldData *)
 101.686 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.687 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.688 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.689 -        AWT_UNLOCK();
 101.690 -        return;
 101.691 -    }
 101.692 -
 101.693 -    XtVaGetValues(tdata->comp.widget,
 101.694 -                  XmNvalue, &cval,
 101.695 -                  NULL);
 101.696 -
 101.697 -    DASSERT(c != 0 || tdata->echoContextIDInit);
 101.698 -
 101.699 -    if (!tdata->echoContextIDInit) {
 101.700 -        tdata->echoContextID = XUniqueContext();
 101.701 -        tdata->echoContextIDInit = TRUE;
 101.702 -    }
 101.703 -    ret = XFindContext(XtDisplay(tdata->comp.widget), (XID)(tdata->comp.widget),
 101.704 -                       tdata->echoContextID, (XPointer *)&dp);
 101.705 -    /*
 101.706 -     * Fix for BugTraq ID 4307281.
 101.707 -     * Special case for setting echo char to 0:
 101.708 -     *  - remove the callback and X context associated with echo character;
 101.709 -     *  - restore the original text.
 101.710 -     */
 101.711 -    if (c == 0) {
 101.712 -        XtRemoveCallback(tdata->comp.widget, XmNmodifyVerifyCallback,
 101.713 -                         (XtCallbackProc) echoChar, NULL);
 101.714 -        if (ret == 0 && dp != NULL) {
 101.715 -
 101.716 -            /* Remove the X context associated with echo character. */
 101.717 -            XDeleteContext(XtDisplay(tdata->comp.widget),
 101.718 -                           (XID)(tdata->comp.widget),
 101.719 -                           tdata->echoContextID);
 101.720 -
 101.721 -            tdata->echoContextIDInit = FALSE;
 101.722 -
 101.723 -            /* Restore the original text. */
 101.724 -            if (dp->data != NULL) {
 101.725 -                val = (char *)(dp->data);
 101.726 -            } else {
 101.727 -                val = "";
 101.728 -            }
 101.729 -            XtVaSetValues(tdata->comp.widget,
 101.730 -                          XmNvalue, val,
 101.731 -                          NULL);
 101.732 -
 101.733 -            /* Free up the space allocated for the echo character data. */
 101.734 -            if (dp->data) {
 101.735 -                free(dp->data);
 101.736 -            }
 101.737 -            free(dp);
 101.738 -        }
 101.739 -        AWT_UNLOCK();
 101.740 -        return;
 101.741 -    }
 101.742 -    if (ret != 0) {
 101.743 -        dp = NULL;
 101.744 -    }
 101.745 -
 101.746 -    if (dp != NULL) {
 101.747 -        /* Fix bug 4124697: cannot change setEchoChar twice on Motif */
 101.748 -        XtRemoveCallback(tdata->comp.widget, XmNmodifyVerifyCallback,
 101.749 -                        (XtCallbackProc) echoChar, NULL);
 101.750 -    } else {
 101.751 -        if ((int32_t) strlen(cval) > ECHO_BUFFER_LEN) {
 101.752 -            val = (char *) malloc(strlen(cval) + 1);
 101.753 -        } else {
 101.754 -            val = (char *) malloc(ECHO_BUFFER_LEN + 1);
 101.755 -        }
 101.756 -        if (val == NULL) {
 101.757 -            JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
 101.758 -            AWT_UNLOCK();
 101.759 -            return;
 101.760 -        }
 101.761 -        if (cval != NULL) {
 101.762 -            strcpy(val, cval);
 101.763 -        } else {
 101.764 -            *val = '\0';
 101.765 -        }
 101.766 -        dp = (struct DPos *) malloc(sizeof(struct DPos));
 101.767 -
 101.768 -        dp->x = -1;
 101.769 -        dp->data = (void *) val;
 101.770 -    }
 101.771 -
 101.772 -    dp->echoC = c;
 101.773 -    len = strlen(cval);
 101.774 -    for (i = 0; i < len; i++) {
 101.775 -        cval[i] = (char) (c);
 101.776 -    }
 101.777 -    XtVaSetValues(tdata->comp.widget,
 101.778 -                  XmNvalue, cval,
 101.779 -                  NULL);
 101.780 -
 101.781 -    ret = XSaveContext(XtDisplay(tdata->comp.widget), (XID)tdata->comp.widget,
 101.782 -                       tdata->echoContextID, (XPointer)dp);
 101.783 -    if (ret == 0) {
 101.784 -        XtAddCallback(tdata->comp.widget, XmNmodifyVerifyCallback,
 101.785 -                      (XtCallbackProc) echoChar, NULL);
 101.786 -    }
 101.787 -    AWT_UNLOCK();
 101.788 -}
 101.789 -
 101.790 -/*
 101.791 - * Class:     sun_awt_motif_MTextFieldPeer
 101.792 - * Method:    setFont
 101.793 - * Signature: (Ljava/awt/Font;)V
 101.794 - */
 101.795 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextFieldPeer_setFont
 101.796 -  (JNIEnv *env, jobject this, jobject f)
 101.797 -{
 101.798 -    struct TextFieldData *tdata;
 101.799 -    struct FontData *fdata;
 101.800 -    XmFontListEntry fontentry;
 101.801 -    XmFontList fontlist;
 101.802 -    char *err;
 101.803 -
 101.804 -    AWT_LOCK();
 101.805 -    if (JNU_IsNull(env, f)) {
 101.806 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.807 -        AWT_UNLOCK();
 101.808 -        return;
 101.809 -    }
 101.810 -    fdata = awtJNI_GetFontData(env, f, &err);
 101.811 -    if (fdata == NULL) {
 101.812 -        JNU_ThrowInternalError(env, err);
 101.813 -        AWT_UNLOCK();
 101.814 -        return;
 101.815 -    }
 101.816 -    tdata = (struct TextFieldData *)
 101.817 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.818 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.819 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.820 -        AWT_UNLOCK();
 101.821 -        return;
 101.822 -    }
 101.823 -    if (awtJNI_IsMultiFont(env, f)) {
 101.824 -        if (fdata->xfs == NULL) {
 101.825 -            fdata->xfs = awtJNI_MakeFontSet(env, f);
 101.826 -        }
 101.827 -        if (fdata->xfs != NULL) {
 101.828 -            fontentry = XmFontListEntryCreate("labelFont",
 101.829 -                                              XmFONT_IS_FONTSET,
 101.830 -                                              (XtPointer) (fdata->xfs));
 101.831 -            fontlist = XmFontListAppendEntry(NULL, fontentry);
 101.832 -            /*
 101.833 -             * Some versions of motif have a bug in
 101.834 -             * XmFontListEntryFree() which causes it to free more than it
 101.835 -             * should.  Use XtFree() instead.  See O'Reilly's
 101.836 -             * Motif Reference Manual for more information.
 101.837 -             */
 101.838 -            XmFontListEntryFree(&fontentry);
 101.839 -        } else {
 101.840 -            fontlist = XmFontListCreate(fdata->xfont, "labelFont");
 101.841 -        }
 101.842 -    } else {
 101.843 -        fontlist = XmFontListCreate(fdata->xfont, "labelFont");
 101.844 -    }
 101.845 -
 101.846 -    if (fontlist != NULL) {
 101.847 -        XtVaSetValues(tdata->comp.widget, XmNfontList, fontlist, NULL);
 101.848 -        XmFontListFree(fontlist);
 101.849 -    } else {
 101.850 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.851 -    }
 101.852 -    AWT_UNLOCK();
 101.853 -}
 101.854 -
 101.855 -/*
 101.856 - * Class:     sun_awt_motif_MTextFieldPeer
 101.857 - * Method:    setCaretPosition
 101.858 - * Signature: (I)V
 101.859 - */
 101.860 -JNIEXPORT void JNICALL Java_sun_awt_motif_MTextFieldPeer_setCaretPosition
 101.861 -  (JNIEnv *env, jobject this, jint pos)
 101.862 -{
 101.863 -    struct TextFieldData *tdata;
 101.864 -
 101.865 -    AWT_LOCK();
 101.866 -
 101.867 -    tdata = (struct TextFieldData *)
 101.868 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.869 -
 101.870 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.871 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.872 -        AWT_UNLOCK();
 101.873 -        return;
 101.874 -    }
 101.875 -    XmTextSetInsertionPosition(tdata->comp.widget, (XmTextPosition) pos);
 101.876 -
 101.877 -    AWT_FLUSH_UNLOCK();
 101.878 -}
 101.879 -
 101.880 -/*
 101.881 - * Class:     sun_awt_motif_MTextFieldPeer
 101.882 - * Method:    getCaretPosition
 101.883 - * Signature: ()I
 101.884 - */
 101.885 -JNIEXPORT jint JNICALL Java_sun_awt_motif_MTextFieldPeer_getCaretPosition
 101.886 -  (JNIEnv *env, jobject this)
 101.887 -{
 101.888 -    struct TextFieldData *tdata;
 101.889 -    XmTextPosition pos;
 101.890 -
 101.891 -    AWT_LOCK();
 101.892 -
 101.893 -    tdata = (struct TextFieldData *)
 101.894 -        JNU_GetLongFieldAsPtr(env,this,mComponentPeerIDs.pData);
 101.895 -
 101.896 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.897 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.898 -        AWT_UNLOCK();
 101.899 -        return 0;
 101.900 -    }
 101.901 -    pos = XmTextGetInsertionPosition(tdata->comp.widget);
 101.902 -    AWT_UNLOCK();
 101.903 -
 101.904 -    return (jint) pos;
 101.905 -}
 101.906 -
 101.907 -
 101.908 -/*  To be fully implemented in a future release
 101.909 - *
 101.910 - * Class:     sun_awt_windows_MTextFieldPeer
 101.911 - * Method:    getIndexAtPoint
 101.912 - * Signature: (Ljava/awt/Point;)I
 101.913 - *
 101.914 -JNIEXPORT jint JNICALL
 101.915 -Java_sun_awt_motif_MTextFieldPeer_getIndexAtPoint(JNIEnv *env, jobject self,
 101.916 - jint x, jint y)
 101.917 -{
 101.918 -    struct ComponentData *tdata;
 101.919 -    XmTextPosition pos;
 101.920 -
 101.921 -    AWT_LOCK();
 101.922 -
 101.923 -    tdata = (struct ComponentData *)
 101.924 -        JNU_GetLongFieldAsPtr(env,self,mComponentPeerIDs.pData);
 101.925 -
 101.926 -    if (tdata == NULL || tdata->comp.widget == NULL) {
 101.927 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.928 -        AWT_UNLOCK();
 101.929 -        return -1;
 101.930 -    }
 101.931 -    pos = XmTextFieldXYToPos(tdata->widget, x, y);
 101.932 -    AWT_UNLOCK();
 101.933 -
 101.934 -    return (jint) pos;
 101.935 -}
 101.936 -*/
 101.937 -
 101.938 -/*  To be fully implemented in a future release
 101.939 - *
 101.940 - * Class:     sun_awt_windows_MTextFieldPeer
 101.941 - * Method:    getCharacterBounds
 101.942 - * Signature: (I)Ljava/awt/Rectangle;
 101.943 - *
 101.944 -JNIEXPORT jobject JNICALL
 101.945 -Java_sun_awt_motif_MTextFieldPeer_getCharacterBounds(JNIEnv *env, jobject self, jint i)
 101.946 -{
 101.947 -#define TextF_FontAscent(tfg)                   (((XmTextFieldWidget)(tfg)) -> \
 101.948 -                                           text.font_ascent)
 101.949 -#define TextF_FontDescent(tfg)                  (((XmTextFieldWidget)(tfg)) -> \
 101.950 -                                           text.font_descent)
 101.951 -
 101.952 -    struct ComponentData *tdata;
 101.953 -    jobject rect=NULL;
 101.954 -    Position x=0, y=0;
 101.955 -    Position next_x=0, next_y=0;
 101.956 -    int32_t w=0, h=0;
 101.957 -
 101.958 -    AWT_LOCK();
 101.959 -
 101.960 -    tdata = (struct ComponentData *)
 101.961 -        JNU_GetLongFieldAsPtr(env,self,mComponentPeerIDs.pData);
 101.962 -
 101.963 -    if (tdata == NULL || tdata->widget == NULL) {
 101.964 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 101.965 -        AWT_UNLOCK();
 101.966 -        return (jobject) NULL;
 101.967 -    }
 101.968 -
 101.969 -    XmTextFieldPosToXY(tdata->widget, i, &x, &y);
 101.970 -    y -= TextF_FontAscent(tdata->widget);
 101.971 -    XmTextFieldPosToXY(tdata->widget, i+1, &next_x, &next_y);
 101.972 -    w = next_x - x;
 101.973 -    h = TextF_FontAscent(tdata->widget) + TextF_FontDescent(tdata->widget);
 101.974 -
 101.975 -    AWT_UNLOCK();
 101.976 -
 101.977 -    if (w>0) {
 101.978 -        jclass clazz;
 101.979 -        jmethodID mid;
 101.980 -
 101.981 -        clazz = (*env)->FindClass(env, "java/awt/Rectangle");
 101.982 -        mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
 101.983 -        if (mid != NULL) {
 101.984 -            rect = (*env)->NewObject(env, clazz, mid, x, y, w, h);
 101.985 -            if ((*env)->ExceptionOccurred(env)) {
 101.986 -                return NULL;
 101.987 -            }
 101.988 -        }
 101.989 -    }
 101.990 -    return rect;
 101.991 -}
 101.992 -*/
   102.1 --- a/src/solaris/native/sun/awt/awt_TextField.h	Wed Sep 17 13:45:37 2008 -0700
   102.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   102.3 @@ -1,36 +0,0 @@
   102.4 -/*
   102.5 - * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
   102.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   102.7 - *
   102.8 - * This code is free software; you can redistribute it and/or modify it
   102.9 - * under the terms of the GNU General Public License version 2 only, as
  102.10 - * published by the Free Software Foundation.  Sun designates this
  102.11 - * particular file as subject to the "Classpath" exception as provided
  102.12 - * by Sun in the LICENSE file that accompanied this code.
  102.13 - *
  102.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  102.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  102.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  102.17 - * version 2 for more details (a copy is included in the LICENSE file that
  102.18 - * accompanied this code).
  102.19 - *
  102.20 - * You should have received a copy of the GNU General Public License version
  102.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  102.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  102.23 - *
  102.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  102.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  102.26 - * have any questions.
  102.27 - */
  102.28 -
  102.29 -#include "jni_util.h"
  102.30 -
  102.31 -/* fieldIDs for TextField fields that may be accessed from C */
  102.32 -static struct TextFieldIDs {
  102.33 -    jfieldID echoChar;
  102.34 -};
  102.35 -
  102.36 -/* fieldIDs for MTextFieldPeer fields that may be accessed from C */
  102.37 -struct MTextFieldPeerIDs {
  102.38 -    jfieldID firstChangeSkipped;
  102.39 -};
   103.1 --- a/src/solaris/native/sun/awt/awt_TopLevel.c	Wed Sep 17 13:45:37 2008 -0700
   103.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   103.3 @@ -1,5095 +0,0 @@
   103.4 -/*
   103.5 - * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
   103.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   103.7 - *
   103.8 - * This code is free software; you can redistribute it and/or modify it
   103.9 - * under the terms of the GNU General Public License version 2 only, as
  103.10 - * published by the Free Software Foundation.  Sun designates this
  103.11 - * particular file as subject to the "Classpath" exception as provided
  103.12 - * by Sun in the LICENSE file that accompanied this code.
  103.13 - *
  103.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  103.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  103.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  103.17 - * version 2 for more details (a copy is included in the LICENSE file that
  103.18 - * accompanied this code).
  103.19 - *
  103.20 - * You should have received a copy of the GNU General Public License version
  103.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  103.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  103.23 - *
  103.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  103.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  103.26 - * have any questions.
  103.27 - */
  103.28 -
  103.29 -#ifdef HEADLESS
  103.30 -    #error This file should not be included in headless library
  103.31 -#endif
  103.32 -
  103.33 -#include "awt_p.h"
  103.34 -
  103.35 -#include <X11/Shell.h>
  103.36 -#include <Xm/VendorS.h>
  103.37 -#include <Xm/Form.h>
  103.38 -#include <Xm/DialogS.h>
  103.39 -#include <Xm/AtomMgr.h>
  103.40 -#include <Xm/Protocols.h>
  103.41 -#include <Xm/MenuShell.h>
  103.42 -#include <Xm/MwmUtil.h>
  103.43 -#include "VDrawingArea.h"
  103.44 -
  103.45 -#ifdef DEBUG
  103.46 -#  include <X11/Xmu/Editres.h>
  103.47 -#endif
  103.48 -
  103.49 -#include <jni.h>
  103.50 -#include <jni_util.h>
  103.51 -
  103.52 -/* JNI headers */
  103.53 -#include "java_awt_Color.h"
  103.54 -#include "java_awt_Component.h"
  103.55 -#include "java_awt_Dialog.h"
  103.56 -#include "java_awt_Font.h"
  103.57 -#include "java_awt_Frame.h"
  103.58 -#include "java_awt_Image.h"
  103.59 -#include "java_awt_Insets.h"
  103.60 -#include "java_awt_Insets.h"
  103.61 -#include "java_awt_MenuBar.h"
  103.62 -#include "java_awt_Window.h"
  103.63 -#include "java_awt_event_FocusEvent.h"
  103.64 -#include "java_awt_TrayIcon.h"
  103.65 -#include "sun_awt_EmbeddedFrame.h"
  103.66 -#include "sun_awt_motif_MComponentPeer.h"
  103.67 -#include "sun_awt_motif_MDialogPeer.h"
  103.68 -#include "sun_awt_motif_MEmbeddedFramePeer.h"
  103.69 -#include "sun_awt_motif_MFramePeer.h"
  103.70 -#include "sun_awt_motif_MMenuBarPeer.h"
  103.71 -#include "sun_awt_motif_MWindowPeer.h"
  103.72 -
  103.73 -/* JNI field and method ids */
  103.74 -#include "awt_Component.h"
  103.75 -#include "awt_GraphicsEnv.h"
  103.76 -#include "awt_Insets.h"
  103.77 -#include "awt_MenuBar.h"
  103.78 -#include "awt_Window.h"
  103.79 -#include "awt_KeyboardFocusManager.h"
  103.80 -#include "awt_MToolkit.h"
  103.81 -#include "awt_Plugin.h"
  103.82 -
  103.83 -#include "color.h"
  103.84 -#include "canvas.h"
  103.85 -#include "awt_util.h"
  103.86 -#include "img_util.h"
  103.87 -#include "awt_wm.h"
  103.88 -#include "awt_util.h"
  103.89 -#include "awt_xembed.h"
  103.90 -
  103.91 -
  103.92 -#ifdef __linux__
  103.93 -void adjustStatusWindow(Widget shell);
  103.94 -#endif
  103.95 -/* For the moment only InputMethodWindow is taking advantage of
  103.96 -** the posibility for different decor styles
  103.97 -** values could be passed are the MWM_DECOR defines
  103.98 -** for the moment we are full on or full off.
  103.99 -*/
 103.100 -#define AWT_NO_DECOR    0x0
 103.101 -#define AWT_FULL_DECOR  MWM_DECOR_ALL
 103.102 -
 103.103 -static void reshape(JNIEnv *env, jobject this, struct FrameData *wdata,
 103.104 -                    jint x, jint y, jint w, jint h, Boolean setXY);
 103.105 -Widget findTopLevelByShell(Widget widget);
 103.106 -
 103.107 -extern EmbeddedFrame *theEmbeddedFrameList;
 103.108 -extern struct ComponentIDs componentIDs;
 103.109 -extern struct MMenuBarPeerIDs mMenuBarPeerIDs;
 103.110 -extern struct MComponentPeerIDs mComponentPeerIDs;
 103.111 -struct WindowIDs windowIDs;
 103.112 -struct MWindowPeerIDs mWindowPeerIDs;
 103.113 -extern struct InsetsIDs insetsIDs;
 103.114 -extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
 103.115 -extern struct KeyboardFocusManagerIDs keyboardFocusManagerIDs;
 103.116 -extern struct X11GraphicsDeviceIDs x11GraphicsDeviceIDs;
 103.117 -
 103.118 -#ifndef NOMODALFIX
 103.119 -extern Boolean awt_isModal();
 103.120 -extern Boolean awt_isWidgetModal(Widget w);
 103.121 -extern void awt_shellPoppedUp(Widget shell, XtPointer c, XtPointer d);
 103.122 -extern void awt_shellPoppedDown(Widget shell, XtPointer c, XtPointer d);
 103.123 -#endif //NOMODALFIX
 103.124 -
 103.125 -static jclass inputMethodWindowClass = NULL;
 103.126 -
 103.127 -static int32_t globalTopGuess    = 0;
 103.128 -static int32_t globalLeftGuess   = 0;
 103.129 -static int32_t globalBottomGuess = 0;
 103.130 -static int32_t globalRightGuess  = 0;
 103.131 -
 103.132 -
 103.133 -// Atom used for otlogenniy top-level disposal
 103.134 -static Atom _XA_JAVA_DISPOSE_PROPERTY_ATOM = 0;
 103.135 -
 103.136 -/*
 103.137 - * Fix for bug 4141361
 103.138 - *
 103.139 - * We keep a linked list of the FrameData information for
 103.140 - * every top level window.
 103.141 - */
 103.142 -struct FrameDataList {
 103.143 -    struct FrameData* wdata;
 103.144 -    struct FrameDataList* next;
 103.145 -};
 103.146 -
 103.147 -static struct FrameDataList* allTopLevel = NULL;
 103.148 -
 103.149 -extern void checkNewXineramaScreen(JNIEnv* env, jobject peer,
 103.150 -                                   struct FrameData* wdata,
 103.151 -                                   int32_t newX, int32_t newY,
 103.152 -                                   int32_t newWidth, int32_t newHeight);
 103.153 -
 103.154 -// Returns false if this Window is non-focusable
 103.155 -// or its nearest decorated parent is non-focusable.
 103.156 -Boolean isFocusableWindowByPeer(JNIEnv * env, jobject peer) {
 103.157 -    jobject target, decoratedParent;
 103.158 -    struct FrameData *wdata;
 103.159 -    Boolean focusable;
 103.160 -
 103.161 -    wdata = (struct FrameData *)JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
 103.162 -    DASSERT(wdata != NULL);
 103.163 -
 103.164 -    target = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
 103.165 -    DASSERT(target != NULL);
 103.166 -
 103.167 -    decoratedParent = getOwningFrameOrDialog(target, env);
 103.168 -    (*env)->DeleteLocalRef(env, target);
 103.169 -
 103.170 -    if (decoratedParent == NULL) {
 103.171 -        return wdata->isFocusableWindow;
 103.172 -    } else {
 103.173 -        jobject parentPeer = (*env)->GetObjectField(env, decoratedParent, componentIDs.peer);
 103.174 -        DASSERT(parentPeer != NULL);
 103.175 -        focusable = wdata->isFocusableWindow && isFocusableWindowByPeer(env, parentPeer);
 103.176 -
 103.177 -        (*env)->DeleteLocalRef(env, decoratedParent);
 103.178 -        (*env)->DeleteLocalRef(env, parentPeer);
 103.179 -    }
 103.180 -    return focusable;
 103.181 -}
 103.182 -
 103.183 -// Returns false if this shell's Java Window is non-focusable
 103.184 -// or its nearest decorated parent is non-focusable.
 103.185 -// Returns true otherwise or if any of parameters is NULL
 103.186 -Boolean isFocusableWindowByShell(JNIEnv* env, Widget shell) {
 103.187 -    Widget toplevel;
 103.188 -    jobject peer;
 103.189 -    Boolean focusable;
 103.190 -
 103.191 -    DASSERT(shell != NULL && XtIsShell(shell));
 103.192 -    if (shell == NULL) return True;
 103.193 -    if (!XtIsShell(shell)) return True;
 103.194 -
 103.195 -    toplevel = findTopLevelByShell(shell);
 103.196 -    if (toplevel == NULL) {
 103.197 -        return True;
 103.198 -    }
 103.199 -    peer = findPeer(&toplevel);
 103.200 -    DASSERT(peer != NULL);
 103.201 -
 103.202 -    if (env == NULL) {
 103.203 -        env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 103.204 -    }
 103.205 -    return isFocusableWindowByPeer(env, peer);
 103.206 -}
 103.207 -
 103.208 -
 103.209 -// Returns Shell widget - the parent of this child
 103.210 -Widget getShellWidget(Widget child) {
 103.211 -
 103.212 -    while (child != NULL && !XtIsShell(child)) {
 103.213 -        child = XtParent(child);
 103.214 -    }
 103.215 -    return child;
 103.216 -}
 103.217 -
 103.218 -// Returns false if the parent shell of this widget is non-focusable Java Window.
 103.219 -// Returns false otherwise.
 103.220 -// Doesn't accept NULL parameters.
 103.221 -Boolean isFocusableComponentTopLevelByWidget(JNIEnv * env, Widget child) {
 103.222 -    Widget shell = NULL;
 103.223 -    shell = getShellWidget(child);
 103.224 -    DASSERT(shell);
 103.225 -    return isFocusableWindowByShell(env, shell);
 103.226 -}
 103.227 -
 103.228 -
 103.229 -/*
 103.230 - * Add a new element into the top level window list
 103.231 - */
 103.232 -void addTopLevel(struct FrameData* wdata) {
 103.233 -    struct FrameDataList* newNode;
 103.234 -    newNode = (struct FrameDataList*)
 103.235 -        malloc(sizeof(struct FrameDataList));
 103.236 -    newNode->wdata = wdata;
 103.237 -    newNode->next = allTopLevel;
 103.238 -    allTopLevel = newNode;
 103.239 -}
 103.240 -
 103.241 -/*
 103.242 - * Remove an element from the top level window list
 103.243 - * (recursive)
 103.244 - */
 103.245 -Boolean removeTopLevelR(struct FrameDataList** ptr,
 103.246 -    struct FrameData* wdata) {
 103.247 -    struct FrameDataList* node = *ptr;
 103.248 -    if (node == NULL) {
 103.249 -        return False;
 103.250 -    }
 103.251 -    if (node->wdata == wdata) {
 103.252 -        *ptr = node->next;
 103.253 -        free(node);
 103.254 -        return True;
 103.255 -    }
 103.256 -    return removeTopLevelR(&(node->next), wdata);
 103.257 -}
 103.258 -
 103.259 -Boolean removeTopLevel(struct FrameData* wdata) {
 103.260 -    return removeTopLevelR(&allTopLevel, wdata);
 103.261 -}
 103.262 -
 103.263 -/*
 103.264 - * Return the Widget ID of the top level window underneath the
 103.265 - * mouse pointer.
 103.266 - */
 103.267 -Widget awt_GetWidgetAtPointer() {
 103.268 -    struct FrameDataList* ptr = allTopLevel;
 103.269 -    Window rootWindow, childWindow, mainWindow;
 103.270 -    int32_t xw, yw, xr, yr;
 103.271 -    uint32_t keys;
 103.272 -    while (ptr != NULL) {
 103.273 -        mainWindow = XtWindow(ptr->wdata->mainWindow);
 103.274 -        XQueryPointer(awt_display, mainWindow,
 103.275 -            &rootWindow, &childWindow, &xr, &yr, &xw, &yw, &keys);
 103.276 -        if (childWindow != None) {
 103.277 -            return ptr->wdata->winData.comp.widget;
 103.278 -        }
 103.279 -        ptr = ptr->next;
 103.280 -    }
 103.281 -    return NULL;
 103.282 -}
 103.283 -
 103.284 -Widget findFocusProxy(Widget widget) {
 103.285 -  struct FrameDataList* ptr = allTopLevel;
 103.286 -  for (ptr = allTopLevel; ptr != NULL; ptr = ptr->next) {
 103.287 -    if (ptr->wdata->winData.comp.widget == widget) {
 103.288 -      return ptr->wdata->focusProxy;
 103.289 -    }
 103.290 -  }
 103.291 -  return NULL;
 103.292 -}
 103.293 -
 103.294 -Widget findTopLevelByShell(Widget widget) {
 103.295 -  struct FrameDataList* ptr;
 103.296 -  for (ptr = allTopLevel; ptr != NULL; ptr = ptr->next) {
 103.297 -      if (ptr->wdata->winData.shell == widget) {
 103.298 -          return ptr->wdata->winData.comp.widget;
 103.299 -      }
 103.300 -  }
 103.301 -  return NULL;
 103.302 -}
 103.303 -
 103.304 -void
 103.305 -awt_Frame_guessInsets(struct FrameData *wdata)
 103.306 -{
 103.307 -    if (wdata->decor == AWT_NO_DECOR ) {
 103.308 -        wdata->top    = wdata->topGuess    = 0;
 103.309 -        wdata->left   = wdata->leftGuess   = 0;
 103.310 -        wdata->bottom = wdata->bottomGuess = 0;
 103.311 -        wdata->right  = wdata->rightGuess  = 0;
 103.312 -        return;
 103.313 -    }
 103.314 -
 103.315 -    if (globalTopGuess == 0) {
 103.316 -        char *insets_env;
 103.317 -
 103.318 -        if (wdata->top >= 0) {
 103.319 -            /* insets were set on wdata by System Properties */
 103.320 -            globalTopGuess    = wdata->top;
 103.321 -            globalLeftGuess   = wdata->left;
 103.322 -            globalBottomGuess = wdata->bottom;
 103.323 -            globalRightGuess  = wdata->right;
 103.324 -        }
 103.325 -        else switch (awt_wm_getRunningWM()) {
 103.326 -        case ENLIGHTEN_WM:
 103.327 -            globalTopGuess    = 19;
 103.328 -            globalLeftGuess   =  4;
 103.329 -            globalBottomGuess =  4;
 103.330 -            globalRightGuess  =  4;
 103.331 -            break;
 103.332 -
 103.333 -        case CDE_WM:
 103.334 -            globalTopGuess    = 28;
 103.335 -            globalLeftGuess   =  6;
 103.336 -            globalBottomGuess =  6;
 103.337 -            globalRightGuess  =  6;
 103.338 -            break;
 103.339 -
 103.340 -        case MOTIF_WM:
 103.341 -        case OPENLOOK_WM:
 103.342 -        default:
 103.343 -            globalTopGuess    = 25;
 103.344 -            globalLeftGuess   =  5;
 103.345 -            globalBottomGuess =  5;
 103.346 -            globalRightGuess  =  5;
 103.347 -            break;
 103.348 -        }
 103.349 -
 103.350 -        if ((insets_env = getenv("AWT_INSETS")) != NULL) {
 103.351 -            int guess = atoi(insets_env);
 103.352 -            globalTopGuess    = (guess & 0xff00) >> 8;
 103.353 -            globalLeftGuess   = guess & 0x00ff;
 103.354 -            globalBottomGuess = wdata->leftGuess;
 103.355 -            globalRightGuess  = wdata->leftGuess;
 103.356 -        }
 103.357 -
 103.358 -        /* don't allow bizarly large insets */
 103.359 -        if ((globalTopGuess > 64) || (globalTopGuess < 0))
 103.360 -            globalTopGuess = 28;
 103.361 -        if ((globalLeftGuess > 32) || (globalLeftGuess < 0))
 103.362 -            globalLeftGuess = 6;
 103.363 -        if ((globalBottomGuess > 32) || (globalBottomGuess < 0))
 103.364 -            globalBottomGuess = 6;
 103.365 -        if ((globalRightGuess > 32) || (globalRightGuess < 0))
 103.366 -            globalRightGuess = 6;
 103.367 -    }
 103.368 -
 103.369 -    wdata->top    = wdata->topGuess    = globalTopGuess;
 103.370 -    wdata->left   = wdata->leftGuess   = globalLeftGuess;
 103.371 -    wdata->bottom = wdata->bottomGuess = globalBottomGuess;
 103.372 -    wdata->right  = wdata->rightGuess  = globalRightGuess;
 103.373 -}
 103.374 -
 103.375 -/*
 103.376 - * To keep input method windows floating, maintain a list of all
 103.377 - * input method windows here.  When some top level window gets
 103.378 - * activated, moved, or resized, these input method windows need
 103.379 - * to be brought on top.
 103.380 - */
 103.381 -static struct FrameDataList* allInputMethodWindow = NULL;
 103.382 -
 103.383 -/*
 103.384 - * Add a new element into the input method window list
 103.385 - */
 103.386 -void addInputMethodWindow(struct FrameData* wdata) {
 103.387 -    struct FrameDataList* newNode;
 103.388 -    newNode = (struct FrameDataList*)
 103.389 -        malloc(sizeof(struct FrameDataList));
 103.390 -    newNode->wdata = wdata;
 103.391 -    newNode->next = allInputMethodWindow;
 103.392 -    allInputMethodWindow = newNode;
 103.393 -}
 103.394 -
 103.395 -/*
 103.396 - * Remove an element from the top level window list
 103.397 - * (recursive)
 103.398 - */
 103.399 -Boolean removeInputMethodWindowR(struct FrameDataList** ptr,
 103.400 -    struct FrameData* wdata) {
 103.401 -    struct FrameDataList* node = *ptr;
 103.402 -    if (node == NULL) {
 103.403 -        return False;
 103.404 -    }
 103.405 -    if (node->wdata == wdata) {
 103.406 -        *ptr = node->next;
 103.407 -        free(node);
 103.408 -        return True;
 103.409 -    }
 103.410 -    return removeInputMethodWindowR(&(node->next), wdata);
 103.411 -}
 103.412 -
 103.413 -Boolean removeInputMethodWindow(struct FrameData* wdata) {
 103.414 -    return removeInputMethodWindowR(&allInputMethodWindow, wdata);
 103.415 -}
 103.416 -
 103.417 -/*
 103.418 - * Raise input method windows
 103.419 - */
 103.420 -void raiseInputMethodWindow(struct FrameData* wdata) {
 103.421 -    struct FrameDataList* node = allInputMethodWindow;
 103.422 -
 103.423 -    if (wdata->isInputMethodWindow) {
 103.424 -        return;
 103.425 -    }
 103.426 -
 103.427 -    while (node != NULL) {
 103.428 -        XRaiseWindow(awt_display, XtWindow(node->wdata->winData.shell));
 103.429 -        node = node->next;
 103.430 -    }
 103.431 -}
 103.432 -
 103.433 -/* fieldIDs for Frame fields that may be accessed from C */
 103.434 -static struct FrameIDs {
 103.435 -    jfieldID resizable;
 103.436 -    jfieldID state;
 103.437 -} frameIDs;
 103.438 -
 103.439 -/*
 103.440 - * Class:     java_awt_Frame
 103.441 - * Method:    initIDs
 103.442 - * Signature: ()V
 103.443 - */
 103.444 -
 103.445 -/* This function gets called from the static initializer for Frame.java
 103.446 -   to initialize the fieldIDs for fields that may be accessed from C */
 103.447 -JNIEXPORT void JNICALL
 103.448 -Java_java_awt_Frame_initIDs
 103.449 -  (JNIEnv *env, jclass cls)
 103.450 -{
 103.451 -    frameIDs.resizable = (*env)->GetFieldID(env, cls, "resizable", "Z");
 103.452 -    frameIDs.state = (*env)->GetFieldID(env, cls, "state", "I");
 103.453 -}
 103.454 -
 103.455 -/* ******* */
 103.456 -/* Dialogs */
 103.457 -/* ******* */
 103.458 -/* No longer have a need for unique fields for query */
 103.459 -static struct DialogIDs {
 103.460 -    jfieldID modal;
 103.461 -    jfieldID resizable;
 103.462 -} dialogIDs;
 103.463 -
 103.464 -JNIEXPORT void JNICALL
 103.465 -Java_java_awt_Dialog_initIDs
 103.466 -  (JNIEnv *env, jclass cls)
 103.467 -{
 103.468 -#if 0
 103.469 -    dialogIDs.modal = (*env)->GetFieldID(env, cls, "modal", "Z");
 103.470 -    dialogIDs.resizable = (*env)->GetFieldID(env, cls, "resizable", "Z");
 103.471 -#endif
 103.472 -}
 103.473 -
 103.474 -/* ******* */
 103.475 -/* Windows */
 103.476 -/* ******* */
 103.477 -
 103.478 -JNIEXPORT void JNICALL
 103.479 -Java_java_awt_Window_initIDs
 103.480 -  (JNIEnv *env, jclass cls)
 103.481 -{
 103.482 -    windowIDs.warningString = (*env)->GetFieldID(env, cls, "warningString",
 103.483 -                                                 "Ljava/lang/String;");
 103.484 -    windowIDs.resetGCMID = (*env)->GetMethodID(env, cls, "resetGC",
 103.485 -                                                 "()V");
 103.486 -
 103.487 -    windowIDs.locationByPlatform = (*env)->GetFieldID(env, cls, "locationByPlatform",
 103.488 -                                                        "Z");
 103.489 -    windowIDs.isAutoRequestFocus = (*env)->GetFieldID(env, cls, "autoRequestFocus", "Z");
 103.490 -
 103.491 -    DASSERT(windowIDs.resetGCMID);
 103.492 -}
 103.493 -
 103.494 -/*
 103.495 - * Class:     sun_motif_awt_WindowAttributes
 103.496 - * Method:    initIDs
 103.497 - * Signature: ()V
 103.498 - */
 103.499 -
 103.500 -static struct MWindowAttributeIDs {
 103.501 -    jfieldID nativeDecor;
 103.502 -    jfieldID initialFocus;
 103.503 -    jfieldID isResizable;
 103.504 -    jfieldID initialState;
 103.505 -    jfieldID visibilityState;
 103.506 -    jfieldID decorations;
 103.507 -} mWindowAttributeIDs;
 103.508 -
 103.509 -JNIEXPORT void JNICALL
 103.510 -Java_sun_awt_motif_MWindowAttributes_initIDs
 103.511 -  (JNIEnv *env, jclass cls)
 103.512 -{
 103.513 -    mWindowAttributeIDs.nativeDecor =
 103.514 -        (*env)->GetFieldID(env, cls, "nativeDecor", "Z");
 103.515 -    mWindowAttributeIDs.initialFocus =
 103.516 -        (*env)->GetFieldID(env, cls, "initialFocus", "Z");
 103.517 -    mWindowAttributeIDs.isResizable =
 103.518 -        (*env)->GetFieldID(env, cls, "isResizable", "Z");
 103.519 -    mWindowAttributeIDs.initialState =
 103.520 -        (*env)->GetFieldID(env, cls, "initialState", "I");
 103.521 -    mWindowAttributeIDs.visibilityState =
 103.522 -        (*env)->GetFieldID(env, cls, "visibilityState", "I");
 103.523 -    mWindowAttributeIDs.decorations =
 103.524 -        (*env)->GetFieldID(env, cls, "decorations", "I");
 103.525 -}
 103.526 -
 103.527 -/*
 103.528 - * Class:     sun_awt_motif_MWindowPeer
 103.529 - * Method:    initIDs
 103.530 - * Signature: ()V
 103.531 - */
 103.532 -
 103.533 -/* This function gets called from the static initializer for MWindowPeer.java
 103.534 -   to initialize the fieldIDs for fields that may be accessed from C */
 103.535 -
 103.536 -JNIEXPORT void JNICALL
 103.537 -Java_sun_awt_motif_MWindowPeer_initIDs
 103.538 -  (JNIEnv *env, jclass cls)
 103.539 -{
 103.540 -    mWindowPeerIDs.insets =
 103.541 -        (*env)->GetFieldID(env, cls, "insets", "Ljava/awt/Insets;");
 103.542 -    mWindowPeerIDs.winAttr =
 103.543 -        (*env)->GetFieldID( env,
 103.544 -                            cls,
 103.545 -                            "winAttr",
 103.546 -                            "Lsun/awt/motif/MWindowAttributes;"
 103.547 -                          );
 103.548 -    mWindowPeerIDs.iconWidth =
 103.549 -        (*env)->GetFieldID(env, cls, "iconWidth", "I");
 103.550 -    mWindowPeerIDs.iconHeight =
 103.551 -        (*env)->GetFieldID(env, cls, "iconHeight", "I");
 103.552 -    mWindowPeerIDs.handleWindowFocusOut =
 103.553 -        (*env)->GetMethodID(env,
 103.554 -                            cls,
 103.555 -                            "handleWindowFocusOut",
 103.556 -                            "(Ljava/awt/Window;)V");
 103.557 -    mWindowPeerIDs.handleWindowFocusIn =
 103.558 -        (*env)->GetMethodID(env,
 103.559 -                            cls,
 103.560 -                            "handleWindowFocusIn",
 103.561 -                            "()V");
 103.562 -    mWindowPeerIDs.handleIconify =
 103.563 -        (*env)->GetMethodID(env,
 103.564 -                            cls,
 103.565 -                            "handleIconify",
 103.566 -                            "()V");
 103.567 -    mWindowPeerIDs.handleDeiconify =
 103.568 -        (*env)->GetMethodID(env,
 103.569 -                            cls,
 103.570 -                            "handleDeiconify",
 103.571 -                            "()V");
 103.572 -    mWindowPeerIDs.handleStateChange =
 103.573 -        (*env)->GetMethodID(env,
 103.574 -                            cls,
 103.575 -                            "handleStateChange",
 103.576 -                            "(II)V");
 103.577 -
 103.578 -    mWindowPeerIDs.draggedToScreenMID = (*env)->GetMethodID(env, cls,
 103.579 -                                                           "draggedToNewScreen",
 103.580 -                                                           "(I)V");
 103.581 -    DASSERT(mWindowPeerIDs.draggedToScreenMID);
 103.582 -}
 103.583 -
 103.584 -/*
 103.585 - * Class:     sun_awt_motif_MWindowPeer
 103.586 - * Method:    wrapInSequenced
 103.587 - * Signature: (Ljava/awt/AWTEvent;)Ljava/awt/SequencedEvent;
 103.588 - */
 103.589 -
 103.590 -/* This method gets called from MWindowPeer to wrap a FocusEvent in
 103.591 -   a SequencedEvent. We have to do this in native code, because we
 103.592 -   don't want to make SequencedEvent a public class. */
 103.593 -
 103.594 -JNIEXPORT jobject JNICALL
 103.595 -Java_sun_awt_motif_MWindowPeer_wrapInSequenced
 103.596 -  (JNIEnv *env, jobject this, jobject awtevent)
 103.597 -{
 103.598 -  jobject global = awt_canvas_wrapInSequenced(awtevent);
 103.599 -  jobject local = (*env)->NewLocalRef(env, global);
 103.600 -  (*env)->DeleteGlobalRef(env, global);
 103.601 -  return local;
 103.602 -}
 103.603 -
 103.604 -extern jobject findTopLevelOpposite();
 103.605 -
 103.606 -/*
 103.607 - * Class:     sun_awt_motif_MWindowPeer
 103.608 - * Method:    findOpposite
 103.609 - * Signature: (Ljava/awt/AWTEvent;)Ljava/awt/Window;
 103.610 - */
 103.611 -
 103.612 -JNIEXPORT jobject JNICALL
 103.613 -Java_sun_awt_motif_MWindowPeer_findOpposite
 103.614 -    (JNIEnv *env, jobject this, jint eventType)
 103.615 -{
 103.616 -#ifdef HEADLESS
 103.617 -    return NULL;
 103.618 -#else
 103.619 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
 103.620 -        return NULL;
 103.621 -    }
 103.622 -
 103.623 -    return findTopLevelOpposite(env, eventType);
 103.624 -#endif
 103.625 -}
 103.626 -
 103.627 -/* changeInsets() sets target's insets equal to X/Motif values. */
 103.628 -
 103.629 -static void
 103.630 -awtJNI_ChangeInsets(JNIEnv * env, jobject this, struct FrameData *wdata)
 103.631 -{
 103.632 -    jobject insets;
 103.633 -
 103.634 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0)
 103.635 -        return;
 103.636 -
 103.637 -    insets = (*env)->GetObjectField(env, this, mWindowPeerIDs.insets);
 103.638 -
 103.639 -    if (JNU_IsNull(env, insets)) {
 103.640 -        return;
 103.641 -    }
 103.642 -
 103.643 -    (*env)->SetIntField(env, insets, insetsIDs.top, wdata->top);
 103.644 -    (*env)->SetIntField(env, insets, insetsIDs.left, wdata->left);
 103.645 -    (*env)->SetIntField(env, insets, insetsIDs.bottom, wdata->bottom);
 103.646 -    (*env)->SetIntField(env, insets, insetsIDs.right, wdata->right);
 103.647 -
 103.648 -    /* Fix for 4106068: don't do it, rely on the window */
 103.649 -    /*   manager maximizing policy instead              */
 103.650 -#if 0
 103.651 -    /* when the insets get set, make sure we set the proper */
 103.652 -    /* max window size (since it's dependent on inset size) */
 103.653 -    if (wdata->isResizable) {
 103.654 -        int32_t screenWidth = XWidthOfScreen( XDefaultScreenOfDisplay(awt_display));
 103.655 -        int32_t screenHeight= XHeightOfScreen(XDefaultScreenOfDisplay(awt_display));
 103.656 -        XtVaSetValues(wdata->winData.shell,
 103.657 -                XmNmaxWidth, screenWidth - (wdata->left + wdata->right),
 103.658 -                XmNmaxHeight, screenHeight - (wdata->top + wdata->bottom),
 103.659 -                NULL);
 103.660 -    }
 103.661 -#endif
 103.662 -    (*env)->DeleteLocalRef(env, insets);
 103.663 -}
 103.664 -
 103.665 -
 103.666 -/* setMbAndWwHeightAndOffsets() attempts to establish the heights
 103.667 -   of frame's menu bar and warning window (if present in frame).
 103.668 -   setMbAndWwHeightAndOffsets() also adjusts appropriately the
 103.669 -   X/Motif offsets and calls changeInsets() to set target insets.
 103.670 -   A warning window, if present, is established during ...create().
 103.671 -   wdata->warningWindow is set there, wdata->wwHeight is set here.
 103.672 -   Routine pSetMenuBar() sets value of the wdata->menuBar field.
 103.673 -   This routine reads that value. If it is not null, a menubar
 103.674 -   has been added.  In this case, calculate the current height
 103.675 -   of the menu bar.  This may be a partial (incomplete) menubar
 103.676 -   because ths routine may be called before the X/Motif menubar
 103.677 -   is completely realized. In this case, the menubar height may
 103.678 -   be adjusted incrementally.  This routine may be called from
 103.679 -   ...pSetMenuBar(), innerCanvasEH(), and ...pReshape(). It is
 103.680 -   designed to (eventually) obtain the correct menubar height.
 103.681 -   On the other hand, if wdata->menuBar is NULL and the stored
 103.682 -   menubar height is not zero, then we subtract off the height. */
 103.683 -
 103.684 -static void
 103.685 -awtJNI_setMbAndWwHeightAndOffsets(JNIEnv * env,
 103.686 -                                  jobject this,
 103.687 -                                  struct FrameData *wdata )
 103.688 -{
 103.689 -    Dimension   warningHeight,  /* Motif warning window height  */
 103.690 -                labelHeight;    /* Motif warning label's height */
 103.691 -
 103.692 -    WidgetList  warningChildrenWL; /* warning children widgets  */
 103.693 -
 103.694 -    Dimension   menuBarWidth,   /* Motif menubar width          */
 103.695 -                menuBarHeight,  /* Motif menubar height         */
 103.696 -                menuBarBorderSize, /* Motif menubar border size */
 103.697 -                marginHeight,   /* Motif menubar margin height  */
 103.698 -                menuHeight,     /* Motif menubar's menu height  */
 103.699 -                menuBorderSize, /* Motif menu border size       */
 103.700 -                actualHeight;   /* height: menu+margins+borders */
 103.701 -
 103.702 -    WidgetList  menuBarChildrenWL; /* menubar children widgets  */
 103.703 -    Cardinal    numberChildren; /* number of menubar children   */
 103.704 -
 103.705 -#ifdef _pauly_debug
 103.706 -    fprintf(stdout," ++ setMenuBar\n");
 103.707 -    fflush(stdout);
 103.708 -#endif /* _pauly_debug */
 103.709 -
 103.710 -    /* If warning window height not yet known, try to get it now.
 103.711 -       It will be added to top or bottom (iff NETSCAPE) offset. */
 103.712 -    if  (wdata->warningWindow != NULL) {
 103.713 -        XtVaGetValues(wdata->warningWindow,
 103.714 -                      XmNheight, &warningHeight,
 103.715 -                      XmNchildren, &warningChildrenWL,
 103.716 -                      XmNnumChildren, &numberChildren,
 103.717 -                      NULL);
 103.718 -
 103.719 -        /* We may be doing this before warning window is realized ! So,
 103.720 -           check for a child label in the warning. If its height is not
 103.721 -           yet accounted for in the warning height, then use it here.   */
 103.722 -        if  (numberChildren != 0) {
 103.723 -            XtVaGetValues(warningChildrenWL[0],
 103.724 -                          XmNheight, &labelHeight,
 103.725 -                          NULL);
 103.726 -#ifdef _pauly_debug
 103.727 -            fprintf(stdout,"    setMenuBar.... warning label found with height: %d\n", labelHeight);
 103.728 -            fflush(stdout);
 103.729 -#endif /* _pauly_debug */
 103.730 -            if  (warningHeight < labelHeight) {
 103.731 -#ifdef _pauly_debug
 103.732 -    fprintf(stdout,"    setMenuBar.... !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
 103.733 -    fflush(stdout);
 103.734 -#endif /* _pauly_debug */
 103.735 -                warningHeight = labelHeight;
 103.736 -            }
 103.737 -        }
 103.738 -
 103.739 -        if  (wdata->wwHeight < warningHeight) {
 103.740 -#ifdef _pauly_debug
 103.741 -            fprintf(stdout, "    setMenuBar.... adding warning height: %d\n", warningHeight);
 103.742 -            fflush(stdout);
 103.743 -#endif /* _pauly_debug */
 103.744 -#ifdef NETSCAPE
 103.745 -            wdata->bottom += (warningHeight - wdata->wwHeight);
 103.746 -#else
 103.747 -            wdata->top += (warningHeight - wdata->wwHeight);
 103.748 -#endif /* NETSCAPE */
 103.749 -            awtJNI_ChangeInsets(env, this, wdata);
 103.750 -            wdata->wwHeight = warningHeight;
 103.751 -        }
 103.752 -    }
 103.753 -
 103.754 -    /* Now we adjust offsets for an added or removed menu bar   */
 103.755 -    if  (wdata->menuBar != NULL) {
 103.756 -#ifdef _pauly_debug
 103.757 -        fprintf(stdout,"    setMenuBar.  menu bar: %x\n", wdata->menuBar);
 103.758 -        fflush(stdout);
 103.759 -#endif /* _pauly_debug */
 103.760 -        XtVaGetValues(wdata->menuBar,
 103.761 -                      XmNwidth, &menuBarWidth,
 103.762 -                      XmNheight, &menuBarHeight,
 103.763 -                      XmNchildren, &menuBarChildrenWL,
 103.764 -                      XmNnumChildren, &numberChildren,
 103.765 -                      XmNborderWidth, &menuBarBorderSize,
 103.766 -                      XmNmarginHeight, &marginHeight,
 103.767 -                      NULL);
 103.768 -
 103.769 -        /* We may be doing this before menu bar is realized ! Hence,
 103.770 -           check for a menu in the menu bar. If its height is not yet
 103.771 -           accounted for in the menu bar height, then add it in here.   */
 103.772 -        if  (numberChildren != 0) {
 103.773 -            XtVaGetValues(menuBarChildrenWL[0],
 103.774 -                          XmNheight, &menuHeight,
 103.775 -                          XmNborderWidth, &menuBorderSize,
 103.776 -                          NULL);
 103.777 -#ifdef _pauly_debug
 103.778 -            fprintf(stdout,"    setMenuBar.... menu found with height: %d, border: %d, margin: %d, bar border: %d\n", menuHeight, menuBorderSize, marginHeight, menuBarBorderSize);
 103.779 -            fflush(stdout);
 103.780 -#endif /* _pauly_debug */
 103.781 -            /* Calculate real height of menu bar by adding height of its
 103.782 -               child menu and borders, margins, and the menu bar borders*/
 103.783 -            actualHeight = menuHeight + (2 * menuBorderSize) +
 103.784 -                           (2 * marginHeight) + (2 * menuBarBorderSize);
 103.785 -#ifdef __linux__
 103.786 -#ifdef _pauly_debug
 103.787 -            fprintf(stdout,"  actual height: %d mb height %d\n", actualHeight, menuBarHeight);
 103.788 -            fflush(stdout);
 103.789 -#endif /* _pauly_debug */
 103.790 -#endif
 103.791 -            if  (menuBarHeight < actualHeight) {
 103.792 -#ifdef _pauly_debug
 103.793 -fprintf(stdout,"    setMenuBar.... ****************************************\n");
 103.794 -fflush(stdout);
 103.795 -#endif /* _pauly_debug */
 103.796 -                menuBarHeight = actualHeight;
 103.797 -            }
 103.798 -        }
 103.799 -
 103.800 -        if  (wdata->mbHeight < menuBarHeight) {
 103.801 -            /* Adjust the (partially) added menu bar height, top offset.*/
 103.802 -#ifdef _pauly_debug
 103.803 -            fprintf(stdout, "    setMenuBar.... added menuBar height: %d\n", menuBarHeight);
 103.804 -            fflush(stdout);
 103.805 -#endif /* _pauly_debug */
 103.806 -            wdata->top += (menuBarHeight - wdata->mbHeight);
 103.807 -            awtJNI_ChangeInsets(env, this, wdata);
 103.808 -            wdata->mbHeight = menuBarHeight;
 103.809 -        }
 103.810 -    } else if  ((wdata->menuBar == NULL) && (wdata->mbHeight > 0)) {
 103.811 -        /* A menu bar has been removed; subtract height from top offset.*/
 103.812 -        wdata->top -= wdata->mbHeight;
 103.813 -#ifdef _pauly_debug
 103.814 -        fprintf(stdout, "    setMenuBar.... removed menuBar height: %d\n", wdata->mbHeight);
 103.815 -        fflush(stdout);
 103.816 -#endif /* _pauly_debug */
 103.817 -        awtJNI_ChangeInsets(env, this, wdata);
 103.818 -        wdata->mbHeight = 0;
 103.819 -    }
 103.820 -}
 103.821 -
 103.822 -
 103.823 -/* outerCanvasResizeCB() is Motif resize callback for outer/child canvas.
 103.824 -   It reads width, height of Motif widget, sets java target accordingly,
 103.825 -   and then calls handleResize() to affect any changes.
 103.826 -   This call is only done for a shell resize or inner/parent resize;
 103.827 -   i.e., it may not be done for a ...pReshape() to avoid doing a loop.
 103.828 -
 103.829 -   client_data is MWindowPeer instance
 103.830 -*/
 103.831 -static void
 103.832 -outerCanvasResizeCB(Widget wd, XtPointer client_data, XtPointer call_data)
 103.833 -{
 103.834 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 103.835 -    jobject target;
 103.836 -    struct FrameData *wdata;
 103.837 -    Position    screenX;        /* x position of the canvas, screen */
 103.838 -    Position    screenY;        /* y position of the canvas, screen */
 103.839 -    Dimension   width;          /* width of the canvas, target  */
 103.840 -    Dimension   height;         /* height of the canvas, target */
 103.841 -    jint        oldWidth;
 103.842 -    jint        oldHeight;
 103.843 -
 103.844 -#ifdef _pauly_debug
 103.845 -    fprintf(stdout," ++ WindowResize.\n");
 103.846 -    fflush(stdout);
 103.847 -#endif /* _pauly_debug */
 103.848 -
 103.849 -    wdata = (struct FrameData *)
 103.850 -        JNU_GetLongFieldAsPtr(env, (jobject) client_data,
 103.851 -                              mComponentPeerIDs.pData);
 103.852 -    if (wdata == NULL) {
 103.853 -        return;
 103.854 -    }
 103.855 -
 103.856 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0)
 103.857 -        return;
 103.858 -
 103.859 -    target = (*env)->GetObjectField(env, (jobject) client_data,
 103.860 -                                    mComponentPeerIDs.target);
 103.861 -    XtVaGetValues(wd,
 103.862 -                  XmNwidth, &width,
 103.863 -                  XmNheight, &height,
 103.864 -                  NULL);
 103.865 -#ifdef _pauly_debug
 103.866 -    fprintf(stdout,"    outerCanvasResizeCB.  width: %d, height: %d\n", width, height);
 103.867 -    fflush(stdout);
 103.868 -#endif /* _pauly_debug */
 103.869 -
 103.870 -
 103.871 -    XtTranslateCoords(wd, 0, 0, &screenX, &screenY);
 103.872 -
 103.873 -    if  ((wdata->shellResized) || (wdata->canvasResized)) {
 103.874 -#ifdef _pauly_debug
 103.875 -        fprintf(stdout,"    outerCanvasResizeCB\n");
 103.876 -        fflush(stdout);
 103.877 -#endif /* _pauly_debug */
 103.878 -        wdata->shellResized = False;
 103.879 -        wdata->canvasResized = False;
 103.880 -        /*
 103.881 -        ** if you are not yet reparented, don't compute the size based on the
 103.882 -        ** widgets, as the window manager shell containg the insets is not yet
 103.883 -        ** there.  Use the size the application has set.
 103.884 -        ** If not reparented, we got here because the application set the size,
 103.885 -        ** so just send them Component.RESIZED event with the size they set.
 103.886 -        **
 103.887 -        ** If the reparenting causes a resize ( only when inset guess is wrong )        ** the new size will be sent in a Component.RESIZED event at that time.
 103.888 -        */
 103.889 -        if (wdata->reparented)
 103.890 -        {
 103.891 -            (*env)->SetIntField(env, target, componentIDs.x, (jint) screenX);
 103.892 -            (*env)->SetIntField(env, target, componentIDs.y, (jint) screenY);
 103.893 -        }
 103.894 -
 103.895 -    oldWidth = (*env)->GetIntField(env, target, componentIDs.width);
 103.896 -    oldHeight = (*env)->GetIntField(env, target, componentIDs.height);
 103.897 -
 103.898 -    if (oldWidth != width || oldHeight != height || wdata->need_reshape)
 103.899 -    {
 103.900 -        wdata->need_reshape = False;
 103.901 -        (*env)->SetIntField(env, target, componentIDs.width, (jint)width);
 103.902 -        (*env)->SetIntField(env, target, componentIDs.height,
 103.903 -                (jint)height);
 103.904 -
 103.905 -        /* only do this for Windows, not Canvases, btw */
 103.906 -        checkNewXineramaScreen(env, client_data, wdata, screenX, screenY, width, height);
 103.907 -
 103.908 -        JNU_CallMethodByName(env, NULL, (jobject) client_data,
 103.909 -                 "handleResize", "(II)V", width, height);
 103.910 -        if  ((*env)->ExceptionOccurred(env)) {
 103.911 -            (*env)->ExceptionDescribe(env);
 103.912 -        (*env)->ExceptionClear(env);
 103.913 -        }
 103.914 -    }
 103.915 -    }
 103.916 -
 103.917 -    (*env)->DeleteLocalRef(env, target);
 103.918 -
 103.919 -#ifdef _pauly_debug
 103.920 -    fprintf(stdout,"    WindowResize. Done.\n");
 103.921 -    fflush(stdout);
 103.922 -#endif /* _pauly_debug */
 103.923 -
 103.924 -} /* outerCanvasResizeCB() */
 103.925 -
 103.926 -static void reconfigureOuterCanvas ( JNIEnv *env, jobject target,
 103.927 -                                     jobject this, struct FrameData *wdata )
 103.928 -{
 103.929 -    Dimension   innerDAWidth,   /* width of inner Motif canvas  */
 103.930 -                innerDAHeight,  /* height of inner Motif canvas */
 103.931 -                outerDAWidth,   /* width of outer Motif canvas  */
 103.932 -                outerDAHeight;  /* height of outer Motif canvas */
 103.933 -    int32_t     targetWidth,    /* java target object's width   */
 103.934 -                targetHeight;   /* java target's object height  */
 103.935 -    Dimension   width;          /* width of the canvas, target  */
 103.936 -    Dimension   height;         /* height of the canvas, target */
 103.937 -
 103.938 -
 103.939 -    Position    innerX,         /* x loc. of inner Motif canvas */
 103.940 -                innerY,         /* y loc. of inner Motif canvas */
 103.941 -                x, y;
 103.942 -
 103.943 -    /* canvasW is (visible) inner/parent drawing area (canvas) widget   */
 103.944 -    XtVaGetValues(XtParent(wdata->winData.comp.widget),
 103.945 -                  XmNwidth, &innerDAWidth,
 103.946 -                  XmNheight, &innerDAHeight,
 103.947 -                  XmNx, &innerX,
 103.948 -                  XmNy, &innerY,
 103.949 -                  NULL);
 103.950 -
 103.951 -    /* This resize may be due to the insertion or removal of a menu bar.
 103.952 -       If so, we appropriately adjust the top offset in wdata, insets.  */
 103.953 -    awtJNI_setMbAndWwHeightAndOffsets(env, this, wdata);
 103.954 -
 103.955 -    outerDAWidth = innerDAWidth + wdata->left + wdata->right;
 103.956 -    outerDAHeight = innerDAHeight + wdata->top + wdata->bottom;
 103.957 -
 103.958 -    /* If it's a menu bar reset, do not do resize of outer/child canvas.
 103.959 -       (Another thread problem; we arrest this now before damage done.) */
 103.960 -    if  (wdata->menuBarReset)
 103.961 -    {
 103.962 -        targetWidth = (*env)->GetIntField(env, target, componentIDs.width);
 103.963 -        targetHeight = (*env)->GetIntField(env, target, componentIDs.height);
 103.964 -        if  ((outerDAWidth != targetWidth) || (outerDAHeight != targetHeight))
 103.965 -        {
 103.966 -            return;
 103.967 -        }
 103.968 -    }
 103.969 -
 103.970 -    wdata->canvasResized = True;
 103.971 -
 103.972 -    /* The outer/child drawing area (canvas) needs to be configured too.
 103.973 -       If its size changes, its resize callback will thereby be invoked.*/
 103.974 -    x = -wdata->left;
 103.975 -    y = -wdata->top;
 103.976 -    width = innerDAWidth + wdata->left + wdata->right;
 103.977 -    height = innerDAHeight + wdata->top + wdata->bottom;
 103.978 -
 103.979 -    XtConfigureWidget(wdata->winData.comp.widget, x, y, width, height, 0 );
 103.980 -}
 103.981 -
 103.982 -
 103.983 -
 103.984 -/* innerCanvasEH() is event handler for inner/parent canvas. It handles
 103.985 -   map and configure notify events. It reads width and height, adjusts
 103.986 -   for menubar insertion / removal and configures outer/child canvas.   */
 103.987 -
 103.988 -static void
 103.989 -innerCanvasEH(Widget canvasW, XtPointer client_data, XEvent *event,
 103.990 -              Boolean* continueToDispatch)
 103.991 -{
 103.992 -    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 103.993 -    jobject     this = (jobject) client_data;
 103.994 -    jobject     target;
 103.995 -    struct FrameData *wdata;
 103.996 -
 103.997 -
 103.998 -    wdata = (struct FrameData *)
 103.999 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.1000 -    if  (wdata == NULL) {
103.1001 -        return;
103.1002 -    }
103.1003 -
103.1004 -    if  ((*env)->EnsureLocalCapacity(env, 1) < 0)
103.1005 -        return;
103.1006 -
103.1007 -    target = (*env)->GetObjectField(env, (jobject) client_data,
103.1008 -                                    mComponentPeerIDs.target);
103.1009 -
103.1010 -    /* While inside ...pSetMenuBar(), don't react to incomplete resizing
103.1011 -       events supplied by Xt toolkit. Wait for completion of the routine. */
103.1012 -
103.1013 -
103.1014 -    /* For a map or resize, we need to check for the addition or deletion
103.1015 -       of a menu bar to the form which is the of this drawing area (canvas).
103.1016 -       We also must then configure the outer/child canvas appropriately.  */
103.1017 -
103.1018 -    if  ( (event->xany.type == MapNotify) ||
103.1019 -          (event->xany.type == ConfigureNotify) )
103.1020 -    {
103.1021 -        reconfigureOuterCanvas( env, target, this, wdata );
103.1022 -    }
103.1023 -
103.1024 -    (*env)->DeleteLocalRef(env, target);
103.1025 -
103.1026 -}
103.1027 -
103.1028 -/* syncTopLevelPos() is necessary to insure that the window manager has in
103.1029 - * fact moved us to our final position relative to the reParented WM window.
103.1030 - * We have noted a timing window which our shell has not been moved so we
103.1031 - * screw up the insets thinking they are 0,0.  Wait (for a limited period of
103.1032 - * time to let the WM hava a chance to move us
103.1033 - */
103.1034 -void syncTopLevelPos( Display *d, Window w, XWindowAttributes *winAttr )
103.1035 -{
103.1036 -    int32_t i = 0;
103.1037 -    memset(winAttr, 0, sizeof(*winAttr));
103.1038 -
103.1039 -    do {
103.1040 -        if (!XGetWindowAttributes(d, w, winAttr)) {
103.1041 -            memset(winAttr, 0, sizeof(*winAttr));
103.1042 -            break;
103.1043 -        }
103.1044 -        /* Sometimes we get here before the WM has updated the
103.1045 -        ** window data struct with the correct position.  Loop
103.1046 -        ** until we get a non-zero position.
103.1047 -        */
103.1048 -        if ((winAttr->x != 0) || (winAttr->y != 0)) {
103.1049 -            break;
103.1050 -        }
103.1051 -        else {
103.1052 -            /* What we really want here is to sync with the WM,
103.1053 -            ** but there's no explicit way to do this, so we
103.1054 -            ** call XSync for a delay.
103.1055 -            */
103.1056 -            XSync(d, False);
103.1057 -        }
103.1058 -    } while (i++ < 50);
103.1059 -}
103.1060 -
103.1061 -typedef struct FocusOutInfo_str {
103.1062 -    XEvent * eventOut;
103.1063 -    Window inWin;
103.1064 -    Window inChild;
103.1065 -    Widget defChild;
103.1066 -    jobject childComp;
103.1067 -} FocusOutInfo_t;
103.1068 -
103.1069 -#define IsCanvasTypeWidget(w) \
103.1070 -        (XtIsSubclass(w, xmDrawingAreaWidgetClass) ||\
103.1071 -        XtIsSubclass(w, vDrawingAreaClass))
103.1072 -
103.1073 -int isTopLevelPartWidget(Widget w) {
103.1074 -    if (XtIsShell(w)) {
103.1075 -        return TRUE;
103.1076 -    }
103.1077 -    if (XtIsSubclass(w, xmFormWidgetClass)) {
103.1078 -        return TRUE;
103.1079 -    }
103.1080 -    if (IsCanvasTypeWidget(w)) {
103.1081 -        Widget w1 = XtParent(w);
103.1082 -        if (w1 != NULL) {
103.1083 -            if (XtIsSubclass(w1, xmFormWidgetClass)) {
103.1084 -                return TRUE;
103.1085 -            }
103.1086 -            if (IsCanvasTypeWidget(w1)) {
103.1087 -                Widget w2 = XtParent(w1);
103.1088 -                if (w2 != NULL) {
103.1089 -                    if (XtIsSubclass(w2, xmFormWidgetClass)) {
103.1090 -                        return TRUE;
103.1091 -                    }
103.1092 -                }
103.1093 -            }
103.1094 -
103.1095 -        }
103.1096 -    }
103.1097 -    return FALSE;
103.1098 -}
103.1099 -
103.1100 -void
103.1101 -shellFocusEH(Widget w, XtPointer data, XEvent *event, Boolean *continueToDispatch)
103.1102 -{
103.1103 -    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
103.1104 -    jobject     this = (jobject) data;
103.1105 -    jobject     target;
103.1106 -    struct FrameData *wdata;
103.1107 -
103.1108 -    /* Any event handlers which take peer instance pointers as
103.1109 -     * client_data should check to ensure the widget has not been
103.1110 -     * marked as destroyed as a result of a dispose() call on the peer
103.1111 -     * (which can result in the peer instance pointer already haven
103.1112 -     * been gc'd by the time this event is processed)
103.1113 -     */
103.1114 -    if (w->core.being_destroyed) {
103.1115 -        return;
103.1116 -    }
103.1117 -
103.1118 -    wdata = (struct FrameData *)
103.1119 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.1120 -    if (wdata == NULL) {
103.1121 -        return;
103.1122 -    }
103.1123 -
103.1124 -    switch (event->xany.type) {
103.1125 -      case FocusOut:
103.1126 -          // Will be handled by proxy automaticall since he is focus owner
103.1127 -        break;
103.1128 -      case FocusIn:
103.1129 -        // Forward focus event to the proxy
103.1130 -        XSetInputFocus(awt_display, XtWindow(wdata->focusProxy), RevertToParent, CurrentTime);
103.1131 -        break;
103.1132 -    }
103.1133 -}
103.1134 -
103.1135 -/**
103.1136 - * Fix for Alt-Tab problem.
103.1137 - * See coments on use semantics below.
103.1138 - */
103.1139 -Boolean skipNextNotifyWhileGrabbed = False;
103.1140 -Boolean skipNextFocusIn = False;
103.1141 -
103.1142 -Boolean focusOnMapNotify = False;
103.1143 -
103.1144 -/* shellEH() is event handler for the Motif shell widget. It handles
103.1145 -   focus change, map notify, configure notify events for the shell.
103.1146 -   Please see internal comments pertaining to these specific events.
103.1147 -
103.1148 -   data is MWindowPeer instance pointer
103.1149 -*/
103.1150 -void
103.1151 -shellEH(Widget w, XtPointer data, XEvent *event, Boolean *continueToDispatch)
103.1152 -{
103.1153 -    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
103.1154 -    jobject     this = (jobject) data;
103.1155 -    jobject     target;
103.1156 -    struct FrameData *wdata;
103.1157 -    int32_t     setTargetX,
103.1158 -                setTargetY,
103.1159 -                getTargetX,
103.1160 -                getTargetY;
103.1161 -    /* Changed long to int for 64-bit */
103.1162 -    int32_t     wwHeight;       /* height of any warning window present */
103.1163 -    int32_t     topAdjust;      /* adjust top offset for menu, warning  */
103.1164 -    jclass      clazz;
103.1165 -    int32_t     x, y;
103.1166 -    int32_t     width, height;
103.1167 -    enum wmgr_t runningWM;
103.1168 -    jobject   winAttrObj;
103.1169 -    static jobject windowClass = NULL;
103.1170 -    /* Any event handlers which take peer instance pointers as
103.1171 -     * client_data should check to ensure the widget has not been
103.1172 -     * marked as destroyed as a result of a dispose() call on the peer
103.1173 -     * (which can result in the peer instance pointer already haven
103.1174 -     * been gc'd by the time this event is processed)
103.1175 -     */
103.1176 -    if (w->core.being_destroyed) {
103.1177 -        return;
103.1178 -    }
103.1179 -
103.1180 -    wdata = (struct FrameData *)
103.1181 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.1182 -    if (wdata == NULL) {
103.1183 -        return;
103.1184 -    }
103.1185 -
103.1186 -    switch (event->xany.type) {
103.1187 -
103.1188 -    case FocusOut: {
103.1189 -        int32_t res = 0;
103.1190 -        int revert_to = 0;
103.1191 -        Widget defChild = NULL;
103.1192 -        Window focusOwner = None;
103.1193 -        jobject oppositeWindow = NULL;
103.1194 -        Widget oppositeShell = NULL;
103.1195 -        XEvent inEvent;
103.1196 -        Widget shell = NULL;
103.1197 -#ifdef DEBUG_FOCUS
103.1198 -        fprintf(stderr, "Focusout on proxy; window = %x, mode %d, detail %d\n",
103.1199 -                event->xfocus.window, event->xfocus.mode, event->xfocus.detail);
103.1200 -#endif
103.1201 -        shell = wdata->winData.shell;
103.1202 -
103.1203 -        if ((*env)->EnsureLocalCapacity(env, 3) < 0) {
103.1204 -            break;
103.1205 -        }
103.1206 -
103.1207 -        /**
103.1208 -         * Fix for Alt-Tab problem. We should process NotifyWhileGrabbed events
103.1209 -         * only if they are due to the switch between top-levels.
103.1210 -         * skipNextNotifyWhileGrabbed is set from Menu and PopupMenu code
103.1211 -         * to prevent generation of focus events when user interact with these
103.1212 -         * widget.
103.1213 -         */
103.1214 -        if (event->xfocus.mode == NotifyWhileGrabbed) {
103.1215 -            if (skipNextNotifyWhileGrabbed) {
103.1216 -                skipNextNotifyWhileGrabbed = False;
103.1217 -                break;
103.1218 -            }
103.1219 -        } else if (event->xfocus.mode != NotifyNormal) break;
103.1220 -
103.1221 -        /**
103.1222 -         * Fix for Alt-Tab problem.
103.1223 -         * skipNextFocusIn is set in Choice code to avoid processing of
103.1224 -         * next focus-in or focus-out generated by Choice as it is a fake
103.1225 -         * event.
103.1226 -         */
103.1227 -        if (skipNextFocusIn && event->xfocus.detail == NotifyPointer) {
103.1228 -            break;
103.1229 -        }
103.1230 -
103.1231 -        XGetInputFocus( awt_display, &focusOwner, &revert_to);
103.1232 -
103.1233 -        if (focusOwner != None) {
103.1234 -            Widget inWidget = NULL;
103.1235 -            jobject wpeer = NULL;
103.1236 -            inWidget = XtWindowToWidget(awt_display, focusOwner);
103.1237 -            if (inWidget != NULL && inWidget != shell) {
103.1238 -                oppositeShell = getShellWidget(inWidget);
103.1239 -                wpeer = findPeer(&inWidget);
103.1240 -                if (wpeer == NULL) {
103.1241 -                    inWidget = findTopLevelByShell(inWidget);
103.1242 -                    if (inWidget != NULL) {
103.1243 -                        wpeer = findPeer(&inWidget);
103.1244 -                    }
103.1245 -                }
103.1246 -                if (wpeer != NULL) {
103.1247 -                    jobject peerComp =
103.1248 -                        (*env)->GetObjectField(env,
103.1249 -                                               wpeer,
103.1250 -                                               mComponentPeerIDs.target);
103.1251 -                    if (peerComp != NULL) {
103.1252 -                        // Check that peerComp is top-level
103.1253 -
103.1254 -                        // load class
103.1255 -                        if (windowClass == NULL) {
103.1256 -                            jobject localWindowClass = (*env)->FindClass(env, "java/awt/Window");
103.1257 -                            windowClass = (*env)->NewGlobalRef(env, localWindowClass);
103.1258 -                            (*env)->DeleteLocalRef(env, localWindowClass);
103.1259 -                        }
103.1260 -                        if ((*env)->IsInstanceOf(env, peerComp, windowClass)) {
103.1261 -                            oppositeWindow = peerComp;
103.1262 -                        } else { // Opposite object is not Window - there is no opposite window.
103.1263 -                            (*env)->DeleteLocalRef(env, peerComp);
103.1264 -                            peerComp = NULL;
103.1265 -                            oppositeShell = NULL;
103.1266 -                        }
103.1267 -                    }
103.1268 -                }
103.1269 -            }
103.1270 -        } else {
103.1271 -            // If there is no opposite shell but we have active popup - this popup is actually
103.1272 -            // the oppposite. This should mean that this focus out is due to popup - and thus
103.1273 -            // should be skipped. Fix for 4478780.
103.1274 -            if (skipNextNotifyWhileGrabbed) {
103.1275 -                break;
103.1276 -            }
103.1277 -        }
103.1278 -
103.1279 -        // If current window is not focusable and opposite window is not focusable - do nothing
103.1280 -        // If current window is focusable and opposite is not - do not clear focus variables like
103.1281 -        // focus didn't leave this window(but it will in terms of X). When we later switch to either
103.1282 -        // - back to this window: variables are already here
103.1283 -        // - another focusable window: variables point to focusable window and "focus lost" events
103.1284 -        //   will be generated for it
103.1285 -        // - non-java window: variables point to focusable window and "focus lost" events
103.1286 -        //   will be generated for it, not for non-focusable.
103.1287 -        // If current window is non-focusable and opposite is focusable then do not generate anything
103.1288 -        // as if we didn't leave previous focusable window so Java events will generated for it.
103.1289 -        //
103.1290 -        // Fix for 6547951.
103.1291 -        // Also do cleaning when switching to non-java window (opposite is null).
103.1292 -        if (isFocusableWindowByShell(env, shell) && shell != oppositeShell &&
103.1293 -            ((oppositeShell != NULL && isFocusableWindowByShell(env, oppositeShell)) ||
103.1294 -             oppositeShell == NULL))
103.1295 -        {
103.1296 -            // The necessary FOCUS_LOST event will be generated by DKFM.
103.1297 -            // So we need to process focus list like we received FocusOut
103.1298 -            // for the desired component - shell's current focus widget
103.1299 -            defChild = XmGetFocusWidget(shell);
103.1300 -            if (defChild != NULL) {
103.1301 -                jobject peer = findPeer(&defChild);
103.1302 -                if (peer == NULL) {
103.1303 -                    defChild = findTopLevelByShell(defChild);
103.1304 -                    if (defChild != NULL) {
103.1305 -                        peer = findPeer(&defChild);
103.1306 -                    }
103.1307 -                }
103.1308 -                if (peer != NULL) {
103.1309 -                    jobject comp = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
103.1310 -                    if (focusList != NULL) {
103.1311 -                        jobject last = (*env)->NewLocalRef(env, focusList->requestor);
103.1312 -                        if ((*env)->IsSameObject(env, comp, last)) {
103.1313 -                            FocusListElt * temp = focusList;
103.1314 -                            forGained = focusList->requestor;
103.1315 -                            focusList = focusList->next;
103.1316 -                            free(temp);
103.1317 -                            if (focusList == NULL) {
103.1318 -                                focusListEnd = NULL;
103.1319 -                            }
103.1320 -                        }
103.1321 -                        if (!JNU_IsNull(env, last)) {
103.1322 -                            (*env)->DeleteLocalRef(env, last);
103.1323 -                        }
103.1324 -                    }
103.1325 -                    (*env)->DeleteLocalRef(env, comp);
103.1326 -                }
103.1327 -            }
103.1328 -            target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.1329 -            processTree(defChild, findWindowsProxy(target, env), False);
103.1330 -            XtSetKeyboardFocus(shell, NULL);
103.1331 -            (*env)->DeleteLocalRef(env, target);
103.1332 -        }
103.1333 -#ifndef NOMODALFIX
103.1334 -        if (!awt_isModal() || awt_isWidgetModal(shell)) {
103.1335 -#endif //NOMODALFIX
103.1336 -            if ( oppositeShell != NULL
103.1337 -                 && isFocusableWindowByShell(env, oppositeShell)
103.1338 -                 && isFocusableWindowByShell(env, shell)
103.1339 -                 || (oppositeShell == NULL))
103.1340 -            {
103.1341 -                /*
103.1342 -                 * Fix for 5095117.
103.1343 -                 * Check if current native focused window is the same as source.
103.1344 -                 * Sometimes it is not - we must not however clean reference to
103.1345 -                 * actual native focused window.
103.1346 -                 */
103.1347 -                jobject currentFocusedWindow = awt_canvas_getFocusedWindowPeer();
103.1348 -                if ((*env)->IsSameObject(env, this, currentFocusedWindow)) {
103.1349 -                    awt_canvas_setFocusedWindowPeer(NULL);
103.1350 -                }
103.1351 -                (*env)->DeleteLocalRef(env, currentFocusedWindow);
103.1352 -
103.1353 -                JNU_CallMethodByName(env, NULL, this, "handleWindowFocusOut", "(Ljava/awt/Window;)V",
103.1354 -                                     oppositeWindow);
103.1355 -                if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
103.1356 -                    (*env)->ExceptionDescribe(env);
103.1357 -                    (*env)->ExceptionClear(env);
103.1358 -                }
103.1359 -            }
103.1360 -#ifndef NOMODALFIX
103.1361 -        }
103.1362 -#endif //NOMODALFIX
103.1363 -        if (oppositeWindow != NULL) {
103.1364 -            (*env)->DeleteLocalRef(env, oppositeWindow);
103.1365 -        }
103.1366 -
103.1367 -        break;
103.1368 -    } /* FocusOut */
103.1369 -
103.1370 -    case FocusIn: {
103.1371 -        Widget shell = wdata->winData.shell;
103.1372 -#ifdef DEBUG_FOCUS
103.1373 -        fprintf(stderr, "FocusIn on proxy; window = %x, mode %d, detail %d\n", event->xfocus.window,
103.1374 -                event->xfocus.mode, event->xfocus.detail);
103.1375 -#endif
103.1376 -        if (/*  event->xfocus.mode == NotifyNormal */ 1) {
103.1377 -
103.1378 -            /**
103.1379 -             * Fix for Alt-Tab problem. We should process NotifyWhileGrabbed events to detect
103.1380 -             * switch between top-levels using alt-tab, but avoid processing these type of event
103.1381 -             * when they are originated from other sources.
103.1382 -             */
103.1383 -            if (event->xfocus.mode == NotifyWhileGrabbed) {
103.1384 -                /**
103.1385 -                 * skipNextNotifyWhileGrabbed is set from Menu and PopupMenu code to
103.1386 -                 * skip next focus-in event with NotifyWhileGrabbed as it is generated
103.1387 -                 * in result of closing of the Menu's shell.
103.1388 -                 * Event will also have NotifyInferior if uses clicked on menu bar in the
103.1389 -                 * space where there is not menu items.
103.1390 -                 */
103.1391 -                if (skipNextNotifyWhileGrabbed || event->xfocus.detail == NotifyInferior) {
103.1392 -                    skipNextNotifyWhileGrabbed = False;
103.1393 -                    break;
103.1394 -                }
103.1395 -            } else if (event->xfocus.mode != NotifyNormal)  {
103.1396 -                break;
103.1397 -            }
103.1398 -
103.1399 -            /**
103.1400 -             * Fix for Alt-Tab problem.
103.1401 -             * skipNextFocusIn is set from Choice code to avoid processing next focus-in
103.1402 -             * as it is a fake event.
103.1403 -             */
103.1404 -            if (skipNextFocusIn == True) {
103.1405 -                /**
103.1406 -                 * There could be the set of fake events, the last one
103.1407 -                 * will have detail == NotifyPointer
103.1408 -                 */
103.1409 -                if (event->xfocus.detail != NotifyPointer) {
103.1410 -                    skipNextFocusIn = False;
103.1411 -                }
103.1412 -                break;
103.1413 -            }
103.1414 -#ifndef NOMODALFIX
103.1415 -            if (!awt_isModal() || awt_isWidgetModal(shell)) {
103.1416 -#endif //NOMODALFIX
103.1417 -                if (isFocusableWindowByShell(env, shell)) {
103.1418 -                    jobject currentFocusedWindow = awt_canvas_getFocusedWindowPeer();
103.1419 -                    // Check if focus variables already point to this window. If so,
103.1420 -                    // it means there were transfer to non-focusable window and now we
103.1421 -                    // are back to origianl focusable window. No need to generate Java events
103.1422 -                    // in this case.
103.1423 -                    if (!(*env)->IsSameObject(env, this, currentFocusedWindow)) {
103.1424 -                        awt_canvas_setFocusedWindowPeer(this);
103.1425 -                        awt_canvas_setFocusOwnerPeer(this);
103.1426 -
103.1427 -                        /*
103.1428 -                         * Fix for 6465038.
103.1429 -                         * Restore focus on the toplevel widget if it's broken.
103.1430 -                         */
103.1431 -                        Widget widgetToFocus = getFocusWidget(findTopLevelByShell(shell));
103.1432 -                        Widget currentOwner = XmGetFocusWidget(shell);
103.1433 -
103.1434 -                        if (widgetToFocus != currentOwner) {
103.1435 -#ifdef DEBUG_FOCUS
103.1436 -                            fprintf(stderr, "Wrong Xm focus; resetting Xm focus from %x to toplevel %x...\n",
103.1437 -                                    currentOwner != NULL ? XtWindow(currentOwner) : 0,
103.1438 -                                    widgetToFocus != NULL ? XtWindow(widgetToFocus) : 0);
103.1439 -#endif
103.1440 -                            if ( !XmProcessTraversal(widgetToFocus, XmTRAVERSE_CURRENT) ) {
103.1441 -                                XtSetKeyboardFocus(shell, widgetToFocus);
103.1442 -                            }
103.1443 -#ifdef DEBUG_FOCUS
103.1444 -                            Widget _w = XmGetFocusWidget(shell);
103.1445 -                            fprintf(stderr, "                ...focus resulted on window %x\n", _w != NULL ? XtWindow(_w) : 0);
103.1446 -#endif
103.1447 -                        }
103.1448 -
103.1449 -                        JNU_CallMethodByName(env, NULL, this, "handleWindowFocusIn", "()V");
103.1450 -                        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
103.1451 -                            (*env)->ExceptionDescribe(env);
103.1452 -                            (*env)->ExceptionClear(env);
103.1453 -                        }
103.1454 -                    }
103.1455 -                    (*env)->DeleteLocalRef(env, currentFocusedWindow);
103.1456 -                }
103.1457 -#ifndef NOMODALFIX
103.1458 -            }
103.1459 -#endif //NOMODALFIX
103.1460 -        }
103.1461 -        raiseInputMethodWindow(wdata);
103.1462 -        break;
103.1463 -    } /* FocusIn */
103.1464 -
103.1465 -    case VisibilityNotify: {
103.1466 -       winAttrObj = (*env)->GetObjectField(env, this, mWindowPeerIDs.winAttr);
103.1467 -       (*env)->SetIntField(env, winAttrObj,
103.1468 -                           mWindowAttributeIDs.visibilityState,
103.1469 -                           event->xvisibility.state);
103.1470 -        if (event->xvisibility.state == VisibilityUnobscured) {
103.1471 -            raiseInputMethodWindow(wdata);
103.1472 -        }
103.1473 -        break;
103.1474 -    } /* VisibilityNotify */
103.1475 -
103.1476 -    case MapNotify: {
103.1477 -        /* Your body seems to unfade */
103.1478 -        if (wdata->initialFocus == False) {
103.1479 -            XtVaSetValues(wdata->winData.shell, XmNinput, True, NULL);
103.1480 -
103.1481 -            // We have to to evidently move the window to the front here.
103.1482 -            Window shellWindow;
103.1483 -            if ((shellWindow = XtWindow(wdata->winData.shell)) != None) {
103.1484 -                XRaiseWindow(awt_display, shellWindow);
103.1485 -            }
103.1486 -        }
103.1487 -        if (awt_wm_isStateNetHidden(XtWindow(wdata->winData.shell))) {
103.1488 -            focusOnMapNotify = True;
103.1489 -        }
103.1490 -        /*
103.1491 -         * TODO: perhaps we need this putback only for simple Window.
103.1492 -         * For Frame/Dialog XmNinput==True would be enough. The native
103.1493 -         * system will focus it itself.
103.1494 -         */
103.1495 -        if (wdata->isFocusableWindow && focusOnMapNotify) {
103.1496 -            XEvent ev;
103.1497 -            memset(&ev, 0, sizeof(ev));
103.1498 -
103.1499 -            ev.type = FocusIn;
103.1500 -            ev.xany.send_event = True;
103.1501 -            ev.xany.display = awt_display;
103.1502 -            ev.xfocus.mode = NotifyNormal;
103.1503 -            ev.xfocus.detail = NotifyNonlinear;
103.1504 -            ev.xfocus.window = XtWindow(wdata->winData.shell);
103.1505 -            awt_put_back_event(env, &ev);
103.1506 -        }
103.1507 -        focusOnMapNotify = False;
103.1508 -
103.1509 -        break;
103.1510 -    }
103.1511 -
103.1512 -    case UnmapNotify: {
103.1513 -        /* Gee!  All of a sudden, you can't see yourself */
103.1514 -        if (wdata->initialFocus == False) {
103.1515 -            XtVaSetValues(wdata->winData.shell, XmNinput, False, NULL);
103.1516 -        }
103.1517 -        if (awt_wm_isStateNetHidden(XtWindow(wdata->winData.shell))) {
103.1518 -            focusOnMapNotify = True;
103.1519 -        }
103.1520 -        break;
103.1521 -    }
103.1522 -
103.1523 -    case DestroyNotify: {       /* Foul play!  ICCCM forbids WM to do this! */
103.1524 -        /* Your window is killed by the WM */
103.1525 -        JNU_CallMethodByName(env, NULL, this, "handleDestroy", "()V");
103.1526 -        if ((*env)->ExceptionOccurred(env)) {
103.1527 -            (*env)->ExceptionDescribe(env);
103.1528 -            (*env)->ExceptionClear(env);
103.1529 -        }
103.1530 -        break;
103.1531 -    }
103.1532 -
103.1533 -    case PropertyNotify: {
103.1534 -        jint state, old_state, changed;
103.1535 -
103.1536 -        /*
103.1537 -         * Let's see if this is a window state protocol message, and
103.1538 -         * if it is - decode a new state in terms of java constants.
103.1539 -         */
103.1540 -        if (!awt_wm_isStateChange(wdata, (XPropertyEvent *)event, &state)) {
103.1541 -            /* Pakka Pakka seems not interested */
103.1542 -            break;
103.1543 -        }
103.1544 -
103.1545 -        changed = wdata->state ^ state;
103.1546 -        if (changed == 0) {
103.1547 -            /* You feel dizzy for a moment, but nothing happens... */
103.1548 -            DTRACE_PRINTLN("TL: >>> state unchanged");
103.1549 -            break;
103.1550 -        }
103.1551 -
103.1552 -        old_state = wdata->state;
103.1553 -        wdata->state = state;
103.1554 -
103.1555 -#ifdef DEBUG
103.1556 -        DTRACE_PRINT("TL: >>> State Changed:");
103.1557 -        if (changed & java_awt_Frame_ICONIFIED) {
103.1558 -            if (state & java_awt_Frame_ICONIFIED) {
103.1559 -                DTRACE_PRINT(" ICON");
103.1560 -            } else {
103.1561 -                DTRACE_PRINT(" !icon");
103.1562 -            }
103.1563 -        }
103.1564 -        if (changed & java_awt_Frame_MAXIMIZED_VERT) {
103.1565 -            if (state & java_awt_Frame_MAXIMIZED_VERT) {
103.1566 -                DTRACE_PRINT(" MAX_VERT");
103.1567 -            } else {
103.1568 -                DTRACE_PRINT(" !max_vert");
103.1569 -            }
103.1570 -        }
103.1571 -        if (changed & java_awt_Frame_MAXIMIZED_HORIZ) {
103.1572 -            if (state & java_awt_Frame_MAXIMIZED_HORIZ) {
103.1573 -                DTRACE_PRINT(" MAX_HORIZ");
103.1574 -            } else {
103.1575 -                DTRACE_PRINT(" !max_horiz");
103.1576 -            }
103.1577 -        }
103.1578 -        DTRACE_PRINTLN("");
103.1579 -#endif
103.1580 -
103.1581 -        if (changed & java_awt_Frame_ICONIFIED) {
103.1582 -            /* Generate window de/iconified event for old clients */
103.1583 -            if (state & java_awt_Frame_ICONIFIED) {
103.1584 -                DTRACE_PRINTLN("TL: ... handleIconify");
103.1585 -                JNU_CallMethodByName(env, NULL,
103.1586 -                                     this, "handleIconify", "()V");
103.1587 -            }
103.1588 -            else {
103.1589 -                DTRACE_PRINTLN("TL: ... handleDeiconify");
103.1590 -                JNU_CallMethodByName(env, NULL,
103.1591 -                                     this, "handleDeiconify", "()V");
103.1592 -            }
103.1593 -            if ((*env)->ExceptionOccurred(env)) {
103.1594 -                (*env)->ExceptionDescribe(env);
103.1595 -                (*env)->ExceptionClear(env);
103.1596 -            }
103.1597 -        }
103.1598 -
103.1599 -        DTRACE_PRINTLN("TL: ... handleStateChange");
103.1600 -        JNU_CallMethodByName(env, NULL,
103.1601 -                             this, "handleStateChange", "(II)V",
103.1602 -                             old_state, state);
103.1603 -        if ((*env)->ExceptionOccurred(env)) {
103.1604 -            (*env)->ExceptionDescribe(env);
103.1605 -            (*env)->ExceptionClear(env);
103.1606 -        }
103.1607 -        break;
103.1608 -    } /* PropertyNotify */
103.1609 -
103.1610 -    case ReparentNotify: {
103.1611 -        Window root = RootWindowOfScreen(XtScreen(wdata->winData.shell));
103.1612 -
103.1613 -#ifdef DEBUG
103.1614 -        DTRACE_PRINT2("TL: ReparentNotify(0x%x/0x%x) to ",
103.1615 -                      wdata->winData.shell, XtWindow(wdata->winData.shell));
103.1616 -        if (event->xreparent.parent == root) {
103.1617 -            DTRACE_PRINTLN("root");
103.1618 -        } else {
103.1619 -            DTRACE_PRINTLN1("window 0x%x", event->xreparent.parent);
103.1620 -        }
103.1621 -#endif
103.1622 -
103.1623 -        if (wdata->winData.flags & W_IS_EMBEDDED) {
103.1624 -            DTRACE_PRINTLN("TL:   embedded frame - nothing to do");
103.1625 -            break;
103.1626 -        }
103.1627 -
103.1628 -#ifdef __linux__
103.1629 -        if (!wdata->fixInsets) {
103.1630 -            DTRACE_PRINTLN("TL:   insets already fixed");
103.1631 -            break;
103.1632 -        }
103.1633 -        else {
103.1634 -            wdata->fixInsets = False;
103.1635 -        }
103.1636 -#endif
103.1637 -
103.1638 -        if ((*env)->EnsureLocalCapacity(env, 1) < 0)
103.1639 -            break;
103.1640 -
103.1641 -        target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.1642 -
103.1643 -        x      = (*env)->GetIntField(env, target, componentIDs.x);
103.1644 -        y      = (*env)->GetIntField(env, target, componentIDs.y);
103.1645 -        width  = (*env)->GetIntField(env, target, componentIDs.width);
103.1646 -        height = (*env)->GetIntField(env, target, componentIDs.height);
103.1647 -
103.1648 -        /* The insets were literally hardcoded in the MWindowPeer.
103.1649 -           But they are dependent upon both the window manager (WM)
103.1650 -           and the hardware display.  So, these are usually wrong.
103.1651 -           This leads to problems with shell positioning and size.
103.1652 -           Furthermore, there is not a published interface or way
103.1653 -           to obtain from any given window manager the dimensions
103.1654 -           of its decoration windows (i.e., borders and title bar).
103.1655 -           So, given this problem in design, we must workaround.
103.1656 -           N.B. (0) This works.  But there is one functional caveat:
103.1657 -           the frame.insets() function will usually return
103.1658 -           the wrong values until AFTER the frame is shown.
103.1659 -           It always did this before; it's just that now,
103.1660 -           the values will become correct after rendering,
103.1661 -           whereas before the values were never corrected.
103.1662 -           (I believe this unavoidable given this design.)
103.1663 -           (1) Note that we must/have to do this exactly once.
103.1664 -           (2) The hardcoded values of ...create() (25,5)
103.1665 -           are also utilized here and must be consistent.
103.1666 -           This of course could be reworked as desired.
103.1667 -           (3) Assume top border (title bar) is one width,
103.1668 -           and other three borders are another width.
103.1669 -           This, however, could be easily reworked below.       */
103.1670 -
103.1671 -        /*
103.1672 -         * The above comment is no longer completely true.
103.1673 -         * The insets are no longer hardcoded but are retrieved from
103.1674 -         * guessInsets(), either from a per-window manager default,
103.1675 -         * set in the awt.properties file, or overwritten by the
103.1676 -         * actual values determined from a previous frames
103.1677 -         * reparenting.
103.1678 -         */
103.1679 -
103.1680 -        if (wdata->decor == AWT_NO_DECOR) {
103.1681 -            if (!wdata->isResizable && !wdata->isFixedSizeSet) {
103.1682 -                reshape(env, this, wdata, x, y, width, height, False);
103.1683 -                if (wdata->warningWindow != NULL)
103.1684 -                    awtJNI_ChangeInsets(env, this, wdata);
103.1685 -            }
103.1686 -        }
103.1687 -        else if (event->xreparent.parent == root) {
103.1688 -            wdata->reparented = False;
103.1689 -            wdata->configure_seen = False;
103.1690 -
103.1691 -            /*
103.1692 -             * We can be repareted to root for two reasons:
103.1693 -             *   . setVisible(false)
103.1694 -             *   . WM exited
103.1695 -             */
103.1696 -            if (wdata->isShowing) { /* WM exited */
103.1697 -                /* Work around 4775545 */
103.1698 -                awt_wm_unshadeKludge(wdata);
103.1699 -            }
103.1700 -        }
103.1701 -        else  { /* reparented to WM frame, figure out our insets */
103.1702 -            XWindowAttributes   winAttr, actualAttr;
103.1703 -            int32_t             correctWMTop = -1;
103.1704 -            int32_t             correctWMLeft = -1;
103.1705 -            int32_t             correctWMBottom;
103.1706 -            int32_t             correctWMRight;
103.1707 -            int32_t             topCorrection;
103.1708 -            int32_t             leftCorrection;
103.1709 -            int32_t             bottomCorrection = 0;
103.1710 -            int32_t             rightCorrection = 0;
103.1711 -            int32_t             screenX, screenY;
103.1712 -            int32_t             i;
103.1713 -            int32_t             actualWidth, actualHeight;
103.1714 -            int32_t             t, l, b, r;
103.1715 -            Window              containerWindow;
103.1716 -
103.1717 -            /* Dummies for XQueryTree */
103.1718 -            Window              ignore_Window, *ignore_WindowPtr;
103.1719 -            uint32_t            ignore_uint;
103.1720 -
103.1721 -            Boolean             setXY = True;
103.1722 -            XSizeHints*         hints = XAllocSizeHints();
103.1723 -
103.1724 -            wdata->reparented = True;
103.1725 -
103.1726 -            if (hints != NULL) {
103.1727 -                long ignore = 0;
103.1728 -                XGetWMNormalHints(awt_display, XtWindow(wdata->winData.shell),
103.1729 -                    hints, &ignore);
103.1730 -                setXY = (hints->flags & (USPosition|PPosition)) != 0;
103.1731 -                XFree(hints);
103.1732 -            }
103.1733 -
103.1734 -            /*
103.1735 -             * Unfortunately the concept of "insets" borrowed to AWT
103.1736 -             * from Win32 is *absolutely*, *unbelievably* foreign to
103.1737 -             * X11.  Few WMs provide the size of frame decor
103.1738 -             * (i.e. insets) in a property they set on the client
103.1739 -             * window, so we check if we can get away with just
103.1740 -             * peeking at it.  [Future versions of wm-spec might add a
103.1741 -             * standardized hint for this].
103.1742 -             *
103.1743 -             * Otherwise we do some special casing.  Actually the
103.1744 -             * fallback code ("default" case) seems to cover most of
103.1745 -             * the existing WMs (modulo Reparent/Configure order
103.1746 -             * perhaps?).
103.1747 -             *
103.1748 -             * Fallback code tries to account for the two most common cases:
103.1749 -             *
103.1750 -             * . single reparenting
103.1751 -             *       parent window is the WM frame
103.1752 -             *       [twm, olwm, sawfish]
103.1753 -             *
103.1754 -             * . double reparenting
103.1755 -             *       parent is a lining exactly the size of the client
103.1756 -             *       grandpa is the WM frame
103.1757 -             *       [mwm, e!, kwin, fvwm2 ... ]
103.1758 -             */
103.1759 -
103.1760 -            if (awt_wm_getInsetsFromProp(event->xreparent.window,
103.1761 -                                         &t, &l, &b, &r))
103.1762 -            {
103.1763 -                correctWMTop    = t;
103.1764 -                correctWMLeft   = l;
103.1765 -                correctWMBottom = b;
103.1766 -                correctWMRight  = r;
103.1767 -                setXY = False;
103.1768 -            }
103.1769 -            else
103.1770 -            switch (awt_wm_getRunningWM()) {
103.1771 -
103.1772 -            /* should've been done in awt_wm_getInsetsFromProp */
103.1773 -            case ENLIGHTEN_WM: {
103.1774 -                DTRACE_PRINTLN("TL:   hmm, E! insets should have been read"
103.1775 -                               " from _E_FRAME_SIZE");
103.1776 -                /* enlightenment does double reparenting */
103.1777 -                syncTopLevelPos(XtDisplay(wdata->winData.shell),
103.1778 -                                event->xreparent.parent, &winAttr);
103.1779 -
103.1780 -                XQueryTree(XtDisplay(wdata->winData.shell),
103.1781 -                           event->xreparent.parent,
103.1782 -                           &ignore_Window,
103.1783 -                           &containerWindow, /* actual WM frame */
103.1784 -                           &ignore_WindowPtr,
103.1785 -                           &ignore_uint);
103.1786 -                if (ignore_WindowPtr)
103.1787 -                    XFree(ignore_WindowPtr);
103.1788 -
103.1789 -                correctWMLeft = winAttr.x;
103.1790 -                correctWMTop  = winAttr.y;
103.1791 -
103.1792 -                /*
103.1793 -                 * Now get the actual dimensions of the parent window
103.1794 -                 * resolve the difference.  We can't rely on the left
103.1795 -                 * to be equal to right or bottom...  Enlightment
103.1796 -                 * breaks that assumption.
103.1797 -                 */
103.1798 -                XGetWindowAttributes(XtDisplay(wdata->winData.shell),
103.1799 -                                     containerWindow, &actualAttr);
103.1800 -                correctWMRight  = actualAttr.width
103.1801 -                    - (winAttr.width + correctWMLeft);
103.1802 -                correctWMBottom = actualAttr.height
103.1803 -                    - (winAttr.height + correctWMTop) ;
103.1804 -                break;
103.1805 -            }
103.1806 -
103.1807 -            case ICE_WM:
103.1808 -            case KDE2_WM: /* should've been done in awt_wm_getInsetsFromProp */
103.1809 -            case CDE_WM:
103.1810 -            case MOTIF_WM: {
103.1811 -                /* these are double reparenting too */
103.1812 -                syncTopLevelPos(XtDisplay(wdata->winData.shell),
103.1813 -                                event->xreparent.parent, &winAttr);
103.1814 -
103.1815 -                correctWMTop    = winAttr.y;
103.1816 -                correctWMLeft   = winAttr.x;
103.1817 -                correctWMRight  = correctWMLeft;
103.1818 -                correctWMBottom = correctWMLeft;
103.1819 -
103.1820 -                XTranslateCoordinates(awt_display, event->xreparent.window,
103.1821 -                                      root, 0,0, &screenX, &screenY,
103.1822 -                                      &containerWindow);
103.1823 -
103.1824 -                if ((screenX != x + wdata->leftGuess)
103.1825 -                    || (screenY != y + wdata->topGuess))
103.1826 -                {
103.1827 -                    /*
103.1828 -                     * looks like the window manager has placed us somewhere
103.1829 -                     * other than where we asked for, lets respect the window
103.1830 -                     * and go where he put us, not where we tried to put us
103.1831 -                     */
103.1832 -                    x = screenX - correctWMLeft;
103.1833 -                    y = screenY - correctWMTop;
103.1834 -                }
103.1835 -                break;
103.1836 -            }
103.1837 -
103.1838 -            case SAWFISH_WM:
103.1839 -            case OPENLOOK_WM: {
103.1840 -                /* single reparenting */
103.1841 -                syncTopLevelPos(XtDisplay(wdata->winData.shell),
103.1842 -                                event->xreparent.window, &winAttr);
103.1843 -
103.1844 -                correctWMTop    = winAttr.y;
103.1845 -                correctWMLeft   = winAttr.x;
103.1846 -                correctWMRight  = correctWMLeft;
103.1847 -                correctWMBottom = correctWMLeft;
103.1848 -                break;
103.1849 -            }
103.1850 -
103.1851 -            case OTHER_WM:
103.1852 -            default: {          /* this is very similar to the E! case above */
103.1853 -                Display *dpy = event->xreparent.display;
103.1854 -                Window w = event->xreparent.window;
103.1855 -                Window parent = event->xreparent.parent;
103.1856 -                XWindowAttributes wattr, pattr;
103.1857 -
103.1858 -                XGetWindowAttributes(dpy, w, &wattr);
103.1859 -                XGetWindowAttributes(dpy, parent, &pattr);
103.1860 -
103.1861 -                DTRACE_PRINTLN5("TL:   window attr +%d+%d+%dx%d (%d)",
103.1862 -                                wattr.x, wattr.y, wattr.width, wattr.height,
103.1863 -                                wattr.border_width);
103.1864 -                DTRACE_PRINTLN5("TL:   parent attr +%d+%d+%dx%d (%d)",
103.1865 -                                pattr.x, pattr.y, pattr.width, pattr.height,
103.1866 -                                pattr.border_width);
103.1867 -
103.1868 -                /*
103.1869 -                 * Check for double-reparenting WM.
103.1870 -                 *
103.1871 -                 * If the parent is exactly the same size as the
103.1872 -                 * top-level assume taht it's the "lining" window and
103.1873 -                 * that the grandparent is the actual frame (NB: we
103.1874 -                 * have already handled undecorated windows).
103.1875 -                 *
103.1876 -                 * XXX: what about timing issues that syncTopLevelPos
103.1877 -                 * is supposed to work around?
103.1878 -                 */
103.1879 -                if (wattr.x == 0 && wattr.y == 0
103.1880 -                    && wattr.width  + 2*wattr.border_width == pattr.width
103.1881 -                    && wattr.height + 2*wattr.border_width == pattr.height)
103.1882 -                {
103.1883 -                    Window ignore_root, grandparent, *children;
103.1884 -                    unsigned int ignore_nchildren;
103.1885 -
103.1886 -                    DTRACE_PRINTLN("TL:   double reparenting WM detected");
103.1887 -                    XQueryTree(dpy, parent,
103.1888 -                               &ignore_root,
103.1889 -                               &grandparent,
103.1890 -                               &children,
103.1891 -                               &ignore_nchildren);
103.1892 -                    if (children)
103.1893 -                        XFree(children);
103.1894 -
103.1895 -                    /* take lining window into account */
103.1896 -                    wattr.x = pattr.x;
103.1897 -                    wattr.y = pattr.y;
103.1898 -                    wattr.border_width += pattr.border_width;
103.1899 -
103.1900 -                    parent = grandparent;
103.1901 -                    XGetWindowAttributes(dpy, parent, &pattr);
103.1902 -                    DTRACE_PRINTLN5("TL:   window attr +%d+%d+%dx%d (%d)",
103.1903 -                                    wattr.x, wattr.y,
103.1904 -                                    wattr.width, wattr.height,
103.1905 -                                    wattr.border_width);
103.1906 -                    DTRACE_PRINTLN5("TL:   parent attr +%d+%d+%dx%d (%d)",
103.1907 -                                    pattr.x, pattr.y,
103.1908 -                                    pattr.width, pattr.height,
103.1909 -                                    pattr.border_width);
103.1910 -                }
103.1911 -
103.1912 -                /*
103.1913 -                 * XXX: To be absolutely correct, we'd need to take
103.1914 -                 * parent's border-width into account too, but the
103.1915 -                 * rest of the code is happily unaware about border
103.1916 -                 * widths and inner/outer distinction, so for the time
103.1917 -                 * being, just ignore it.
103.1918 -                 */
103.1919 -                correctWMTop = wattr.y + wattr.border_width;
103.1920 -                correctWMLeft = wattr.x + wattr.border_width;
103.1921 -                correctWMBottom = pattr.height
103.1922 -                    - (wattr.y + wattr.height + 2*wattr.border_width);
103.1923 -                correctWMRight = pattr.width
103.1924 -                    - (wattr.x + wattr.width + 2*wattr.border_width);
103.1925 -                DTRACE_PRINTLN4("TL: insets = top %d, left %d, bottom %d, right %d",
103.1926 -                                correctWMTop, correctWMLeft,
103.1927 -                                correctWMBottom, correctWMRight);
103.1928 -                break;
103.1929 -            } /* default */
103.1930 -
103.1931 -            } /* switch (runningWM) */
103.1932 -
103.1933 -
103.1934 -            /*
103.1935 -             * Ok, now see if we need adjust window size because
103.1936 -             * initial insets were wrong (most likely they were).
103.1937 -             */
103.1938 -            topCorrection    = correctWMTop    - wdata->topGuess;
103.1939 -            leftCorrection   = correctWMLeft   - wdata->leftGuess;
103.1940 -            bottomCorrection = correctWMBottom - wdata->bottomGuess;
103.1941 -            rightCorrection  = correctWMRight  - wdata->rightGuess;
103.1942 -
103.1943 -            DTRACE_PRINTLN3("TL: top:    computed=%d, guess=%d, correction=%d",
103.1944 -                correctWMTop, wdata->topGuess, topCorrection);
103.1945 -            DTRACE_PRINTLN3("TL: left:   computed=%d, guess=%d, correction=%d",
103.1946 -                correctWMLeft, wdata->leftGuess, leftCorrection);
103.1947 -            DTRACE_PRINTLN3("TL: bottom: computed=%d, guess=%d, correction=%d",
103.1948 -                correctWMBottom, wdata->bottomGuess, bottomCorrection);
103.1949 -            DTRACE_PRINTLN3("TL: right:  computed=%d, guess=%d, correction=%d",
103.1950 -                correctWMRight, wdata->rightGuess, rightCorrection);
103.1951 -
103.1952 -            if (topCorrection != 0 || leftCorrection != 0
103.1953 -                || bottomCorrection != 0 || rightCorrection != 0)
103.1954 -            {
103.1955 -                jboolean isPacked;
103.1956 -
103.1957 -                DTRACE_PRINTLN("TL: insets need correction");
103.1958 -                wdata->need_reshape = True;
103.1959 -
103.1960 -                globalTopGuess    = correctWMTop;
103.1961 -                globalLeftGuess   = correctWMLeft;
103.1962 -                globalBottomGuess = correctWMBottom;
103.1963 -                globalRightGuess  = correctWMRight;
103.1964 -
103.1965 -                /* guesses are for WM decor *only* */
103.1966 -                wdata->topGuess    = correctWMTop;
103.1967 -                wdata->leftGuess   = correctWMLeft;
103.1968 -                wdata->bottomGuess = correctWMBottom;
103.1969 -                wdata->rightGuess  = correctWMRight;
103.1970 -
103.1971 -                /*
103.1972 -                 * Actual insets account for menubar/warning label,
103.1973 -                 * so we can't assign directly but must adjust them.
103.1974 -                 */
103.1975 -                wdata->top    += topCorrection;
103.1976 -                wdata->left   += leftCorrection;
103.1977 -                wdata->bottom += bottomCorrection;
103.1978 -                wdata->right  += rightCorrection;
103.1979 -
103.1980 -                awtJNI_ChangeInsets(env, this, wdata);
103.1981 -
103.1982 -                /*
103.1983 -                 * If this window has been sized by a pack() we need
103.1984 -                 * to keep the interior geometry intact.  Since pack()
103.1985 -                 * computed width and height with wrong insets, we
103.1986 -                 * must adjust the target dimensions appropriately.
103.1987 -                 */
103.1988 -                isPacked = (*env)->GetBooleanField(env, target,
103.1989 -                                                   componentIDs.isPacked);
103.1990 -                if (isPacked) {
103.1991 -                    int32_t correctTargetW;
103.1992 -                    int32_t correctTargetH;
103.1993 -
103.1994 -                    DTRACE_PRINTLN("TL: window is packed, "
103.1995 -                                   "adjusting size to preserve layout");
103.1996 -
103.1997 -                    correctTargetW = width + (leftCorrection + rightCorrection);
103.1998 -                    correctTargetH = height +(topCorrection + bottomCorrection);
103.1999 -
103.2000 -                    (*env)->SetIntField(env, target, componentIDs.width,
103.2001 -                                        (jint) correctTargetW);
103.2002 -                    (*env)->SetIntField(env, target, componentIDs.height,
103.2003 -                                        (jint) correctTargetH);
103.2004 -                    /*
103.2005 -                    **  Normally you only reconfigure the outerCanvas due to
103.2006 -                    **  handling the ReconfigureNotify on the innerCanvas.
103.2007 -                    **  However, in this case the innerCanvas may not have
103.2008 -                    **  changed, but outterCanvas may still need to, since the
103.2009 -                    **  insets have changed.
103.2010 -                    */
103.2011 -                    reshape(env, this, wdata, x, y,
103.2012 -                            correctTargetW, correctTargetH, setXY);
103.2013 -                    reconfigureOuterCanvas(env, target, this, wdata);
103.2014 -                } else {
103.2015 -                    reshape(env, this, wdata, x, y, width, height, setXY);
103.2016 -                    JNU_CallMethodByName(env, NULL, this,
103.2017 -                        "handleResize", "(II)V", width, height);
103.2018 -                }
103.2019 -            }
103.2020 -/* NEW for dialog */ /* XXX: what this comment is supposed to mean? */
103.2021 -            else {
103.2022 -                wdata->need_reshape = False;
103.2023 -                /* fix for 4976337 - son@sparc.spb.su */
103.2024 -                /* we should find better fix later if needed */
103.2025 -                if (wdata->isResizable || !wdata->isFixedSizeSet) {
103.2026 -                    reshape(env, this, wdata, x, y, width, height, setXY);
103.2027 -                }
103.2028 -            }
103.2029 -        }
103.2030 -        (*env)->DeleteLocalRef(env, target);
103.2031 -        break;
103.2032 -    } /* ReparentNotify */
103.2033 -
103.2034 -    case ConfigureNotify: {
103.2035 -        DTRACE_PRINTLN2("TL: ConfigureNotify(0x%x/0x%x)",
103.2036 -                        wdata->winData.shell, XtWindow(wdata->winData.shell));
103.2037 -
103.2038 -        /*
103.2039 -         * Some window managers configure before we are reparented and
103.2040 -         * the send event flag is set! ugh... (Enlighetenment for one,
103.2041 -         * possibly MWM as well).  If we haven't been reparented yet
103.2042 -         * this is just the WM shuffling us into position.  Ignore
103.2043 -         * it!!!! or we wind up in a bogus location.
103.2044 -         */
103.2045 -        runningWM = awt_wm_getRunningWM();
103.2046 -        if (!wdata->reparented && wdata->isShowing &&
103.2047 -            runningWM != NO_WM && wdata->decor != AWT_NO_DECOR) {
103.2048 -            break;
103.2049 -        }
103.2050 -
103.2051 -        /*
103.2052 -         * Notice that we have seen a ConfigureNotify after being
103.2053 -         * reparented.  We should really check for it being a
103.2054 -         * synthetic event, but metacity doesn't send one.
103.2055 -         */
103.2056 -        if (wdata->reparented)
103.2057 -            wdata->configure_seen = 1;
103.2058 -
103.2059 -        if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
103.2060 -            break;
103.2061 -        }
103.2062 -        target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.2063 -
103.2064 -        /*
103.2065 -         * We can detect the difference between a move and a resize by
103.2066 -         * checking the send_event flag on the event; if it's true,
103.2067 -         * then it's indeed a move, if it's false, then this is a
103.2068 -         * resize and we do not want to process it as a "move" (for
103.2069 -         * resizes the x,y values are misleadingly set to 0,0 and so
103.2070 -         * just checking for an x,y delta won't work).
103.2071 -         */
103.2072 -
103.2073 -        getTargetX = (*env)->GetIntField(env, target, componentIDs.x);
103.2074 -        getTargetY = (*env)->GetIntField(env, target, componentIDs.y);
103.2075 -
103.2076 -        DTRACE_PRINTLN2("TL:   target thinks (%d, %d)",
103.2077 -                        getTargetX, getTargetY);
103.2078 -        DTRACE_PRINTLN3("TL:   event is (%d, %d)%s",
103.2079 -                        event->xconfigure.x, event->xconfigure.y,
103.2080 -                        (event->xconfigure.send_event ? " synthetic" : ""));
103.2081 -
103.2082 -        /*
103.2083 -         * N.B. The wdata top offset is the offset from the outside of
103.2084 -         * the entire (bordered window) to the inner/parent drawing
103.2085 -         * area (canvas), NOT to the shell.  Thus, if a menubar is
103.2086 -         * present and/or a warning window at the top (not NETSCAPE),
103.2087 -         * the top offset will also include space for these.  In order
103.2088 -         * to position the abstract java window relative to the shell,
103.2089 -         * we must add back in the appropriate space for these when we
103.2090 -         * subtract off the wdata top field.
103.2091 -         */
103.2092 -#ifdef NETSCAPE
103.2093 -        wwHeight = 0;
103.2094 -#else /* NETSCAPE */
103.2095 -        if (wdata->warningWindow != NULL)
103.2096 -            wwHeight = wdata->wwHeight;
103.2097 -        else
103.2098 -            wwHeight = 0;
103.2099 -#endif /* NETSCAPE */
103.2100 -        topAdjust = wdata->mbHeight + wwHeight;
103.2101 -
103.2102 -        /*
103.2103 -         * Coordinates in Component.setLocation() are treated as the
103.2104 -         * upper-left corner of the outer shell.  The x and y in the
103.2105 -         * ConfigureNotify event, however, are the upper-left corner
103.2106 -         * of the inset CLIENT window.  Therefore, the coordinates
103.2107 -         * from the event are massaged using the inset values in order
103.2108 -         * to determine if the top-level shell has moved.  In the
103.2109 -         * event of a user- generated move event (i.e. dragging the
103.2110 -         * window itself), these coordinates are written back into the
103.2111 -         * Window object.
103.2112 -         *
103.2113 -         * Neat X/CDE/Native bug:
103.2114 -         * If an attempt is made to move the shell in the y direction
103.2115 -         * by an amount equal to the top inset, the Window isn't
103.2116 -         * moved.  This can be seen here by examining event->xconfigure.y
103.2117 -         * before and after such a request is made: the value remains
103.2118 -         * unchanged.  This wrecks a little havoc here, as the x and y
103.2119 -         * in the Component have already been set to the new location
103.2120 -         * (in Component.reshape()), but the Window doesn't end up in
103.2121 -         * the new location.  What's more, if a second request is
103.2122 -         * made, the window will be relocated by TWICE the requested
103.2123 -         * amount, sort of "catching up" it would seem.
103.2124 -         *
103.2125 -         * For a test case of this, see bug 4234645.
103.2126 -         */
103.2127 -        setTargetX = event->xconfigure.x - wdata->left;
103.2128 -        setTargetY = event->xconfigure.y - wdata->top + topAdjust;
103.2129 -
103.2130 -        width = (*env)->GetIntField(env, target, componentIDs.width);
103.2131 -        height = (*env)->GetIntField(env, target, componentIDs.height);
103.2132 -        checkNewXineramaScreen(env, this, wdata, setTargetX, setTargetY,
103.2133 -                               width, height);
103.2134 -
103.2135 -        if ((getTargetX != setTargetX || getTargetY != setTargetY)
103.2136 -            && (event->xconfigure.send_event || runningWM == NO_WM))
103.2137 -        {
103.2138 -            (*env)->SetIntField(env, target, componentIDs.x, (jint)setTargetX);
103.2139 -            (*env)->SetIntField(env, target, componentIDs.y, (jint)setTargetY);
103.2140 -#ifdef _pauly_debug
103.2141 -            fprintf(stdout, " ++ shell move. Xevent x,y: %d, %d.\n",
103.2142 -                    event->xconfigure.x, event->xconfigure.y);
103.2143 -            fprintf(stdout, "    shell move. left: %d, top: %d, but offset: %d\n", wdata->left, wdata->top, topAdjust);
103.2144 -            fprintf(stdout,"    shell move. target x: %d, target y: %d\n", setTargetX, setTargetY);
103.2145 -            fprintf(stdout,"    shell move. ww height: %d\n", wwHeight);
103.2146 -            fflush(stdout);
103.2147 -#endif /* _pauly_debug */
103.2148 -
103.2149 -            DTRACE_PRINTLN2("TL:   handleMoved(%d, %d)",
103.2150 -                            setTargetX, setTargetY);
103.2151 -            JNU_CallMethodByName(env, NULL,
103.2152 -                                 this, "handleMoved", "(II)V",
103.2153 -                                 setTargetX, setTargetY);
103.2154 -            if ((*env)->ExceptionOccurred(env)) {
103.2155 -                (*env)->ExceptionDescribe(env);
103.2156 -                (*env)->ExceptionClear(env);
103.2157 -            }
103.2158 -        }
103.2159 -        else if (event->xconfigure.send_event == False) {
103.2160 -#ifdef _pauly_debug
103.2161 -            fprintf(stdout,
103.2162 -                    " ++ shell resize. Xevent x,y,w,h: %d, %d, %d, %d.\n",
103.2163 -                    event->xconfigure.x, event->xconfigure.y,
103.2164 -                    event->xconfigure.width, event->xconfigure.height);
103.2165 -            fflush(stdout);
103.2166 -#endif /* _pauly_debug */
103.2167 -
103.2168 -            wdata->shellResized = True;
103.2169 -        }
103.2170 -
103.2171 -
103.2172 -        (*env)->DeleteLocalRef(env, target);
103.2173 -        raiseInputMethodWindow(wdata);
103.2174 -#ifdef __linux__
103.2175 -        adjustStatusWindow(wdata->winData.shell);
103.2176 -#endif
103.2177 -        break;
103.2178 -    } /* ConfigureNotify */
103.2179 -
103.2180 -    default:
103.2181 -        break;
103.2182 -    }
103.2183 -}
103.2184 -
103.2185 -
103.2186 -static void
103.2187 -Frame_quit(Widget w,
103.2188 -           XtPointer client_data,
103.2189 -           XtPointer call_data)
103.2190 -{
103.2191 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
103.2192 -
103.2193 -    JNU_CallMethodByName(env, NULL, (jobject) client_data, "handleQuit", "()V");
103.2194 -    if ((*env)->ExceptionOccurred(env)) {
103.2195 -        (*env)->ExceptionDescribe(env);
103.2196 -        (*env)->ExceptionClear(env);
103.2197 -    }
103.2198 -}
103.2199 -
103.2200 -
103.2201 -static void
103.2202 -setDeleteCallback(jobject this, struct FrameData *wdata)
103.2203 -{
103.2204 -    Atom xa_WM_DELETE_WINDOW;
103.2205 -    Atom xa_WM_TAKE_FOCUS;
103.2206 -    Atom xa_WM_PROTOCOLS;
103.2207 -
103.2208 -    XtVaSetValues(wdata->winData.shell,
103.2209 -                  XmNdeleteResponse, XmDO_NOTHING,
103.2210 -                  NULL);
103.2211 -    xa_WM_DELETE_WINDOW = XmInternAtom(XtDisplay(wdata->winData.shell),
103.2212 -                                       "WM_DELETE_WINDOW", False);
103.2213 -    xa_WM_TAKE_FOCUS = XmInternAtom(XtDisplay(wdata->winData.shell),
103.2214 -                                    "WM_TAKE_FOCUS", False);
103.2215 -    xa_WM_PROTOCOLS = XmInternAtom(XtDisplay(wdata->winData.shell),
103.2216 -                                   "WM_PROTOCOLS", False);
103.2217 -
103.2218 -    XmAddProtocolCallback(wdata->winData.shell,
103.2219 -                          xa_WM_PROTOCOLS,
103.2220 -                          xa_WM_DELETE_WINDOW,
103.2221 -                          Frame_quit, (XtPointer) this);
103.2222 -}
103.2223 -
103.2224 -
103.2225 -extern AwtGraphicsConfigDataPtr
103.2226 -copyGraphicsConfigToPeer(JNIEnv *env, jobject this);
103.2227 -
103.2228 -extern AwtGraphicsConfigDataPtr
103.2229 -getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
103.2230 -
103.2231 -// Returns true if this shell has some transient shell chidlren
103.2232 -// which are either Dialogs or Windows.
103.2233 -// Returns false otherwise.
103.2234 -Boolean hasTransientChildren(Widget shell) {
103.2235 -    int childIndex;
103.2236 -
103.2237 -    // Enumerate through the popups
103.2238 -    for (childIndex = 0; childIndex < shell->core.num_popups; childIndex++) {
103.2239 -        Widget childShell = shell->core.popup_list[childIndex];
103.2240 -        // Find all transient shell which are either Dialog or Window
103.2241 -        if (XtIsTransientShell(childShell)) {
103.2242 -            Widget toplevel = findTopLevelByShell(childShell);
103.2243 -            if (toplevel != NULL) {
103.2244 -                // It is Dialog or Window - return true.
103.2245 -                return True;
103.2246 -            }
103.2247 -        }
103.2248 -    }
103.2249 -    return False;
103.2250 -}
103.2251 -
103.2252 -extern Widget grabbed_widget;
103.2253 -/**
103.2254 - * Disposes top-level component and its widgets
103.2255 - */
103.2256 -static
103.2257 -void disposeTopLevel(JNIEnv * env, jobject this) {
103.2258 -
103.2259 -    struct FrameData *wdata;
103.2260 -    Widget parentShell;
103.2261 -
103.2262 -    wdata = (struct FrameData *)
103.2263 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.2264 -
103.2265 -    if (wdata == NULL || wdata->mainWindow == NULL
103.2266 -        || wdata->winData.shell == NULL)
103.2267 -    {
103.2268 -        /* do nothing */
103.2269 -        return;
103.2270 -    }
103.2271 -
103.2272 -    // Save parent shell for later disposal.
103.2273 -    parentShell = XtParent(wdata->winData.shell);
103.2274 -
103.2275 -    removeTopLevel(wdata);
103.2276 -    if (wdata->isInputMethodWindow) {
103.2277 -        removeInputMethodWindow(wdata);
103.2278 -    }
103.2279 -
103.2280 -    XtRemoveEventHandler(wdata->focusProxy, FocusChangeMask,
103.2281 -                         False, shellEH, this);
103.2282 -    XtUnmanageChild(wdata->focusProxy);
103.2283 -    awt_util_consumeAllXEvents(wdata->focusProxy);
103.2284 -    awt_util_cleanupBeforeDestroyWidget(wdata->focusProxy);
103.2285 -    XtDestroyWidget(wdata->focusProxy);
103.2286 -
103.2287 -    XtUnmanageChild(wdata->winData.comp.widget);
103.2288 -    awt_delWidget(wdata->winData.comp.widget);
103.2289 -    awt_util_consumeAllXEvents(wdata->winData.comp.widget);
103.2290 -    awt_util_cleanupBeforeDestroyWidget(wdata->winData.comp.widget);
103.2291 -    XtDestroyWidget(wdata->winData.comp.widget);
103.2292 -
103.2293 -    XtUnmanageChild(wdata->mainWindow);
103.2294 -    awt_util_consumeAllXEvents(wdata->mainWindow);
103.2295 -    awt_util_consumeAllXEvents(wdata->winData.shell);
103.2296 -    XtDestroyWidget(wdata->mainWindow);
103.2297 -    XtDestroyWidget(wdata->winData.shell);
103.2298 -    if (wdata->iconPixmap) {
103.2299 -        XFreePixmap(awt_display, wdata->iconPixmap);
103.2300 -    }
103.2301 -
103.2302 -    if (grabbed_widget == wdata->winData.shell) {
103.2303 -        XUngrabPointer(awt_display, CurrentTime);
103.2304 -        XUngrabKeyboard(awt_display, CurrentTime);
103.2305 -        grabbed_widget = NULL;
103.2306 -    }
103.2307 -
103.2308 -    free((void *) wdata);
103.2309 -
103.2310 -    (*env)->SetLongField(env, this, mComponentPeerIDs.pData, 0);
103.2311 -    awtJNI_DeleteGlobalRef(env, this);
103.2312 -
103.2313 -    // Check if parent shell was scheduled for disposal.
103.2314 -    // If it doesn't have window then we have to dispose it
103.2315 -    // by ourselves right now.
103.2316 -    // We can dispose shell only if it doesn't have "transient" children.
103.2317 -    {
103.2318 -        struct FrameData *pdata;
103.2319 -        struct WidgetInfo* winfo;
103.2320 -        Widget toplevel = findTopLevelByShell(parentShell);
103.2321 -        if (toplevel == NULL) {
103.2322 -            // Has already been deleted or it is top shell
103.2323 -            return;
103.2324 -        }
103.2325 -        winfo = findWidgetInfo(toplevel);
103.2326 -        DASSERT(winfo != NULL);
103.2327 -        if (winfo == NULL) {
103.2328 -            // Huh - has already been deleted?
103.2329 -            return;
103.2330 -        }
103.2331 -        pdata = (struct FrameData *)
103.2332 -            JNU_GetLongFieldAsPtr(env, winfo->peer, mComponentPeerIDs.pData);
103.2333 -        DASSERT(pdata != NULL);
103.2334 -        if (pdata == NULL) {
103.2335 -            // Huh - has already been deleted?
103.2336 -            return;
103.2337 -        }
103.2338 -        // 1) scheduled 2) no children 3) no window
103.2339 -        if (pdata->isDisposeScheduled
103.2340 -            && !hasTransientChildren(parentShell)
103.2341 -            && XtWindow(parentShell) == None)
103.2342 -        {
103.2343 -            disposeTopLevel(env, winfo->peer);
103.2344 -        }
103.2345 -    }
103.2346 -}
103.2347 -
103.2348 -
103.2349 -/**
103.2350 - * Property change listener. Listens to _XA_JAVA_DISPOSE_PROPERTY_ATOM,
103.2351 - * disposes the top-level when this property has been changed.
103.2352 - */
103.2353 -static void
103.2354 -shellDisposeNotifyHandler(Widget w, XtPointer client_data,
103.2355 -                           XEvent* event, Boolean* continue_to_dispatch) {
103.2356 -    struct FrameData *wdata;
103.2357 -
103.2358 -    *continue_to_dispatch = True;
103.2359 -
103.2360 -    if (event->type == PropertyNotify &&
103.2361 -        event->xproperty.atom == _XA_JAVA_DISPOSE_PROPERTY_ATOM)
103.2362 -    {
103.2363 -        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
103.2364 -
103.2365 -        wdata = (struct FrameData *)
103.2366 -            JNU_GetLongFieldAsPtr(env, (jobject)client_data,
103.2367 -                                  mComponentPeerIDs.pData);
103.2368 -        if (wdata != NULL && wdata->isDisposeScheduled) {
103.2369 -            disposeTopLevel(env, (jobject)client_data);
103.2370 -
103.2371 -            // We've disposed top-level, no more actions on it
103.2372 -            *continue_to_dispatch = False;
103.2373 -        }
103.2374 -    }
103.2375 -}
103.2376 -
103.2377 -/**
103.2378 - * Schedules top-level for later dispose - when all events
103.2379 - * on it will be processed.
103.2380 - */
103.2381 -static
103.2382 -void scheduleDispose(JNIEnv * env, jobject peer) {
103.2383 -
103.2384 -    struct FrameData *wdata;
103.2385 -
103.2386 -    wdata = (struct FrameData *)
103.2387 -        JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
103.2388 -
103.2389 -    if (wdata->isDisposeScheduled) {
103.2390 -        return;
103.2391 -    }
103.2392 -
103.2393 -    wdata->isDisposeScheduled = True;
103.2394 -    if (XtWindow(wdata->winData.shell) != None) {
103.2395 -        XChangeProperty(awt_display, XtWindow(wdata->winData.shell),
103.2396 -                        _XA_JAVA_DISPOSE_PROPERTY_ATOM, XA_ATOM, 32, PropModeAppend,
103.2397 -                        (unsigned char *)"", 0);
103.2398 -        XFlush(awt_display);
103.2399 -        XSync(awt_display, False);
103.2400 -    } else {
103.2401 -        // If this top-level has children which are still visible then
103.2402 -        // their disposal could have been scheduled. We shouldn't allow this widget
103.2403 -// to destroy its children top-levels. For this purpose we postpone the disposal
103.2404 -        // of this toplevel until after all its children are disposed.
103.2405 -        if (!hasTransientChildren(wdata->winData.shell)) {
103.2406 -            disposeTopLevel(env, peer);
103.2407 -        }
103.2408 -    }
103.2409 -}
103.2410 -
103.2411 -
103.2412 -/* sun_awt_motif_MWindowPeer_pCreate() is native (X/Motif) create routine */
103.2413 -static char* focusProxyName = "FocusProxy";
103.2414 -
103.2415 -Widget createFocusProxy(jobject globalRef, Widget parent) {
103.2416 -    Widget proxy;
103.2417 -#define MAX_ARGC 20
103.2418 -    Arg args[MAX_ARGC];
103.2419 -    int32_t argc;
103.2420 -
103.2421 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
103.2422 -
103.2423 -    if (parent == NULL) {
103.2424 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.2425 -        return NULL;
103.2426 -    }
103.2427 -    argc = 0;
103.2428 -    XtSetArg(args[argc], XmNwidth, 1);
103.2429 -    argc++;
103.2430 -    XtSetArg(args[argc], XmNheight, 1);
103.2431 -    argc++;
103.2432 -    XtSetArg(args[argc], XmNx, -1);
103.2433 -    argc++;
103.2434 -    XtSetArg(args[argc], XmNy, -1);
103.2435 -    argc++;
103.2436 -    XtSetArg(args[argc], XmNmarginWidth, 0);
103.2437 -    argc++;
103.2438 -    XtSetArg(args[argc], XmNmarginHeight, 0);
103.2439 -    argc++;
103.2440 -    XtSetArg(args[argc], XmNspacing, 0);
103.2441 -    argc++;
103.2442 -    XtSetArg(args[argc], XmNresizePolicy, XmRESIZE_NONE);
103.2443 -    argc++;
103.2444 -
103.2445 -    DASSERT(!(argc > MAX_ARGC));
103.2446 -    proxy = XmCreateDrawingArea(parent, focusProxyName, args, argc);
103.2447 -    XtAddEventHandler(proxy,
103.2448 -                      FocusChangeMask,
103.2449 -                      False, shellEH, globalRef);
103.2450 -    XtManageChild(proxy);
103.2451 -#undef MAX_ARGC
103.2452 -    return proxy;
103.2453 -}
103.2454 -
103.2455 -/*
103.2456 - * Class:     sun_awt_motif_MWindowPeer
103.2457 - * Method:    pCreate
103.2458 - * Signature: (Lsun/awt/motif/MComponentPeer;Ljava/lang/String;)V
103.2459 - */
103.2460 -JNIEXPORT void JNICALL
103.2461 -Java_sun_awt_motif_MWindowPeer_pCreate(JNIEnv *env, jobject this,
103.2462 -    jobject parent, jstring target_class_name, jboolean isFocusableWindow)
103.2463 -{
103.2464 -#define MAX_ARGC 50
103.2465 -    Arg                 args[MAX_ARGC];
103.2466 -    int32_t             argc;
103.2467 -    struct FrameData    *wdata;
103.2468 -    struct FrameData    *pdata = NULL;
103.2469 -    char                *shell_name = NULL;
103.2470 -    WidgetClass         shell_class;
103.2471 -    Widget              parent_widget;
103.2472 -    jobject             target;
103.2473 -    jobject             insets;
103.2474 -    jobject             winAttr;
103.2475 -    jstring             warningString;
103.2476 -    jboolean            resizable;
103.2477 -    jboolean            isModal;
103.2478 -    jboolean            initialFocus;
103.2479 -    jint                state;
103.2480 -    jclass              clazz;
103.2481 -    jobject             globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
103.2482 -
103.2483 -    uint32_t            runningWM;      /* the running Window Manager   */
103.2484 -    Widget              innerCanvasW;   /* form's child, parent of the
103.2485 -                                           outer canvas (drawing area)  */
103.2486 -    Position            x,y;
103.2487 -    Dimension           w,h;
103.2488 -    AwtGraphicsConfigDataPtr adata;
103.2489 -    AwtGraphicsConfigDataPtr defConfig;
103.2490 -    jobject gd = NULL;
103.2491 -    jobject gc = NULL;
103.2492 -    char *cname = NULL;
103.2493 -    jstring jname;
103.2494 -
103.2495 -    AWT_LOCK();
103.2496 -
103.2497 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.2498 -
103.2499 -    if (JNU_IsNull(env, target)) {
103.2500 -        JNU_ThrowNullPointerException(env, "null target");
103.2501 -        AWT_UNLOCK();
103.2502 -        return;
103.2503 -    }
103.2504 -
103.2505 -    wdata = ZALLOC(FrameData);
103.2506 -    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.pData, wdata);
103.2507 -    if (wdata == NULL) {
103.2508 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
103.2509 -        AWT_UNLOCK();
103.2510 -        return;
103.2511 -    }
103.2512 -
103.2513 -    adata = copyGraphicsConfigToPeer(env, this);
103.2514 -    defConfig = getDefaultConfig(adata->awt_visInfo.screen);
103.2515 -
103.2516 -
103.2517 -    /* Retrieve the specified characteristics for this window */
103.2518 -    winAttr = (*env)->GetObjectField(env, this, mWindowPeerIDs.winAttr);
103.2519 -    resizable = (*env)->GetBooleanField( env,
103.2520 -                                         winAttr,
103.2521 -                                         mWindowAttributeIDs.isResizable);
103.2522 -    state = (*env)->GetIntField( env,
103.2523 -                                 winAttr,
103.2524 -                                 mWindowAttributeIDs.initialState);
103.2525 -    initialFocus = (*env)->GetBooleanField( env,
103.2526 -                                            winAttr,
103.2527 -                                            mWindowAttributeIDs.initialFocus);
103.2528 -
103.2529 -    /* As of today decor is either on or off... except the InputMethodWindow */
103.2530 -    if ((*env)->GetBooleanField(env, winAttr, mWindowAttributeIDs.nativeDecor)) {
103.2531 -        wdata->decor = (*env)->GetIntField(env, winAttr, mWindowAttributeIDs.decorations);
103.2532 -    } else {
103.2533 -        wdata->decor = AWT_NO_DECOR;
103.2534 -    }
103.2535 -
103.2536 -    insets = (*env)->GetObjectField(env, this, mWindowPeerIDs.insets);
103.2537 -
103.2538 -    /* The insets will be corrected upon the reparent
103.2539 -           event in shellEH().  For now, use bogus values.      */
103.2540 -    wdata->top = (*env)->GetIntField(env, insets, insetsIDs.top);
103.2541 -    wdata->left = (*env)->GetIntField(env, insets, insetsIDs.left);
103.2542 -    wdata->bottom = (*env)->GetIntField(env, insets, insetsIDs.bottom);
103.2543 -    wdata->right = (*env)->GetIntField(env, insets, insetsIDs.right);
103.2544 -    awt_Frame_guessInsets(wdata);
103.2545 -    awtJNI_ChangeInsets(env, this, wdata);
103.2546 -    wdata->reparented = False;
103.2547 -    wdata->configure_seen = False;
103.2548 -    x = (*env)->GetIntField(env, target, componentIDs.x) + wdata->left;
103.2549 -    y = (*env)->GetIntField(env, target, componentIDs.y) + wdata->top;
103.2550 -
103.2551 -    w = (*env)->GetIntField(env, target, componentIDs.width)
103.2552 -        - (wdata->left + wdata->right);
103.2553 -    h = (*env)->GetIntField(env, target, componentIDs.height)
103.2554 -        - (wdata->top + wdata->bottom);
103.2555 -    if (w < 0) w = 0;
103.2556 -    if (h < 0) h = 0;
103.2557 -
103.2558 -    DTRACE_PRINTLN1("TL: pCreate: state = 0x%X", state);
103.2559 -
103.2560 -    wdata->isModal = 0;
103.2561 -    wdata->initialFocus = (Boolean)initialFocus;
103.2562 -    wdata->isShowing = False;
103.2563 -    wdata->shellResized = False;
103.2564 -    wdata->canvasResized = False;
103.2565 -    wdata->menuBarReset = False;
103.2566 -    wdata->need_reshape = False;
103.2567 -    wdata->focusProxy = NULL;
103.2568 -#ifdef __linux__
103.2569 -    wdata->fixInsets = True;
103.2570 -#endif
103.2571 -    wdata->state = state;
103.2572 -
103.2573 -    /* initialize screen to screen number in GraphicsConfig's device */
103.2574 -    /* can the Window's GC ever be null? */
103.2575 -    gc =  (*env)->GetObjectField(env, target, componentIDs.graphicsConfig);
103.2576 -    DASSERT(gc);
103.2577 -
103.2578 -    gd =  (*env)->GetObjectField(env, gc, x11GraphicsConfigIDs.screen);
103.2579 -    DASSERT(gd);
103.2580 -
103.2581 -    wdata->screenNum = (*env)->GetIntField(env, gd, x11GraphicsDeviceIDs.screen);
103.2582 -
103.2583 -    wdata->isFocusableWindow = (Boolean)isFocusableWindow;
103.2584 -
103.2585 -    /*
103.2586 -     * Create a top-level shell widget.
103.2587 -     */
103.2588 -    argc = 0;
103.2589 -    XtSetArg(args[argc], XmNsaveUnder, False); argc++;
103.2590 -    if (resizable) {
103.2591 -        XtSetArg(args[argc], XmNallowShellResize, True); argc++;
103.2592 -    } else {
103.2593 -        XtSetArg(args[argc], XmNallowShellResize, False); argc++;
103.2594 -    }
103.2595 -    XtSetArg(args[argc], XmNvisual, defConfig->awt_visInfo.visual); argc++;
103.2596 -    XtSetArg(args[argc], XmNcolormap, defConfig->awt_cmap); argc++;
103.2597 -    XtSetArg(args[argc], XmNdepth, defConfig->awt_depth); argc++;
103.2598 -    XtSetArg(args[argc], XmNmappedWhenManaged, False); argc++;
103.2599 -    XtSetArg(args[argc], XmNx, x); argc++;
103.2600 -    XtSetArg(args[argc], XmNy, y); argc++;
103.2601 -    XtSetArg(args[argc], XmNwidth, w); argc++;
103.2602 -    XtSetArg(args[argc], XmNheight, h); argc++;
103.2603 -
103.2604 -    XtSetArg(args[argc], XmNbuttonFontList, getMotifFontList()); argc++;
103.2605 -    XtSetArg(args[argc], XmNlabelFontList, getMotifFontList()); argc++;
103.2606 -    XtSetArg(args[argc], XmNtextFontList, getMotifFontList()); argc++;
103.2607 -
103.2608 -    XtSetArg(args[argc], XmNmwmDecorations, wdata->decor); argc++;
103.2609 -    XtSetArg(args[argc], XmNscreen,
103.2610 -             ScreenOfDisplay(awt_display, defConfig->awt_visInfo.screen)); argc++;
103.2611 -
103.2612 -    if (wdata->initialFocus == False || !isFocusableWindowByPeer(env, this)) {
103.2613 -        XtSetArg(args[argc], XmNinput, False); argc++;
103.2614 -    }
103.2615 -
103.2616 -    if (wdata->decor == AWT_NO_DECOR) {
103.2617 -        /* this is heinous but it can not be avoided for now.
103.2618 -         ** this is the only known way to eliminate all decorations
103.2619 -         ** for openlook, which btw, is a bug as ol theoretically
103.2620 -         ** supports MWM_HINTS
103.2621 -         */
103.2622 -#ifndef DO_FULL_DECOR
103.2623 -        if (awt_wm_getRunningWM() == OPENLOOK_WM) {
103.2624 -            XtSetArg(args[argc], XmNoverrideRedirect, True);
103.2625 -            argc++;
103.2626 -        }
103.2627 -#endif
103.2628 -    }
103.2629 -
103.2630 -    /* 4334958: Widget name is set to the Java class name */
103.2631 -    shell_name =
103.2632 -        (char *)JNU_GetStringPlatformChars(env, target_class_name, NULL);
103.2633 -
103.2634 -    if (parent) {
103.2635 -        pdata = (struct FrameData *)
103.2636 -            (*env)->GetLongField(env, parent, mComponentPeerIDs.pData);
103.2637 -    }
103.2638 -
103.2639 -    /* Parenting tells us whether we wish to be transient or not */
103.2640 -    if (pdata == NULL) {
103.2641 -        if (!shell_name)
103.2642 -            shell_name = "AWTapp";
103.2643 -        shell_class =  topLevelShellWidgetClass;
103.2644 -        parent_widget = awt_root_shell;
103.2645 -    }
103.2646 -    else {
103.2647 -        if (!shell_name)
103.2648 -            shell_name = "AWTdialog";
103.2649 -        shell_class = transientShellWidgetClass;
103.2650 -        parent_widget = pdata->winData.shell;
103.2651 -        XtSetArg(args[argc], XmNtransient, True); argc++;
103.2652 -        XtSetArg(args[argc], XmNtransientFor, parent_widget); argc++;
103.2653 -
103.2654 -        /* Fix Forte Menu Bug. If Window name is "###overrideRedirect###",
103.2655 -         * then set XmNoverrideRedirect to prevent Menus from getting focus.
103.2656 -         * In JDK 1.2.2 we created Windows as xmMenuShellWidgetClass,
103.2657 -         * so we did not need to do this. Swing DefaultPopupFactory's
103.2658 -         * createHeavyWeightPopup sets Window name to "###overrideRedirect###".
103.2659 -        */
103.2660 -        /**
103.2661 -         * Fix for 4476629. Allow Swing to create heavyweight popups which will
103.2662 -         * not steal focus from Frame.
103.2663 -         */
103.2664 -        jname = (*env)->GetObjectField(env, target, componentIDs.name);
103.2665 -        if (!JNU_IsNull(env, jname)) {
103.2666 -          cname = (char *)JNU_GetStringPlatformChars(env, jname, NULL);
103.2667 -        }
103.2668 -        if ( (cname != NULL && strcmp(cname, "###overrideRedirect###") == 0)
103.2669 -            || (!isFrameOrDialog(target, env)
103.2670 -                && !isFocusableWindowByPeer(env, this)
103.2671 -                )
103.2672 -            )
103.2673 -        {    /* mbron */
103.2674 -            XtSetArg(args[argc], XmNoverrideRedirect, True);
103.2675 -            argc++;
103.2676 -        }
103.2677 -        if (cname) {
103.2678 -            JNU_ReleaseStringPlatformChars(env, jname, (const char *) cname);
103.2679 -        }
103.2680 -        (*env)->DeleteLocalRef(env, jname);
103.2681 -    }
103.2682 -    DASSERT(!(argc > MAX_ARGC));
103.2683 -    wdata->winData.shell = XtCreatePopupShell(shell_name, shell_class,
103.2684 -                                              parent_widget, args, argc);
103.2685 -    if (shell_name) {
103.2686 -        JNU_ReleaseStringPlatformChars(env, target_class_name, shell_name);
103.2687 -    }
103.2688 -
103.2689 -#ifdef DEBUG
103.2690 -    /* Participate in EditRes protocol to facilitate debugging */
103.2691 -    XtAddEventHandler(wdata->winData.shell, (EventMask)0, True,
103.2692 -                      _XEditResCheckMessages, NULL);
103.2693 -#endif
103.2694 -
103.2695 -    setDeleteCallback(globalRef, wdata);
103.2696 -
103.2697 -    /* Establish resizability.  For the case of not resizable, do not
103.2698 -       yet set a fixed size here; we must wait until in the routine
103.2699 -       sun_awt_motif_MWindowPeer_pReshape() after insets have been fixed.
103.2700 -       This is because correction of the insets may affect shell size.
103.2701 -       (See comments in shellEH() concerning correction of the insets.  */
103.2702 -    /*
103.2703 -     * Fix for BugTraq ID 4313607.
103.2704 -     * Initial resizability will be set later in MWindowPeer_setResizable()
103.2705 -     * called from init().
103.2706 -     */
103.2707 -    wdata->isResizable = True;
103.2708 -    wdata->isFixedSizeSet = False;
103.2709 -
103.2710 -    XtAddEventHandler(wdata->winData.shell,
103.2711 -                      (StructureNotifyMask | PropertyChangeMask
103.2712 -                       | VisibilityChangeMask),
103.2713 -                      False, shellEH, globalRef);
103.2714 -
103.2715 -    XtAddEventHandler(wdata->winData.shell,
103.2716 -                      FocusChangeMask,
103.2717 -                      False, shellFocusEH, globalRef);
103.2718 -
103.2719 -
103.2720 -    /**
103.2721 -     * Installing property change handler for DISPOSE property.
103.2722 -     * This property will be changed when we need to dispose the whole
103.2723 -     * top-level. The nature of PropertyNotify will guarantee that it is
103.2724 -     * the latest event on the top-level so we can freely dispose it.
103.2725 -     */
103.2726 -    wdata->isDisposeScheduled = False;
103.2727 -    if (_XA_JAVA_DISPOSE_PROPERTY_ATOM == 0) {
103.2728 -        _XA_JAVA_DISPOSE_PROPERTY_ATOM = XInternAtom(awt_display, "_SUNW_JAVA_AWT_DISPOSE", False);
103.2729 -    }
103.2730 -    XtAddEventHandler(wdata->winData.shell, PropertyChangeMask, False,
103.2731 -                      shellDisposeNotifyHandler, globalRef);
103.2732 -
103.2733 -    /*
103.2734 -     * Create "main" form.
103.2735 -     */
103.2736 -    argc = 0;
103.2737 -    XtSetArg(args[argc], XmNmarginWidth, 0); argc++;
103.2738 -    XtSetArg(args[argc], XmNmarginHeight, 0); argc++;
103.2739 -    XtSetArg(args[argc], XmNhorizontalSpacing, 0); argc++;
103.2740 -    XtSetArg(args[argc], XmNverticalSpacing, 0); argc++;
103.2741 -    XtSetArg(args[argc], XmNresizePolicy, XmRESIZE_NONE); argc++;
103.2742 -
103.2743 -    XtSetArg(args[argc], XmNbuttonFontList, getMotifFontList()); argc++;
103.2744 -    XtSetArg(args[argc], XmNlabelFontList, getMotifFontList()); argc++;
103.2745 -    XtSetArg(args[argc], XmNtextFontList, getMotifFontList()); argc++;
103.2746 -
103.2747 -    DASSERT(!(argc > MAX_ARGC));
103.2748 -    wdata->mainWindow = XmCreateForm(wdata->winData.shell, "main", args, argc);
103.2749 -
103.2750 -    /* The widget returned by awt_canvas_create is a drawing area
103.2751 -       (i.e., canvas) which is the child of another drawing area
103.2752 -       parent widget.  The parent is the drawing area within the
103.2753 -       form just created.  The child is an drawing area layer over
103.2754 -       the entire frame window, including the form, any menu bar
103.2755 -       and warning windows present, and also window manager stuff.
103.2756 -       The top, bottom, left, and right fields in wdata maintain
103.2757 -       the respective offsets between these two drawing areas.  */
103.2758 -
103.2759 -    wdata->winData.comp.widget = awt_canvas_create((XtPointer)globalRef,
103.2760 -                                                   wdata->mainWindow,
103.2761 -                                                   "frame_",
103.2762 -                                                   -1,
103.2763 -                                                   -1,
103.2764 -                                                   True,
103.2765 -                                                   wdata,
103.2766 -                                                   adata);
103.2767 -    XtAddCallback(wdata->winData.comp.widget,
103.2768 -                  XmNresizeCallback, outerCanvasResizeCB,
103.2769 -                  globalRef);
103.2770 -
103.2771 -    innerCanvasW = XtParent(wdata->winData.comp.widget);
103.2772 -    XtVaSetValues(innerCanvasW,
103.2773 -                  XmNleftAttachment, XmATTACH_FORM,
103.2774 -                  XmNrightAttachment, XmATTACH_FORM,
103.2775 -                  NULL);
103.2776 -
103.2777 -    XtAddEventHandler(innerCanvasW, StructureNotifyMask, FALSE,
103.2778 -                      innerCanvasEH, globalRef);
103.2779 -
103.2780 -    wdata->focusProxy = createFocusProxy((XtPointer)globalRef,
103.2781 -                                         wdata->mainWindow);
103.2782 -
103.2783 -    /* No menu bar initially */
103.2784 -    wdata->menuBar = NULL;
103.2785 -    wdata->mbHeight = 0;
103.2786 -
103.2787 -    /* If a warning window (string) is needed, establish it now.*/
103.2788 -    warningString =
103.2789 -        (*env)->GetObjectField(env, target, windowIDs.warningString);
103.2790 -    if (!JNU_IsNull(env, warningString) ) {
103.2791 -        char *wString;
103.2792 -        /* Insert a warning window. It's height can't be set yet;
103.2793 -           it will later be set in setMbAndWwHeightAndOffsets().*/
103.2794 -        wString = (char *) JNU_GetStringPlatformChars(env, warningString, NULL);
103.2795 -        wdata->warningWindow = awt_util_createWarningWindow(wdata->mainWindow, wString);
103.2796 -        JNU_ReleaseStringPlatformChars(env, warningString, (const char *) wString);
103.2797 -
103.2798 -        wdata->wwHeight = 0;
103.2799 -        XtVaSetValues(wdata->warningWindow,
103.2800 -                      XmNleftAttachment, XmATTACH_FORM,
103.2801 -                      XmNrightAttachment, XmATTACH_FORM,
103.2802 -                      NULL);
103.2803 -
103.2804 -#ifdef NETSCAPE
103.2805 -        /* For NETSCAPE, warning window is at bottom of the form*/
103.2806 -        XtVaSetValues(innerCanvasW,
103.2807 -                      XmNtopAttachment, XmATTACH_FORM,
103.2808 -                      NULL);
103.2809 -        XtVaSetValues(wdata->warningWindow,
103.2810 -                      XmNtopAttachment, XmATTACH_WIDGET,
103.2811 -                      XmNtopWidget, innerCanvasW,
103.2812 -                      XmNbottomAttachment, XmATTACH_FORM,
103.2813 -                      NULL);
103.2814 -#else  /* NETSCAPE */
103.2815 -        /* Otherwise (not NETSCAPE), warning is at top of form  */
103.2816 -        XtVaSetValues(wdata->warningWindow,
103.2817 -                      XmNtopAttachment, XmATTACH_FORM,
103.2818 -                      NULL);
103.2819 -        XtVaSetValues(innerCanvasW,
103.2820 -                      XmNtopAttachment, XmATTACH_WIDGET,
103.2821 -                      XmNtopWidget, wdata->warningWindow,
103.2822 -                      XmNbottomAttachment, XmATTACH_FORM,
103.2823 -                      NULL);
103.2824 -#endif /* NETSCAPE */
103.2825 -
103.2826 -    } else {
103.2827 -        /* No warning window present */
103.2828 -        XtVaSetValues(innerCanvasW,
103.2829 -                      XmNtopAttachment, XmATTACH_FORM,
103.2830 -                      XmNbottomAttachment, XmATTACH_FORM,
103.2831 -                      NULL);
103.2832 -        wdata->warningWindow = NULL;
103.2833 -        wdata->wwHeight = 0;
103.2834 -    }
103.2835 -
103.2836 -    awt_util_show(wdata->winData.comp.widget);
103.2837 -
103.2838 -    AWT_FLUSH_UNLOCK();
103.2839 -
103.2840 -    addTopLevel(wdata);
103.2841 -
103.2842 -    /* Check whether this is an instance of InputMethodWindow or not */
103.2843 -    if (inputMethodWindowClass == NULL) {
103.2844 -        jclass localClass = (*env)->FindClass(env, "sun/awt/im/InputMethodWindow");
103.2845 -        inputMethodWindowClass = (jclass)(*env)->NewGlobalRef(env, localClass);
103.2846 -        (*env)->DeleteLocalRef(env, localClass);
103.2847 -    }
103.2848 -    if ((*env)->IsInstanceOf(env, target, inputMethodWindowClass)) {
103.2849 -        wdata->isInputMethodWindow = True;
103.2850 -        addInputMethodWindow(wdata);
103.2851 -    }
103.2852 -} /* MWindowPeer_pCreate() */
103.2853 -
103.2854 -
103.2855 -/*
103.2856 - * Class:     sun_awt_motif_MWindowPeer
103.2857 - * Method:    pSetTitle
103.2858 - * Signature: (Ljava/lang/String;)V
103.2859 - */
103.2860 -JNIEXPORT void JNICALL
103.2861 -Java_sun_awt_motif_MWindowPeer_pSetTitle(JNIEnv *env, jobject this,
103.2862 -    jstring title)
103.2863 -{
103.2864 -    char *ctitle;
103.2865 -    char *empty_string = " ";
103.2866 -    struct FrameData *wdata;
103.2867 -    XTextProperty text_prop;
103.2868 -    char *c[1];
103.2869 -    int32_t conv_result;
103.2870 -
103.2871 -    AWT_LOCK();
103.2872 -
103.2873 -    wdata = (struct FrameData *)
103.2874 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.2875 -
103.2876 -    if (wdata == NULL || wdata->winData.shell == NULL) {
103.2877 -        JNU_ThrowNullPointerException(env, "null wdata or shell");
103.2878 -        AWT_UNLOCK();
103.2879 -        return;
103.2880 -    }
103.2881 -
103.2882 -    /* TODO: uwe: set _NET_WM_NAME property to utf-8 name */
103.2883 -
103.2884 -    ctitle = (JNU_IsNull(env, title)) ? empty_string
103.2885 -        : (char *) JNU_GetStringPlatformChars(env, title, NULL);
103.2886 -
103.2887 -    if (strcmp(ctitle, "") == 0)
103.2888 -        ctitle = empty_string;
103.2889 -
103.2890 -    c[0] = ctitle;
103.2891 -
103.2892 -    /* need to convert ctitle to CompoundText */
103.2893 -    conv_result = XmbTextListToTextProperty(awt_display, c, 1,
103.2894 -                                            XStdICCTextStyle,
103.2895 -                                            &text_prop);
103.2896 -
103.2897 -    /*
103.2898 -     * XmbTextListToTextProperty returns value that is greater
103.2899 -     * than Success if the supplied text is not fully convertible
103.2900 -     * to specified encoding. In this case, the return value is
103.2901 -     * the number of inconvertible characters. But convertibility
103.2902 -     * is guaranteed for XCompoundTextStyle, so it will actually
103.2903 -     * never be greater than Success. Errors handled below are
103.2904 -     * represented by values that are lower than Success.
103.2905 -     */
103.2906 -    if (conv_result >= Success) {
103.2907 -        XtVaSetValues(wdata->winData.shell,
103.2908 -                  XmNtitle, text_prop.value,
103.2909 -                  XmNtitleEncoding, text_prop.encoding,
103.2910 -                  XmNiconName, text_prop.value,
103.2911 -                  XmNiconNameEncoding, text_prop.encoding,
103.2912 -                  XmNname, ctitle,
103.2913 -                  NULL);
103.2914 -    }
103.2915 -
103.2916 -    if (ctitle != empty_string)
103.2917 -        JNU_ReleaseStringPlatformChars(env, title, (const char *) ctitle);
103.2918 -
103.2919 -    if (conv_result == XNoMemory) {
103.2920 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
103.2921 -        AWT_UNLOCK();
103.2922 -        return;
103.2923 -    }
103.2924 -    if (conv_result == XLocaleNotSupported) {
103.2925 -        JNU_ThrowInternalError(env, "Current locale is not supported");
103.2926 -        AWT_UNLOCK();
103.2927 -        return;
103.2928 -    }
103.2929 -
103.2930 -    XFree(text_prop.value);
103.2931 -    AWT_FLUSH_UNLOCK();
103.2932 -}
103.2933 -
103.2934 -/*
103.2935 - * Class:     sun_awt_motif_MWindowPeer
103.2936 - * Method:    pToFront
103.2937 - * Signature: ()V
103.2938 - */
103.2939 -JNIEXPORT void JNICALL
103.2940 -Java_sun_awt_motif_MWindowPeer_pToFront(JNIEnv *env, jobject this)
103.2941 -{
103.2942 -    struct FrameData *wdata;
103.2943 -    jobject target;
103.2944 -    Window shellWindow;
103.2945 -    Boolean autoRequestFocus;
103.2946 -    Boolean isModal = FALSE;
103.2947 -
103.2948 -    AWT_LOCK();
103.2949 -
103.2950 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.2951 -
103.2952 -    wdata = (struct FrameData *)
103.2953 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.2954 -    if (wdata == NULL
103.2955 -        || wdata->winData.comp.widget == NULL
103.2956 -        || wdata->winData.shell == NULL
103.2957 -        || wdata->mainWindow == NULL
103.2958 -        || JNU_IsNull(env, target))
103.2959 -    {
103.2960 -        JNU_ThrowNullPointerException(env, "null widget/target data");
103.2961 -        AWT_UNLOCK();
103.2962 -        return;
103.2963 -    }
103.2964 -
103.2965 -    if ((shellWindow = XtWindow(wdata->winData.shell)) != None) {
103.2966 -        XRaiseWindow(awt_display, shellWindow);
103.2967 -
103.2968 -        autoRequestFocus = (*env)->GetBooleanField(env, target, windowIDs.isAutoRequestFocus);
103.2969 -
103.2970 -        if (isDialog(target, env)) {
103.2971 -            isModal = (*env)->GetBooleanField(env, target, dialogIDs.modal);
103.2972 -        }
103.2973 -
103.2974 -        // In contrast to XToolkit/WToolkit modal dialog can be unfocused.
103.2975 -        // So we should also ask for modality in addition to 'autoRequestFocus'.
103.2976 -        if (wdata->isFocusableWindow && (autoRequestFocus || isModal)) {
103.2977 -            XSetInputFocus(awt_display, XtWindow(wdata->focusProxy), RevertToPointerRoot, CurrentTime);
103.2978 -        }
103.2979 -    }
103.2980 -
103.2981 -   (*env)->DeleteLocalRef(env, target);
103.2982 -
103.2983 -    AWT_UNLOCK();
103.2984 -}
103.2985 -
103.2986 -/*
103.2987 - * Class:     sun_awt_motif_MWindowPeer
103.2988 - * Method:    pShow
103.2989 - * Signature: ()V
103.2990 - */
103.2991 -JNIEXPORT void JNICALL
103.2992 -Java_sun_awt_motif_MWindowPeer_pShow(JNIEnv *env, jobject this)
103.2993 -{
103.2994 -    Java_sun_awt_motif_MWindowPeer_pShowModal(env, this, JNI_FALSE);
103.2995 -}
103.2996 -
103.2997 -/*
103.2998 - * Class:     sun_awt_motif_MWindowPeer
103.2999 - * Method:    pShowModal
103.3000 - * Signature: (Z)V
103.3001 - */
103.3002 -JNIEXPORT void JNICALL
103.3003 -Java_sun_awt_motif_MWindowPeer_pShowModal(JNIEnv *env, jobject this,
103.3004 -    jboolean isModal)
103.3005 -{
103.3006 -    struct FrameData *wdata;
103.3007 -    Boolean iconic;
103.3008 -    jobject target;
103.3009 -    Boolean locationByPlatform;
103.3010 -
103.3011 -    AWT_LOCK();
103.3012 -
103.3013 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.3014 -
103.3015 -    wdata = (struct FrameData *)
103.3016 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3017 -    if (wdata == NULL
103.3018 -        || wdata->winData.comp.widget == NULL
103.3019 -        || wdata->winData.shell == NULL
103.3020 -        || wdata->mainWindow == NULL
103.3021 -        || (wdata->winData.flags & W_IS_EMBEDDED)
103.3022 -        || JNU_IsNull(env, target))
103.3023 -    {
103.3024 -        JNU_ThrowNullPointerException(env, "null widget/target data");
103.3025 -        AWT_UNLOCK();
103.3026 -        return;
103.3027 -    }
103.3028 -
103.3029 -    DTRACE_PRINTLN2("TL: pShowModal(modal = %s) state = 0x%X",
103.3030 -                    isModal ? "true" : "false",
103.3031 -                    wdata->state);
103.3032 -
103.3033 -    wdata->isModal = isModal;
103.3034 -
103.3035 -    /*
103.3036 -     * A workaround for bug 4062589 that is really a motif problem
103.3037 -     * (see bug 4064803).  Before popping up a modal dialog, if a
103.3038 -     * pulldown menu has the input focus (i.e. user has pulled the
103.3039 -     * menu down), we send a fake click event and make sure the click
103.3040 -     * event is processed.  With this simulation of user clicking, X
103.3041 -     * server will not get confused about the modality and a
103.3042 -     * subsequent click on the popup modal dialog will not cause
103.3043 -     * system lockup.
103.3044 -     */
103.3045 -    if (wdata->isModal && awt_util_focusIsOnMenu(awt_display)
103.3046 -        && awt_util_sendButtonClick(awt_display, InputFocus))
103.3047 -    {
103.3048 -        for (;;) {
103.3049 -            XEvent ev;
103.3050 -            XtAppPeekEvent(awt_appContext, &ev);
103.3051 -            if ((ev.type == ButtonRelease)
103.3052 -                && (*(XButtonEvent *)&ev).send_event)
103.3053 -            {
103.3054 -                XtAppProcessEvent(awt_appContext, XtIMAll);
103.3055 -                break;
103.3056 -            } else {
103.3057 -                XtAppProcessEvent(awt_appContext, XtIMAll);
103.3058 -            }
103.3059 -        }
103.3060 -    }
103.3061 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.3062 -
103.3063 -    // 4488209: kdm@sparc.spb.su
103.3064 -    // wdata->isShowing is True when toFront calls pShow.
103.3065 -    // We do not need to do some things if wdata->isShowing is True.
103.3066 -    if (!wdata->isShowing) {
103.3067 -        XtVaSetValues(wdata->winData.comp.widget,
103.3068 -                      XmNx, -(wdata->left),
103.3069 -                      XmNy, -(wdata->top),
103.3070 -                      NULL);
103.3071 -
103.3072 -        /* But see below! */
103.3073 -        iconic = (wdata->state & java_awt_Frame_ICONIFIED) ? True : False;
103.3074 -        XtVaSetValues(wdata->winData.shell,
103.3075 -                      XmNinitialState, iconic ? IconicState : NormalState,
103.3076 -                      NULL);
103.3077 -
103.3078 -        if (wdata->menuBar != NULL) {
103.3079 -            awt_util_show(wdata->menuBar);
103.3080 -        }
103.3081 -        XtManageChild(wdata->mainWindow);
103.3082 -        XtRealizeWidget(wdata->winData.shell); /* but not map it yet */
103.3083 -
103.3084 -/*         fprintf(stderr, "*** proxy window %x\n", XtWindow(wdata->focusProxy)); */
103.3085 -        XStoreName(awt_display, XtWindow(wdata->focusProxy), "FocusProxy");
103.3086 -        /*
103.3087 -         * Maximization and other stuff that requires a live Window to set
103.3088 -         * properties on to communicate with WM.
103.3089 -         */
103.3090 -        awt_wm_setExtendedState(wdata, wdata->state);
103.3091 -        awt_wm_setShellDecor(wdata, wdata->isResizable);
103.3092 -
103.3093 -        if (wdata->isModal) {
103.3094 -            removePopupMenus();
103.3095 -#ifndef NOMODALFIX
103.3096 -            /*
103.3097 -             * Fix for 4078176 Modal dialogs don't act modal
103.3098 -             * if addNotify() is called before setModal(true).
103.3099 -             * Moved from Java_sun_awt_motif_MDialogPeer_create.
103.3100 -             */
103.3101 -            if (!wdata->callbacksAdded) {
103.3102 -                XtAddCallback(wdata->winData.shell,
103.3103 -                              XtNpopupCallback, awt_shellPoppedUp,
103.3104 -                              NULL);
103.3105 -                XtAddCallback(wdata->winData.shell,
103.3106 -                              XtNpopdownCallback, awt_shellPoppedDown,
103.3107 -                              NULL);
103.3108 -                wdata->callbacksAdded = True;
103.3109 -            }
103.3110 -#endif /* !NOMODALFIX */
103.3111 -            /*
103.3112 -             * Set modality on the Shell, not the BB.  The BB expects that
103.3113 -             * its parent is an xmDialogShell, which as the result of
103.3114 -             * coalescing is now a transientShell...  This has resulted in
103.3115 -             * a warning message generated under fvwm.  The shells are
103.3116 -             * virtually identical and a review of Motif src suggests that
103.3117 -             * setting dialog style on BB is a convenience not functional
103.3118 -             * for BB so set Modality on shell, not the BB(form) widget.
103.3119 -             */
103.3120 -            XtVaSetValues(wdata->winData.shell,
103.3121 -                          XmNmwmInputMode, MWM_INPUT_FULL_APPLICATION_MODAL,
103.3122 -                          NULL);
103.3123 -            XtManageChild(wdata->winData.comp.widget);
103.3124 -        }
103.3125 -        else {                  /* not modal */
103.3126 -            XtVaSetValues(wdata->winData.shell,
103.3127 -                          XmNmwmInputMode, MWM_INPUT_MODELESS, NULL);
103.3128 -            XtManageChild(wdata->winData.comp.widget);
103.3129 -            XtSetMappedWhenManaged(wdata->winData.shell, True);
103.3130 -        }
103.3131 -        if (wdata->isResizable) {
103.3132 -            /* REMINDER: uwe: will need to revisit for setExtendedStateBounds */
103.3133 -            awt_wm_removeSizeHints(wdata->winData.shell, PMinSize|PMaxSize);
103.3134 -        }
103.3135 -        locationByPlatform =
103.3136 -            (*env)->GetBooleanField(env, target, windowIDs.locationByPlatform);
103.3137 -        if (locationByPlatform) {
103.3138 -            awt_wm_removeSizeHints(wdata->winData.shell, USPosition|PPosition);
103.3139 -        }
103.3140 -    }
103.3141 -
103.3142 -    /*
103.3143 -     * 4261047: always pop up with XtGrabNone.  Motif notices the
103.3144 -     * modal input mode and perform the grab for us, doing its
103.3145 -     * internal book-keeping as well.
103.3146 -     */
103.3147 -    XtPopup(wdata->winData.shell, XtGrabNone);
103.3148 -    wdata->isShowing = True;
103.3149 -
103.3150 -    wdata->initialFocus = (*env)->GetBooleanField(env, target, windowIDs.isAutoRequestFocus);
103.3151 -
103.3152 -    if (wdata->isFocusableWindow) {
103.3153 -        if (wdata->initialFocus || wdata->isModal) {
103.3154 -            focusOnMapNotify = True;
103.3155 -        } else {
103.3156 -            XtVaSetValues(wdata->winData.shell, XmNinput, False, NULL);
103.3157 -        }
103.3158 -    }
103.3159 -
103.3160 -    (*env)->DeleteLocalRef(env, target);
103.3161 -
103.3162 -    AWT_FLUSH_UNLOCK();
103.3163 -}
103.3164 -
103.3165 -/*
103.3166 - * Class:     sun_awt_motif_MWindowPeer
103.3167 - * Method:    getState
103.3168 - * Signature: ()I
103.3169 - */
103.3170 -JNIEXPORT jint JNICALL
103.3171 -Java_sun_awt_motif_MWindowPeer_getState(JNIEnv *env, jobject this)
103.3172 -{
103.3173 -    struct FrameData *wdata;
103.3174 -    jint state;
103.3175 -
103.3176 -    AWT_LOCK();
103.3177 -
103.3178 -    wdata = (struct FrameData *)
103.3179 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3180 -    if (wdata == NULL || wdata->winData.shell == NULL) {
103.3181 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3182 -        AWT_UNLOCK();
103.3183 -        return java_awt_Frame_NORMAL;
103.3184 -    }
103.3185 -
103.3186 -    state = wdata->state;
103.3187 -
103.3188 -    AWT_FLUSH_UNLOCK();
103.3189 -    return state;
103.3190 -}
103.3191 -
103.3192 -/*
103.3193 - * Class:     sun_awt_motif_MWindowPeer
103.3194 - * Method:    setState
103.3195 - * Signature: (I)V
103.3196 - */
103.3197 -JNIEXPORT void JNICALL
103.3198 -Java_sun_awt_motif_MWindowPeer_setState(JNIEnv *env, jobject this,
103.3199 -    jint state)
103.3200 -{
103.3201 -    struct FrameData *wdata;
103.3202 -    Widget shell;
103.3203 -    Window shell_win;
103.3204 -    jint changed;
103.3205 -    Boolean changeIconic, iconic;
103.3206 -
103.3207 -    AWT_LOCK();
103.3208 -    wdata = (struct FrameData *)
103.3209 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3210 -    if (wdata == NULL || wdata->winData.shell == NULL) {
103.3211 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3212 -        AWT_UNLOCK();
103.3213 -        return;
103.3214 -    }
103.3215 -
103.3216 -    shell = wdata->winData.shell;
103.3217 -    shell_win = XtWindow(shell);
103.3218 -
103.3219 -    DTRACE_PRINTLN4("TL: setState(0x%x/0x%x, 0x%X -> 0x%X)",
103.3220 -                    shell, shell_win,
103.3221 -                    wdata->state, state);
103.3222 -
103.3223 -    if (!wdata->isShowing) {
103.3224 -        /*
103.3225 -         * Not showing, so just record requested state; pShow will set
103.3226 -         * initial state hints/properties appropriately before poping
103.3227 -         * us up again.
103.3228 -         */
103.3229 -        DTRACE_PRINTLN("TL:     NOT showing (just record the new state)");
103.3230 -        wdata->state = state;
103.3231 -        AWT_UNLOCK();
103.3232 -        return;
103.3233 -    }
103.3234 -
103.3235 -    /*
103.3236 -     * Request the state transition from WM here and do java upcalls
103.3237 -     * in shell event handler when WM actually changes our state.
103.3238 -     */
103.3239 -    changed = wdata->state ^ state;
103.3240 -
103.3241 -    changeIconic = changed & java_awt_Frame_ICONIFIED;
103.3242 -    iconic = (state & java_awt_Frame_ICONIFIED) ? True : False;
103.3243 -
103.3244 -    if (changeIconic && iconic) {
103.3245 -        DTRACE_PRINTLN("TL:     set iconic = True");
103.3246 -        XIconifyWindow(XtDisplay(shell), shell_win,
103.3247 -                       XScreenNumberOfScreen(XtScreen(shell)));
103.3248 -    }
103.3249 -
103.3250 -    /*
103.3251 -     * If a change in both iconic and extended states requested, do
103.3252 -     * changes to extended state when we are in iconic state.
103.3253 -     */
103.3254 -    if ((changed & ~java_awt_Frame_ICONIFIED) != 0) {
103.3255 -        awt_wm_setExtendedState(wdata, state);
103.3256 -    }
103.3257 -
103.3258 -    if (changeIconic && !iconic) {
103.3259 -        DTRACE_PRINTLN("TL:     set iconic = False");
103.3260 -        XMapWindow(XtDisplay(shell), shell_win);
103.3261 -    }
103.3262 -
103.3263 -    AWT_FLUSH_UNLOCK();
103.3264 -}
103.3265 -
103.3266 -
103.3267 -/*
103.3268 - * Class:     sun_awt_motif_MWindowPeer
103.3269 - * Method:    pHide
103.3270 - * Signature: ()V
103.3271 - */
103.3272 -JNIEXPORT void JNICALL
103.3273 -Java_sun_awt_motif_MWindowPeer_pHide(JNIEnv *env, jobject this)
103.3274 -{
103.3275 -    struct FrameData *wdata;
103.3276 -
103.3277 -    AWT_LOCK();
103.3278 -    wdata = (struct FrameData *)
103.3279 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3280 -
103.3281 -    if (wdata == NULL
103.3282 -        || wdata->winData.comp.widget == NULL
103.3283 -        || wdata->winData.shell == NULL)
103.3284 -    {
103.3285 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3286 -        AWT_UNLOCK();
103.3287 -        return;
103.3288 -    }
103.3289 -
103.3290 -    /**
103.3291 -     * Disable proxy mechanism when Window's shell is being hidden
103.3292 -     */
103.3293 -    clearFocusPath(wdata->winData.shell);
103.3294 -
103.3295 -    wdata->isShowing = False;   /* ignore window state events */
103.3296 -
103.3297 -    if (XtIsRealized(wdata->winData.shell)) {
103.3298 -        /* XXX: uwe: this is bogus */
103.3299 -        /*
103.3300 -         * Make sure we withdraw a window in an unmaximized state, or
103.3301 -         * we'll lose out normal bounds (pShow will take care of
103.3302 -         * hinting maximization, so when the window is shown again it
103.3303 -         * will be correctly shown maximized).
103.3304 -         */
103.3305 -        if (wdata->state & java_awt_Frame_MAXIMIZED_BOTH) {
103.3306 -            awt_wm_setExtendedState(wdata,
103.3307 -                wdata->state & ~java_awt_Frame_MAXIMIZED_BOTH);
103.3308 -        }
103.3309 -        XtUnmanageChild(wdata->winData.comp.widget);
103.3310 -        XtPopdown(wdata->winData.shell);
103.3311 -    }
103.3312 -
103.3313 -    AWT_FLUSH_UNLOCK();
103.3314 -}
103.3315 -
103.3316 -
103.3317 -/* sun_awt_motif_MWindowPeer_pReshape() is native (X/Motif) routine that
103.3318 -   is called to effect a reposition and / or resize of the target frame.
103.3319 -   The parameters x,y,w,h specify target's x, y position, width, height.*/
103.3320 -
103.3321 -/*
103.3322 - * This functionality is invoked from both java and native code, and
103.3323 - * we only want to lock when invoking it from java, so wrap the native
103.3324 - * method version with the locking.
103.3325 - */
103.3326 -
103.3327 -/*
103.3328 - * Class:     sun_awt_motif_MWindowPeer
103.3329 - * Method:    pReshape
103.3330 - * Signature: (IIII)V
103.3331 - */
103.3332 -JNIEXPORT void JNICALL
103.3333 -Java_sun_awt_motif_MWindowPeer_pReshape(JNIEnv *env, jobject this,
103.3334 -    jint x, jint y, jint w, jint h)
103.3335 -{
103.3336 -    struct FrameData    *wdata;
103.3337 -
103.3338 -    AWT_LOCK();
103.3339 -
103.3340 -    wdata = (struct FrameData *)
103.3341 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3342 -
103.3343 -    if (wdata == NULL ||
103.3344 -        wdata->winData.comp.widget == NULL ||
103.3345 -        wdata->winData.shell == NULL) {
103.3346 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3347 -        AWT_UNLOCK();
103.3348 -        return;
103.3349 -    }
103.3350 -
103.3351 -    // See if our new location is on a new screen
103.3352 -    if (wdata->reparented) {
103.3353 -        checkNewXineramaScreen(env, this, wdata, x, y, w, h);
103.3354 -    }
103.3355 -
103.3356 -    /**
103.3357 -     * Fix for 4652685.
103.3358 -     * Avoid setting position for embedded frames, since this conflicts with the
103.3359 -     * fix for 4419207. We assume that the embedded frame never changes its
103.3360 -     * position relative to the parent.
103.3361 -     */
103.3362 -    if (wdata->winData.flags & W_IS_EMBEDDED) {
103.3363 -        x = 0;
103.3364 -        y = 0;
103.3365 -    }
103.3366 -
103.3367 -    reshape(env, this, wdata, x, y, w, h, True);
103.3368 -
103.3369 -    AWT_FLUSH_UNLOCK();
103.3370 -}
103.3371 -
103.3372 -/*
103.3373 - * Class:     sun_awt_motif_MEmbeddedFramePeer
103.3374 - * Method:    pReshapePrivate
103.3375 - * Signature: (IIII)V
103.3376 - */
103.3377 -JNIEXPORT void JNICALL
103.3378 -Java_sun_awt_motif_MEmbeddedFramePeer_pReshapePrivate(JNIEnv *env, jobject this,
103.3379 -    jint x, jint y, jint w, jint h)
103.3380 -{
103.3381 -    struct FrameData    *wdata;
103.3382 -
103.3383 -    AWT_LOCK();
103.3384 -
103.3385 -    wdata = (struct FrameData *)
103.3386 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3387 -
103.3388 -    if (wdata == NULL ||
103.3389 -        wdata->winData.comp.widget == NULL ||
103.3390 -        wdata->winData.shell == NULL) {
103.3391 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3392 -        AWT_UNLOCK();
103.3393 -        return;
103.3394 -    }
103.3395 -
103.3396 -    reshape(env, this, wdata, x, y, w, h, True);
103.3397 -
103.3398 -    AWT_FLUSH_UNLOCK();
103.3399 -}
103.3400 -
103.3401 -static void
103.3402 -reshape(JNIEnv *env, jobject this, struct FrameData *wdata,
103.3403 -        jint x, jint y, jint w, jint h, Boolean setXY)
103.3404 -{
103.3405 -    int32_t     topAdjust,      /* top adjustment of offset     */
103.3406 -                bottomAdjust;   /* bottom adjustment of offset  */
103.3407 -    int32_t     width,          /* of X/Motif shell and form    */
103.3408 -                height;         /* of X/Motif shell and form    */
103.3409 -    int32_t     w1, h1;
103.3410 -    enum wmgr_t wm;             /* window manager */
103.3411 -    XWindowAttributes winAttr;
103.3412 -
103.3413 -    DTRACE_PRINTLN7("TL: reshape(0x%x/0x%x,\n"/**/
103.3414 -                    "TL:         x = %d, y = %d, w = %d, h = %d, %s)",
103.3415 -                    wdata->winData.shell, XtWindow(wdata->winData.shell),
103.3416 -                    x, y, w, h,
103.3417 -                    setXY ? "setXY" : "false");
103.3418 -
103.3419 -    wm = awt_wm_getRunningWM();
103.3420 -
103.3421 -    /* Make adjustments in case of a dynamically added/removed menu bar */
103.3422 -    awtJNI_setMbAndWwHeightAndOffsets(env, this, wdata);
103.3423 -
103.3424 -#ifdef _pauly_debug
103.3425 -    fprintf(stdout,"    reshape. offsets - top: %d, bottom: %d, left: %d, right: %d\n",
103.3426 -            wdata->top, wdata->bottom, wdata->left, wdata->right);
103.3427 -    fflush(stdout);
103.3428 -#endif /* _pauly_debug */
103.3429 -
103.3430 -    /* The abstract java (target) position coordinates (x,y)
103.3431 -       are for the bordered window.  Eventually(!), the Motif
103.3432 -       (shell) coordinates (XmNx, XmNy) will exclude borders.
103.3433 -       (This is true only AFTER shell is massaged by the WM.)   */
103.3434 -
103.3435 -    /* The abstract java (target) width and height includes any WM
103.3436 -       borders. But the Motif width and height excludes WM borders.
103.3437 -       The wdata top and bottom fields may include space for menu bar,
103.3438 -       warning window, etc. We must adjust by these values for shell.   */
103.3439 -    topAdjust = 0;
103.3440 -    bottomAdjust = 0;
103.3441 -    /* Surprise - do not(!) check for nonNull MenuBar because that can
103.3442 -       occur separately (in ...pSetMenubar()) from calculation of the
103.3443 -       menu bar height and offsets (in setMbAndWwHeightAndOffsets()).
103.3444 -       In any event, the offsets and wdata mbHeight field should jive.  */
103.3445 -    topAdjust += wdata->mbHeight;
103.3446 -    if  (wdata->warningWindow != NULL) {
103.3447 -#ifdef NETSCAPE
103.3448 -        bottomAdjust += wdata->wwHeight;
103.3449 -#else /* NETSCAPE */
103.3450 -        topAdjust += wdata->wwHeight;
103.3451 -#endif /* NETSCAPE */
103.3452 -    }
103.3453 -    if (wdata->hasTextComponentNative) {
103.3454 -        bottomAdjust +=  wdata->imHeight;
103.3455 -    }
103.3456 -#ifdef _pauly_debug
103.3457 -    fprintf(stdout,"    reshape. adjustments - top: %d, bottom: %d\n", topAdjust, bottomAdjust);
103.3458 -    fflush(stdout);
103.3459 -#endif /* _pauly_debug */
103.3460 -
103.3461 -    width  = w - (wdata->left + wdata->right);
103.3462 -    height = h - (wdata->top + wdata->bottom) + (topAdjust + bottomAdjust);
103.3463 -
103.3464 -    /*
103.3465 -     * Shell size.
103.3466 -     * 4033151.  If nonpositive size specified (e.g., if no size
103.3467 -     * given), establish minimum allowable size.  Note: Motif shell
103.3468 -     * can not be sized 0.
103.3469 -     */
103.3470 -    w1 = (width  > 0) ? width  : 1;
103.3471 -    h1 = (height > 0) ? height : 1;
103.3472 -
103.3473 -    if (awt_wm_configureGravityBuggy() /* WM ignores window gravity */
103.3474 -        && wdata->reparented && wdata->isShowing)
103.3475 -    {
103.3476 -        /*
103.3477 -         * Buggy WM places client window at (x,y) ignoring the window
103.3478 -         * gravity.  All our windows are NorthWestGravity, so adjust
103.3479 -         * (x,y) by insets appropriately.
103.3480 -         */
103.3481 -        x += wdata->left;
103.3482 -        y += wdata->top;
103.3483 -        DTRACE_PRINTLN2("TL: work around WM gravity bug: x += %d, y += %d",
103.3484 -                        wdata->left, wdata->top);
103.3485 -    }
103.3486 -
103.3487 -    if (wdata->imRemove) {
103.3488 -        XtVaSetValues(XtParent(wdata->winData.comp.widget),
103.3489 -                      XmNheight, (((h - (wdata->top + wdata->bottom)) > 0) ?
103.3490 -                                  (h - (wdata->top + wdata->bottom)) : 1),
103.3491 -                      NULL);
103.3492 -        wdata->imRemove = False;
103.3493 -    }
103.3494 -
103.3495 -#if 0 /* XXX: this screws insets calculation under KDE2 in the case of
103.3496 -         negative x, y */
103.3497 -    /*
103.3498 -     * Without these checks, kwm places windows slightly off the screen,
103.3499 -     * when there is a window underneath at (0,0) and empty space below,
103.3500 -     * but not to the right.
103.3501 -     */
103.3502 -    if (x < 0) x = 0;
103.3503 -    if (y < 0) y = 0;
103.3504 -#endif
103.3505 -    if ((wdata->winData.flags & W_IS_EMBEDDED) == 0) {
103.3506 -        if ((wm == MOTIF_WM) || (wm == CDE_WM)) {
103.3507 -            /*
103.3508 -             * By default MWM has "usePPosition: nonzero" and so ignores
103.3509 -             * windows with PPosition (0,0).  Work around (should we???).
103.3510 -             */
103.3511 -            if ((x == 0) && (y == 0)) {
103.3512 -                x = y = 1;
103.3513 -            }
103.3514 -        }
103.3515 -    }
103.3516 -
103.3517 -    if ( wdata->decor == AWT_NO_DECOR ) {
103.3518 -        if (setXY)
103.3519 -            XtConfigureWidget(wdata->winData.shell, x, y, w1, h1, 0 );
103.3520 -        else
103.3521 -            XtResizeWidget(wdata->winData.shell, w1, h1, 0);
103.3522 -    }
103.3523 -    else {
103.3524 -        /*
103.3525 -         * 5006248, workaround for OpenLook WM.
103.3526 -         * Thread gets stuck at XtVaSetValues call awaiting for first
103.3527 -         * ConfigureNotify to come. For OpenLook it looks like a showstopper.
103.3528 -         * We put dummy ConfigureNotify to satisfy the requirements.
103.3529 -         */
103.3530 -        if (awt_wm_getRunningWM() == OPENLOOK_WM) {
103.3531 -            XEvent xev;
103.3532 -            xev.xconfigure.type = ConfigureNotify;
103.3533 -            xev.xconfigure.display = awt_display;
103.3534 -            xev.xconfigure.window = XtWindow(wdata->winData.shell);
103.3535 -            xev.xconfigure.event = xev.xconfigure.window;
103.3536 -            xev.xconfigure.x = x;
103.3537 -            xev.xconfigure.y = y;
103.3538 -            xev.xconfigure.height = h1;
103.3539 -            xev.xconfigure.width = w1;
103.3540 -            xev.xconfigure.serial = NextRequest(awt_display) + 1; // see isMine() Xt inner function code.
103.3541 -
103.3542 -            XPutBackEvent(awt_display, &xev);
103.3543 -        }
103.3544 -
103.3545 -        if (wdata->isResizable) {
103.3546 -            XtVaSetValues(wdata->winData.shell,
103.3547 -                          XmNwidth, w1,
103.3548 -                          XmNheight, h1,
103.3549 -                          NULL);
103.3550 -        }
103.3551 -        else {
103.3552 -            /*
103.3553 -             * Fix for BugTraq ID 4313607 - call awt_wm_setShellNotResizable
103.3554 -             * regardless of wdata->isFixedSizeSet and wdata->reparented values.
103.3555 -             */
103.3556 -            DTRACE_PRINTLN("TL: set fixed size from reshape");
103.3557 -            awt_wm_setShellNotResizable(wdata, w1, h1, True);
103.3558 -            if (wdata->reparented && (w1 > 0) && (h1 > 0)) {
103.3559 -                wdata->isFixedSizeSet = True;
103.3560 -            }
103.3561 -        }
103.3562 -        if (setXY)
103.3563 -            XtVaSetValues(wdata->winData.shell,
103.3564 -                          XmNx, x,
103.3565 -                          XmNy, y,
103.3566 -                          NULL);
103.3567 -    }
103.3568 -    /* inner/parent drawing area (parent is form) */
103.3569 -    h1 = h - (wdata->top + wdata->bottom);
103.3570 -    h1 = ( h1 > 0 ) ? h1 : 1;
103.3571 -#if 0
103.3572 -    XtConfigureWidget(XtParent(wdata->winData.comp.widget),
103.3573 -                      0, topAdjust, w1, h1, 0 );
103.3574 -#else
103.3575 -    XtVaSetValues(XtParent(wdata->winData.comp.widget),
103.3576 -                  XmNx, 0,
103.3577 -                  XmNy, topAdjust,
103.3578 -                  XmNwidth, w1,
103.3579 -                  XmNheight, h1,
103.3580 -                  NULL);
103.3581 -#endif
103.3582 -
103.3583 -#ifdef _pauly_debug
103.3584 -        fprintf(stdout,"    reshape. setting inner canvas to: %d,%d,%d,%d\n",
103.3585 -        0, topAdjust, w1, h1 );
103.3586 -        fflush(stdout);
103.3587 -#endif /* _pauly_debug */
103.3588 -
103.3589 -    wdata->menuBarReset = False;
103.3590 -
103.3591 -    /* DTRACE_PRINTLN("TL: reshape -> returning"); */
103.3592 -    return;
103.3593 -}
103.3594 -
103.3595 -/*
103.3596 - * Class:     sun_awt_motif_MEmbeddedFramePeer
103.3597 - * Method:    getBoundsPrivate
103.3598 - * Signature: ()Ljava/awt/Rectangle
103.3599 - */
103.3600 -JNIEXPORT jobject JNICALL Java_sun_awt_motif_MEmbeddedFramePeer_getBoundsPrivate
103.3601 -  (JNIEnv * env, jobject this)
103.3602 -{
103.3603 -    jobject bounds = NULL;
103.3604 -    struct FrameData *cdata;
103.3605 -    XWindowAttributes attr;
103.3606 -
103.3607 -    AWT_LOCK();
103.3608 -
103.3609 -    cdata = (struct FrameData *)
103.3610 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3611 -    if (cdata == NULL || cdata->mainWindow == NULL) {
103.3612 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3613 -        AWT_UNLOCK();
103.3614 -        return NULL;
103.3615 -    }
103.3616 -    if (!XtIsRealized(cdata->mainWindow) || !XtIsRealized(cdata->winData.shell)) {
103.3617 -        JNU_ThrowInternalError(env, "widget not visible on screen");
103.3618 -        AWT_UNLOCK();
103.3619 -        return NULL;
103.3620 -    }
103.3621 -
103.3622 -    memset(&attr, 0, sizeof(XWindowAttributes));
103.3623 -    XGetWindowAttributes(awt_display, XtWindow(cdata->winData.shell), &attr);
103.3624 -
103.3625 -    bounds = JNU_NewObjectByName(env, "java/awt/Rectangle", "(IIII)V",
103.3626 -                                (jint)attr.x, (jint)attr.y, (jint)attr.width, (jint)attr.height);
103.3627 -    if (((*env)->ExceptionOccurred(env)) || JNU_IsNull(env, bounds)) {
103.3628 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3629 -        AWT_UNLOCK();
103.3630 -        return NULL;
103.3631 -    }
103.3632 -
103.3633 -    AWT_UNLOCK();
103.3634 -
103.3635 -    return bounds;
103.3636 -}
103.3637 -
103.3638 -/*
103.3639 - * Class:     sun_awt_motif_MWindowPeer
103.3640 - * Method:    pDispose
103.3641 - * Signature: ()V
103.3642 - */
103.3643 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_pDispose
103.3644 -(JNIEnv *env, jobject this)
103.3645 -{
103.3646 -    struct FrameData *wdata;
103.3647 -
103.3648 -    AWT_LOCK();
103.3649 -    wdata = (struct FrameData *)
103.3650 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3651 -    if (wdata == NULL || wdata->mainWindow == NULL || wdata->winData.shell == NULL) {
103.3652 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3653 -        AWT_UNLOCK();
103.3654 -        return;
103.3655 -    }
103.3656 -    if (wdata->winData.flags & W_IS_EMBEDDED) {
103.3657 -        awt_util_delEmbeddedFrame(wdata->winData.shell);
103.3658 -        deinstall_xembed(wdata);
103.3659 -    }
103.3660 -    scheduleDispose(env, this);
103.3661 -
103.3662 -    AWT_FLUSH_UNLOCK();
103.3663 -}
103.3664 -
103.3665 -/*
103.3666 - * Class:     sun_awt_motif_MFramePeer
103.3667 - * Method:    pGetIconSize
103.3668 - * Signature: (II)Z
103.3669 - */
103.3670 -JNIEXPORT jboolean JNICALL Java_sun_awt_motif_MFramePeer_pGetIconSize
103.3671 -(JNIEnv *env, jobject this, jint widthHint, jint heightHint)
103.3672 -{
103.3673 -    struct FrameData *wdata;
103.3674 -    uint32_t width, height, border_width, depth;
103.3675 -    Window win;
103.3676 -    int32_t x, y;
103.3677 -    uint32_t mask;
103.3678 -    XSetWindowAttributes attrs;
103.3679 -    uint32_t saveWidth = 0;
103.3680 -    uint32_t saveHeight = 0;
103.3681 -    uint32_t dist = 0xffffffff;
103.3682 -    int32_t diff = 0;
103.3683 -    int32_t closestWidth;
103.3684 -    int32_t closestHeight;
103.3685 -    int32_t newDist;
103.3686 -    int32_t found = 0;
103.3687 -    AwtGraphicsConfigDataPtr adata;
103.3688 -
103.3689 -    AWT_LOCK();
103.3690 -    wdata = (struct FrameData *)
103.3691 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3692 -    if (wdata == NULL) {
103.3693 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3694 -        AWT_UNLOCK();
103.3695 -        return FALSE;
103.3696 -    }
103.3697 -    XtVaGetValues(wdata->winData.shell,
103.3698 -                  XmNiconWindow, &win,
103.3699 -                  NULL);
103.3700 -    if (!win) {
103.3701 -        int32_t count;
103.3702 -        int32_t i;
103.3703 -        XIconSize *sizeList;
103.3704 -
103.3705 -        adata = getGraphicsConfigFromComponentPeer(env, this);
103.3706 -
103.3707 -        if (!XGetIconSizes(awt_display,
103.3708 -                           RootWindow(awt_display, adata->awt_visInfo.screen),
103.3709 -                           &sizeList, &count)) {
103.3710 -            /* No icon sizes so can't set it -- Should we throw an exception?*/
103.3711 -            /* [jk] I don't think so: simply fall back to 16x16 */
103.3712 -            saveWidth = saveHeight = 16;
103.3713 -            goto top;
103.3714 -        }
103.3715 -        for (i=0; i < count; i++) {
103.3716 -            if (widthHint >= sizeList[i].min_width &&
103.3717 -                widthHint <= sizeList[i].max_width &&
103.3718 -                heightHint >= sizeList[i].min_height &&
103.3719 -                heightHint <= sizeList[i].max_height) {
103.3720 -                found = 1;
103.3721 -                if ((((widthHint-sizeList[i].min_width)
103.3722 -                      % sizeList[i].width_inc) == 0) &&
103.3723 -                    (((heightHint-sizeList[i].min_height)
103.3724 -                      % sizeList[i].height_inc) ==0)) {
103.3725 -                    /* Found an exact match */
103.3726 -                    saveWidth = widthHint;
103.3727 -                    saveHeight = heightHint;
103.3728 -                    dist = 0;
103.3729 -                    break;
103.3730 -                }
103.3731 -                diff = widthHint - sizeList[i].min_width;
103.3732 -                if (diff == 0) {
103.3733 -                    closestWidth = widthHint;
103.3734 -                } else {
103.3735 -                    diff = diff%sizeList[i].width_inc;
103.3736 -                    closestWidth = widthHint - diff;
103.3737 -                }
103.3738 -                diff = heightHint - sizeList[i].min_height;
103.3739 -                if (diff == 0) {
103.3740 -                    closestHeight = heightHint;
103.3741 -                } else {
103.3742 -                    diff = diff%sizeList[i].height_inc;
103.3743 -                    closestHeight = heightHint - diff;
103.3744 -                }
103.3745 -                newDist = closestWidth*closestWidth +
103.3746 -                    closestHeight*closestHeight;
103.3747 -                if (dist > newDist) {
103.3748 -                    saveWidth = closestWidth;
103.3749 -                    saveHeight = closestHeight;
103.3750 -                    dist = newDist;
103.3751 -                }
103.3752 -            }
103.3753 -        }
103.3754 -
103.3755 -        if (!found) {
103.3756 -#if 1
103.3757 -            /* [sbb] this code should work better than the original Solaris
103.3758 -               code */
103.3759 -            if (widthHint  >= sizeList[0].max_width ||
103.3760 -                heightHint >= sizeList[0].max_height) {
103.3761 -              /* determine which way to scale */
103.3762 -              int32_t wdiff = widthHint - sizeList[0].max_width;
103.3763 -              int32_t hdiff = heightHint - sizeList[0].max_height;
103.3764 -              if (wdiff >= hdiff) { /* need to scale width more  */
103.3765 -                saveWidth = sizeList[0].max_width;
103.3766 -                saveHeight = (int32_t)(((double)sizeList[0].max_width/widthHint) *
103.3767 -                                   heightHint);
103.3768 -              } else {
103.3769 -                saveWidth = (int32_t)(((double)sizeList[0].max_height/heightHint) *
103.3770 -                                  widthHint);
103.3771 -                saveHeight = sizeList[0].max_height;
103.3772 -              }
103.3773 -            } else if (widthHint  < sizeList[0].min_width ||
103.3774 -                       heightHint < sizeList[0].min_height) {
103.3775 -                saveWidth = (sizeList[0].min_width+sizeList[0].max_width)/2;
103.3776 -                saveHeight = (sizeList[0].min_height+sizeList[0].max_height)/2;
103.3777 -            } else {            /* it fits within the right size */
103.3778 -              saveWidth = widthHint;
103.3779 -              saveHeight = heightHint;
103.3780 -            }
103.3781 -
103.3782 -#else /* XXX: old Solaris code */
103.3783 -            /* REMIND: Aspect ratio */
103.3784 -            if (widthHint  >= sizeList[0].max_width &&
103.3785 -                heightHint >= sizeList[0].max_height) {
103.3786 -                saveWidth = sizeList[0].max_width;
103.3787 -                saveHeight = sizeList[0].max_height;
103.3788 -            } else if (widthHint  >= sizeList[0].min_width &&
103.3789 -                       heightHint >= sizeList[0].min_height) {
103.3790 -                saveWidth = sizeList[0].min_width;
103.3791 -                saveHeight = sizeList[0].min_height;
103.3792 -            } else {
103.3793 -                saveWidth = (sizeList[0].min_width+sizeList[0].max_width)/2;
103.3794 -                saveHeight = (sizeList[0].min_height+sizeList[0].max_height)/2;
103.3795 -            }
103.3796 -#endif
103.3797 -        }
103.3798 -        free((void *) sizeList);
103.3799 -    } else {
103.3800 -        Window root;
103.3801 -        if (XGetGeometry(awt_display,
103.3802 -                         win,
103.3803 -                         &root,
103.3804 -                         &x,
103.3805 -                         &y,
103.3806 -                         (uint32_t *)&saveWidth,
103.3807 -                         (uint32_t *)&saveHeight,
103.3808 -                         (uint32_t *)&border_width,
103.3809 -                         (uint32_t *)&depth)) {
103.3810 -        }
103.3811 -    }
103.3812 -
103.3813 - top:
103.3814 -    (*env)->SetIntField(env, this, mWindowPeerIDs.iconWidth, (jint)saveWidth);
103.3815 -    (*env)->SetIntField(env, this, mWindowPeerIDs.iconHeight, (jint)saveHeight);
103.3816 -
103.3817 -    AWT_UNLOCK();
103.3818 -    return TRUE;
103.3819 -}
103.3820 -
103.3821 -/*
103.3822 - * Class:     sun_awt_motif_MFramePeer
103.3823 - * Method:    pSetIconImage
103.3824 - * Signature: ([B[I[SII)V
103.3825 - */
103.3826 -JNIEXPORT void JNICALL Java_sun_awt_motif_MFramePeer_pSetIconImage___3B_3I_3SII
103.3827 -(JNIEnv *env, jobject this,
103.3828 - jbyteArray jbyteData, jintArray jintData, jshortArray jushortData,
103.3829 - jint iconWidth, jint iconHeight)
103.3830 -{
103.3831 -    struct FrameData *wdata;
103.3832 -    Window win;
103.3833 -    GC gc;
103.3834 -    int32_t x, y;
103.3835 -    XImage *dst;
103.3836 -    uint32_t mask;
103.3837 -    XSetWindowAttributes attrs;
103.3838 -    jobject jbuf = NULL;
103.3839 -    void *buf = NULL;
103.3840 -    int32_t len = 0;
103.3841 -    int32_t bpp, slp, bpsl;
103.3842 -    AwtGraphicsConfigDataPtr adata;
103.3843 -
103.3844 -    if (JNU_IsNull(env, jbyteData)) {
103.3845 -        if (JNU_IsNull(env, jintData)) {
103.3846 -            if (JNU_IsNull(env, jushortData)) {
103.3847 -                /* [jk] Don't throw an exception here, it breaks
103.3848 -                 * programs that run correctly on Windows
103.3849 -                 * JNU_ThrowNullPointerException(env, "NullPointerException");
103.3850 -                 */
103.3851 -                return;
103.3852 -            } else {
103.3853 -                jbuf = jushortData;
103.3854 -            }
103.3855 -        } else {
103.3856 -            jbuf = jintData;
103.3857 -        }
103.3858 -    } else {
103.3859 -        jbuf = jbyteData;
103.3860 -        len = (*env)->GetArrayLength(env, jbyteData);
103.3861 -    }
103.3862 -    AWT_LOCK();
103.3863 -    wdata = (struct FrameData *)
103.3864 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.3865 -    /* REMIND: Need to figure out how to display image on a pixmap */
103.3866 -
103.3867 -    if (wdata == NULL || wdata->winData.shell == NULL) {
103.3868 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.3869 -        AWT_UNLOCK();
103.3870 -        return;
103.3871 -    }
103.3872 -
103.3873 -    adata = getGraphicsConfigFromComponentPeer(env, this);
103.3874 -
103.3875 -    /* [jk] we need a new pixmap everytime:
103.3876 -     * Test case: src/share/test/awt/FrameTest.html Look at the icon,
103.3877 -     * select Operations/Change IconImage, you should see a different
103.3878 -     * icon now.
103.3879 -     */
103.3880 -    if (wdata->iconPixmap) {
103.3881 -        XFreePixmap(awt_display, wdata->iconPixmap);
103.3882 -        wdata->iconPixmap = None;
103.3883 -    }
103.3884 -
103.3885 -    if (wdata->iconPixmap == None) {
103.3886 -        if ((wdata->iconPixmap =
103.3887 -             XCreatePixmap(awt_display,
103.3888 -                           RootWindow(awt_display, adata->awt_visInfo.screen),
103.3889 -                           iconWidth, iconHeight,
103.3890 -                           adata->awtImage->Depth)) == None) {
103.3891 -            /* REMIND: How to warn that there was a problem? */
103.3892 -            AWT_UNLOCK();
103.3893 -            return;
103.3894 -        }
103.3895 -        wdata->iconWidth = iconWidth;
103.3896 -        wdata->iconHeight = iconHeight;
103.3897 -    }
103.3898 -
103.3899 -    buf = (void *) (*env)->GetPrimitiveArrayCritical(env, jbuf, NULL);
103.3900 -    if (jbyteData != NULL) {
103.3901 -        int32_t i;
103.3902 -        unsigned char *ubuf = (unsigned char *) buf;
103.3903 -        /* Need to map from ICM lut to cmap */
103.3904 -        for (i=0; i < len; i++) {
103.3905 -            ubuf[i] = (ubuf[i] >= adata->color_data->awt_numICMcolors)
103.3906 -                        ? 0
103.3907 -                        : adata->color_data->awt_icmLUT2Colors[ubuf[i]];
103.3908 -        }
103.3909 -    }
103.3910 -
103.3911 -    bpp = adata->awtImage->wsImageFormat.bits_per_pixel;
103.3912 -    slp = adata->awtImage->wsImageFormat.scanline_pad;
103.3913 -    bpsl = paddedwidth(iconWidth * bpp, slp) >> 3;
103.3914 -    if (((bpsl << 3) / bpp) < iconWidth) {
103.3915 -        (*env)->ReleasePrimitiveArrayCritical(env, jbuf, buf, JNI_ABORT);
103.3916 -        AWT_UNLOCK();
103.3917 -        return;
103.3918 -    }
103.3919 -    dst = XCreateImage(awt_display, adata->awt_visInfo.visual,
103.3920 -                       adata->awtImage->Depth, ZPixmap, 0,
103.3921 -                       buf, iconWidth, iconHeight, 32, bpsl);
103.3922 -    if (dst == NULL) {
103.3923 -        /* REMIND: How to warn that there was a problem? */
103.3924 -        (*env)->ReleasePrimitiveArrayCritical(env, jbuf, buf, JNI_ABORT);
103.3925 -        AWT_UNLOCK();
103.3926 -        return;
103.3927 -    }
103.3928 -
103.3929 -    if ((gc = XCreateGC(awt_display, wdata->iconPixmap, 0, 0)) == NULL) {
103.3930 -        XDestroyImage (dst);
103.3931 -        (*env)->ReleasePrimitiveArrayCritical(env, jbuf, buf, JNI_ABORT);
103.3932 -        AWT_UNLOCK();
103.3933 -        return;
103.3934 -    }
103.3935 -
103.3936 -    XPutImage(awt_display, wdata->iconPixmap, gc, dst,
103.3937 -              0, 0, 0, 0, iconWidth, iconHeight);
103.3938 -    (*env)->ReleasePrimitiveArrayCritical(env, jbuf, buf, JNI_ABORT);
103.3939 -    dst->data=NULL;
103.3940 -    XDestroyImage(dst);
103.3941 -    XFreeGC(awt_display, gc);
103.3942 -
103.3943 -    XtVaGetValues(wdata->winData.shell,
103.3944 -                  XmNiconWindow, &win,
103.3945 -                  NULL);
103.3946 -    if (!win) {
103.3947 -        mask = CWBorderPixel | CWColormap | CWBackPixmap;
103.3948 -        attrs.border_pixel = awt_defaultFg;
103.3949 -        attrs.colormap = adata->awt_cmap;
103.3950 -        attrs.background_pixmap = wdata->iconPixmap;
103.3951 -        if (!(win = XCreateWindow(awt_display,
103.3952 -                                  RootWindow(awt_display,
103.3953 -                                             adata->awt_visInfo.screen),
103.3954 -                                  0, 0, iconWidth, iconHeight,
103.3955 -                                  (uint32_t) 0,
103.3956 -                                  adata->awtImage->Depth,
103.3957 -                                  InputOutput,
103.3958 -                                  adata->awt_visInfo.visual,
103.3959 -                                  mask, &attrs))) {
103.3960 -            /* Still can't create the window so try setting iconPixmap */
103.3961 -            XtVaSetValues(wdata->winData.shell,
103.3962 -                          XmNiconPixmap, wdata->iconPixmap,
103.3963 -                          NULL);
103.3964 -            AWT_FLUSH_UNLOCK();
103.3965 -            return;
103.3966 -        }
103.3967 -    }
103.3968 -
103.3969 -    XtVaSetValues(wdata->winData.shell,
103.3970 -                  XmNiconPixmap, wdata->iconPixmap,
103.3971 -                  XmNiconWindow, win,
103.3972 -                  NULL);
103.3973 -
103.3974 -    XSetWindowBackgroundPixmap(awt_display, win, wdata->iconPixmap);
103.3975 -    XClearWindow(awt_display, win);
103.3976 -    AWT_FLUSH_UNLOCK();
103.3977 -}
103.3978 -
103.3979 -
103.3980 -/*
103.3981 - * Class:     sun_awt_motif_MWindowPeer
103.3982 - * Method:    setResizable
103.3983 - * Signature: (Z)V
103.3984 - */
103.3985 -JNIEXPORT void JNICALL
103.3986 -Java_sun_awt_motif_MWindowPeer_setResizable(JNIEnv *env, jobject this,
103.3987 -    jboolean resizable)
103.3988 -{
103.3989 -    struct FrameData    *wdata;
103.3990 -    jobject             target;
103.3991 -    int32_t             targetWidth,
103.3992 -                        targetHeight;
103.3993 -    int32_t             width,          /* fixed width if not resizable */
103.3994 -                        height;         /* fixed height if not resizable*/
103.3995 -    int32_t             verticalAdjust; /* menubar, warning window, etc.*/
103.3996 -
103.3997 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
103.3998 -        return;
103.3999 -    }
103.4000 -
103.4001 -    AWT_LOCK();
103.4002 -
103.4003 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.4004 -
103.4005 -    wdata = (struct FrameData *)
103.4006 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4007 -
103.4008 -    if (wdata == NULL
103.4009 -        || wdata->winData.comp.widget == NULL
103.4010 -        || wdata->winData.shell == NULL
103.4011 -        || JNU_IsNull(env, target))
103.4012 -    {
103.4013 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4014 -        if (!JNU_IsNull(env, target))
103.4015 -            (*env)->DeleteLocalRef(env, target);
103.4016 -        AWT_UNLOCK();
103.4017 -        return;
103.4018 -    }
103.4019 -
103.4020 -    DTRACE_PRINTLN3("TL: setResizable(0x%x/0x%x, %s)",
103.4021 -                    wdata->winData.shell, XtWindow(wdata->winData.shell),
103.4022 -                    resizable ? "true" : "false");
103.4023 -
103.4024 -    if ((!wdata->isResizable) && (resizable)) {
103.4025 -        awt_wm_setShellResizable(wdata);
103.4026 -        wdata->isFixedSizeSet = False;
103.4027 -    }
103.4028 -    else if ((wdata->isResizable) && (!resizable)) {
103.4029 -        /*
103.4030 -         * To calculate fixed window width, height, we must subtract
103.4031 -         * off the window manager borders as stored in the wdata
103.4032 -         * structure.  But note that the wdata top and bottom fields
103.4033 -         * may include space for warning window, menubar, IM status;
103.4034 -         * this IS part of shell.
103.4035 -         */
103.4036 -        verticalAdjust = wdata->mbHeight;
103.4037 -        if (wdata->warningWindow != NULL) {
103.4038 -            verticalAdjust += wdata->wwHeight;
103.4039 -        }
103.4040 -        if (wdata->hasTextComponentNative) {
103.4041 -            verticalAdjust += wdata->imHeight;
103.4042 -        }
103.4043 -
103.4044 -        targetWidth  = (*env)->GetIntField(env, target, componentIDs.width);
103.4045 -        targetHeight = (*env)->GetIntField(env, target, componentIDs.height);
103.4046 -        width  = targetWidth  - (wdata->left + wdata->right);
103.4047 -        height = targetHeight - (wdata->top + wdata->bottom) + verticalAdjust;
103.4048 -#ifdef __linux__
103.4049 -        width  = (width  > 0) ? width  : 1;
103.4050 -        height = (height > 0) ? height : 1;
103.4051 -#endif
103.4052 -        DTRACE_PRINTLN2("TL:     setting fixed size %ld x %ld", width, height);
103.4053 -        awt_wm_setShellNotResizable(wdata, width, height, False);
103.4054 -        if ((width > 0) && (height > 0)) {
103.4055 -            wdata->isFixedSizeSet = True;
103.4056 -        }
103.4057 -    }
103.4058 -
103.4059 -    wdata->isResizable = (Boolean)resizable;
103.4060 -
103.4061 -    (*env)->DeleteLocalRef(env, target);
103.4062 -    AWT_FLUSH_UNLOCK();
103.4063 -}
103.4064 -
103.4065 -
103.4066 -/* sun_awt_motif_MWindowPeer_pSetMenuBar() is native (X/Motif) routine
103.4067 -   which handles insertion or deletion of a menubar from this frame.    */
103.4068 -
103.4069 -/*
103.4070 - * Class:     sun_awt_motif_MWindowPeer
103.4071 - * Method:    pSetMenuBar
103.4072 - * Signature: (Lsun/awt/motif/MMenuBarPeer;)V
103.4073 - */
103.4074 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_pSetMenuBar
103.4075 -(JNIEnv *env, jobject this, jobject mb)
103.4076 -{
103.4077 -    struct FrameData            *wdata;
103.4078 -    struct ComponentData        *mdata;
103.4079 -    jobject                     target;
103.4080 -    Widget                      innerCanvasW;   /* Motif inner canvas   */
103.4081 -#ifdef _pauly_debug
103.4082 -    Dimension                   mbHeight;       /* Motif menubar height */
103.4083 -#endif /* _pauly_debug */
103.4084 -
103.4085 -#ifdef _pauly_debug
103.4086 -    fprintf(stdout," ++ ...pSetMenuBar.\n");
103.4087 -    fflush(stdout);
103.4088 -#endif /* _pauly_debug */
103.4089 -
103.4090 -
103.4091 -    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
103.4092 -        return;
103.4093 -    }
103.4094 -    AWT_LOCK();
103.4095 -
103.4096 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.4097 -
103.4098 -    wdata = (struct FrameData *)
103.4099 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4100 -
103.4101 -    if (JNU_IsNull(env, target) || wdata == NULL) {
103.4102 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4103 -        if  (!JNU_IsNull(env, target)) {
103.4104 -            (*env)->DeleteLocalRef(env, target);
103.4105 -        }
103.4106 -        AWT_UNLOCK();
103.4107 -        return;
103.4108 -    }
103.4109 -
103.4110 -    if (mb == NULL) {
103.4111 -#ifdef _pauly_debug
103.4112 -        fprintf(stdout,"    ...pSetMenuBar. mb is null.\n");
103.4113 -        fflush(stdout);
103.4114 -#endif /* _pauly_debug */
103.4115 -        if  (wdata->menuBar != NULL) {
103.4116 -            /* Redo attachments of other form widgets appropriately now */
103.4117 -            innerCanvasW = XtParent(wdata->winData.comp.widget);
103.4118 -
103.4119 -            if  (wdata->warningWindow == NULL) {
103.4120 -                /* no warning window: canvas is now attached to form    */
103.4121 -                XtVaSetValues(innerCanvasW,
103.4122 -                              XmNtopAttachment, XmATTACH_FORM,
103.4123 -                              NULL);
103.4124 -            } else {
103.4125 -                /* warning window present - conditional on #define NETSCAPE:
103.4126 -                   if NETSCAPE, warning window is at bottom, so canvas is
103.4127 -                   attached to the form (as above); otherwise (not NETSCAPE),
103.4128 -                   warning window itself is instead attached to form.   */
103.4129 -#ifdef NETSCAPE
103.4130 -                XtVaSetValues(innerCanvasW,
103.4131 -                              XmNtopAttachment, XmATTACH_FORM,
103.4132 -                              NULL);
103.4133 -#else  /* NETSCAPE */
103.4134 -                XtVaSetValues(wdata->warningWindow,
103.4135 -                              XmNtopAttachment, XmATTACH_FORM,
103.4136 -                              NULL);
103.4137 -#endif /* NETSCAPE */
103.4138 -            }
103.4139 -
103.4140 -            wdata->menuBarReset = True;
103.4141 -        }
103.4142 -        wdata->menuBar = NULL;
103.4143 -        awtJNI_setMbAndWwHeightAndOffsets(env, this, wdata);
103.4144 -        (*env)->DeleteLocalRef(env, target);
103.4145 -        AWT_FLUSH_UNLOCK();
103.4146 -#ifdef _pauly_debug
103.4147 -        fprintf(stdout,"    ...pSetMenuBar. Done.\n");
103.4148 -        fflush(stdout);
103.4149 -#endif /* _pauly_debug */
103.4150 -        return;
103.4151 -    }
103.4152 -
103.4153 -    mdata = (struct ComponentData *)
103.4154 -        JNU_GetLongFieldAsPtr(env, mb, mMenuBarPeerIDs.pData);
103.4155 -    if (mdata == NULL) {
103.4156 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4157 -        (*env)->DeleteLocalRef(env, target);
103.4158 -        AWT_UNLOCK();
103.4159 -        return;
103.4160 -    }
103.4161 -
103.4162 -    /* OK - insert the new menu bar into the form (at the top).
103.4163 -       Redo the attachments of other form widgets appropriately.*/
103.4164 -
103.4165 -    if  (wdata->menuBar == NULL)
103.4166 -        wdata->menuBarReset = True;
103.4167 -    wdata->menuBar = mdata->widget;
103.4168 -
103.4169 -#ifdef _pauly_debug
103.4170 -    XtVaGetValues(mdata->widget, XmNheight, &mbHeight, NULL);
103.4171 -    fprintf(stdout,"    ...pSetMenuBar. new menu bar (widget %x, parent: %x) - menu bar height: %d\n", wdata->menuBar, XtParent(wdata->menuBar), mbHeight);
103.4172 -    fflush(stdout);
103.4173 -#endif /* _pauly_debug */
103.4174 -
103.4175 -    XtVaSetValues(mdata->widget,
103.4176 -                  XmNtopAttachment, XmATTACH_FORM,
103.4177 -                  XmNleftAttachment, XmATTACH_FORM,
103.4178 -                  XmNrightAttachment, XmATTACH_FORM,
103.4179 -                  NULL);
103.4180 -
103.4181 -    innerCanvasW = XtParent(wdata->winData.comp.widget);
103.4182 -
103.4183 -    if  (wdata->warningWindow == NULL) {
103.4184 -        /* no warning window: menu bar at top, canvas attached to it    */
103.4185 -        XtVaSetValues(innerCanvasW,
103.4186 -                      XmNtopAttachment, XmATTACH_WIDGET,
103.4187 -                      XmNtopWidget, mdata->widget,
103.4188 -                      NULL);
103.4189 -    } else {
103.4190 -        /* warning window present - conditional on #define NETSCAPE:
103.4191 -           if NETSCAPE, warning window is at bottom, so canvas is
103.4192 -           attached to menu bar (as above); otherwise (not NETSCAPE),
103.4193 -           the warning window is attached just below the menu bar.  */
103.4194 -#ifdef NETSCAPE
103.4195 -        XtVaSetValues(innerCanvasW,
103.4196 -                      XmNtopAttachment, XmATTACH_WIDGET,
103.4197 -                      XmNtopWidget, mdata->widget,
103.4198 -                      NULL);
103.4199 -#else  /* NETSCAPE */
103.4200 -        XtVaSetValues(wdata->warningWindow,
103.4201 -                      XmNtopAttachment, XmATTACH_WIDGET,
103.4202 -                      XmNtopWidget, mdata->widget,
103.4203 -                      NULL);
103.4204 -#endif /* NETSCAPE */
103.4205 -    }
103.4206 -
103.4207 -    XtManageChild(mdata->widget);
103.4208 -    XtMapWidget(mdata->widget);
103.4209 -    XSync(awt_display, False);
103.4210 -    awtJNI_setMbAndWwHeightAndOffsets(env, this, wdata);
103.4211 -
103.4212 -#ifdef _pauly_debug
103.4213 -    XtVaGetValues(mdata->widget, XmNheight, &mbHeight, NULL);
103.4214 -    fprintf(stdout,"    ...pSetMenuBar. with menu bar: menu bar height: %d, top offset: %d, bottom offset: %d\n", mbHeight, wdata->top, wdata->bottom);
103.4215 -    fflush(stdout);
103.4216 -#endif /* _pauly_debug */
103.4217 -
103.4218 -    (*env)->DeleteLocalRef(env, target);
103.4219 -
103.4220 -    AWT_FLUSH_UNLOCK();
103.4221 -
103.4222 -#ifdef _pauly_debug
103.4223 -    fprintf(stdout,"    ...pSetMenuBar. Done\n");
103.4224 -    fflush(stdout);
103.4225 -#endif /* _pauly_debug */
103.4226 -}
103.4227 -
103.4228 -/*
103.4229 - * Class:     sun_awt_motif_MWindowPeer
103.4230 - * Method:    toBack
103.4231 - * Signature: ()V
103.4232 - */
103.4233 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_toBack
103.4234 -(JNIEnv *env, jobject this)
103.4235 -{
103.4236 -    struct FrameData *wdata;
103.4237 -
103.4238 -    AWT_LOCK();
103.4239 -
103.4240 -    wdata = (struct FrameData *)
103.4241 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4242 -
103.4243 -    if (wdata == NULL || wdata->winData.shell == NULL) {
103.4244 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4245 -        AWT_UNLOCK();
103.4246 -        return;
103.4247 -    }
103.4248 -    if (XtWindow(wdata->winData.shell) != 0) {
103.4249 -        XLowerWindow(awt_display, XtWindow(wdata->winData.shell));
103.4250 -    }
103.4251 -    AWT_FLUSH_UNLOCK();
103.4252 -}
103.4253 -
103.4254 -/*
103.4255 - * Class:     sun_awt_motif_MWindowPeer
103.4256 - * Method:    updateAlwaysOnTop
103.4257 - * Signature: ()V
103.4258 - */
103.4259 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_updateAlwaysOnTop
103.4260 -(JNIEnv *env, jobject this, jboolean isOnTop)
103.4261 -{
103.4262 -    struct FrameData *wdata;
103.4263 -    AWT_LOCK();
103.4264 -    wdata = (struct FrameData *)
103.4265 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4266 -    awt_wm_updateAlwaysOnTop(wdata, isOnTop);
103.4267 -    AWT_FLUSH_UNLOCK();
103.4268 -}
103.4269 -
103.4270 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_addTextComponentNative
103.4271 -(JNIEnv *env, jobject this, jobject tc)
103.4272 -{
103.4273 -    struct FrameData            *wdata;
103.4274 -    jobject                     target;
103.4275 -
103.4276 -    if (JNU_IsNull(env, this)) {
103.4277 -        return;
103.4278 -    }
103.4279 -
103.4280 -    AWT_LOCK();
103.4281 -
103.4282 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.4283 -    wdata = (struct FrameData *)
103.4284 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4285 -
103.4286 -    if (wdata == NULL ||
103.4287 -        wdata->winData.comp.widget==NULL ||
103.4288 -        wdata->winData.shell==NULL ||
103.4289 -        JNU_IsNull(env, target)) {
103.4290 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4291 -        AWT_UNLOCK();
103.4292 -        return;
103.4293 -    }
103.4294 -    if ( !wdata->hasTextComponentNative) {
103.4295 -        wdata->hasTextComponentNative = True;
103.4296 -        wdata->imHeight = awt_motif_getIMStatusHeight(wdata->winData.shell, tc);
103.4297 -        wdata->bottom += wdata->imHeight;
103.4298 -        awtJNI_ChangeInsets(env, this, wdata);
103.4299 -        reshape(env, this, wdata,
103.4300 -                (*env)->GetIntField(env, target, componentIDs.x),
103.4301 -                (*env)->GetIntField(env, target, componentIDs.y),
103.4302 -                (*env)->GetIntField(env, target, componentIDs.width),
103.4303 -                (*env)->GetIntField(env, target, componentIDs.height),
103.4304 -                True);
103.4305 -    }
103.4306 -    AWT_UNLOCK();
103.4307 -}
103.4308 -
103.4309 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_removeTextComponentNative
103.4310 -(JNIEnv *env, jobject this)
103.4311 -{
103.4312 -    struct FrameData            *wdata;
103.4313 -    jobject                     target;
103.4314 -
103.4315 -    if (JNU_IsNull(env, this)) {
103.4316 -        return;
103.4317 -    }
103.4318 -
103.4319 -    AWT_LOCK();
103.4320 -
103.4321 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.4322 -    wdata = (struct FrameData *)
103.4323 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4324 -
103.4325 -    if (wdata == NULL ||
103.4326 -        wdata->winData.comp.widget== NULL ||
103.4327 -        wdata->winData.shell== NULL ||
103.4328 -        JNU_IsNull(env, target)) {
103.4329 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4330 -        AWT_UNLOCK();
103.4331 -        return;
103.4332 -    }
103.4333 -    if (!wdata->hasTextComponentNative) {
103.4334 -        AWT_UNLOCK();
103.4335 -        return;
103.4336 -    }
103.4337 -
103.4338 -    wdata->bottom -= wdata->imHeight;
103.4339 -    awtJNI_ChangeInsets(env, this, wdata);
103.4340 -    wdata->imRemove = True;
103.4341 -    reshape(env, this, wdata,
103.4342 -            (*env)->GetIntField(env, target, componentIDs.x),
103.4343 -            (*env)->GetIntField(env, target, componentIDs.y),
103.4344 -            (*env)->GetIntField(env, target, componentIDs.width),
103.4345 -            (*env)->GetIntField(env, target, componentIDs.height),
103.4346 -            True);
103.4347 -
103.4348 -    wdata->hasTextComponentNative = False;
103.4349 -    wdata->imHeight = 0;
103.4350 -
103.4351 -    AWT_UNLOCK();
103.4352 -} /* ...removeTextComponentPeer() */
103.4353 -
103.4354 -static Atom java_protocol = None;
103.4355 -static Atom motif_wm_msgs = None;
103.4356 -
103.4357 -static void im_callback(Widget shell, XtPointer client_data, XtPointer call_data)
103.4358 -{
103.4359 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
103.4360 -    JNU_CallMethodByName(env, NULL,
103.4361 -                         (jobject)client_data,
103.4362 -                         "notifyIMMOptionChange",
103.4363 -                         "()V");
103.4364 -}
103.4365 -
103.4366 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_pSetIMMOption
103.4367 -(JNIEnv *env, jobject this, jstring option)
103.4368 -{
103.4369 -    char        *coption;
103.4370 -    char        *empty = "InputMethod";
103.4371 -    char        *menuItem;
103.4372 -    jobject     globalRef;
103.4373 -    struct FrameData *wdata;
103.4374 -
103.4375 -    AWT_LOCK();
103.4376 -
103.4377 -    wdata = (struct FrameData *)
103.4378 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4379 -    if (wdata == NULL || wdata->winData.shell == NULL) {
103.4380 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4381 -        AWT_UNLOCK();
103.4382 -        return;
103.4383 -    }
103.4384 -
103.4385 -    globalRef = (jobject)JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.jniGlobalRef);
103.4386 -    coption = (JNU_IsNull(env, option)) ? empty : (char *) JNU_GetStringPlatformChars(env, option, NULL);
103.4387 -    if (java_protocol == None || motif_wm_msgs == None) {
103.4388 -        java_protocol = XmInternAtom(awt_display, "_JAVA_IM_MSG", False);
103.4389 -        motif_wm_msgs = XmInternAtom(awt_display, "_MOTIF_WM_MESSAGES", False);
103.4390 -    }
103.4391 -    XmAddProtocols (wdata->winData.shell, motif_wm_msgs, &java_protocol, 1);
103.4392 -    XmAddProtocolCallback(wdata->winData.shell, motif_wm_msgs, java_protocol, im_callback, (XtPointer)globalRef);
103.4393 -
103.4394 -    if ((menuItem = awt_util_makeWMMenuItem(coption, java_protocol))) {
103.4395 -        XtVaSetValues(wdata->winData.shell,
103.4396 -                      XmNmwmMenu,
103.4397 -                      menuItem,
103.4398 -                      NULL);
103.4399 -        free(menuItem);
103.4400 -    }
103.4401 -    if (coption != empty)
103.4402 -        JNU_ReleaseStringPlatformChars(env, option, (const char *) coption);
103.4403 -    AWT_FLUSH_UNLOCK();
103.4404 -}
103.4405 -
103.4406 -
103.4407 -JNIEXPORT void JNICALL
103.4408 -Java_sun_awt_motif_MEmbeddedFramePeer_synthesizeFocusInOut(JNIEnv *env, jobject this,
103.4409 -                                                           jboolean b)
103.4410 -{
103.4411 -    EmbeddedFrame *ef;
103.4412 -    Boolean dummy;
103.4413 -
103.4414 -    AWT_LOCK();
103.4415 -    ef = theEmbeddedFrameList;
103.4416 -    while (ef != NULL) {
103.4417 -        if ((*env)->IsSameObject(env, ef->javaRef, this)) {
103.4418 -            XFocusChangeEvent xev;
103.4419 -            xev.display = awt_display;
103.4420 -            xev.serial = 0;
103.4421 -            xev.type = b ? FocusIn : FocusOut;
103.4422 -            xev.send_event = False;
103.4423 -            xev.window = XtWindow(ef->embeddedFrame);
103.4424 -            xev.mode = NotifyNormal;
103.4425 -            xev.detail = NotifyNonlinear;
103.4426 -            shellEH(ef->embeddedFrame, this, (XEvent*)&xev, &dummy);
103.4427 -            break;
103.4428 -        }
103.4429 -        ef = ef->next;
103.4430 -    }
103.4431 -    AWT_UNLOCK();
103.4432 -}
103.4433 -
103.4434 -JNIEXPORT void JNICALL
103.4435 -Java_sun_awt_motif_MEmbeddedFramePeer_traverseOut(JNIEnv *env, jobject this, jboolean direction)
103.4436 -{
103.4437 -    struct FrameData            *wdata;
103.4438 -
103.4439 -    if (JNU_IsNull(env, this)) {
103.4440 -        return;
103.4441 -    }
103.4442 -
103.4443 -    AWT_LOCK();
103.4444 -
103.4445 -    wdata = (struct FrameData *)
103.4446 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4447 -
103.4448 -    if (wdata == NULL ||
103.4449 -        wdata->winData.comp.widget== NULL ||
103.4450 -        wdata->winData.shell== NULL)
103.4451 -    {
103.4452 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4453 -        AWT_UNLOCK();
103.4454 -        return;
103.4455 -    }
103.4456 -    xembed_traverse_out(wdata, direction);
103.4457 -    AWT_UNLOCK();
103.4458 -}
103.4459 -
103.4460 -
103.4461 -JNIEXPORT void JNICALL
103.4462 -Java_sun_awt_motif_MEmbeddedFramePeer_NEFcreate(JNIEnv *env, jobject this,
103.4463 -                                                jobject parent, jlong handle)
103.4464 -{
103.4465 -#undef MAX_ARGC
103.4466 -#define MAX_ARGC 40
103.4467 -    Arg      args[MAX_ARGC];
103.4468 -    int32_t  argc;
103.4469 -    struct   FrameData *wdata;
103.4470 -    jobject  target;
103.4471 -    jstring  warningString;
103.4472 -    jboolean resizable;
103.4473 -    jobject  globalRef = awtJNI_CreateAndSetGlobalRef(env, this);
103.4474 -    Widget   innerCanvasW;  /* form's child, parent of the outer canvas
103.4475 -                               drawing area */
103.4476 -    AwtGraphicsConfigDataPtr adata;
103.4477 -    AwtGraphicsConfigDataPtr defConfig;
103.4478 -
103.4479 -    AWT_LOCK();
103.4480 -
103.4481 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.4482 -
103.4483 -    if (JNU_IsNull(env, target)) {
103.4484 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4485 -        AWT_UNLOCK();
103.4486 -        return;
103.4487 -    }
103.4488 -
103.4489 -    wdata = ZALLOC(FrameData);
103.4490 -    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.pData, wdata);
103.4491 -    if (wdata == NULL) {
103.4492 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
103.4493 -        AWT_UNLOCK();
103.4494 -        return;
103.4495 -    }
103.4496 -
103.4497 -    adata = getGraphicsConfigFromComponentPeer(env, this);
103.4498 -    defConfig = getDefaultConfig(adata->awt_visInfo.screen);
103.4499 -
103.4500 -    /* A variation on Netscape's hack for embedded frames: the client area
103.4501 -     * of the browser is a Java Frame for parenting purposes, but really a
103.4502 -     * Motif child window
103.4503 -     */
103.4504 -    wdata->winData.flags |= W_IS_EMBEDDED;
103.4505 -
103.4506 -    wdata->top = 0;
103.4507 -    wdata->left = 0;
103.4508 -    wdata->bottom = 0;
103.4509 -    wdata->right = 0;
103.4510 -    awtJNI_ChangeInsets(env, this, wdata);
103.4511 -
103.4512 -
103.4513 -    wdata->isModal = 0;
103.4514 -    wdata->isShowing = False;
103.4515 -    wdata->shellResized = False;
103.4516 -    wdata->canvasResized = False;
103.4517 -    wdata->menuBarReset = False;
103.4518 -
103.4519 -    resizable = (*env)->GetBooleanField(env, target, frameIDs.resizable);
103.4520 -
103.4521 -    wdata->winData.shell = (Widget)handle;
103.4522 -    awt_util_addEmbeddedFrame(wdata->winData.shell, globalRef);
103.4523 -
103.4524 -    install_xembed((Widget)handle, wdata);
103.4525 -
103.4526 -    setDeleteCallback(globalRef, wdata);
103.4527 -    /* Establish resizability.  For the case of not resizable, do not
103.4528 -       yet set a fixed size here; we must wait until in the routine
103.4529 -       sun_awt_motif_MWindowPeer_pReshape() after insets have been fixed.
103.4530 -       This is because correction of the insets may affect shell size.
103.4531 -       (See comments in shellEH() concerning correction of the insets.  */
103.4532 -    /*
103.4533 -     * Fix for BugTraq ID 4313607.
103.4534 -     * Initial resizability will be set later in MWindowPeer_setResizable()
103.4535 -     * called from init(). But the real changes will be made only if the new
103.4536 -     * and old resizability values are different at that point, so we
103.4537 -     * initialize isResizable with inverse value here to get the job done.
103.4538 -     */
103.4539 -    wdata->isResizable = !resizable;
103.4540 -    wdata->isFixedSizeSet = False;
103.4541 -#if 0
103.4542 -    if (resizable) {
103.4543 -        awt_wm_setShellResizable(wdata);
103.4544 -    }
103.4545 -#endif
103.4546 -
103.4547 -    XtAddEventHandler(wdata->winData.shell, StructureNotifyMask | FocusChangeMask,
103.4548 -                      FALSE, (XtEventHandler)shellEH, globalRef);
103.4549 -
103.4550 -
103.4551 -    argc = 0;
103.4552 -    XtSetArg(args[argc], XmNvisual, defConfig->awt_visInfo.visual); argc++;
103.4553 -    XtSetArg(args[argc], XmNcolormap, defConfig->awt_cmap); argc++;
103.4554 -    XtSetArg(args[argc], XmNdepth, defConfig->awt_depth); argc++;
103.4555 -    XtSetArg(args[argc], XmNmarginWidth, 0); argc++;
103.4556 -    XtSetArg(args[argc], XmNmarginHeight, 0); argc++;
103.4557 -    XtSetArg(args[argc], XmNhorizontalSpacing, 0); argc++;
103.4558 -    XtSetArg(args[argc], XmNverticalSpacing, 0); argc++;
103.4559 -    XtSetArg(args[argc], XmNscreen,
103.4560 -             ScreenOfDisplay(awt_display, defConfig->awt_visInfo.screen)); argc++;
103.4561 -
103.4562 -
103.4563 -    XtSetArg(args[argc], XmNresizePolicy, XmRESIZE_NONE); argc++;
103.4564 -
103.4565 -    DASSERT(!(argc > MAX_ARGC));
103.4566 -    wdata->mainWindow = XmCreateForm(wdata->winData.shell, "main", args, argc);
103.4567 -
103.4568 -    /* The widget returned by awt_canvas_create is a drawing area
103.4569 -       (i.e., canvas) which is the child of another drawing area
103.4570 -       parent widget.  The parent is the drawing area within the
103.4571 -       form just created.  The child is an drawing area layer over
103.4572 -       the entire frame window, including the form, any menu bar
103.4573 -       and warning windows present, and also window manager stuff.
103.4574 -       The top, bottom, left, and right fields in wdata maintain
103.4575 -       the respective offsets between these two drawing areas.  */
103.4576 -
103.4577 -    wdata->winData.comp.widget = awt_canvas_create((XtPointer)globalRef,
103.4578 -                                                   wdata->mainWindow,
103.4579 -                                                   "frame_",
103.4580 -                                                   -1,
103.4581 -                                                   -1,
103.4582 -                                                   True,
103.4583 -                                                   wdata,
103.4584 -                                                   defConfig);
103.4585 -
103.4586 -    XtAddCallback(wdata->winData.comp.widget,
103.4587 -                  XmNresizeCallback,
103.4588 -                  outerCanvasResizeCB,
103.4589 -                  globalRef);
103.4590 -
103.4591 -
103.4592 -    innerCanvasW = XtParent(wdata->winData.comp.widget);
103.4593 -    XtVaSetValues(innerCanvasW,
103.4594 -                  XmNleftAttachment, XmATTACH_FORM,
103.4595 -                  XmNrightAttachment, XmATTACH_FORM,
103.4596 -                  NULL);
103.4597 -
103.4598 -
103.4599 -    XtAddEventHandler(innerCanvasW, StructureNotifyMask, FALSE,
103.4600 -                      (XtEventHandler)innerCanvasEH, globalRef);
103.4601 -
103.4602 -    /* No menu bar initially */
103.4603 -    wdata->menuBar = NULL;
103.4604 -    wdata->mbHeight = 0;
103.4605 -
103.4606 -    /* If a warning window (string) is needed, establish it now.*/
103.4607 -    warningString =
103.4608 -        (*env)->GetObjectField(env, target, windowIDs.warningString);
103.4609 -
103.4610 -    /* No warning window present */
103.4611 -    XtVaSetValues(innerCanvasW,
103.4612 -                  XmNtopAttachment, XmATTACH_FORM,
103.4613 -                  XmNbottomAttachment, XmATTACH_FORM,
103.4614 -                  NULL);
103.4615 -    wdata->warningWindow = NULL;
103.4616 -    wdata->wwHeight = 0;
103.4617 -
103.4618 -
103.4619 -    awt_util_show(wdata->winData.comp.widget);
103.4620 -
103.4621 -    AWT_FLUSH_UNLOCK();
103.4622 -}  /* MEmbeddedFramePeer_NEFcreate() */
103.4623 -
103.4624 -
103.4625 -JNIEXPORT void JNICALL
103.4626 -Java_sun_awt_motif_MEmbeddedFramePeer_pShowImpl(JNIEnv *env, jobject this)
103.4627 -{
103.4628 -    struct FrameData *wdata;
103.4629 -
103.4630 -    AWT_LOCK();
103.4631 -
103.4632 -    wdata = (struct FrameData *)
103.4633 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4634 -    if (wdata == NULL ||
103.4635 -        wdata->winData.comp.widget == NULL ||
103.4636 -        wdata->winData.shell == NULL ||
103.4637 -        wdata->mainWindow == NULL) {
103.4638 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4639 -        AWT_UNLOCK();
103.4640 -        return;
103.4641 -    }
103.4642 -    XtVaSetValues(wdata->winData.comp.widget,
103.4643 -                  XmNx, -(wdata->left),
103.4644 -                  XmNy, -(wdata->top), NULL);
103.4645 -
103.4646 -    if (wdata->menuBar != 0) {
103.4647 -        awt_util_show(wdata->menuBar);
103.4648 -    }
103.4649 -
103.4650 -    XtManageChild(wdata->mainWindow);
103.4651 -    if (XtWindow(wdata->winData.shell) == None) {
103.4652 -        XtRealizeWidget(wdata->winData.shell);
103.4653 -    }
103.4654 -    XtManageChild(wdata->winData.comp.widget);
103.4655 -    XtSetMappedWhenManaged(wdata->winData.shell, True);
103.4656 -    XtPopup(wdata->winData.shell, XtGrabNone);
103.4657 -    wdata->isShowing = True;
103.4658 -
103.4659 -    AWT_FLUSH_UNLOCK();
103.4660 -}
103.4661 -
103.4662 -/*
103.4663 - * Create a local managed widget inside a given X window.
103.4664 - * We allocate a top-level shell and then reparent it into the
103.4665 - * given window id.
103.4666 - *
103.4667 - * This is used to take the X11 window ID that has been passed
103.4668 - * to us by our parent Navigator plugin and return a widget
103.4669 - * that can be used as the base for our Java EmbeddeFrame.
103.4670 - *
103.4671 - * Note that the ordering of the various calls is tricky here as
103.4672 - * we have to cope with the variations between 1.1.3, 1.1.6,
103.4673 - * and 1.2.
103.4674 - */
103.4675 -JNIEXPORT jlong JNICALL
103.4676 -Java_sun_awt_motif_MEmbeddedFrame_getWidget(
103.4677 -                JNIEnv *env, jclass clz, jlong winid)
103.4678 -{
103.4679 -    Arg args[40];
103.4680 -    int argc;
103.4681 -    Widget w;
103.4682 -    Window child, parent;
103.4683 -    Visual *visual;
103.4684 -    Colormap cmap;
103.4685 -    int depth;
103.4686 -    int ncolors;
103.4687 -
103.4688 -    /*
103.4689 -     * Create a top-level shell.  Note that we need to use the
103.4690 -     * AWT's own awt_display to initialize the widget.  If we
103.4691 -     * try to create a second X11 display connection the Java
103.4692 -     * runtimes get very confused.
103.4693 -     */
103.4694 -    AWT_LOCK();
103.4695 -
103.4696 -    argc = 0;
103.4697 -    XtSetArg(args[argc], XtNsaveUnder, False); argc++;
103.4698 -    XtSetArg(args[argc], XtNallowShellResize, False); argc++;
103.4699 -
103.4700 -    /* the awt initialization should be done by now (awt_GraphicsEnv.c) */
103.4701 -
103.4702 -    getAwtData(&depth,&cmap,&visual,&ncolors,NULL);
103.4703 -
103.4704 -    XtSetArg(args[argc], XtNvisual, visual); argc++;
103.4705 -    XtSetArg(args[argc], XtNdepth, depth); argc++;
103.4706 -    XtSetArg(args[argc], XtNcolormap, cmap); argc++;
103.4707 -
103.4708 -    XtSetArg(args[argc], XtNwidth, 1); argc++;
103.4709 -    XtSetArg(args[argc], XtNheight, 1); argc++;
103.4710 -    /* The shell has to have relative coords of O,0? */
103.4711 -    XtSetArg(args[argc], XtNx, 0); argc++;
103.4712 -    XtSetArg(args[argc], XtNy, 0); argc++;
103.4713 -
103.4714 -    /* The shell widget starts out as a top level widget.
103.4715 -     * Without intervention, it will be managed by the window
103.4716 -     * manager and will be its own widow. So, until it is reparented,
103.4717 -     *  we don't map it.
103.4718 -     */
103.4719 -    XtSetArg(args[argc], XtNmappedWhenManaged, False); argc++;
103.4720 -
103.4721 -    w = XtAppCreateShell("AWTapp","XApplication",
103.4722 -                                    vendorShellWidgetClass,
103.4723 -                                    awt_display,
103.4724 -                                    args,
103.4725 -                                    argc);
103.4726 -    XtRealizeWidget(w);
103.4727 -
103.4728 -    /*
103.4729 -     * Now reparent our new Widget into our Navigator window
103.4730 -     */
103.4731 -    parent = (Window) winid;
103.4732 -    child = XtWindow(w);
103.4733 -    XReparentWindow(awt_display, child, parent, 0, 0);
103.4734 -    XFlush(awt_display);
103.4735 -    XSync(awt_display, False);
103.4736 -    XtVaSetValues(w, XtNx, 0, XtNy, 0, NULL);
103.4737 -    XFlush(awt_display);
103.4738 -    XSync(awt_display, False);
103.4739 -
103.4740 -    AWT_UNLOCK();
103.4741 -
103.4742 -    return (jlong)w;
103.4743 -}
103.4744 -
103.4745 -/*
103.4746 - * Make sure the given widget is mapped.
103.4747 - *
103.4748 - * This isn't necessary on JDK 1.1.5 but is needed on JDK 1.1.4
103.4749 - */
103.4750 -JNIEXPORT jint JNICALL
103.4751 -Java_sun_awt_motif_MEmbeddedFrame_mapWidget(JNIEnv *env, jclass clz, jlong widget)
103.4752 -{
103.4753 -    Widget w = (Widget)widget;
103.4754 -    /*
103.4755 -     * this is what JDK 1.1.5 does in MFramePeer.pShow.
103.4756 -     */
103.4757 -    AWT_LOCK();
103.4758 -    XtSetMappedWhenManaged(w, True);
103.4759 -    XtPopup(w, XtGrabNone);
103.4760 -    AWT_UNLOCK();
103.4761 -    return (jint) 1;
103.4762 -}
103.4763 -
103.4764 -
103.4765 -JNIEXPORT jboolean JNICALL
103.4766 -Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedActive(JNIEnv *env, jobject this)
103.4767 -{
103.4768 -    struct FrameData *wdata;
103.4769 -    Boolean res;
103.4770 -
103.4771 -    AWT_LOCK();
103.4772 -
103.4773 -    wdata = (struct FrameData *)
103.4774 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4775 -    if (wdata == NULL ||
103.4776 -        wdata->winData.comp.widget == NULL ||
103.4777 -        wdata->winData.shell == NULL ||
103.4778 -        wdata->mainWindow == NULL) {
103.4779 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4780 -        AWT_UNLOCK();
103.4781 -        return False;
103.4782 -    }
103.4783 -
103.4784 -    res = isXEmbedActive(wdata);
103.4785 -    AWT_UNLOCK();
103.4786 -    return res;
103.4787 -
103.4788 -}
103.4789 -
103.4790 -JNIEXPORT jboolean JNICALL
103.4791 -Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedApplicationActive(JNIEnv *env, jobject this)
103.4792 -{
103.4793 -    struct FrameData *wdata;
103.4794 -    Boolean res;
103.4795 -
103.4796 -    AWT_LOCK();
103.4797 -
103.4798 -    wdata = (struct FrameData *)
103.4799 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4800 -    if (wdata == NULL ||
103.4801 -        wdata->winData.comp.widget == NULL ||
103.4802 -        wdata->winData.shell == NULL ||
103.4803 -        wdata->mainWindow == NULL) {
103.4804 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4805 -        AWT_UNLOCK();
103.4806 -        return False;
103.4807 -    }
103.4808 -
103.4809 -    res = isXEmbedApplicationActive(wdata);
103.4810 -    AWT_UNLOCK();
103.4811 -    return res;
103.4812 -
103.4813 -}
103.4814 -
103.4815 -JNIEXPORT void JNICALL
103.4816 -Java_sun_awt_motif_MEmbeddedFramePeer_requestXEmbedFocus(JNIEnv *env, jobject this)
103.4817 -{
103.4818 -    struct FrameData *wdata;
103.4819 -
103.4820 -    AWT_LOCK();
103.4821 -
103.4822 -    wdata = (struct FrameData *)
103.4823 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4824 -    if (wdata == NULL ||
103.4825 -        wdata->winData.comp.widget == NULL ||
103.4826 -        wdata->winData.shell == NULL ||
103.4827 -        wdata->mainWindow == NULL) {
103.4828 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4829 -        AWT_UNLOCK();
103.4830 -        return;
103.4831 -    }
103.4832 -
103.4833 -    requestXEmbedFocus(wdata);
103.4834 -    AWT_UNLOCK();
103.4835 -}
103.4836 -
103.4837 -/*
103.4838 - * Class:     sun_awt_motif_MWindowPeer
103.4839 - * Method:    setSaveUnder
103.4840 - * Signature: (Z)V
103.4841 - */
103.4842 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_setSaveUnder
103.4843 -(JNIEnv *env, jobject this, jboolean state)
103.4844 -{
103.4845 -    struct FrameData    *wdata;
103.4846 -    jobject             target;
103.4847 -
103.4848 -    AWT_LOCK();
103.4849 -
103.4850 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.4851 -
103.4852 -    wdata = (struct FrameData *)
103.4853 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4854 -
103.4855 -    if (wdata == NULL ||
103.4856 -        wdata->winData.comp.widget == NULL ||
103.4857 -        wdata->winData.shell == NULL ||
103.4858 -        JNU_IsNull(env, target)) {
103.4859 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4860 -        if  (!JNU_IsNull(env, target))
103.4861 -            (*env)->DeleteLocalRef(env, target);
103.4862 -        AWT_UNLOCK();
103.4863 -        return;
103.4864 -    }
103.4865 -
103.4866 -    XtVaSetValues(wdata->winData.shell, XmNsaveUnder, state, NULL);
103.4867 -
103.4868 -    AWT_FLUSH_UNLOCK();
103.4869 -}
103.4870 -
103.4871 -
103.4872 -/*
103.4873 - * Class:     sun_awt_motif_MWindowPeer
103.4874 - * Method:    setFocusableWindow
103.4875 - * Signature: (Z)V
103.4876 - */
103.4877 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_setFocusableWindow
103.4878 -(JNIEnv *env, jobject this, jboolean isFocusableWindow)
103.4879 -{
103.4880 -    struct FrameData    *wdata;
103.4881 -    jobject             target;
103.4882 -
103.4883 -    AWT_LOCK();
103.4884 -
103.4885 -    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
103.4886 -
103.4887 -    wdata = (struct FrameData *)
103.4888 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
103.4889 -
103.4890 -    if (wdata == NULL ||
103.4891 -        wdata->winData.comp.widget == NULL ||
103.4892 -        wdata->winData.shell == NULL ||
103.4893 -        JNU_IsNull(env, target)) {
103.4894 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4895 -        if  (!JNU_IsNull(env, target))
103.4896 -            (*env)->DeleteLocalRef(env, target);
103.4897 -        AWT_UNLOCK();
103.4898 -        return;
103.4899 -    }
103.4900 -
103.4901 -    wdata->isFocusableWindow = isFocusableWindow;
103.4902 -
103.4903 -    AWT_FLUSH_UNLOCK();
103.4904 -}
103.4905 -
103.4906 -/*
103.4907 - * Class:     sun_awt_motif_MWindowPeer
103.4908 - * Method:    resetTargetGC
103.4909 - * Signature: ()V
103.4910 - */
103.4911 -JNIEXPORT void JNICALL Java_sun_awt_motif_MWindowPeer_resetTargetGC
103.4912 -  (JNIEnv * env, jobject this, jobject target)
103.4913 -{
103.4914 -    (*env)->CallVoidMethod(env, target, windowIDs.resetGCMID);
103.4915 -}
103.4916 -
103.4917 -
103.4918 -/*
103.4919 - * Old, compatibility, backdoor for DT.  This is a different
103.4920 - * implementation.  It keeps the signature, but acts on
103.4921 - * awt_root_shell, not the frame passed as an argument.  Note, that
103.4922 - * the code that uses the old backdoor doesn't work correctly with
103.4923 - * gnome session proxy that checks for WM_COMMAND when the window is
103.4924 - * firts mapped, because DT code calls this old backdoor *after* the
103.4925 - * frame is shown or it would get NPE with old AWT (previous
103.4926 - * implementation of this backdoor) otherwise.  Old style session
103.4927 - * managers (e.g. CDE) that check WM_COMMAND only during session
103.4928 - * checkpoint should work fine, though.
103.4929 - *
103.4930 - * NB: The function name looks deceptively like a JNI native method
103.4931 - * name.  It's not!  It's just a plain function.
103.4932 - */
103.4933 -JNIEXPORT void JNICALL
103.4934 -Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
103.4935 -    jobject frame, jstring jcommand)
103.4936 -{
103.4937 -    const char *command;
103.4938 -    XTextProperty text_prop;
103.4939 -    char *c[1];
103.4940 -    int32_t status;
103.4941 -
103.4942 -    AWT_LOCK();
103.4943 -
103.4944 -    if (awt_root_shell == NULL) {
103.4945 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4946 -        AWT_UNLOCK();
103.4947 -        return;
103.4948 -    }
103.4949 -
103.4950 -    if (XtWindow(awt_root_shell) == None) {
103.4951 -        JNU_ThrowNullPointerException(env, "NullPointerException");
103.4952 -        AWT_UNLOCK();
103.4953 -        return;
103.4954 -    }
103.4955 -
103.4956 -    /* need to convert ctitle to CompoundText */
103.4957 -    command = (char *) JNU_GetStringPlatformChars(env, jcommand, NULL);
103.4958 -    c[0] = (char *)command;
103.4959 -    status = XmbTextListToTextProperty(awt_display, c, 1,
103.4960 -                                       XStdICCTextStyle, &text_prop);
103.4961 -
103.4962 -    if (status == Success || status > 0) {
103.4963 -        XSetTextProperty(awt_display, XtWindow(awt_root_shell),
103.4964 -                         &text_prop, XA_WM_COMMAND);
103.4965 -        if (text_prop.value != NULL)
103.4966 -            XFree(text_prop.value);
103.4967 -    }
103.4968 -
103.4969 -    JNU_ReleaseStringPlatformChars(env, jcommand, command);
103.4970 -
103.4971 -    AWT_UNLOCK();
103.4972 -    return;
103.4973 -}
103.4974 -
103.4975 -
103.4976 -/*
103.4977 - * New DT backdoor to set WM_COMMAND.  New code should use this
103.4978 - * backdoor and call it *before* the first frame is shown so that
103.4979 - * gnome session proxy can correctly handle it.
103.4980 - *
103.4981 - * NB: The function name looks deceptively like a JNI native method
103.4982 - * name.  It's not!  It's just a plain function.
103.4983 - */
103.4984 -JNIEXPORT void JNICALL
103.4985 -Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
103.4986 -{
103.4987 -    static const char empty[] = "";
103.4988 -
103.4989 -    int argc;
103.4990 -    const char **cargv;
103.4991 -    XTextProperty text_prop;
103.4992 -    int status;
103.4993 -    int i;
103.4994 -
103.4995 -    AWT_LOCK();
103.4996 -
103.4997 -    if (awt_root_shell == NULL) {
103.4998 -        JNU_ThrowNullPointerException(env, "AWT root shell");
103.4999 -        AWT_UNLOCK();
103.5000 -        return;
103.5001 -    }
103.5002 -
103.5003 -    if (XtWindow(awt_root_shell) == None) {
103.5004 -        JNU_ThrowNullPointerException(env, "AWT root shell is unrealized");
103.5005 -        AWT_UNLOCK();
103.5006 -        return;
103.5007 -    }
103.5008 -
103.5009 -    argc = (int)(*env)->GetArrayLength(env, jargv);
103.5010 -    if (argc == 0) {
103.5011 -        /* nothing to do */
103.5012 -        AWT_UNLOCK();
103.5013 -        return;
103.5014 -    }
103.5015 -
103.5016 -    /* array of C strings */
103.5017 -    cargv = (const char **)calloc(argc, sizeof(char *));
103.5018 -    if (cargv == NULL) {
103.5019 -        JNU_ThrowOutOfMemoryError(env, "Unable to allocate cargv");
103.5020 -        AWT_UNLOCK();
103.5021 -        return;
103.5022 -    }
103.5023 -
103.5024 -    /* fill C array with platform chars of java strings */
103.5025 -    for (i = 0; i < argc; ++i) {
103.5026 -        jstring js;
103.5027 -        const char *cs;
103.5028 -
103.5029 -        cs = NULL;
103.5030 -        js = (*env)->GetObjectArrayElement(env, jargv, i);
103.5031 -        if (js != NULL) {
103.5032 -            cs = JNU_GetStringPlatformChars(env, js, NULL);
103.5033 -        }
103.5034 -        if (cs == NULL) {
103.5035 -            cs = empty;
103.5036 -        }
103.5037 -
103.5038 -        cargv[i] = cs;
103.5039 -        (*env)->DeleteLocalRef(env, js);
103.5040 -    }
103.5041 -
103.5042 -    /* grr, X prototype doesn't declare cargv as const, thought it really is */
103.5043 -    status = XmbTextListToTextProperty(awt_display, (char **)cargv, argc,
103.5044 -                                       XStdICCTextStyle, &text_prop);
103.5045 -    if (status < 0) {
103.5046 -        switch (status) {
103.5047 -        case XNoMemory:
103.5048 -            JNU_ThrowOutOfMemoryError(env,
103.5049 -                "XmbTextListToTextProperty: XNoMemory");
103.5050 -            break;
103.5051 -        case XLocaleNotSupported:
103.5052 -            JNU_ThrowInternalError(env,
103.5053 -                "XmbTextListToTextProperty: XLocaleNotSupported");
103.5054 -            break;
103.5055 -        case XConverterNotFound:
103.5056 -            JNU_ThrowNullPointerException(env,
103.5057 -                "XmbTextListToTextProperty: XConverterNotFound");
103.5058 -            break;
103.5059 -        default:
103.5060 -            JNU_ThrowInternalError(env,
103.5061 -                "XmbTextListToTextProperty: unknown error");
103.5062 -        }
103.5063 -    } else {
103.5064 -        /*
103.5065 -         * status == Success (i.e. 0) or
103.5066 -         * status > 0 - a number of unconvertible characters
103.5067 -         *              (cannot happen for XStdICCTextStyle).
103.5068 -         */
103.5069 -        XSetTextProperty(awt_display, XtWindow(awt_root_shell),
103.5070 -                         &text_prop, XA_WM_COMMAND);
103.5071 -    }
103.5072 -
103.5073 -    /* release platform chars */
103.5074 -    for (i = 0; i < argc; ++i) {
103.5075 -        jstring js;
103.5076 -
103.5077 -        if (cargv[i] == empty)
103.5078 -            continue;
103.5079 -
103.5080 -        js = (*env)->GetObjectArrayElement(env, jargv, i);
103.5081 -        JNU_ReleaseStringPlatformChars(env, js, cargv[i]);
103.5082 -        (*env)->DeleteLocalRef(env, js);
103.5083 -    }
103.5084 -    if (text_prop.value != NULL)
103.5085 -      XFree(text_prop.value);
103.5086 -
103.5087 -    AWT_UNLOCK();
103.5088 -    return;
103.5089 -}
103.5090 -
103.5091 -/*
103.5092 - * Class:     java_awt_TrayIcon
103.5093 - * Method:    initIDs
103.5094 - * Signature: ()V
103.5095 - */
103.5096 -JNIEXPORT void JNICALL Java_java_awt_TrayIcon_initIDs(JNIEnv *env , jclass clazz)
103.5097 -{
103.5098 -}
   104.1 --- a/src/solaris/native/sun/awt/awt_XmDnD.c	Wed Sep 17 13:45:37 2008 -0700
   104.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   104.3 @@ -1,2282 +0,0 @@
   104.4 -/*
   104.5 - * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
   104.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   104.7 - *
   104.8 - * This code is free software; you can redistribute it and/or modify it
   104.9 - * under the terms of the GNU General Public License version 2 only, as
  104.10 - * published by the Free Software Foundation.  Sun designates this
  104.11 - * particular file as subject to the "Classpath" exception as provided
  104.12 - * by Sun in the LICENSE file that accompanied this code.
  104.13 - *
  104.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  104.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  104.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  104.17 - * version 2 for more details (a copy is included in the LICENSE file that
  104.18 - * accompanied this code).
  104.19 - *
  104.20 - * You should have received a copy of the GNU General Public License version
  104.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  104.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  104.23 - *
  104.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  104.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  104.26 - * have any questions.
  104.27 - */
  104.28 -
  104.29 -#ifdef HEADLESS
  104.30 -    #error This file should not be included in headless library
  104.31 -#endif
  104.32 -
  104.33 -#include <stdio.h>
  104.34 -#include <string.h>
  104.35 -
  104.36 -#include "jvm.h"
  104.37 -#include "jni.h"
  104.38 -#include "jni_util.h"
  104.39 -#include "jlong.h"
  104.40 -
  104.41 -#include "awt_DataTransferer.h"
  104.42 -#include "awt_XmDnD.h"
  104.43 -
  104.44 -#include "awt_p.h"
  104.45 -
  104.46 -#include "java_awt_Cursor.h"
  104.47 -#include "java_awt_dnd_DnDConstants.h"
  104.48 -#include "java_awt_event_MouseEvent.h"
  104.49 -#include "sun_awt_dnd_SunDragSourceContextPeer.h"
  104.50 -#include "sun_awt_motif_MComponentPeer.h"
  104.51 -#include "sun_awt_motif_MDragSourceContextPeer.h"
  104.52 -#include "sun_awt_motif_MDropTargetContextPeer.h"
  104.53 -
  104.54 -#include <X11/cursorfont.h>
  104.55 -#include <X11/Xutil.h>
  104.56 -/*
  104.57 - * Fix for 4285634.
  104.58 - * Include the private Motif header to enable access to lastEventState.
  104.59 - */
  104.60 -#include <Xm/DragCP.h>
  104.61 -
  104.62 -#include "awt_Component.h"
  104.63 -#include "awt_Cursor.h"
  104.64 -#include "awt_AWTEvent.h"
  104.65 -
  104.66 -extern struct MComponentPeerIDs mComponentPeerIDs;
  104.67 -extern struct CursorIDs cursorIDs;
  104.68 -extern struct ContainerIDs containerIDs;
  104.69 -
  104.70 -/* globals */
  104.71 -
  104.72 -
  104.73 -/* forwards */
  104.74 -
  104.75 -static void awt_XmDropProc(Widget, XtPointer, XmDropProcCallbackStruct*);
  104.76 -static void awt_XmDragProc(Widget, XtPointer, XmDragProcCallbackStruct*);
  104.77 -
  104.78 -static void awt_XmTransferProc(Widget, XtPointer, Atom*, Atom*, XtPointer,
  104.79 -                               unsigned long*, int32_t*);
  104.80 -
  104.81 -/* for XmDragContext callbacks etc ... */
  104.82 -static void awt_XmDragEnterProc(Widget, XtPointer,
  104.83 -                                XmDropSiteEnterCallbackStruct*);
  104.84 -static void awt_XmDragMotionProc(Widget, XtPointer,
  104.85 -                                 XmDragMotionCallbackStruct*);
  104.86 -static void awt_XmDragLeaveProc(Widget, XtPointer,
  104.87 -                                XmDropSiteLeaveCallbackStruct*);
  104.88 -static void awt_XmDropOperationChangedProc(Widget, XtPointer,
  104.89 -                                           XmDropStartCallbackStruct*);
  104.90 -static void awt_XmDropFinishProc(Widget, XtPointer,
  104.91 -                                 XmDropFinishCallbackStruct*);
  104.92 -
  104.93 -static unsigned char DnDConstantsToXm(jint operations);
  104.94 -static jint XmToDnDConstants(unsigned char operations);
  104.95 -static unsigned char selectOperation(unsigned char operations);
  104.96 -
  104.97 -static void flush_cache(JNIEnv* env);
  104.98 -static void    cacheDropDone(Boolean dropDone);
  104.99 -static Boolean isDropDone();
 104.100 -
 104.101 -static void setCursor(JNIEnv* env, Display* d, jobject c, jint type, Time t);
 104.102 -
 104.103 -static Atom MOTIF_DROP_ATOM = None;
 104.104 -
 104.105 -/* in canvas.c */
 104.106 -extern jint getModifiers(uint32_t state, jint button, jint keyCode);
 104.107 -
 104.108 -/**
 104.109 - * static cache of DropTarget related info.
 104.110 - */
 104.111 -
 104.112 -static struct {
 104.113 -    Widget        w;                /* if NULL, cache invalid */
 104.114 -
 104.115 -    jobject       peer;
 104.116 -    jobject       component;
 104.117 -
 104.118 -    jobject       dtcpeer;
 104.119 -
 104.120 -    Widget        dt;
 104.121 -
 104.122 -    jlongArray    targets;
 104.123 -    Cardinal      nTargets;
 104.124 -
 104.125 -    Boolean       dropDone;
 104.126 -    int32_t       transfersPending;
 104.127 -    Widget        transfer;
 104.128 -
 104.129 -    jint          dropAction;       /* used only on JVM transfers */
 104.130 -
 104.131 -    Boolean       flushPending;
 104.132 -
 104.133 -    Window win;
 104.134 -    uint32_t state;
 104.135 -} _cache;
 104.136 -
 104.137 -uint32_t
 104.138 -buttonToMask(uint32_t button) {
 104.139 -    switch (button) {
 104.140 -        case Button1:
 104.141 -            return Button1Mask;
 104.142 -        case Button2:
 104.143 -            return Button2Mask;
 104.144 -        case Button3:
 104.145 -            return Button3Mask;
 104.146 -        case Button4:
 104.147 -            return Button4Mask;
 104.148 -        case Button5:
 104.149 -            return Button5Mask;
 104.150 -        default:
 104.151 -            return 0;
 104.152 -    }
 104.153 -}
 104.154 -
 104.155 -/* Fix for 4215643: extract the values cached on drag start and send
 104.156 -   ButtonRelease event to the window which originated the drag */
 104.157 -
 104.158 -void
 104.159 -dragsource_track_release(Widget w, XtPointer client_data,
 104.160 -                         XEvent * event, Boolean * cont)
 104.161 -{
 104.162 -    DASSERT (event != NULL);
 104.163 -
 104.164 -    if (_cache.win != None &&
 104.165 -        (buttonToMask(event->xbutton.button) & _cache.state)) {
 104.166 -
 104.167 -        JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
 104.168 -        Window win = event->xbutton.window;
 104.169 -        event->xbutton.window = _cache.win;
 104.170 -        awt_put_back_event(env, event);
 104.171 -        event->xbutton.window = win;
 104.172 -        _cache.win = None;
 104.173 -        _cache.state = 0;
 104.174 -        XtRemoveEventHandler(w, ButtonReleaseMask, False,
 104.175 -                             dragsource_track_release, NULL);
 104.176 -    }
 104.177 -}
 104.178 -
 104.179 -static void
 104.180 -cancel_drag(XtPointer client_data, XtIntervalId* id) {
 104.181 -    Time time = awt_util_getCurrentServerTime();
 104.182 -    Widget dc = XmGetDragContext(awt_root_shell, time);
 104.183 -
 104.184 -    if (dc != NULL) {
 104.185 -        Boolean sourceIsExternal = True;
 104.186 -        XtVaGetValues(dc, XmNsourceIsExternal, &sourceIsExternal, NULL);
 104.187 -        if (!sourceIsExternal) {
 104.188 -            XEvent xevent;
 104.189 -            XmDragCancel(dc);
 104.190 -
 104.191 -            /*
 104.192 -             * When running the internal drag-and-drop event loop
 104.193 -             * (see DragC.c:InitiatorMainLoop) Motif DnD uses XtAppNextEvent,
 104.194 -             * that processes all timer callbacks and then returns the next X
 104.195 -             * event from the queue. Motif DnD doesn't check if the drag
 104.196 -             * operation is cancelled after XtAppNextEvent returns and processes
 104.197 -             * the returned event. When the drag operation is cancelled the
 104.198 -             * XmDragContext widget is destroyed and Motif will crash if the new
 104.199 -             * event is dispatched to the destroyed XmDragContext.
 104.200 -             * We cancel the drag operation in the timer callback, so we putback
 104.201 -             * a dummy X event. This event will be returned from XtAppNextEvent
 104.202 -             * and Motif DnD will safely exit from the internal event loop.
 104.203 -             */
 104.204 -            xevent.type = LASTEvent;
 104.205 -            xevent.xany.send_event = True;
 104.206 -            xevent.xany.display = awt_display;
 104.207 -            xevent.xany.window = XtWindow(awt_root_shell);
 104.208 -            XPutBackEvent(awt_display, &xevent);
 104.209 -        }
 104.210 -    }
 104.211 -}
 104.212 -
 104.213 -#define DONT_CARE -1
 104.214 -
 104.215 -static void
 104.216 -awt_popupCallback(Widget shell, XtPointer closure, XtPointer call_data) {
 104.217 -    XtGrabKind grab_kind = XtGrabNone;
 104.218 -
 104.219 -    if (call_data != NULL) {
 104.220 -        grab_kind = *((XtGrabKind*)call_data);
 104.221 -    }
 104.222 -
 104.223 -    if (XmIsVendorShell(shell)) {
 104.224 -        int input_mode;
 104.225 -        XtVaGetValues(shell, XmNmwmInputMode, &input_mode, NULL);
 104.226 -        switch (input_mode) {
 104.227 -        case DONT_CARE:
 104.228 -        case MWM_INPUT_MODELESS:
 104.229 -            grab_kind = XtGrabNonexclusive; break;
 104.230 -        case MWM_INPUT_PRIMARY_APPLICATION_MODAL:
 104.231 -        case MWM_INPUT_SYSTEM_MODAL:
 104.232 -        case MWM_INPUT_FULL_APPLICATION_MODAL:
 104.233 -            grab_kind = XtGrabExclusive; break;
 104.234 -        }
 104.235 -    }
 104.236 -
 104.237 -    if (grab_kind == XtGrabExclusive) {
 104.238 -        /*
 104.239 -         * We should cancel the drag on the toolkit thread. Otherwise, it can be
 104.240 -         * called while the toolkit thread is waiting inside some drag callback.
 104.241 -         * In this case Motif will crash when the drag callback returns.
 104.242 -         */
 104.243 -        XtAppAddTimeOut(awt_appContext, 0L, cancel_drag, NULL);
 104.244 -    }
 104.245 -}
 104.246 -
 104.247 -static XtInitProc xt_shell_initialize = NULL;
 104.248 -
 104.249 -static void
 104.250 -awt_ShellInitialize(Widget req, Widget new, ArgList args, Cardinal *num_args) {
 104.251 -    XtAddCallback(new, XtNpopupCallback, awt_popupCallback, NULL);
 104.252 -    (*xt_shell_initialize)(req, new, args, num_args);
 104.253 -}
 104.254 -
 104.255 -/*
 104.256 - * Fix for 4484572.
 104.257 - * Modify the 'initialize' routine for all ShellWidget instances, so that it
 104.258 - * will install an XtNpopupCallback that cancels the current drag operation.
 104.259 - * It is needed, since AWT doesn't have full control over all ShellWidget
 104.260 - * instances (e.g. XmPopupMenu internally creates and popups an XmMenuShell).
 104.261 - */
 104.262 -static void
 104.263 -awt_set_ShellInitialize() {
 104.264 -    static Boolean inited = False;
 104.265 -
 104.266 -    DASSERT(!inited);
 104.267 -    if (inited) {
 104.268 -        return;
 104.269 -    }
 104.270 -
 104.271 -    xt_shell_initialize = shellWidgetClass->core_class.initialize;
 104.272 -    shellWidgetClass->core_class.initialize = (XtInitProc)awt_ShellInitialize;
 104.273 -    inited = True;
 104.274 -}
 104.275 -
 104.276 -/**
 104.277 - * global function to initialize this client as a Dynamic-only app.
 104.278 - *
 104.279 - * gets called once during toolkit initialization.
 104.280 - */
 104.281 -
 104.282 -void awt_initialize_Xm_DnD(Display* dpy) {
 104.283 -    JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 104.284 -    jclass  clazz;
 104.285 -
 104.286 -    XtVaSetValues(XmGetXmDisplay(dpy),
 104.287 -                  XmNdragInitiatorProtocolStyle, XmDRAG_DYNAMIC,
 104.288 -                  XmNdragReceiverProtocolStyle,  XmDRAG_DYNAMIC,
 104.289 -                  NULL
 104.290 -                  );
 104.291 -
 104.292 -    MOTIF_DROP_ATOM = XInternAtom(dpy, _XA_MOTIF_DROP, False);
 104.293 -    if (XSaveContext(dpy, MOTIF_DROP_ATOM, awt_convertDataContext,
 104.294 -                     (XPointer)NULL) == XCNOMEM) {
 104.295 -        JNU_ThrowInternalError(env, "");
 104.296 -        return;
 104.297 -    }
 104.298 -
 104.299 -    /* No drop in progress. */
 104.300 -    cacheDropDone(True);
 104.301 -
 104.302 -    /*
 104.303 -     * Fix for BugTraq ID 4407057.
 104.304 -     * Have to disable Motif default drag support, since it doesn't work
 104.305 -     * reliably with our event dispatch mechanism. To do this we allow a drag
 104.306 -     * operation only if it is registered on the awt_root_shell.
 104.307 -     */
 104.308 -    awt_motif_enableSingleDragInitiator(awt_root_shell);
 104.309 -
 104.310 -    awt_set_ShellInitialize();
 104.311 -
 104.312 -    /*
 104.313 -     * load the Cursor stuff
 104.314 -     */
 104.315 -
 104.316 -    clazz = (*env)->FindClass(env, "sun/awt/motif/MCustomCursor");
 104.317 -
 104.318 -    if (!JNU_IsNull(env, ((*env)->ExceptionOccurred(env)))) {
 104.319 -        (*env)->ExceptionDescribe(env);
 104.320 -        (*env)->ExceptionClear(env);
 104.321 -    }
 104.322 -}
 104.323 -
 104.324 -typedef struct DSInfoRec {
 104.325 -    Widget         widget;
 104.326 -
 104.327 -    Pixmap         animation_mask;
 104.328 -    Pixmap         animation_pixmap;
 104.329 -    int32_t        animation_pixmap_depth;
 104.330 -    unsigned char  animation_style;
 104.331 -    XtPointer      client_data;
 104.332 -    XtCallbackProc drag_proc;
 104.333 -    XtCallbackProc drop_proc;
 104.334 -    XRectangle     *drop_rectangles;
 104.335 -    unsigned char  drop_site_activity;
 104.336 -    unsigned char  drop_site_operations;
 104.337 -    unsigned char  drop_site_type;
 104.338 -    Atom           *import_targets;
 104.339 -    Cardinal       num_drop_rectangles;
 104.340 -    Cardinal       num_import_targets;
 104.341 -
 104.342 -    struct DSInfoRec* next;
 104.343 -} DSInfoRec, * DSInfoPtr;
 104.344 -
 104.345 -#define ARG_COUNT 14
 104.346 -
 104.347 -/*
 104.348 - * Allocates DSInfoRect structure, retrieves all attributes of a Motif drop site
 104.349 - * registered on the specified widget and puts them into the allocated storage.
 104.350 - * The caller should free the storage after use.
 104.351 - */
 104.352 -DSInfoPtr get_drop_site_info(Widget w) {
 104.353 -    Arg       arglist[ARG_COUNT];
 104.354 -    Cardinal  argcount = 0;
 104.355 -    DSInfoPtr info = ZALLOC(DSInfoRec);
 104.356 -
 104.357 -    if (info == NULL) {
 104.358 -        JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 104.359 -        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
 104.360 -        return NULL;
 104.361 -    }
 104.362 -
 104.363 -    XtSetArg(arglist[argcount], XmNanimationMask,
 104.364 -             (XtArgVal)&info->animation_mask); argcount++;
 104.365 -    XtSetArg(arglist[argcount], XmNanimationPixmap,
 104.366 -             (XtArgVal)&info->animation_pixmap); argcount++;
 104.367 -    XtSetArg(arglist[argcount], XmNanimationPixmapDepth,
 104.368 -             (XtArgVal)&info->animation_pixmap_depth); argcount++;
 104.369 -    XtSetArg(arglist[argcount], XmNanimationStyle,
 104.370 -             (XtArgVal)&info->animation_style); argcount++;
 104.371 -    XtSetArg(arglist[argcount], XmNclientData,
 104.372 -             (XtArgVal)&info->client_data); argcount++;
 104.373 -    XtSetArg(arglist[argcount], XmNdragProc,
 104.374 -             (XtArgVal)&info->drag_proc); argcount++;
 104.375 -    XtSetArg(arglist[argcount], XmNdropProc,
 104.376 -             (XtArgVal)&info->drop_proc); argcount++;
 104.377 -    XtSetArg(arglist[argcount], XmNdropSiteActivity,
 104.378 -             (XtArgVal)&info->drop_site_activity); argcount++;
 104.379 -    XtSetArg(arglist[argcount], XmNdropSiteOperations,
 104.380 -             (XtArgVal)&info->drop_site_operations); argcount++;
 104.381 -    XtSetArg(arglist[argcount], XmNdropSiteType,
 104.382 -             (XtArgVal)&info->drop_site_type); argcount++;
 104.383 -    XtSetArg(arglist[argcount], XmNnumDropRectangles,
 104.384 -             (XtArgVal)&info->num_drop_rectangles); argcount++;
 104.385 -    XtSetArg(arglist[argcount], XmNnumImportTargets,
 104.386 -             (XtArgVal)&info->num_import_targets); argcount++;
 104.387 -    DASSERT(argcount == ARG_COUNT - 2);
 104.388 -
 104.389 -    XmDropSiteRetrieve(w, arglist, argcount);
 104.390 -
 104.391 -    if (info->num_import_targets > 0) {
 104.392 -        Atom *targets = NULL;
 104.393 -
 104.394 -        info->import_targets = malloc(info->num_import_targets * sizeof(Atom));
 104.395 -
 104.396 -        if (info->import_targets == NULL) {
 104.397 -            JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 104.398 -
 104.399 -            free(info);
 104.400 -            JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
 104.401 -            return NULL;
 104.402 -        }
 104.403 -
 104.404 -        XtSetArg(arglist[0], XmNimportTargets, (XtArgVal)&targets);
 104.405 -        XmDropSiteRetrieve(w, arglist, 1);
 104.406 -
 104.407 -        memcpy(info->import_targets, targets,
 104.408 -               info->num_import_targets * sizeof(Atom));
 104.409 -    }
 104.410 -
 104.411 -    if (info->drop_site_type == XmDROP_SITE_SIMPLE && info->num_drop_rectangles > 0) {
 104.412 -            XRectangle *rectangles = NULL;
 104.413 -            info->drop_rectangles =
 104.414 -                malloc(info->num_drop_rectangles * sizeof(XRectangle));
 104.415 -
 104.416 -            if (info->drop_rectangles == NULL) {
 104.417 -                JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 104.418 -
 104.419 -                if (info->import_targets != NULL) {
 104.420 -                    free(info->import_targets);
 104.421 -                }
 104.422 -                free(info);
 104.423 -                JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
 104.424 -                return NULL;
 104.425 -            }
 104.426 -
 104.427 -            XtSetArg(arglist[0], XmNdropRectangles, (XtArgVal)&rectangles);
 104.428 -            XmDropSiteRetrieve(w, arglist, 1);
 104.429 -
 104.430 -            memcpy(info->drop_rectangles, rectangles,
 104.431 -                   info->num_drop_rectangles * sizeof(XRectangle));
 104.432 -    } else /* if (info->drop_site_type == XmDROP_SITE_COMPOSITE) */ {
 104.433 -        info->num_drop_rectangles = 1;
 104.434 -        info->drop_rectangles = NULL;
 104.435 -    }
 104.436 -
 104.437 -    info->widget = w;
 104.438 -    return info;
 104.439 -}
 104.440 -
 104.441 -/*
 104.442 - * Registers a Motif drop site on a widget given the information
 104.443 - * in the passed DSInfoRec structure.
 104.444 - */
 104.445 -void restore_drop_site(DSInfoPtr info) {
 104.446 -    Arg      arglist[ARG_COUNT];
 104.447 -    Cardinal argcount = 0;
 104.448 -
 104.449 -    if (info->drop_site_type == XmDROP_SITE_COMPOSITE) {
 104.450 -        info->num_drop_rectangles = 1;
 104.451 -        info->drop_rectangles = NULL;
 104.452 -    }
 104.453 -
 104.454 -    XtSetArg(arglist[argcount], XmNanimationMask,
 104.455 -             (XtArgVal)info->animation_mask); argcount++;
 104.456 -    XtSetArg(arglist[argcount], XmNanimationPixmap,
 104.457 -             (XtArgVal)info->animation_pixmap); argcount++;
 104.458 -    XtSetArg(arglist[argcount], XmNanimationPixmapDepth,
 104.459 -             (XtArgVal)info->animation_pixmap_depth); argcount++;
 104.460 -    XtSetArg(arglist[argcount], XmNanimationStyle,
 104.461 -             (XtArgVal)info->animation_style); argcount++;
 104.462 -    XtSetArg(arglist[argcount], XmNclientData,
 104.463 -             (XtArgVal)info->client_data); argcount++;
 104.464 -    XtSetArg(arglist[argcount], XmNdragProc,
 104.465 -             (XtArgVal)info->drag_proc); argcount++;
 104.466 -    XtSetArg(arglist[argcount], XmNdropProc,
 104.467 -             (XtArgVal)info->drop_proc); argcount++;
 104.468 -    XtSetArg(arglist[argcount], XmNdropRectangles,
 104.469 -             (XtArgVal)info->drop_rectangles); argcount++;
 104.470 -    XtSetArg(arglist[argcount], XmNdropSiteActivity,
 104.471 -             (XtArgVal)info->drop_site_activity); argcount++;
 104.472 -    XtSetArg(arglist[argcount], XmNdropSiteOperations,
 104.473 -             (XtArgVal)info->drop_site_operations); argcount++;
 104.474 -    XtSetArg(arglist[argcount], XmNdropSiteType,
 104.475 -             (XtArgVal)info->drop_site_type); argcount++;
 104.476 -    XtSetArg(arglist[argcount], XmNimportTargets,
 104.477 -             (XtArgVal)info->import_targets); argcount++;
 104.478 -    XtSetArg(arglist[argcount], XmNnumDropRectangles,
 104.479 -             (XtArgVal)info->num_drop_rectangles); argcount++;
 104.480 -    XtSetArg(arglist[argcount], XmNnumImportTargets,
 104.481 -             (XtArgVal)info->num_import_targets); argcount++;
 104.482 -    DASSERT(argcount == ARG_COUNT);
 104.483 -
 104.484 -    XmDropSiteUnregister(info->widget);
 104.485 -    XmDropSiteRegister(info->widget, arglist, argcount);
 104.486 -    XmDropSiteConfigureStackingOrder(info->widget, (Widget)NULL, XmABOVE);
 104.487 -}
 104.488 -
 104.489 -#undef ARG_COUNT
 104.490 -
 104.491 -/*
 104.492 - * This routine ensures that hierarchy of Motif drop sites is not broken
 104.493 - * when a new drop site is registered or an existing drop site is
 104.494 - * unregistered. It unregisters all drop sites registered on the descendants of
 104.495 - * the specified widget, then registers or unregisters a Motif drop site on the
 104.496 - * root widget depending on the value of registerNewSite. After that the routine
 104.497 - * restores all the drop sites on the descendants.
 104.498 - * The routine recursively traverses through the hierarchy of descendant Motif
 104.499 - * drop sites and stores the info for all drop sites in a list. Then this list
 104.500 - * is used to restore all descendant drop sites.
 104.501 - * @param w    current widget in the hierarchy traversal
 104.502 - * @param top  root widget of the traversed hierarchy - the one to be inserted or
 104.503 - *             removed
 104.504 - * @param list a list of DSInfoRec structures which keep drop site info for
 104.505 - *             child drop sites
 104.506 - * @param registerNewSite if True a new Motif drop site should be registered on
 104.507 - *             the root widget. If False an existing drop site of the root widget
 104.508 - *             should be unregistered.
 104.509 - * @param isDropSite if True the widget being currently traversed has an
 104.510 - *             associated Motif drop site.
 104.511 - */
 104.512 -static DSInfoPtr
 104.513 -update_drop_site_hierarchy(Widget w, Widget top, DSInfoPtr list,
 104.514 -                           Boolean registerNewSite, Boolean isDropSite) {
 104.515 -
 104.516 -    Widget     parent = NULL;
 104.517 -    Widget     *children = NULL;
 104.518 -    Cardinal   num_children = 0;
 104.519 -
 104.520 -    if (w == NULL || !XtIsObject(w) || w->core.being_destroyed) {
 104.521 -        return NULL;
 104.522 -    }
 104.523 -
 104.524 -    /* Get the child drop sites of the widget.*/
 104.525 -    if (XmDropSiteQueryStackingOrder(w, &parent, &children,
 104.526 -                                     &num_children) == 0) {
 104.527 -        /*
 104.528 -         * The widget is declared to be a drop site, but the query fails.
 104.529 -         * The drop site must be corrupted. Truncate traversal.
 104.530 -         */
 104.531 -        if (isDropSite) {
 104.532 -            return NULL;
 104.533 -        }
 104.534 -    } else {
 104.535 -        /* The query succeded, so the widget is definitely a drop site. */
 104.536 -        isDropSite = True;
 104.537 -    }
 104.538 -
 104.539 -    /* Traverse descendants of the widget, if it is composite. */
 104.540 -    if (XtIsComposite(w)) {
 104.541 -        Cardinal   i = 0;
 104.542 -
 104.543 -        /* If it is not a drop site, check all its children. */
 104.544 -        if (!isDropSite) {
 104.545 -            XtVaGetValues(w, XmNchildren, &children,
 104.546 -                          XmNnumChildren, &num_children, NULL);
 104.547 -        }
 104.548 -
 104.549 -        for (i = 0; i < num_children; i++) {
 104.550 -            list = update_drop_site_hierarchy(children[i], top, list,
 104.551 -                                              registerNewSite, isDropSite);
 104.552 -        }
 104.553 -    }
 104.554 -
 104.555 -    /* The storage allocated by XmDropSiteQueryStackingOrder must be freed.*/
 104.556 -    if (isDropSite && children != NULL) {
 104.557 -        XtFree((void*)children);
 104.558 -    }
 104.559 -
 104.560 -    if (w != top) {
 104.561 -        if (isDropSite) {
 104.562 -            /* Prepend drop site info to the list and unregister a drop site.*/
 104.563 -            DSInfoPtr info = get_drop_site_info(w);
 104.564 -
 104.565 -            if (info != NULL) {
 104.566 -                info->next = list;
 104.567 -                list = info;
 104.568 -            }
 104.569 -            XmDropSiteUnregister(w);
 104.570 -        }
 104.571 -    } else {
 104.572 -        /* Traversal is complete.*/
 104.573 -        DSInfoPtr info = list;
 104.574 -
 104.575 -        if (isDropSite) {
 104.576 -            XmDropSiteUnregister(w);
 104.577 -        }
 104.578 -
 104.579 -        if (registerNewSite) {
 104.580 -            Arg              args[10];
 104.581 -            unsigned int nargs = 0;
 104.582 -
 104.583 -#define SetArg(n, v) args[nargs].name = n; args[nargs++].value = (XtArgVal)(v);
 104.584 -
 104.585 -            SetArg(XmNanimationStyle,   XmDRAG_UNDER_NONE);
 104.586 -            SetArg(XmNdragProc,                awt_XmDragProc);
 104.587 -            SetArg(XmNdropProc,                awt_XmDropProc);
 104.588 -            SetArg(XmNdropSiteActivity, XmDROP_SITE_ACTIVE);
 104.589 -
 104.590 -            SetArg(XmNdropSiteOperations,
 104.591 -                   XmDROP_LINK | XmDROP_MOVE | XmDROP_COPY);
 104.592 -
 104.593 -            SetArg(XmNimportTargets,    NULL);
 104.594 -            SetArg(XmNnumImportTargets, 0);
 104.595 -
 104.596 -            SetArg(XmNdropSiteType,     XmDROP_SITE_COMPOSITE);
 104.597 -            SetArg(XmNdropRectangles,   (XRectangle*)NULL);
 104.598 -#undef  SetArg
 104.599 -
 104.600 -            XmDropSiteRegister(w, args, nargs);
 104.601 -            XmDropSiteConfigureStackingOrder(w, (Widget)NULL, XmABOVE);
 104.602 -        }
 104.603 -
 104.604 -        /* Go through the list and restore all child drop sites.*/
 104.605 -        while (info != NULL) {
 104.606 -            restore_drop_site(info);
 104.607 -
 104.608 -            info = info->next;
 104.609 -            list->next = NULL;
 104.610 -            if (list->import_targets != NULL) {
 104.611 -                free(list->import_targets);
 104.612 -            }
 104.613 -            if (list->drop_rectangles != NULL) {
 104.614 -                free(list->drop_rectangles);
 104.615 -            }
 104.616 -            free(list);
 104.617 -            list = info;
 104.618 -        }
 104.619 -    }
 104.620 -    return list;
 104.621 -}
 104.622 -
 104.623 -void
 104.624 -register_drop_site(Widget w) {
 104.625 -    update_drop_site_hierarchy(w, w, NULL, True, False);
 104.626 -}
 104.627 -
 104.628 -void
 104.629 -unregister_drop_site(Widget w) {
 104.630 -    update_drop_site_hierarchy(w, w, NULL, False, True);
 104.631 -}
 104.632 -
 104.633 -DECLARE_JAVA_CLASS(dSCClazz, "sun/awt/motif/MDragSourceContextPeer")
 104.634 -DECLARE_JAVA_CLASS(dTCClazz, "sun/awt/motif/MDropTargetContextPeer")
 104.635 -
 104.636 -static void
 104.637 -call_dSCenter(JNIEnv* env, jobject this, jint targetActions,
 104.638 -              jint modifiers, jint x, jint y) {
 104.639 -    DECLARE_VOID_JAVA_METHOD(dSCenter, dSCClazz, "dragEnter", "(IIII)V");
 104.640 -    DASSERT(!JNU_IsNull(env, this));
 104.641 -    (*env)->CallVoidMethod(env, this, dSCenter, targetActions, modifiers, x, y);
 104.642 -}
 104.643 -
 104.644 -static void
 104.645 -call_dSCmotion(JNIEnv* env, jobject this, jint targetActions,
 104.646 -               jint modifiers, jint x, jint y) {
 104.647 -    DECLARE_VOID_JAVA_METHOD(dSCmotion, dSCClazz, "dragMotion", "(IIII)V");
 104.648 -    DASSERT(!JNU_IsNull(env, this));
 104.649 -    (*env)->CallVoidMethod(env, this, dSCmotion, targetActions,
 104.650 -                           modifiers, x, y);
 104.651 -}
 104.652 -
 104.653 -static void
 104.654 -call_dSCchanged(JNIEnv* env, jobject this, jint targetActions,
 104.655 -                jint modifiers, jint x, jint y) {
 104.656 -    DECLARE_VOID_JAVA_METHOD(dSCchanged, dSCClazz, "operationChanged",
 104.657 -                             "(IIII)V");
 104.658 -    DASSERT(!JNU_IsNull(env, this));
 104.659 -    (*env)->CallVoidMethod(env, this, dSCchanged, targetActions,
 104.660 -                           modifiers, x, y);
 104.661 -}
 104.662 -
 104.663 -static void
 104.664 -call_dSCmouseMoved(JNIEnv* env, jobject this, jint targetActions,
 104.665 -                   jint modifiers, jint x, jint y) {
 104.666 -    DECLARE_VOID_JAVA_METHOD(dSCmouseMoved, dSCClazz, "dragMouseMoved",
 104.667 -                             "(IIII)V");
 104.668 -    DASSERT(!JNU_IsNull(env, this));
 104.669 -    (*env)->CallVoidMethod(env, this, dSCmouseMoved, targetActions,
 104.670 -                           modifiers, x, y);
 104.671 -}
 104.672 -
 104.673 -static void
 104.674 -call_dSCexit(JNIEnv* env, jobject this, jint x, jint y) {
 104.675 -    DECLARE_VOID_JAVA_METHOD(dSCexit, dSCClazz, "dragExit", "(II)V");
 104.676 -    DASSERT(!JNU_IsNull(env, this));
 104.677 -    (*env)->CallVoidMethod(env, this, dSCexit, x, y);
 104.678 -}
 104.679 -
 104.680 -static void
 104.681 -call_dSCddfinished(JNIEnv* env, jobject this, jboolean success,
 104.682 -                   jint operations, jint x, jint y) {
 104.683 -    DECLARE_VOID_JAVA_METHOD(dSCddfinished, dSCClazz, "dragDropFinished",
 104.684 -                             "(ZIII)V");
 104.685 -    DASSERT(!JNU_IsNull(env, this));
 104.686 -    (*env)->CallVoidMethod(env, this, dSCddfinished, success, operations, x, y);
 104.687 -}
 104.688 -
 104.689 -static jobject
 104.690 -call_dTCcreate(JNIEnv* env) {
 104.691 -    DECLARE_STATIC_OBJECT_JAVA_METHOD(dTCcreate, dTCClazz,
 104.692 -                                     "createMDropTargetContextPeer",
 104.693 -                                     "()Lsun/awt/motif/MDropTargetContextPeer;");
 104.694 -    return (*env)->CallStaticObjectMethod(env, clazz, dTCcreate);
 104.695 -}
 104.696 -
 104.697 -static jint
 104.698 -call_dTCenter(JNIEnv* env, jobject this, jobject component, jint x, jint y,
 104.699 -              jint dropAction, jint actions, jlongArray formats,
 104.700 -              jlong nativeCtxt) {
 104.701 -    DECLARE_JINT_JAVA_METHOD(dTCenter, dTCClazz, "handleEnterMessage",
 104.702 -                            "(Ljava/awt/Component;IIII[JJ)I");
 104.703 -    DASSERT(!JNU_IsNull(env, this));
 104.704 -    return (*env)->CallIntMethod(env, this, dTCenter, component, x, y, dropAction,
 104.705 -                                 actions, formats, nativeCtxt);
 104.706 -}
 104.707 -
 104.708 -static void
 104.709 -call_dTCexit(JNIEnv* env, jobject this, jobject component, jlong nativeCtxt) {
 104.710 -    DECLARE_VOID_JAVA_METHOD(dTCexit, dTCClazz, "handleExitMessage",
 104.711 -                            "(Ljava/awt/Component;J)V");
 104.712 -    DASSERT(!JNU_IsNull(env, this));
 104.713 -    (*env)->CallVoidMethod(env, this, dTCexit, component, nativeCtxt);
 104.714 -}
 104.715 -
 104.716 -static jint
 104.717 -call_dTCmotion(JNIEnv* env, jobject this, jobject component, jint x, jint y,
 104.718 -               jint dropAction, jint actions, jlongArray formats,
 104.719 -               jlong nativeCtxt) {
 104.720 -    DECLARE_JINT_JAVA_METHOD(dTCmotion, dTCClazz, "handleMotionMessage",
 104.721 -                            "(Ljava/awt/Component;IIII[JJ)I");
 104.722 -    DASSERT(!JNU_IsNull(env, this));
 104.723 -    return (*env)->CallIntMethod(env, this, dTCmotion, component, x, y,
 104.724 -                                 dropAction, actions, formats, nativeCtxt);
 104.725 -}
 104.726 -
 104.727 -static void
 104.728 -call_dTCdrop(JNIEnv* env, jobject this, jobject component, jint x, jint y,
 104.729 -             jint dropAction, jint actions, jlongArray formats,
 104.730 -             jlong nativeCtxt) {
 104.731 -    DECLARE_VOID_JAVA_METHOD(dTCdrop, dTCClazz, "handleDropMessage",
 104.732 -                            "(Ljava/awt/Component;IIII[JJ)V");
 104.733 -    DASSERT(!JNU_IsNull(env, this));
 104.734 -    (*env)->CallVoidMethod(env, this, dTCdrop, component, x, y,
 104.735 -                           dropAction, actions, formats, nativeCtxt);
 104.736 -}
 104.737 -
 104.738 -static void
 104.739 -call_dTCnewData(JNIEnv* env, jobject this, jlong format, jobject type,
 104.740 -                jbyteArray data) {
 104.741 -    DECLARE_VOID_JAVA_METHOD(dTCnewData, dTCClazz, "newData",
 104.742 -                            "(JLjava/lang/String;[B)V");
 104.743 -    DASSERT(!JNU_IsNull(env, this));
 104.744 -    (*env)->CallVoidMethod(env, this, dTCnewData, format, type, data);
 104.745 -}
 104.746 -
 104.747 -static void
 104.748 -call_dTCtxFailed(JNIEnv* env, jobject this, jlong format) {
 104.749 -    DECLARE_VOID_JAVA_METHOD(dTCtxFailed, dTCClazz, "transferFailed", "(J)V");
 104.750 -    DASSERT(!JNU_IsNull(env, this));
 104.751 -    (*env)->CallVoidMethod(env, this, dTCtxFailed, format);
 104.752 -}
 104.753 -
 104.754 -/*
 104.755 - * Class:     sun_awt_motif_MComponentPeer
 104.756 - * Method:    addNativeDropTarget
 104.757 - * Signature: (Ljava/awt/dnd/DropTarget;)V
 104.758 - */
 104.759 -
 104.760 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_addNativeDropTarget
 104.761 -    (JNIEnv *env, jobject this, jobject droptarget)
 104.762 -{
 104.763 -    struct ComponentData* cdata     = (struct ComponentData *)NULL;
 104.764 -    DropSitePtr          dropsite  = (DropSitePtr)NULL;
 104.765 -
 104.766 -    if (JNU_IsNull(env, droptarget)) {
 104.767 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 104.768 -        return;
 104.769 -    }
 104.770 -
 104.771 -    AWT_LOCK();
 104.772 -
 104.773 -    cdata = (struct ComponentData *)
 104.774 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
 104.775 -
 104.776 -    if (cdata == NULL || cdata->widget == NULL) {
 104.777 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 104.778 -        AWT_UNLOCK();
 104.779 -        return;
 104.780 -    }
 104.781 -
 104.782 -    /* introduce a new Component as a root of a set of DropTargets */
 104.783 -
 104.784 -    if ((dropsite = cdata->dsi) == (DropSitePtr)NULL) {
 104.785 -        dropsite = cdata->dsi = (DropSitePtr)ZALLOC(DropSiteInfo);
 104.786 -
 104.787 -        if (dropsite == (DropSitePtr)NULL) {
 104.788 -            JNU_ThrowOutOfMemoryError (env, "OutOfMemoryError");
 104.789 -            AWT_UNLOCK ();
 104.790 -            return;
 104.791 -        }
 104.792 -
 104.793 -        dropsite->component = (*env)->NewGlobalRef
 104.794 -            (env, (*env)->GetObjectField(env, this,
 104.795 -                                         mComponentPeerIDs.target));
 104.796 -        dropsite->isComposite = True;
 104.797 -
 104.798 -        /*
 104.799 -         * Fix for Bug Id 4389284.
 104.800 -         * Revalidate drop site hierarchy so that this drop site doesn't obscure
 104.801 -         * drop sites that are already registered on its children.
 104.802 -         */
 104.803 -        register_drop_site(cdata->widget);
 104.804 -    }
 104.805 -
 104.806 -    dropsite->dsCnt++;
 104.807 -
 104.808 -    AWT_UNLOCK();
 104.809 -}
 104.810 -
 104.811 -/*
 104.812 - * Class:     sun_awt_motif_MComponentPeer
 104.813 - * Method:    removeNativeDropTarget
 104.814 - * Signature: (Ljava/awt/dnd/DropTarget;)V
 104.815 - */
 104.816 -
 104.817 -JNIEXPORT void JNICALL Java_sun_awt_motif_MComponentPeer_removeNativeDropTarget
 104.818 -    (JNIEnv *env, jobject this, jobject droptarget)
 104.819 -{
 104.820 -    struct ComponentData* cdata;
 104.821 -    DropSitePtr           dropsite;
 104.822 -
 104.823 -    if (JNU_IsNull(env, droptarget)) {
 104.824 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 104.825 -        return;
 104.826 -    }
 104.827 -
 104.828 -    AWT_LOCK();
 104.829 -
 104.830 -    cdata = (struct ComponentData *)
 104.831 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
 104.832 -
 104.833 -    if (cdata == NULL || cdata->widget == NULL) {
 104.834 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 104.835 -        AWT_UNLOCK();
 104.836 -        return;
 104.837 -    }
 104.838 -
 104.839 -    if ((dropsite = cdata->dsi) == (DropSitePtr)NULL) {
 104.840 -        JNU_ThrowNullPointerException(env, "NullPointerException");
 104.841 -        AWT_UNLOCK();
 104.842 -        return;
 104.843 -    }
 104.844 -
 104.845 -    dropsite->dsCnt--;
 104.846 -    if (dropsite->dsCnt == 0) {
 104.847 -        /*
 104.848 -         * Fix for Bug Id 4411368.
 104.849 -         * Revalidate drop site hierarchy to prevent crash when a composite drop
 104.850 -         * site is unregistered before its child drop sites.
 104.851 -         */
 104.852 -        unregister_drop_site(cdata->widget);
 104.853 -
 104.854 -        (*env)->DeleteGlobalRef(env, dropsite->component);
 104.855 -
 104.856 -        free((void *)(cdata->dsi));
 104.857 -        cdata->dsi = (DropSitePtr)NULL;
 104.858 -    }
 104.859 -
 104.860 -    AWT_UNLOCK();
 104.861 -}
 104.862 -
 104.863 -/**
 104.864 - *
 104.865 - */
 104.866 -
 104.867 -JNIEXPORT void JNICALL
 104.868 -Java_sun_awt_motif_MDragSourceContextPeer_setNativeCursor(JNIEnv *env,
 104.869 -                                                          jobject this,
 104.870 -                                                          jlong nativeCtxt,
 104.871 -                                                          jobject cursor,
 104.872 -                                                          jint type) {
 104.873 -    /*
 104.874 -     * NOTE: no need to synchronize on awt_lock here, since we should have
 104.875 -     * already acquired it in MDragSourceContextPeer.setCursor().
 104.876 -     */
 104.877 -    setCursor(env, awt_display, cursor, type, CurrentTime);
 104.878 -}
 104.879 -
 104.880 -/**
 104.881 - *
 104.882 - */
 104.883 -
 104.884 -JNIEXPORT jlong JNICALL
 104.885 -Java_sun_awt_motif_MDropTargetContextPeer_startTransfer(JNIEnv *env,
 104.886 -                                                        jobject this,
 104.887 -                                                        jlong dragContextVal,
 104.888 -                                                        jlong atom) {
 104.889 -    XmDropTransferEntryRec trec;
 104.890 -    Widget                 dropTransfer;
 104.891 -    Arg                    args[3];
 104.892 -    Cardinal               nargs = 0;
 104.893 -    jboolean               isCopy;
 104.894 -    Widget                 dragContext = (Widget)jlong_to_ptr(dragContextVal);
 104.895 -
 104.896 -    AWT_LOCK();
 104.897 -
 104.898 -    trec.target      = (Atom) atom;
 104.899 -    trec.client_data = (XtPointer)trec.target;
 104.900 -
 104.901 -
 104.902 -#define SetArg(n, v) args[nargs].name = n; args[nargs++].value = (XtArgVal)(v);
 104.903 -
 104.904 -    SetArg(XmNdropTransfers,    &trec);
 104.905 -    SetArg(XmNnumDropTransfers, 1    );
 104.906 -    SetArg(XmNtransferProc,     awt_XmTransferProc);
 104.907 -
 104.908 -#undef SetArg
 104.909 -
 104.910 -    _cache.transfer = dropTransfer =
 104.911 -        XmDropTransferStart(dragContext, args, nargs);
 104.912 -
 104.913 -    _cache.transfersPending++;
 104.914 -
 104.915 -    AWT_NOTIFY_ALL();
 104.916 -    AWT_UNLOCK();
 104.917 -
 104.918 -    return ptr_to_jlong(dropTransfer);
 104.919 -}
 104.920 -
 104.921 -/**
 104.922 - *
 104.923 - */
 104.924 -
 104.925 -JNIEXPORT void JNICALL
 104.926 -Java_sun_awt_motif_MDropTargetContextPeer_addTransfer(JNIEnv *env,
 104.927 -                                                      jobject this,
 104.928 -                                                      jlong dropTransferVal,
 104.929 -                                                      jlong atom) {
 104.930 -    XmDropTransferEntryRec trec;
 104.931 -    jboolean               isCopy;
 104.932 -    Widget                 dropTransfer=(Widget)jlong_to_ptr(dropTransferVal);
 104.933 -    trec.target      = (Atom)atom;
 104.934 -    trec.client_data = (XtPointer)trec.target;
 104.935 -
 104.936 -    AWT_LOCK();
 104.937 -
 104.938 -    XmDropTransferAdd(dropTransfer, &trec, 1);
 104.939 -
 104.940 -    _cache.transfersPending++;
 104.941 -
 104.942 -    AWT_NOTIFY_ALL();
 104.943 -    AWT_UNLOCK();
 104.944 -}
 104.945 -
 104.946 -/**
 104.947 - *
 104.948 - */
 104.949 -
 104.950 -JNIEXPORT void JNICALL Java_sun_awt_motif_MDropTargetContextPeer_dropDone
 104.951 -    (JNIEnv *env, jobject this, jlong dragContextVal, jlong dropTransferVal,
 104.952 -     jboolean isLocal, jboolean success, jint dropAction)
 104.953 -{
 104.954 -    Widget dropTransfer = (Widget)jlong_to_ptr(dropTransferVal);
 104.955 -    Widget dragContext = (Widget)jlong_to_ptr(dragContextVal);
 104.956 -
 104.957 -    AWT_LOCK();
 104.958 -
 104.959 -    if (_cache.w == (Widget)NULL) {
 104.960 -        AWT_UNLOCK();
 104.961 -        return;
 104.962 -    }
 104.963 -
 104.964 -    if (!isDropDone()) {
 104.965 -        if (dropTransfer != (jlong)NULL) {
 104.966 -            XtVaSetValues(dropTransfer,
 104.967 -                          XmNtransferStatus,
 104.968 -                          success == JNI_TRUE
 104.969 -                          ? XmTRANSFER_SUCCESS : XmTRANSFER_FAILURE,
 104.970 -                          NULL
 104.971 -                          );
 104.972 -        } else {
 104.973 -            /*
 104.974 -             * start a transfer that notifies failure
 104.975 -             * this causes src side callbacks to be processed.
 104.976 -             * However, you cannot pass an a success, so the workaround is
 104.977 -             * to set _cache.transferSuccess to the proper value and read it
 104.978 -             * on the other side.
 104.979 -             */
 104.980 -
 104.981 -
 104.982 -            Arg arg;
 104.983 -
 104.984 -            /*
 104.985 -             * this is the workaround code
 104.986 -             */
 104.987 -            _cache.transfer = NULL;
 104.988 -            _cache.dropAction = dropAction;
 104.989 -
 104.990 -            /*
 104.991 -             * End workaround code
 104.992 -             */
 104.993 -
 104.994 -            arg.name  = XmNtransferStatus;
 104.995 -            arg.value = (XtArgVal)(success == JNI_TRUE ? XmTRANSFER_SUCCESS
 104.996 -                                   : XmTRANSFER_FAILURE
 104.997 -                                   );
 104.998 -
 104.999 -            XmDropTransferStart(dragContext, &arg, 1);
104.1000 -        }
104.1001 -
104.1002 -        /*
104.1003 -         * bugid# 4146717
104.1004 -         *
104.1005 -         * If this is a local tx, then we never exec the awt_XmTransferProc,
104.1006 -         * thus we need to flush the cache here as it is our only chance,
104.1007 -         * otherwise we leave a mess for the next operation to fail on ....
104.1008 -         *
104.1009 -         */
104.1010 -
104.1011 -        if (isLocal == JNI_TRUE)
104.1012 -            flush_cache(env); /* flush now, last chance */
104.1013 -        else
104.1014 -            _cache.flushPending = True; /* flush pending in transfer proc */
104.1015 -    }
104.1016 -
104.1017 -    cacheDropDone(True);
104.1018 -
104.1019 -    AWT_NOTIFY_ALL();
104.1020 -    AWT_UNLOCK();
104.1021 -}
104.1022 -
104.1023 -
104.1024 -static Boolean exitIdleProc = False;
104.1025 -static int32_t x_root = -1, y_root = -1;
104.1026 -
104.1027 -extern void waitForEvents(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe);
104.1028 -
104.1029 -static jint convertModifiers(uint32_t modifiers) {
104.1030 -    return getModifiers(modifiers, 0, 0);
104.1031 -}
104.1032 -
104.1033 -static void
104.1034 -checkMouseMoved(XtPointer client_data) {
104.1035 -    Window rootWindow, childWindow;
104.1036 -    int32_t xw, yw, xr, yr;
104.1037 -    uint32_t modifiers;
104.1038 -
104.1039 -    /*
104.1040 -     * When dragging over the root window XmNdragMotionCallback is not called
104.1041 -     * (Motif feature).
104.1042 -     * Since there is no legal way to receive MotionNotify events during drag
104.1043 -     * we have to query for mouse position periodically.
104.1044 -     */
104.1045 -    if (XQueryPointer(awt_display, XDefaultRootWindow(awt_display),
104.1046 -                      &rootWindow, &childWindow,
104.1047 -                      &xr, &yr, &xw, &yw, &modifiers) &&
104.1048 -        childWindow == None && (xr != x_root || yr != y_root)) {
104.1049 -
104.1050 -        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.1051 -        jobject this = (jobject)client_data;
104.1052 -
104.1053 -        call_dSCmouseMoved(env, this, XmDROP_NOOP, convertModifiers(modifiers),
104.1054 -                           xr, yr);
104.1055 -
104.1056 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
104.1057 -            (*env)->ExceptionDescribe(env);
104.1058 -            (*env)->ExceptionClear(env);
104.1059 -        }
104.1060 -
104.1061 -        x_root = xr;
104.1062 -        y_root = yr;
104.1063 -    }
104.1064 -}
104.1065 -
104.1066 -static void IdleProc(XtPointer client_data, XtIntervalId* id) {
104.1067 -    if (!exitIdleProc) {
104.1068 -        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.1069 -        /* The pipe where X events arrive */
104.1070 -        int32_t fdXPipe = ConnectionNumber(awt_display) ;
104.1071 -
104.1072 -        /*
104.1073 -         * Motif DnD internal event loop doesn't process the events
104.1074 -         * from the AWT putback event queue. So we pass -1 instead
104.1075 -         * of the AWT read pipe descriptor to disable checking of
104.1076 -         * the putback event queue.
104.1077 -         */
104.1078 -        waitForEvents(env, fdXPipe, -1);
104.1079 -
104.1080 -        checkMouseMoved(client_data);
104.1081 -        /* Reschedule the timer callback */
104.1082 -        XtAppAddTimeOut(awt_appContext, AWT_DND_POLL_INTERVAL / 10,
104.1083 -                        IdleProc, client_data);
104.1084 -    }
104.1085 -}
104.1086 -
104.1087 -static void RemoveIdleProc(Widget w,
104.1088 -                           XtPointer client_data,
104.1089 -                           XmDropFinishCallbackStruct* cbstruct) {
104.1090 -    exitIdleProc = True;
104.1091 -}
104.1092 -
104.1093 -/**
104.1094 - *
104.1095 - */
104.1096 -
104.1097 -JNIEXPORT jlong JNICALL
104.1098 -Java_sun_awt_motif_MDragSourceContextPeer_startDrag(JNIEnv *env,
104.1099 -                                                    jobject this,
104.1100 -                                                    jobject component,
104.1101 -                                                    jobject transferable,
104.1102 -                                                    jobject trigger,
104.1103 -                                                    jobject cursor,
104.1104 -                                                    jint ctype,
104.1105 -                                                    jint actions,
104.1106 -                                                    jlongArray formats,
104.1107 -                                                    jobject formatMap) {
104.1108 -    Arg                    args[32];
104.1109 -    Cardinal               nargs = 0;
104.1110 -    jobject                dscp  = (*env)->NewGlobalRef(env, this);
104.1111 -    jbyteArray             bdata =
104.1112 -        (jbyteArray)(*env)->GetObjectField(env, trigger, awtEventIDs.bdata);
104.1113 -    Atom*                  targets = NULL;
104.1114 -    jlong*                 jTargets;
104.1115 -    jsize                  nTargets;
104.1116 -    Widget                 dc;
104.1117 -    XtCallbackRec          dsecbr[2];
104.1118 -    XtCallbackRec          dmcbr[2];
104.1119 -    XtCallbackRec          occbr[2];
104.1120 -    XtCallbackRec          dslcbr[2];
104.1121 -    XtCallbackRec          dscbr[2];
104.1122 -    XtCallbackRec          ddfcbr[2];
104.1123 -    XEvent*                xevent;
104.1124 -    unsigned char          xmActions = DnDConstantsToXm(actions);
104.1125 -    jboolean               isCopy=JNI_TRUE;
104.1126 -    awt_convertDataCallbackStruct* structPtr;
104.1127 -
104.1128 -#ifndef _LP64 /* Atom and jlong are different sizes in the 32-bit build */
104.1129 -    jsize                  i;
104.1130 -    jlong*                 saveJTargets;
104.1131 -    Atom*                  saveTargets;
104.1132 -#endif
104.1133 -
104.1134 -    if (xmActions == XmDROP_NOOP) {
104.1135 -        JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
104.1136 -                        "Invalid source actions.");
104.1137 -        return ptr_to_jlong(NULL);
104.1138 -    }
104.1139 -
104.1140 -    if (JNU_IsNull(env, formats)) {
104.1141 -        JNU_ThrowNullPointerException(env, "formats");
104.1142 -        return ptr_to_jlong(NULL);
104.1143 -    }
104.1144 -
104.1145 -    if (JNU_IsNull(env, bdata)) {
104.1146 -        JNU_ThrowNullPointerException(env,
104.1147 -                                      "null native data for trigger event");
104.1148 -        return ptr_to_jlong(NULL);
104.1149 -    }
104.1150 -
104.1151 -    nTargets = (*env)->GetArrayLength(env, formats);
104.1152 -
104.1153 -    /*
104.1154 -     * In debug build GetLongArrayElements aborts with assertion on an empty
104.1155 -     * array.
104.1156 -     */
104.1157 -    if (nTargets > 0) {
104.1158 -        jTargets = (*env)->GetLongArrayElements(env, formats, &isCopy);
104.1159 -        if (!JNU_IsNull(env, ((*env)->ExceptionOccurred(env)))) {
104.1160 -            (*env)->ExceptionDescribe(env);
104.1161 -            (*env)->ExceptionClear(env);
104.1162 -        }
104.1163 -        if (jTargets != NULL) {
104.1164 -            targets = (Atom *)malloc(nTargets * sizeof(Atom));
104.1165 -            if (targets != NULL) {
104.1166 -#ifdef _LP64
104.1167 -                memcpy(targets, jTargets, nTargets * sizeof(Atom));
104.1168 -#else
104.1169 -                saveJTargets = jTargets;
104.1170 -                saveTargets = targets;
104.1171 -                for (i = 0; i < nTargets; i++, targets++, jTargets++) {
104.1172 -                    *targets = (Atom)*jTargets;
104.1173 -                }
104.1174 -                jTargets = saveJTargets;
104.1175 -                targets = saveTargets;
104.1176 -#endif
104.1177 -            }
104.1178 -            (*env)->ReleaseLongArrayElements(env, formats, jTargets, JNI_ABORT);
104.1179 -        }
104.1180 -    }
104.1181 -    if (targets == NULL) {
104.1182 -        nTargets = 0;
104.1183 -    }
104.1184 -
104.1185 -#define SetCB(cbr, cb, cl) cbr[0].callback = (XtCallbackProc)cb; cbr[0].closure = (XtPointer)cl; cbr[1].callback = (XtCallbackProc)NULL; cbr[1].closure = (XtPointer)NULL
104.1186 -
104.1187 -#define SetArg(n, v) args[nargs].name = n; args[nargs++].value = (XtArgVal)(v);
104.1188 -
104.1189 -    SetCB(dsecbr, awt_XmDragEnterProc,            dscp);
104.1190 -    SetCB(dmcbr,  awt_XmDragMotionProc,           dscp);
104.1191 -    SetCB(occbr,  awt_XmDropOperationChangedProc, dscp);
104.1192 -    SetCB(dslcbr, awt_XmDragLeaveProc,            dscp);
104.1193 -    SetCB(ddfcbr, awt_XmDropFinishProc,           dscp);
104.1194 -
104.1195 -    SetArg(XmNblendModel,               XmBLEND_NONE      );
104.1196 -    SetArg(XmNdragOperations,           xmActions         );
104.1197 -    /* No incremental transfer */
104.1198 -    SetArg(XmNconvertProc,              awt_convertData    );
104.1199 -    SetArg(XmNdropSiteEnterCallback,    dsecbr             );
104.1200 -    SetArg(XmNdragMotionCallback,       dmcbr              );
104.1201 -    SetArg(XmNoperationChangedCallback, occbr              );
104.1202 -    SetArg(XmNdropSiteLeaveCallback,    dslcbr             );
104.1203 -    SetArg(XmNdropFinishCallback,       ddfcbr             );
104.1204 -    SetArg(XmNexportTargets,            targets            );
104.1205 -    SetArg(XmNnumExportTargets,         (Cardinal)nTargets );
104.1206 -
104.1207 -    {
104.1208 -        jsize len = (*env)->GetArrayLength(env, bdata);
104.1209 -        if (len <= 0) {
104.1210 -            free(targets);
104.1211 -            return ptr_to_jlong(NULL);
104.1212 -        }
104.1213 -
104.1214 -        xevent = calloc(1, len);
104.1215 -
104.1216 -        if (xevent == NULL) {
104.1217 -            free(targets);
104.1218 -            JNU_ThrowOutOfMemoryError(env, "");
104.1219 -            return ptr_to_jlong(NULL);
104.1220 -        }
104.1221 -
104.1222 -        (*env)->GetByteArrayRegion(env, bdata, 0, len, (jbyte *)xevent);
104.1223 -
104.1224 -        DASSERT(JNU_IsNull(env, (*env)->ExceptionOccurred(env)));
104.1225 -    }
104.1226 -
104.1227 -    if (xevent->type != ButtonPress &&
104.1228 -        xevent->type != ButtonRelease &&
104.1229 -        xevent->type != KeyRelease &&
104.1230 -        xevent->type != KeyPress &&
104.1231 -        xevent->type != MotionNotify) {
104.1232 -
104.1233 -        JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
104.1234 -                        "A drag can only be initiated in response to an InputEvent.");
104.1235 -        free(xevent);
104.1236 -        free(targets);
104.1237 -        return ptr_to_jlong(NULL);
104.1238 -    }
104.1239 -
104.1240 -    /* This call causes an UnsatisfiedLinkError on Linux.
104.1241 -     * This function is a no-op for Motif 2.1.
104.1242 -     * Since Linux only links against Motif 2.1, we can safely remove
104.1243 -     * this function altogether from the Linux build.
104.1244 -     * bchristi 1/22/2001
104.1245 -     */
104.1246 -
104.1247 -#ifdef __solaris__
104.1248 -    awt_motif_adjustDragTriggerEvent(xevent);
104.1249 -#endif
104.1250 -
104.1251 -    AWT_LOCK();
104.1252 -
104.1253 -    /*
104.1254 -     * Fix for BugTraq ID 4357905.
104.1255 -     * Drop is processed asynchronously on the event dispatch thread.
104.1256 -     * Reject all drag attempts until the current drop is done.
104.1257 -     */
104.1258 -    if (!isDropDone()) {
104.1259 -        JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
104.1260 -                        "Drop transfer in progress.");
104.1261 -        free(xevent);
104.1262 -        free(targets);
104.1263 -        AWT_UNLOCK();
104.1264 -        return ptr_to_jlong(NULL);
104.1265 -    }
104.1266 -
104.1267 -    if (XFindContext(awt_display, MOTIF_DROP_ATOM, awt_convertDataContext,
104.1268 -                     (XPointer*)&structPtr) == XCNOMEM || structPtr != NULL) {
104.1269 -        free(xevent);
104.1270 -        free(targets);
104.1271 -        AWT_UNLOCK();
104.1272 -        return ptr_to_jlong(NULL);
104.1273 -    }
104.1274 -
104.1275 -    structPtr = calloc(1, sizeof(awt_convertDataCallbackStruct));
104.1276 -    if (structPtr == NULL) {
104.1277 -        free(xevent);
104.1278 -        free(targets);
104.1279 -        JNU_ThrowOutOfMemoryError(env, "");
104.1280 -        AWT_UNLOCK();
104.1281 -        return ptr_to_jlong(NULL);
104.1282 -    }
104.1283 -
104.1284 -    structPtr->source              = (*env)->NewGlobalRef(env, component);
104.1285 -    structPtr->transferable        = (*env)->NewGlobalRef(env, transferable);
104.1286 -    structPtr->formatMap           = (*env)->NewGlobalRef(env, formatMap);
104.1287 -    structPtr->formats             = (*env)->NewGlobalRef(env, formats);
104.1288 -
104.1289 -    if (XSaveContext(awt_display, MOTIF_DROP_ATOM, awt_convertDataContext,
104.1290 -                     (XPointer)structPtr) == XCNOMEM) {
104.1291 -        free(structPtr);
104.1292 -        free(xevent);
104.1293 -        free(targets);
104.1294 -        AWT_UNLOCK();
104.1295 -        return ptr_to_jlong(NULL);
104.1296 -    }
104.1297 -
104.1298 -    dc = XmDragStart(awt_root_shell, xevent, args, nargs);
104.1299 -
104.1300 -    /* Fix for 4215643: remember the window corresponding to the drag source
104.1301 -       and the button mask after the event which triggered drag start */
104.1302 -
104.1303 -    if (xevent->type == ButtonPress || xevent->type == MotionNotify) {
104.1304 -        _cache.win = xevent->xbutton.window;
104.1305 -        if (xevent->type == ButtonPress) {
104.1306 -            _cache.state = buttonToMask(xevent->xbutton.button);
104.1307 -        } else {
104.1308 -            _cache.state = xevent->xmotion.state & (Button1Mask | Button2Mask);
104.1309 -        }
104.1310 -        XtAddEventHandler(dc, ButtonReleaseMask, False,
104.1311 -                          dragsource_track_release, NULL);
104.1312 -    }
104.1313 -
104.1314 -    free(targets);
104.1315 -
104.1316 -    if (dc != (Widget)NULL) {
104.1317 -        setCursor(env, awt_display, cursor, ctype, xevent->xbutton.time);
104.1318 -    }
104.1319 -
104.1320 -    free(xevent);
104.1321 -
104.1322 -    /*
104.1323 -     * With the new synchronization model we don't release awt_lock
104.1324 -     * in the DragContext callbacks. During drag-n-drop operation
104.1325 -     * the events processing is performed not by our awt_MToolkit_loop,
104.1326 -     * but by internal Motif InitiatorMainLoop, which returns only
104.1327 -     * when the operation is completed. So our polling mechanism doesn't
104.1328 -     * have a chance to execute and even if there are no events in
104.1329 -     * the queue AWT_LOCK will still be held by the Toolkit thread
104.1330 -     * and so other threads will likely be blocked on it.
104.1331 -     *
104.1332 -     * The solution is to schedule a timer callback which checks
104.1333 -     * for events and if the queue is empty releases AWT_LOCK and polls
104.1334 -     * the X pipe for some time, then acquires AWT_LOCK back again
104.1335 -     * and reschedules itself.
104.1336 -     */
104.1337 -    if (dc != NULL) {
104.1338 -        exitIdleProc = False;
104.1339 -        XtAddCallback(dc, XmNdragDropFinishCallback,
104.1340 -                      (XtCallbackProc)RemoveIdleProc, NULL);
104.1341 -        XtAppAddTimeOut(awt_appContext, AWT_DND_POLL_INTERVAL / 10,
104.1342 -                        IdleProc, (XtPointer)dscp);
104.1343 -    }
104.1344 -
104.1345 -    AWT_UNLOCK();
104.1346 -
104.1347 -    return ptr_to_jlong(dc);
104.1348 -
104.1349 -#undef SetArg
104.1350 -#undef SetCB
104.1351 -}
104.1352 -
104.1353 -/*****************************************************************************/
104.1354 -
104.1355 -/**
104.1356 - *
104.1357 - */
104.1358 -
104.1359 -static void setCursor(JNIEnv* env, Display* dpy, jobject cursor, jint type,
104.1360 -                      Time time)
104.1361 -{
104.1362 -    Cursor xcursor = None;
104.1363 -
104.1364 -    if (JNU_IsNull(env, cursor)) return;
104.1365 -
104.1366 -    XChangeActivePointerGrab(dpy,
104.1367 -                             ButtonPressMask   |
104.1368 -                             ButtonMotionMask  |
104.1369 -                             ButtonReleaseMask |
104.1370 -                             EnterWindowMask   |
104.1371 -                             LeaveWindowMask,
104.1372 -                             getCursor(env, cursor),
104.1373 -                             time
104.1374 -                             );
104.1375 -
104.1376 -    XSync(dpy, False);
104.1377 -}
104.1378 -
104.1379 -/**
104.1380 - * Update the cached targets for this widget
104.1381 - */
104.1382 -
104.1383 -static Boolean updateCachedTargets(JNIEnv* env, Widget dt) {
104.1384 -    Atom*              targets  = (Atom*)NULL;
104.1385 -    Cardinal           nTargets = (Cardinal)0;
104.1386 -    Arg                args[2];
104.1387 -
104.1388 -    /*
104.1389 -     * Get the targets for this component
104.1390 -     */
104.1391 -    args[0].name = XmNexportTargets;    args[0].value = (XtArgVal)&targets;
104.1392 -    args[1].name = XmNnumExportTargets; args[1].value = (XtArgVal)&nTargets;
104.1393 -    XtGetValues(_cache.dt = dt, args, 2);
104.1394 -
104.1395 -    /*
104.1396 -     * Free the previous targets if there were any
104.1397 -     */
104.1398 -    if (!JNU_IsNull(env, _cache.targets)) {
104.1399 -        (*env)->DeleteGlobalRef(env, _cache.targets);
104.1400 -        _cache.targets = (jlongArray)NULL;
104.1401 -    }
104.1402 -
104.1403 -    _cache.nTargets = nTargets;
104.1404 -
104.1405 -    /*
104.1406 -     * If the widget has targets (atoms) then copy them to the cache
104.1407 -     */
104.1408 -    if (nTargets > 0) {
104.1409 -        jboolean isCopy;
104.1410 -        jlong*   jTargets;
104.1411 -
104.1412 -#ifndef _LP64 /* Atom and jlong are different sizes in the 32-bit build */
104.1413 -        jlong*   saveJTargets;
104.1414 -        Cardinal i;
104.1415 -#endif
104.1416 -
104.1417 -        _cache.targets = (*env)->NewLongArray(env, nTargets);
104.1418 -        if (_cache.targets == NULL) {
104.1419 -            _cache.nTargets = 0;
104.1420 -            return False;
104.1421 -        }
104.1422 -
104.1423 -        _cache.targets = (*env)->NewGlobalRef(env, _cache.targets);
104.1424 -        if (_cache.targets == NULL) {
104.1425 -            _cache.nTargets = 0;
104.1426 -            return False;
104.1427 -        }
104.1428 -
104.1429 -        jTargets = (*env)->GetLongArrayElements(env, _cache.targets, &isCopy);
104.1430 -        if (jTargets == NULL) {
104.1431 -            (*env)->DeleteGlobalRef(env, _cache.targets);
104.1432 -            _cache.targets = NULL;
104.1433 -            _cache.nTargets = 0;
104.1434 -            return False;
104.1435 -        }
104.1436 -
104.1437 -#ifdef _LP64
104.1438 -        memcpy(jTargets, targets, nTargets * sizeof(Atom));
104.1439 -#else
104.1440 -        saveJTargets = jTargets;
104.1441 -        for (i = 0; i < nTargets; i++, jTargets++, targets++) {
104.1442 -            *jTargets = (*targets & 0xFFFFFFFFLU);
104.1443 -        }
104.1444 -        jTargets = saveJTargets;
104.1445 -#endif
104.1446 -
104.1447 -        (*env)->ReleaseLongArrayElements(env, _cache.targets, jTargets, 0);
104.1448 -        return True;
104.1449 -    }
104.1450 -
104.1451 -    return False;
104.1452 -}
104.1453 -
104.1454 -
104.1455 -/**
104.1456 - *
104.1457 - */
104.1458 -
104.1459 -static void flush_cache(JNIEnv* env) {
104.1460 -    _cache.w  = (Widget)NULL;
104.1461 -    _cache.dt = (Widget)NULL;
104.1462 -
104.1463 -    (*env)->DeleteGlobalRef(env, _cache.peer);
104.1464 -    _cache.peer = (jobject)NULL;
104.1465 -
104.1466 -    (*env)->DeleteGlobalRef(env, _cache.component);
104.1467 -    _cache.component = (jobject)NULL;
104.1468 -
104.1469 -    if (_cache.dtcpeer != (jobject)NULL) {
104.1470 -        (*env)->DeleteGlobalRef(env, _cache.dtcpeer);
104.1471 -
104.1472 -        _cache.dtcpeer = (jobject)NULL;
104.1473 -    }
104.1474 -
104.1475 -    _cache.nTargets  = (Cardinal)0;
104.1476 -    if (_cache.targets != (jlongArray)NULL) {
104.1477 -        (*env)->DeleteGlobalRef(env, _cache.targets);
104.1478 -        _cache.targets = (jlongArray)NULL;
104.1479 -    }
104.1480 -
104.1481 -    _cache.transfersPending = 0;
104.1482 -    _cache.flushPending     = False;
104.1483 -    _cache.transfer         = (Widget)NULL;
104.1484 -    cacheDropDone(True);
104.1485 -}
104.1486 -
104.1487 -/**
104.1488 - *
104.1489 - */
104.1490 -
104.1491 -static void update_cache(JNIEnv* env, Widget w, Widget dt) {
104.1492 -    if(w != _cache.w) {
104.1493 -        struct ComponentData* cdata   = (struct ComponentData *)NULL;
104.1494 -        Arg                   args[1] =
104.1495 -        {{ XmNuserData, (XtArgVal)&_cache.peer}};
104.1496 -
104.1497 -        flush_cache(env);
104.1498 -
104.1499 -        if (w == (Widget)NULL) return;
104.1500 -
104.1501 -        XtGetValues(w, args, 1);
104.1502 -
104.1503 -        if (JNU_IsNull(env, _cache.peer)) {
104.1504 -            _cache.w = NULL;
104.1505 -
104.1506 -            return;
104.1507 -        }
104.1508 -
104.1509 -        cdata = (struct ComponentData *)
104.1510 -            JNU_GetLongFieldAsPtr(env, _cache.peer, mComponentPeerIDs.pData);
104.1511 -
104.1512 -        if (cdata         == NULL ||
104.1513 -            cdata->widget != w ||
104.1514 -            cdata->dsi    == (DropSitePtr)NULL) {
104.1515 -            _cache.w = NULL;
104.1516 -
104.1517 -            return;
104.1518 -        }
104.1519 -
104.1520 -        _cache.w         = w;
104.1521 -        _cache.component = (*env)->NewGlobalRef(env, cdata->dsi->component);
104.1522 -        _cache.peer      = (*env)->NewGlobalRef(env, _cache.peer);
104.1523 -        /* SECURITY: OK to call this on privileged thread - peer is secure */
104.1524 -        {
104.1525 -            jobject dtcpeer = call_dTCcreate(env);
104.1526 -            if (!JNU_IsNull(env, dtcpeer)) {
104.1527 -                _cache.dtcpeer = (*env)->NewGlobalRef(env, dtcpeer);
104.1528 -                (*env)->DeleteLocalRef(env, dtcpeer);
104.1529 -            } else {
104.1530 -                _cache.dtcpeer = NULL;
104.1531 -            }
104.1532 -        }
104.1533 -
104.1534 -        _cache.transfersPending = 0;
104.1535 -        cacheDropDone(True);
104.1536 -    }
104.1537 -
104.1538 -    if (_cache.w != (Widget)NULL) updateCachedTargets(env, dt);
104.1539 -}
104.1540 -
104.1541 -
104.1542 -/**
104.1543 - *
104.1544 - */
104.1545 -
104.1546 -static void
104.1547 -cacheDropDone(Boolean dropDone) {
104.1548 -    _cache.dropDone = dropDone;
104.1549 -}
104.1550 -
104.1551 -static Boolean
104.1552 -isDropDone() {
104.1553 -    return _cache.dropDone;
104.1554 -}
104.1555 -
104.1556 -/**
104.1557 - *
104.1558 - */
104.1559 -
104.1560 -static jint XmToDnDConstants(unsigned char operations) {
104.1561 -    jint src = java_awt_dnd_DnDConstants_ACTION_NONE;
104.1562 -
104.1563 -    if (operations & XmDROP_MOVE) src |= java_awt_dnd_DnDConstants_ACTION_MOVE;
104.1564 -    if (operations & XmDROP_COPY) src |= java_awt_dnd_DnDConstants_ACTION_COPY;
104.1565 -    if (operations & XmDROP_LINK) src |= java_awt_dnd_DnDConstants_ACTION_LINK;
104.1566 -
104.1567 -    return src;
104.1568 -}
104.1569 -
104.1570 -static unsigned char selectOperation(unsigned char operations) {
104.1571 -    if (operations & XmDROP_MOVE) return XmDROP_MOVE;
104.1572 -    if (operations & XmDROP_COPY) return XmDROP_COPY;
104.1573 -    if (operations & XmDROP_LINK) return XmDROP_LINK;
104.1574 -
104.1575 -    return XmDROP_NOOP;
104.1576 -}
104.1577 -
104.1578 -/**
104.1579 - *
104.1580 - */
104.1581 -
104.1582 -static unsigned char DnDConstantsToXm(jint actions) {
104.1583 -    unsigned char ret = XmDROP_NOOP;
104.1584 -
104.1585 -    if (actions & java_awt_dnd_DnDConstants_ACTION_COPY) ret |= XmDROP_COPY;
104.1586 -    if (actions & java_awt_dnd_DnDConstants_ACTION_MOVE) ret |= XmDROP_MOVE;
104.1587 -    if (actions & java_awt_dnd_DnDConstants_ACTION_LINK) ret |= XmDROP_LINK;
104.1588 -
104.1589 -    return ret;
104.1590 -}
104.1591 -
104.1592 -/**
104.1593 - *
104.1594 - */
104.1595 -
104.1596 -typedef struct DragExitProcStruct {
104.1597 -    XtIntervalId timerId;
104.1598 -    jobject      dtcpeer;     /* global reference */
104.1599 -    jobject      component;   /* global reference */
104.1600 -    jlong        dragContext; /* pointer          */
104.1601 -} DragExitProcStruct;
104.1602 -
104.1603 -static DragExitProcStruct pending_drag_exit_data =
104.1604 -    { (XtIntervalId)0, NULL, NULL, (jlong)0 };
104.1605 -
104.1606 -static void drag_exit_proc(XtPointer client_data, XtIntervalId* id) {
104.1607 -    JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.1608 -
104.1609 -    DASSERT(!JNU_IsNull(env, pending_drag_exit_data.dtcpeer));
104.1610 -    DASSERT(!JNU_IsNull(env, pending_drag_exit_data.component));
104.1611 -    DASSERT(pending_drag_exit_data.dragContext != NULL);
104.1612 -
104.1613 -    if (pending_drag_exit_data.timerId != (XtIntervalId)0) {
104.1614 -        if (id == NULL) {
104.1615 -            XtRemoveTimeOut(pending_drag_exit_data.timerId);
104.1616 -        }
104.1617 -        if (id == NULL || pending_drag_exit_data.timerId == *id) {
104.1618 -
104.1619 -            /* SECURITY: OK to call this on privileged thread -
104.1620 -               peer is secure */
104.1621 -            call_dTCexit(env, pending_drag_exit_data.dtcpeer,
104.1622 -                         pending_drag_exit_data.component,
104.1623 -                         pending_drag_exit_data.dragContext);
104.1624 -
104.1625 -            if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
104.1626 -                (*env)->ExceptionDescribe(env);
104.1627 -                (*env)->ExceptionClear(env);
104.1628 -            }
104.1629 -        }
104.1630 -    }
104.1631 -
104.1632 -    /* cleanup */
104.1633 -    (*env)->DeleteGlobalRef(env, pending_drag_exit_data.dtcpeer);
104.1634 -    (*env)->DeleteGlobalRef(env, pending_drag_exit_data.component);
104.1635 -
104.1636 -    memset(&pending_drag_exit_data, 0, sizeof(DragExitProcStruct));
104.1637 -}
104.1638 -
104.1639 -static void awt_XmDragProc(Widget w, XtPointer closure,
104.1640 -                           XmDragProcCallbackStruct* cbstruct)
104.1641 -{
104.1642 -    JNIEnv* env       = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.1643 -    jobject component = (jobject)NULL;
104.1644 -    jint    src       = java_awt_dnd_DnDConstants_ACTION_NONE;
104.1645 -    jint    usrAction = java_awt_dnd_DnDConstants_ACTION_NONE;
104.1646 -    jint    ret       = java_awt_dnd_DnDConstants_ACTION_NONE;
104.1647 -    unsigned char srcOps = XmDROP_NOOP;
104.1648 -
104.1649 -    /*
104.1650 -     * Fix for BugTraq ID 4395290.
104.1651 -     * We should dispatch any pending java upcall right now
104.1652 -     * to keep the order of upcalls.
104.1653 -     */
104.1654 -    if (pending_drag_exit_data.timerId != (XtIntervalId)0) {
104.1655 -        drag_exit_proc(NULL, NULL);
104.1656 -    }
104.1657 -
104.1658 -    /*
104.1659 -     * Fix for BugTraq ID 4357905.
104.1660 -     * Drop is processed asynchronously on the event dispatch thread.
104.1661 -     * We reject other drop attempts to protect the SunDTCP context
104.1662 -     * from being overwritten by an upcall before the drop is done.
104.1663 -     */
104.1664 -    if (!isDropDone()) {
104.1665 -        cbstruct->operation  = XmDROP_NOOP;
104.1666 -        cbstruct->dropSiteStatus = XmINVALID_DROP_SITE;
104.1667 -        return;
104.1668 -    }
104.1669 -
104.1670 -    if (cbstruct->dragContext == NULL) {
104.1671 -        cbstruct->operation  = XmDROP_NOOP;
104.1672 -        cbstruct->dropSiteStatus = XmINVALID_DROP_SITE;
104.1673 -        return;
104.1674 -    }
104.1675 -
104.1676 -    (*env)->PushLocalFrame(env, 0);
104.1677 -
104.1678 -    /*
104.1679 -     * Fix for BugTraq ID 4285634.
104.1680 -     * If some modifier keys are pressed the Motif toolkit initializes
104.1681 -     * cbstruct->operations this field to the bitwise AND of the
104.1682 -     * XmDragOperations resource of the XmDragContext for this drag operation
104.1683 -     * and the drop action corresponding to the current modifiers state.
104.1684 -     * We need to determine the drag operations supported by the drag source, so
104.1685 -     * we have to get XmNdragOperations value of the XmDragSource.
104.1686 -     */
104.1687 -    XtVaGetValues(cbstruct->dragContext, XmNdragOperations, &srcOps, NULL);
104.1688 -    src = XmToDnDConstants(srcOps);
104.1689 -    usrAction = XmToDnDConstants(selectOperation(cbstruct->operations));
104.1690 -
104.1691 -    update_cache(env, w, cbstruct->dragContext);
104.1692 -
104.1693 -    if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.1694 -        flush_cache(env);
104.1695 -        (*env)->ExceptionDescribe(env);
104.1696 -        (*env)->ExceptionClear(env);
104.1697 -        goto wayout;
104.1698 -    }
104.1699 -
104.1700 -    switch (cbstruct->reason) {
104.1701 -    case XmCR_DROP_SITE_ENTER_MESSAGE: {
104.1702 -
104.1703 -        /* SECURITY: OK to call this on privileged thread -
104.1704 -           peer is secure */
104.1705 -        ret = call_dTCenter(env, _cache.dtcpeer, _cache.component,
104.1706 -                            cbstruct->x, cbstruct->y,
104.1707 -                            usrAction, src,
104.1708 -                            _cache.targets,ptr_to_jlong(cbstruct->dragContext));
104.1709 -
104.1710 -        if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.1711 -            flush_cache(env);
104.1712 -            (*env)->ExceptionDescribe(env);
104.1713 -            (*env)->ExceptionClear(env);
104.1714 -        }
104.1715 -    }
104.1716 -    break;
104.1717 -
104.1718 -    case XmCR_DROP_SITE_LEAVE_MESSAGE: {
104.1719 -
104.1720 -        DASSERT(pending_drag_exit_data.timerId == (XtIntervalId)0);
104.1721 -        DASSERT(JNU_IsNull(env, pending_drag_exit_data.dtcpeer));
104.1722 -        DASSERT(JNU_IsNull(env, pending_drag_exit_data.component));
104.1723 -        DASSERT(pending_drag_exit_data.dragContext == (jlong)0);
104.1724 -
104.1725 -        DASSERT(!JNU_IsNull(env, _cache.dtcpeer));
104.1726 -        DASSERT(!JNU_IsNull(env, _cache.component));
104.1727 -        DASSERT(cbstruct->dragContext != NULL);
104.1728 -
104.1729 -        pending_drag_exit_data.dtcpeer =
104.1730 -            (*env)->NewGlobalRef(env, _cache.dtcpeer);
104.1731 -        pending_drag_exit_data.component =
104.1732 -            (*env)->NewGlobalRef(env, _cache.component);
104.1733 -        pending_drag_exit_data.dragContext =
104.1734 -            ptr_to_jlong(cbstruct->dragContext);
104.1735 -
104.1736 -        /*
104.1737 -         * Fix for BugTraq ID 4395290.
104.1738 -         * Postpone upcall to java, so that we can abort it in case
104.1739 -         * if drop immediatelly follows.
104.1740 -         */
104.1741 -        if (!JNU_IsNull(env, pending_drag_exit_data.dtcpeer) &&
104.1742 -            !JNU_IsNull(env, pending_drag_exit_data.component)) {
104.1743 -            pending_drag_exit_data.timerId =
104.1744 -                XtAppAddTimeOut(awt_appContext, 0, drag_exit_proc, NULL);
104.1745 -            DASSERT(pending_drag_exit_data.timerId != (XtIntervalId)0);
104.1746 -        } else {
104.1747 -            JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
104.1748 -            if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
104.1749 -                (*env)->ExceptionDescribe(env);
104.1750 -                (*env)->ExceptionClear(env);
104.1751 -            }
104.1752 -            if (!JNU_IsNull(env, pending_drag_exit_data.dtcpeer)) {
104.1753 -                (*env)->DeleteGlobalRef(env, pending_drag_exit_data.dtcpeer);
104.1754 -            }
104.1755 -            if (!JNU_IsNull(env, pending_drag_exit_data.component)) {
104.1756 -                (*env)->DeleteGlobalRef(env, pending_drag_exit_data.component);
104.1757 -            }
104.1758 -            memset(&pending_drag_exit_data, 0, sizeof(DragExitProcStruct));
104.1759 -        }
104.1760 -
104.1761 -        ret = java_awt_dnd_DnDConstants_ACTION_NONE;
104.1762 -
104.1763 -        /* now cleanup */
104.1764 -
104.1765 -        flush_cache(env);
104.1766 -    }
104.1767 -    break;
104.1768 -
104.1769 -    case XmCR_DROP_SITE_MOTION_MESSAGE: {
104.1770 -
104.1771 -        /* SECURITY: OK to call this on privileged thread -
104.1772 -           peer is secure */
104.1773 -        ret = call_dTCmotion(env, _cache.dtcpeer, _cache.component,
104.1774 -                             cbstruct->x, cbstruct->y,
104.1775 -                             usrAction, src,
104.1776 -                             _cache.targets,
104.1777 -                             ptr_to_jlong(cbstruct->dragContext));
104.1778 -
104.1779 -        if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.1780 -            flush_cache(env);
104.1781 -            (*env)->ExceptionDescribe(env);
104.1782 -            (*env)->ExceptionClear(env);
104.1783 -        }
104.1784 -
104.1785 -    }
104.1786 -    break;
104.1787 -
104.1788 -    case XmCR_OPERATION_CHANGED: {
104.1789 -
104.1790 -        /* SECURITY: OK to call this on privileged thread -
104.1791 -           peer is secure */
104.1792 -        ret = call_dTCmotion(env, _cache.dtcpeer, _cache.component,
104.1793 -                             cbstruct->x, cbstruct->y,
104.1794 -                             usrAction, src,
104.1795 -                             _cache.targets,
104.1796 -                             ptr_to_jlong(cbstruct->dragContext));
104.1797 -
104.1798 -        if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.1799 -            flush_cache(env);
104.1800 -            (*env)->ExceptionDescribe(env);
104.1801 -            (*env)->ExceptionClear(env);
104.1802 -        }
104.1803 -
104.1804 -    }
104.1805 -    break;
104.1806 -
104.1807 -    default: break;
104.1808 -    }
104.1809 -
104.1810 - wayout:
104.1811 -
104.1812 -    /*
104.1813 -     * Fix for BugTraq ID 4285634.
104.1814 -     * If some modifier keys are pressed the Motif toolkit initializes
104.1815 -     * cbstruct->operations this field to the bitwise AND of the
104.1816 -     * XmDragOperations resource of the XmDragContext for this drag operation
104.1817 -     * and the drop action corresponding to the current modifiers state.
104.1818 -     * We should allow the drop target to select a drop action independent of
104.1819 -     * the current modifiers state.
104.1820 -     */
104.1821 -    cbstruct->operation  = DnDConstantsToXm(ret);
104.1822 -
104.1823 -    if (cbstruct->reason != XmCR_DROP_SITE_LEAVE_MESSAGE) {
104.1824 -        Arg arg;
104.1825 -        arg.name = XmNdropSiteOperations;
104.1826 -        arg.value = (XtArgVal)cbstruct->operation;
104.1827 -
104.1828 -        XmDropSiteUpdate(w, &arg, 1);
104.1829 -    }
104.1830 -
104.1831 -    if (ret != java_awt_dnd_DnDConstants_ACTION_NONE) {
104.1832 -        cbstruct->dropSiteStatus = XmVALID_DROP_SITE;
104.1833 -    }  else {
104.1834 -        cbstruct->dropSiteStatus = XmINVALID_DROP_SITE;
104.1835 -    }
104.1836 -
104.1837 -    (*env)->PopLocalFrame(env, NULL);
104.1838 -}
104.1839 -
104.1840 -static void drop_failure_cleanup(JNIEnv* env, Widget dragContext) {
104.1841 -    Arg arg;
104.1842 -
104.1843 -    DASSERT(dragContext != NULL);
104.1844 -    _cache.transfer = NULL;
104.1845 -    _cache.dropAction = XmDROP_NOOP;
104.1846 -
104.1847 -    arg.name  = XmNtransferStatus;
104.1848 -    arg.value = (XtArgVal)XmTRANSFER_FAILURE;
104.1849 -    XmDropTransferStart(dragContext, &arg, 1);
104.1850 -
104.1851 -    /* Flush here, since awt_XmTransferProc won't be called. */
104.1852 -    flush_cache(env);
104.1853 -}
104.1854 -
104.1855 -/**
104.1856 - *
104.1857 - */
104.1858 -
104.1859 -static void awt_XmDropProc(Widget w, XtPointer closure,
104.1860 -                           XmDropProcCallbackStruct* cbstruct)
104.1861 -{
104.1862 -    JNIEnv*       env       = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.1863 -    jint          src       = java_awt_dnd_DnDConstants_ACTION_NONE;
104.1864 -    unsigned char operation = selectOperation(cbstruct->operations);
104.1865 -    unsigned char srcOps = XmDROP_NOOP;
104.1866 -    unsigned char dstOps = XmDROP_NOOP;
104.1867 -    Arg           arg;
104.1868 -    Boolean       sourceIsExternal = False;
104.1869 -
104.1870 -    arg.name = XmNdropSiteOperations;
104.1871 -    arg.value = (XtArgVal)&dstOps;
104.1872 -    XmDropSiteRetrieve(w, &arg, 1);
104.1873 -    arg.value = (XtArgVal)(XmDROP_COPY | XmDROP_MOVE | XmDROP_LINK);
104.1874 -    XmDropSiteUpdate(w, &arg, 1);
104.1875 -
104.1876 -    /*
104.1877 -     * Fix for BugTraq ID 4357905.
104.1878 -     * Drop is processed asynchronously on the event dispatch thread.
104.1879 -     * We reject other drop attempts to protect the SunDTCP context
104.1880 -     * from being overwritten by an upcall before the drop is done.
104.1881 -     */
104.1882 -    if (!isDropDone()) {
104.1883 -        return;
104.1884 -    }
104.1885 -
104.1886 -    if (cbstruct->dragContext == NULL) {
104.1887 -        cbstruct->operation  = XmDROP_NOOP;
104.1888 -        cbstruct->dropSiteStatus = XmINVALID_DROP_SITE;
104.1889 -        return;
104.1890 -    }
104.1891 -
104.1892 -    /*
104.1893 -     * Fix for BugTraq ID 4492640.
104.1894 -     * Because of the Motif bug #4528191 XmNdragOperations resource is always
104.1895 -     * equal to XmDROP_MOVE | XmDROP_COPY when the drag source is external.
104.1896 -     * The workaround for this bug is to assume that an external drag source
104.1897 -     * supports all drop actions.
104.1898 -     */
104.1899 -    XtVaGetValues(cbstruct->dragContext,
104.1900 -                  XmNsourceIsExternal, &sourceIsExternal, NULL);
104.1901 -
104.1902 -    if (sourceIsExternal) {
104.1903 -        srcOps = XmDROP_LINK | XmDROP_MOVE | XmDROP_COPY;
104.1904 -    } else {
104.1905 -        /*
104.1906 -         * Fix for BugTraq ID 4285634.
104.1907 -         * If some modifier keys are pressed the Motif toolkit initializes
104.1908 -         * cbstruct->operations to the bitwise AND of the
104.1909 -         * XmDragOperations resource of the XmDragContext for this drag operation
104.1910 -         * and the drop action corresponding to the current modifiers state.
104.1911 -         * We need to determine the drag operations supported by the drag source, so
104.1912 -         * we have to get XmNdragOperations value of the XmDragSource.
104.1913 -         */
104.1914 -        XtVaGetValues(cbstruct->dragContext, XmNdragOperations, &srcOps, NULL);
104.1915 -    }
104.1916 -
104.1917 -    src = XmToDnDConstants(srcOps);
104.1918 -
104.1919 -    if ((srcOps & dstOps) == 0) {
104.1920 -        cbstruct->operation  = XmDROP_NOOP;
104.1921 -        cbstruct->dropSiteStatus = XmINVALID_DROP_SITE;
104.1922 -        drop_failure_cleanup(env, cbstruct->dragContext);
104.1923 -        return;
104.1924 -    }
104.1925 -
104.1926 -    (*env)->PushLocalFrame(env, 0);
104.1927 -
104.1928 -    update_cache(env, w, cbstruct->dragContext);
104.1929 -
104.1930 -    cacheDropDone(False);
104.1931 -
104.1932 -    if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.1933 -        (*env)->ExceptionDescribe(env);
104.1934 -        (*env)->ExceptionClear(env);
104.1935 -        (*env)->PopLocalFrame(env, NULL);
104.1936 -        drop_failure_cleanup(env, cbstruct->dragContext);
104.1937 -        return;
104.1938 -    }
104.1939 -
104.1940 -    /*
104.1941 -     * Fix for BugTraq ID 4395290.
104.1942 -     * Abort a pending upcall to dragExit.
104.1943 -     */
104.1944 -    pending_drag_exit_data.timerId = (XtIntervalId)0;
104.1945 -
104.1946 -    /* SECURITY: OK to call this on privileged thread - peer is secure */
104.1947 -    call_dTCdrop(env, _cache.dtcpeer, _cache.component,
104.1948 -                 cbstruct->x, cbstruct->y,
104.1949 -                 XmToDnDConstants(operation), src, _cache.targets,
104.1950 -                 ptr_to_jlong(cbstruct->dragContext));
104.1951 -
104.1952 -    if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.1953 -        flush_cache(env);
104.1954 -        (*env)->ExceptionDescribe(env);
104.1955 -        (*env)->ExceptionClear(env);
104.1956 -    }
104.1957 -    (*env)->PopLocalFrame(env, NULL);
104.1958 -}
104.1959 -
104.1960 -/**
104.1961 - *
104.1962 - */
104.1963 -
104.1964 -static void awt_XmTransferProc(Widget w, XtPointer closure, Atom* selection,
104.1965 -                               Atom* type, XtPointer value,
104.1966 -                               unsigned long* length, int32_t* format)
104.1967 -{
104.1968 -    JNIEnv*  env   = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.1969 -    Atom     req   = (Atom)closure;
104.1970 -    Display* dpy   = XtDisplayOfObject(w);
104.1971 -    jobject  tName = NULL;
104.1972 -
104.1973 -    /*
104.1974 -     * Note: this method is only called to transfer data between clients
104.1975 -     * in different JVM's or native apps. For Intra-JVM transfers the peer
104.1976 -     * code shares the sources Transferable with the destination.
104.1977 -     */
104.1978 -
104.1979 -    if (_cache.w == (Widget)NULL || _cache.transfer != w) {
104.1980 -        if (value != NULL) {
104.1981 -            XtFree(value);
104.1982 -            value = NULL;
104.1983 -        }
104.1984 -        /* we have already cleaned up ... */
104.1985 -        return;
104.1986 -    }
104.1987 -
104.1988 -    (*env)->PushLocalFrame(env, 0);
104.1989 -
104.1990 -    if (*type == None || *type == XT_CONVERT_FAIL) {
104.1991 -        /* SECURITY: OK to call this on privileged thread - peer is secure
104.1992 -         */
104.1993 -        call_dTCtxFailed(env, _cache.dtcpeer, (jlong)req);
104.1994 -    } else {
104.1995 -        switch (*format) {
104.1996 -        case  8:
104.1997 -        case 16:
104.1998 -        case 32: {
104.1999 -            jsize size = (*length <= INT_MAX) ? (jsize)*length : INT_MAX;
104.2000 -            jbyteArray arry = (*env)->NewByteArray(env, size);
104.2001 -
104.2002 -            if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2003 -                (*env)->ExceptionDescribe(env);
104.2004 -                (*env)->ExceptionClear(env);
104.2005 -
104.2006 -                /* SECURITY: OK to call this on privileged thread -
104.2007 -                   peer is secure */
104.2008 -                call_dTCtxFailed(env, _cache.dtcpeer, (jlong)req);
104.2009 -
104.2010 -                goto wayout;
104.2011 -            }
104.2012 -
104.2013 -            (*env)->SetByteArrayRegion(env, arry, 0, size, (jbyte*)value);
104.2014 -            if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2015 -                (*env)->ExceptionDescribe(env);
104.2016 -                (*env)->ExceptionClear(env);
104.2017 -
104.2018 -                /* SECURITY: OK to call this on privileged thread -
104.2019 -                   peer is secure */
104.2020 -                call_dTCtxFailed(env, _cache.dtcpeer, (jlong)req);
104.2021 -                goto wayout;
104.2022 -            }
104.2023 -
104.2024 -            arry = (*env)->NewGlobalRef(env, arry);
104.2025 -
104.2026 -            if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2027 -                (*env)->ExceptionDescribe(env);
104.2028 -                (*env)->ExceptionClear(env);
104.2029 -            }
104.2030 -
104.2031 -            {
104.2032 -                char* tn = XGetAtomName(dpy, *type);
104.2033 -
104.2034 -                tName = (*env)->NewStringUTF(env, (const char *)tn);
104.2035 -
104.2036 -                if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2037 -                    (*env)->ExceptionDescribe(env);
104.2038 -                    (*env)->ExceptionClear(env);
104.2039 -                }
104.2040 -
104.2041 -                XFree((void *)tn);
104.2042 -            }
104.2043 -
104.2044 -            /* SECURITY: OK to call this on privileged thread - peer is
104.2045 -               secure */
104.2046 -            call_dTCnewData(env, _cache.dtcpeer, (jlong)req, tName, arry);
104.2047 -
104.2048 -            if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2049 -                (*env)->ExceptionDescribe(env);
104.2050 -                (*env)->ExceptionClear(env);
104.2051 -            }
104.2052 -        }
104.2053 -
104.2054 -        default:
104.2055 -            break;
104.2056 -        }
104.2057 -    }
104.2058 -
104.2059 - wayout:
104.2060 -    if (value != NULL) {
104.2061 -        XtFree(value);
104.2062 -        value = NULL;
104.2063 -    }
104.2064 -
104.2065 -    _cache.transfersPending--;
104.2066 -    while (_cache.transfersPending == 0 && !isDropDone()) {
104.2067 -        AWT_WAIT(0);
104.2068 -    }
104.2069 -
104.2070 -    if (isDropDone() && _cache.flushPending) {
104.2071 -        flush_cache(env);
104.2072 -    }
104.2073 -
104.2074 -    (*env)->PopLocalFrame(env, NULL);
104.2075 -}
104.2076 -
104.2077 -/**
104.2078 - *
104.2079 - */
104.2080 -
104.2081 -static void awt_XmDragEnterProc(Widget w, XtPointer closure,
104.2082 -                                XmDropSiteEnterCallbackStruct* cbstruct)
104.2083 -{
104.2084 -    JNIEnv*  env   = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.2085 -    jobject  this  = (jobject)closure;
104.2086 -
104.2087 -    /*  This should only be valid, but Im leaving this part of the old code */
104.2088 -    jboolean valid = cbstruct->dropSiteStatus == XmVALID_DROP_SITE
104.2089 -        ? JNI_TRUE : JNI_FALSE;
104.2090 -
104.2091 -    if (valid == JNI_TRUE) {
104.2092 -        /*
104.2093 -         * Workaround for Motif bug id #4457656.
104.2094 -         * Pointer coordinates passed in cbstruct are incorrect.
104.2095 -         * We have to make a round-trip query.
104.2096 -         */
104.2097 -        Window rootWindow, childWindow;
104.2098 -        int32_t xw, yw, xr, yr;
104.2099 -        uint32_t modifiers;
104.2100 -
104.2101 -        XQueryPointer(awt_display, XtWindow(w),
104.2102 -                      &rootWindow, &childWindow, &xr, &yr, &xw, &yw, &modifiers);
104.2103 -
104.2104 -        (*env)->PushLocalFrame(env, 0);
104.2105 -
104.2106 -        /* SECURITY: OK to call this on privileged thread - peer is secure */
104.2107 -        call_dSCenter(env, this, XmToDnDConstants(cbstruct->operation),
104.2108 -                      convertModifiers(modifiers), xr, yr);
104.2109 -
104.2110 -        if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2111 -            (*env)->ExceptionDescribe(env);
104.2112 -            (*env)->ExceptionClear(env);
104.2113 -        }
104.2114 -
104.2115 -        (*env)->PopLocalFrame(env, NULL);
104.2116 -    }
104.2117 -}
104.2118 -
104.2119 -/**
104.2120 - *
104.2121 - */
104.2122 -
104.2123 -static void awt_XmDragMotionProc(Widget w, XtPointer closure,
104.2124 -                                 XmDragMotionCallbackStruct* cbstruct)
104.2125 -{
104.2126 -    JNIEnv*  env   = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.2127 -    jobject  this  = (jobject)closure;
104.2128 -
104.2129 -    /*  This should only be valid, but Im leaving this part of the old code */
104.2130 -    jboolean valid = cbstruct->dropSiteStatus == XmVALID_DROP_SITE
104.2131 -        ? JNI_TRUE : JNI_FALSE;
104.2132 -    Window rootWindow, childWindow;
104.2133 -    int32_t xw, yw, xr, yr;
104.2134 -    uint32_t modifiers;
104.2135 -
104.2136 -    XQueryPointer(awt_display, XtWindow(w),
104.2137 -                  &rootWindow, &childWindow, &xr, &yr, &xw, &yw, &modifiers);
104.2138 -    /*
104.2139 -     * Fix for 4285634.
104.2140 -     * Use the cached modifiers state, since the directly queried state can
104.2141 -     * differ from the one associated with this dnd notification.
104.2142 -     */
104.2143 -    modifiers = ((XmDragContext)w)->drag.lastEventState;
104.2144 -    if (xr != x_root || yr != y_root) {
104.2145 -        call_dSCmouseMoved(env, this, XmToDnDConstants(cbstruct->operation),
104.2146 -                           convertModifiers(modifiers), xr, yr);
104.2147 -
104.2148 -        if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
104.2149 -            (*env)->ExceptionDescribe(env);
104.2150 -            (*env)->ExceptionClear(env);
104.2151 -        }
104.2152 -
104.2153 -        x_root = xr;
104.2154 -        y_root = yr;
104.2155 -    }
104.2156 -
104.2157 -    if (valid == JNI_TRUE) {
104.2158 -
104.2159 -        (*env)->PushLocalFrame(env, 0);
104.2160 -
104.2161 -        /* SECURITY: OK to call this on privileged thread - peer is secure */
104.2162 -        call_dSCmotion(env, this, XmToDnDConstants(cbstruct->operation),
104.2163 -                       convertModifiers(modifiers), xr, yr);
104.2164 -
104.2165 -        if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2166 -            (*env)->ExceptionDescribe(env);
104.2167 -            (*env)->ExceptionClear(env);
104.2168 -        }
104.2169 -
104.2170 -        (*env)->PopLocalFrame(env, NULL);
104.2171 -    } else {
104.2172 -        (*env)->PushLocalFrame(env, 0);
104.2173 -
104.2174 -        /* SECURITY: OK to call this on privileged thread - peer is secure */
104.2175 -        call_dSCexit(env, this, xr, yr);
104.2176 -
104.2177 -        if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2178 -            (*env)->ExceptionDescribe(env);
104.2179 -            (*env)->ExceptionClear(env);
104.2180 -        }
104.2181 -
104.2182 -        (*env)->PopLocalFrame(env, NULL);
104.2183 -    }
104.2184 -}
104.2185 -
104.2186 -/**
104.2187 - *
104.2188 - */
104.2189 -
104.2190 -static void awt_XmDragLeaveProc(Widget w, XtPointer closure,
104.2191 -                                XmDropSiteLeaveCallbackStruct* cbstruct)
104.2192 -{
104.2193 -    JNIEnv* env  = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.2194 -    jobject this = (jobject)closure;
104.2195 -    Window rootWindow, childWindow;
104.2196 -    int32_t xw, yw, xr, yr;
104.2197 -    uint32_t modifiers;
104.2198 -
104.2199 -    XQueryPointer(XtDisplay(w), XtWindow(w),
104.2200 -                  &rootWindow, &childWindow, &xr, &yr, &xw, &yw, &modifiers);
104.2201 -
104.2202 -    (*env)->PushLocalFrame(env, 0);
104.2203 -
104.2204 -    /* SECURITY: OK to call this on privileged thread - peer is secure */
104.2205 -    call_dSCexit(env, this, xr, yr);
104.2206 -
104.2207 -    if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2208 -        (*env)->ExceptionDescribe(env);
104.2209 -        (*env)->ExceptionClear(env);
104.2210 -    }
104.2211 -
104.2212 -    (*env)->PopLocalFrame(env, NULL);
104.2213 -}
104.2214 -
104.2215 -/**
104.2216 - *
104.2217 - */
104.2218 -
104.2219 -static void awt_XmDropOperationChangedProc(Widget w, XtPointer closure,
104.2220 -                                           XmDropStartCallbackStruct* cbstruct)
104.2221 -{
104.2222 -    JNIEnv*  env   = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.2223 -    jobject  this  = (jobject)closure;
104.2224 -    Window rootWindow, childWindow;
104.2225 -    int32_t xw, yw, xr, yr;
104.2226 -    uint32_t modifiers;
104.2227 -
104.2228 -    XQueryPointer(XtDisplay(w), XtWindow(w),
104.2229 -                  &rootWindow, &childWindow, &xr, &yr, &xw, &yw, &modifiers);
104.2230 -
104.2231 -    (*env)->PushLocalFrame(env, 0);
104.2232 -
104.2233 -
104.2234 -    /* SECURITY: OK to call this on privileged thread - peer is secure */
104.2235 -    call_dSCchanged(env, this, XmToDnDConstants(cbstruct->operation),
104.2236 -                    convertModifiers(modifiers), xr, yr);
104.2237 -
104.2238 -    if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2239 -        (*env)->ExceptionDescribe(env);
104.2240 -        (*env)->ExceptionClear(env);
104.2241 -    }
104.2242 -
104.2243 -    (*env)->PopLocalFrame(env, NULL);
104.2244 -}
104.2245 -
104.2246 -/**
104.2247 - *
104.2248 - */
104.2249 -
104.2250 -static void awt_XmDropFinishProc(Widget w, XtPointer closure,
104.2251 -                                 XmDropFinishCallbackStruct* cbstruct)
104.2252 -{
104.2253 -    JNIEnv* env  = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
104.2254 -    jobject this = (jobject)closure;
104.2255 -    unsigned char completionStatus = cbstruct->completionStatus;
104.2256 -    jint dropAction = XmToDnDConstants(cbstruct->operation);
104.2257 -    Window rootWindow, childWindow;
104.2258 -    int32_t xw, yw, xr, yr;
104.2259 -    uint32_t modifiers;
104.2260 -
104.2261 -    XQueryPointer(XtDisplay(w), XtWindow(w),
104.2262 -                  &rootWindow, &childWindow, &xr, &yr, &xw, &yw, &modifiers);
104.2263 -
104.2264 -    /* cleanup */
104.2265 -
104.2266 -    if (_cache.transfer == NULL) {
104.2267 -        dropAction = _cache.dropAction;
104.2268 -    }
104.2269 -
104.2270 -    _cache.dropAction = java_awt_dnd_DnDConstants_ACTION_NONE;
104.2271 -    _cache.win = None;
104.2272 -    _cache.state = 0;
104.2273 -    XtRemoveEventHandler(w, ButtonReleaseMask, False,
104.2274 -                         dragsource_track_release, NULL);
104.2275 -
104.2276 -    /* SECURITY: OK to call this on privileged thread - peer is secure */
104.2277 -    call_dSCddfinished(env, this, completionStatus, dropAction, xr, yr);
104.2278 -
104.2279 -    if (!JNU_IsNull(env, (*env)->ExceptionOccurred(env))) {
104.2280 -        (*env)->ExceptionDescribe(env);
104.2281 -        (*env)->ExceptionClear(env);
104.2282 -    }
104.2283 -
104.2284 -    awt_cleanupConvertDataContext(env, MOTIF_DROP_ATOM);
104.2285 -}
   105.1 --- a/src/solaris/native/sun/awt/awt_XmDnD.h	Wed Sep 17 13:45:37 2008 -0700
   105.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   105.3 @@ -1,41 +0,0 @@
   105.4 -/*
   105.5 - * Copyright 1997-2001 Sun Microsystems, Inc.  All Rights Reserved.
   105.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   105.7 - *
   105.8 - * This code is free software; you can redistribute it and/or modify it
   105.9 - * under the terms of the GNU General Public License version 2 only, as
  105.10 - * published by the Free Software Foundation.  Sun designates this
  105.11 - * particular file as subject to the "Classpath" exception as provided
  105.12 - * by Sun in the LICENSE file that accompanied this code.
  105.13 - *
  105.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  105.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  105.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  105.17 - * version 2 for more details (a copy is included in the LICENSE file that
  105.18 - * accompanied this code).
  105.19 - *
  105.20 - * You should have received a copy of the GNU General Public License version
  105.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  105.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  105.23 - *
  105.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  105.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  105.26 - * have any questions.
  105.27 - */
  105.28 -
  105.29 -#include <Xm/Display.h>
  105.30 -#include <Xm/DropSMgr.h>
  105.31 -#include <Xm/DropTrans.h>
  105.32 -#include <inttypes.h>
  105.33 -
  105.34 -/**
  105.35 - *
  105.36 - */
  105.37 -
  105.38 -typedef struct DropSiteInfo {
  105.39 -        Widget                  tlw;
  105.40 -
  105.41 -        jobject                 component;
  105.42 -        Boolean                 isComposite;
  105.43 -        uint32_t                dsCnt;
  105.44 -} DropSiteInfo;
   106.1 --- a/src/solaris/native/sun/awt/awt_dnd.c	Wed Sep 17 13:45:37 2008 -0700
   106.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   106.3 @@ -1,887 +0,0 @@
   106.4 -/*
   106.5 - * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
   106.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   106.7 - *
   106.8 - * This code is free software; you can redistribute it and/or modify it
   106.9 - * under the terms of the GNU General Public License version 2 only, as
  106.10 - * published by the Free Software Foundation.  Sun designates this
  106.11 - * particular file as subject to the "Classpath" exception as provided
  106.12 - * by Sun in the LICENSE file that accompanied this code.
  106.13 - *
  106.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  106.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  106.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  106.17 - * version 2 for more details (a copy is included in the LICENSE file that
  106.18 - * accompanied this code).
  106.19 - *
  106.20 - * You should have received a copy of the GNU General Public License version
  106.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  106.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  106.23 - *
  106.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  106.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  106.26 - * have any questions.
  106.27 - */
  106.28 -
  106.29 -#ifdef HEADLESS
  106.30 -    #error This file should not be included in headless library
  106.31 -#endif
  106.32 -
  106.33 -#include "awt_dnd.h"
  106.34 -
  106.35 -#include "awt_p.h"
  106.36 -
  106.37 -#include "java_awt_dnd_DnDConstants.h"
  106.38 -
  106.39 -/* Shared atoms */
  106.40 -
  106.41 -Atom XA_WM_STATE;
  106.42 -Atom XA_DELETE;
  106.43 -
  106.44 -/* XDnD atoms */
  106.45 -
  106.46 -Atom XA_XdndAware;
  106.47 -Atom XA_XdndProxy;
  106.48 -
  106.49 -Atom XA_XdndEnter;
  106.50 -Atom XA_XdndPosition;
  106.51 -Atom XA_XdndLeave;
  106.52 -Atom XA_XdndDrop;
  106.53 -Atom XA_XdndStatus;
  106.54 -Atom XA_XdndFinished;
  106.55 -
  106.56 -Atom XA_XdndTypeList;
  106.57 -Atom XA_XdndSelection;
  106.58 -
  106.59 -Atom XA_XdndActionCopy;
  106.60 -Atom XA_XdndActionMove;
  106.61 -Atom XA_XdndActionLink;
  106.62 -Atom XA_XdndActionAsk;
  106.63 -Atom XA_XdndActionPrivate;
  106.64 -Atom XA_XdndActionList;
  106.65 -
  106.66 -/* Motif DnD atoms */
  106.67 -
  106.68 -Atom _XA_MOTIF_DRAG_WINDOW;
  106.69 -Atom _XA_MOTIF_DRAG_TARGETS;
  106.70 -Atom _XA_MOTIF_DRAG_INITIATOR_INFO;
  106.71 -Atom _XA_MOTIF_DRAG_RECEIVER_INFO;
  106.72 -Atom _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
  106.73 -Atom _XA_MOTIF_ATOM_0;
  106.74 -Atom XA_XmTRANSFER_SUCCESS;
  106.75 -Atom XA_XmTRANSFER_FAILURE;
  106.76 -
  106.77 -unsigned char MOTIF_BYTE_ORDER = 0;
  106.78 -
  106.79 -static Window awt_root_window = None;
  106.80 -
  106.81 -static Boolean
  106.82 -init_atoms(Display* display) {
  106.83 -    struct atominit {
  106.84 -        Atom *atomptr;
  106.85 -        const char *name;
  106.86 -    };
  106.87 -
  106.88 -    /* Add new atoms to this list */
  106.89 -    static struct atominit atom_list[] = {
  106.90 -        /* Shared atoms */
  106.91 -        { &XA_WM_STATE,                     "WM_STATE"                     },
  106.92 -        { &XA_DELETE,                       "DELETE"                       },
  106.93 -
  106.94 -        /* XDnD atoms */
  106.95 -        { &XA_XdndAware,                    "XdndAware"                    },
  106.96 -        { &XA_XdndProxy,                    "XdndProxy"                    },
  106.97 -        { &XA_XdndEnter,                    "XdndEnter"                    },
  106.98 -        { &XA_XdndPosition,                 "XdndPosition"                 },
  106.99 -        { &XA_XdndLeave,                    "XdndLeave"                    },
 106.100 -        { &XA_XdndDrop,                     "XdndDrop"                     },
 106.101 -        { &XA_XdndStatus,                   "XdndStatus"                   },
 106.102 -        { &XA_XdndFinished,                 "XdndFinished"                 },
 106.103 -        { &XA_XdndTypeList,                 "XdndTypeList"                 },
 106.104 -        { &XA_XdndSelection,                "XdndSelection"                },
 106.105 -        { &XA_XdndActionCopy,               "XdndActionCopy"               },
 106.106 -        { &XA_XdndActionMove,               "XdndActionMove"               },
 106.107 -        { &XA_XdndActionLink,               "XdndActionLink"               },
 106.108 -        { &XA_XdndActionAsk,                "XdndActionAsk"                },
 106.109 -        { &XA_XdndActionPrivate,            "XdndActionPrivate"            },
 106.110 -        { &XA_XdndActionList,               "XdndActionList"               },
 106.111 -
 106.112 -        /* Motif DnD atoms */
 106.113 -        { &_XA_MOTIF_DRAG_WINDOW,           "_MOTIF_DRAG_WINDOW"           },
 106.114 -        { &_XA_MOTIF_DRAG_TARGETS,          "_MOTIF_DRAG_TARGETS"          },
 106.115 -        { &_XA_MOTIF_DRAG_INITIATOR_INFO,   "_MOTIF_DRAG_INITIATOR_INFO"   },
 106.116 -        { &_XA_MOTIF_DRAG_RECEIVER_INFO,    "_MOTIF_DRAG_RECEIVER_INFO"    },
 106.117 -        { &_XA_MOTIF_DRAG_AND_DROP_MESSAGE, "_MOTIF_DRAG_AND_DROP_MESSAGE" },
 106.118 -        { &_XA_MOTIF_ATOM_0,                "_MOTIF_ATOM_0"                },
 106.119 -        { &XA_XmTRANSFER_SUCCESS,           "XmTRANSFER_SUCCESS"           },
 106.120 -        { &XA_XmTRANSFER_FAILURE,           "XmTRANSFER_FAILURE"           }
 106.121 -    };
 106.122 -
 106.123 -#define ATOM_LIST_LENGTH (sizeof(atom_list)/sizeof(atom_list[0]))
 106.124 -
 106.125 -    const char *names[ATOM_LIST_LENGTH];
 106.126 -    Atom atoms[ATOM_LIST_LENGTH];
 106.127 -    Status status;
 106.128 -    size_t i;
 106.129 -
 106.130 -    /* Fill the array of atom names */
 106.131 -    for (i = 0; i < ATOM_LIST_LENGTH; ++i) {
 106.132 -        names[i] = atom_list[i].name;
 106.133 -    }
 106.134 -
 106.135 -    DTRACE_PRINT2("%s:%d initializing atoms ... ", __FILE__, __LINE__);
 106.136 -
 106.137 -    status = XInternAtoms(awt_display, (char**)names, ATOM_LIST_LENGTH,
 106.138 -                          False, atoms);
 106.139 -    if (status == 0) {
 106.140 -        DTRACE_PRINTLN("failed");
 106.141 -        return False;
 106.142 -    }
 106.143 -
 106.144 -    /* Store returned atoms into corresponding global variables */
 106.145 -    DTRACE_PRINTLN("ok");
 106.146 -    for (i = 0; i < ATOM_LIST_LENGTH; ++i) {
 106.147 -        *atom_list[i].atomptr = atoms[i];
 106.148 -    }
 106.149 -
 106.150 -    return True;
 106.151 -#undef ATOM_LIST_LENGTH
 106.152 -}
 106.153 -
 106.154 -/*
 106.155 - * NOTE: must be called after awt_root_shell is created and realized.
 106.156 - */
 106.157 -Boolean
 106.158 -awt_dnd_init(Display* display) {
 106.159 -    static Boolean inited = False;
 106.160 -
 106.161 -    if (!inited) {
 106.162 -        Boolean atoms_inited = False;
 106.163 -        Boolean ds_inited = False;
 106.164 -        unsigned int value = 1;
 106.165 -        MOTIF_BYTE_ORDER = (*((char*)&value) != 0) ? 'l' : 'B';
 106.166 -
 106.167 -        /* NOTE: init_atoms() should be called before the rest of initialization
 106.168 -           so that atoms can be used. */
 106.169 -        inited = init_atoms(display);
 106.170 -
 106.171 -        if (inited) {
 106.172 -            if (XtIsRealized(awt_root_shell)) {
 106.173 -                awt_root_window = XtWindow(awt_root_shell);
 106.174 -            } else {
 106.175 -                inited = False;
 106.176 -            }
 106.177 -        }
 106.178 -
 106.179 -        inited = inited && awt_dnd_ds_init(display);
 106.180 -    }
 106.181 -
 106.182 -    return inited;
 106.183 -}
 106.184 -
 106.185 -/*
 106.186 - * Returns a window of awt_root_shell.
 106.187 - */
 106.188 -Window
 106.189 -get_awt_root_window() {
 106.190 -    return awt_root_window;
 106.191 -}
 106.192 -
 106.193 -static unsigned char local_xerror_code = Success;
 106.194 -
 106.195 -static int
 106.196 -xerror_handler(Display *dpy, XErrorEvent *err) {
 106.197 -    local_xerror_code = err->error_code;
 106.198 -    return 0;
 106.199 -}
 106.200 -
 106.201 -/**************** checked_X* wrappers *****************************************/
 106.202 -#undef NO_SYNC
 106.203 -#undef SYNC_TRACE
 106.204 -
 106.205 -unsigned char
 106.206 -checked_XChangeProperty(Display* display, Window w, Atom property, Atom type,
 106.207 -                        int format, int mode, unsigned char* data,
 106.208 -                        int nelements) {
 106.209 -    XErrorHandler xerror_saved_handler;
 106.210 -
 106.211 -#ifndef NO_SYNC
 106.212 -    XSync(display, False);
 106.213 -#ifdef SYNC_TRACE
 106.214 -    fprintf(stderr,"XSync 1\n");
 106.215 -#endif
 106.216 -#endif
 106.217 -    local_xerror_code = Success;
 106.218 -    xerror_saved_handler = XSetErrorHandler(xerror_handler);
 106.219 -
 106.220 -    XChangeProperty(display, w, property, type, format, mode, data, nelements);
 106.221 -
 106.222 -#ifndef NO_SYNC
 106.223 -    XSync(display, False);
 106.224 -#ifdef SYNC_TRACE
 106.225 -    fprintf(stderr,"XSync 2\n");
 106.226 -#endif
 106.227 -#endif
 106.228 -    XSetErrorHandler(xerror_saved_handler);
 106.229 -
 106.230 -    return local_xerror_code;
 106.231 -}
 106.232 -
 106.233 -unsigned char
 106.234 -checked_XGetWindowProperty(Display* display, Window w, Atom property, long long_offset,
 106.235 -                           long long_length, Bool delete, Atom req_type,
 106.236 -                           Atom* actual_type_return, int* actual_format_return,
 106.237 -                           unsigned long* nitems_return, unsigned long* bytes_after_return,
 106.238 -                           unsigned char** prop_return) {
 106.239 -
 106.240 -    XErrorHandler xerror_saved_handler;
 106.241 -    int ret_val = Success;
 106.242 -
 106.243 -#ifndef NO_SYNC
 106.244 -    XSync(display, False);
 106.245 -#ifdef SYNC_TRACE
 106.246 -    fprintf(stderr,"XSync 3\n");
 106.247 -#endif
 106.248 -#endif
 106.249 -    local_xerror_code = Success;
 106.250 -    xerror_saved_handler = XSetErrorHandler(xerror_handler);
 106.251 -
 106.252 -    ret_val = XGetWindowProperty(display, w, property, long_offset, long_length,
 106.253 -                                 delete, req_type, actual_type_return,
 106.254 -                                 actual_format_return, nitems_return,
 106.255 -                                 bytes_after_return, prop_return);
 106.256 -
 106.257 -#ifndef NO_SYNC
 106.258 -    XSync(display, False);
 106.259 -#ifdef SYNC_TRACE
 106.260 -    fprintf(stderr,"XSync 4\n");
 106.261 -#endif
 106.262 -#endif
 106.263 -    XSetErrorHandler(xerror_saved_handler);
 106.264 -
 106.265 -    return ret_val != Success ? local_xerror_code : Success;
 106.266 -}
 106.267 -
 106.268 -unsigned char
 106.269 -checked_XSendEvent(Display* display, Window w, Bool propagate, long event_mask,
 106.270 -                   XEvent* event_send) {
 106.271 -
 106.272 -    XErrorHandler xerror_saved_handler;
 106.273 -    Status ret_val = 0;
 106.274 -
 106.275 -#ifndef NO_SYNC
 106.276 -    XSync(display, False);
 106.277 -#ifdef SYNC_TRACE
 106.278 -    fprintf(stderr,"XSync 5\n");
 106.279 -#endif
 106.280 -#endif
 106.281 -    local_xerror_code = Success;
 106.282 -    xerror_saved_handler = XSetErrorHandler(xerror_handler);
 106.283 -
 106.284 -    ret_val = XSendEvent(display, w, propagate, event_mask, event_send);
 106.285 -
 106.286 -#ifndef NO_SYNC
 106.287 -    XSync(display, False);
 106.288 -#ifdef SYNC_TRACE
 106.289 -    fprintf(stderr,"XSync 6\n");
 106.290 -#endif
 106.291 -#endif
 106.292 -    XSetErrorHandler(xerror_saved_handler);
 106.293 -
 106.294 -    return ret_val == 0 ? local_xerror_code : Success;
 106.295 -}
 106.296 -
 106.297 -/*
 106.298 - * NOTE: returns Success even if the two windows aren't on the same screen.
 106.299 - */
 106.300 -unsigned char
 106.301 -checked_XTranslateCoordinates(Display* display, Window src_w, Window dest_w,
 106.302 -                              int src_x, int src_y, int* dest_x_return,
 106.303 -                              int* dest_y_return, Window* child_return) {
 106.304 -
 106.305 -    XErrorHandler xerror_saved_handler;
 106.306 -    Bool ret_val = True;
 106.307 -
 106.308 -#ifndef NO_SYNC
 106.309 -    XSync(display, False);
 106.310 -#ifdef SYNC_TRACE
 106.311 -    fprintf(stderr,"XSync 7\n");
 106.312 -#endif
 106.313 -#endif
 106.314 -    local_xerror_code = Success;
 106.315 -    xerror_saved_handler = XSetErrorHandler(xerror_handler);
 106.316 -
 106.317 -    ret_val = XTranslateCoordinates(display, src_w, dest_w, src_x, src_y,
 106.318 -                                    dest_x_return, dest_y_return, child_return);
 106.319 -
 106.320 -#ifndef NO_SYNC
 106.321 -    XSync(display, False);
 106.322 -#ifdef SYNC_TRACE
 106.323 -    fprintf(stderr,"XSync 8\n");
 106.324 -#endif
 106.325 -#endif
 106.326 -    XSetErrorHandler(xerror_saved_handler);
 106.327 -
 106.328 -    return local_xerror_code;
 106.329 -}
 106.330 -
 106.331 -unsigned char
 106.332 -checked_XSelectInput(Display* display, Window w, long event_mask) {
 106.333 -    XErrorHandler xerror_saved_handler;
 106.334 -    Bool ret_val = True;
 106.335 -
 106.336 -#ifndef NO_SYNC
 106.337 -    XSync(display, False);
 106.338 -#ifdef SYNC_TRACE
 106.339 -    fprintf(stderr,"XSync 7\n");
 106.340 -#endif
 106.341 -#endif
 106.342 -    local_xerror_code = Success;
 106.343 -    xerror_saved_handler = XSetErrorHandler(xerror_handler);
 106.344 -
 106.345 -    XSelectInput(display, w, event_mask);
 106.346 -
 106.347 -#ifndef NO_SYNC
 106.348 -    XSync(display, False);
 106.349 -#ifdef SYNC_TRACE
 106.350 -    fprintf(stderr,"XSync 8\n");
 106.351 -#endif
 106.352 -#endif
 106.353 -    XSetErrorHandler(xerror_saved_handler);
 106.354 -
 106.355 -    return local_xerror_code;
 106.356 -}
 106.357 -/******************************************************************************/
 106.358 -
 106.359 -jint
 106.360 -xdnd_to_java_action(Atom action) {
 106.361 -    if (action == XA_XdndActionCopy) {
 106.362 -        return java_awt_dnd_DnDConstants_ACTION_COPY;
 106.363 -    } else if (action == XA_XdndActionMove) {
 106.364 -        return java_awt_dnd_DnDConstants_ACTION_MOVE;
 106.365 -    } else if (action == XA_XdndActionLink) {
 106.366 -        return java_awt_dnd_DnDConstants_ACTION_LINK;
 106.367 -    } else if (action == None) {
 106.368 -        return java_awt_dnd_DnDConstants_ACTION_NONE;
 106.369 -    } else {
 106.370 -        /* XdndActionCopy is the default. */
 106.371 -        return java_awt_dnd_DnDConstants_ACTION_COPY;
 106.372 -    }
 106.373 -}
 106.374 -
 106.375 -Atom
 106.376 -java_to_xdnd_action(jint action) {
 106.377 -    switch (action) {
 106.378 -    case java_awt_dnd_DnDConstants_ACTION_COPY: return XA_XdndActionCopy;
 106.379 -    case java_awt_dnd_DnDConstants_ACTION_MOVE: return XA_XdndActionMove;
 106.380 -    case java_awt_dnd_DnDConstants_ACTION_LINK: return XA_XdndActionLink;
 106.381 -    default:                                    return None;
 106.382 -    }
 106.383 -}
 106.384 -
 106.385 -void
 106.386 -write_card8(void** p, CARD8 value) {
 106.387 -    CARD8** card8_pp = (CARD8**)p;
 106.388 -    **card8_pp = value;
 106.389 -    (*card8_pp)++;
 106.390 -}
 106.391 -
 106.392 -void
 106.393 -write_card16(void** p, CARD16 value) {
 106.394 -    CARD16** card16_pp = (CARD16**)p;
 106.395 -    **card16_pp = value;
 106.396 -    (*card16_pp)++;
 106.397 -}
 106.398 -
 106.399 -void
 106.400 -write_card32(void** p, CARD32 value) {
 106.401 -    CARD32** card32_pp = (CARD32**)p;
 106.402 -    **card32_pp = value;
 106.403 -    (*card32_pp)++;
 106.404 -}
 106.405 -
 106.406 -CARD8
 106.407 -read_card8(char* data, size_t offset) {
 106.408 -    return *((CARD8*)(data + offset));
 106.409 -}
 106.410 -
 106.411 -CARD16
 106.412 -read_card16(char* data, size_t offset, char byte_order) {
 106.413 -    CARD16 card16 = *((CARD16*)(data + offset));
 106.414 -
 106.415 -    if (byte_order != MOTIF_BYTE_ORDER) {
 106.416 -        SWAP2BYTES(card16);
 106.417 -    }
 106.418 -
 106.419 -    return card16;
 106.420 -}
 106.421 -
 106.422 -CARD32
 106.423 -read_card32(char* data, size_t offset, char byte_order) {
 106.424 -    CARD32 card32 = *((CARD32*)(data + offset));
 106.425 -
 106.426 -    if (byte_order != MOTIF_BYTE_ORDER) {
 106.427 -        SWAP4BYTES(card32);
 106.428 -    }
 106.429 -
 106.430 -    return card32;
 106.431 -}
 106.432 -
 106.433 -static Window
 106.434 -read_motif_window(Display* dpy) {
 106.435 -    Window         root_window = DefaultRootWindow(dpy);
 106.436 -    Window         motif_window = None;
 106.437 -
 106.438 -    unsigned char  ret;
 106.439 -    Atom           type;
 106.440 -    int            format;
 106.441 -    unsigned long  nitems;
 106.442 -    unsigned long  after;
 106.443 -    unsigned char  *data;
 106.444 -
 106.445 -    ret = checked_XGetWindowProperty(dpy, root_window, _XA_MOTIF_DRAG_WINDOW,
 106.446 -                                     0, 0xFFFF, False, AnyPropertyType, &type,
 106.447 -                                     &format, &nitems, &after, &data);
 106.448 -
 106.449 -    if (ret != Success) {
 106.450 -        DTRACE_PRINTLN2("%s:%d Failed to read _MOTIF_DRAG_WINDOW.",
 106.451 -                        __FILE__, __LINE__);
 106.452 -        return None;
 106.453 -    }
 106.454 -
 106.455 -
 106.456 -    if (type == XA_WINDOW && format == 32 && nitems == 1) {
 106.457 -        motif_window = *((Window*)data);
 106.458 -    }
 106.459 -
 106.460 -    XFree ((char *)data);
 106.461 -
 106.462 -    return motif_window;
 106.463 -}
 106.464 -
 106.465 -static Window
 106.466 -create_motif_window(Display* dpy) {
 106.467 -    Window   root_window = DefaultRootWindow(dpy);
 106.468 -    Window   motif_window = None;
 106.469 -    Display* display = NULL;
 106.470 -    XSetWindowAttributes swa;
 106.471 -
 106.472 -    display = XOpenDisplay(XDisplayString(dpy));
 106.473 -    if (display == NULL) {
 106.474 -        return None;
 106.475 -    }
 106.476 -
 106.477 -    XGrabServer(display);
 106.478 -
 106.479 -    XSetCloseDownMode(display, RetainPermanent);
 106.480 -
 106.481 -    swa.override_redirect = True;
 106.482 -    swa.event_mask = PropertyChangeMask;
 106.483 -    motif_window = XCreateWindow(display, root_window,
 106.484 -                                 -10, -10, 1, 1, 0, 0,
 106.485 -                                 InputOnly, CopyFromParent,
 106.486 -                                 (CWOverrideRedirect|CWEventMask),
 106.487 -                                 &swa);
 106.488 -    XMapWindow(display, motif_window);
 106.489 -
 106.490 -    XChangeProperty(display, root_window, _XA_MOTIF_DRAG_WINDOW, XA_WINDOW, 32,
 106.491 -                    PropModeReplace, (unsigned char *)&motif_window, 1);
 106.492 -
 106.493 -    XUngrabServer(display);
 106.494 -
 106.495 -    XCloseDisplay(display);
 106.496 -
 106.497 -    return motif_window;
 106.498 -}
 106.499 -
 106.500 -Window
 106.501 -get_motif_window(Display* dpy) {
 106.502 -    /*
 106.503 -     * Note: it is unsafe to cache the motif drag window handle, as another
 106.504 -     * client can change the _MOTIF_DRAG_WINDOW property on the root, the handle
 106.505 -     * becomes out-of-sync and all subsequent drag operations will fail.
 106.506 -     */
 106.507 -    Window motif_window = read_motif_window(dpy);
 106.508 -    if (motif_window == None) {
 106.509 -        motif_window = create_motif_window(dpy);
 106.510 -    }
 106.511 -
 106.512 -    return motif_window;
 106.513 -}
 106.514 -
 106.515 -typedef struct {
 106.516 -    CARD16 num_targets;
 106.517 -    Atom* targets;
 106.518 -} TargetsTableEntry;
 106.519 -
 106.520 -typedef struct {
 106.521 -    CARD16 num_entries;
 106.522 -    TargetsTableEntry* entries;
 106.523 -} TargetsTable;
 106.524 -
 106.525 -typedef struct {
 106.526 -    CARD8       byte_order;
 106.527 -    CARD8       protocol_version;
 106.528 -    CARD16      num_entries B16;
 106.529 -    CARD32      heap_offset B32;
 106.530 -} TargetsPropertyRec;
 106.531 -
 106.532 -static TargetsTable*
 106.533 -get_target_list_table(Display* dpy) {
 106.534 -    Window motif_window = get_motif_window(dpy);
 106.535 -    TargetsTable* targets_table = NULL;
 106.536 -    TargetsPropertyRec* targets_property_rec_ptr;
 106.537 -    char* bufptr;
 106.538 -
 106.539 -    unsigned char  ret;
 106.540 -    Atom           type;
 106.541 -    int            format;
 106.542 -    unsigned long  nitems;
 106.543 -    unsigned long  after;
 106.544 -    unsigned char  *data;
 106.545 -    unsigned int   i, j;
 106.546 -
 106.547 -    ret = checked_XGetWindowProperty(dpy, motif_window, _XA_MOTIF_DRAG_TARGETS,
 106.548 -                                     0L, 100000L, False, _XA_MOTIF_DRAG_TARGETS,
 106.549 -                                     &type, &format, &nitems, &after,
 106.550 -                                     (unsigned char**)&targets_property_rec_ptr);
 106.551 -
 106.552 -    if (ret != Success || type != _XA_MOTIF_DRAG_TARGETS ||
 106.553 -        targets_property_rec_ptr == NULL) {
 106.554 -
 106.555 -        DTRACE_PRINT2("%s:%d Cannot read _XA_MOTIF_DRAG_TARGETS", __FILE__, __LINE__);
 106.556 -        return NULL;
 106.557 -    }
 106.558 -
 106.559 -    if (targets_property_rec_ptr->protocol_version !=
 106.560 -        MOTIF_DND_PROTOCOL_VERSION) {
 106.561 -        DTRACE_PRINT2("%s:%d incorrect protocol version", __FILE__, __LINE__);
 106.562 -        return NULL;
 106.563 -    }
 106.564 -
 106.565 -    if (targets_property_rec_ptr->byte_order != MOTIF_BYTE_ORDER) {
 106.566 -        SWAP2BYTES(targets_property_rec_ptr->num_entries);
 106.567 -        SWAP4BYTES(targets_property_rec_ptr->heap_offset);
 106.568 -    }
 106.569 -
 106.570 -    targets_table = (TargetsTable*)malloc(sizeof(TargetsTable));
 106.571 -    if (targets_table == NULL) {
 106.572 -        DTRACE_PRINT2("%s:%d malloc failed", __FILE__, __LINE__);
 106.573 -        return NULL;
 106.574 -    }
 106.575 -    targets_table->num_entries = targets_property_rec_ptr->num_entries;
 106.576 -    targets_table->entries =
 106.577 -        (TargetsTableEntry*)malloc(sizeof(TargetsTableEntry) *
 106.578 -                                   targets_property_rec_ptr->num_entries);
 106.579 -    if (targets_table->entries == NULL) {
 106.580 -        DTRACE_PRINT2("%s:%d malloc failed", __FILE__, __LINE__);
 106.581 -        free(targets_table);
 106.582 -        return NULL;
 106.583 -    }
 106.584 -
 106.585 -    bufptr = (char *)targets_property_rec_ptr + sizeof(TargetsPropertyRec);
 106.586 -    for (i = 0; i < targets_table->num_entries; i++) {
 106.587 -        CARD16 num_targets;
 106.588 -        Atom* targets;
 106.589 -        memcpy(&num_targets, bufptr, 2 );
 106.590 -        bufptr += 2;
 106.591 -        if (targets_property_rec_ptr->byte_order != MOTIF_BYTE_ORDER) {
 106.592 -            SWAP2BYTES(num_targets);
 106.593 -        }
 106.594 -
 106.595 -        targets = (Atom*)malloc(sizeof(Atom) * num_targets);
 106.596 -        if (targets == NULL) {
 106.597 -            DTRACE_PRINT2("%s:%d malloc failed", __FILE__, __LINE__);
 106.598 -            free(targets_table->entries);
 106.599 -            free(targets_table);
 106.600 -            return NULL;
 106.601 -        }
 106.602 -        for (j = 0; j < num_targets; j++) {
 106.603 -            CARD32 target;
 106.604 -            memcpy(&target, bufptr, 4 );
 106.605 -            bufptr += 4;
 106.606 -            if (targets_property_rec_ptr->byte_order != MOTIF_BYTE_ORDER) {
 106.607 -                SWAP4BYTES(target);
 106.608 -            }
 106.609 -            targets[j] = (Atom)target;
 106.610 -        }
 106.611 -
 106.612 -        targets_table->entries[i].num_targets = num_targets;
 106.613 -        targets_table->entries[i].targets = targets;
 106.614 -    }
 106.615 -
 106.616 -    free(targets_property_rec_ptr);
 106.617 -
 106.618 -    return targets_table;
 106.619 -}
 106.620 -
 106.621 -static void
 106.622 -put_target_list_table(Display* dpy, TargetsTable* table) {
 106.623 -    Window motif_window = get_motif_window(dpy);
 106.624 -    TargetsPropertyRec* targets_property_rec_ptr;
 106.625 -    size_t table_size = sizeof(TargetsPropertyRec);
 106.626 -    unsigned char ret;
 106.627 -    int i, j;
 106.628 -    char* buf;
 106.629 -
 106.630 -    for (i = 0; i < table->num_entries; i++) {
 106.631 -        table_size += table->entries[i].num_targets * sizeof(Atom) + 2;
 106.632 -    }
 106.633 -
 106.634 -    targets_property_rec_ptr = (TargetsPropertyRec*)malloc(table_size);
 106.635 -    if (targets_property_rec_ptr == NULL) {
 106.636 -        DTRACE_PRINT2("%s:%d malloc failed", __FILE__, __LINE__);
 106.637 -        return;
 106.638 -    }
 106.639 -    targets_property_rec_ptr->byte_order = MOTIF_BYTE_ORDER;
 106.640 -    targets_property_rec_ptr->protocol_version = MOTIF_DND_PROTOCOL_VERSION;
 106.641 -    targets_property_rec_ptr->num_entries = table->num_entries;
 106.642 -    targets_property_rec_ptr->heap_offset = table_size;
 106.643 -
 106.644 -    buf = (char*)targets_property_rec_ptr + sizeof(TargetsPropertyRec);
 106.645 -
 106.646 -    for (i = 0; i < table->num_entries; i++) {
 106.647 -        CARD16 num_targets = table->entries[i].num_targets;
 106.648 -        memcpy(buf, &num_targets, 2);
 106.649 -        buf += 2;
 106.650 -
 106.651 -        for (j = 0; j < num_targets; j++) {
 106.652 -            CARD32 target = table->entries[i].targets[j];
 106.653 -            memcpy(buf, &target, 4);
 106.654 -            buf += 4;
 106.655 -        }
 106.656 -    }
 106.657 -
 106.658 -    ret = checked_XChangeProperty(dpy, motif_window, _XA_MOTIF_DRAG_TARGETS,
 106.659 -                                  _XA_MOTIF_DRAG_TARGETS, 8, PropModeReplace,
 106.660 -                                  (unsigned char*)targets_property_rec_ptr,
 106.661 -                                  (int)table_size);
 106.662 -
 106.663 -    if (ret != Success) {
 106.664 -        DTRACE_PRINT2("%s:%d XChangeProperty failed", __FILE__, __LINE__);
 106.665 -    }
 106.666 -
 106.667 -    XtFree((char*)targets_property_rec_ptr);
 106.668 -}
 106.669 -
 106.670 -static int
 106.671 -_compare(const void* p1, const void* p2) {
 106.672 -    long diff = *(Atom*)p1 - *(Atom*)p2;
 106.673 -
 106.674 -    if (diff > 0) {
 106.675 -        return 1;
 106.676 -    } else if (diff < 0) {
 106.677 -        return -1;
 106.678 -    } else {
 106.679 -        return 0;
 106.680 -    }
 106.681 -}
 106.682 -
 106.683 -/*
 106.684 - * Returns the index for the specified target list or -1 on failure.
 106.685 - */
 106.686 -int
 106.687 -get_index_for_target_list(Display* dpy, Atom* targets, unsigned int num_targets) {
 106.688 -    TargetsTable* targets_table = NULL;
 106.689 -    Atom* sorted_targets = NULL;
 106.690 -    int i, j;
 106.691 -    int ret = -1;
 106.692 -
 106.693 -    if (targets == NULL && num_targets > 0) {
 106.694 -        DTRACE_PRINT4("%s:%d targets=%X num_targets=%d",
 106.695 -                      __FILE__, __LINE__, targets, num_targets);
 106.696 -        return -1;
 106.697 -    }
 106.698 -
 106.699 -    if (num_targets > 0) {
 106.700 -        sorted_targets = (Atom*)malloc(sizeof(Atom) * num_targets);
 106.701 -        if (sorted_targets == NULL) {
 106.702 -            DTRACE_PRINT2("%s:%d malloc failed.", __FILE__, __LINE__);
 106.703 -            return -1;
 106.704 -        }
 106.705 -
 106.706 -        memcpy(sorted_targets, targets, sizeof(Atom) * num_targets);
 106.707 -        qsort ((void *)sorted_targets, (size_t)num_targets, (size_t)sizeof(Atom),
 106.708 -               _compare);
 106.709 -    }
 106.710 -
 106.711 -    XGrabServer(dpy);
 106.712 -    targets_table = get_target_list_table(dpy);
 106.713 -
 106.714 -    if (targets_table != NULL) {
 106.715 -        for (i = 0; i < targets_table->num_entries; i++) {
 106.716 -            TargetsTableEntry* entry_ptr = &targets_table->entries[i];
 106.717 -            Boolean equals = True;
 106.718 -            if (num_targets == entry_ptr->num_targets) {
 106.719 -                for (j = 0; j < entry_ptr->num_targets; j++) {
 106.720 -                    if (sorted_targets[j] != entry_ptr->targets[j]) {
 106.721 -                        equals = False;
 106.722 -                        break;
 106.723 -                    }
 106.724 -                }
 106.725 -            } else {
 106.726 -                equals = False;
 106.727 -            }
 106.728 -
 106.729 -            if (equals) {
 106.730 -                XUngrabServer(dpy);
 106.731 -                /* Workaround for bug 5039226 */
 106.732 -                XSync(dpy, False);
 106.733 -                free((char*)sorted_targets);
 106.734 -                return i;
 106.735 -            }
 106.736 -        }
 106.737 -    } else {
 106.738 -        targets_table = (TargetsTable*)malloc(sizeof(TargetsTable));
 106.739 -        targets_table->num_entries = 0;
 106.740 -        targets_table->entries = NULL;
 106.741 -    }
 106.742 -
 106.743 -    /* Index not found - expand the table. */
 106.744 -    targets_table->entries =
 106.745 -        (TargetsTableEntry*)realloc((char*)targets_table->entries,
 106.746 -                                    sizeof(TargetsTableEntry) *
 106.747 -                                    (targets_table->num_entries + 1));
 106.748 -    if (targets_table->entries == NULL) {
 106.749 -        DTRACE_PRINT2("%s:%d realloc failed.", __FILE__, __LINE__);
 106.750 -        XUngrabServer(dpy);
 106.751 -        /* Workaround for bug 5039226 */
 106.752 -        XSync(dpy, False);
 106.753 -        free((char*)sorted_targets);
 106.754 -        return -1;
 106.755 -    }
 106.756 -
 106.757 -    /* Fill in the new entry */
 106.758 -    {
 106.759 -        TargetsTableEntry* new_entry =
 106.760 -            &targets_table->entries[targets_table->num_entries];
 106.761 -
 106.762 -        new_entry->num_targets = num_targets;
 106.763 -        if (num_targets > 0) {
 106.764 -            new_entry->targets = (Atom*)malloc(sizeof(Atom) * num_targets);
 106.765 -            if (new_entry->targets == NULL) {
 106.766 -                DTRACE_PRINT2("%s:%d malloc failed.", __FILE__, __LINE__);
 106.767 -                XUngrabServer(dpy);
 106.768 -                /* Workaround for bug 5039226 */
 106.769 -                XSync(dpy, False);
 106.770 -                free((char*)sorted_targets);
 106.771 -                return -1;
 106.772 -            }
 106.773 -            memcpy(new_entry->targets, sorted_targets,
 106.774 -                   sizeof(Atom) * num_targets);
 106.775 -        } else {
 106.776 -            new_entry->targets = NULL;
 106.777 -        }
 106.778 -    }
 106.779 -
 106.780 -    targets_table->num_entries++;
 106.781 -
 106.782 -    put_target_list_table(dpy, targets_table);
 106.783 -
 106.784 -    XUngrabServer(dpy);
 106.785 -    /* Workaround for bug 5039226 */
 106.786 -    XSync(dpy, False);
 106.787 -
 106.788 -    ret = targets_table->num_entries - 1;
 106.789 -
 106.790 -    free((char*)sorted_targets);
 106.791 -
 106.792 -    for (i = 0; i < targets_table->num_entries; i++) {
 106.793 -        free((char*)targets_table->entries[i].targets);
 106.794 -    }
 106.795 -
 106.796 -    free((char*)targets_table->entries);
 106.797 -    free((char*)targets_table);
 106.798 -    return ret;
 106.799 -}
 106.800 -
 106.801 -/*
 106.802 - * Retrieves the target list for the specified index.
 106.803 - * Stores the number of targets in the list to 'num_targets' and the targets
 106.804 - * to 'targets'. On failure stores 0 and NULL respectively.
 106.805 - * The caller should free the allocated array when done with it.
 106.806 - */
 106.807 -void
 106.808 -get_target_list_for_index(Display* dpy, int index, Atom** targets, unsigned int* num_targets) {
 106.809 -    TargetsTable* table = get_target_list_table(dpy);
 106.810 -    TargetsTableEntry* entry = NULL;
 106.811 -
 106.812 -    if (table == NULL) {
 106.813 -        DTRACE_PRINT2("%s:%d No target table.", __FILE__, __LINE__);
 106.814 -        *targets = NULL;
 106.815 -        *num_targets = 0;
 106.816 -        return;
 106.817 -    }
 106.818 -
 106.819 -    if (table->num_entries <= index) {
 106.820 -        DTRACE_PRINT4("%s:%d index out of bounds idx=%d entries=%d",
 106.821 -                      __FILE__, __LINE__, index, table->num_entries);
 106.822 -        *targets = NULL;
 106.823 -        *num_targets = 0;
 106.824 -        return;
 106.825 -    }
 106.826 -
 106.827 -    entry = &table->entries[index];
 106.828 -
 106.829 -    *targets = (Atom*)malloc(entry->num_targets * sizeof(Atom));
 106.830 -
 106.831 -    if (*targets == NULL) {
 106.832 -        DTRACE_PRINT2("%s:%d malloc failed.", __FILE__, __LINE__);
 106.833 -        *num_targets = 0;
 106.834 -        return;
 106.835 -    }
 106.836 -
 106.837 -    memcpy(*targets, entry->targets, entry->num_targets * sizeof(Atom));
 106.838 -    *num_targets = entry->num_targets;
 106.839 -}
 106.840 -
 106.841 -jint
 106.842 -motif_to_java_actions(unsigned char motif_action) {
 106.843 -    jint java_action = java_awt_dnd_DnDConstants_ACTION_NONE;
 106.844 -
 106.845 -    if (motif_action & MOTIF_DND_COPY) {
 106.846 -        java_action |= java_awt_dnd_DnDConstants_ACTION_COPY;
 106.847 -    }
 106.848 -
 106.849 -    if (motif_action & MOTIF_DND_MOVE) {
 106.850 -        java_action |= java_awt_dnd_DnDConstants_ACTION_MOVE;
 106.851 -    }
 106.852 -
 106.853 -    if (motif_action & MOTIF_DND_LINK) {
 106.854 -        java_action |= java_awt_dnd_DnDConstants_ACTION_LINK;
 106.855 -    }
 106.856 -
 106.857 -    return java_action;
 106.858 -}
 106.859 -
 106.860 -unsigned char
 106.861 -java_to_motif_actions(jint java_action) {
 106.862 -    unsigned char motif_action = MOTIF_DND_NOOP;
 106.863 -
 106.864 -    if (java_action & java_awt_dnd_DnDConstants_ACTION_COPY) {
 106.865 -        motif_action |= MOTIF_DND_COPY;
 106.866 -    }
 106.867 -
 106.868 -    if (java_action & java_awt_dnd_DnDConstants_ACTION_MOVE) {
 106.869 -        motif_action |= MOTIF_DND_MOVE;
 106.870 -    }
 106.871 -
 106.872 -    if (java_action & java_awt_dnd_DnDConstants_ACTION_LINK) {
 106.873 -        motif_action |= MOTIF_DND_LINK;
 106.874 -    }
 106.875 -
 106.876 -    return motif_action;
 106.877 -}
 106.878 -
 106.879 -Boolean
 106.880 -awt_dnd_process_event(XEvent* event) {
 106.881 -    Boolean ret = awt_dnd_ds_process_event(event) ||
 106.882 -        awt_dnd_dt_process_event(event);
 106.883 -
 106.884 -    /* Extract the event from the queue if it is processed. */
 106.885 -    if (ret) {
 106.886 -        XNextEvent(event->xany.display, event);
 106.887 -    }
 106.888 -
 106.889 -    return ret;
 106.890 -}
   107.1 --- a/src/solaris/native/sun/awt/awt_dnd.h	Wed Sep 17 13:45:37 2008 -0700
   107.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   107.3 @@ -1,242 +0,0 @@
   107.4 -/*
   107.5 - * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
   107.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   107.7 - *
   107.8 - * This code is free software; you can redistribute it and/or modify it
   107.9 - * under the terms of the GNU General Public License version 2 only, as
  107.10 - * published by the Free Software Foundation.  Sun designates this
  107.11 - * particular file as subject to the "Classpath" exception as provided
  107.12 - * by Sun in the LICENSE file that accompanied this code.
  107.13 - *
  107.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  107.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  107.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  107.17 - * version 2 for more details (a copy is included in the LICENSE file that
  107.18 - * accompanied this code).
  107.19 - *
  107.20 - * You should have received a copy of the GNU General Public License version
  107.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  107.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  107.23 - *
  107.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  107.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  107.26 - * have any questions.
  107.27 - */
  107.28 -
  107.29 -#ifdef HEADLESS
  107.30 -    #error This file should not be included in headless library
  107.31 -#endif
  107.32 -
  107.33 -#include <X11/Intrinsic.h>
  107.34 -
  107.35 -#include "awt_p.h"
  107.36 -
  107.37 -/* For definition of MComponentPeerIDs */
  107.38 -#include "awt_Component.h"
  107.39 -
  107.40 -extern struct MComponentPeerIDs mComponentPeerIDs;
  107.41 -
  107.42 -/* DnD protocols */
  107.43 -
  107.44 -typedef enum {
  107.45 -    NO_PROTOCOL,
  107.46 -    XDND_PROTOCOL,
  107.47 -    MOTIF_DND_PROTOCOL
  107.48 -} Protocol;
  107.49 -
  107.50 -/* XDnD constants */
  107.51 -
  107.52 -#define XDND_PROTOCOL_VERSION          5
  107.53 -/* XDnD compliance only requires supporting version 3 and up. */
  107.54 -#define XDND_MIN_PROTOCOL_VERSION      3
  107.55 -
  107.56 -#define XDND_PROTOCOL_MASK    0xFF000000
  107.57 -#define XDND_PROTOCOL_SHIFT           24
  107.58 -#define XDND_DATA_TYPES_BIT          0x1
  107.59 -#define XDND_ACCEPT_DROP_FLAG        0x1
  107.60 -
  107.61 -/* Motif DnD constants */
  107.62 -
  107.63 -#define MOTIF_DND_PROTOCOL_VERSION 0
  107.64 -
  107.65 -/* Suuported protocol styles */
  107.66 -#define MOTIF_PREFER_PREREGISTER_STYLE    2
  107.67 -#define MOTIF_PREFER_DYNAMIC_STYLE        4
  107.68 -#define MOTIF_DYNAMIC_STYLE               5
  107.69 -#define MOTIF_PREFER_RECEIVER_STYLE       6
  107.70 -
  107.71 -#define MOTIF_MESSAGE_REASON_MASK      0x7F
  107.72 -#define MOTIF_MESSAGE_SENDER_MASK      0x80
  107.73 -#define MOTIF_MESSAGE_FROM_RECEIVER    0x80
  107.74 -#define MOTIF_MESSAGE_FROM_INITIATOR      0
  107.75 -
  107.76 -/* Info structure sizes */
  107.77 -#define MOTIF_INITIATOR_INFO_SIZE         8
  107.78 -#define MOTIF_RECEIVER_INFO_SIZE         16
  107.79 -
  107.80 -/* Message flags masks and shifts */
  107.81 -#define MOTIF_DND_ACTION_MASK        0x000F
  107.82 -#define MOTIF_DND_ACTION_SHIFT            0
  107.83 -#define MOTIF_DND_STATUS_MASK        0x00F0
  107.84 -#define MOTIF_DND_STATUS_SHIFT            4
  107.85 -#define MOTIF_DND_ACTIONS_MASK       0x0F00
  107.86 -#define MOTIF_DND_ACTIONS_SHIFT           8
  107.87 -
  107.88 -/* message type constants */
  107.89 -#define TOP_LEVEL_ENTER    0
  107.90 -#define TOP_LEVEL_LEAVE    1
  107.91 -#define DRAG_MOTION        2
  107.92 -#define DROP_SITE_ENTER    3
  107.93 -#define DROP_SITE_LEAVE    4
  107.94 -#define DROP_START         5
  107.95 -#define DROP_FINISH        6
  107.96 -#define DRAG_DROP_FINISH   7
  107.97 -#define OPERATION_CHANGED  8
  107.98 -
  107.99 -/* drop action constants */
 107.100 -#define MOTIF_DND_NOOP  0L
 107.101 -#define MOTIF_DND_MOVE  (1L << 0)
 107.102 -#define MOTIF_DND_COPY  (1L << 1)
 107.103 -#define MOTIF_DND_LINK  (1L << 2)
 107.104 -
 107.105 -/* drop site status constants */
 107.106 -#define MOTIF_NO_DROP_SITE      1
 107.107 -#define MOTIF_INVALID_DROP_SITE 2
 107.108 -#define MOTIF_VALID_DROP_SITE   3
 107.109 -
 107.110 -/* Shared atoms */
 107.111 -
 107.112 -extern Atom XA_WM_STATE;
 107.113 -extern Atom XA_DELETE;
 107.114 -
 107.115 -/* XDnD atoms */
 107.116 -
 107.117 -extern Atom XA_XdndAware;
 107.118 -extern Atom XA_XdndProxy;
 107.119 -
 107.120 -extern Atom XA_XdndEnter;
 107.121 -extern Atom XA_XdndPosition;
 107.122 -extern Atom XA_XdndLeave;
 107.123 -extern Atom XA_XdndDrop;
 107.124 -extern Atom XA_XdndStatus;
 107.125 -extern Atom XA_XdndFinished;
 107.126 -
 107.127 -extern Atom XA_XdndTypeList;
 107.128 -extern Atom XA_XdndSelection;
 107.129 -
 107.130 -extern Atom XA_XdndActionCopy;
 107.131 -extern Atom XA_XdndActionMove;
 107.132 -extern Atom XA_XdndActionLink;
 107.133 -extern Atom XA_XdndActionAsk;
 107.134 -extern Atom XA_XdndActionPrivate;
 107.135 -extern Atom XA_XdndActionList;
 107.136 -
 107.137 -/* Motif DnD atoms */
 107.138 -
 107.139 -extern Atom _XA_MOTIF_DRAG_WINDOW;
 107.140 -extern Atom _XA_MOTIF_DRAG_TARGETS;
 107.141 -extern Atom _XA_MOTIF_DRAG_INITIATOR_INFO;
 107.142 -extern Atom _XA_MOTIF_DRAG_RECEIVER_INFO;
 107.143 -extern Atom _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
 107.144 -extern Atom XA_XmTRANSFER_SUCCESS;
 107.145 -extern Atom XA_XmTRANSFER_FAILURE;
 107.146 -extern Atom _XA_MOTIF_ATOM_0;
 107.147 -
 107.148 -extern unsigned char MOTIF_BYTE_ORDER;
 107.149 -
 107.150 -/* Motif DnD macros */
 107.151 -
 107.152 -#define SWAP4BYTES(l) {\
 107.153 -        struct {\
 107.154 -          unsigned t :32;\
 107.155 -        } bit32;\
 107.156 -        char n, *tp = (char *) &bit32;\
 107.157 -        bit32.t = l;\
 107.158 -        n = tp[0]; tp[0] = tp[3]; tp[3] = n;\
 107.159 -        n = tp[1]; tp[1] = tp[2]; tp[2] = n;\
 107.160 -        l = bit32.t;\
 107.161 -}
 107.162 -
 107.163 -#define SWAP2BYTES(s) {\
 107.164 -        struct {\
 107.165 -          unsigned t :16;\
 107.166 -        } bit16;\
 107.167 -        char n, *tp = (char *) &bit16;\
 107.168 -        bit16.t = s;\
 107.169 -        n = tp[0]; tp[0] = tp[1]; tp[1] = n;\
 107.170 -        s = bit16.t;\
 107.171 -}
 107.172 -
 107.173 -typedef struct DropSiteInfo {
 107.174 -        Widget                  tlw;
 107.175 -        jobject                 component;
 107.176 -        Boolean                 isComposite;
 107.177 -        uint32_t                dsCnt;
 107.178 -} DropSiteInfo;
 107.179 -
 107.180 -Boolean awt_dnd_init(Display* display);
 107.181 -Boolean awt_dnd_ds_init(Display* display);
 107.182 -
 107.183 -Window get_awt_root_window();
 107.184 -
 107.185 -/**************** checked_X* wrappers *****************************************/
 107.186 -unsigned char
 107.187 -checked_XChangeProperty(Display* display, Window w, Atom property, Atom type,
 107.188 -                        int format, int mode, unsigned char* data,
 107.189 -                        int nelements);
 107.190 -
 107.191 -unsigned char
 107.192 -checked_XGetWindowProperty(Display* display, Window w, Atom property,
 107.193 -                           long long_offset, long long_length, Bool delete,
 107.194 -                           Atom req_type, Atom* actual_type_return,
 107.195 -                           int* actual_format_return,
 107.196 -                           unsigned long* nitems_return,
 107.197 -                           unsigned long* bytes_after_return,
 107.198 -                           unsigned char** prop_return);
 107.199 -
 107.200 -unsigned char
 107.201 -checked_XSendEvent(Display* display, Window w, Bool propagate, long event_mask,
 107.202 -                   XEvent* event_send);
 107.203 -
 107.204 -unsigned char
 107.205 -checked_XTranslateCoordinates(Display* display, Window src_w, Window dest_w,
 107.206 -                              int src_x, int src_y, int* dest_x_return,
 107.207 -                              int* dest_y_return, Window* child_return);
 107.208 -
 107.209 -unsigned char
 107.210 -checked_XSelectInput(Display* display, Window w, long event_mask);
 107.211 -/******************************************************************************/
 107.212 -
 107.213 -jint xdnd_to_java_action(Atom action);
 107.214 -Atom java_to_xdnd_action(jint action);
 107.215 -
 107.216 -jint motif_to_java_actions(unsigned char action);
 107.217 -unsigned char java_to_motif_actions(jint action);
 107.218 -
 107.219 -void write_card8(void** p, CARD8 value);
 107.220 -void write_card16(void** p, CARD16 value);
 107.221 -void write_card32(void** p, CARD32 value);
 107.222 -
 107.223 -CARD8 read_card8(char* data, size_t offset);
 107.224 -CARD16 read_card16(char* data, size_t offset, char byte_order);
 107.225 -CARD32 read_card32(char* data, size_t offset, char byte_order);
 107.226 -
 107.227 -Window get_motif_window(Display* dpy);
 107.228 -
 107.229 -/*************************** TARGET LIST SUPPORT ***************************************/
 107.230 -
 107.231 -int get_index_for_target_list(Display* dpy, Atom* targets, unsigned int num_targets);
 107.232 -void get_target_list_for_index(Display* dpy, int index, Atom** targets, unsigned
 107.233 -                               int* num_targets);
 107.234 -
 107.235 -/***************************************************************************************/
 107.236 -
 107.237 -Boolean awt_dnd_process_event(XEvent* event);
 107.238 -Boolean awt_dnd_ds_process_event(XEvent* event);
 107.239 -Boolean awt_dnd_dt_process_event(XEvent* event);
 107.240 -
 107.241 -Window awt_dnd_ds_get_source_window();
 107.242 -
 107.243 -/**************************** XEmbed server DnD support ***********************/
 107.244 -void set_proxy_mode_source_window(Window window);
 107.245 -/******************************************************************************/
   108.1 --- a/src/solaris/native/sun/awt/awt_dnd_ds.c	Wed Sep 17 13:45:37 2008 -0700
   108.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   108.3 @@ -1,1796 +0,0 @@
   108.4 -/*
   108.5 - * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
   108.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   108.7 - *
   108.8 - * This code is free software; you can redistribute it and/or modify it
   108.9 - * under the terms of the GNU General Public License version 2 only, as
  108.10 - * published by the Free Software Foundation.  Sun designates this
  108.11 - * particular file as subject to the "Classpath" exception as provided
  108.12 - * by Sun in the LICENSE file that accompanied this code.
  108.13 - *
  108.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  108.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  108.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  108.17 - * version 2 for more details (a copy is included in the LICENSE file that
  108.18 - * accompanied this code).
  108.19 - *
  108.20 - * You should have received a copy of the GNU General Public License version
  108.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  108.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  108.23 - *
  108.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  108.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  108.26 - * have any questions.
  108.27 - */
  108.28 -
  108.29 -#ifdef HEADLESS
  108.30 -    #error This file should not be included in headless library
  108.31 -#endif
  108.32 -
  108.33 -#include "awt_dnd.h"
  108.34 -
  108.35 -/* Declares getCursor(JNIEnv, jobject) */
  108.36 -#include "awt_Cursor.h"
  108.37 -
  108.38 -/* Define java constants */
  108.39 -#include "java_awt_dnd_DnDConstants.h"
  108.40 -#include "sun_awt_dnd_SunDragSourceContextPeer.h"
  108.41 -
  108.42 -/* Define DECLARE_* macros */
  108.43 -#include "awt_DataTransferer.h"
  108.44 -
  108.45 -#define GRAB_EVENT_MASK                                          \
  108.46 -   (ButtonPressMask | ButtonMotionMask | ButtonReleaseMask)
  108.47 -
  108.48 -/* Events selected on the root window during drag. */
  108.49 -#define ROOT_EVENT_MASK                                          \
  108.50 -   (ButtonMotionMask | KeyPressMask | KeyReleaseMask)
  108.51 -
  108.52 -/* Events selected on registered receiver windows during drag. */
  108.53 -#define RECEIVER_EVENT_MASK                                      \
  108.54 -   (StructureNotifyMask)
  108.55 -
  108.56 -
  108.57 -/* in canvas.c */
  108.58 -extern jint getModifiers(uint32_t state, jint button, jint keyCode);
  108.59 -
  108.60 -typedef struct {
  108.61 -    CARD8    byte_order;
  108.62 -    CARD8    protocol_version;
  108.63 -    CARD16   index;
  108.64 -    CARD32   selection_atom;
  108.65 -} InitiatorInfo;
  108.66 -
  108.67 -typedef enum {
  108.68 -    /*
  108.69 -     * Communicate with receivers of both protocols.
  108.70 -     * If the receiver supports both protocols,
  108.71 -     * choose Motif DnD for communication.
  108.72 -     */
  108.73 -    DS_POLICY_PREFER_MOTIF,
  108.74 -    /*
  108.75 -     * Communicate with receivers of both protocols.
  108.76 -     * If the receiver supports both protocols,
  108.77 -     * choose XDnD for communication. [default]
  108.78 -     */
  108.79 -    DS_POLICY_PREFER_XDND,
  108.80 -    /* Communicate only with Motif DnD receivers. */
  108.81 -    DS_POLICY_ONLY_MOTIF,
  108.82 -    /* Communicate only with XDnD receivers. */
  108.83 -    DS_POLICY_ONLY_XDND
  108.84 -} DragSourcePolicy;
  108.85 -
  108.86 -
  108.87 -/* The drag source policy. */
  108.88 -static DragSourcePolicy drag_source_policy = DS_POLICY_PREFER_XDND;
  108.89 -
  108.90 -static Boolean dnd_in_progress = False;
  108.91 -static Boolean drag_in_progress = False;
  108.92 -static jobject source_peer = NULL;
  108.93 -static Atom* data_types = NULL;
  108.94 -static unsigned int data_types_count = 0;
  108.95 -static Window drag_root_window = None;
  108.96 -static EventMask your_root_event_mask = NoEventMask;
  108.97 -static Time latest_time_stamp = CurrentTime;
  108.98 -
  108.99 -/* The child of the root which is currently under the mouse. */
 108.100 -static Window target_root_subwindow = None;
 108.101 -
 108.102 -static Window target_window = None;
 108.103 -static long target_window_mask = 0;
 108.104 -static Window target_proxy_window = None;
 108.105 -static Protocol target_protocol = NO_PROTOCOL;
 108.106 -static unsigned int target_protocol_version = 0;
 108.107 -/*
 108.108 - * The server time when the pointer entered the current target -
 108.109 - * needed on Motif DnD to filter out messages from the previous
 108.110 - * target.
 108.111 - * It is updated whenever the target_window is updated.
 108.112 - * If the target_window is set to non-None, it is set to the time stamp
 108.113 - * of the X event that trigger the update. Otherwise, it is set to CurrentTime.
 108.114 - */
 108.115 -static Time target_enter_server_time = CurrentTime;
 108.116 -
 108.117 -static int x_root = 0;
 108.118 -static int y_root = 0;
 108.119 -static unsigned int event_state = 0;
 108.120 -
 108.121 -static jint source_action = java_awt_dnd_DnDConstants_ACTION_NONE;
 108.122 -static jint source_actions = java_awt_dnd_DnDConstants_ACTION_NONE;
 108.123 -static jint target_action = java_awt_dnd_DnDConstants_ACTION_NONE;
 108.124 -
 108.125 -/* Forward declarations */
 108.126 -static void cleanup_drag(Display* dpy, Time time);
 108.127 -static Boolean process_proxy_mode_event(XEvent* xev);
 108.128 -
 108.129 -/**************************** XEmbed server DnD support ***********************/
 108.130 -static Window proxy_mode_source_window = None;
 108.131 -/******************************************************************************/
 108.132 -
 108.133 -/**************************** JNI stuff ***************************************/
 108.134 -
 108.135 -DECLARE_JAVA_CLASS(dscp_clazz, "sun/awt/dnd/SunDragSourceContextPeer")
 108.136 -
 108.137 -static void
 108.138 -ds_postDragSourceDragEvent(JNIEnv* env, jint targetAction, unsigned int state,
 108.139 -                           int x, int y, jint dispatch_type) {
 108.140 -    DECLARE_VOID_JAVA_METHOD(dscp_postDragSourceDragEvent, dscp_clazz,
 108.141 -                             "postDragSourceDragEvent", "(IIIII)V");
 108.142 -
 108.143 -    DASSERT(!JNU_IsNull(env, source_peer));
 108.144 -    if (JNU_IsNull(env, source_peer)) {
 108.145 -        return;
 108.146 -    }
 108.147 -
 108.148 -    (*env)->CallVoidMethod(env, source_peer, dscp_postDragSourceDragEvent,
 108.149 -                           targetAction, getModifiers(state, 0, 0), x, y,
 108.150 -                           dispatch_type);
 108.151 -}
 108.152 -
 108.153 -static jint
 108.154 -ds_convertModifiersToDropAction(JNIEnv* env, unsigned int state) {
 108.155 -    jint action;
 108.156 -    DECLARE_STATIC_JINT_JAVA_METHOD(dscp_convertModifiersToDropAction, dscp_clazz,
 108.157 -                                    "convertModifiersToDropAction", "(II)I");
 108.158 -    action = (*env)->CallStaticIntMethod(env, clazz, dscp_convertModifiersToDropAction,
 108.159 -                                              getModifiers(state, 0, 0), source_actions);
 108.160 -    if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
 108.161 -        (*env)->ExceptionDescribe(env);
 108.162 -        (*env)->ExceptionClear(env);
 108.163 -        return java_awt_dnd_DnDConstants_ACTION_NONE;
 108.164 -    }
 108.165 -    return action;
 108.166 -}
 108.167 -
 108.168 -static void
 108.169 -ds_postDragSourceEvent(JNIEnv* env, int x, int y) {
 108.170 -    DECLARE_VOID_JAVA_METHOD(dscp_dragExit, dscp_clazz,
 108.171 -                             "dragExit", "(II)V");
 108.172 -
 108.173 -    DASSERT(!JNU_IsNull(env, source_peer));
 108.174 -    if (JNU_IsNull(env, source_peer)) {
 108.175 -        return;
 108.176 -    }
 108.177 -
 108.178 -    (*env)->CallVoidMethod(env, source_peer, dscp_dragExit, x, y);
 108.179 -}
 108.180 -
 108.181 -static void
 108.182 -ds_postDragSourceDropEvent(JNIEnv* env, jboolean success, jint targetAction,
 108.183 -                           int x, int y) {
 108.184 -    DECLARE_VOID_JAVA_METHOD(dscp_dragDropFinished, dscp_clazz,
 108.185 -                             "dragDropFinished", "(ZIII)V");
 108.186 -
 108.187 -    DASSERT(!JNU_IsNull(env, source_peer));
 108.188 -    if (JNU_IsNull(env, source_peer)) {
 108.189 -        return;
 108.190 -    }
 108.191 -
 108.192 -    (*env)->CallVoidMethod(env, source_peer, dscp_dragDropFinished,
 108.193 -                           success, targetAction, x, y);
 108.194 -}
 108.195 -
 108.196 -/******************************************************************************/
 108.197 -
 108.198 -static void
 108.199 -cancel_drag(XtPointer client_data, XtIntervalId* id) {
 108.200 -    Time time_stamp = awt_util_getCurrentServerTime();
 108.201 -
 108.202 -    cleanup_drag(awt_display, time_stamp);
 108.203 -}
 108.204 -
 108.205 -#define DONT_CARE -1
 108.206 -
 108.207 -static void
 108.208 -awt_popupCallback(Widget shell, XtPointer closure, XtPointer call_data) {
 108.209 -    XtGrabKind grab_kind = XtGrabNone;
 108.210 -
 108.211 -    if (call_data != NULL) {
 108.212 -        grab_kind = *((XtGrabKind*)call_data);
 108.213 -    }
 108.214 -
 108.215 -    if (XmIsVendorShell(shell)) {
 108.216 -        int input_mode;
 108.217 -        XtVaGetValues(shell, XmNmwmInputMode, &input_mode, NULL);
 108.218 -        switch (input_mode) {
 108.219 -        case DONT_CARE:
 108.220 -        case MWM_INPUT_MODELESS:
 108.221 -            grab_kind = XtGrabNonexclusive; break;
 108.222 -        case MWM_INPUT_PRIMARY_APPLICATION_MODAL:
 108.223 -        case MWM_INPUT_SYSTEM_MODAL:
 108.224 -        case MWM_INPUT_FULL_APPLICATION_MODAL:
 108.225 -            grab_kind = XtGrabExclusive; break;
 108.226 -        }
 108.227 -    }
 108.228 -
 108.229 -    if (grab_kind == XtGrabExclusive) {
 108.230 -        /*
 108.231 -         * We should cancel the drag on the toolkit thread. Otherwise, it can be
 108.232 -         * called while the toolkit thread is waiting inside some drag callback.
 108.233 -         * In this case Motif will crash when the drag callback returns.
 108.234 -         */
 108.235 -        XtAppAddTimeOut(awt_appContext, 0L, cancel_drag, NULL);
 108.236 -    }
 108.237 -}
 108.238 -
 108.239 -static XtInitProc xt_shell_initialize = NULL;
 108.240 -
 108.241 -static void
 108.242 -awt_ShellInitialize(Widget req, Widget new, ArgList args, Cardinal *num_args) {
 108.243 -    XtAddCallback(new, XtNpopupCallback, awt_popupCallback, NULL);
 108.244 -    (*xt_shell_initialize)(req, new, args, num_args);
 108.245 -}
 108.246 -
 108.247 -/*
 108.248 - * Fix for 4484572 (copied from awt_XmDnD.c).
 108.249 - * Modify the 'initialize' routine for all ShellWidget instances, so that it
 108.250 - * will install an XtNpopupCallback that cancels the current drag operation.
 108.251 - * It is needed, since AWT doesn't have full control over all ShellWidget
 108.252 - * instances (e.g. XmPopupMenu internally creates and popups an XmMenuShell).
 108.253 - */
 108.254 -static void
 108.255 -awt_set_ShellInitialize() {
 108.256 -    static Boolean inited = False;
 108.257 -
 108.258 -    DASSERT(!inited);
 108.259 -    if (inited) {
 108.260 -        return;
 108.261 -    }
 108.262 -
 108.263 -    xt_shell_initialize = shellWidgetClass->core_class.initialize;
 108.264 -    shellWidgetClass->core_class.initialize = (XtInitProc)awt_ShellInitialize;
 108.265 -    inited = True;
 108.266 -}
 108.267 -
 108.268 -/*
 108.269 - * Returns True if initialization completes successfully.
 108.270 - */
 108.271 -Boolean
 108.272 -awt_dnd_ds_init(Display* display) {
 108.273 -    if (XSaveContext(display, XA_XdndSelection, awt_convertDataContext,
 108.274 -                     (XPointer)NULL) == XCNOMEM) {
 108.275 -        return False;
 108.276 -    }
 108.277 -
 108.278 -    if (XSaveContext(display, _XA_MOTIF_ATOM_0, awt_convertDataContext,
 108.279 -                     (XPointer)NULL) == XCNOMEM) {
 108.280 -        return False;
 108.281 -    }
 108.282 -
 108.283 -    {
 108.284 -        char *ev = getenv("_JAVA_DRAG_SOURCE_POLICY");
 108.285 -
 108.286 -        /* By default XDnD protocol is preferred. */
 108.287 -        drag_source_policy = DS_POLICY_PREFER_XDND;
 108.288 -
 108.289 -        if (ev != NULL) {
 108.290 -            if (strcmp(ev, "PREFER_XDND") == 0) {
 108.291 -                drag_source_policy = DS_POLICY_PREFER_XDND;
 108.292 -            } else if (strcmp(ev, "PREFER_MOTIF") == 0) {
 108.293 -                drag_source_policy = DS_POLICY_PREFER_MOTIF;
 108.294 -            } else if (strcmp(ev, "ONLY_MOTIF") == 0) {
 108.295 -                drag_source_policy = DS_POLICY_ONLY_MOTIF;
 108.296 -            } else if (strcmp(ev, "ONLY_XDND") == 0) {
 108.297 -                drag_source_policy = DS_POLICY_ONLY_XDND;
 108.298 -            }
 108.299 -        }
 108.300 -    }
 108.301 -
 108.302 -    awt_set_ShellInitialize();
 108.303 -
 108.304 -    return True;
 108.305 -}
 108.306 -
 108.307 -/*
 108.308 - * Returns a handle of the window used as a drag source.
 108.309 - */
 108.310 -Window
 108.311 -awt_dnd_ds_get_source_window() {
 108.312 -    return get_awt_root_window();
 108.313 -}
 108.314 -
 108.315 -/*
 108.316 - * Returns True if a drag operation initiated by this client
 108.317 - * is still in progress.
 108.318 - */
 108.319 -Boolean
 108.320 -awt_dnd_ds_in_progress() {
 108.321 -    return dnd_in_progress;
 108.322 -}
 108.323 -
 108.324 -static void
 108.325 -ds_send_event_to_target(XClientMessageEvent* xclient) {
 108.326 -    /* Shortcut if the source is in the same JVM. */
 108.327 -    if (XtWindowToWidget(xclient->display, target_proxy_window) != NULL) {
 108.328 -        awt_dnd_dt_process_event((XEvent*)xclient);
 108.329 -    } else {
 108.330 -        XSendEvent(xclient->display, target_proxy_window, False, NoEventMask,
 108.331 -                   (XEvent*)xclient);
 108.332 -    }
 108.333 -}
 108.334 -
 108.335 -static void
 108.336 -xdnd_send_enter(Display* dpy, Time time) {
 108.337 -    XClientMessageEvent enter;
 108.338 -
 108.339 -    enter.display = dpy;
 108.340 -    enter.type = ClientMessage;
 108.341 -    enter.window = target_window;
 108.342 -    enter.format = 32;
 108.343 -    enter.message_type = XA_XdndEnter;
 108.344 -    enter.data.l[0] = awt_dnd_ds_get_source_window();
 108.345 -    enter.data.l[1] = target_protocol_version << XDND_PROTOCOL_SHIFT;
 108.346 -    enter.data.l[1] |= data_types_count > 3 ? XDND_DATA_TYPES_BIT : 0;
 108.347 -    enter.data.l[2] = data_types_count > 0 ? data_types[0] : None;
 108.348 -    enter.data.l[3] = data_types_count > 1 ? data_types[1] : None;
 108.349 -    enter.data.l[4] = data_types_count > 2 ? data_types[2] : None;
 108.350 -
 108.351 -    ds_send_event_to_target(&enter);
 108.352 -}
 108.353 -
 108.354 -static void
 108.355 -motif_send_enter(Display* dpy, Time time) {
 108.356 -    XClientMessageEvent enter;
 108.357 -
 108.358 -    enter.display = dpy;
 108.359 -    enter.type = ClientMessage;
 108.360 -    enter.window = target_window;
 108.361 -    enter.format = 8;
 108.362 -    enter.message_type = _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
 108.363 -
 108.364 -    {
 108.365 -        void* p = &enter.data.b[0];
 108.366 -        int flags = 0;
 108.367 -
 108.368 -        flags |= java_to_motif_actions(source_action) << MOTIF_DND_ACTION_SHIFT;
 108.369 -        flags |= java_to_motif_actions(source_actions) << MOTIF_DND_ACTIONS_SHIFT;
 108.370 -
 108.371 -        write_card8(&p, TOP_LEVEL_ENTER | MOTIF_MESSAGE_FROM_INITIATOR);
 108.372 -        write_card8(&p, MOTIF_BYTE_ORDER);
 108.373 -        write_card16(&p, flags);
 108.374 -        write_card32(&p, time);
 108.375 -        write_card32(&p, awt_dnd_ds_get_source_window());
 108.376 -        write_card32(&p, _XA_MOTIF_ATOM_0);
 108.377 -    }
 108.378 -
 108.379 -    ds_send_event_to_target(&enter);
 108.380 -}
 108.381 -
 108.382 -static void
 108.383 -send_enter(Display* dpy, Time time) {
 108.384 -    switch (target_protocol) {
 108.385 -    case XDND_PROTOCOL:
 108.386 -        xdnd_send_enter(dpy, time);
 108.387 -        break;
 108.388 -    case MOTIF_DND_PROTOCOL:
 108.389 -        motif_send_enter(dpy, time);
 108.390 -        break;
 108.391 -    case NO_PROTOCOL:
 108.392 -    default:
 108.393 -        DTRACE_PRINTLN2("%s:%d send_enter: unknown DnD protocol.", __FILE__, __LINE__);
 108.394 -        break;
 108.395 -    }
 108.396 -}
 108.397 -
 108.398 -static void
 108.399 -xdnd_send_move(XMotionEvent* event) {
 108.400 -    XClientMessageEvent move;
 108.401 -
 108.402 -    move.display = event->display;
 108.403 -    move.type = ClientMessage;
 108.404 -    move.window = target_window;
 108.405 -    move.format = 32;
 108.406 -    move.message_type = XA_XdndPosition;
 108.407 -    move.data.l[0] = awt_dnd_ds_get_source_window();
 108.408 -    move.data.l[1] = 0; /* flags */
 108.409 -    move.data.l[2] = event->x_root << 16 | event->y_root;
 108.410 -    move.data.l[3] = event->time;
 108.411 -    move.data.l[4] = java_to_xdnd_action(source_action);
 108.412 -
 108.413 -    ds_send_event_to_target(&move);
 108.414 -}
 108.415 -
 108.416 -static void
 108.417 -motif_send_move(XMotionEvent* event) {
 108.418 -    XClientMessageEvent move;
 108.419 -
 108.420 -    move.display = event->display;
 108.421 -    move.type = ClientMessage;
 108.422 -    move.window = target_window;
 108.423 -    move.format = 8;
 108.424 -    move.message_type = _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
 108.425 -
 108.426 -    {
 108.427 -        void* p = move.data.b;
 108.428 -        int flags = 0;
 108.429 -
 108.430 -        flags |= java_to_motif_actions(source_action) << MOTIF_DND_ACTION_SHIFT;
 108.431 -        flags |= java_to_motif_actions(source_actions) << MOTIF_DND_ACTIONS_SHIFT;
 108.432 -
 108.433 -        write_card8(&p, DRAG_MOTION | MOTIF_MESSAGE_FROM_INITIATOR);
 108.434 -        write_card8(&p, MOTIF_BYTE_ORDER);
 108.435 -        write_card16(&p, flags);
 108.436 -        write_card32(&p, event->time);
 108.437 -        write_card16(&p, event->x_root);
 108.438 -        write_card16(&p, event->y_root);
 108.439 -    }
 108.440 -
 108.441 -    ds_send_event_to_target(&move);
 108.442 -}
 108.443 -
 108.444 -static void
 108.445 -send_move(XMotionEvent* event) {
 108.446 -    switch (target_protocol) {
 108.447 -    case XDND_PROTOCOL:
 108.448 -        xdnd_send_move(event);
 108.449 -        break;
 108.450 -    case MOTIF_DND_PROTOCOL:
 108.451 -        motif_send_move(event);
 108.452 -        break;
 108.453 -    case NO_PROTOCOL:
 108.454 -    default:
 108.455 -        DTRACE_PRINTLN2("%s:%d send_move: unknown DnD protocol.", __FILE__, __LINE__);
 108.456 -        break;
 108.457 -    }
 108.458 -}
 108.459 -
 108.460 -static void
 108.461 -xdnd_send_leave(Display* dpy, Time time) {
 108.462 -    XClientMessageEvent leave;
 108.463 -
 108.464 -    leave.display = dpy;
 108.465 -    leave.type = ClientMessage;
 108.466 -    leave.window = target_window;
 108.467 -    leave.format = 32;
 108.468 -    leave.message_type = XA_XdndLeave;
 108.469 -    leave.data.l[0] = awt_dnd_ds_get_source_window();
 108.470 -    leave.data.l[1] = 0;
 108.471 -    leave.data.l[2] = 0;
 108.472 -    leave.data.l[3] = 0;
 108.473 -    leave.data.l[4] = 0;
 108.474 -
 108.475 -    ds_send_event_to_target(&leave);
 108.476 -}
 108.477 -
 108.478 -static void
 108.479 -motif_send_leave(Display* dpy, Time time) {
 108.480 -    XClientMessageEvent leave;
 108.481 -
 108.482 -    leave.display = dpy;
 108.483 -    leave.type = ClientMessage;
 108.484 -    leave.window = target_window;
 108.485 -    leave.format = 8;
 108.486 -    leave.message_type = _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
 108.487 -
 108.488 -    {
 108.489 -        void* p = &leave.data.b[0];
 108.490 -
 108.491 -        write_card8(&p, TOP_LEVEL_LEAVE | MOTIF_MESSAGE_FROM_INITIATOR);
 108.492 -        write_card8(&p, MOTIF_BYTE_ORDER);
 108.493 -        write_card16(&p, 0);
 108.494 -        write_card32(&p, time);
 108.495 -        write_card32(&p, awt_dnd_ds_get_source_window());
 108.496 -    }
 108.497 -
 108.498 -    ds_send_event_to_target(&leave);
 108.499 -}
 108.500 -
 108.501 -static void
 108.502 -send_leave(Display* dpy, Time time) {
 108.503 -    switch (target_protocol) {
 108.504 -    case XDND_PROTOCOL:
 108.505 -        xdnd_send_leave(dpy, time);
 108.506 -        break;
 108.507 -    case MOTIF_DND_PROTOCOL:
 108.508 -        motif_send_leave(dpy, time);
 108.509 -        break;
 108.510 -    case NO_PROTOCOL:
 108.511 -    default:
 108.512 -        DTRACE_PRINTLN2("%s:%d send_leave: unknown DnD protocol.", __FILE__, __LINE__);
 108.513 -        break;
 108.514 -    }
 108.515 -}
 108.516 -
 108.517 -
 108.518 -static void
 108.519 -xdnd_send_drop(XButtonEvent* event) {
 108.520 -    XClientMessageEvent drop;
 108.521 -
 108.522 -    drop.display = event->display;
 108.523 -    drop.type = ClientMessage;
 108.524 -    drop.window = target_window;
 108.525 -    drop.format = 32;
 108.526 -    drop.message_type = XA_XdndDrop;
 108.527 -    drop.data.l[0] = awt_dnd_ds_get_source_window();
 108.528 -    drop.data.l[1] = 0; /* flags */
 108.529 -    drop.data.l[2] = event->time; /* ### */
 108.530 -    drop.data.l[3] = 0;
 108.531 -    drop.data.l[4] = 0;
 108.532 -
 108.533 -    ds_send_event_to_target(&drop);
 108.534 -}
 108.535 -
 108.536 -static void
 108.537 -motif_send_drop(XButtonEvent* event) {
 108.538 -    XClientMessageEvent drop;
 108.539 -
 108.540 -    /*
 108.541 -     * Motif drop sites expect TOP_LEVEL_LEAVE before DROP_START.
 108.542 -     */
 108.543 -    motif_send_leave(event->display, event->time);
 108.544 -
 108.545 -    drop.display = event->display;
 108.546 -    drop.type = ClientMessage;
 108.547 -    drop.window = target_window;
 108.548 -    drop.format = 8;
 108.549 -    drop.message_type = _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
 108.550 -
 108.551 -    {
 108.552 -        void* p = &drop.data.b[0];
 108.553 -        int flags = 0;
 108.554 -
 108.555 -        flags |= java_to_motif_actions(source_action) << MOTIF_DND_ACTION_SHIFT;
 108.556 -        flags |= java_to_motif_actions(source_actions) << MOTIF_DND_ACTIONS_SHIFT;
 108.557 -
 108.558 -        write_card8(&p, DROP_START | MOTIF_MESSAGE_FROM_INITIATOR);
 108.559 -        write_card8(&p, MOTIF_BYTE_ORDER);
 108.560 -        write_card16(&p, flags);
 108.561 -        write_card32(&p, event->time);
 108.562 -        write_card16(&p, event->x_root);
 108.563 -        write_card16(&p, event->y_root);
 108.564 -        write_card32(&p, _XA_MOTIF_ATOM_0);
 108.565 -        write_card32(&p, awt_dnd_ds_get_source_window());
 108.566 -    }
 108.567 -
 108.568 -    ds_send_event_to_target(&drop);
 108.569 -}
 108.570 -
 108.571 -static void
 108.572 -send_drop(XButtonEvent* event) {
 108.573 -    switch (target_protocol) {
 108.574 -    case XDND_PROTOCOL:
 108.575 -        xdnd_send_drop(event);
 108.576 -        break;
 108.577 -    case MOTIF_DND_PROTOCOL:
 108.578 -        motif_send_drop(event);
 108.579 -        break;
 108.580 -    case NO_PROTOCOL:
 108.581 -    default:
 108.582 -        DTRACE_PRINTLN2("%s:%d send_drop: unknown DnD protocol.", __FILE__, __LINE__);
 108.583 -        break;
 108.584 -    }
 108.585 -}
 108.586 -
 108.587 -static void
 108.588 -remove_dnd_grab(Display* dpy, Time time) {
 108.589 -    XUngrabPointer(dpy, time);
 108.590 -    XUngrabKeyboard(dpy, time);
 108.591 -
 108.592 -    /* Restore the root event mask if it was changed. */
 108.593 -    if ((your_root_event_mask | ROOT_EVENT_MASK) != your_root_event_mask &&
 108.594 -        drag_root_window != None) {
 108.595 -
 108.596 -        XSelectInput(dpy, drag_root_window, your_root_event_mask);
 108.597 -
 108.598 -        drag_root_window = None;
 108.599 -        your_root_event_mask = NoEventMask;
 108.600 -    }
 108.601 -}
 108.602 -
 108.603 -static void
 108.604 -cleanup_target_info(Display* dpy) {
 108.605 -    target_root_subwindow = None;
 108.606 -
 108.607 -    target_window = None;
 108.608 -    target_proxy_window = None;
 108.609 -    target_protocol = NO_PROTOCOL;
 108.610 -    target_protocol_version = 0;
 108.611 -    target_enter_server_time = CurrentTime;
 108.612 -    target_action = java_awt_dnd_DnDConstants_ACTION_NONE;
 108.613 -}
 108.614 -
 108.615 -static void
 108.616 -cleanup_drag(Display* dpy, Time time) {
 108.617 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
 108.618 -
 108.619 -    if (dnd_in_progress) {
 108.620 -        if (target_window != None) {
 108.621 -            send_leave(dpy, time);
 108.622 -        }
 108.623 -
 108.624 -        if (target_action != java_awt_dnd_DnDConstants_ACTION_NONE) {
 108.625 -            JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
 108.626 -            ds_postDragSourceEvent(env, x_root, y_root);
 108.627 -        }
 108.628 -
 108.629 -        ds_postDragSourceDropEvent(env, JNI_FALSE,
 108.630 -                                   java_awt_dnd_DnDConstants_ACTION_NONE,
 108.631 -                                   x_root, y_root);
 108.632 -    }
 108.633 -
 108.634 -    /* Cleanup the global state */
 108.635 -    dnd_in_progress = False;
 108.636 -    drag_in_progress = False;
 108.637 -    data_types_count = 0;
 108.638 -    if (data_types != NULL) {
 108.639 -        free(data_types);
 108.640 -        data_types = NULL;
 108.641 -    }
 108.642 -    if (!JNU_IsNull(env, source_peer)) {
 108.643 -        (*env)->DeleteGlobalRef(env, source_peer);
 108.644 -        source_peer = NULL;
 108.645 -    }
 108.646 -
 108.647 -    cleanup_target_info(dpy);
 108.648 -
 108.649 -    remove_dnd_grab(dpy, time);
 108.650 -
 108.651 -    XDeleteProperty(awt_display, awt_dnd_ds_get_source_window(), _XA_MOTIF_ATOM_0);
 108.652 -    XDeleteProperty(awt_display, awt_dnd_ds_get_source_window(), XA_XdndTypeList);
 108.653 -    XDeleteProperty(awt_display, awt_dnd_ds_get_source_window(), XA_XdndActionList);
 108.654 -    XtDisownSelection(awt_root_shell, _XA_MOTIF_ATOM_0, time);
 108.655 -    XtDisownSelection(awt_root_shell, XA_XdndSelection, time);
 108.656 -
 108.657 -    awt_cleanupConvertDataContext(env, _XA_MOTIF_ATOM_0);
 108.658 -    awt_cleanupConvertDataContext(env, XA_XdndSelection);
 108.659 -}
 108.660 -
 108.661 -static void
 108.662 -process_drop(XButtonEvent* event) {
 108.663 -    unsigned char ret;
 108.664 -    XWindowAttributes xwa;
 108.665 -
 108.666 -    DASSERT(target_window != None);
 108.667 -
 108.668 -    XGetWindowAttributes(event->display, target_window, &xwa);
 108.669 -
 108.670 -    target_window_mask = xwa.your_event_mask;
 108.671 -
 108.672 -    /* Select for DestoyNotify to cleanup if the target crashes. */
 108.673 -    ret = checked_XSelectInput(event->display, target_window,
 108.674 -                               (target_window_mask | StructureNotifyMask));
 108.675 -
 108.676 -    if (ret == Success) {
 108.677 -        send_drop(event);
 108.678 -    } else {
 108.679 -        DTRACE_PRINTLN2("%s:%d drop rejected - invalid window.",
 108.680 -                        __FILE__, __LINE__);
 108.681 -        cleanup_drag(event->display, event->time);
 108.682 -    }
 108.683 -}
 108.684 -
 108.685 -static Window
 108.686 -find_client_window(Display* dpy, Window window) {
 108.687 -    Window root, parent, *children;
 108.688 -    unsigned int nchildren, idx;
 108.689 -
 108.690 -    Atom           type;
 108.691 -    int            format;
 108.692 -    unsigned long  nitems;
 108.693 -    unsigned long  after;
 108.694 -    unsigned char  *data;
 108.695 -    Status ret;
 108.696 -
 108.697 -    if (XGetWindowProperty(dpy, window, XA_WM_STATE, 0, 0, False,
 108.698 -                           AnyPropertyType, &type, &format, &nitems,
 108.699 -                           &after, &data) == Success) {
 108.700 -        XFree(data);
 108.701 -    }
 108.702 -
 108.703 -    if (type != None) {
 108.704 -        return window;
 108.705 -    }
 108.706 -
 108.707 -    if (!XQueryTree(dpy, window, &root, &parent, &children, &nchildren)) {
 108.708 -        return None;
 108.709 -    }
 108.710 -
 108.711 -    if (children == NULL) {
 108.712 -        return None;
 108.713 -    }
 108.714 -
 108.715 -    for (idx = 0; idx < nchildren; idx++) {
 108.716 -        Window win = find_client_window(dpy, children[idx]);
 108.717 -        if (win != None) {
 108.718 -            XFree(children);
 108.719 -            return win;
 108.720 -        }
 108.721 -    }
 108.722 -
 108.723 -    XFree(children);
 108.724 -    return None;
 108.725 -}
 108.726 -
 108.727 -static void
 108.728 -do_update_target_window(Display* dpy, Window subwindow, Time time) {
 108.729 -    Window client_window = None;
 108.730 -    Window proxy_window = None;
 108.731 -    Protocol protocol = NO_PROTOCOL;
 108.732 -    unsigned int protocol_version = 0;
 108.733 -    Boolean is_receiver = False;
 108.734 -
 108.735 -    client_window = find_client_window(dpy, subwindow);
 108.736 -
 108.737 -    if (client_window != None) {
 108.738 -        /* Request status */
 108.739 -        int            status;
 108.740 -
 108.741 -        /* Returns of XGetWindowProperty */
 108.742 -        Atom           type;
 108.743 -        int            format;
 108.744 -        unsigned long  nitems;
 108.745 -        unsigned long  after;
 108.746 -        unsigned char  *data;
 108.747 -
 108.748 -        /*
 108.749 -         * No need for checked_XGetWindowProperty, since we check the returned
 108.750 -         * property type anyway.
 108.751 -         */
 108.752 -        if (drag_source_policy != DS_POLICY_ONLY_XDND) {
 108.753 -
 108.754 -            data = NULL;
 108.755 -            status = XGetWindowProperty(dpy, client_window,
 108.756 -                                        _XA_MOTIF_DRAG_RECEIVER_INFO,
 108.757 -                                        0, 0xFFFF, False, AnyPropertyType,
 108.758 -                                        &type, &format, &nitems, &after, &data);
 108.759 -
 108.760 -            if (status == Success && data != NULL && type != None && format == 8
 108.761 -                && nitems >= MOTIF_RECEIVER_INFO_SIZE) {
 108.762 -                unsigned char byte_order = read_card8((char*)data, 0);
 108.763 -                unsigned char drag_protocol_style = read_card8((char*)data, 2);
 108.764 -
 108.765 -                switch (drag_protocol_style) {
 108.766 -                case MOTIF_PREFER_PREREGISTER_STYLE :
 108.767 -                case MOTIF_PREFER_DYNAMIC_STYLE :
 108.768 -                case MOTIF_DYNAMIC_STYLE :
 108.769 -                case MOTIF_PREFER_RECEIVER_STYLE :
 108.770 -                    proxy_window = read_card32((char*)data, 4, byte_order);
 108.771 -                    protocol = MOTIF_DND_PROTOCOL;
 108.772 -                    protocol_version = read_card8((char*)data, 1);
 108.773 -                    is_receiver = True;
 108.774 -                    break;
 108.775 -                default:
 108.776 -                    DTRACE_PRINTLN3("%s:%d unsupported protocol style (%d).",
 108.777 -                                    __FILE__, __LINE__, (int)drag_protocol_style);
 108.778 -                }
 108.779 -            }
 108.780 -
 108.781 -            if (status == Success) {
 108.782 -                XFree(data);
 108.783 -                data = NULL;
 108.784 -            }
 108.785 -        }
 108.786 -
 108.787 -        if (drag_source_policy != DS_POLICY_ONLY_MOTIF &&
 108.788 -            (drag_source_policy != DS_POLICY_PREFER_MOTIF || !is_receiver)) {
 108.789 -
 108.790 -            data = NULL;
 108.791 -            status = XGetWindowProperty(dpy, client_window, XA_XdndAware, 0, 1,
 108.792 -                                        False, AnyPropertyType, &type, &format,
 108.793 -                                        &nitems, &after, &data);
 108.794 -
 108.795 -            if (status == Success && data != NULL && type == XA_ATOM) {
 108.796 -                unsigned int target_version = *((unsigned int*)data);
 108.797 -
 108.798 -                if (target_version >= XDND_MIN_PROTOCOL_VERSION) {
 108.799 -                    proxy_window = None;
 108.800 -                    protocol = XDND_PROTOCOL;
 108.801 -                    protocol_version = target_version < XDND_PROTOCOL_VERSION ?
 108.802 -                        target_version : XDND_PROTOCOL_VERSION;
 108.803 -                    is_receiver = True;
 108.804 -                }
 108.805 -            }
 108.806 -
 108.807 -            /* Retrieve the proxy window handle and check if it is valid. */
 108.808 -            if (protocol == XDND_PROTOCOL) {
 108.809 -                if (status == Success) {
 108.810 -                    XFree(data);
 108.811 -                }
 108.812 -
 108.813 -                data = NULL;
 108.814 -                status = XGetWindowProperty(dpy, client_window, XA_XdndProxy, 0,
 108.815 -                                            1, False, XA_WINDOW, &type, &format,
 108.816 -                                            &nitems, &after, &data);
 108.817 -
 108.818 -                if (status == Success && data != NULL && type == XA_WINDOW) {
 108.819 -                    proxy_window = *((Window*)data);
 108.820 -                }
 108.821 -
 108.822 -                if (proxy_window != None) {
 108.823 -                    if (status == Success) {
 108.824 -                        XFree(data);
 108.825 -                    }
 108.826 -
 108.827 -                    data = NULL;
 108.828 -                    status = XGetWindowProperty(dpy, proxy_window, XA_XdndProxy,
 108.829 -                                                0, 1, False, XA_WINDOW, &type,
 108.830 -                                                &format, &nitems, &after, &data);
 108.831 -
 108.832 -                    if (status != Success || data == NULL || type != XA_WINDOW ||
 108.833 -                        *((Window*)data) != proxy_window) {
 108.834 -                        proxy_window = None;
 108.835 -                    } else {
 108.836 -                        if (status == Success) {
 108.837 -                            XFree(data);
 108.838 -                        }
 108.839 -
 108.840 -                        data = NULL;
 108.841 -                        status = XGetWindowProperty(dpy, proxy_window,
 108.842 -                                                    XA_XdndAware,  0, 1, False,
 108.843 -                                                    AnyPropertyType, &type,
 108.844 -                                                    &format, &nitems, &after,
 108.845 -                                                    &data);
 108.846 -
 108.847 -                        if (status != Success || data == NULL || type != XA_ATOM) {
 108.848 -                            proxy_window = None;
 108.849 -                        }
 108.850 -                    }
 108.851 -                }
 108.852 -            }
 108.853 -
 108.854 -            XFree(data);
 108.855 -        }
 108.856 -
 108.857 -        if (proxy_window == None) {
 108.858 -            proxy_window = client_window;
 108.859 -        }
 108.860 -    }
 108.861 -
 108.862 -    if (is_receiver) {
 108.863 -        target_window = client_window;
 108.864 -        target_proxy_window = proxy_window;
 108.865 -        target_protocol = protocol;
 108.866 -        target_protocol_version = protocol_version;
 108.867 -    } else {
 108.868 -        target_window = None;
 108.869 -        target_proxy_window = None;
 108.870 -        target_protocol = NO_PROTOCOL;
 108.871 -        target_protocol_version = 0;
 108.872 -    }
 108.873 -
 108.874 -    target_action = java_awt_dnd_DnDConstants_ACTION_NONE;
 108.875 -
 108.876 -    if (target_window != None) {
 108.877 -        target_enter_server_time = time;
 108.878 -    } else {
 108.879 -        target_enter_server_time = CurrentTime;
 108.880 -    }
 108.881 -
 108.882 -    target_root_subwindow = subwindow;
 108.883 -}
 108.884 -
 108.885 -static void
 108.886 -update_target_window(XMotionEvent* event) {
 108.887 -    Display* dpy = event->display;
 108.888 -    int x = event->x_root;
 108.889 -    int y = event->x_root;
 108.890 -    Time time = event->time;
 108.891 -    Window subwindow = event->subwindow;
 108.892 -
 108.893 -    /*
 108.894 -     * If this event had occurred before the pointer was grabbed,
 108.895 -     * query the server for the current root subwindow.
 108.896 -     */
 108.897 -    if (event->window != event->root) {
 108.898 -        int xw, yw, xr, yr;
 108.899 -        unsigned int modifiers;
 108.900 -        XQueryPointer(dpy, event->root, &event->root, &subwindow,
 108.901 -                      &xr, &yr, &xw, &yw, &modifiers);
 108.902 -    }
 108.903 -
 108.904 -    if (target_root_subwindow != subwindow) {
 108.905 -        if (target_window != None) {
 108.906 -            send_leave(dpy, time);
 108.907 -
 108.908 -            /*
 108.909 -             * Neither Motif DnD nor XDnD provide a mean for the target
 108.910 -             * to notify the source that the pointer exits the drop site
 108.911 -             * that occupies the whole top level.
 108.912 -             * We detect this situation and post dragExit.
 108.913 -             */
 108.914 -            if (target_action != java_awt_dnd_DnDConstants_ACTION_NONE) {
 108.915 -                JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
 108.916 -                ds_postDragSourceEvent(env, x, y);
 108.917 -            }
 108.918 -        }
 108.919 -
 108.920 -        /* Update the global state. */
 108.921 -        do_update_target_window(dpy, subwindow, time);
 108.922 -
 108.923 -        if (target_window != None) {
 108.924 -            send_enter(dpy, time);
 108.925 -        }
 108.926 -    }
 108.927 -}
 108.928 -
 108.929 -/*
 108.930 - * Updates the source action based on the specified event state.
 108.931 - * Returns True if source action changed, False otherwise.
 108.932 - */
 108.933 -static Boolean
 108.934 -update_source_action(unsigned int state) {
 108.935 -    JNIEnv* env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
 108.936 -    jint action = ds_convertModifiersToDropAction(env, state);
 108.937 -    if (source_action == action) {
 108.938 -        return False;
 108.939 -    }
 108.940 -    source_action = action;
 108.941 -    return True;
 108.942 -}
 108.943 -
 108.944 -static void
 108.945 -handle_mouse_move(XMotionEvent* event) {
 108.946 -    if (!drag_in_progress) {
 108.947 -        return;
 108.948 -    }
 108.949 -
 108.950 -    if (x_root != event->x_root || y_root != event->y_root) {
 108.951 -        JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
 108.952 -        ds_postDragSourceDragEvent(env, target_action, event->state,
 108.953 -                                   event->x_root, event->y_root,
 108.954 -                                   sun_awt_dnd_SunDragSourceContextPeer_DISPATCH_MOUSE_MOVED);
 108.955 -
 108.956 -        x_root = event->x_root;
 108.957 -        y_root = event->y_root;
 108.958 -    }
 108.959 -
 108.960 -    if (event_state != event->state) {
 108.961 -        if (update_source_action(event->state) && target_window != None) {
 108.962 -            JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
 108.963 -            ds_postDragSourceDragEvent(env, target_action, event->state,
 108.964 -                                       event->x_root, event->y_root,
 108.965 -                                       sun_awt_dnd_SunDragSourceContextPeer_DISPATCH_CHANGED);
 108.966 -        }
 108.967 -        event_state = event->state;
 108.968 -    }
 108.969 -
 108.970 -    update_target_window(event);
 108.971 -
 108.972 -    if (target_window != None) {
 108.973 -        send_move(event);
 108.974 -    }
 108.975 -}
 108.976 -
 108.977 -static Boolean
 108.978 -handle_xdnd_status(XClientMessageEvent* event) {
 108.979 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
 108.980 -    long* event_data = event->data.l;
 108.981 -    Window target_win = None;
 108.982 -    jint action = java_awt_dnd_DnDConstants_ACTION_NONE;
 108.983 -
 108.984 -    DTRACE_PRINTLN4("%s:%d XdndStatus target_window=%ld target_protocol=%d.",
 108.985 -                    __FILE__, __LINE__, target_window, target_protocol);
 108.986 -
 108.987 -    if (target_protocol != XDND_PROTOCOL) {
 108.988 -        DTRACE_PRINTLN2("%s:%d XdndStatus rejected - invalid state.",
 108.989 -                        __FILE__, __LINE__);
 108.990 -        return True;
 108.991 -    }
 108.992 -
 108.993 -    target_win = event_data[0];
 108.994 -
 108.995 -    /* Ignore XDnD messages from all other windows. */
 108.996 -    if (target_window != target_win) {
 108.997 -        DTRACE_PRINTLN4("%s:%d XdndStatus rejected - invalid target window cur=%ld this=%ld.",
 108.998 -                        __FILE__, __LINE__, target_window, target_win);
 108.999 -        return True;
108.1000 -    }
108.1001 -
108.1002 -    if (event_data[1] & XDND_ACCEPT_DROP_FLAG) {
108.1003 -        /* This feature is new in XDnD version 2, but we can use it as XDnD
108.1004 -           compliance only requires supporting version 3 and up. */
108.1005 -        action = xdnd_to_java_action(event_data[4]);
108.1006 -    }
108.1007 -
108.1008 -    if (action == java_awt_dnd_DnDConstants_ACTION_NONE &&
108.1009 -        target_action != java_awt_dnd_DnDConstants_ACTION_NONE) {
108.1010 -        ds_postDragSourceEvent(env, x_root, y_root);
108.1011 -    } else if (action != java_awt_dnd_DnDConstants_ACTION_NONE) {
108.1012 -        jint type = 0;
108.1013 -
108.1014 -        if (target_action == java_awt_dnd_DnDConstants_ACTION_NONE) {
108.1015 -            type = sun_awt_dnd_SunDragSourceContextPeer_DISPATCH_ENTER;
108.1016 -        } else {
108.1017 -            type = sun_awt_dnd_SunDragSourceContextPeer_DISPATCH_MOTION;
108.1018 -        }
108.1019 -
108.1020 -        ds_postDragSourceDragEvent(env, action, event_state,
108.1021 -                                   x_root, y_root, type);
108.1022 -    }
108.1023 -
108.1024 -    target_action = action;
108.1025 -
108.1026 -    return True;
108.1027 -}
108.1028 -
108.1029 -static Boolean
108.1030 -handle_xdnd_finished(XClientMessageEvent* event) {
108.1031 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
108.1032 -    long* event_data = event->data.l;
108.1033 -    Window target_win = None;
108.1034 -    jboolean success = JNI_TRUE;
108.1035 -    jint action = java_awt_dnd_DnDConstants_ACTION_NONE;
108.1036 -
108.1037 -    if (target_protocol != XDND_PROTOCOL) {
108.1038 -        DTRACE_PRINTLN2("%s:%d XdndStatus rejected - invalid state.",
108.1039 -                        __FILE__, __LINE__);
108.1040 -        return True;
108.1041 -    }
108.1042 -
108.1043 -    target_win = event_data[0];
108.1044 -
108.1045 -    /* Ignore XDnD messages from all other windows. */
108.1046 -    if (target_window != target_win) {
108.1047 -        DTRACE_PRINTLN4("%s:%d XdndStatus rejected - invalid target window cur=%ld this=%ld.",
108.1048 -                        __FILE__, __LINE__, target_window, target_win);
108.1049 -        return True;
108.1050 -    }
108.1051 -
108.1052 -    if (target_protocol_version >= 5) {
108.1053 -        success = (event_data[1] & XDND_ACCEPT_DROP_FLAG) != 0 ?
108.1054 -            JNI_TRUE : JNI_FALSE;
108.1055 -        action = xdnd_to_java_action(event_data[2]);
108.1056 -    } else {
108.1057 -        /* Assume that the drop was successful and the performed drop action is
108.1058 -           the drop action accepted with the latest XdndStatus message. */
108.1059 -        success = JNI_TRUE;
108.1060 -        action = target_action;
108.1061 -    }
108.1062 -
108.1063 -    ds_postDragSourceDropEvent(env, success, action, x_root, y_root);
108.1064 -
108.1065 -    dnd_in_progress = False;
108.1066 -
108.1067 -    XSelectInput(event->display, target_win, target_window_mask);
108.1068 -
108.1069 -    cleanup_drag(event->display, CurrentTime);
108.1070 -
108.1071 -    return True;
108.1072 -}
108.1073 -
108.1074 -static Boolean
108.1075 -handle_motif_client_message(XClientMessageEvent* event) {
108.1076 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
108.1077 -    int reason = (int)(event->data.b[0] & MOTIF_MESSAGE_REASON_MASK);
108.1078 -    int origin = (int)(event->data.b[0] & MOTIF_MESSAGE_SENDER_MASK);
108.1079 -    unsigned char byte_order = event->data.b[1];
108.1080 -    jint action = java_awt_dnd_DnDConstants_ACTION_NONE;
108.1081 -    Time time = CurrentTime;
108.1082 -    int x = 0, y = 0;
108.1083 -
108.1084 -    /* Only receiver messages should be handled. */
108.1085 -    if (origin != MOTIF_MESSAGE_FROM_RECEIVER) {
108.1086 -        return False;
108.1087 -    }
108.1088 -
108.1089 -    if (target_protocol != MOTIF_DND_PROTOCOL) {
108.1090 -        DTRACE_PRINTLN2("%s:%d _MOTIF_DRAG_AND_DROP_MESSAGE rejected - invalid state.",
108.1091 -                        __FILE__, __LINE__);
108.1092 -        return True;
108.1093 -    }
108.1094 -
108.1095 -    switch (reason) {
108.1096 -    case DROP_SITE_ENTER:
108.1097 -    case DROP_SITE_LEAVE:
108.1098 -    case DRAG_MOTION:
108.1099 -    case OPERATION_CHANGED:
108.1100 -        break;
108.1101 -    default:
108.1102 -        return False;
108.1103 -    }
108.1104 -
108.1105 -    time = read_card32(event->data.b, 4, byte_order);
108.1106 -
108.1107 -    /* Discard events from the previous receiver. */
108.1108 -    if (target_enter_server_time == CurrentTime ||
108.1109 -        time < target_enter_server_time) {
108.1110 -        DTRACE_PRINTLN2("%s:%d _MOTIF_DRAG_AND_DROP_MESSAGE rejected - invalid time.",
108.1111 -                        __FILE__, __LINE__);
108.1112 -        return True;
108.1113 -    }
108.1114 -
108.1115 -    if (reason != DROP_SITE_LEAVE) {
108.1116 -        CARD16 flags = read_card16(event->data.b, 2, byte_order);
108.1117 -        unsigned char status = (flags & MOTIF_DND_STATUS_MASK) >>
108.1118 -            MOTIF_DND_STATUS_SHIFT;
108.1119 -        unsigned char motif_action = (flags & MOTIF_DND_ACTION_MASK) >>
108.1120 -            MOTIF_DND_ACTION_SHIFT;
108.1121 -
108.1122 -        if (status == MOTIF_VALID_DROP_SITE) {
108.1123 -            action = motif_to_java_actions(motif_action);
108.1124 -        } else {
108.1125 -            action = java_awt_dnd_DnDConstants_ACTION_NONE;
108.1126 -        }
108.1127 -
108.1128 -        x = read_card16(event->data.b, 8, byte_order);
108.1129 -        y = read_card16(event->data.b, 10, byte_order);
108.1130 -    }
108.1131 -
108.1132 -    /*
108.1133 -     * We should derive the type of java event to post not from the message
108.1134 -     * reason, but from the combination of the current and previous target
108.1135 -     * actions:
108.1136 -     * Even if the reason is DROP_SITE_LEAVE we shouldn't post dragExit
108.1137 -     * if the drag was rejected earlier.
108.1138 -     * Even if the reason is DROP_SITE_ENTER we shouldn't post dragEnter
108.1139 -     * if the drag is not accepted.
108.1140 -     */
108.1141 -    if (target_action != java_awt_dnd_DnDConstants_ACTION_NONE &&
108.1142 -        action == java_awt_dnd_DnDConstants_ACTION_NONE) {
108.1143 -
108.1144 -        ds_postDragSourceEvent(env, x, y);
108.1145 -    } else if (action != java_awt_dnd_DnDConstants_ACTION_NONE) {
108.1146 -        jint type = 0;
108.1147 -
108.1148 -        if (target_action == java_awt_dnd_DnDConstants_ACTION_NONE) {
108.1149 -            type = sun_awt_dnd_SunDragSourceContextPeer_DISPATCH_ENTER;
108.1150 -        } else {
108.1151 -            type = sun_awt_dnd_SunDragSourceContextPeer_DISPATCH_MOTION;
108.1152 -        }
108.1153 -
108.1154 -        ds_postDragSourceDragEvent(env, action, event_state, x, y, type);
108.1155 -    }
108.1156 -
108.1157 -    target_action = action;
108.1158 -
108.1159 -    return True;
108.1160 -}
108.1161 -
108.1162 -/*
108.1163 - * Handles client messages.
108.1164 - * Returns True if the event is processed, False otherwise.
108.1165 - */
108.1166 -static Boolean
108.1167 -handle_client_message(XClientMessageEvent* event) {
108.1168 -    if (event->message_type == XA_XdndStatus) {
108.1169 -        return handle_xdnd_status(event);
108.1170 -    } else if (event->message_type == XA_XdndFinished) {
108.1171 -        return handle_xdnd_finished(event);
108.1172 -    } else if (event->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) {
108.1173 -        return handle_motif_client_message(event);
108.1174 -    }
108.1175 -    return False;
108.1176 -}
108.1177 -
108.1178 -/*
108.1179 - * Similar to XtLastTimestampProcessed(). We cannot use Xt time stamp, as it is
108.1180 - * updated in XtDispatchEvent that may not be called if a java event is
108.1181 - * consumed. This can make Xt time stamp out-of-date and cause XGrab* failures
108.1182 - * with GrabInvalidTime reason.
108.1183 - */
108.1184 -static Time
108.1185 -get_latest_time_stamp() {
108.1186 -    return latest_time_stamp;
108.1187 -}
108.1188 -
108.1189 -static void
108.1190 -update_latest_time_stamp(XEvent* event) {
108.1191 -    Time time = latest_time_stamp;
108.1192 -
108.1193 -    switch (event->type) {
108.1194 -    case KeyPress:
108.1195 -    case KeyRelease:     time = event->xkey.time;            break;
108.1196 -    case ButtonPress:
108.1197 -    case ButtonRelease:  time = event->xbutton.time;         break;
108.1198 -    case MotionNotify:   time = event->xmotion.time;         break;
108.1199 -    case EnterNotify:
108.1200 -    case LeaveNotify:    time = event->xcrossing.time;       break;
108.1201 -    case PropertyNotify: time = event->xproperty.time;       break;
108.1202 -    case SelectionClear: time = event->xselectionclear.time; break;
108.1203 -    }
108.1204 -
108.1205 -    latest_time_stamp = time;
108.1206 -}
108.1207 -
108.1208 -Boolean
108.1209 -awt_dnd_ds_process_event(XEvent* event) {
108.1210 -    Display* dpy = event->xany.display;
108.1211 -
108.1212 -    update_latest_time_stamp(event);
108.1213 -
108.1214 -    if (process_proxy_mode_event(event)) {
108.1215 -        return True;
108.1216 -    }
108.1217 -
108.1218 -    if (!dnd_in_progress) {
108.1219 -        return False;
108.1220 -    }
108.1221 -
108.1222 -    /* Process drag and drop messages. */
108.1223 -    switch (event->type) {
108.1224 -    case ClientMessage:
108.1225 -        return handle_client_message(&event->xclient);
108.1226 -    case DestroyNotify:
108.1227 -        /* Target crashed during drop processing - cleanup. */
108.1228 -        if (!drag_in_progress &&
108.1229 -            event->xdestroywindow.window == target_window) {
108.1230 -            cleanup_drag(dpy, CurrentTime);
108.1231 -            return True;
108.1232 -        }
108.1233 -        /* Pass along */
108.1234 -        return False;
108.1235 -    }
108.1236 -
108.1237 -    if (!drag_in_progress) {
108.1238 -        return False;
108.1239 -    }
108.1240 -
108.1241 -    /* Process drag-only messages. */
108.1242 -    switch (event->type) {
108.1243 -    case KeyRelease:
108.1244 -    case KeyPress: {
108.1245 -        KeySym keysym = XKeycodeToKeysym(dpy, event->xkey.keycode, 0);
108.1246 -        switch (keysym) {
108.1247 -        case XK_Escape: {
108.1248 -            if (keysym == XK_Escape) {
108.1249 -                remove_dnd_grab(dpy, event->xkey.time);
108.1250 -                cleanup_drag(dpy, event->xkey.time);
108.1251 -            }
108.1252 -            break;
108.1253 -        }
108.1254 -        case XK_Control_R:
108.1255 -        case XK_Control_L:
108.1256 -        case XK_Shift_R:
108.1257 -        case XK_Shift_L: {
108.1258 -            Window subwindow;
108.1259 -            int xw, yw, xr, yr;
108.1260 -            unsigned int modifiers;
108.1261 -            XQueryPointer(event->xkey.display, event->xkey.root, &event->xkey.root, &subwindow,
108.1262 -                          &xr, &yr, &xw, &yw, &modifiers);
108.1263 -            event->xkey.state = modifiers;
108.1264 -            //It's safe to use key event as motion event since we use only their common fields.
108.1265 -            handle_mouse_move(&event->xmotion);
108.1266 -            break;
108.1267 -        }
108.1268 -        }
108.1269 -        return True;
108.1270 -    }
108.1271 -    case ButtonPress:
108.1272 -        return True;
108.1273 -    case MotionNotify:
108.1274 -        handle_mouse_move(&event->xmotion);
108.1275 -        return True;
108.1276 -    case ButtonRelease:
108.1277 -        /*
108.1278 -         * On some X servers it could happen that ButtonRelease coordinates
108.1279 -         * differ from the latest MotionNotify coordinates, so we need to
108.1280 -         * process it as a mouse motion.
108.1281 -         * MotionNotify differs from ButtonRelease only in is_hint member, but
108.1282 -         * we never use it, so it is safe to cast to MotionNotify.
108.1283 -         */
108.1284 -        handle_mouse_move(&event->xmotion);
108.1285 -        if (event->xbutton.button == Button1 || event->xbutton.button == Button2) {
108.1286 -            // drag is initiated with Button1 or Button2 pressed and
108.1287 -            // ended on release of either of these buttons (as the same
108.1288 -            // behavior was with our old Motif DnD-based implementation)
108.1289 -            remove_dnd_grab(dpy, event->xbutton.time);
108.1290 -            drag_in_progress = False;
108.1291 -            if (target_window != None && target_action != java_awt_dnd_DnDConstants_ACTION_NONE) {
108.1292 -                /*
108.1293 -                 * ACTION_NONE indicates that either the drop target rejects the
108.1294 -                 * drop or it haven't responded yet. The latter could happen in
108.1295 -                 * case of fast drag, slow target-server connection or slow
108.1296 -                 * drag notifications processing on the target side.
108.1297 -                 */
108.1298 -                process_drop(&event->xbutton);
108.1299 -            } else {
108.1300 -                cleanup_drag(dpy, event->xbutton.time);
108.1301 -            }
108.1302 -        }
108.1303 -        return True;
108.1304 -    default:
108.1305 -        return False;
108.1306 -    }
108.1307 -}
108.1308 -
108.1309 -static Boolean
108.1310 -motif_convert_proc(Widget w, Atom* selection, Atom* target, Atom* type,
108.1311 -                   XtPointer* value, unsigned long* length, int32_t* format) {
108.1312 -
108.1313 -    if (*target == XA_XmTRANSFER_SUCCESS ||
108.1314 -        *target == XA_XmTRANSFER_FAILURE) {
108.1315 -
108.1316 -        JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
108.1317 -        jboolean success =
108.1318 -            (*target == XA_XmTRANSFER_SUCCESS) ? JNI_TRUE : JNI_FALSE;
108.1319 -
108.1320 -        ds_postDragSourceDropEvent(env, success, target_action,
108.1321 -                                   x_root, y_root);
108.1322 -
108.1323 -        dnd_in_progress = False;
108.1324 -
108.1325 -        XSelectInput(XtDisplay(w), target_window, target_window_mask);
108.1326 -
108.1327 -        cleanup_drag(XtDisplay(w), CurrentTime);
108.1328 -
108.1329 -        *type = *target;
108.1330 -        *length = 0;
108.1331 -        *format = 32;
108.1332 -        *value = NULL;
108.1333 -
108.1334 -        return True;
108.1335 -    } else {
108.1336 -        return awt_convertData(w, selection, target, type, value, length,
108.1337 -                               format);
108.1338 -    }
108.1339 -}
108.1340 -
108.1341 -static Boolean
108.1342 -set_convert_data_context(JNIEnv* env, Display* dpy, XID xid, jobject component,
108.1343 -                         jobject transferable, jobject formatMap,
108.1344 -                         jlongArray formats) {
108.1345 -    awt_convertDataCallbackStruct* structPtr = NULL;
108.1346 -
108.1347 -    if (XFindContext(awt_display, xid, awt_convertDataContext,
108.1348 -                     (XPointer*)&structPtr) == XCNOMEM || structPtr != NULL) {
108.1349 -        return False;
108.1350 -    }
108.1351 -
108.1352 -    structPtr = calloc(1, sizeof(awt_convertDataCallbackStruct));
108.1353 -    if (structPtr == NULL) {
108.1354 -        return False;
108.1355 -    }
108.1356 -
108.1357 -    structPtr->source              = (*env)->NewGlobalRef(env, component);
108.1358 -    structPtr->transferable        = (*env)->NewGlobalRef(env, transferable);
108.1359 -    structPtr->formatMap           = (*env)->NewGlobalRef(env, formatMap);
108.1360 -    structPtr->formats             = (*env)->NewGlobalRef(env, formats);
108.1361 -
108.1362 -    if (JNU_IsNull(env, structPtr->source) ||
108.1363 -        JNU_IsNull(env, structPtr->transferable) ||
108.1364 -        JNU_IsNull(env, structPtr->formatMap) ||
108.1365 -        JNU_IsNull(env, structPtr->formats)) {
108.1366 -
108.1367 -        if (!JNU_IsNull(env, structPtr->source)) {
108.1368 -            (*env)->DeleteGlobalRef(env, structPtr->source);
108.1369 -        }
108.1370 -        if (!JNU_IsNull(env, structPtr->transferable)) {
108.1371 -            (*env)->DeleteGlobalRef(env, structPtr->transferable);
108.1372 -        }
108.1373 -        if (!JNU_IsNull(env, structPtr->formatMap)) {
108.1374 -            (*env)->DeleteGlobalRef(env, structPtr->formatMap);
108.1375 -        }
108.1376 -        if (!JNU_IsNull(env, structPtr->formats)) {
108.1377 -            (*env)->DeleteGlobalRef(env, structPtr->formats);
108.1378 -        }
108.1379 -        free(structPtr);
108.1380 -        return False;
108.1381 -    }
108.1382 -
108.1383 -    if (XSaveContext(dpy, xid, awt_convertDataContext,
108.1384 -                     (XPointer)structPtr) == XCNOMEM) {
108.1385 -        free(structPtr);
108.1386 -        return False;
108.1387 -    }
108.1388 -
108.1389 -    return True;
108.1390 -}
108.1391 -
108.1392 -/*
108.1393 - * Convenience routine. Constructs an appropriate exception message based on the
108.1394 - * specified prefix and the return code of XGrab* function and throws an
108.1395 - * InvalidDnDOperationException with the constructed message.
108.1396 - */
108.1397 -static void
108.1398 -throw_grab_failure_exception(JNIEnv* env, int ret_code, char* msg_prefix) {
108.1399 -    char msg[200];
108.1400 -    char* msg_cause = "";
108.1401 -
108.1402 -    switch (ret_code) {
108.1403 -    case GrabNotViewable:  msg_cause = "not viewable";    break;
108.1404 -    case AlreadyGrabbed:   msg_cause = "already grabbed"; break;
108.1405 -    case GrabInvalidTime:  msg_cause = "invalid time";    break;
108.1406 -    case GrabFrozen:       msg_cause = "grab frozen";     break;
108.1407 -    default:               msg_cause = "unknown failure"; break;
108.1408 -    }
108.1409 -
108.1410 -    sprintf(msg, "%s: %s.", msg_prefix, msg_cause);
108.1411 -    JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1412 -                    msg);
108.1413 -}
108.1414 -
108.1415 -/*
108.1416 - * Sets the proxy mode source window - the source window which the drag
108.1417 - * notifications from an XEmbed client should be forwarded to.
108.1418 - * If the window is not None and there is a drag operation in progress,
108.1419 - * throws InvalidDnDOperationException and doesn't change
108.1420 - * proxy_mode_source_window.
108.1421 - * The caller mush hold AWT_LOCK.
108.1422 - */
108.1423 -void
108.1424 -set_proxy_mode_source_window(Window window) {
108.1425 -    if (window != None && dnd_in_progress) {
108.1426 -        JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
108.1427 -        JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1428 -                        "Drag and drop is already in progress.");
108.1429 -        return;
108.1430 -    }
108.1431 -
108.1432 -    proxy_mode_source_window = window;
108.1433 -}
108.1434 -
108.1435 -/*
108.1436 - * Checks if the event is a drag notification from an XEmbed client.
108.1437 - * If it is, forwards this event back to the current source and returns True.
108.1438 - * Otherwise, returns False.
108.1439 - * Currently only XDnD protocol notifications are recognized.
108.1440 - * The caller must hold AWT_LOCK.
108.1441 - */
108.1442 -static Boolean
108.1443 -process_proxy_mode_event(XEvent* event) {
108.1444 -    if (proxy_mode_source_window == None) {
108.1445 -        return False;
108.1446 -    }
108.1447 -
108.1448 -    if (event->type == ClientMessage) {
108.1449 -        XClientMessageEvent* xclient = &event->xclient;
108.1450 -        if (xclient->message_type == XA_XdndStatus ||
108.1451 -            xclient->message_type == XA_XdndFinished) {
108.1452 -            Window source = proxy_mode_source_window;
108.1453 -
108.1454 -            xclient->data.l[0] = xclient->window;
108.1455 -            xclient->window = source;
108.1456 -
108.1457 -            XSendEvent(xclient->display, source, False, NoEventMask,
108.1458 -                       (XEvent*)xclient);
108.1459 -
108.1460 -            if (xclient->message_type == XA_XdndFinished) {
108.1461 -                proxy_mode_source_window = None;
108.1462 -            }
108.1463 -
108.1464 -            return True;
108.1465 -        }
108.1466 -    }
108.1467 -
108.1468 -    return False;
108.1469 -}
108.1470 -
108.1471 -/*
108.1472 - * Class:     sun_awt_motif_X11DragSourceContextPeer
108.1473 - * Method:    startDrag
108.1474 - * Signature: ()V
108.1475 - */
108.1476 -JNIEXPORT void JNICALL
108.1477 -Java_sun_awt_motif_X11DragSourceContextPeer_startDrag(JNIEnv *env,
108.1478 -                                                      jobject this,
108.1479 -                                                      jobject component,
108.1480 -                                                      jobject wpeer,
108.1481 -                                                      jobject transferable,
108.1482 -                                                      jobject trigger,
108.1483 -                                                      jobject cursor,
108.1484 -                                                      jint ctype,
108.1485 -                                                      jint actions,
108.1486 -                                                      jlongArray formats,
108.1487 -                                                      jobject formatMap) {
108.1488 -    Time time_stamp = CurrentTime;
108.1489 -    Cursor xcursor = None;
108.1490 -    Window root_window = None;
108.1491 -    Atom* targets = NULL;
108.1492 -    jsize num_targets = 0;
108.1493 -
108.1494 -    AWT_LOCK();
108.1495 -
108.1496 -    if (dnd_in_progress) {
108.1497 -        JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1498 -                        "Drag and drop is already in progress.");
108.1499 -        AWT_UNLOCK();
108.1500 -        return;
108.1501 -    }
108.1502 -
108.1503 -    if (proxy_mode_source_window != None) {
108.1504 -        JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1505 -                        "Proxy drag is in progress.");
108.1506 -        AWT_UNLOCK();
108.1507 -        return;
108.1508 -    }
108.1509 -
108.1510 -    if (!awt_dnd_init(awt_display)) {
108.1511 -        JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1512 -                        "DnD subsystem initialization failed.");
108.1513 -        AWT_UNLOCK();
108.1514 -        return;
108.1515 -    }
108.1516 -
108.1517 -    if (!JNU_IsNull(env, cursor)) {
108.1518 -        xcursor = getCursor(env, cursor);
108.1519 -
108.1520 -        if (xcursor == None) {
108.1521 -            JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1522 -                            "Invalid drag cursor");
108.1523 -            AWT_UNLOCK();
108.1524 -        }
108.1525 -    }
108.1526 -
108.1527 -    /* Determine the root window for the drag operation. */
108.1528 -    {
108.1529 -        struct FrameData* wdata = (struct FrameData*)
108.1530 -            JNU_GetLongFieldAsPtr(env, wpeer, mComponentPeerIDs.pData);
108.1531 -
108.1532 -        if (wdata == NULL) {
108.1533 -            JNU_ThrowNullPointerException(env, "Null component data");
108.1534 -            AWT_UNLOCK();
108.1535 -            return;
108.1536 -        }
108.1537 -
108.1538 -        if (wdata->winData.shell == NULL) {
108.1539 -            JNU_ThrowNullPointerException(env, "Null shell widget");
108.1540 -            AWT_UNLOCK();
108.1541 -            return;
108.1542 -        }
108.1543 -
108.1544 -        root_window = RootWindowOfScreen(XtScreen(wdata->winData.shell));
108.1545 -
108.1546 -        if (root_window == None) {
108.1547 -            JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1548 -                            "Cannot get the root window for the drag operation.");
108.1549 -            AWT_UNLOCK();
108.1550 -            return;
108.1551 -        }
108.1552 -    }
108.1553 -
108.1554 -    time_stamp = get_latest_time_stamp();
108.1555 -
108.1556 -    /* Extract the targets from java array. */
108.1557 -    {
108.1558 -        targets = NULL;
108.1559 -        num_targets = (*env)->GetArrayLength(env, formats);
108.1560 -
108.1561 -        /*
108.1562 -         * In debug build GetLongArrayElements aborts with assertion on an empty
108.1563 -         * array.
108.1564 -         */
108.1565 -        if (num_targets > 0) {
108.1566 -            jboolean isCopy = JNI_TRUE;
108.1567 -            jlong* java_targets = (*env)->GetLongArrayElements(env, formats,
108.1568 -                                                               &isCopy);
108.1569 -
108.1570 -            if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
108.1571 -                AWT_UNLOCK();
108.1572 -                return;
108.1573 -            }
108.1574 -
108.1575 -            if (java_targets != NULL) {
108.1576 -                targets = (Atom*)malloc(num_targets * sizeof(Atom));
108.1577 -                if (targets != NULL) {
108.1578 -#ifdef _LP64
108.1579 -                    memcpy(targets, java_targets, num_targets * sizeof(Atom));
108.1580 -#else
108.1581 -                    jsize i;
108.1582 -
108.1583 -                    for (i = 0; i < num_targets; i++) {
108.1584 -                        targets[i] = (Atom)java_targets[i];
108.1585 -                    }
108.1586 -#endif
108.1587 -                }
108.1588 -                (*env)->ReleaseLongArrayElements(env, formats, java_targets,
108.1589 -                                                 JNI_ABORT);
108.1590 -            }
108.1591 -        }
108.1592 -        if (targets == NULL) {
108.1593 -            num_targets = 0;
108.1594 -        }
108.1595 -    }
108.1596 -
108.1597 -    /* Write the XDnD initiator info on the awt_root_shell. */
108.1598 -    {
108.1599 -        unsigned char ret;
108.1600 -        Atom action_atoms[3];
108.1601 -        unsigned int action_count = 0;
108.1602 -
108.1603 -        if (actions & java_awt_dnd_DnDConstants_ACTION_COPY) {
108.1604 -            action_atoms[action_count] = XA_XdndActionCopy;
108.1605 -            action_count++;
108.1606 -        }
108.1607 -        if (actions & java_awt_dnd_DnDConstants_ACTION_MOVE) {
108.1608 -            action_atoms[action_count] = XA_XdndActionMove;
108.1609 -            action_count++;
108.1610 -        }
108.1611 -        if (actions & java_awt_dnd_DnDConstants_ACTION_LINK) {
108.1612 -            action_atoms[action_count] = XA_XdndActionLink;
108.1613 -            action_count++;
108.1614 -        }
108.1615 -
108.1616 -        ret = checked_XChangeProperty(awt_display, awt_dnd_ds_get_source_window(),
108.1617 -                                      XA_XdndActionList, XA_ATOM, 32,
108.1618 -                                      PropModeReplace, (unsigned char*)action_atoms,
108.1619 -                                      action_count * sizeof(Atom));
108.1620 -
108.1621 -        if (ret != Success) {
108.1622 -            cleanup_drag(awt_display, time_stamp);
108.1623 -            JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1624 -                            "Cannot write XdndActionList property");
108.1625 -            AWT_UNLOCK();
108.1626 -            return;
108.1627 -        }
108.1628 -
108.1629 -        ret = checked_XChangeProperty(awt_display, awt_dnd_ds_get_source_window(),
108.1630 -                                      XA_XdndTypeList, XA_ATOM, 32,
108.1631 -                                      PropModeReplace, (unsigned char*)targets,
108.1632 -                                      num_targets);
108.1633 -
108.1634 -        if (ret != Success) {
108.1635 -            cleanup_drag(awt_display, time_stamp);
108.1636 -            JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1637 -                            "Cannot write XdndTypeList property");
108.1638 -            AWT_UNLOCK();
108.1639 -            return;
108.1640 -        }
108.1641 -    }
108.1642 -
108.1643 -    /* Write the Motif DnD initiator info on the awt_root_shell. */
108.1644 -    {
108.1645 -        InitiatorInfo info;
108.1646 -        unsigned char ret;
108.1647 -        int target_list_index =
108.1648 -            get_index_for_target_list(awt_display, targets, num_targets);
108.1649 -
108.1650 -        if (target_list_index == -1) {
108.1651 -            cleanup_drag(awt_display, time_stamp);
108.1652 -            JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1653 -                            "Cannot determine the target list index.");
108.1654 -            AWT_UNLOCK();
108.1655 -            return;
108.1656 -        }
108.1657 -
108.1658 -        info.byte_order = MOTIF_BYTE_ORDER;
108.1659 -        info.protocol_version = MOTIF_DND_PROTOCOL_VERSION;
108.1660 -        info.index = target_list_index;
108.1661 -        info.selection_atom = _XA_MOTIF_ATOM_0;
108.1662 -
108.1663 -        ret = checked_XChangeProperty(awt_display, awt_dnd_ds_get_source_window(),
108.1664 -                                      _XA_MOTIF_ATOM_0,
108.1665 -                                      _XA_MOTIF_DRAG_INITIATOR_INFO, 8,
108.1666 -                                      PropModeReplace, (unsigned char*)&info,
108.1667 -                                      sizeof(InitiatorInfo));
108.1668 -
108.1669 -        if (ret != Success) {
108.1670 -            cleanup_drag(awt_display, time_stamp);
108.1671 -            JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1672 -                            "Cannot write the Motif DnD initiator info");
108.1673 -            AWT_UNLOCK();
108.1674 -            return;
108.1675 -        }
108.1676 -    }
108.1677 -
108.1678 -    /* Acquire XDnD selection ownership. */
108.1679 -    if (XtOwnSelection(awt_root_shell, XA_XdndSelection, time_stamp,
108.1680 -                       awt_convertData, NULL, NULL) != True) {
108.1681 -        cleanup_drag(awt_display, time_stamp);
108.1682 -        JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1683 -                        "Cannot acquire XdndSelection ownership.");
108.1684 -        AWT_UNLOCK();
108.1685 -        return;
108.1686 -    }
108.1687 -
108.1688 -    /* Acquire Motif DnD selection ownership. */
108.1689 -    if (XtOwnSelection(awt_root_shell, _XA_MOTIF_ATOM_0, time_stamp,
108.1690 -                       motif_convert_proc, NULL, NULL) != True) {
108.1691 -        cleanup_drag(awt_display, time_stamp);
108.1692 -        JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1693 -                        "Cannot acquire Motif DnD selection ownership.");
108.1694 -        AWT_UNLOCK();
108.1695 -        return;
108.1696 -    }
108.1697 -
108.1698 -    /*
108.1699 -     * Store the information needed to convert data for both selections
108.1700 -     * in awt_convertDataContext.
108.1701 -     */
108.1702 -    {
108.1703 -        if (!set_convert_data_context(env, awt_display, XA_XdndSelection,
108.1704 -                                      component, transferable, formatMap,
108.1705 -                                      formats)) {
108.1706 -            cleanup_drag(awt_display, time_stamp);
108.1707 -            JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1708 -                            "Cannot save context for XDnD selection data conversion.");
108.1709 -            AWT_UNLOCK();
108.1710 -            return;
108.1711 -        }
108.1712 -
108.1713 -        if (!set_convert_data_context(env, awt_display, _XA_MOTIF_ATOM_0,
108.1714 -                                      component, transferable, formatMap,
108.1715 -                                      formats)) {
108.1716 -            cleanup_drag(awt_display, time_stamp);
108.1717 -            JNU_ThrowByName(env, "java/awt/dnd/InvalidDnDOperationException",
108.1718 -                            "Cannot save context for Motif DnD selection data conversion.");
108.1719 -            AWT_UNLOCK();
108.1720 -            return;
108.1721 -        }
108.1722 -    }
108.1723 -
108.1724 -    /* Install X grabs. */
108.1725 -    {
108.1726 -        XWindowAttributes xwa;
108.1727 -        int ret;
108.1728 -
108.1729 -        XGetWindowAttributes(awt_display, root_window, &xwa);
108.1730 -
108.1731 -        your_root_event_mask = xwa.your_event_mask;
108.1732 -
108.1733 -        XSelectInput(awt_display, root_window,
108.1734 -                     your_root_event_mask | ROOT_EVENT_MASK);
108.1735 -
108.1736 -        ret = XGrabPointer(awt_display,
108.1737 -                           root_window,
108.1738 -                           False,
108.1739 -                           GRAB_EVENT_MASK,
108.1740 -                           GrabModeAsync,
108.1741 -                           GrabModeAsync,
108.1742 -                           None,
108.1743 -                           xcursor,
108.1744 -                           time_stamp);
108.1745 -
108.1746 -        if (ret != GrabSuccess) {
108.1747 -            cleanup_drag(awt_display, time_stamp);
108.1748 -            throw_grab_failure_exception(env, ret, "Cannot grab pointer");
108.1749 -            AWT_UNLOCK();
108.1750 -            return;
108.1751 -        }
108.1752 -
108.1753 -        ret = XGrabKeyboard(awt_display,
108.1754 -                            root_window,
108.1755 -                            False,
108.1756 -                            GrabModeAsync,
108.1757 -                            GrabModeAsync,
108.1758 -                            time_stamp);
108.1759 -
108.1760 -        if (ret != GrabSuccess) {
108.1761 -            cleanup_drag(awt_display, time_stamp);
108.1762 -            throw_grab_failure_exception(env, ret, "Cannot grab keyboard");
108.1763 -            AWT_UNLOCK();
108.1764 -            return;
108.1765 -        }
108.1766 -    }
108.1767 -
108.1768 -    /* Update the global state. */
108.1769 -    source_peer = (*env)->NewGlobalRef(env, this);
108.1770 -    dnd_in_progress = True;
108.1771 -    drag_in_progress = True;
108.1772 -    data_types = targets;
108.1773 -    data_types_count = num_targets;
108.1774 -    source_actions = actions;
108.1775 -    drag_root_window = root_window;
108.1776 -
108.1777 -    AWT_UNLOCK();
108.1778 -}
108.1779 -
108.1780 -/*
108.1781 - * Class:     sun_awt_motif_X11DragSourceContextPeer
108.1782 - * Method:    setNativeCursor
108.1783 - * Signature: ()V
108.1784 - */
108.1785 -JNIEXPORT void JNICALL
108.1786 -Java_sun_awt_motif_X11DragSourceContextPeer_setNativeCursor(JNIEnv *env,
108.1787 -                                                            jobject this,
108.1788 -                                                            jlong nativeCtxt,
108.1789 -                                                            jobject cursor,
108.1790 -                                                            jint type) {
108.1791 -    if (JNU_IsNull(env, cursor)) {
108.1792 -        return;
108.1793 -    }
108.1794 -
108.1795 -    XChangeActivePointerGrab(awt_display,
108.1796 -                             GRAB_EVENT_MASK,
108.1797 -                             getCursor(env, cursor),
108.1798 -                             CurrentTime);
108.1799 -}
   109.1 --- a/src/solaris/native/sun/awt/awt_dnd_dt.c	Wed Sep 17 13:45:37 2008 -0700
   109.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   109.3 @@ -1,3700 +0,0 @@
   109.4 -/*
   109.5 - * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
   109.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   109.7 - *
   109.8 - * This code is free software; you can redistribute it and/or modify it
   109.9 - * under the terms of the GNU General Public License version 2 only, as
  109.10 - * published by the Free Software Foundation.  Sun designates this
  109.11 - * particular file as subject to the "Classpath" exception as provided
  109.12 - * by Sun in the LICENSE file that accompanied this code.
  109.13 - *
  109.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  109.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  109.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  109.17 - * version 2 for more details (a copy is included in the LICENSE file that
  109.18 - * accompanied this code).
  109.19 - *
  109.20 - * You should have received a copy of the GNU General Public License version
  109.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  109.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  109.23 - *
  109.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  109.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  109.26 - * have any questions.
  109.27 - */
  109.28 -
  109.29 -#ifdef HEADLESS
  109.30 -    #error This file should not be included in headless library
  109.31 -#endif
  109.32 -
  109.33 -#include "awt_dnd.h"
  109.34 -
  109.35 -#include "jlong.h"
  109.36 -
  109.37 -#include "awt_DataTransferer.h"
  109.38 -#include "awt_MToolkit.h"
  109.39 -
  109.40 -#include "java_awt_dnd_DnDConstants.h"
  109.41 -#include "java_awt_event_MouseEvent.h"
  109.42 -
  109.43 -#include "sun_awt_motif_MComponentPeer.h"
  109.44 -#include "awt_xembed.h"
  109.45 -
  109.46 -#define DT_INITIAL_STATE 0
  109.47 -#define DT_ENTERED_STATE 1
  109.48 -#define DT_OVER_STATE    2
  109.49 -
  109.50 -extern struct ComponentIDs componentIDs;
  109.51 -extern struct MComponentPeerIDs mComponentPeerIDs;
  109.52 -
  109.53 -/**************************** XEmbed server DnD support ***********************/
  109.54 -extern void
  109.55 -set_xembed_drop_target(JNIEnv* env, jobject server);
  109.56 -extern void
  109.57 -remove_xembed_drop_target(JNIEnv* env, jobject server);
  109.58 -extern Boolean
  109.59 -is_xembed_client(Window window);
  109.60 -
  109.61 -DECLARE_JAVA_CLASS(MEmbedCanvasPeerClass, "sun/awt/motif/MEmbedCanvasPeer");
  109.62 -/******************************************************************************/
  109.63 -
  109.64 -typedef enum {
  109.65 -    EventSuccess,    /* Event is successfully processed. */
  109.66 -    EventFailure     /* Failed to process the event. */
  109.67 -} EventStatus;
  109.68 -
  109.69 -typedef enum {
  109.70 -    EnterEvent,    /* XdndEnter, TOP_LEVEL_ENTER */
  109.71 -    MotionEvent,   /* XdndPosition, DRAG_MOTION, OPERATION_CHANGED */
  109.72 -    LeaveEvent,    /* XdndLeave, TOP_LEVEL_LEAVE */
  109.73 -    DropEvent,     /* XdndDrop, DROP_START */
  109.74 -    UnknownEvent
  109.75 -} EventType;
  109.76 -
  109.77 -static Protocol source_protocol = NO_PROTOCOL;
  109.78 -static unsigned int source_protocol_version = 0;
  109.79 -static Window source_window = None;
  109.80 -static Atom source_atom = None;
  109.81 -static long source_window_mask = None;
  109.82 -static jint source_actions = java_awt_dnd_DnDConstants_ACTION_NONE;
  109.83 -/*
  109.84 - * According to XDnD protocol, XdndActionList is optional.
  109.85 - * In case if XdndActionList is not set on the source, the list of drop actions
  109.86 - * supported by the source is constructed as follows:
  109.87 - *  - "copy" is always included;
  109.88 - *  - "move" is included if at least one XdndPosition message received
  109.89 - *    after the latest XdndEnter passed XdndActionMove in data.l[4];
  109.90 - *  - "link" is included if at least one XdndPosition message received
  109.91 - *    after the latest XdndEnter passed XdndActionLink in data.l[4].
  109.92 - * We use a boolean flag to signal that we are building the list of drop actions
  109.93 - * supported by the source.
  109.94 - */
  109.95 -static Boolean track_source_actions = False;
  109.96 -static jint user_action = java_awt_dnd_DnDConstants_ACTION_NONE;
  109.97 -static jlongArray source_data_types = NULL;
  109.98 -static Atom* source_data_types_native = NULL;
  109.99 -static unsigned int source_data_types_count = 0;
 109.100 -static int source_x = 0;
 109.101 -static int source_y = 0;
 109.102 -static jobject target_component = NULL;
 109.103 -/*
 109.104 - * The Motif DnD protocol prescribes that DROP_START message should always be
 109.105 - * preceeded with TOP_LEVEL_LEAVE message. We need to cleanup on TOP_LEVEL_LEAVE
 109.106 - * message, but DROP_START wouldn't be processed properly.
 109.107 - * To resolve this issue we postpone cleanup using a boolean flag this flag is
 109.108 - * set when we receive the TOP_LEVEL_LEAVE message and cleared when the next
 109.109 - * client message arrives if that message is not DROP_START. If that message is
 109.110 - * a DROP_START message, the flag is cleared after the DROP_START is processed.
 109.111 - */
 109.112 -static Boolean motif_top_level_leave_postponed = False;
 109.113 -/*
 109.114 - * We store a postponed TOP_LEVEL_LEAVE message here.
 109.115 - */
 109.116 -static XClientMessageEvent motif_top_level_leave_postponed_event;
 109.117 -
 109.118 -/* Forward declarations */
 109.119 -static Window get_root_for_window(Window window);
 109.120 -static Window get_outer_canvas_for_window(Window window);
 109.121 -static Boolean register_drop_site(Widget outer_canvas, XtPointer componentRef);
 109.122 -static Boolean is_xdnd_drag_message_type(unsigned long message_type);
 109.123 -static Boolean register_xdnd_drop_site(Display* dpy, Window toplevel,
 109.124 -                                       Window window);
 109.125 -
 109.126 -/**************************** JNI stuff ***************************************/
 109.127 -
 109.128 -DECLARE_JAVA_CLASS(dtcp_clazz, "sun/awt/motif/X11DropTargetContextPeer")
 109.129 -
 109.130 -static void
 109.131 -dt_postDropTargetEvent(JNIEnv* env, jobject component, int x, int y,
 109.132 -                       jint dropAction, jint event_id,
 109.133 -                       XClientMessageEvent* event) {
 109.134 -    DECLARE_STATIC_VOID_JAVA_METHOD(dtcp_postDropTargetEventToPeer, dtcp_clazz,
 109.135 -                                    "postDropTargetEventToPeer",
 109.136 -                                    "(Ljava/awt/Component;IIII[JJI)V");
 109.137 -
 109.138 -    {
 109.139 -        void* copy = NULL;
 109.140 -
 109.141 -        if (event != NULL) {
 109.142 -            /*
 109.143 -             * For XDnD messages we append the information from the latest
 109.144 -             * XdndEnter to the context. It is done to be able to reconstruct
 109.145 -             * XdndEnter for an XEmbed client.
 109.146 -             */
 109.147 -            Boolean isXDnDMessage =
 109.148 -                is_xdnd_drag_message_type(event->message_type);
 109.149 -
 109.150 -            if (isXDnDMessage) {
 109.151 -                copy = malloc(sizeof(XClientMessageEvent) +
 109.152 -                                                 4 * sizeof(long));
 109.153 -            } else {
 109.154 -                copy = malloc(sizeof(XClientMessageEvent));
 109.155 -            }
 109.156 -
 109.157 -            if (copy == NULL) {
 109.158 -                DTRACE_PRINTLN2("%s:%d malloc failed.", __FILE__, __LINE__);
 109.159 -                return;
 109.160 -            }
 109.161 -
 109.162 -            memcpy(copy, event, sizeof(XClientMessageEvent));
 109.163 -
 109.164 -            if (isXDnDMessage) {
 109.165 -                size_t msgSize = sizeof(XClientMessageEvent);
 109.166 -                long data1 = source_protocol_version << XDND_PROTOCOL_SHIFT;
 109.167 -                long * appended_data;
 109.168 -                if (source_data_types_native != NULL &&
 109.169 -                    source_data_types_count > 3) {
 109.170 -
 109.171 -                    data1 |= XDND_DATA_TYPES_BIT;
 109.172 -                }
 109.173 -
 109.174 -                appended_data = (long*)((char*)copy + msgSize);
 109.175 -                appended_data[0] = data1;
 109.176 -                appended_data[1] = source_data_types_count > 0 ?
 109.177 -                    source_data_types_native[0] : 0;
 109.178 -                appended_data[2] = source_data_types_count > 1 ?
 109.179 -                    source_data_types_native[1] : 0;
 109.180 -                appended_data[3] = source_data_types_count > 2 ?
 109.181 -                    source_data_types_native[2] : 0;
 109.182 -            }
 109.183 -        }
 109.184 -
 109.185 -        DASSERT(!JNU_IsNull(env, component));
 109.186 -
 109.187 -        (*env)->CallStaticVoidMethod(env, clazz, dtcp_postDropTargetEventToPeer,
 109.188 -                                     component, x, y, dropAction,
 109.189 -                                     source_actions, source_data_types,
 109.190 -                                     ptr_to_jlong(copy), event_id);
 109.191 -    }
 109.192 -}
 109.193 -
 109.194 -/******************************************************************************/
 109.195 -
 109.196 -/********************* Embedded drop site list support ************************/
 109.197 -
 109.198 -struct EmbeddedDropSiteListEntryRec;
 109.199 -
 109.200 -typedef struct EmbeddedDropSiteListEntryRec EmbeddedDropSiteListEntry;
 109.201 -
 109.202 -struct EmbeddedDropSiteListEntryRec {
 109.203 -    Window toplevel;
 109.204 -    Window root;
 109.205 -    /*
 109.206 -     * We select for PropertyNotify events on the toplevel, so we need to
 109.207 -     * restore the event mask when we are done with this toplevel.
 109.208 -     */
 109.209 -    long event_mask;
 109.210 -    unsigned int embedded_sites_count;
 109.211 -    Window* embedded_sites;
 109.212 -    EmbeddedDropSiteListEntry* next;
 109.213 -};
 109.214 -
 109.215 -static EmbeddedDropSiteListEntry* embedded_drop_site_list = NULL;
 109.216 -
 109.217 -struct EmbeddedDropSiteProtocolListEntryRec;
 109.218 -
 109.219 -typedef struct EmbeddedDropSiteProtocolListEntryRec EmbeddedDropSiteProtocolListEntry;
 109.220 -
 109.221 -struct EmbeddedDropSiteProtocolListEntryRec {
 109.222 -    Window window;
 109.223 -    Window proxy;
 109.224 -    /*
 109.225 -     * We override the XdndAware property on the toplevel, so we should keep its
 109.226 -     * original contents - the XDnD protocol version supported by the browser.
 109.227 -     * This is needed to adjust XDnD messages forwarded to the browser.
 109.228 -     */
 109.229 -    unsigned int protocol_version;
 109.230 -    /* True if the toplevel was already registered as a drag receiver and
 109.231 -       we just changed the proxy. False, otherwise */
 109.232 -    Boolean overriden;
 109.233 -    EmbeddedDropSiteProtocolListEntry* next;
 109.234 -};
 109.235 -
 109.236 -static EmbeddedDropSiteProtocolListEntry* embedded_motif_protocol_list = NULL;
 109.237 -static EmbeddedDropSiteProtocolListEntry* embedded_xdnd_protocol_list = NULL;
 109.238 -
 109.239 -typedef enum {
 109.240 -    RegFailure, /* Proxy registration failed */
 109.241 -    RegSuccess, /* The new drop site is registered with the new proxy */
 109.242 -    RegOverride, /* The new proxy is set for the existing drop site */
 109.243 -    RegAlreadyRegistered /* This proxy is already set for this drop site */
 109.244 -} ProxyRegistrationStatus;
 109.245 -
 109.246 -/* Forward declarations. */
 109.247 -static EmbeddedDropSiteProtocolListEntry*
 109.248 -get_xdnd_protocol_entry_for_toplevel(Window toplevel);
 109.249 -static EmbeddedDropSiteProtocolListEntry*
 109.250 -get_motif_protocol_entry_for_toplevel(Window toplevel);
 109.251 -static void remove_xdnd_protocol_entry_for_toplevel(Window toplevel);
 109.252 -static void remove_motif_protocol_entry_for_toplevel(Window toplevel);
 109.253 -
 109.254 -/*
 109.255 - * Registers the toplevel as a Motif drag receiver if it is not registered yet,
 109.256 - * sets the specified new_proxy for it and returns the previous proxy in old_proxy.
 109.257 - * Does nothing if the new_proxy is already set as a proxy for this toplevel.
 109.258 - * Returns the completion status.
 109.259 - */
 109.260 -static ProxyRegistrationStatus
 109.261 -set_motif_proxy(Display* dpy, Window toplevel, Window new_proxy, Window *old_proxy) {
 109.262 -    Boolean        override = False;
 109.263 -
 109.264 -    Atom           type;
 109.265 -    int            format;
 109.266 -    unsigned long  nitems;
 109.267 -    unsigned long  after;
 109.268 -    unsigned char* data;
 109.269 -    unsigned char  ret;
 109.270 -
 109.271 -    DASSERT(old_proxy != NULL);
 109.272 -
 109.273 -    *old_proxy = None;
 109.274 -
 109.275 -    data = NULL;
 109.276 -    ret = checked_XGetWindowProperty(dpy, toplevel,
 109.277 -                                     _XA_MOTIF_DRAG_RECEIVER_INFO, 0, 0xFFFF,
 109.278 -                                     False, AnyPropertyType, &type, &format,
 109.279 -                                     &nitems, &after, &data);
 109.280 -
 109.281 -    /* Check if toplevel is a valid window. */
 109.282 -    if (ret != Success) {
 109.283 -        return RegFailure;
 109.284 -    }
 109.285 -
 109.286 -    if (ret == Success && data != NULL && type != None && format == 8
 109.287 -        && nitems >= MOTIF_RECEIVER_INFO_SIZE) {
 109.288 -        unsigned char byte_order = read_card8((char*)data, 0);
 109.289 -        void* p = (char*)data + 4;
 109.290 -
 109.291 -        /* Browser and plugin have different byte orders - report failure for now. */
 109.292 -        if (MOTIF_BYTE_ORDER != byte_order) {
 109.293 -            XFree(data);
 109.294 -            return RegFailure;
 109.295 -        }
 109.296 -
 109.297 -        *old_proxy = read_card32((char*)data, 4, byte_order);
 109.298 -
 109.299 -        /* If the proxy is already set to the specified window - return. */
 109.300 -        if (*old_proxy == new_proxy) {
 109.301 -            XFree(data);
 109.302 -            return RegAlreadyRegistered;
 109.303 -        }
 109.304 -
 109.305 -        /* replace the proxy window */
 109.306 -        write_card32(&p, new_proxy);
 109.307 -
 109.308 -        override = True;
 109.309 -    } else {
 109.310 -        void* p;
 109.311 -
 109.312 -        if (ret == Success) {
 109.313 -            XFree(data);
 109.314 -            data = NULL;
 109.315 -        }
 109.316 -
 109.317 -        data = malloc(MOTIF_RECEIVER_INFO_SIZE);
 109.318 -
 109.319 -        if (data == NULL) {
 109.320 -            DTRACE_PRINTLN2("%s:%d malloc failed.", __FILE__, __LINE__);
 109.321 -            return RegFailure;
 109.322 -        }
 109.323 -
 109.324 -        p = data;
 109.325 -
 109.326 -        write_card8(&p, MOTIF_BYTE_ORDER);
 109.327 -        write_card8(&p, MOTIF_DND_PROTOCOL_VERSION); /* protocol version */
 109.328 -        write_card8(&p, MOTIF_DYNAMIC_STYLE); /* protocol style */
 109.329 -        write_card8(&p, 0); /* pad */
 109.330 -        write_card32(&p, new_proxy); /* proxy window */
 109.331 -        write_card16(&p, 0); /* num_drop_sites */
 109.332 -        write_card16(&p, 0); /* pad */
 109.333 -        write_card32(&p, MOTIF_RECEIVER_INFO_SIZE);
 109.334 -    }
 109.335 -
 109.336 -    ret = checked_XChangeProperty(dpy, toplevel,
 109.337 -                                  _XA_MOTIF_DRAG_RECEIVER_INFO,
 109.338 -                                  _XA_MOTIF_DRAG_RECEIVER_INFO, 8,
 109.339 -                                  PropModeReplace, (unsigned char*)data,
 109.340 -                                  MOTIF_RECEIVER_INFO_SIZE);
 109.341 -
 109.342 -    if (data != NULL) {
 109.343 -        XFree(data);
 109.344 -        data = NULL;
 109.345 -    }
 109.346 -
 109.347 -    if (ret == Success) {
 109.348 -        if (override) {
 109.349 -            return RegOverride;
 109.350 -        } else {
 109.351 -            return RegSuccess;
 109.352 -        }
 109.353 -    } else {
 109.354 -        return RegFailure;
 109.355 -    }
 109.356 -}
 109.357 -
 109.358 -/*
 109.359 - * Registers the toplevel as a XDnD drag receiver if it is not registered yet,
 109.360 - * sets the specified new_proxy for it and returns the previous proxy in
 109.361 - * old_proxy and the original XDnD protocol version in old_version.
 109.362 - * Does nothing if the new_proxy is already set as a proxy for this toplevel.
 109.363 - * Returns the completion status.
 109.364 - */
 109.365 -static ProxyRegistrationStatus
 109.366 -set_xdnd_proxy(Display* dpy, Window toplevel, Window new_proxy,
 109.367 -               Window* old_proxy, unsigned int* old_version) {
 109.368 -    Atom version_atom = XDND_PROTOCOL_VERSION;
 109.369 -    Window xdnd_proxy = None;
 109.370 -    Boolean override = False;
 109.371 -
 109.372 -    Atom           type;
 109.373 -    int            format;
 109.374 -    unsigned long  nitems;
 109.375 -    unsigned long  after;
 109.376 -    unsigned char* data;
 109.377 -    unsigned char  ret;
 109.378 -
 109.379 -    DASSERT(old_proxy != NULL);
 109.380 -
 109.381 -    *old_proxy = None;
 109.382 -
 109.383 -    data = NULL;
 109.384 -    ret = checked_XGetWindowProperty(dpy, toplevel, XA_XdndAware, 0, 1,
 109.385 -                                     False, AnyPropertyType, &type, &format,
 109.386 -                                     &nitems, &after, &data);
 109.387 -
 109.388 -    if (ret != Success) {
 109.389 -        return RegFailure;
 109.390 -    }
 109.391 -
 109.392 -    if (ret == Success && data != NULL && type == XA_ATOM) {
 109.393 -        unsigned int protocol_version = *((unsigned int*)data);
 109.394 -
 109.395 -        override = True;
 109.396 -        *old_version = protocol_version;
 109.397 -
 109.398 -        /* XdndProxy is not supported for prior to XDnD version 4 */
 109.399 -        if (protocol_version >= 4) {
 109.400 -            int status;
 109.401 -
 109.402 -            XFree(data);
 109.403 -
 109.404 -            data = NULL;
 109.405 -            status = XGetWindowProperty(dpy, toplevel, XA_XdndProxy, 0, 1,
 109.406 -                                        False, XA_WINDOW, &type, &format,
 109.407 -                                        &nitems, &after, &data);
 109.408 -
 109.409 -            if (status == Success && data != NULL && type == XA_WINDOW) {
 109.410 -                xdnd_proxy = *((Window*)data);
 109.411 -
 109.412 -                if (xdnd_proxy != None) {
 109.413 -                    XFree(data);
 109.414 -
 109.415 -                    data = NULL;
 109.416 -                    status = XGetWindowProperty(dpy, xdnd_proxy, XA_XdndProxy,
 109.417 -                                                0, 1, False, XA_WINDOW, &type,
 109.418 -                                                &format, &nitems, &after, &data);
 109.419 -
 109.420 -                    if (status != Success || data == NULL || type != XA_WINDOW ||
 109.421 -                        *((Window*)data) != xdnd_proxy) {
 109.422 -                        /* Ignore invalid proxy. */
 109.423 -                        xdnd_proxy = None;
 109.424 -                    }
 109.425 -                }
 109.426 -
 109.427 -                if (xdnd_proxy != None) {
 109.428 -                    XFree(data);
 109.429 -
 109.430 -                    data = NULL;
 109.431 -                    status = XGetWindowProperty(dpy, xdnd_proxy, XA_XdndAware,
 109.432 -                                                0, 1, False, AnyPropertyType,
 109.433 -                                                &type, &format, &nitems, &after,
 109.434 -                                                &data);
 109.435 -
 109.436 -                    if (status == Success && data != NULL && type == XA_ATOM) {
 109.437 -                        unsigned int proxy_version = *((unsigned int*)data);
 109.438 -
 109.439 -                        if (proxy_version != protocol_version) {
 109.440 -                            /* Ignore invalid proxy. */
 109.441 -                            xdnd_proxy = None;
 109.442 -                        }
 109.443 -                    } else {
 109.444 -                        /* Ignore invalid proxy. */
 109.445 -                        xdnd_proxy = None;
 109.446 -                    }
 109.447 -                }
 109.448 -            }
 109.449 -
 109.450 -            *old_proxy = xdnd_proxy;
 109.451 -        }
 109.452 -    }
 109.453 -
 109.454 -    XFree(data);
 109.455 -
 109.456 -    /* If the proxy is already set to the specified window - return. */
 109.457 -    if (xdnd_proxy == new_proxy) {
 109.458 -        return RegAlreadyRegistered;
 109.459 -    }
 109.460 -
 109.461 -    /* The proxy window must have the XdndAware set, as XDnD protocol prescribes
 109.462 -       to check the proxy window for XdndAware. */
 109.463 -    ret = checked_XChangeProperty(dpy, new_proxy, XA_XdndAware, XA_ATOM, 32,
 109.464 -                                  PropModeReplace,
 109.465 -                                  (unsigned char*)&version_atom, 1);
 109.466 -
 109.467 -    if (ret != Success) {
 109.468 -        return RegFailure;
 109.469 -    }
 109.470 -
 109.471 -    /* The proxy window must have the XdndProxy set to point to itself. */
 109.472 -    ret = checked_XChangeProperty(dpy, new_proxy, XA_XdndProxy, XA_WINDOW, 32,
 109.473 -                                  PropModeReplace,
 109.474 -                                  (unsigned char*)&new_proxy, 1);
 109.475 -
 109.476 -    if (ret != Success) {
 109.477 -        return RegFailure;
 109.478 -    }
 109.479 -
 109.480 -    ret = checked_XChangeProperty(dpy, toplevel, XA_XdndAware, XA_ATOM, 32,
 109.481 -                                  PropModeReplace,
 109.482 -                                  (unsigned char*)&version_atom, 1);
 109.483 -
 109.484 -    if (ret != Success) {
 109.485 -        return RegFailure;
 109.486 -    }
 109.487 -
 109.488 -    ret = checked_XChangeProperty(dpy, toplevel, XA_XdndProxy, XA_WINDOW, 32,
 109.489 -                                  PropModeReplace,
 109.490 -                                  (unsigned char*)&new_proxy, 1);
 109.491 -
 109.492 -    if (ret == Success) {
 109.493 -        if (override) {
 109.494 -            return RegOverride;
 109.495 -        } else {
 109.496 -            return RegSuccess;
 109.497 -        }
 109.498 -    } else {
 109.499 -        return RegFailure;
 109.500 -    }
 109.501 -}
 109.502 -
 109.503 -/*
 109.504 - * 'toplevel' is the browser toplevel window. To register a drop site on the
 109.505 - * plugin window we set the proxy for the browser toplevel window to point to
 109.506 - * the awt_root_shell window.
 109.507 - *
 109.508 - * We assume that only one JVM per browser instance is possible. This
 109.509 - * assumption is true with the current plugin implementation - it creates a
 109.510 - * single JVM for all plugin instances created by the given plugin factory.
 109.511 - *
 109.512 - * When a client message event for the browser toplevel window is received, we
 109.513 - * will iterate over drop sites registered with this toplevel and determine if
 109.514 - * the mouse pointer is currently over one of them (there could be several
 109.515 - * plugin windows in one browser window - for example if an HTML page contains
 109.516 - * frames and several frames contain a plugin object).
 109.517 - *
 109.518 - * If the pointer is not over any of the plugin drop sites the client message
 109.519 - * will be resent to the browser, otherwise it will be processed normally.
 109.520 - */
 109.521 -static EmbeddedDropSiteListEntry*
 109.522 -awt_dnd_dt_init_proxy(Display* dpy, Window root, Window toplevel, Window window) {
 109.523 -    Window         awt_root_window = get_awt_root_window();
 109.524 -    Window         motif_proxy = None;
 109.525 -    Boolean        motif_override = False;
 109.526 -    unsigned long  event_mask = 0;
 109.527 -
 109.528 -    if (awt_root_window == None) {
 109.529 -        return NULL;
 109.530 -    }
 109.531 -
 109.532 -    /* Grab server, since we are working with the window that belongs to
 109.533 -       another client. REMIND: ungrab when done!!! */
 109.534 -    XGrabServer(dpy);
 109.535 -
 109.536 -    {
 109.537 -        ProxyRegistrationStatus motif_status = RegFailure;
 109.538 -
 109.539 -        motif_status = set_motif_proxy(dpy, toplevel, awt_root_window, &motif_proxy);
 109.540 -
 109.541 -        switch (motif_status) {
 109.542 -        case RegFailure:
 109.543 -        case RegAlreadyRegistered:
 109.544 -            XUngrabServer(dpy);
 109.545 -            /* Workaround for bug 5039226 */
 109.546 -            XSync(dpy, False);
 109.547 -            return NULL;
 109.548 -        case RegOverride:
 109.549 -            motif_override = True;
 109.550 -            break;
 109.551 -        case RegSuccess:
 109.552 -            motif_override = False;
 109.553 -            break;
 109.554 -        default:
 109.555 -            DASSERT(False);
 109.556 -        }
 109.557 -
 109.558 -
 109.559 -    }
 109.560 -
 109.561 -    {
 109.562 -        XWindowAttributes xwa;
 109.563 -        XGetWindowAttributes(dpy, toplevel, &xwa);
 109.564 -        event_mask = xwa.your_event_mask;
 109.565 -        if ((event_mask & PropertyChangeMask) == 0) {
 109.566 -            XSelectInput(dpy, toplevel, event_mask | PropertyChangeMask);
 109.567 -        }
 109.568 -    }
 109.569 -
 109.570 -    XUngrabServer(dpy);
 109.571 -    /* Workaround for bug 5039226 */
 109.572 -    XSync(dpy, False);
 109.573 -
 109.574 -    /* Add protocol specific entries for the toplevel. */
 109.575 -    {
 109.576 -        EmbeddedDropSiteProtocolListEntry* motif_entry = NULL;
 109.577 -
 109.578 -        motif_entry = malloc(sizeof(EmbeddedDropSiteProtocolListEntry));
 109.579 -
 109.580 -        if (motif_entry == NULL) {
 109.581 -            return NULL;
 109.582 -        }
 109.583 -
 109.584 -        motif_entry->window = toplevel;
 109.585 -        motif_entry->proxy = motif_proxy;
 109.586 -        motif_entry->protocol_version = 0;
 109.587 -        motif_entry->overriden = motif_override;
 109.588 -        motif_entry->next = embedded_motif_protocol_list;
 109.589 -        embedded_motif_protocol_list = motif_entry;
 109.590 -    }
 109.591 -
 109.592 -    {
 109.593 -        EmbeddedDropSiteListEntry* entry = NULL;
 109.594 -        Window* sites = NULL;
 109.595 -
 109.596 -        entry = malloc(sizeof(EmbeddedDropSiteListEntry));
 109.597 -
 109.598 -        if (entry == NULL) {
 109.599 -            return NULL;
 109.600 -        }
 109.601 -
 109.602 -        sites = malloc(sizeof(Window));
 109.603 -
 109.604 -        if (sites == NULL) {
 109.605 -            free(entry);
 109.606 -            return NULL;
 109.607 -        }
 109.608 -
 109.609 -        sites[0] = window;
 109.610 -
 109.611 -        entry->toplevel = toplevel;
 109.612 -        entry->root = root;
 109.613 -        entry->event_mask = event_mask;
 109.614 -        entry->embedded_sites_count = 1;
 109.615 -        entry->embedded_sites = sites;
 109.616 -        entry->next = NULL;
 109.617 -
 109.618 -        return entry;
 109.619 -    }
 109.620 -}
 109.621 -
 109.622 -static void
 109.623 -register_xdnd_embedder(Display* dpy, EmbeddedDropSiteListEntry* entry, long window) {
 109.624 -    Window         awt_root_window = get_awt_root_window();
 109.625 -    Window         toplevel = entry->toplevel;
 109.626 -    Window         xdnd_proxy = None;
 109.627 -    unsigned int   xdnd_protocol_version = 0;
 109.628 -    Boolean        xdnd_override = False;
 109.629 -    Boolean        register_xdnd = True;
 109.630 -    Boolean        motif_overriden = False;
 109.631 -
 109.632 -    EmbeddedDropSiteProtocolListEntry* motif_entry = embedded_motif_protocol_list;
 109.633 -    while (motif_entry != NULL) {
 109.634 -        if (motif_entry->window == toplevel) {
 109.635 -            motif_overriden = motif_entry->overriden;
 109.636 -            break;
 109.637 -        }
 109.638 -        motif_entry = motif_entry->next;
 109.639 -    }
 109.640 -
 109.641 -    /*
 109.642 -     * First check if the window is an XEmbed client.
 109.643 -     * In this case we don't have to setup a proxy on the toplevel,
 109.644 -     * instead we register the XDnD drop site on the embedded window.
 109.645 -     */
 109.646 -    if (isXEmbedActiveByWindow(window)) {
 109.647 -        register_xdnd_drop_site(dpy, toplevel, window);
 109.648 -        return;
 109.649 -    }
 109.650 -
 109.651 -    /*
 109.652 -     * By default, we register a drop site that supports both dnd
 109.653 -     * protocols. This approach is not appropriate in plugin
 109.654 -     * scenario if the browser doesn't support XDnD. If we forcibly set
 109.655 -     * XdndAware on the browser toplevel, any drag source that supports both
 109.656 -     * protocols and prefers XDnD will be unable to drop anything on the
 109.657 -     * browser.
 109.658 -     * The solution for this problem is not to register XDnD drop site
 109.659 -     * if the browser supports only Motif DnD.
 109.660 -     */
 109.661 -    if (motif_overriden) {
 109.662 -        int            status;
 109.663 -        Atom           type;
 109.664 -        int            format;
 109.665 -        unsigned long  nitems;
 109.666 -        unsigned long  after;
 109.667 -        unsigned char* data;
 109.668 -
 109.669 -        data = NULL;
 109.670 -        status = XGetWindowProperty(dpy, toplevel, XA_XdndAware, 0, 1,
 109.671 -                                    False, AnyPropertyType, &type, &format,
 109.672 -                                    &nitems, &after, &data);
 109.673 -
 109.674 -        XFree(data);
 109.675 -        data = NULL;
 109.676 -
 109.677 -        if (type != XA_ATOM) {
 109.678 -            register_xdnd = False;
 109.679 -        }
 109.680 -    }
 109.681 -
 109.682 -    if (register_xdnd) {
 109.683 -        ProxyRegistrationStatus xdnd_status;
 109.684 -        /* Grab server, since we are working with the window that belongs to
 109.685 -           another client. REMIND: ungrab when done!!! */
 109.686 -        XGrabServer(dpy);
 109.687 -
 109.688 -        xdnd_status =
 109.689 -            set_xdnd_proxy(dpy, toplevel, awt_root_window, &xdnd_proxy,
 109.690 -                           &xdnd_protocol_version);
 109.691 -
 109.692 -        XUngrabServer(dpy);
 109.693 -
 109.694 -        switch (xdnd_status) {
 109.695 -        case RegFailure:
 109.696 -        case RegAlreadyRegistered:
 109.697 -            return;
 109.698 -        case RegOverride:
 109.699 -            xdnd_override = True;
 109.700 -            break;
 109.701 -        case RegSuccess:
 109.702 -            xdnd_override = False;
 109.703 -            break;
 109.704 -        default:
 109.705 -            DASSERT(False);
 109.706 -        }
 109.707 -
 109.708 -        {
 109.709 -            EmbeddedDropSiteProtocolListEntry* xdnd_entry = NULL;
 109.710 -
 109.711 -            xdnd_entry = malloc(sizeof(EmbeddedDropSiteProtocolListEntry));
 109.712 -
 109.713 -            if (xdnd_entry == NULL) {
 109.714 -                return;
 109.715 -            }
 109.716 -
 109.717 -            xdnd_entry->window = toplevel;
 109.718 -            xdnd_entry->proxy = xdnd_proxy;
 109.719 -            xdnd_entry->protocol_version = xdnd_protocol_version;
 109.720 -            xdnd_entry->overriden = xdnd_override;
 109.721 -            xdnd_entry->next = embedded_xdnd_protocol_list;
 109.722 -            embedded_xdnd_protocol_list = xdnd_entry;
 109.723 -        }
 109.724 -    }
 109.725 -}
 109.726 -
 109.727 -/*
 109.728 - * If embedded_drop_site_list already contains an entry with the specified
 109.729 - * 'toplevel', the method registers the specified 'window' as an embedded drop
 109.730 - * site for this 'toplevel' and returns True.
 109.731 - * Otherwise, it checks if the 'toplevel' is a registered drop site for adds
 109.732 - * (window, component) pair to the list and returns True
 109.733 - * if completes successfully.
 109.734 - */
 109.735 -static Boolean
 109.736 -add_to_embedded_drop_site_list(Display* dpy, Window root, Window toplevel,
 109.737 -                               Window window) {
 109.738 -    EmbeddedDropSiteListEntry* entry = embedded_drop_site_list;
 109.739 -
 109.740 -    while (entry != NULL) {
 109.741 -        if (entry->toplevel == toplevel) {
 109.742 -            void* p = realloc(entry->embedded_sites,
 109.743 -                              sizeof(Window) *
 109.744 -                              (entry->embedded_sites_count + 1));
 109.745 -            if (p == NULL) {
 109.746 -                return False;
 109.747 -            }
 109.748 -            entry->embedded_sites = p;
 109.749 -            entry->embedded_sites[entry->embedded_sites_count++] = window;
 109.750 -
 109.751 -            register_xdnd_embedder(dpy, entry, window);
 109.752 -
 109.753 -            return True;
 109.754 -        }
 109.755 -        entry = entry->next;
 109.756 -    }
 109.757 -
 109.758 -    entry = awt_dnd_dt_init_proxy(dpy, root, toplevel, window);
 109.759 -
 109.760 -    if (entry == NULL) {
 109.761 -        return False;
 109.762 -    }
 109.763 -
 109.764 -    register_xdnd_embedder(dpy, entry, window);
 109.765 -
 109.766 -    entry->next = embedded_drop_site_list;
 109.767 -    embedded_drop_site_list = entry;
 109.768 -
 109.769 -    return True;
 109.770 -}
 109.771 -
 109.772 -/*
 109.773 - * Removes the window from the list of embedded drop sites for the toplevel.
 109.774 - * Returns True if the window was successfully removed, False otherwise.
 109.775 - */
 109.776 -static Boolean
 109.777 -remove_from_embedded_drop_site_list(Display* dpy, Window toplevel, Window window) {
 109.778 -    EmbeddedDropSiteListEntry* entry = embedded_drop_site_list;
 109.779 -    EmbeddedDropSiteListEntry* prev = NULL;
 109.780 -
 109.781 -    while (entry != NULL) {
 109.782 -        if (entry->toplevel == toplevel) {
 109.783 -            unsigned int idx;
 109.784 -
 109.785 -            for (idx = 0; idx < entry->embedded_sites_count; idx++) {
 109.786 -                if (entry->embedded_sites[idx] == window) {
 109.787 -                    int tail = entry->embedded_sites_count - idx - 1;
 109.788 -                    if (tail > 0) {
 109.789 -                        memmove(entry->embedded_sites + idx,
 109.790 -                                entry->embedded_sites + idx + 1,
 109.791 -                                tail * sizeof(Window));
 109.792 -                    }
 109.793 -                    entry->embedded_sites_count--;
 109.794 -
 109.795 -                    /* If the list of embedded drop sites for this toplevel
 109.796 -                       becomes empty - restore the original proxies and remove
 109.797 -                       the entry. */
 109.798 -                    if (entry->embedded_sites_count == 0) {
 109.799 -                        Widget w = XtWindowToWidget(dpy, toplevel);
 109.800 -
 109.801 -                        if (w != NULL) {
 109.802 -                            JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
 109.803 -                            Widget copy = w;
 109.804 -                            jobject peer = findPeer(&w);
 109.805 -
 109.806 -                            if (!JNU_IsNull(env, peer) &&
 109.807 -                                (*env)->IsInstanceOf(env, peer,
 109.808 -                                                     get_MEmbedCanvasPeerClass(env)) == JNI_TRUE) {
 109.809 -                                remove_xembed_drop_target(env, peer);
 109.810 -                            }
 109.811 -                        } else {
 109.812 -                            EmbeddedDropSiteProtocolListEntry* xdnd_entry =
 109.813 -                                get_xdnd_protocol_entry_for_toplevel(toplevel);
 109.814 -                            EmbeddedDropSiteProtocolListEntry* motif_entry =
 109.815 -                                get_motif_protocol_entry_for_toplevel(toplevel);
 109.816 -
 109.817 -                            if (xdnd_entry != NULL) {
 109.818 -                                if (xdnd_entry->overriden == True) {
 109.819 -                                    XChangeProperty(dpy, toplevel, XA_XdndAware,
 109.820 -                                                    XA_ATOM, 32,
 109.821 -                                                    PropModeReplace,
 109.822 -                                                    (unsigned char*)&xdnd_entry->protocol_version,
 109.823 -                                                    1);
 109.824 -
 109.825 -                                    XChangeProperty(dpy, toplevel, XA_XdndProxy,
 109.826 -                                                    XA_WINDOW, 32,
 109.827 -                                                    PropModeReplace,
 109.828 -                                                    (unsigned char*)&xdnd_entry->proxy, 1);
 109.829 -                                } else {
 109.830 -                                    XDeleteProperty(dpy, toplevel, XA_XdndAware);
 109.831 -                                    XDeleteProperty(dpy, toplevel, XA_XdndProxy);
 109.832 -                                }
 109.833 -                                remove_xdnd_protocol_entry_for_toplevel(toplevel);
 109.834 -                            }
 109.835 -
 109.836 -                            if (motif_entry != NULL) {
 109.837 -                                if (motif_entry->overriden == True) {
 109.838 -                                    /* Request status */
 109.839 -                                    int status;
 109.840 -
 109.841 -                                    Atom           type;
 109.842 -                                    int            format;
 109.843 -                                    unsigned long  nitems;
 109.844 -                                    unsigned long  after;
 109.845 -                                    unsigned char* data;
 109.846 -
 109.847 -                                    data = NULL;
 109.848 -                                    status = XGetWindowProperty(dpy, toplevel,
 109.849 -                                                                _XA_MOTIF_DRAG_RECEIVER_INFO, 0, 0xFFFF,
 109.850 -                                                                False, AnyPropertyType, &type, &format,
 109.851 -                                                                &nitems, &after, &data);
 109.852 -
 109.853 -                                    if (status == Success && data != NULL && type != None &&
 109.854 -                                        format == 8 && nitems >= MOTIF_RECEIVER_INFO_SIZE) {
 109.855 -                                        unsigned char byte_order = read_card8((char*)data, 0);
 109.856 -                                        void* p = (char*)data + 4;
 109.857 -
 109.858 -                                        DASSERT(MOTIF_BYTE_ORDER == byte_order);
 109.859 -
 109.860 -                                        if (MOTIF_BYTE_ORDER == byte_order) {
 109.861 -                                            /* restore the original proxy window */
 109.862 -                                            write_card32(&p, motif_entry->proxy);
 109.863 -
 109.864 -                                            XChangeProperty(dpy, toplevel,
 109.865 -                                                            _XA_MOTIF_DRAG_RECEIVER_INFO,
 109.866 -                                                            _XA_MOTIF_DRAG_RECEIVER_INFO, 8,
 109.867 -                                                            PropModeReplace,
 109.868 -                                                            (unsigned char*)data,
 109.869 -                                                            MOTIF_RECEIVER_INFO_SIZE);
 109.870 -                                        }
 109.871 -                                    }
 109.872 -
 109.873 -                                    if (status == Success) {
 109.874 -                                        XFree(data);
 109.875 -                                    }
 109.876 -                                } else {
 109.877 -                                    XDeleteProperty(dpy, toplevel, _XA_MOTIF_DRAG_RECEIVER_INFO);
 109.878 -                                }
 109.879 -
 109.880 -                                remove_motif_protocol_entry_for_toplevel(toplevel);
 109.881 -                            }
 109.882 -
 109.883 -                            if ((entry->event_mask & PropertyChangeMask) == 0) {
 109.884 -                                XSelectInput(dpy, toplevel, entry->event_mask);
 109.885 -                            }
 109.886 -                        }
 109.887 -
 109.888 -                        if (prev == NULL) {
 109.889 -                            embedded_drop_site_list = entry->next;
 109.890 -                        } else {
 109.891 -                            prev->next = entry->next;
 109.892 -                        }
 109.893 -
 109.894 -                        free(entry);
 109.895 -                    }
 109.896 -                    return True;
 109.897 -                }
 109.898 -            }
 109.899 -            return False;
 109.900 -        }
 109.901 -        prev = entry;
 109.902 -        entry = entry->next;
 109.903 -    }
 109.904 -    return False;
 109.905 -}
 109.906 -
 109.907 -static EmbeddedDropSiteListEntry*
 109.908 -get_entry_for_toplevel(Window toplevel) {
 109.909 -    EmbeddedDropSiteListEntry* entry = embedded_drop_site_list;
 109.910 -
 109.911 -    while (entry != NULL) {
 109.912 -        if (entry->toplevel == toplevel) {
 109.913 -            return entry;
 109.914 -        }
 109.915 -        entry = entry->next;
 109.916 -    }
 109.917 -    return NULL;
 109.918 -}
 109.919 -
 109.920 -static EmbeddedDropSiteProtocolListEntry*
 109.921 -get_motif_protocol_entry_for_toplevel(Window toplevel) {
 109.922 -    EmbeddedDropSiteProtocolListEntry* entry = embedded_motif_protocol_list;
 109.923 -
 109.924 -    while (entry != NULL) {
 109.925 -        if (entry->window == toplevel) {
 109.926 -            return entry;
 109.927 -        }
 109.928 -        entry = entry->next;
 109.929 -    }
 109.930 -    return NULL;
 109.931 -}
 109.932 -
 109.933 -static EmbeddedDropSiteProtocolListEntry*
 109.934 -get_xdnd_protocol_entry_for_toplevel(Window toplevel) {
 109.935 -    EmbeddedDropSiteProtocolListEntry* entry = embedded_xdnd_protocol_list;
 109.936 -
 109.937 -    while (entry != NULL) {
 109.938 -        if (entry->window == toplevel) {
 109.939 -            return entry;
 109.940 -        }
 109.941 -        entry = entry->next;
 109.942 -    }
 109.943 -    return NULL;
 109.944 -}
 109.945 -
 109.946 -static void
 109.947 -remove_motif_protocol_entry_for_toplevel(Window toplevel) {
 109.948 -    EmbeddedDropSiteProtocolListEntry* entry = embedded_motif_protocol_list;
 109.949 -    EmbeddedDropSiteProtocolListEntry* prev_entry = NULL;
 109.950 -
 109.951 -    while (entry != NULL) {
 109.952 -        if (entry->window == toplevel) {
 109.953 -            if (prev_entry != NULL) {
 109.954 -                prev_entry->next = entry->next;
 109.955 -            } else {
 109.956 -                embedded_motif_protocol_list = entry->next;
 109.957 -            }
 109.958 -            free(entry);
 109.959 -        }
 109.960 -        entry = entry->next;
 109.961 -        prev_entry = entry;
 109.962 -    }
 109.963 -}
 109.964 -
 109.965 -static void
 109.966 -remove_xdnd_protocol_entry_for_toplevel(Window toplevel) {
 109.967 -    EmbeddedDropSiteProtocolListEntry* entry = embedded_xdnd_protocol_list;
 109.968 -    EmbeddedDropSiteProtocolListEntry* prev_entry = NULL;
 109.969 -
 109.970 -    while (entry != NULL) {
 109.971 -        if (entry->window == toplevel) {
 109.972 -            if (prev_entry != NULL) {
 109.973 -                prev_entry->next = entry->next;
 109.974 -            } else {
 109.975 -                embedded_xdnd_protocol_list = entry->next;
 109.976 -            }
 109.977 -            free(entry);
 109.978 -        }
 109.979 -        entry = entry->next;
 109.980 -    }
 109.981 -}
 109.982 -
 109.983 -static Boolean
 109.984 -is_embedding_toplevel(Window toplevel) {
 109.985 -    return get_entry_for_toplevel(toplevel) != NULL;
 109.986 -}
 109.987 -
 109.988 -static Window
 109.989 -get_embedded_window(Display* dpy, Window toplevel, int x, int y) {
 109.990 -    EmbeddedDropSiteListEntry* entry = get_entry_for_toplevel(toplevel);
 109.991 -
 109.992 -    if (entry != NULL) {
 109.993 -        unsigned int idx;
 109.994 -
 109.995 -        for (idx = 0; idx < entry->embedded_sites_count; idx++) {
 109.996 -            Window site = entry->embedded_sites[idx];
 109.997 -            Window child = None;
 109.998 -            int x_return, y_return;
 109.999 -
109.1000 -            if (XTranslateCoordinates(dpy, entry->root, site, x, y,
109.1001 -                                      &x_return, &y_return, &child)) {
109.1002 -                if (x_return >= 0 && y_return >= 0) {
109.1003 -                    XWindowAttributes xwa;
109.1004 -                    XGetWindowAttributes(dpy, site, &xwa);
109.1005 -                    if (xwa.map_state != IsUnmapped &&
109.1006 -                        x_return < xwa.width && y_return < xwa.height) {
109.1007 -                        return site;
109.1008 -                    }
109.1009 -                }
109.1010 -            }
109.1011 -        }
109.1012 -    }
109.1013 -
109.1014 -    return None;
109.1015 -}
109.1016 -
109.1017 -/*
109.1018 - * If the toplevel is not an embedding toplevel does nothing and returns False.
109.1019 - * Otherwise, sets xdnd_proxy for the specified toplevel to the 'proxy_window',
109.1020 - * xdnd_protocol_version to 'version', xdnd_override to 'override', returns True.
109.1021 - */
109.1022 -static Boolean
109.1023 -set_xdnd_proxy_for_toplevel(Window toplevel, Window proxy_window,
109.1024 -                            unsigned int version, Boolean override) {
109.1025 -    EmbeddedDropSiteProtocolListEntry* entry =
109.1026 -        get_xdnd_protocol_entry_for_toplevel(toplevel);
109.1027 -
109.1028 -    if (entry == NULL) {
109.1029 -        return False;
109.1030 -    }
109.1031 -
109.1032 -    entry->proxy = proxy_window;
109.1033 -    entry->protocol_version = version;
109.1034 -    entry->overriden = override;
109.1035 -
109.1036 -    return True;
109.1037 -}
109.1038 -
109.1039 -/*
109.1040 - * If the toplevel is not an embedding toplevel does nothing and returns False.
109.1041 - * Otherwise, sets motif_proxy for the specified toplevel to the proxy_window,
109.1042 - * motif_override to 'override' and returns True.
109.1043 - */
109.1044 -static Boolean
109.1045 -set_motif_proxy_for_toplevel(Window toplevel, Window proxy_window, Boolean override) {
109.1046 -    EmbeddedDropSiteProtocolListEntry* entry =
109.1047 -        get_motif_protocol_entry_for_toplevel(toplevel);
109.1048 -
109.1049 -    if (entry == NULL) {
109.1050 -        return False;
109.1051 -    }
109.1052 -
109.1053 -    entry->proxy = proxy_window;
109.1054 -    entry->overriden = override;
109.1055 -
109.1056 -    return True;
109.1057 -}
109.1058 -
109.1059 -/*
109.1060 - * Forwards a drag notification to the embedding toplevel modifying the event
109.1061 - * to match the protocol version supported by the toplevel.
109.1062 - * Returns True if the event is sent, False otherwise.
109.1063 - */
109.1064 -static Boolean
109.1065 -forward_client_message_to_toplevel(Window toplevel, XClientMessageEvent* event) {
109.1066 -    EmbeddedDropSiteProtocolListEntry* protocol_entry = NULL;
109.1067 -    Window proxy = None;
109.1068 -
109.1069 -    if (event->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) {
109.1070 -        protocol_entry = get_motif_protocol_entry_for_toplevel(toplevel);
109.1071 -    } else {
109.1072 -        /* Assume XDnD */
109.1073 -        protocol_entry = get_xdnd_protocol_entry_for_toplevel(toplevel);
109.1074 -        if (protocol_entry != NULL) {
109.1075 -            /* Adjust the event to match the XDnD protocol version. */
109.1076 -            unsigned int version = protocol_entry->protocol_version;
109.1077 -            if (event->message_type == XA_XdndEnter) {
109.1078 -                unsigned int min_version = source_protocol_version < version ?
109.1079 -                    source_protocol_version : version;
109.1080 -                event->data.l[1] = min_version << XDND_PROTOCOL_SHIFT;
109.1081 -                event->data.l[1] |= source_data_types_count > 3 ? XDND_DATA_TYPES_BIT : 0;
109.1082 -            }
109.1083 -        }
109.1084 -    }
109.1085 -
109.1086 -    if (protocol_entry == NULL) {
109.1087 -        return False;
109.1088 -    }
109.1089 -
109.1090 -    if (!protocol_entry->overriden) {
109.1091 -        return False;
109.1092 -    }
109.1093 -    proxy = protocol_entry->proxy;
109.1094 -
109.1095 -    if (proxy == None) {
109.1096 -        proxy = toplevel;
109.1097 -    }
109.1098 -
109.1099 -    event->window = toplevel;
109.1100 -
109.1101 -    XSendEvent(event->display, proxy, False, NoEventMask, (XEvent*)event);
109.1102 -
109.1103 -    return True;
109.1104 -}
109.1105 -
109.1106 -/******************************************************************************/
109.1107 -
109.1108 -/********************* Drop site list support *********************************/
109.1109 -
109.1110 -struct DropSiteListEntryRec;
109.1111 -
109.1112 -typedef struct DropSiteListEntryRec DropSiteListEntry;
109.1113 -
109.1114 -struct DropSiteListEntryRec {
109.1115 -    Window             window;
109.1116 -    Window             root;
109.1117 -    /*
109.1118 -     * The closest to the root ancestor with WM_STATE property set.
109.1119 -     * Normally toplevel == window.
109.1120 -     * In plugin scenario toplevel is the browser toplevel window.
109.1121 -     */
109.1122 -    Window             toplevel;
109.1123 -    /*
109.1124 -     * Java top-level position is the outer canvas position, not the shell
109.1125 -     * window position. We need to keep the outer canvas ID (and the root ID) to
109.1126 -     * translate from mouse position root coordinates to the Java component
109.1127 -     * coordinates.
109.1128 -     */
109.1129 -    Window             outer_canvas;
109.1130 -    jobject            component;
109.1131 -    DropSiteListEntry* next;
109.1132 -};
109.1133 -
109.1134 -static DropSiteListEntry* drop_site_list = NULL;
109.1135 -
109.1136 -/*
109.1137 - * If drop_site_list already contains an entry with the same window,
109.1138 - * does nothing and returns False.
109.1139 - * Otherwise, adds a new entry the list and returns True
109.1140 - * if completes successfully.
109.1141 - */
109.1142 -static Boolean
109.1143 -add_to_drop_site_list(Window window, Window root, Window toplevel,
109.1144 -                      Window outer_canvas, jobject component) {
109.1145 -    DropSiteListEntry* entry = drop_site_list;
109.1146 -
109.1147 -    while (entry != NULL) {
109.1148 -        if (entry->window == window) {
109.1149 -            return False;
109.1150 -        }
109.1151 -        entry = entry->next;
109.1152 -    }
109.1153 -
109.1154 -    entry = malloc(sizeof(DropSiteListEntry));
109.1155 -
109.1156 -    if (entry == NULL) {
109.1157 -        return False;
109.1158 -    }
109.1159 -
109.1160 -    entry->window = window;
109.1161 -    entry->root = root;
109.1162 -    entry->toplevel = toplevel;
109.1163 -    entry->outer_canvas = outer_canvas;
109.1164 -    entry->component = component;
109.1165 -    entry->next = drop_site_list;
109.1166 -    drop_site_list = entry;
109.1167 -
109.1168 -    return True;
109.1169 -}
109.1170 -
109.1171 -/*
109.1172 - * Returns True if the list entry for the specified window has been successfully
109.1173 - * removed from the list. Otherwise, returns False.
109.1174 - */
109.1175 -static Boolean
109.1176 -remove_from_drop_site_list(Window window) {
109.1177 -    DropSiteListEntry* entry = drop_site_list;
109.1178 -    DropSiteListEntry* prev = NULL;
109.1179 -
109.1180 -    while (entry != NULL) {
109.1181 -        if (entry->window == window) {
109.1182 -            if (prev != NULL) {
109.1183 -                prev->next = entry->next;
109.1184 -            } else {
109.1185 -                drop_site_list = entry->next;
109.1186 -            }
109.1187 -            free(entry);
109.1188 -            return True;
109.1189 -        }
109.1190 -        prev = entry;
109.1191 -        entry = entry->next;
109.1192 -    }
109.1193 -
109.1194 -    return False;
109.1195 -}
109.1196 -
109.1197 -static jobject
109.1198 -get_component_for_window(Window window) {
109.1199 -    DropSiteListEntry* entry = drop_site_list;
109.1200 -
109.1201 -    while (entry != NULL) {
109.1202 -        if (entry->window == window) {
109.1203 -            return entry->component;
109.1204 -        }
109.1205 -        entry = entry->next;
109.1206 -    }
109.1207 -
109.1208 -    return NULL;
109.1209 -}
109.1210 -
109.1211 -static Window
109.1212 -get_root_for_window(Window window) {
109.1213 -    DropSiteListEntry* entry = drop_site_list;
109.1214 -
109.1215 -    while (entry != NULL) {
109.1216 -        if (entry->window == window) {
109.1217 -            return entry->root;
109.1218 -        }
109.1219 -        entry = entry->next;
109.1220 -    }
109.1221 -
109.1222 -    return None;
109.1223 -}
109.1224 -
109.1225 -static Window
109.1226 -get_toplevel_for_window(Window window) {
109.1227 -    DropSiteListEntry* entry = drop_site_list;
109.1228 -
109.1229 -    while (entry != NULL) {
109.1230 -        if (entry->window == window) {
109.1231 -            return entry->toplevel;
109.1232 -        }
109.1233 -        entry = entry->next;
109.1234 -    }
109.1235 -
109.1236 -    return None;
109.1237 -}
109.1238 -
109.1239 -static Window
109.1240 -get_outer_canvas_for_window(Window window) {
109.1241 -    DropSiteListEntry* entry = drop_site_list;
109.1242 -
109.1243 -    while (entry != NULL) {
109.1244 -        if (entry->window == window) {
109.1245 -            return entry->outer_canvas;
109.1246 -        }
109.1247 -        entry = entry->next;
109.1248 -    }
109.1249 -
109.1250 -    return None;
109.1251 -}
109.1252 -/******************************************************************************/
109.1253 -
109.1254 -/******************* Delayed drop site registration stuff *********************/
109.1255 -struct DelayedRegistrationEntryRec;
109.1256 -
109.1257 -typedef struct DelayedRegistrationEntryRec DelayedRegistrationEntry;
109.1258 -
109.1259 -struct DelayedRegistrationEntryRec {
109.1260 -    Widget outer_canvas;
109.1261 -    jobject component;
109.1262 -    XtIntervalId timer;
109.1263 -    DelayedRegistrationEntry* next;
109.1264 -};
109.1265 -
109.1266 -static DelayedRegistrationEntry* delayed_registration_list = NULL;
109.1267 -
109.1268 -static const int DELAYED_REGISTRATION_PERIOD = 500;
109.1269 -
109.1270 -/* Timer callback. */
109.1271 -static void
109.1272 -register_drop_site_later(XtPointer client_data, XtIntervalId* id);
109.1273 -
109.1274 -/*
109.1275 - * Enqueues the specified widget and component for delayed drop site
109.1276 - * registration. If this widget has already been registered, does nothing and
109.1277 - * returns False. Otherwise, schedules a timer callback that will repeatedly
109.1278 - * attempt to register the drop site until the registration succeeds.
109.1279 - * To remove this widget from the queue of delayed registration call
109.1280 - * remove_delayed_registration_entry().
109.1281 - *
109.1282 - * The caller must own AWT_LOCK.
109.1283 - */
109.1284 -static Boolean
109.1285 -add_delayed_registration_entry(Widget outer_canvas, XtPointer componentRef) {
109.1286 -    DelayedRegistrationEntry* entry = delayed_registration_list;
109.1287 -
109.1288 -    if (outer_canvas == NULL || componentRef == NULL) {
109.1289 -        return False;
109.1290 -    }
109.1291 -
109.1292 -    while (entry != NULL && entry->outer_canvas != outer_canvas) {
109.1293 -        entry = entry->next;
109.1294 -    }
109.1295 -
109.1296 -    if (entry != NULL) {
109.1297 -        return False;
109.1298 -    }
109.1299 -
109.1300 -    entry = malloc(sizeof(DelayedRegistrationEntry));
109.1301 -
109.1302 -    if (entry == NULL) {
109.1303 -        return False;
109.1304 -    }
109.1305 -
109.1306 -    entry->outer_canvas = outer_canvas;
109.1307 -    entry->component = componentRef;
109.1308 -    entry->timer = XtAppAddTimeOut(awt_appContext, DELAYED_REGISTRATION_PERIOD,
109.1309 -                                   register_drop_site_later, entry);
109.1310 -    entry->next = delayed_registration_list;
109.1311 -    delayed_registration_list = entry;
109.1312 -
109.1313 -    return True;
109.1314 -}
109.1315 -
109.1316 -/*
109.1317 - * Unregisters the timer callback and removes this widget from the queue of
109.1318 - * delayed drop site registration.
109.1319 - *
109.1320 - * The caller must own AWT_LOCK.
109.1321 - */
109.1322 -static Boolean
109.1323 -remove_delayed_registration_entry(Widget outer_canvas) {
109.1324 -    DelayedRegistrationEntry* entry = delayed_registration_list;
109.1325 -    DelayedRegistrationEntry* prev = NULL;
109.1326 -
109.1327 -    if (outer_canvas == NULL) {
109.1328 -        return False;
109.1329 -    }
109.1330 -
109.1331 -    while (entry != NULL && entry->outer_canvas != outer_canvas) {
109.1332 -        prev = entry;
109.1333 -        entry = entry->next;
109.1334 -    }
109.1335 -
109.1336 -    if (entry == NULL) {
109.1337 -        return False;
109.1338 -    }
109.1339 -
109.1340 -    if (prev != NULL) {
109.1341 -        prev->next = entry->next;
109.1342 -    } else {
109.1343 -        delayed_registration_list = entry->next;
109.1344 -    }
109.1345 -
109.1346 -    if (entry->timer) {
109.1347 -        XtRemoveTimeOut(entry->timer);
109.1348 -        entry->timer = (XtIntervalId)0;
109.1349 -    }
109.1350 -
109.1351 -    free(entry);
109.1352 -
109.1353 -    return True;
109.1354 -}
109.1355 -
109.1356 -static void
109.1357 -register_drop_site_later(XtPointer client_data, XtIntervalId* id) {
109.1358 -    DelayedRegistrationEntry* entry = (DelayedRegistrationEntry*)client_data;
109.1359 -
109.1360 -    if (XtIsRealized(entry->outer_canvas) &&
109.1361 -        register_drop_site(entry->outer_canvas, entry->component)) {
109.1362 -        remove_delayed_registration_entry(entry->outer_canvas);
109.1363 -    } else {
109.1364 -        entry->timer = XtAppAddTimeOut(awt_appContext, DELAYED_REGISTRATION_PERIOD,
109.1365 -                                       register_drop_site_later, entry);
109.1366 -    }
109.1367 -}
109.1368 -/******************************************************************************/
109.1369 -
109.1370 -static void
109.1371 -awt_dnd_cleanup() {
109.1372 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
109.1373 -
109.1374 -    if (!JNU_IsNull(env, target_component)) {
109.1375 -        /* Trigger dragExit */
109.1376 -        /*
109.1377 -         * Note: we pass NULL native context. This indicates that response
109.1378 -         * shouldn't be sent to the source.
109.1379 -         */
109.1380 -        dt_postDropTargetEvent(env, target_component, 0, 0,
109.1381 -                               java_awt_dnd_DnDConstants_ACTION_NONE,
109.1382 -                               java_awt_event_MouseEvent_MOUSE_EXITED,
109.1383 -                               NULL);
109.1384 -    }
109.1385 -
109.1386 -    if (motif_top_level_leave_postponed) {
109.1387 -        XClientMessageEvent* leave = &motif_top_level_leave_postponed_event;
109.1388 -        if (leave->type == ClientMessage) {
109.1389 -            Window win = leave->window;
109.1390 -            if (is_embedding_toplevel(win)) {
109.1391 -                forward_client_message_to_toplevel(win, leave);
109.1392 -            }
109.1393 -        }
109.1394 -    }
109.1395 -
109.1396 -    if (source_window != None) {
109.1397 -        XSelectInput(awt_display, source_window, source_window_mask);
109.1398 -    }
109.1399 -
109.1400 -    source_protocol = NO_PROTOCOL;
109.1401 -    source_protocol_version = 0;
109.1402 -    source_window = None;
109.1403 -    source_atom = None;
109.1404 -    source_window_mask = 0;
109.1405 -    source_actions = java_awt_dnd_DnDConstants_ACTION_NONE;
109.1406 -    track_source_actions = False;
109.1407 -    (*env)->DeleteGlobalRef(env, source_data_types);
109.1408 -    source_data_types = NULL;
109.1409 -    if (source_data_types_native != NULL) {
109.1410 -        free(source_data_types_native);
109.1411 -        source_data_types_native = NULL;
109.1412 -    }
109.1413 -    source_data_types_count = 0;
109.1414 -    source_x = 0;
109.1415 -    source_y = 0;
109.1416 -    target_component = NULL;
109.1417 -    motif_top_level_leave_postponed = False;
109.1418 -    memset(&motif_top_level_leave_postponed_event, 0,
109.1419 -           sizeof(XClientMessageEvent));
109.1420 -}
109.1421 -
109.1422 -static jlongArray
109.1423 -get_data_types_array(JNIEnv* env, Atom* types, unsigned int types_count) {
109.1424 -    jlongArray array = NULL;
109.1425 -    jboolean isCopy;
109.1426 -    jlong*   jTargets;
109.1427 -#ifndef _LP64 /* Atom and jlong are different sizes in the 32-bit build */
109.1428 -    unsigned int i;
109.1429 -#endif
109.1430 -
109.1431 -    if ((*env)->PushLocalFrame(env, 1) < 0) {
109.1432 -        return NULL;
109.1433 -    }
109.1434 -
109.1435 -    array = (*env)->NewLongArray(env, types_count);
109.1436 -
109.1437 -    if (JNU_IsNull(env, array)) {
109.1438 -        return NULL;
109.1439 -    }
109.1440 -
109.1441 -    if (types_count == 0) {
109.1442 -        return array;
109.1443 -    }
109.1444 -
109.1445 -    jTargets = (*env)->GetLongArrayElements(env, array, &isCopy);
109.1446 -    if (jTargets == NULL) {
109.1447 -        (*env)->PopLocalFrame(env, NULL);
109.1448 -        return NULL;
109.1449 -    }
109.1450 -
109.1451 -#ifdef _LP64
109.1452 -    memcpy(jTargets, types, types_count * sizeof(Atom));
109.1453 -#else
109.1454 -    for (i = 0; i < types_count; i++) {
109.1455 -        jTargets[i] = (types[i] & 0xFFFFFFFFLU);
109.1456 -    }
109.1457 -#endif
109.1458 -
109.1459 -    (*env)->ReleaseLongArrayElements(env, array, jTargets, 0);
109.1460 -
109.1461 -    array = (*env)->NewGlobalRef(env, array);
109.1462 -
109.1463 -    (*env)->PopLocalFrame(env, NULL);
109.1464 -
109.1465 -    return array;
109.1466 -}
109.1467 -
109.1468 -static Boolean
109.1469 -is_xdnd_drag_message_type(unsigned long message_type) {
109.1470 -    return message_type == XA_XdndEnter ||
109.1471 -        message_type == XA_XdndPosition ||
109.1472 -        message_type == XA_XdndLeave ||
109.1473 -        message_type == XA_XdndDrop ? True : False;
109.1474 -}
109.1475 -
109.1476 -/*
109.1477 - * Returns EventConsume if the event should be consumed,
109.1478 - * EventPassAlong otherwise.
109.1479 - */
109.1480 -static EventStatus
109.1481 -handle_xdnd_enter(XClientMessageEvent* event) {
109.1482 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
109.1483 -    Display* dpy = event->display;
109.1484 -    long* event_data = event->data.l;
109.1485 -    Window source_win = None;
109.1486 -    long source_win_mask = 0;
109.1487 -    unsigned int protocol_version = 0;
109.1488 -    unsigned int data_types_count = 0;
109.1489 -    Atom* data_types = NULL;
109.1490 -    jlongArray java_data_types = NULL;
109.1491 -    jint actions = java_awt_dnd_DnDConstants_ACTION_NONE;
109.1492 -    Boolean track = False;
109.1493 -
109.1494 -    DTRACE_PRINTLN5("%s:%d XdndEnter comp=%X src_win=%ld protocol=%d.",
109.1495 -                    __FILE__, __LINE__,
109.1496 -                    target_component, source_window, source_protocol);
109.1497 -
109.1498 -    if (!JNU_IsNull(env, target_component) || source_window != None ||
109.1499 -        source_protocol != NO_PROTOCOL) {
109.1500 -        DTRACE_PRINTLN2("%s:%d XdndEnter rejected - invalid state.",
109.1501 -                        __FILE__, __LINE__);
109.1502 -        return EventFailure;
109.1503 -    }
109.1504 -
109.1505 -    /*
109.1506 -     * NOTE: the component can be NULL if the event was sent to the embedding
109.1507 -     * toplevel.
109.1508 -     */
109.1509 -    if (JNU_IsNull(env, get_component_for_window(event->window)) &&
109.1510 -        !is_embedding_toplevel(event->window)) {
109.1511 -        DTRACE_PRINTLN2("%s:%d XdndEnter rejected - window is not a registered drop site.",
109.1512 -                        __FILE__, __LINE__);
109.1513 -        return EventFailure;
109.1514 -    }
109.1515 -
109.1516 -    protocol_version =
109.1517 -        (event_data[1] & XDND_PROTOCOL_MASK) >> XDND_PROTOCOL_SHIFT;
109.1518 -
109.1519 -    /* XDnD compliance only requires supporting version 3 and up. */
109.1520 -    if (protocol_version < XDND_MIN_PROTOCOL_VERSION) {
109.1521 -        DTRACE_PRINTLN2("%s:%d XdndEnter rejected - invalid protocol version.",
109.1522 -                        __FILE__, __LINE__);
109.1523 -        return EventFailure;
109.1524 -    }
109.1525 -
109.1526 -    /* Ignore the source if the protocol version is higher than we support. */
109.1527 -    if (protocol_version > XDND_PROTOCOL_VERSION) {
109.1528 -        DTRACE_PRINTLN2("%s:%d XdndEnter rejected - invalid protocol version.",
109.1529 -                        __FILE__, __LINE__);
109.1530 -        return EventFailure;
109.1531 -    }
109.1532 -
109.1533 -    source_win = event_data[0];
109.1534 -
109.1535 -    /* Extract the list of supported actions. */
109.1536 -    if (protocol_version < 2) {
109.1537 -        /* Prior to XDnD version 2 only COPY action was supported. */
109.1538 -        actions = java_awt_dnd_DnDConstants_ACTION_COPY;
109.1539 -    } else {
109.1540 -        unsigned char  ret;
109.1541 -        Atom           type;
109.1542 -        int            format;
109.1543 -        unsigned long  nitems;
109.1544 -        unsigned long  after;
109.1545 -        unsigned char  *data;
109.1546 -
109.1547 -        data = NULL;
109.1548 -        ret = checked_XGetWindowProperty(dpy, source_win, XA_XdndActionList,
109.1549 -                                         0, 0xFFFF, False, XA_ATOM, &type,
109.1550 -                                         &format, &nitems, &after, &data);
109.1551 -
109.1552 -        /* Ignore the source if the window is destroyed. */
109.1553 -        if (ret == BadWindow) {
109.1554 -            DTRACE_PRINTLN2("%s:%d XdndEnter rejected - invalid window.",
109.1555 -                            __FILE__, __LINE__);
109.1556 -            return EventFailure;
109.1557 -        }
109.1558 -
109.1559 -        if (ret == Success) {
109.1560 -            if (type == XA_ATOM && format == 32) {
109.1561 -                unsigned int i;
109.1562 -                Atom* action_atoms = (Atom*)data;
109.1563 -
109.1564 -                for (i = 0; i < nitems; i++) {
109.1565 -                    actions |= xdnd_to_java_action(action_atoms[i]);
109.1566 -                }
109.1567 -            }
109.1568 -
109.1569 -            /*
109.1570 -             * According to XDnD protocol, XdndActionList is optional.
109.1571 -             * If XdndActionList is not set we try to guess which actions are
109.1572 -             * supported.
109.1573 -             */
109.1574 -            if (type == None) {
109.1575 -                actions = java_awt_dnd_DnDConstants_ACTION_COPY;
109.1576 -                track = True;
109.1577 -            }
109.1578 -
109.1579 -            XFree(data);
109.1580 -        }
109.1581 -    }
109.1582 -
109.1583 -    /* Extract the available data types. */
109.1584 -    if (event_data[1] & XDND_DATA_TYPES_BIT) {
109.1585 -        unsigned char  ret;
109.1586 -        Atom           type;
109.1587 -        int            format;
109.1588 -        unsigned long  nitems;
109.1589 -        unsigned long  after;
109.1590 -        unsigned char  *data;
109.1591 -
109.1592 -        data = NULL;
109.1593 -        ret = checked_XGetWindowProperty(dpy, source_win, XA_XdndTypeList,
109.1594 -                                         0, 0xFFFF, False, XA_ATOM, &type,
109.1595 -                                         &format, &nitems, &after, &data);
109.1596 -
109.1597 -        /* Ignore the source if the window is destroyed. */
109.1598 -        if (ret == BadWindow) {
109.1599 -            DTRACE_PRINTLN2("%s:%d XdndEnter rejected - invalid window.",
109.1600 -                            __FILE__, __LINE__);
109.1601 -            return EventFailure;
109.1602 -        }
109.1603 -
109.1604 -        if (ret == Success) {
109.1605 -            if (type == XA_ATOM && format == 32 && nitems > 0) {
109.1606 -                data_types_count = nitems;
109.1607 -                data_types = (Atom*)malloc(data_types_count * sizeof(Atom));
109.1608 -
109.1609 -                if (data_types == NULL) {
109.1610 -                    XFree(data);
109.1611 -                    DTRACE_PRINTLN2("%s:%d XdndEnter rejected - malloc fails.",
109.1612 -                                    __FILE__, __LINE__);
109.1613 -                    return EventFailure;
109.1614 -                }
109.1615 -
109.1616 -                memcpy((void *)data_types, (void *)data,
109.1617 -                       data_types_count * sizeof(Atom));
109.1618 -            }
109.1619 -
109.1620 -            XFree(data);
109.1621 -        }
109.1622 -    } else {
109.1623 -        int i;
109.1624 -        data_types = (Atom*)malloc(3 * sizeof (Atom));
109.1625 -        if (data_types == NULL) {
109.1626 -            DTRACE_PRINTLN2("%s:%d XdndEnter rejected - malloc fails.",
109.1627 -                            __FILE__, __LINE__);
109.1628 -            return EventFailure;
109.1629 -        }
109.1630 -        for (i = 0; i < 3; i++) {
109.1631 -            Atom j;
109.1632 -            if ((j = event_data[2 + i]) != None) {
109.1633 -                data_types[data_types_count++] = j;
109.1634 -            }
109.1635 -        }
109.1636 -    }
109.1637 -
109.1638 -    java_data_types = get_data_types_array(env, data_types, data_types_count);
109.1639 -
109.1640 -    if (JNU_IsNull(env, java_data_types)) {
109.1641 -        DTRACE_PRINTLN2("%s:%d XdndEnter rejected - cannot create types array.",
109.1642 -                        __FILE__, __LINE__);
109.1643 -        free((char*)data_types);
109.1644 -        return EventFailure;
109.1645 -    }
109.1646 -
109.1647 -    /*
109.1648 -     * Select for StructureNotifyMask to receive DestroyNotify in case of source
109.1649 -     * crash.
109.1650 -     */
109.1651 -    {
109.1652 -        unsigned char ret;
109.1653 -        XWindowAttributes xwa;
109.1654 -
109.1655 -        XGetWindowAttributes(dpy, source_win, &xwa);
109.1656 -
109.1657 -        source_win_mask = xwa.your_event_mask;
109.1658 -
109.1659 -        ret = checked_XSelectInput(dpy, source_win,
109.1660 -                                   (source_win_mask | StructureNotifyMask));
109.1661 -
109.1662 -        if (ret == BadWindow) {
109.1663 -            DTRACE_PRINTLN2("%s:%d XdndEnter rejected - invalid window.",
109.1664 -                            __FILE__, __LINE__);
109.1665 -            free((char*)data_types);
109.1666 -            (*env)->DeleteGlobalRef(env, java_data_types);
109.1667 -            return EventFailure;
109.1668 -        }
109.1669 -    }
109.1670 -
109.1671 -    /* Update the global state. */
109.1672 -    source_protocol = XDND_PROTOCOL;
109.1673 -    source_protocol_version = protocol_version;
109.1674 -    source_window = source_win;
109.1675 -    source_window_mask = source_win_mask;
109.1676 -    source_actions = actions;
109.1677 -    track_source_actions = track;
109.1678 -    source_data_types = java_data_types;
109.1679 -    source_data_types_native = data_types;
109.1680 -    source_data_types_count = data_types_count;
109.1681 -
109.1682 -    DTRACE_PRINTLN5("%s:%d XdndEnter handled src_win=%ld protocol=%d fmt=%d.",
109.1683 -                    __FILE__, __LINE__,
109.1684 -                    source_window, source_protocol, data_types_count);
109.1685 -
109.1686 -    return EventSuccess;
109.1687 -}
109.1688 -
109.1689 -/*
109.1690 - * Returns EventConsume if the event should be consumed,
109.1691 - * EventPassAlong otherwise.
109.1692 - */
109.1693 -static EventStatus
109.1694 -handle_xdnd_position(XClientMessageEvent* event) {
109.1695 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
109.1696 -    long* event_data = event->data.l;
109.1697 -    Window source_win = None;
109.1698 -    Time time_stamp = CurrentTime;
109.1699 -    Atom action_atom = None;
109.1700 -    jint action = java_awt_dnd_DnDConstants_ACTION_NONE;
109.1701 -    int x = 0;
109.1702 -    int y = 0;
109.1703 -    jint java_event_id = 0;
109.1704 -    jobject component = NULL;
109.1705 -    Window receiver = None;
109.1706 -
109.1707 -    DTRACE_PRINTLN5("%s:%d XdndPosition comp=%X src_win=%ld protocol=%d.",
109.1708 -                    __FILE__, __LINE__,
109.1709 -                    target_component, source_window, source_protocol);
109.1710 -
109.1711 -    if (source_protocol != XDND_PROTOCOL) {
109.1712 -        DTRACE_PRINTLN2("%s:%d XdndPosition rejected - invalid state.",
109.1713 -                        __FILE__, __LINE__);
109.1714 -        return EventFailure;
109.1715 -    }
109.1716 -
109.1717 -    source_win = event_data[0];
109.1718 -
109.1719 -    /* Ignore XDnD messages from all other windows. */
109.1720 -    if (source_window != source_win) {
109.1721 -        DTRACE_PRINTLN4("%s:%d XdndPosition rejected - invalid source window cur=%ld this=%ld.",
109.1722 -                        __FILE__, __LINE__, source_window, source_win);
109.1723 -        return EventFailure;
109.1724 -    }
109.1725 -
109.1726 -    x = event_data[2] >> 16;
109.1727 -    y = event_data[2] & 0xFFFF;
109.1728 -
109.1729 -    component = get_component_for_window(event->window);
109.1730 -
109.1731 -    if (JNU_IsNull(env, component)) {
109.1732 -        /*
109.1733 -         * The window must be the embedding toplevel, since otherwise we would reject the
109.1734 -         * XdndEnter and never get to this point.
109.1735 -         */
109.1736 -        DASSERT(is_embedding_toplevel(event->window));
109.1737 -
109.1738 -        receiver = get_embedded_window(event->display, event->window, x, y);
109.1739 -
109.1740 -        if (receiver != None) {
109.1741 -            component = get_component_for_window(receiver);
109.1742 -        }
109.1743 -    } else {
109.1744 -        receiver = event->window;
109.1745 -    }
109.1746 -
109.1747 -    /* Translate mouse position from root coordinates
109.1748 -       to the target window coordinates. */
109.1749 -    if (receiver != None) {
109.1750 -        Window child = None;
109.1751 -        XTranslateCoordinates(event->display,
109.1752 -                              get_root_for_window(receiver),
109.1753 -                              get_outer_canvas_for_window(receiver),
109.1754 -                              x, y, &x, &y, &child);
109.1755 -    }
109.1756 -
109.1757 -    /* Time stamp - new in XDnD version 1. */
109.1758 -    if (source_protocol_version > 0) {
109.1759 -        time_stamp = event_data[3];
109.1760 -    }
109.1761 -
109.1762 -    /* User action - new in XDnD version 1. */
109.1763 -    if (source_protocol_version > 1) {
109.1764 -        action_atom = event_data[4];
109.1765 -    } else {
109.1766 -        /* The default action is XdndActionCopy */
109.1767 -        action_atom = XA_XdndActionCopy;
109.1768 -    }
109.1769 -
109.1770 -    action = xdnd_to_java_action(action_atom);
109.1771 -
109.1772 -    if (track_source_actions) {
109.1773 -        source_actions |= action;
109.1774 -    }
109.1775 -
109.1776 -    if (JNU_IsNull(env, component)) {
109.1777 -        if (!JNU_IsNull(env, target_component)) {
109.1778 -            dt_postDropTargetEvent(env, target_component, x, y,
109.1779 -                                   java_awt_dnd_DnDConstants_ACTION_NONE,
109.1780 -                                   java_awt_event_MouseEvent_MOUSE_EXITED,
109.1781 -                                   NULL);
109.1782 -        }
109.1783 -    } else {
109.1784 -        if (JNU_IsNull(env, target_component)) {
109.1785 -            java_event_id = java_awt_event_MouseEvent_MOUSE_ENTERED;
109.1786 -        } else {
109.1787 -            java_event_id = java_awt_event_MouseEvent_MOUSE_DRAGGED;
109.1788 -        }
109.1789 -
109.1790 -        dt_postDropTargetEvent(env, component, x, y, action,
109.1791 -                               java_event_id, event);
109.1792 -    }
109.1793 -
109.1794 -    user_action = action;
109.1795 -    source_x = x;
109.1796 -    source_y = y;
109.1797 -    target_component = component;
109.1798 -
109.1799 -    return EventSuccess;
109.1800 -}
109.1801 -
109.1802 -/*
109.1803 - * Returns EventConsume if the event should be consumed,
109.1804 - * EventPassAlong otherwise.
109.1805 - */
109.1806 -static EventStatus
109.1807 -handle_xdnd_leave(XClientMessageEvent* event) {
109.1808 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
109.1809 -    long* event_data = event->data.l;
109.1810 -    Window source_win = None;
109.1811 -
109.1812 -    if (source_protocol != XDND_PROTOCOL) {
109.1813 -        DTRACE_PRINTLN2("%s:%d XdndLeave rejected - invalid state.",
109.1814 -                        __FILE__, __LINE__);
109.1815 -        return EventFailure;
109.1816 -    }
109.1817 -
109.1818 -    source_win = event_data[0];
109.1819 -
109.1820 -    /* Ignore XDnD messages from all other windows. */
109.1821 -    if (source_window != source_win) {
109.1822 -        DTRACE_PRINTLN4("%s:%d XdndLeave rejected - invalid source window cur=%ld this=%ld.",
109.1823 -                        __FILE__, __LINE__, source_window, source_win);
109.1824 -        return EventFailure;
109.1825 -    }
109.1826 -
109.1827 -    awt_dnd_cleanup();
109.1828 -
109.1829 -    return EventSuccess;
109.1830 -}
109.1831 -
109.1832 -/*
109.1833 - * Returns EventConsume if the event should be consumed,
109.1834 - * EventPassAlong otherwise.
109.1835 - */
109.1836 -static EventStatus
109.1837 -handle_xdnd_drop(XClientMessageEvent* event) {
109.1838 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
109.1839 -    long* event_data = event->data.l;
109.1840 -    Window source_win = None;
109.1841 -
109.1842 -    DTRACE_PRINTLN5("%s:%d XdndDrop comp=%X src_win=%ld protocol=%d.",
109.1843 -                    __FILE__, __LINE__,
109.1844 -                    target_component, source_window, source_protocol);
109.1845 -
109.1846 -    if (source_protocol != XDND_PROTOCOL) {
109.1847 -        DTRACE_PRINTLN2("%s:%d XdndDrop rejected - invalid state.",
109.1848 -                        __FILE__, __LINE__);
109.1849 -        return EventFailure;
109.1850 -    }
109.1851 -
109.1852 -    source_win = event_data[0];
109.1853 -
109.1854 -    /* Ignore XDnD messages from all other windows. */
109.1855 -    if (source_window != source_win) {
109.1856 -        DTRACE_PRINTLN4("%s:%d XdndDrop rejected - invalid source window cur=%ld this=%ld.",
109.1857 -                        __FILE__, __LINE__, source_window, source_win);
109.1858 -        return EventFailure;
109.1859 -    }
109.1860 -
109.1861 -    if (!JNU_IsNull(env, target_component)) {
109.1862 -        dt_postDropTargetEvent(env, target_component, source_x, source_y, user_action,
109.1863 -                               java_awt_event_MouseEvent_MOUSE_RELEASED, event);
109.1864 -    }
109.1865 -
109.1866 -    return EventSuccess;
109.1867 -}
109.1868 -
109.1869 -/*
109.1870 - * Returns EventPassAlong if the event should be passed to the original proxy.
109.1871 - * TOP_LEVEL_ENTER should be passed to the original proxy only if the event is
109.1872 - * invalid.
109.1873 - */
109.1874 -static EventStatus
109.1875 -handle_motif_top_level_enter(XClientMessageEvent* event) {
109.1876 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
109.1877 -    Display* dpy = event->display;
109.1878 -    char* event_data = event->data.b;
109.1879 -    unsigned char event_byte_order = 0;
109.1880 -    Window source_win = None;
109.1881 -    long source_win_mask = 0;
109.1882 -    unsigned int protocol_version = MOTIF_DND_PROTOCOL_VERSION;
109.1883 -    Atom property_atom = None;
109.1884 -    unsigned int data_types_count = 0;
109.1885 -    Atom* data_types = NULL;
109.1886 -    jlongArray java_data_types = NULL;
109.1887 -
109.1888 -    DTRACE_PRINTLN5("%s:%d TOP_LEVEL_ENTER comp=%X src_win=%ld protocol=%d.",
109.1889 -                    __FILE__, __LINE__,
109.1890 -                    target_component, source_window, source_protocol);
109.1891 -
109.1892 -    if (!JNU_IsNull(env, target_component) || source_window != None ||
109.1893 -        source_protocol != NO_PROTOCOL) {
109.1894 -        DTRACE_PRINTLN2("%s:%d TOP_LEVEL_ENTER rejected - invalid state.",
109.1895 -                        __FILE__, __LINE__);
109.1896 -        return EventFailure;
109.1897 -    }
109.1898 -
109.1899 -    if (JNU_IsNull(env, get_component_for_window(event->window)) &&
109.1900 -        !is_embedding_toplevel(event->window)) {
109.1901 -        DTRACE_PRINTLN2("%s:%d TOP_LEVEL_ENTER rejected - window is not a registered drop site.",
109.1902 -                        __FILE__, __LINE__);
109.1903 -        return EventFailure;
109.1904 -    }
109.1905 -
109.1906 -    event_byte_order = read_card8(event_data, 1);
109.1907 -    source_win = read_card32(event_data, 8, event_byte_order);
109.1908 -    property_atom = read_card32(event_data, 12, event_byte_order);
109.1909 -
109.1910 -    /* Extract the available data types. */
109.1911 -    {
109.1912 -        unsigned char  ret;
109.1913 -        Atom           type;
109.1914 -        int            format;
109.1915 -        unsigned long  nitems;
109.1916 -        unsigned long  after;
109.1917 -        unsigned char  *data;
109.1918 -
109.1919 -        data = NULL;
109.1920 -        ret = checked_XGetWindowProperty(dpy, source_win, property_atom, 0,
109.1921 -                                         0xFFFF, False,
109.1922 -                                         _XA_MOTIF_DRAG_INITIATOR_INFO, &type,
109.1923 -                                         &format, &nitems, &after, &data);
109.1924 -
109.1925 -        /* Ignore the source if the window is destroyed. */
109.1926 -        if (ret == BadWindow) {
109.1927 -            DTRACE_PRINTLN2("%s:%d TOP_LEVEL_ENTER rejected - invalid window.",
109.1928 -                            __FILE__, __LINE__);
109.1929 -            return EventFailure;
109.1930 -        }
109.1931 -
109.1932 -        if (ret == BadAtom) {
109.1933 -            DTRACE_PRINTLN2("%s:%d TOP_LEVEL_ENTER rejected - invalid property atom.",
109.1934 -                            __FILE__, __LINE__);
109.1935 -            return EventFailure;
109.1936 -        }
109.1937 -
109.1938 -        if (ret == Success) {
109.1939 -            if (type == _XA_MOTIF_DRAG_INITIATOR_INFO && format == 8 &&
109.1940 -                nitems == MOTIF_INITIATOR_INFO_SIZE) {
109.1941 -                unsigned char property_byte_order = read_card8((char*)data, 0);
109.1942 -                int index = read_card16((char*)data, 2, property_byte_order);
109.1943 -
109.1944 -                protocol_version = read_card8((char*)data, 1);
109.1945 -
109.1946 -                if (protocol_version > MOTIF_DND_PROTOCOL_VERSION) {
109.1947 -                    DTRACE_PRINTLN3("%s:%d TOP_LEVEL_ENTER rejected - invalid protocol version: %d.",
109.1948 -                                    __FILE__, __LINE__, protocol_version);
109.1949 -                    XFree(data);
109.1950 -                    return EventFailure;
109.1951 -                }
109.1952 -
109.1953 -                get_target_list_for_index(dpy, index, &data_types, &data_types_count);
109.1954 -            }
109.1955 -
109.1956 -            XFree(data);
109.1957 -        }
109.1958 -    }
109.1959 -
109.1960 -    java_data_types = get_data_types_array(env, data_types, data_types_count);
109.1961 -
109.1962 -    if (JNU_IsNull(env, java_data_types)) {
109.1963 -        DTRACE_PRINTLN2("%s:%d TOP_LEVEL_ENTER rejected - cannot create types array.",
109.1964 -                        __FILE__, __LINE__);
109.1965 -        free((char*)data_types);
109.1966 -        return EventFailure;
109.1967 -    }
109.1968 -
109.1969 -    /*
109.1970 -     * Select for StructureNotifyMask to receive DestroyNotify in case of source
109.1971 -     * crash.
109.1972 -     */
109.1973 -    {
109.1974 -        unsigned char ret;
109.1975 -        XWindowAttributes xwa;
109.1976 -
109.1977 -        XGetWindowAttributes(dpy, source_win, &xwa);
109.1978 -
109.1979 -        source_win_mask = xwa.your_event_mask;
109.1980 -
109.1981 -        ret = checked_XSelectInput(dpy, source_win,
109.1982 -                                   (source_win_mask | StructureNotifyMask));
109.1983 -
109.1984 -        if (ret == BadWindow) {
109.1985 -            DTRACE_PRINTLN2("%s:%d XdndEnter rejected - invalid window.",
109.1986 -                            __FILE__, __LINE__);
109.1987 -            free((char*)data_types);
109.1988 -            (*env)->DeleteGlobalRef(env, java_data_types);
109.1989 -            return EventFailure;
109.1990 -        }
109.1991 -    }
109.1992 -
109.1993 -    source_protocol = MOTIF_DND_PROTOCOL;
109.1994 -    source_protocol_version = protocol_version;
109.1995 -    source_window = source_win;
109.1996 -    source_atom = property_atom;
109.1997 -    source_window_mask = source_win_mask;
109.1998 -    /*
109.1999 -     * TOP_LEVEL_ENTER doesn't communicate the list of supported actions
109.2000 -     * They are provided in DRAG_MOTION.
109.2001 -     */
109.2002 -    source_actions = java_awt_dnd_DnDConstants_ACTION_NONE;
109.2003 -    track_source_actions = False;
109.2004 -    source_data_types = java_data_types;
109.2005 -    source_data_types_native = data_types;
109.2006 -    source_data_types_count = data_types_count;
109.2007 -    DTRACE_PRINTLN6("%s:%d TOP_LEVEL_ENTER comp=%d src_win=%ld protocol=%d fmt=%d.",
109.2008 -                    __FILE__, __LINE__,
109.2009 -                    target_component, source_window, source_protocol, data_types_count);
109.2010 -
109.2011 -    return EventSuccess;
109.2012 -}
109.2013 -
109.2014 -/*
109.2015 - * Returns EventPassAlong if the event should be passed to the original proxy.
109.2016 - * DRAG_MOTION event shouldn't be passed to the original proxy only if it is
109.2017 - * a valid event and the mouse coordinates passed in it specify the point over
109.2018 - * a Java component in this JVM.
109.2019 - */
109.2020 -static EventStatus
109.2021 -handle_motif_drag_motion(XClientMessageEvent* event) {
109.2022 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
109.2023 -    char* event_data = event->data.b;
109.2024 -    unsigned char event_reason = 0;
109.2025 -    unsigned char event_byte_order = 0;
109.2026 -    Window source_win = None;
109.2027 -    CARD16 flags = 0;
109.2028 -    unsigned char motif_action = 0;
109.2029 -    unsigned char motif_actions = 0;
109.2030 -    jint java_action = java_awt_dnd_DnDConstants_ACTION_NONE;
109.2031 -    jint java_actions = java_awt_dnd_DnDConstants_ACTION_NONE;
109.2032 -    int x = 0;
109.2033 -    int y = 0;
109.2034 -    jint java_event_id = 0;
109.2035 -    jobject component = NULL;
109.2036 -
109.2037 -    DTRACE_PRINTLN5("%s:%d DRAG_MOTION comp=%X src_win=%ld protocol=%d.",
109.2038 -                    __FILE__, __LINE__,
109.2039 -                    target_component, source_window, source_protocol);
109.2040 -
109.2041 -    if (source_protocol != MOTIF_DND_PROTOCOL) {
109.2042 -        DTRACE_PRINTLN2("%s:%d DRAG_MOTION rejected - invalid state.",
109.2043 -                        __FILE__, __LINE__);
109.2044 -        return EventFailure;
109.2045 -    }
109.2046 -
109.2047 -    event_reason = read_card8(event_data, 0) & MOTIF_MESSAGE_REASON_MASK;
109.2048 -    event_byte_order = read_card8(event_data, 1);
109.2049 -
109.2050 -    flags = read_card16(event_data, 2, event_byte_order);
109.2051 -
109.2052 -    motif_action = (flags & MOTIF_DND_ACTION_MASK) >> MOTIF_DND_ACTION_SHIFT;
109.2053 -    motif_actions = (flags & MOTIF_DND_ACTIONS_MASK) >> MOTIF_DND_ACTIONS_SHIFT;
109.2054 -
109.2055 -    java_action = motif_to_java_actions(motif_action);
109.2056 -    java_actions = motif_to_java_actions(motif_actions);
109.2057 -
109.2058 -    /* Append source window id to the event data, so that we can send the
109.2059 -       response properly. */
109.2060 -    {
109.2061 -        Window win = source_window;
109.2062 -        void* p = &event->data.b[12];
109.2063 -        if (event_byte_order != MOTIF_BYTE_ORDER) {
109.2064 -            SWAP4BYTES(win);
109.2065 -        }
109.2066 -        write_card32(&p, (CARD32)win);
109.2067 -    }
109.2068 -
109.2069 -    component = get_component_for_window(event->window);
109.2070 -
109.2071 -    if (event_reason == OPERATION_CHANGED) {
109.2072 -        /* OPERATION_CHANGED event doesn't provide coordinates, so we use
109.2073 -           previously stored position and component ref. */
109.2074 -        x = source_x;
109.2075 -        y = source_y;
109.2076 -
109.2077 -        if (JNU_IsNull(env, component)) {
109.2078 -            component = target_component;
109.2079 -        }
109.2080 -    } else {
109.2081 -        Window receiver = None;
109.2082 -
109.2083 -        x = read_card16(event_data, 8, event_byte_order);
109.2084 -        y = read_card16(event_data, 10, event_byte_order);
109.2085 -
109.2086 -        if (JNU_IsNull(env, component)) {
109.2087 -            /*
109.2088 -             * The window must be the embedding toplevel, since otherwise we
109.2089 -             * would reject the TOP_LEVEL_ENTER and never get to this point.
109.2090 -             */
109.2091 -            DASSERT(is_embedding_toplevel(event->window));
109.2092 -
109.2093 -            receiver = get_embedded_window(event->display, event->window, x, y);
109.2094 -
109.2095 -            if (receiver != None) {
109.2096 -                component = get_component_for_window(receiver);
109.2097 -            }
109.2098 -        } else {
109.2099 -            receiver = event->window;
109.2100 -        }
109.2101 -
109.2102 -        /* Translate mouse position from root coordinates
109.2103 -           to the target window coordinates. */
109.2104 -        if (receiver != None) {
109.2105 -            Window child = None;
109.2106 -            XTranslateCoordinates(event->display,
109.2107 -                                  get_root_for_window(receiver),
109.2108 -                                  get_outer_canvas_for_window(receiver),
109.2109 -                                  x, y, &x, &y, &child);
109.2110 -        }
109.2111 -    }
109.2112 -
109.2113 -    if (JNU_IsNull(env, component)) {
109.2114 -        if (!JNU_IsNull(env, target_component)) {
109.2115 -            /* Triggers dragExit */
109.2116 -            dt_postDropTargetEvent(env, target_component, x, y,
109.2117 -                                   java_awt_dnd_DnDConstants_ACTION_NONE,
109.2118 -                                   java_awt_event_MouseEvent_MOUSE_EXITED,
109.2119 -                                   NULL);
109.2120 -        }
109.2121 -    } else {
109.2122 -        if (JNU_IsNull(env, target_component)) {
109.2123 -            /* Triggers dragEnter */
109.2124 -            java_event_id = java_awt_event_MouseEvent_MOUSE_ENTERED;
109.2125 -        } else {
109.2126 -            /* Triggers dragOver */
109.2127 -            java_event_id = java_awt_event_MouseEvent_MOUSE_DRAGGED;
109.2128 -        }
109.2129 -
109.2130 -        dt_postDropTargetEvent(env, component, x, y, java_action, java_event_id,
109.2131 -                               event);
109.2132 -    }
109.2133 -
109.2134 -    source_actions = java_actions;
109.2135 -    track_source_actions = False;
109.2136 -    user_action = java_action;
109.2137 -    source_x = x;
109.2138 -    source_y = y;
109.2139 -    target_component = component;
109.2140 -
109.2141 -    return EventSuccess;
109.2142 -}
109.2143 -
109.2144 -/*
109.2145 - * Returns EventPassAlong if the event should be passed to the original proxy.
109.2146 - * TOP_LEVEL_LEAVE should be passed to the original proxy only if the event
109.2147 - * is invalid.
109.2148 - */
109.2149 -static EventStatus
109.2150 -handle_motif_top_level_leave(XClientMessageEvent* event) {
109.2151 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
109.2152 -    char* event_data = event->data.b;
109.2153 -    unsigned char event_byte_order = 0;
109.2154 -    Window source_win = None;
109.2155 -
109.2156 -    DTRACE_PRINTLN5("%s:%d TOP_LEVEL_LEAVE comp=%X src_win=%ld protocol=%d.",
109.2157 -                    __FILE__, __LINE__,
109.2158 -                    target_component, source_window, source_protocol);
109.2159 -
109.2160 -    if (source_protocol != MOTIF_DND_PROTOCOL) {
109.2161 -        DTRACE_PRINTLN2("%s:%d TOP_LEVEL_LEAVE rejected - invalid state.",
109.2162 -                        __FILE__, __LINE__);
109.2163 -        return EventFailure;
109.2164 -    }
109.2165 -
109.2166 -    event_byte_order = read_card8(event_data, 1);
109.2167 -    source_win = read_card32(event_data, 8, event_byte_order);
109.2168 -
109.2169 -    /* Ignore Motif DnD messages from all other windows. */
109.2170 -    if (source_window != source_win) {
109.2171 -        DTRACE_PRINTLN4("%s:%d TOP_LEVEL_LEAVE rejected - invalid source window cur=%ld this=%ld.",
109.2172 -                        __FILE__, __LINE__, source_window, source_win);
109.2173 -        return EventFailure;
109.2174 -    }
109.2175 -
109.2176 -    /*
109.2177 -     * Postpone upcall to java, so that we can abort it in case
109.2178 -     * if drop immediatelly follows (see BugTraq ID 4395290).
109.2179 -     * Send a dummy ClientMessage event to guarantee that a postponed java
109.2180 -     * upcall will be processed.
109.2181 -     */
109.2182 -    motif_top_level_leave_postponed = True;
109.2183 -    {
109.2184 -        XClientMessageEvent dummy;
109.2185 -        Window proxy;
109.2186 -
109.2187 -        dummy.display      = event->display;
109.2188 -        dummy.type         = ClientMessage;
109.2189 -        dummy.window       = event->window;
109.2190 -        dummy.format       = 32;
109.2191 -        dummy.message_type = None;
109.2192 -
109.2193 -        /*
109.2194 -         * If this is an embedded drop site, the event should go to the
109.2195 -         * awt_root_window as this is a proxy for all embedded drop sites.
109.2196 -         * Otherwise the event should go to the event->window, as we don't use
109.2197 -         * proxies for normal drop sites.
109.2198 -         */
109.2199 -        if (is_embedding_toplevel(event->window)) {
109.2200 -            proxy = get_awt_root_window();
109.2201 -        } else {
109.2202 -            proxy = event->window;
109.2203 -        }
109.2204 -
109.2205 -        XSendEvent(event->display, proxy, False, NoEventMask,
109.2206 -                   (XEvent*)&dummy);
109.2207 -    }
109.2208 -
109.2209 -    return EventSuccess;
109.2210 -}
109.2211 -
109.2212 -/*
109.2213 - * Returns EventPassAlong if the event should be passed to the original proxy.
109.2214 - * DROP_START event shouldn't be passed to the original proxy only if it is
109.2215 - * a valid event and the mouse coordinates passed in it specify the point over
109.2216 - * a Java component in this JVM.
109.2217 - */
109.2218 -static EventStatus
109.2219 -handle_motif_drop_start(XClientMessageEvent* event) {
109.2220 -    JNIEnv *env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_4);
109.2221 -    char* event_data = event->data.b;
109.2222 -    unsigned char event_byte_order = 0;
109.2223 -    Window source_win = None;
109.2224 -    Atom property_atom = None;
109.2225 -    CARD16 flags = 0;
109.2226 -    unsigned char motif_action = 0;
109.2227 -    unsigned char motif_actions = 0;
109.2228 -    jint java_action = java_awt_dnd_DnDConstants_ACTION_NONE;
109.2229 -    jint java_actions = java_awt_dnd_DnDConstants_ACTION_NONE;
109.2230 -    int x = 0;
109.2231 -    int y = 0;
109.2232 -    jobject component = NULL;
109.2233 -    Window receiver = None;
109.2234 -
109.2235 -    DTRACE_PRINTLN5("%s:%d DROP_START comp=%X src_win=%ld protocol=%d.",
109.2236 -                    __FILE__, __LINE__,
109.2237 -                    target_component, source_window, source_protocol);
109.2238 -
109.2239 -    if (source_protocol != MOTIF_DND_PROTOCOL) {
109.2240 -        DTRACE_PRINTLN2("%s:%d DROP_START rejected - invalid state.",
109.2241 -                        __FILE__, __LINE__);
109.2242 -        return EventFailure;
109.2243 -    }
109.2244 -
109.2245 -    event_byte_order = read_card8(event_data, 1);
109.2246 -    source_win = read_card32(event_data, 16, event_byte_order);
109.2247 -
109.2248 -    /* Ignore Motif DnD messages from all other windows. */
109.2249 -    if (source_window != source_win) {
109.2250 -        DTRACE_PRINTLN4("%s:%d DROP_START rejected - invalid source window cur=%ld this=%ld.",
109.2251 -                        __FILE__, __LINE__, source_window, source_win);
109.2252 -        return EventFailure;
109.2253 -    }
109.2254 -
109.2255 -    property_atom = read_card32(event_data, 12, event_byte_order);
109.2256 -
109.2257 -    flags = read_card16(event_data, 2, event_byte_order);
109.2258 -
109.2259 -    motif_action = (flags & MOTIF_DND_ACTION_MASK) >> MOTIF_DND_ACTION_SHIFT;
109.2260 -    motif_actions = (flags & MOTIF_DND_ACTIONS_MASK) >> MOTIF_DND_ACTIONS_SHIFT;
109.2261 -
109.2262 -    java_action = motif_to_java_actions(motif_action);
109.2263 -    java_actions = motif_to_java_actions(motif_actions);
109.2264 -
109.2265 -    x = read_card16(event_data, 8, event_byte_order);
109.2266 -    y = read_card16(event_data, 10, event_byte_order);
109.2267 -
109.2268 -    source_actions = java_actions;
109.2269 -
109.2270 -    component = get_component_for_window(event->window);
109.2271 -
109.2272 -    if (JNU_IsNull(env, component)) {
109.2273 -        /*
109.2274 -         * The window must be the embedding toplevel, since otherwise we would reject the
109.2275 -         * TOP_LEVEL_ENTER and never get to this point.
109.2276 -         */
109.2277 -        DASSERT(is_embedding_toplevel(event->window));
109.2278 -
109.2279 -        receiver = get_embedded_window(event->display, event->window, x, y);
109.2280 -
109.2281 -        if (receiver != None) {
109.2282 -            component = get_component_for_window(receiver);
109.2283 -        }
109.2284 -    } else {
109.2285 -        receiver = event->window;
109.2286 -    }
109.2287 -
109.2288 -    /* Translate mouse position from root coordinates
109.2289 -       to the target window coordinates. */
109.2290 -    if (receiver != None) {
109.2291 -        Window child = None;
109.2292 -        XTranslateCoordinates(event->display,
109.2293 -                              get_root_for_window(receiver),
109.2294 -                              get_outer_canvas_for_window(receiver),
109.2295 -                              x, y, &x, &y, &child);
109.2296 -    }
109.2297 -
109.2298 -    if (JNU_IsNull(env, component)) {
109.2299 -        if (!JNU_IsNull(env, target_component)) {
109.2300 -            /* Triggers dragExit */
109.2301 -            dt_postDropTargetEvent(env, target_component, x, y,
109.2302 -                                   java_awt_dnd_DnDConstants_ACTION_NONE,
109.2303 -                                   java_awt_event_MouseEvent_MOUSE_EXITED,
109.2304 -                                   NULL);
109.2305 -        }
109.2306 -    } else {
109.2307 -        dt_postDropTargetEvent(env, component, x, y, java_action,
109.2308 -                               java_awt_event_MouseEvent_MOUSE_RELEASED,
109.2309 -                               event);
109.2310 -    }
109.2311 -
109.2312 -    return EventSuccess;
109.2313 -}
109.2314 -
109.2315 -static void
109.2316 -send_enter_message_to_toplevel(Window toplevel, XClientMessageEvent* xclient) {
109.2317 -    XClientMessageEvent enter;
109.2318 -
109.2319 -    if (source_protocol == XDND_PROTOCOL) {
109.2320 -        enter.display = xclient->display;
109.2321 -        enter.type = ClientMessage;
109.2322 -        enter.window = toplevel;
109.2323 -        enter.format = 32;
109.2324 -        enter.message_type = XA_XdndEnter;
109.2325 -        enter.data.l[0] = xclient->data.l[0]; /* XID of the source window */
109.2326 -        enter.data.l[1] = source_protocol_version << XDND_PROTOCOL_SHIFT;
109.2327 -        enter.data.l[1] |= source_data_types_count > 3 ? XDND_DATA_TYPES_BIT : 0;
109.2328 -        enter.data.l[2] =
109.2329 -            source_data_types_count > 0 ? source_data_types_native[0] : None;
109.2330 -        enter.data.l[3] =
109.2331 -            source_data_types_count > 1 ? source_data_types_native[1] : None;
109.2332 -        enter.data.l[4] =
109.2333 -            source_data_types_count > 2 ? source_data_types_native[2] : None;
109.2334 -    } else if (source_protocol == MOTIF_DND_PROTOCOL) {
109.2335 -        int reason = (int)(xclient->data.b[0] & MOTIF_MESSAGE_REASON_MASK);
109.2336 -        unsigned char byte_order = xclient->data.b[1];
109.2337 -
109.2338 -        enter.display = xclient->display;
109.2339 -        enter.type = ClientMessage;
109.2340 -        enter.window = toplevel;
109.2341 -        enter.format = 8;
109.2342 -        enter.message_type = _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
109.2343 -
109.2344 -        {
109.2345 -            void* p = &enter.data.b[0];
109.2346 -            int flags = 0;
109.2347 -
109.2348 -            flags |= java_to_motif_actions(user_action) << MOTIF_DND_ACTION_SHIFT;
109.2349 -            flags |= java_to_motif_actions(source_actions) << MOTIF_DND_ACTIONS_SHIFT;
109.2350 -
109.2351 -            write_card8(&p, TOP_LEVEL_ENTER | MOTIF_MESSAGE_FROM_INITIATOR);
109.2352 -            write_card8(&p, byte_order);
109.2353 -            write_card16(&p, flags);
109.2354 -            {
109.2355 -                Time time_stamp = read_card32(xclient->data.b, 4, byte_order);
109.2356 -                Window src_window = source_window;
109.2357 -                Atom motif_atom = _XA_MOTIF_ATOM_0;
109.2358 -
109.2359 -                if (byte_order != MOTIF_BYTE_ORDER) {
109.2360 -                    SWAP4BYTES(time_stamp);
109.2361 -                    SWAP4BYTES(src_window);
109.2362 -                    SWAP4BYTES(motif_atom);
109.2363 -                }
109.2364 -                write_card32(&p, time_stamp);
109.2365 -                write_card32(&p, src_window);
109.2366 -                write_card32(&p, motif_atom);
109.2367 -            }
109.2368 -        }
109.2369 -    } else {
109.2370 -        return;
109.2371 -    }
109.2372 -
109.2373 -    forward_client_message_to_toplevel(toplevel, &enter);
109.2374 -}
109.2375 -
109.2376 -static void
109.2377 -send_leave_message_to_toplevel(Window toplevel, XClientMessageEvent* xclient) {
109.2378 -    XClientMessageEvent leave;
109.2379 -
109.2380 -    if (source_protocol == XDND_PROTOCOL) {
109.2381 -        leave.display = xclient->display;
109.2382 -        leave.type = ClientMessage;
109.2383 -        leave.window = toplevel;
109.2384 -        leave.format = 32;
109.2385 -        leave.message_type = XA_XdndLeave;
109.2386 -        leave.data.l[0] = xclient->data.l[0]; /* XID of the source window */
109.2387 -        leave.data.l[1] = 0; /* flags */
109.2388 -    } else if (source_protocol == MOTIF_DND_PROTOCOL) {
109.2389 -        int reason = (int)(xclient->data.b[0] & MOTIF_MESSAGE_REASON_MASK);
109.2390 -        unsigned char byte_order = xclient->data.b[1];
109.2391 -
109.2392 -        leave.display = xclient->display;
109.2393 -        leave.type = ClientMessage;
109.2394 -        leave.window = toplevel;
109.2395 -        leave.format = 8;
109.2396 -        leave.message_type = _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
109.2397 -
109.2398 -        {
109.2399 -            void* p = &leave.data.b[0];
109.2400 -            int flags = 0;
109.2401 -
109.2402 -            write_card8(&p, TOP_LEVEL_LEAVE | MOTIF_MESSAGE_FROM_INITIATOR);
109.2403 -            write_card8(&p, byte_order);
109.2404 -
109.2405 -            {
109.2406 -                Time time_stamp = read_card32(xclient->data.b, 4, byte_order);
109.2407 -                Window src_window = source_window;
109.2408 -
109.2409 -                if (byte_order != MOTIF_BYTE_ORDER) {
109.2410 -                    SWAP4BYTES(time_stamp);
109.2411 -                    SWAP4BYTES(src_window);
109.2412 -                }
109.2413 -                write_card32(&p, time_stamp);
109.2414 -                write_card32(&p, src_window);
109.2415 -            }
109.2416 -        }
109.2417 -    } else {
109.2418 -        return;
109.2419 -    }
109.2420 -
109.2421 -    forward_client_message_to_toplevel(toplevel, &leave);
109.2422 -}
109.2423 -
109.2424 -static void
109.2425 -post_process_client_message(XClientMessageEvent* xclient, EventStatus status,
109.2426 -                            EventType type) {
109.2427 -    Window win = xclient->window;
109.2428 -    Boolean postponed_leave = motif_top_level_leave_postponed;
109.2429 -
109.2430 -    motif_top_level_leave_postponed = False;
109.2431 -
109.2432 -    if (is_embedding_toplevel(win)) {
109.2433 -        Boolean server_grabbed = False;
109.2434 -
109.2435 -        if (postponed_leave) {
109.2436 -            XClientMessageEvent* leave = &motif_top_level_leave_postponed_event;
109.2437 -            DASSERT(leave->type == ClientMessage && type == DropEvent);
109.2438 -            /* Grab the server to ensure that no event is sent between
109.2439 -               the TOP_LEVEL_LEAVE and the next message. */
109.2440 -            XGrabServer(awt_display);
109.2441 -            forward_client_message_to_toplevel(leave->window, leave);
109.2442 -            memset(&motif_top_level_leave_postponed_event, 0,
109.2443 -                   sizeof(XClientMessageEvent));
109.2444 -        }
109.2445 -
109.2446 -        /*
109.2447 -         * This code forwards drag notifications to the browser according to the
109.2448 -         * following rules:
109.2449 -         *  - the messages that we failed to process are always forwarded to the
109.2450 -         *    browser;
109.2451 -         *  - MotionEvents and DropEvents are forwarded if and only if the drag
109.2452 -         *    is not over a plugin window;
109.2453 -         *  - XDnD: EnterEvents and LeaveEvents are never forwarded, instead, we
109.2454 -         *    send synthesized EnterEvents or LeaveEvents when the drag
109.2455 -         *    respectively exits or enters plugin windows;
109.2456 -         *  - Motif DnD: EnterEvents and LeaveEvents are always forwarded.
109.2457 -         * Synthetic EnterEvents and LeaveEvents are needed, because the XDnD drop
109.2458 -         * site implemented Netscape 6.2 has a nice feature: when it receives
109.2459 -         * the first XdndPosition it continuously sends XdndStatus messages to
109.2460 -         * the source (every 100ms) until the drag terminates or leaves the drop
109.2461 -         * site. When the mouse is dragged over plugin window embedded in the
109.2462 -         * browser frame, these XdndStatus messages are mixed with the XdndStatus
109.2463 -         * messages sent from the plugin.
109.2464 -         * For Motif DnD, synthetic events cause Motif warnings being displayed,
109.2465 -         * so these events are always forwarded. However, Motif DnD drop site in
109.2466 -         * Netscape 6.2 is implemented in the same way, so there could be similar
109.2467 -         * problems if the drag source choose Motif DnD for communication.
109.2468 -         */
109.2469 -        switch (status) {
109.2470 -        case EventFailure:
109.2471 -            forward_client_message_to_toplevel(win, xclient);
109.2472 -            break;
109.2473 -        case EventSuccess:
109.2474 -        {
109.2475 -            /* True iff the previous notification was MotionEvent and it was
109.2476 -               forwarded to the browser. */
109.2477 -            static Boolean motion_passed_along = False;
109.2478 -
109.2479 -            Boolean motif_protocol =
109.2480 -                xclient->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
109.2481 -
109.2482 -            switch (type) {
109.2483 -            case MotionEvent:
109.2484 -                if (JNU_IsNull(env, target_component)) {
109.2485 -                    if (!motion_passed_along && !motif_protocol) {
109.2486 -                        send_enter_message_to_toplevel(win, xclient);
109.2487 -                    }
109.2488 -                    forward_client_message_to_toplevel(win, xclient);
109.2489 -                    motion_passed_along = True;
109.2490 -                } else {
109.2491 -                    if (motion_passed_along && !motif_protocol) {
109.2492 -                        send_leave_message_to_toplevel(win, xclient);
109.2493 -                    }
109.2494 -                    motion_passed_along = False;
109.2495 -                }
109.2496 -                break;
109.2497 -            case DropEvent:
109.2498 -                if (JNU_IsNull(env, target_component)) {
109.2499 -                    forward_client_message_to_toplevel(win, xclient);
109.2500 -                    /* The last chance to cleanup. */
109.2501 -                    awt_dnd_cleanup();
109.2502 -                }
109.2503 -                motion_passed_along = False;
109.2504 -                break;
109.2505 -            case EnterEvent:
109.2506 -            case LeaveEvent:
109.2507 -                if (motif_protocol) {
109.2508 -                    forward_client_message_to_toplevel(win, xclient);
109.2509 -                }
109.2510 -                motion_passed_along = False;
109.2511 -                break;
109.2512 -            }
109.2513 -        }
109.2514 -        }
109.2515 -
109.2516 -        if (postponed_leave) {
109.2517 -            XUngrabServer(awt_display);
109.2518 -        }
109.2519 -    }
109.2520 -}
109.2521 -
109.2522 -/*
109.2523 - * Returns True if the event is processed and shouldn't be passed along to Java.
109.2524 - * Otherwise, return False.
109.2525 - */
109.2526 -Boolean
109.2527 -awt_dnd_dt_process_event(XEvent* event) {
109.2528 -    Display* dpy = event->xany.display;
109.2529 -    EventStatus status = EventFailure;
109.2530 -    EventType type = UnknownEvent;
109.2531 -
109.2532 -    if (event->type == DestroyNotify) {
109.2533 -        if (event->xany.window == source_window) {
109.2534 -            awt_dnd_cleanup();
109.2535 -        }
109.2536 -        /* pass along */
109.2537 -        return False;
109.2538 -    }
109.2539 -
109.2540 -    if (event->type == PropertyNotify) {
109.2541 -        if (is_embedding_toplevel(event->xany.window)) {
109.2542 -            Atom atom = event->xproperty.atom;
109.2543 -            /*
109.2544 -             * If some other client replaced the XDnD or Motif DnD proxy with
109.2545 -             * another window we set the proxy back to the awt_root_window
109.2546 -             * and update the entry in the embedded_drop_site_list.
109.2547 -             * This code is needed, as for example Netscape 4.7 resets the proxy
109.2548 -             * when the browser shell is resized.
109.2549 -             */
109.2550 -            if (atom == _XA_MOTIF_DRAG_RECEIVER_INFO) {
109.2551 -                Window prev_motif_proxy;
109.2552 -                ProxyRegistrationStatus status;
109.2553 -                status = set_motif_proxy(event->xany.display, event->xany.window,
109.2554 -                                         get_awt_root_window(), &prev_motif_proxy);
109.2555 -                if (status != RegFailure && status != RegAlreadyRegistered) {
109.2556 -                    set_motif_proxy_for_toplevel(event->xany.window,
109.2557 -                                                 prev_motif_proxy,
109.2558 -                                                 status == RegOverride);
109.2559 -                }
109.2560 -            }
109.2561 -
109.2562 -            if (atom == XA_XdndAware || atom == XA_XdndProxy) {
109.2563 -                Window prev_xdnd_proxy;
109.2564 -                unsigned int prev_protocol_version;
109.2565 -                ProxyRegistrationStatus status;
109.2566 -                status = set_xdnd_proxy(event->xany.display, event->xany.window,
109.2567 -                                        get_awt_root_window(), &prev_xdnd_proxy,
109.2568 -                                        &prev_protocol_version);
109.2569 -                if (status != RegFailure && status != RegAlreadyRegistered) {
109.2570 -                    set_xdnd_proxy_for_toplevel(event->xany.window,
109.2571 -                                                prev_xdnd_proxy,
109.2572 -                                                prev_protocol_version,
109.2573 -                                                status == RegOverride);
109.2574 -                }
109.2575 -            }
109.2576 -        }
109.2577 -        /* pass along */
109.2578 -        return False;
109.2579 -    }
109.2580 -
109.2581 -    if (event->type != ClientMessage) {
109.2582 -        return False;
109.2583 -    }
109.2584 -
109.2585 -    if (get_component_for_window(event->xany.window) == NULL &&
109.2586 -        !is_embedding_toplevel(event->xany.window)) {
109.2587 -        return False;
109.2588 -    }
109.2589 -
109.2590 -    if (motif_top_level_leave_postponed) {
109.2591 -        /* Sanity check. */
109.2592 -        if (source_protocol != MOTIF_DND_PROTOCOL) {
109.2593 -            DTRACE_PRINTLN2("%s:%d TOP_LEVEL_LEAVE rejected - invalid state.",
109.2594 -                            __FILE__, __LINE__);
109.2595 -            awt_dnd_cleanup();
109.2596 -        } else if (event->xclient.message_type ==
109.2597 -                   _XA_MOTIF_DRAG_AND_DROP_MESSAGE) {
109.2598 -            unsigned char first_byte = event->xclient.data.b[0];
109.2599 -            unsigned char reason = first_byte & MOTIF_MESSAGE_REASON_MASK;
109.2600 -            unsigned char origin = first_byte & MOTIF_MESSAGE_SENDER_MASK;
109.2601 -
109.2602 -            if (origin == MOTIF_MESSAGE_FROM_INITIATOR &&
109.2603 -                reason != DROP_START) {
109.2604 -                awt_dnd_cleanup();
109.2605 -            }
109.2606 -        } else {
109.2607 -            awt_dnd_cleanup();
109.2608 -        }
109.2609 -    }
109.2610 -
109.2611 -    if (event->xclient.message_type == XA_XdndEnter) {
109.2612 -        status = handle_xdnd_enter(&event->xclient);
109.2613 -        type = EnterEvent;
109.2614 -    } else if (event->xclient.message_type == XA_XdndPosition) {
109.2615 -        status = handle_xdnd_position(&event->xclient);
109.2616 -        type = MotionEvent;
109.2617 -    } else if (event->xclient.message_type == XA_XdndLeave) {
109.2618 -        status = handle_xdnd_leave(&event->xclient);
109.2619 -        type = LeaveEvent;
109.2620 -    } else if (event->xclient.message_type == XA_XdndDrop) {
109.2621 -        status = handle_xdnd_drop(&event->xclient);
109.2622 -        type = DropEvent;
109.2623 -    } else if (event->xclient.message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) {
109.2624 -        unsigned char reason = event->xclient.data.b[0] & MOTIF_MESSAGE_REASON_MASK;
109.2625 -        unsigned char origin = event->xclient.data.b[0] & MOTIF_MESSAGE_SENDER_MASK;
109.2626 -
109.2627 -        /* Only initiator messages should be handled. */
109.2628 -        if (origin == MOTIF_MESSAGE_FROM_INITIATOR) {
109.2629 -            switch (reason) {
109.2630 -            case DRAG_MOTION:
109.2631 -            case OPERATION_CHANGED:
109.2632 -                status = handle_motif_drag_motion(&event->xclient);
109.2633 -                type = MotionEvent;
109.2634 -                break;
109.2635 -            case TOP_LEVEL_ENTER:
109.2636 -                status = handle_motif_top_level_enter(&event->xclient);
109.2637 -                type = EnterEvent;
109.2638 -                break;
109.2639 -            case TOP_LEVEL_LEAVE:
109.2640 -                status = handle_motif_top_level_leave(&event->xclient);
109.2641 -                type = LeaveEvent;
109.2642 -                break;
109.2643 -            case DROP_START:
109.2644 -                status = handle_motif_drop_start(&event->xclient);
109.2645 -                type = DropEvent;
109.2646 -                break;
109.2647 -            }
109.2648 -        }
109.2649 -    } else {
109.2650 -        /* Unknown message type. */
109.2651 -        return False;
109.2652 -    }
109.2653 -
109.2654 -    /*
109.2655 -     * We need to handle a special case here: Motif DnD protocol prescribed that
109.2656 -     * DROP_START message should always be preceeded with TOP_LEVEL_LEAVE
109.2657 -     * message. We need to cleanup on TOP_LEVEL_LEAVE message, but DROP_START
109.2658 -     * wouldn't be processed properly. Instead we postpone the cleanup and
109.2659 -     * send a dummy client message to ourselves. If dummy arrives first we do a
109.2660 -     * normal cleanup. If DROP_START arrives before the dummy we discard delayed
109.2661 -     * cleanup.
109.2662 -     * In case of forwarding events from an embedded Java app to an embedding
109.2663 -     * Java app it could happen that the embedding app receives the dummy before
109.2664 -     * the DROP_START message arrives from the embedding app. In this case the
109.2665 -     * drop operation on the embedding app fails to complete.
109.2666 -     * To resolve this problem we postpone forwarding of TOP_LEVEL_LEAVE message
109.2667 -     * until the next client message is about to be forwarded.
109.2668 -     */
109.2669 -    if (motif_top_level_leave_postponed && type == LeaveEvent) {
109.2670 -        /* motif_top_level_leave_postponed can be set only if the latest client
109.2671 -           message has been processed successfully. */
109.2672 -        DASSERT(status == EventSuccess);
109.2673 -        memcpy(&motif_top_level_leave_postponed_event, &event->xclient,
109.2674 -               sizeof(XClientMessageEvent));
109.2675 -    } else {
109.2676 -        post_process_client_message(&event->xclient, status, type);
109.2677 -    }
109.2678 -
109.2679 -    return True;
109.2680 -}
109.2681 -
109.2682 -static Boolean
109.2683 -register_xdnd_drop_site(Display* dpy, Window toplevel, Window window) {
109.2684 -    unsigned char ret;
109.2685 -    Atom version_atom = XDND_PROTOCOL_VERSION;
109.2686 -
109.2687 -    ret = checked_XChangeProperty(dpy, window, XA_XdndAware, XA_ATOM, 32,
109.2688 -                                  PropModeReplace,
109.2689 -                                  (unsigned char*)&version_atom, 1);
109.2690 -
109.2691 -    return (ret == Success);
109.2692 -}
109.2693 -
109.2694 -static Boolean
109.2695 -register_motif_drop_site(Display* dpy, Window toplevel, Window window) {
109.2696 -    unsigned char status;
109.2697 -    size_t data_size = MOTIF_RECEIVER_INFO_SIZE;
109.2698 -    char* data = malloc(data_size);
109.2699 -    void* p = data;
109.2700 -
109.2701 -    if (data == NULL) {
109.2702 -        DTRACE_PRINTLN2("%s:%d malloc failed.", __FILE__, __LINE__);
109.2703 -        return False;
109.2704 -    }
109.2705 -
109.2706 -    write_card8(&p, MOTIF_BYTE_ORDER);
109.2707 -    write_card8(&p, MOTIF_DND_PROTOCOL_VERSION); /* protocol version */
109.2708 -    write_card8(&p, MOTIF_DYNAMIC_STYLE); /* protocol style */
109.2709 -    write_card8(&p, 0); /* pad */
109.2710 -    write_card32(&p, window); /* proxy window */
109.2711 -    write_card16(&p, 0); /* num_drop_sites */
109.2712 -    write_card16(&p, 0); /* pad */
109.2713 -    write_card32(&p, data_size);
109.2714 -
109.2715 -    status = checked_XChangeProperty(dpy, window, _XA_MOTIF_DRAG_RECEIVER_INFO,
109.2716 -                                     _XA_MOTIF_DRAG_RECEIVER_INFO, 8, PropModeReplace,
109.2717 -                                     (unsigned char*)data, data_size);
109.2718 -
109.2719 -    free(data);
109.2720 -
109.2721 -    return (status == Success);
109.2722 -}
109.2723 -
109.2724 -static Window
109.2725 -find_toplevel_window(Display* dpy, Window window) {
109.2726 -    Window         ret = None;
109.2727 -    Window         root = None;
109.2728 -    Window         parent = None;
109.2729 -    Window         *children;
109.2730 -    unsigned int   nchildren;
109.2731 -
109.2732 -    int            status;
109.2733 -
109.2734 -    Atom           type;
109.2735 -    int            format;
109.2736 -    unsigned long  nitems;
109.2737 -    unsigned long  after;
109.2738 -    unsigned char  *data;
109.2739 -
109.2740 -    /* Traverse the ancestor tree from window up to the root and find
109.2741 -       the top-level client window nearest to the root. */
109.2742 -    do {
109.2743 -        type = None;
109.2744 -
109.2745 -        data = NULL;
109.2746 -        status = XGetWindowProperty(dpy, window, XA_WM_STATE, 0, 0, False,
109.2747 -                                    AnyPropertyType, &type, &format, &nitems,
109.2748 -                                    &after, &data);
109.2749 -
109.2750 -        if (status == Success) {
109.2751 -            XFree(data);
109.2752 -        }
109.2753 -
109.2754 -        if (type != None) {
109.2755 -            ret = window;
109.2756 -        }
109.2757 -
109.2758 -        if (!XQueryTree(dpy, window, &root, &parent, &children, &nchildren)) {
109.2759 -            return None;
109.2760 -        }
109.2761 -
109.2762 -        XFree(children);
109.2763 -
109.2764 -        window = parent;
109.2765 -    } while (window != root);
109.2766 -
109.2767 -    return ret;
109.2768 -}
109.2769 -
109.2770 -static Boolean
109.2771 -register_drop_site(Widget outer_canvas, XtPointer componentRef) {
109.2772 -    Display* dpy = XtDisplay(outer_canvas);
109.2773 -    Widget shell = NULL;
109.2774 -    /* Shell window. */
109.2775 -    Window window = None;
109.2776 -    Window root = None;
109.2777 -    Window toplevel = None;
109.2778 -
109.2779 -    for (shell = outer_canvas; shell != NULL && !XtIsShell(shell);
109.2780 -         shell = XtParent(shell));
109.2781 -
109.2782 -    if (shell == NULL || !XtIsRealized(shell)) {
109.2783 -        DTRACE_PRINTLN2("%s:%d Cannot find a realized shell for the widget.",
109.2784 -                       __FILE__, __LINE__);
109.2785 -        return False;
109.2786 -    }
109.2787 -
109.2788 -    window = XtWindow(shell);
109.2789 -
109.2790 -    if (!awt_dnd_init(dpy)) {
109.2791 -        DTRACE_PRINTLN2("%s:%d Fail to initialize.", __FILE__, __LINE__);
109.2792 -        return False;
109.2793 -    }
109.2794 -
109.2795 -    {
109.2796 -        XWindowAttributes xwa;
109.2797 -
109.2798 -        if (!XGetWindowAttributes(dpy, window, &xwa)) {
109.2799 -            DTRACE_PRINTLN2("%s:%d XGetWindowAttributes failed.", __FILE__, __LINE__);
109.2800 -            return False;
109.2801 -        }
109.2802 -
109.2803 -        root = xwa.root;
109.2804 -
109.2805 -        if (root == None) {
109.2806 -            DTRACE_PRINTLN2("%s:%d Bad root.", __FILE__, __LINE__);
109.2807 -            return False;
109.2808 -        }
109.2809 -    }
109.2810 -
109.2811 -    toplevel = find_toplevel_window(dpy, window);
109.2812 -
109.2813 -    /*
109.2814 -     * No window with WM_STATE property is found.
109.2815 -     * Since the window can be a plugin window reparented to the browser
109.2816 -     * toplevel, we cannot determine which window will eventually have WM_STATE
109.2817 -     * property set. So we schedule a timer callback that will periodically
109.2818 -     * attempt to find an ancestor with WM_STATE and register the drop site
109.2819 -     * appropriately.
109.2820 -     */
109.2821 -    if (toplevel == None) {
109.2822 -        add_delayed_registration_entry(outer_canvas, componentRef);
109.2823 -        return False;
109.2824 -    }
109.2825 -
109.2826 -    if (toplevel == window) {
109.2827 -        Boolean xdnd_registered = False;
109.2828 -        Boolean motif_registered = False;
109.2829 -
109.2830 -        xdnd_registered = register_xdnd_drop_site(dpy, toplevel, window);
109.2831 -
109.2832 -        motif_registered = register_motif_drop_site(dpy, toplevel, window);
109.2833 -
109.2834 -        if (!xdnd_registered && !motif_registered) {
109.2835 -            DTRACE_PRINTLN2("%s:%d Failed to register.", __FILE__, __LINE__);
109.2836 -            return False;
109.2837 -        }
109.2838 -    } else {
109.2839 -        if (!add_to_embedded_drop_site_list(dpy, root, toplevel, window)) {
109.2840 -            DTRACE_PRINTLN2("%s:%d Failed to init proxy.", __FILE__, __LINE__);
109.2841 -            return False;
109.2842 -        }
109.2843 -    }
109.2844 -
109.2845 -    /* There is no need to update the window for the component later, since the
109.2846 -       window is destroyed only when the component is disposed in which case the
109.2847 -       drop site will be unregistered as well. */
109.2848 -    if (add_to_drop_site_list(window, root, toplevel, XtWindow(outer_canvas),
109.2849 -                              (jobject)componentRef)) {
109.2850 -        DTRACE_PRINTLN2("%s:%d Drop site registered.", __FILE__, __LINE__);
109.2851 -        return True;
109.2852 -    } else {
109.2853 -        DTRACE_PRINTLN2("%s:%d Failed to register.", __FILE__, __LINE__);
109.2854 -        return False;
109.2855 -    }
109.2856 -}
109.2857 -
109.2858 -static void
109.2859 -register_drop_site_when_realized(Widget outer_canvas, XtPointer client_data,
109.2860 -                                 XEvent *event, Boolean *dontSwallow) {
109.2861 -    if (XtIsRealized(outer_canvas)) {
109.2862 -        XtRemoveEventHandler(outer_canvas, StructureNotifyMask, False,
109.2863 -                             register_drop_site_when_realized, client_data);
109.2864 -
109.2865 -        register_drop_site(outer_canvas, client_data);
109.2866 -    }
109.2867 -}
109.2868 -
109.2869 -/*
109.2870 - * Registers the top-level Window that contains the specified widget as a drop
109.2871 - * site that supports XDnD and Motif DnD protocols.
109.2872 - * If the registration fails for some reason, adds an event handler that will
109.2873 - * attempt to register the drop site later.
109.2874 - *
109.2875 - * Returns True if the drop site is registered successfully.
109.2876 - */
109.2877 -static Boolean
109.2878 -awt_dnd_register_drop_site(Widget outer_canvas, XtPointer componentRef) {
109.2879 -    if (XtIsRealized(outer_canvas)) {
109.2880 -        return register_drop_site(outer_canvas, componentRef);
109.2881 -    } else {
109.2882 -        XtAddEventHandler(outer_canvas, StructureNotifyMask, False,
109.2883 -                          register_drop_site_when_realized,
109.2884 -                          componentRef);
109.2885 -
109.2886 -        DTRACE_PRINTLN2("%s:%d Unrealized shell. Register later.",
109.2887 -                        __FILE__, __LINE__);
109.2888 -
109.2889 -        return True;
109.2890 -    }
109.2891 -}
109.2892 -
109.2893 -/*
109.2894 - * Unregisters the drop site associated with the top-level Window that contains
109.2895 - * the specified widget .
109.2896 - *
109.2897 - * Returns True if completes successfully, False otherwise.
109.2898 - */
109.2899 -static Boolean
109.2900 -awt_dnd_unregister_drop_site(Widget outer_canvas, XtPointer componentRef) {
109.2901 -    Widget shell = NULL;
109.2902 -
109.2903 -    XtRemoveEventHandler(outer_canvas, StructureNotifyMask, False,
109.2904 -                         register_drop_site_when_realized, componentRef);
109.2905 -
109.2906 -    remove_delayed_registration_entry(outer_canvas);
109.2907 -
109.2908 -    for (shell = outer_canvas; shell != NULL && !XtIsShell(shell);
109.2909 -         shell = XtParent(shell));
109.2910 -
109.2911 -    if (shell != NULL && XtIsShell(shell) && XtIsRealized(shell)) {
109.2912 -        Window win = XtWindow(shell);
109.2913 -        Window toplevel = get_toplevel_for_window(win);
109.2914 -        /*
109.2915 -         * Cleanup the global state if this drop site participate in the current
109.2916 -         * drag operation. Particularly, this allows to delete global ref to the
109.2917 -         * component safely.
109.2918 -         */
109.2919 -        if (get_component_for_window(win) == target_component) {
109.2920 -            awt_dnd_cleanup();
109.2921 -        }
109.2922 -        if (toplevel != win) {
109.2923 -            remove_from_embedded_drop_site_list(awt_display, toplevel, win);
109.2924 -        }
109.2925 -        return remove_from_drop_site_list(win);
109.2926 -    }
109.2927 -
109.2928 -    return True;
109.2929 -}
109.2930 -
109.2931 -/**************************** XEmbed server DnD support ***********************/
109.2932 -
109.2933 -/*
109.2934 - *
109.2935 - *
109.2936 - */
109.2937 -Boolean
109.2938 -register_xembed_drop_site(JNIEnv* env, Display* dpy, jobject server,
109.2939 -                          Window serverHandle, Window clientHandle) {
109.2940 -    Atom           type;
109.2941 -    int            format;
109.2942 -    unsigned long  nitems;
109.2943 -    unsigned long  after;
109.2944 -    unsigned char* data;
109.2945 -    unsigned char  ret;
109.2946 -    unsigned int   protocol_version;
109.2947 -
109.2948 -    Window         xdnd_proxy = None;
109.2949 -    unsigned int   xdnd_protocol_version = 0;
109.2950 -    Boolean        xdnd_override = False;
109.2951 -
109.2952 -    if (!awt_dnd_init(dpy)) {
109.2953 -        DTRACE_PRINTLN2("%s:%d Fail to initialize.", __FILE__, __LINE__);
109.2954 -        return False;
109.2955 -    }
109.2956 -
109.2957 -    /* Get the XDnD protocol version and XDnD proxy of the XEmbed client. */
109.2958 -    data = NULL;
109.2959 -    ret = checked_XGetWindowProperty(dpy, clientHandle, XA_XdndAware, 0, 1,
109.2960 -                                     False, AnyPropertyType, &type, &format,
109.2961 -                                     &nitems, &after, &data);
109.2962 -
109.2963 -    /* XEmbed client doesn't have an associated XDnD drop site -
109.2964 -       do nothing and return True to indicate success. */
109.2965 -    if (ret != Success || data == NULL || nitems == 0 || type != XA_ATOM) {
109.2966 -        XFree(data);
109.2967 -        return False;
109.2968 -    }
109.2969 -
109.2970 -    protocol_version = *((unsigned int*)data);
109.2971 -
109.2972 -    XFree(data);
109.2973 -
109.2974 -    if (protocol_version < XDND_MIN_PROTOCOL_VERSION) {
109.2975 -        return False;
109.2976 -    }
109.2977 -
109.2978 -    xdnd_protocol_version = protocol_version;
109.2979 -
109.2980 -    /* XdndProxy is not supported prior to XDnD version 4 */
109.2981 -    if (protocol_version >= 4) {
109.2982 -        int status;
109.2983 -
109.2984 -        data = NULL;
109.2985 -        status = XGetWindowProperty(dpy, clientHandle, XA_XdndProxy, 0, 1,
109.2986 -                                    False, XA_WINDOW, &type, &format,
109.2987 -                                    &nitems, &after, &data);
109.2988 -
109.2989 -        if (status == Success && data != NULL && type == XA_WINDOW) {
109.2990 -            xdnd_proxy = *((Window*)data);
109.2991 -
109.2992 -            if (xdnd_proxy != None) {
109.2993 -                XFree(data);
109.2994 -
109.2995 -                data = NULL;
109.2996 -                status = XGetWindowProperty(dpy, xdnd_proxy, XA_XdndProxy,
109.2997 -                                            0, 1, False, XA_WINDOW, &type,
109.2998 -                                            &format, &nitems, &after,
109.2999 -                                            &data);
109.3000 -
109.3001 -                if (status != Success || data == NULL || type != XA_WINDOW ||
109.3002 -                    *((Window*)data) != xdnd_proxy) {
109.3003 -                    /* Ignore invalid proxy. */
109.3004 -                    xdnd_proxy = None;
109.3005 -                }
109.3006 -            }
109.3007 -
109.3008 -            if (xdnd_proxy != None) {
109.3009 -                XFree(data);
109.3010 -
109.3011 -                data = NULL;
109.3012 -                status = XGetWindowProperty(dpy, xdnd_proxy, XA_XdndAware, 0, 1,
109.3013 -                                            False, AnyPropertyType, &type,
109.3014 -                                            &format, &nitems, &after, &data);
109.3015 -
109.3016 -                if (status == Success && data != NULL && type == XA_ATOM) {
109.3017 -                    unsigned int proxy_version = *((unsigned int*)data);
109.3018 -
109.3019 -                    if (proxy_version != protocol_version) {
109.3020 -                        /* Ignore invalid proxy. */
109.3021 -                        xdnd_proxy = None;
109.3022 -                    }
109.3023 -                } else {
109.3024 -                    /* Ignore invalid proxy. */
109.3025 -                    xdnd_proxy = None;
109.3026 -                }
109.3027 -            }
109.3028 -        }
109.3029 -
109.3030 -        XFree(data);
109.3031 -    }
109.3032 -
109.3033 -    set_xembed_drop_target(env, server);
109.3034 -
109.3035 -    /* Add protocol specific entries for the embedded window. */
109.3036 -    /* Only XDnD protocol is supported for XEmbed clients. */
109.3037 -    {
109.3038 -        EmbeddedDropSiteProtocolListEntry* xdnd_entry = NULL;
109.3039 -
109.3040 -        xdnd_entry = malloc(sizeof(EmbeddedDropSiteProtocolListEntry));
109.3041 -
109.3042 -        if (xdnd_entry == NULL) {
109.3043 -            return False;
109.3044 -        }
109.3045 -
109.3046 -        xdnd_entry->window = clientHandle;
109.3047 -        xdnd_entry->proxy = xdnd_proxy;
109.3048 -        xdnd_entry->protocol_version = xdnd_protocol_version;
109.3049 -        xdnd_entry->overriden = True;
109.3050 -        xdnd_entry->next = embedded_xdnd_protocol_list;
109.3051 -        embedded_xdnd_protocol_list = xdnd_entry;
109.3052 -    }
109.3053 -
109.3054 -    {
109.3055 -        EmbeddedDropSiteListEntry* entry = NULL;
109.3056 -        Window* sites = NULL;
109.3057 -
109.3058 -        entry = malloc(sizeof(EmbeddedDropSiteListEntry));
109.3059 -
109.3060 -        if (entry == NULL) {
109.3061 -            return False;
109.3062 -        }
109.3063 -
109.3064 -        sites = malloc(sizeof(Window));
109.3065 -
109.3066 -        if (sites == NULL) {
109.3067 -            free(entry);
109.3068 -            return False;
109.3069 -        }
109.3070 -
109.3071 -        sites[0] = clientHandle;
109.3072 -
109.3073 -        entry->toplevel = serverHandle;
109.3074 -        entry->root = None;
109.3075 -        entry->event_mask = 0;
109.3076 -        entry->embedded_sites_count = 1;
109.3077 -        entry->embedded_sites = sites;
109.3078 -        entry->next = embedded_drop_site_list;
109.3079 -        embedded_drop_site_list = entry;
109.3080 -    }
109.3081 -
109.3082 -    return True;
109.3083 -}
109.3084 -
109.3085 -Boolean
109.3086 -unregister_xembed_drop_site(JNIEnv* env, Display* dpy, jobject server,
109.3087 -                            Window serverHandle, Window clientHandle) {
109.3088 -    remove_from_embedded_drop_site_list(dpy, serverHandle, clientHandle);
109.3089 -    return True;
109.3090 -}
109.3091 -
109.3092 -void
109.3093 -forward_event_to_embedded(Window embedded, jlong ctxt, jint eventID) {
109.3094 -    static XClientMessageEvent* prevMessage = NULL;
109.3095 -    static Boolean overXEmbedClient = False;
109.3096 -
109.3097 -    XClientMessageEvent* xclient =
109.3098 -        (XClientMessageEvent*)jlong_to_ptr(ctxt);
109.3099 -
109.3100 -    if (xclient == NULL && prevMessage == NULL) {
109.3101 -        return;
109.3102 -    }
109.3103 -
109.3104 -    if (xclient != NULL) {
109.3105 -        /*
109.3106 -         * NOTE: this check guarantees that prevMessage will always be an XDnD
109.3107 -         * drag message.
109.3108 -         */
109.3109 -        if (!is_xdnd_drag_message_type(xclient->message_type)) {
109.3110 -            return;
109.3111 -        }
109.3112 -
109.3113 -        if (!overXEmbedClient) {
109.3114 -            long* appended_data = jlong_to_ptr(ctxt) +
109.3115 -                sizeof(XClientMessageEvent);
109.3116 -
109.3117 -            /* Copy XdndTypeList from source to proxy. */
109.3118 -            if ((appended_data[0] & XDND_DATA_TYPES_BIT) != 0) {
109.3119 -                unsigned char  ret;
109.3120 -                Atom           type;
109.3121 -                int            format;
109.3122 -                unsigned long  nitems;
109.3123 -                unsigned long  after;
109.3124 -                unsigned char  *data;
109.3125 -
109.3126 -                data = NULL;
109.3127 -                ret = checked_XGetWindowProperty(xclient->display,
109.3128 -                                                 xclient->data.l[0],
109.3129 -                                                 XA_XdndTypeList, 0, 0xFFFF,
109.3130 -                                                 False, XA_ATOM, &type, &format,
109.3131 -                                                 &nitems, &after, &data);
109.3132 -
109.3133 -                /* Ignore the source if the window is destroyed. */
109.3134 -                if (ret == BadWindow) {
109.3135 -                    return;
109.3136 -                }
109.3137 -
109.3138 -                if (ret == Success) {
109.3139 -                    if (type == XA_ATOM && format == 32) {
109.3140 -                        ret = checked_XChangeProperty(xclient->display,
109.3141 -                                                      xclient->window,
109.3142 -                                                      XA_XdndTypeList, XA_ATOM,
109.3143 -                                                      32, PropModeReplace, data,
109.3144 -                                                      nitems);
109.3145 -                    }
109.3146 -
109.3147 -                    XFree(data);
109.3148 -                }
109.3149 -            }
109.3150 -
109.3151 -            set_proxy_mode_source_window(xclient->data.l[0]);
109.3152 -
109.3153 -            {
109.3154 -                XClientMessageEvent enter;
109.3155 -                enter.display = xclient->display;
109.3156 -                enter.type = ClientMessage;
109.3157 -                enter.window = embedded;
109.3158 -                enter.format = 32;
109.3159 -                enter.message_type = XA_XdndEnter;
109.3160 -
109.3161 -                enter.data.l[0] = xclient->window; /* XID of the source window */
109.3162 -                enter.data.l[1] = appended_data[0];
109.3163 -                enter.data.l[2] = appended_data[1];
109.3164 -                enter.data.l[3] = appended_data[2];
109.3165 -                enter.data.l[4] = appended_data[3];
109.3166 -
109.3167 -                forward_client_message_to_toplevel(embedded, &enter);
109.3168 -            }
109.3169 -
109.3170 -            overXEmbedClient = True;
109.3171 -        }
109.3172 -
109.3173 -        /* Make a copy of the original event, since we are going to modify the
109.3174 -           event while it still can be referenced from other Java events. */
109.3175 -        {
109.3176 -            XClientMessageEvent copy;
109.3177 -            memcpy(&copy, xclient, sizeof(XClientMessageEvent));
109.3178 -            copy.data.l[0] = xclient->window;
109.3179 -
109.3180 -            forward_client_message_to_toplevel(embedded, &copy);
109.3181 -        }
109.3182 -    }
109.3183 -
109.3184 -    if (eventID == java_awt_event_MouseEvent_MOUSE_EXITED) {
109.3185 -        if (overXEmbedClient) {
109.3186 -            if (xclient != NULL || prevMessage != NULL) {
109.3187 -                /* Last chance to send XdndLeave to the XEmbed client. */
109.3188 -                XClientMessageEvent leave;
109.3189 -
109.3190 -                leave.display = xclient != NULL ?
109.3191 -                    xclient->display : prevMessage->display;
109.3192 -                leave.type = ClientMessage;
109.3193 -                leave.window = embedded;
109.3194 -                leave.format = 32;
109.3195 -                leave.message_type = XA_XdndLeave;
109.3196 -                leave.data.l[0] = xclient != NULL ?
109.3197 -                    xclient->window : prevMessage->window; /* XID of the source window */
109.3198 -                leave.data.l[1] = 0; /* flags */
109.3199 -
109.3200 -                forward_client_message_to_toplevel(embedded, &leave);
109.3201 -            }
109.3202 -            overXEmbedClient = False;
109.3203 -        }
109.3204 -    }
109.3205 -
109.3206 -    if (eventID == java_awt_event_MouseEvent_MOUSE_RELEASED) {
109.3207 -        overXEmbedClient = False;
109.3208 -        awt_dnd_cleanup();
109.3209 -    }
109.3210 -
109.3211 -    if (prevMessage != 0) {
109.3212 -        free(prevMessage);
109.3213 -        prevMessage = 0;
109.3214 -    }
109.3215 -
109.3216 -    if (xclient != 0 && overXEmbedClient) {
109.3217 -        prevMessage = malloc(sizeof(XClientMessageEvent));
109.3218 -
109.3219 -        memcpy(prevMessage, xclient, sizeof(XClientMessageEvent));
109.3220 -    }
109.3221 -}
109.3222 -
109.3223 -/******************************************************************************/
109.3224 -
109.3225 -/*
109.3226 - * Class:     sun_awt_motif_MWindowPeer
109.3227 - * Method:    registerX11DropTarget
109.3228 - * Signature: (Ljava/awt/Component;)V
109.3229 - */
109.3230 -
109.3231 -JNIEXPORT void JNICALL
109.3232 -Java_sun_awt_motif_MWindowPeer_registerX11DropTarget(JNIEnv *env, jobject this,
109.3233 -                                                     jobject target) {
109.3234 -    struct FrameData* wdata = NULL;
109.3235 -    DropSitePtr dsi = NULL;
109.3236 -
109.3237 -    wdata = (struct FrameData *)
109.3238 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
109.3239 -
109.3240 -    if (wdata == NULL || wdata->winData.comp.widget == NULL) {
109.3241 -        JNU_ThrowNullPointerException(env, "NULL component data");
109.3242 -        return;
109.3243 -    }
109.3244 -
109.3245 -    if (wdata->winData.shell == NULL) {
109.3246 -        JNU_ThrowNullPointerException(env, "Null shell widget");
109.3247 -        return;
109.3248 -    }
109.3249 -
109.3250 -    DASSERT(wdata->winData.comp.dsi == NULL);
109.3251 -
109.3252 -    dsi = (DropSitePtr)calloc(1, sizeof(struct DropSiteInfo));
109.3253 -
109.3254 -    if (dsi == NULL) {
109.3255 -        JNU_ThrowOutOfMemoryError(env, "");
109.3256 -        return;
109.3257 -    }
109.3258 -
109.3259 -    dsi->component = (*env)->NewGlobalRef(env, target);
109.3260 -    dsi->isComposite = False;
109.3261 -
109.3262 -    wdata->winData.comp.dsi = dsi;
109.3263 -
109.3264 -    AWT_LOCK();
109.3265 -
109.3266 -    awt_dnd_register_drop_site(wdata->winData.comp.widget,
109.3267 -                               dsi->component);
109.3268 -
109.3269 -    AWT_UNLOCK();
109.3270 -}
109.3271 -
109.3272 -/*
109.3273 - * Class:     sun_awt_motif_MWindowPeer
109.3274 - * Method:    unregisterX11DropTarget
109.3275 - * Signature: (Ljava/awt/Component;)V
109.3276 - */
109.3277 -
109.3278 -JNIEXPORT void JNICALL
109.3279 -Java_sun_awt_motif_MWindowPeer_unregisterX11DropTarget(JNIEnv *env,
109.3280 -                                                       jobject this,
109.3281 -                                                       jobject target) {
109.3282 -    struct FrameData* wdata = NULL;
109.3283 -    DropSitePtr dsi = NULL;
109.3284 -
109.3285 -    wdata = (struct FrameData *)
109.3286 -        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
109.3287 -
109.3288 -    if (wdata == NULL) {
109.3289 -        JNU_ThrowNullPointerException(env, "Null component data");
109.3290 -        return;
109.3291 -    }
109.3292 -
109.3293 -    if (wdata->winData.shell == NULL) {
109.3294 -        JNU_ThrowNullPointerException(env, "Null shell widget");
109.3295 -        return;
109.3296 -    }
109.3297 -
109.3298 -    dsi = wdata->winData.comp.dsi;
109.3299 -
109.3300 -    if (dsi == NULL) {
109.3301 -        JNU_ThrowNullPointerException(env, "Null DropSiteInfo");
109.3302 -        return;
109.3303 -    }
109.3304 -
109.3305 -    AWT_LOCK();
109.3306 -
109.3307 -    awt_dnd_unregister_drop_site(wdata->winData.comp.widget, dsi->component);
109.3308 -
109.3309 -    AWT_UNLOCK();
109.3310 -
109.3311 -    wdata->winData.comp.dsi = NULL;
109.3312 -
109.3313 -    (*env)->DeleteGlobalRef(env, dsi->component);
109.3314 -
109.3315 -    free(dsi);
109.3316 -}
109.3317 -
109.3318 -static void
109.3319 -dt_send_event_to_source(XClientMessageEvent* xclient) {
109.3320 -    /* Shortcut if the source is in the same JVM. */
109.3321 -    if (xclient->window == awt_dnd_ds_get_source_window()) {
109.3322 -        awt_dnd_ds_process_event((XEvent*)xclient);
109.3323 -    } else {
109.3324 -        unsigned char ret;
109.3325 -
109.3326 -        ret = checked_XSendEvent(xclient->display, xclient->window, False,
109.3327 -                                 NoEventMask, (XEvent*)xclient);
109.3328 -
109.3329 -        if (ret == BadWindow) {
109.3330 -            DTRACE_PRINTLN2("%s:%d XSendEvent - invalid window.",
109.3331 -                            __FILE__, __LINE__);
109.3332 -
109.3333 -            /* Cleanup if we are still communicating with this window. */
109.3334 -            if (source_window == xclient->window) {
109.3335 -                awt_dnd_cleanup();
109.3336 -            }
109.3337 -        }
109.3338 -    }
109.3339 -}
109.3340 -
109.3341 -static void
109.3342 -dt_send_response(XClientMessageEvent* xclient, jint eventID, jint action) {
109.3343 -    Display* dpy = xclient->display;
109.3344 -    XClientMessageEvent response;
109.3345 -
109.3346 -    if (xclient->message_type == XA_XdndPosition) {
109.3347 -        long* event_data = xclient->data.l;
109.3348 -
109.3349 -        if (eventID == java_awt_event_MouseEvent_MOUSE_EXITED) {
109.3350 -            action = java_awt_dnd_DnDConstants_ACTION_NONE;
109.3351 -        }
109.3352 -
109.3353 -        response.display = dpy;
109.3354 -        response.type = ClientMessage;
109.3355 -        response.window = event_data[0];
109.3356 -        response.format = 32;
109.3357 -        response.message_type = XA_XdndStatus;
109.3358 -        /* target window */
109.3359 -        response.data.l[0] = xclient->window;
109.3360 -        /* flags */
109.3361 -        response.data.l[1] = 0;
109.3362 -        if (action != java_awt_dnd_DnDConstants_ACTION_NONE) {
109.3363 -            response.data.l[1] |= XDND_ACCEPT_DROP_FLAG;
109.3364 -        }
109.3365 -        /* specify an empty rectangle */
109.3366 -        response.data.l[2] = 0; /* x, y */
109.3367 -        response.data.l[3] = 0; /* w, h */
109.3368 -        /* action accepted by the target */
109.3369 -        response.data.l[4] = java_to_xdnd_action(action);
109.3370 -    } else if (xclient->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) {
109.3371 -        int reason = (int)(xclient->data.b[0] & MOTIF_MESSAGE_REASON_MASK);
109.3372 -        int origin = (int)(xclient->data.b[0] & MOTIF_MESSAGE_SENDER_MASK);
109.3373 -        unsigned char byte_order = xclient->data.b[1];
109.3374 -        CARD16 response_flags = 0;
109.3375 -        CARD8 response_reason = 0;
109.3376 -        void* p = &response.data.b;
109.3377 -
109.3378 -        /* Only initiator messages should be handled. */
109.3379 -        if (origin != MOTIF_MESSAGE_FROM_INITIATOR) {
109.3380 -            DTRACE_PRINTLN2("%s:%d Receiver message.", __FILE__, __LINE__);
109.3381 -            return;
109.3382 -        }
109.3383 -
109.3384 -        switch (reason) {
109.3385 -        case DRAG_MOTION:
109.3386 -            switch (eventID) {
109.3387 -            case java_awt_event_MouseEvent_MOUSE_ENTERED:
109.3388 -                response_reason = DROP_SITE_ENTER;
109.3389 -                break;
109.3390 -            case java_awt_event_MouseEvent_MOUSE_DRAGGED:
109.3391 -                response_reason = DRAG_MOTION;
109.3392 -                break;
109.3393 -            case java_awt_event_MouseEvent_MOUSE_EXITED:
109.3394 -                response_reason = DROP_SITE_LEAVE;
109.3395 -                break;
109.3396 -            }
109.3397 -        }
109.3398 -
109.3399 -        response.display = dpy;
109.3400 -        response.type = ClientMessage;
109.3401 -        response.window = read_card32(xclient->data.b, 12, byte_order);
109.3402 -        response.format = 8;
109.3403 -        response.message_type = _XA_MOTIF_DRAG_AND_DROP_MESSAGE;
109.3404 -
109.3405 -        write_card8(&p, response_reason | MOTIF_MESSAGE_FROM_RECEIVER);
109.3406 -        write_card8(&p, MOTIF_BYTE_ORDER);
109.3407 -
109.3408 -        if (response_reason != DROP_SITE_LEAVE) {
109.3409 -            CARD16 flags = read_card16(xclient->data.b, 2, byte_order);
109.3410 -            unsigned char drop_site_status =
109.3411 -                (action == java_awt_dnd_DnDConstants_ACTION_NONE) ?
109.3412 -                MOTIF_INVALID_DROP_SITE : MOTIF_VALID_DROP_SITE;
109.3413 -
109.3414 -            /* Clear action and drop site status bits. */
109.3415 -            response_flags =
109.3416 -                flags & ~MOTIF_DND_ACTION_MASK & ~MOTIF_DND_STATUS_MASK;
109.3417 -
109.3418 -            /* Fill in new action and drop site status. */
109.3419 -            response_flags |=
109.3420 -                java_to_motif_actions(action) << MOTIF_DND_ACTION_SHIFT;
109.3421 -            response_flags |=
109.3422 -                drop_site_status << MOTIF_DND_STATUS_SHIFT;
109.3423 -        } else {
109.3424 -            response_flags = 0;
109.3425 -        }
109.3426 -
109.3427 -        write_card16(&p, response_flags);
109.3428 -
109.3429 -        /* Write time stamp. */
109.3430 -        write_card32(&p, read_card32(xclient->data.b, 4, byte_order));
109.3431 -
109.3432 -        /* Write coordinates. */
109.3433 -        if (response_reason != DROP_SITE_LEAVE) {
109.3434 -            write_card16(&p, read_card16(xclient->data.b, 8, byte_order));
109.3435 -            write_card16(&p, read_card16(xclient->data.b, 10, byte_order));
109.3436 -        } else {
109.3437 -            write_card16(&p, 0);
109.3438 -            write_card16(&p, 0);
109.3439 -        }
109.3440 -    } else {
109.3441 -        return;
109.3442 -    }
109.3443 -
109.3444 -    dt_send_event_to_source(&response);
109.3445 -}
109.3446 -
109.3447 -static void
109.3448 -dummy_selection_callback(Widget w, XtPointer client_data, Atom* selection,
109.3449 -                         Atom* type, XtPointer value, unsigned long *length,
109.3450 -                         int32_t *format) {
109.3451 -    /* The selection callback is responsible for freeing the data. */
109.3452 -    if (value != NULL) {
109.3453 -        XtFree(value);
109.3454 -        value = NULL;
109.3455 -    }
109.3456 -}
109.3457 -
109.3458 -static void
109.3459 -dt_notify_drop_done(JNIEnv* env, XClientMessageEvent* xclient, jboolean success,
109.3460 -                    jint action) {
109.3461 -    if (xclient->message_type == XA_XdndDrop) {
109.3462 -        Display* dpy = xclient->display;
109.3463 -        XClientMessageEvent finished;
109.3464 -        long* event_data = xclient->data.l;
109.3465 -
109.3466 -        /*
109.3467 -         * The XDnD protocol recommends that the target requests the special
109.3468 -         * target DELETE in case if the drop action is XdndActionMove.
109.3469 -         */
109.3470 -        if (action == java_awt_dnd_DnDConstants_ACTION_MOVE &&
109.3471 -            success == JNI_TRUE) {
109.3472 -
109.3473 -            Time time_stamp = event_data[2];
109.3474 -
109.3475 -            XtGetSelectionValue(awt_root_shell, XA_XdndSelection, XA_DELETE,
109.3476 -                                dummy_selection_callback, NULL, time_stamp);
109.3477 -        }
109.3478 -
109.3479 -        finished.display = dpy;
109.3480 -        finished.type = ClientMessage;
109.3481 -        finished.window = event_data[0];
109.3482 -        finished.format = 32;
109.3483 -        finished.message_type = XA_XdndFinished;
109.3484 -        finished.data.l[0] = xclient->window;
109.3485 -        finished.data.l[1] = 0; /* flags */
109.3486 -        finished.data.l[2] = None;
109.3487 -        if (source_protocol_version >= 5) {
109.3488 -            if (success == JNI_TRUE) {
109.3489 -                finished.data.l[1] |= XDND_ACCEPT_DROP_FLAG;
109.3490 -            }
109.3491 -            finished.data.l[2] = java_to_xdnd_action(action);
109.3492 -        }
109.3493 -
109.3494 -        dt_send_event_to_source(&finished);
109.3495 -    } else if (xclient->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) {
109.3496 -        char* event_data = xclient->data.b;
109.3497 -        unsigned char event_byte_order = read_card8(event_data, 1);
109.3498 -        unsigned char first_byte = read_card8(event_data, 0);
109.3499 -        unsigned char reason = first_byte & MOTIF_MESSAGE_REASON_MASK;
109.3500 -        unsigned char origin = first_byte & MOTIF_MESSAGE_SENDER_MASK;
109.3501 -        Atom selection = None;
109.3502 -        Time time_stamp = CurrentTime;
109.3503 -        Atom status_atom = None;
109.3504 -
109.3505 -        if (origin != MOTIF_MESSAGE_FROM_INITIATOR) {
109.3506 -            DTRACE_PRINTLN2("%s:%d Invalid origin.", __FILE__, __LINE__);
109.3507 -            return;
109.3508 -        }
109.3509 -
109.3510 -        if (reason != DROP_START) {
109.3511 -            DTRACE_PRINTLN2("%s:%d Invalid reason.", __FILE__, __LINE__);
109.3512 -            return;
109.3513 -        }
109.3514 -
109.3515 -        selection = read_card32(event_data, 12, event_byte_order);
109.3516 -        time_stamp = read_card32(event_data, 4, event_byte_order);
109.3517 -
109.3518 -        if (success == JNI_TRUE) {
109.3519 -            status_atom = XA_XmTRANSFER_SUCCESS;
109.3520 -        } else {
109.3521 -            status_atom = XA_XmTRANSFER_FAILURE;
109.3522 -        }
109.3523 -
109.3524 -        /*
109.3525 -         * This is just the way to communicate the drop completion status back
109.3526 -         * to the initiator as prescribed by the Motif DnD protocol.
109.3527 -         */
109.3528 -        XtGetSelectionValue(awt_root_shell, selection, status_atom,
109.3529 -                            dummy_selection_callback, NULL, time_stamp);
109.3530 -    }
109.3531 -
109.3532 -    /*
109.3533 -     * Flush the buffer to guarantee that the drop completion event is sent
109.3534 -     * to the source before the method returns.
109.3535 -     */
109.3536 -    XFlush(awt_display);
109.3537 -
109.3538 -    /* Trick to prevent awt_dnd_cleanup() from posting dragExit */
109.3539 -    target_component = NULL;
109.3540 -    /* Cannot do cleanup before the drop finishes as we need source protocol
109.3541 -       version to send XdndFinished message. */
109.3542 -    awt_dnd_cleanup();
109.3543 -}
109.3544 -
109.3545 -/*
109.3546 - * Class:     sun_awt_motif_X11DropTargetContextPeer
109.3547 - * Method:    sendResponse
109.3548 - * Signature: (IIJZ)V
109.3549 - */
109.3550 -
109.3551 -JNIEXPORT void JNICALL
109.3552 -Java_sun_awt_motif_X11DropTargetContextPeer_sendResponse(JNIEnv *env,
109.3553 -                                                         jobject this,
109.3554 -                                                         jint eventID,
109.3555 -                                                         jint action,
109.3556 -                                                         jlong nativeCtxt,
109.3557 -                                                         jboolean dispatcherDone,
109.3558 -                                                         jboolean consumed) {
109.3559 -    XClientMessageEvent* xclient =
109.3560 -        (XClientMessageEvent*)jlong_to_ptr(nativeCtxt);
109.3561 -
109.3562 -    AWT_LOCK();
109.3563 -
109.3564 -    if (consumed == JNI_FALSE) {
109.3565 -        dt_send_response(xclient, eventID, action);
109.3566 -    }
109.3567 -
109.3568 -    /*
109.3569 -     * Free the native context only if all copies of the original event are
109.3570 -     * processed.
109.3571 -     */
109.3572 -    if (dispatcherDone == JNI_TRUE) {
109.3573 -        XtFree((char*)xclient);
109.3574 -    }
109.3575 -
109.3576 -    AWT_UNLOCK();
109.3577 -}
109.3578 -
109.3579 -/*
109.3580 - * Class:     sun_awt_motif_X11DropTargetContextPeer
109.3581 - * Method:    dropDone
109.3582 - * Signature: (JZI)V
109.3583 - */
109.3584 -
109.3585 -JNIEXPORT void JNICALL
109.3586 -Java_sun_awt_motif_X11DropTargetContextPeer_dropDone(JNIEnv *env,
109.3587 -                                                     jobject this,
109.3588 -                                                     jlong nativeCtxt,
109.3589 -                                                     jboolean success,
109.3590 -                                                     jint action) {
109.3591 -    XClientMessageEvent* xclient =
109.3592 -        (XClientMessageEvent*)jlong_to_ptr(nativeCtxt);
109.3593 -
109.3594 -    AWT_LOCK();
109.3595 -
109.3596 -    dt_notify_drop_done(env, xclient, success, action);
109.3597 -
109.3598 -    XtFree((char*)xclient);
109.3599 -
109.3600 -    AWT_UNLOCK();
109.3601 -}
109.3602 -
109.3603 -/*
109.3604 - * Class:     sun_awt_motif_X11DropTargetContextPeer
109.3605 - * Method:    getData
109.3606 - * Signature: (IJ)Ljava/lang/Object;
109.3607 - */
109.3608 -
109.3609 -JNIEXPORT jobject JNICALL
109.3610 -Java_sun_awt_motif_X11DropTargetContextPeer_getData(JNIEnv *env,
109.3611 -                                                    jobject this,
109.3612 -                                                    jlong nativeCtxt,
109.3613 -                                                    jlong formatAtom) {
109.3614 -    XClientMessageEvent* xclient =
109.3615 -        (XClientMessageEvent*)jlong_to_ptr(nativeCtxt);
109.3616 -
109.3617 -    Atom selection    = None;
109.3618 -    Time time_stamp   = CurrentTime;
109.3619 -    Atom target       = (Atom)formatAtom;
109.3620 -
109.3621 -    if (xclient->message_type == XA_XdndDrop ||
109.3622 -        xclient->message_type == XA_XdndPosition) {
109.3623 -        Display* dpy = xclient->display;
109.3624 -        Window source_win = xclient->data.l[0];
109.3625 -        Atom protocol_version = 0;
109.3626 -
109.3627 -        int            status;
109.3628 -
109.3629 -        Atom           type;
109.3630 -        int            format;
109.3631 -        unsigned long  nitems;
109.3632 -        unsigned long  after;
109.3633 -        unsigned char  *data;
109.3634 -
109.3635 -        AWT_LOCK();
109.3636 -
109.3637 -        data = NULL;
109.3638 -        status = XGetWindowProperty(dpy, source_win, XA_XdndAware, 0, 0xFFFF,
109.3639 -                                    False, XA_ATOM, &type, &format, &nitems,
109.3640 -                                    &after, &data);
109.3641 -
109.3642 -        if (status == Success && data != NULL && type == XA_ATOM && format == 32
109.3643 -            && nitems > 0) {
109.3644 -            protocol_version = (protocol_version > XDND_PROTOCOL_VERSION) ?
109.3645 -                XDND_PROTOCOL_VERSION : protocol_version;
109.3646 -
109.3647 -            if (protocol_version > 0) {
109.3648 -                if (xclient->message_type == XA_XdndDrop) {
109.3649 -                    time_stamp = xclient->data.l[2];
109.3650 -                } else if (xclient->message_type == XA_XdndPosition) {
109.3651 -                    time_stamp = xclient->data.l[3];
109.3652 -                }
109.3653 -            }
109.3654 -        }
109.3655 -
109.3656 -        if (status == Success) {
109.3657 -            XFree(data);
109.3658 -            data = NULL;
109.3659 -        }
109.3660 -
109.3661 -        AWT_FLUSH_UNLOCK();
109.3662 -
109.3663 -        selection = XA_XdndSelection;
109.3664 -        if (time_stamp == CurrentTime) {
109.3665 -            time_stamp = awt_util_getCurrentServerTime();
109.3666 -        }
109.3667 -
109.3668 -    } else if (xclient->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) {
109.3669 -        char* event_data = xclient->data.b;
109.3670 -        unsigned char event_byte_order = read_card8(event_data, 1);
109.3671 -        unsigned char first_byte = read_card8(event_data, 0);
109.3672 -        unsigned char reason = first_byte & MOTIF_MESSAGE_REASON_MASK;
109.3673 -        unsigned char origin = first_byte & MOTIF_MESSAGE_SENDER_MASK;
109.3674 -
109.3675 -        if (origin != MOTIF_MESSAGE_FROM_INITIATOR) {
109.3676 -            DTRACE_PRINTLN2("%s:%d Invalid origin.", __FILE__, __LINE__);
109.3677 -            return NULL;
109.3678 -        }
109.3679 -
109.3680 -        switch (reason) {
109.3681 -        case DROP_START:
109.3682 -            selection = read_card32(event_data, 12, event_byte_order);
109.3683 -            break;
109.3684 -        case DRAG_MOTION:
109.3685 -        case OPERATION_CHANGED:
109.3686 -            selection = source_atom;
109.3687 -            break;
109.3688 -        default:
109.3689 -            DTRACE_PRINTLN2("%s:%d Invalid reason.", __FILE__, __LINE__);
109.3690 -            return NULL;
109.3691 -        }
109.3692 -
109.3693 -        if (selection == None) {
109.3694 -            return NULL;
109.3695 -        }
109.3696 -
109.3697 -        time_stamp = read_card32(event_data, 4, event_byte_order);
109.3698 -    } else {
109.3699 -        return NULL;
109.3700 -    }
109.3701 -
109.3702 -    return get_selection_data(env, selection, target, time_stamp);
109.3703 -}
   110.1 --- a/src/solaris/native/sun/awt/awt_motif.c	Wed Sep 17 13:45:37 2008 -0700
   110.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   110.3 @@ -1,58 +0,0 @@
   110.4 -/*
   110.5 - * Copyright 2000-2002 Sun Microsystems, Inc.  All Rights Reserved.
   110.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   110.7 - *
   110.8 - * This code is free software; you can redistribute it and/or modify it
   110.9 - * under the terms of the GNU General Public License version 2 only, as
  110.10 - * published by the Free Software Foundation.  Sun designates this
  110.11 - * particular file as subject to the "Classpath" exception as provided
  110.12 - * by Sun in the LICENSE file that accompanied this code.
  110.13 - *
  110.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  110.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  110.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  110.17 - * version 2 for more details (a copy is included in the LICENSE file that
  110.18 - * accompanied this code).
  110.19 - *
  110.20 - * You should have received a copy of the GNU General Public License version
  110.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  110.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  110.23 - *
  110.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  110.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  110.26 - * have any questions.
  110.27 - */
  110.28 -
  110.29 -#ifdef HEADLESS
  110.30 -    #error This file should not be included in headless library
  110.31 -#endif
  110.32 -
  110.33 -#include "awt_motif.h"
  110.34 -
  110.35 -#include <jvm.h>
  110.36 -
  110.37 -/* Common routines required for both Motif 2.1 and Motif 1.2 */
  110.38 -#include <Xm/ScrollBarP.h>
  110.39 -
  110.40 -/* Remove the ScrollBar widget's continuous scrolling timeout handler
  110.41 -   on a ButtonRelease to prevent the continuous scrolling that would
  110.42 -   occur if a timeout expired after the ButtonRelease.
  110.43 -*/
  110.44 -/*
  110.45 - * Note: RFE:4263104 is filed when the API is available these needs to removed
  110.46 - */
  110.47 -void
  110.48 -awt_motif_Scrollbar_ButtonReleaseHandler(Widget w,
  110.49 -                                         XtPointer data,
  110.50 -                                         XEvent *event,
  110.51 -                                         Boolean *cont)
  110.52 -{
  110.53 -  /* Remove the timeout handler. */
  110.54 -#define END_TIMER         (1<<2)
  110.55 -  XmScrollBarWidget sbw = (XmScrollBarWidget) w;
  110.56 -  if (sbw->scrollBar.timer != NULL) {
  110.57 -    XtRemoveTimeOut( sbw->scrollBar.timer );
  110.58 -    sbw->scrollBar.timer = (XtIntervalId)NULL;
  110.59 -    sbw->scrollBar.flags |= END_TIMER;
  110.60 -  }
  110.61 -}
   111.1 --- a/src/solaris/native/sun/awt/awt_motif12.c	Wed Sep 17 13:45:37 2008 -0700
   111.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   111.3 @@ -1,435 +0,0 @@
   111.4 -/*
   111.5 - * Copyright 2000-2001 Sun Microsystems, Inc.  All Rights Reserved.
   111.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   111.7 - *
   111.8 - * This code is free software; you can redistribute it and/or modify it
   111.9 - * under the terms of the GNU General Public License version 2 only, as
  111.10 - * published by the Free Software Foundation.  Sun designates this
  111.11 - * particular file as subject to the "Classpath" exception as provided
  111.12 - * by Sun in the LICENSE file that accompanied this code.
  111.13 - *
  111.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  111.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  111.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  111.17 - * version 2 for more details (a copy is included in the LICENSE file that
  111.18 - * accompanied this code).
  111.19 - *
  111.20 - * You should have received a copy of the GNU General Public License version
  111.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  111.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  111.23 - *
  111.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  111.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  111.26 - * have any questions.
  111.27 - */
  111.28 -
  111.29 -#if MOTIF_VERSION!=1
  111.30 -    #error This file should only be compiled with motif 1.2
  111.31 -#endif
  111.32 -
  111.33 -#include "awt_motif.h"
  111.34 -#include <Xm/VendorSEP.h>
  111.35 -#include <Xm/DragCP.h>
  111.36 -#include "debug_util.h"
  111.37 -#include "awt.h"
  111.38 -
  111.39 -/*
  111.40 - * awt_motif_getIMStatusHeight is a cut and paste of the ImGetGeo() function
  111.41 - * found in CDE Motif's Xm/XmIm.c.  It returns the height of the Input Method
  111.42 - * Status region attached to the given VendorShell.  This is needed in order
  111.43 - * to calculate geometry for Frames and Dialogs that contain TextField or
  111.44 - * TextArea widgets.
  111.45 - *
  111.46 - * BCB: Copying this function out of the Motif source is a horrible
  111.47 - * hack. Unfortunately, Motif tries to hide the existence of the IM Status
  111.48 - * region from us so it does not provide any public way to get this info.
  111.49 - * Clearly a better long term solution needs to be found.
  111.50 - */
  111.51 -
  111.52 -typedef struct _XmICStruct {
  111.53 -    struct _XmICStruct *next;
  111.54 -    Widget icw;
  111.55 -    Window focus_window;
  111.56 -    XtArgVal foreground;
  111.57 -    XtArgVal background;
  111.58 -    XtArgVal background_pixmap;
  111.59 -    XtArgVal font_list;
  111.60 -    XtArgVal line_space;
  111.61 -    int32_t status_width;
  111.62 -    int32_t status_height;
  111.63 -    int32_t preedit_width;
  111.64 -    int32_t preedit_height;
  111.65 -    Boolean has_focus;
  111.66 -    Boolean need_reset;
  111.67 -}   XmICStruct;
  111.68 -
  111.69 -typedef struct {
  111.70 -    Widget im_widget;
  111.71 -    XIMStyle input_style;
  111.72 -    XIC xic;
  111.73 -    int32_t status_width;
  111.74 -    int32_t status_height;
  111.75 -    int32_t preedit_width;
  111.76 -    int32_t preedit_height;
  111.77 -    XmICStruct *iclist;
  111.78 -    XmICStruct *current;
  111.79 -}   XmImInfo;
  111.80 -
  111.81 -static XFontSet extract_fontset(XmFontList);
  111.82 -static XmICStruct *get_iclist(Widget);
  111.83 -
  111.84 -#define MAXARGS 10
  111.85 -static Arg xic_vlist[MAXARGS];
  111.86 -static Arg status_vlist[MAXARGS];
  111.87 -static Arg preedit_vlist[MAXARGS];
  111.88 -
  111.89 -#define NO_ARG_VAL -1
  111.90 -#define SEPARATOR_HEIGHT 2
  111.91 -
  111.92 -
  111.93 -#ifdef MOTIF_2_1_HACK
  111.94 -/* To shut up warning messages from "cc -v"
  111.95 - *   Copied from Solaris 2.6 /usr/dt/include/Xm/BaseClassP.h and not
  111.96 - *     there in Solaris 7.
  111.97 - */
  111.98 -#if defined(__SunOS_5_7) || defined(__SunOS_5_8)
  111.99 -extern XmWidgetExtData _XmGetWidgetExtData(Widget, unsigned char);
 111.100 -#endif
 111.101 -
 111.102 -#else
 111.103 -
 111.104 -/*
 111.105 -   The following defines are to make the XmImGetXIC to compile on systems
 111.106 -   lower than SunOS 5.7, so therefore the following is a copy of the
 111.107 -   defines on SunOS 5.7/Motif2.1 header files.
 111.108 -*/
 111.109 -/*#if defined (__SunOS_5_5_1) || defined (__SunOS_5_6)*/
 111.110 -#define XmPER_SHELL 0
 111.111 -
 111.112 -extern XIC XmImGetXIC(
 111.113 -                        Widget          w,
 111.114 -                        unsigned int    input_policy,
 111.115 -                        ArgList         args,
 111.116 -                        Cardinal        num_args) ;
 111.117 -#endif
 111.118 -
 111.119 -static XmICStruct *
 111.120 -get_iclist(Widget w)
 111.121 -{
 111.122 -    Widget p;
 111.123 -    XmVendorShellExtObject ve;
 111.124 -    XmWidgetExtData extData;
 111.125 -    XmImInfo *im_info;
 111.126 -
 111.127 -    p = w;
 111.128 -    while (!XtIsShell(p))
 111.129 -        p = XtParent(p);
 111.130 -
 111.131 -    extData = (XmWidgetExtData)_XmGetWidgetExtData((Widget) p, XmSHELL_EXTENSION);
 111.132 -    if (extData == NULL)
 111.133 -        return NULL;
 111.134 -
 111.135 -    ve = (XmVendorShellExtObject) extData->widget;
 111.136 -    if ((im_info = (XmImInfo *) ve->vendor.im_info) == NULL)
 111.137 -        return NULL;
 111.138 -    else
 111.139 -        return im_info->iclist;
 111.140 -}
 111.141 -
 111.142 -int32_t
 111.143 -awt_motif_getIMStatusHeight(Widget vw, jobject tc)
 111.144 -{
 111.145 -    XmICStruct *icp;
 111.146 -    XmVendorShellExtObject ve;
 111.147 -    XmWidgetExtData extData;
 111.148 -    XmImInfo *im_info;
 111.149 -    int32_t width = 0;
 111.150 -    int32_t height = 0;
 111.151 -    XRectangle rect;
 111.152 -    XRectangle *rp;
 111.153 -    int32_t old_height;
 111.154 -    Arg args[1];
 111.155 -    int32_t base_height;
 111.156 -    XFontSet fs;
 111.157 -    XFontSet fss = NULL;
 111.158 -    XFontSet fsp = NULL;
 111.159 -
 111.160 -    extData = (XmWidgetExtData)_XmGetWidgetExtData((Widget) vw, XmSHELL_EXTENSION);
 111.161 -    ve = (XmVendorShellExtObject) extData->widget;
 111.162 -
 111.163 -    if ((icp = get_iclist(vw)) == NULL) {
 111.164 -        ve->vendor.im_height = 0;
 111.165 -        return 0;
 111.166 -    }
 111.167 -    im_info = (XmImInfo *) ve->vendor.im_info;
 111.168 -    if (im_info->xic == NULL) {
 111.169 -        ve->vendor.im_height = 0;
 111.170 -        return 0;
 111.171 -    }
 111.172 -    status_vlist[0].name = XNFontSet;
 111.173 -    status_vlist[1].name = NULL;
 111.174 -    preedit_vlist[0].name = XNFontSet;
 111.175 -    preedit_vlist[1].name = NULL;
 111.176 -
 111.177 -    xic_vlist[0].name = XNAreaNeeded;
 111.178 -    xic_vlist[1].name = NULL;
 111.179 -
 111.180 -    im_info->status_width = 0;
 111.181 -    im_info->status_height = 0;
 111.182 -    im_info->preedit_width = 0;
 111.183 -    im_info->preedit_height = 0;
 111.184 -    for (; icp != NULL; icp = icp->next) {
 111.185 -        if (im_info->input_style & XIMStatusArea) {
 111.186 -            if (icp->status_height == 0) {
 111.187 -                char *ret;
 111.188 -
 111.189 -                if (icp->font_list == NO_ARG_VAL ||
 111.190 -                    (fss = extract_fontset((XmFontList) icp->font_list)) == NULL)
 111.191 -                    continue;
 111.192 -
 111.193 -                status_vlist[0].value = (XtArgVal) fss;
 111.194 -                XSetICValues(im_info->xic,
 111.195 -                             XNStatusAttributes, &status_vlist[0],
 111.196 -                             NULL);
 111.197 -
 111.198 -                xic_vlist[0].value = (XtArgVal) & rp;
 111.199 -                ret = XGetICValues(im_info->xic,
 111.200 -                                   XNStatusAttributes, &xic_vlist[0],
 111.201 -                                   NULL);
 111.202 -
 111.203 -                if (ret) {
 111.204 -                    /* Cannot obtain XIC value. IM server may be gone. */
 111.205 -                    ve->vendor.im_height = 0;
 111.206 -                    return 0;
 111.207 -                } else {
 111.208 -                    icp->status_width = rp->width;
 111.209 -                    icp->status_height = rp->height;
 111.210 -                    XFree(rp);
 111.211 -                }
 111.212 -            }
 111.213 -            if (icp->status_width > im_info->status_width)
 111.214 -                im_info->status_width = icp->status_width;
 111.215 -            if (icp->status_height > im_info->status_height)
 111.216 -                im_info->status_height = icp->status_height;
 111.217 -        }
 111.218 -        if (im_info->input_style & XIMPreeditArea) {
 111.219 -            if (icp->preedit_height == 0) {
 111.220 -                if (icp->font_list == NO_ARG_VAL ||
 111.221 -                    (fsp = extract_fontset((XmFontList) icp->font_list)) == NULL)
 111.222 -                    continue;
 111.223 -
 111.224 -                preedit_vlist[0].value = (XtArgVal) fsp;
 111.225 -                XSetICValues(im_info->xic,
 111.226 -                             XNPreeditAttributes, &preedit_vlist[0],
 111.227 -                             NULL);
 111.228 -
 111.229 -                xic_vlist[0].value = (XtArgVal) & rp;
 111.230 -                XGetICValues(im_info->xic,
 111.231 -                             XNPreeditAttributes, &xic_vlist[0],
 111.232 -                             NULL);
 111.233 -
 111.234 -                icp->preedit_width = rp->width;
 111.235 -                icp->preedit_height = rp->height;
 111.236 -                XFree(rp);
 111.237 -            }
 111.238 -            if (icp->preedit_width > im_info->preedit_width)
 111.239 -                im_info->preedit_width = icp->preedit_width;
 111.240 -            if (icp->preedit_height > im_info->preedit_height)
 111.241 -                im_info->preedit_height = icp->preedit_height;
 111.242 -        }
 111.243 -    }
 111.244 -
 111.245 -    if (im_info->current != NULL && (fss != NULL || fsp != NULL)) {
 111.246 -        if (im_info->current->font_list != NO_ARG_VAL &&
 111.247 -            (fs = extract_fontset((XmFontList) im_info->current->font_list))
 111.248 -            != NULL) {
 111.249 -            if (fss != NULL)
 111.250 -                status_vlist[0].value = (XtArgVal) fs;
 111.251 -            else
 111.252 -                status_vlist[0].name = NULL;
 111.253 -            if (fsp != NULL)
 111.254 -                preedit_vlist[0].value = (XtArgVal) fs;
 111.255 -            else
 111.256 -                preedit_vlist[0].name = NULL;
 111.257 -            XSetICValues(im_info->xic,
 111.258 -                         XNStatusAttributes, &status_vlist[0],
 111.259 -                         XNPreeditAttributes, &preedit_vlist[0],
 111.260 -                         NULL);
 111.261 -        }
 111.262 -    }
 111.263 -    if (im_info->status_height > im_info->preedit_height)
 111.264 -        height = im_info->status_height;
 111.265 -    else
 111.266 -        height = im_info->preedit_height;
 111.267 -    old_height = ve->vendor.im_height;
 111.268 -    if (height)
 111.269 -        height += SEPARATOR_HEIGHT;
 111.270 -
 111.271 -    ve->vendor.im_height = height;
 111.272 -
 111.273 -    XtSetArg(args[0], XtNbaseHeight, &base_height);
 111.274 -    XtGetValues(vw, args, 1);
 111.275 -    if (base_height < 0)
 111.276 -        base_height = 0;
 111.277 -    XtSetArg(args[0], XtNbaseHeight, base_height);
 111.278 -    XtSetValues(vw, args, 1);
 111.279 -    return height;
 111.280 -}
 111.281 -static XRectangle geometryRect;
 111.282 -XVaNestedList awt_motif_getXICStatusAreaList(Widget w, jobject tc)
 111.283 -{
 111.284 -    Widget p;
 111.285 -    XmVendorShellExtObject ve;
 111.286 -    XmWidgetExtData extData;
 111.287 -    XmImInfo *im_info;
 111.288 -    XmICStruct *icp;
 111.289 -
 111.290 -    XVaNestedList list = NULL;
 111.291 -    XRectangle  *ssgeometry = &geometryRect;
 111.292 -    Pixel  bg;
 111.293 -    Pixel  fg;
 111.294 -    Pixmap bpm;
 111.295 -    Dimension height,width;
 111.296 -    Position  x,y;
 111.297 -
 111.298 -    p = w;
 111.299 -    while (!XtIsShell(p)){
 111.300 -        p = XtParent(p);
 111.301 -    }
 111.302 -
 111.303 -    XtVaGetValues(p,
 111.304 -                  XmNx, &x,
 111.305 -                  XmNy, &y,
 111.306 -                  XmNwidth, &width,
 111.307 -                  XmNheight, &height,
 111.308 -                  NULL);
 111.309 -
 111.310 -    extData = (XmWidgetExtData)_XmGetWidgetExtData((Widget) p, XmSHELL_EXTENSION);
 111.311 -    if (extData == NULL) {
 111.312 -        return NULL;
 111.313 -    }
 111.314 -
 111.315 -    ve = (XmVendorShellExtObject) extData->widget;
 111.316 -    if ((im_info = (XmImInfo *) ve->vendor.im_info) == NULL) {
 111.317 -        return NULL;
 111.318 -    } else
 111.319 -        icp = im_info->iclist;
 111.320 -
 111.321 -
 111.322 -    if (icp) {
 111.323 -        /*
 111.324 -         * We hava at least a textfield/textarea in the frame, use the
 111.325 -         * first one.
 111.326 -         */
 111.327 -        ssgeometry->x = 0;
 111.328 -        ssgeometry->y = height - icp->status_height;
 111.329 -        ssgeometry->width = icp->status_width;
 111.330 -        ssgeometry->height = icp->status_height;
 111.331 -
 111.332 -        /*
 111.333 -         * use motif TextComponent's resource
 111.334 -         */
 111.335 -        fg = icp->foreground;
 111.336 -        bg = icp->background;
 111.337 -        bpm = icp->background_pixmap;
 111.338 -
 111.339 -        list = XVaCreateNestedList(0,
 111.340 -                        XNFontSet, extract_fontset((XmFontList)icp->font_list),
 111.341 -                        XNArea, ssgeometry,
 111.342 -                        XNBackground, bg,
 111.343 -                        XNForeground, fg,
 111.344 -                        XNBackgroundPixmap, bpm,
 111.345 -                        NULL);
 111.346 -   }
 111.347 -    return list ;
 111.348 -}
 111.349 -
 111.350 -static XFontSet
 111.351 -extract_fontset(XmFontList fl)
 111.352 -{
 111.353 -    XmFontContext context;
 111.354 -    XmFontListEntry next_entry;
 111.355 -    XmFontType type_return;
 111.356 -    XtPointer tmp_font;
 111.357 -    XFontSet first_fs = NULL;
 111.358 -    char *font_tag;
 111.359 -
 111.360 -    if (!XmFontListInitFontContext(&context, fl))
 111.361 -        return NULL;
 111.362 -
 111.363 -    do {
 111.364 -        next_entry = XmFontListNextEntry(context);
 111.365 -        if (next_entry) {
 111.366 -            tmp_font = XmFontListEntryGetFont(next_entry, &type_return);
 111.367 -            if (type_return == XmFONT_IS_FONTSET) {
 111.368 -                font_tag = XmFontListEntryGetTag(next_entry);
 111.369 -                if (!strcmp(font_tag, XmFONTLIST_DEFAULT_TAG)) {
 111.370 -                    XmFontListFreeFontContext(context);
 111.371 -                    XtFree(font_tag);
 111.372 -                    return (XFontSet) tmp_font;
 111.373 -                }
 111.374 -                XtFree(font_tag);
 111.375 -                if (first_fs == NULL)
 111.376 -                    first_fs = (XFontSet) tmp_font;
 111.377 -            }
 111.378 -        }
 111.379 -    } while (next_entry);
 111.380 -
 111.381 -    XmFontListFreeFontContext(context);
 111.382 -    return first_fs;
 111.383 -}
 111.384 -
 111.385 -/*
 111.386 - * Motif 1.2 requires that an X event passed to XmDragStart is of
 111.387 - * ButtonPress type. In Motif 2.1 the restriction is relaxed to allow
 111.388 - * ButtonPress, ButtonRelease, KeyRelease, KeyPress, MotionNotify events
 111.389 - * as drag initiators. Actually the code in Motif 1.2 works okay for these
 111.390 - * events as well, since it uses only the fields that have the same values
 111.391 - * in all five event types. To bypass the initial sanity check in
 111.392 - * XmDragStart we forcibly change event type to ButtonPress.
 111.393 - *
 111.394 - * This function causes an UnsatisfiedLinkError on Linux.
 111.395 - * Since Linux only links against Motif 2.1, we can safely remove
 111.396 - * this function altogether from the Linux build.
 111.397 - * bchristi 1/22/2001
 111.398 - */
 111.399 -
 111.400 -#ifdef __solaris__
 111.401 -void
 111.402 -awt_motif_adjustDragTriggerEvent(XEvent* xevent) {
 111.403 -    xevent->type = ButtonPress;
 111.404 -}
 111.405 -#endif /* __solaris__ */
 111.406 -
 111.407 -static XmDragStartProc do_drag_start = NULL;
 111.408 -static Widget drag_initiator = NULL;
 111.409 -
 111.410 -static void
 111.411 -CheckedDragStart(XmDragContext dc, Widget src, XEvent *event) {
 111.412 -    DASSERT(do_drag_start != NULL);
 111.413 -    DASSERT(drag_initiator != NULL);
 111.414 -    /*
 111.415 -     * Fix for BugTraq ID 4407057.
 111.416 -     * Enable the drag operation only if it is registered on the specific widget.
 111.417 -     * We use this check to disable Motif default drag support.
 111.418 -     */
 111.419 -    if (src == drag_initiator) {
 111.420 -        do_drag_start(dc, src, event);
 111.421 -    } else {
 111.422 -        /*
 111.423 -         * This is the last chance to destroy the XmDragContext widget.
 111.424 -         * NOTE: We rely on the fact that Motif 1.2 never uses the pointer
 111.425 -         * to XmDragContext object returned from XmDragStart.
 111.426 -         */
 111.427 -        XtDestroyWidget(dc);
 111.428 -    }
 111.429 -}
 111.430 -
 111.431 -void
 111.432 -awt_motif_enableSingleDragInitiator(Widget w) {
 111.433 -    DASSERT(drag_initiator == NULL && do_drag_start == NULL && w != NULL);
 111.434 -    drag_initiator = w;
 111.435 -    do_drag_start = xmDragContextClassRec.drag_class.start;
 111.436 -    DASSERT(do_drag_start != NULL);
 111.437 -    xmDragContextClassRec.drag_class.start = (XmDragStartProc)CheckedDragStart;
 111.438 -}
   112.1 --- a/src/solaris/native/sun/awt/awt_motif21.c	Wed Sep 17 13:45:37 2008 -0700
   112.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   112.3 @@ -1,234 +0,0 @@
   112.4 -/*
   112.5 - * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
   112.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   112.7 - *
   112.8 - * This code is free software; you can redistribute it and/or modify it
   112.9 - * under the terms of the GNU General Public License version 2 only, as
  112.10 - * published by the Free Software Foundation.  Sun designates this
  112.11 - * particular file as subject to the "Classpath" exception as provided
  112.12 - * by Sun in the LICENSE file that accompanied this code.
  112.13 - *
  112.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  112.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  112.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  112.17 - * version 2 for more details (a copy is included in the LICENSE file that
  112.18 - * accompanied this code).
  112.19 - *
  112.20 - * You should have received a copy of the GNU General Public License version
  112.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  112.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  112.23 - *
  112.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  112.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  112.26 - * have any questions.
  112.27 - */
  112.28 -
  112.29 -#if MOTIF_VERSION!=2
  112.30 -    #error This file should only be compiled with motif 2.1
  112.31 -#endif
  112.32 -
  112.33 -#include "awt_motif.h"
  112.34 -#include <Xm/Xm.h>
  112.35 -#include "awt.h"
  112.36 -#include "awt_p.h"
  112.37 -#include "awt_Component.h"
  112.38 -
  112.39 -#define XmPER_SHELL 0
  112.40 -extern int32_t _XmImGetGeo(
  112.41 -                        Widget vw) ;
  112.42 -
  112.43 -#define MAXARGS 10
  112.44 -static Arg xic_vlist[MAXARGS];
  112.45 -
  112.46 -#define SEPARATOR_HEIGHT        2
  112.47 -#define MTEXTAREAPEER_CLASS_NAME        "sun/awt/motif/MTextAreaPeer"
  112.48 -extern struct MComponentPeerIDs mComponentPeerIDs;
  112.49 -static jobject  mTextAreaClass = NULL;
  112.50 -
  112.51 -/*
  112.52 - * Get the Motif text widget from the text component peer.  XmImGetXIC()
  112.53 - * function should be issued on Motif text widgets.
  112.54 - */
  112.55 -static Widget getTextWidget(jobject tc) {
  112.56 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  112.57 -
  112.58 -    if (mTextAreaClass == NULL) {
  112.59 -        jclass localClass = (*env)->FindClass(env, MTEXTAREAPEER_CLASS_NAME);
  112.60 -        mTextAreaClass = (jclass)(*env)->NewGlobalRef(env, localClass);
  112.61 -        (*env)->DeleteLocalRef(env, localClass);
  112.62 -    }
  112.63 -
  112.64 -    if ((*env)->IsInstanceOf(env, tc, mTextAreaClass)) {
  112.65 -        struct TextAreaData * tdata = (struct TextAreaData *)
  112.66 -        JNU_GetLongFieldAsPtr(env, tc, mComponentPeerIDs.pData);
  112.67 -        return tdata->txt;
  112.68 -    } else {
  112.69 -        struct ComponentData * tdata = (struct ComponentData *)
  112.70 -        JNU_GetLongFieldAsPtr(env, tc, mComponentPeerIDs.pData);
  112.71 -        return tdata->widget;
  112.72 -    }
  112.73 -}
  112.74 -
  112.75 -/* get_im_height: returns height of the input method status area in pixels.
  112.76 - *
  112.77 - * This function assumes that if any XIM related information cannot be
  112.78 - * queried then the app must not have an input method status area in the
  112.79 - * current locale and returns zero as the status area height
  112.80 - */
  112.81 -int32_t
  112.82 -awt_motif_getIMStatusHeight(Widget w, jobject tc)
  112.83 -{
  112.84 -    XIC xic = NULL;
  112.85 -    XRectangle *im_rect=NULL;
  112.86 -    int32_t im_height = 0;
  112.87 -    char *ret;
  112.88 -
  112.89 -    xic = XmImGetXIC(getTextWidget(tc), XmPER_SHELL, NULL, 0);
  112.90 -
  112.91 -    if(xic != NULL) {
  112.92 -        /* finally query the server for the status area geometry */
  112.93 -        xic_vlist[0].name = XNArea;
  112.94 -        xic_vlist[0].value = (XtArgVal)&im_rect;
  112.95 -        xic_vlist[1].name = NULL;
  112.96 -        ret=XGetICValues(xic, XNStatusAttributes, &xic_vlist[0], NULL);
  112.97 -        if (ret == NULL && im_rect != NULL) {
  112.98 -            im_height = im_rect->height;
  112.99 -            if (im_height > 0) {
 112.100 -                im_height += SEPARATOR_HEIGHT;
 112.101 -            }
 112.102 -            XFree(im_rect);
 112.103 -        } else {
 112.104 -            im_height = 0;
 112.105 -        }
 112.106 -    }
 112.107 -
 112.108 -    if (im_height == 0) {
 112.109 -        im_height = _XmImGetGeo(w);
 112.110 -    }
 112.111 -
 112.112 -#if defined(DEBUG)
 112.113 -    jio_fprintf(stderr,"awt_motif_getIMStatusHeight: Height = %d",im_height);
 112.114 -#endif
 112.115 -    return im_height;
 112.116 -}
 112.117 -
 112.118 -
 112.119 -static XRectangle geomRect;
 112.120 -static Pixmap bpm;
 112.121 -XVaNestedList awt_motif_getXICStatusAreaList(Widget w, jobject tc)
 112.122 -{
 112.123 -    XIC xic;
 112.124 -
 112.125 -    XRectangle *im_rect;
 112.126 -    XFontSet   *im_font;
 112.127 -
 112.128 -    Pixel bg ;
 112.129 -    Pixel fg ;
 112.130 -    Dimension height, width ;
 112.131 -    Position x,y ;
 112.132 -
 112.133 -    XVaNestedList list = NULL;
 112.134 -
 112.135 -    char *ret;
 112.136 -    Widget p=w;
 112.137 -
 112.138 -    while (!XtIsShell(p)) {
 112.139 -        p = XtParent(p);
 112.140 -    }
 112.141 -
 112.142 -    XtVaGetValues(p,
 112.143 -        XmNx, &x,
 112.144 -        XmNy, &y,
 112.145 -        XmNwidth, &width,
 112.146 -        XmNheight, &height,
 112.147 -        XmNbackgroundPixmap, &bpm,
 112.148 -        NULL);
 112.149 -
 112.150 -
 112.151 -
 112.152 -    xic = XmImGetXIC(getTextWidget(tc), XmPER_SHELL, NULL, 0);
 112.153 -    if(xic == NULL)
 112.154 -    {
 112.155 -#if defined DEBUG
 112.156 -        jio_fprintf(stderr,"Could not get XIC");
 112.157 -#endif
 112.158 -        return list ;
 112.159 -    }
 112.160 -
 112.161 -   /* finally query the server for the required attributes area geometry */
 112.162 -    xic_vlist[0].name = XNFontSet ;
 112.163 -    xic_vlist[0].value =  (XtArgVal) &im_font ;
 112.164 -    xic_vlist[1].name = XNArea;
 112.165 -    xic_vlist[1].value = (XtArgVal) &im_rect;
 112.166 -    xic_vlist[2].name = XNBackground ;
 112.167 -    xic_vlist[2].value = (XtArgVal) &bg ;
 112.168 -    xic_vlist[3].name = XNForeground ;
 112.169 -    xic_vlist[3].value = (XtArgVal) &fg ;
 112.170 -    xic_vlist[4].name = NULL;
 112.171 -
 112.172 -
 112.173 -    if(ret=XGetICValues(xic, XNStatusAttributes, &xic_vlist[0], NULL))
 112.174 -    {
 112.175 -        return list ;
 112.176 -    } else {
 112.177 -        geomRect.x = 0 ;
 112.178 -        geomRect.y = height - im_rect->height ;
 112.179 -        geomRect.width = im_rect->width ;
 112.180 -        geomRect.height = im_rect->height ;
 112.181 -        XFree(im_rect) ;
 112.182 -
 112.183 -        list = XVaCreateNestedList(0 ,
 112.184 -                        XNFontSet, im_font ,
 112.185 -                        XNArea, &geomRect ,
 112.186 -                        XNBackground, bg ,
 112.187 -                        XNForeground, fg ,
 112.188 -                        XNBackgroundPixmap, &bpm ,
 112.189 -                        NULL );
 112.190 -    }
 112.191 -#if defined(DEBUG)
 112.192 -    jio_fprintf(stderr,"awt_motif_getXICStatusAreaList:\n");
 112.193 -    jio_fprintf(stderr,"XNArea:x=%d,y=%d,width=%d,height=%d\n", \
 112.194 -         geomRect.x,geomRect.y,geomRect.width,geomRect.height);
 112.195 -    jio_fprintf(stderr,"XNBackground=0x%x\n",bg);
 112.196 -    jio_fprintf(stderr,"XNForeground=0x%x\n",fg);
 112.197 -    jio_fprintf(stderr,"XNBackgroundPixmap=0x%x\n",bpm);
 112.198 -#endif
 112.199 -    return list ;
 112.200 -
 112.201 -}
 112.202 -
 112.203 -    /* This function causes an UnsatisfiedLinkError on Linux.
 112.204 -     * Since Linux only links against Motif 2.1 and under 2.1 this function
 112.205 -     * is a no-op, we can safely remove
 112.206 -     * this function altogether from the Linux build.
 112.207 -     * bchristi 1/22/2001
 112.208 -     */
 112.209 -
 112.210 -#ifdef __solaris__
 112.211 -void
 112.212 -awt_motif_adjustDragTriggerEvent(XEvent* xevent) {
 112.213 -    /* Do nothing. In Motif 2.1 the sanity check is corrected
 112.214 -       to allow any imput event as a drag trigger event. */
 112.215 -}
 112.216 -#endif /* __solaris__ */
 112.217 -
 112.218 -static void
 112.219 -CheckDragInitiator(Widget w, XtPointer client_data,
 112.220 -                   XmDragStartCallbackStruct* cbstruct) {
 112.221 -    Widget drag_initiator = (Widget)client_data;
 112.222 -    /*
 112.223 -     * Fix for BugTraq ID 4407057.
 112.224 -     * Enable the drag operation only if it is registered on the specific
 112.225 -     * widget. We use this check to disable Motif default drag support.
 112.226 -     */
 112.227 -    if (drag_initiator != cbstruct->widget) {
 112.228 -        cbstruct->doit = False;
 112.229 -    }
 112.230 -}
 112.231 -
 112.232 -void
 112.233 -awt_motif_enableSingleDragInitiator(Widget w) {
 112.234 -    XtAddCallback(XmGetXmDisplay(XtDisplay(w)),
 112.235 -                  XmNdragStartCallback, (XtCallbackProc)CheckDragInitiator,
 112.236 -                  (XtPointer)w);
 112.237 -}
   113.1 --- a/src/solaris/native/sun/awt/awt_p.h	Wed Sep 17 13:45:37 2008 -0700
   113.2 +++ b/src/solaris/native/sun/awt/awt_p.h	Fri Sep 19 19:38:12 2008 -0700
   113.3 @@ -79,7 +79,7 @@
   113.4  
   113.5  #ifndef XAWT
   113.6  #include "GLXGraphicsConfig.h"
   113.7 -#include <sun_awt_motif_MComponentPeer.h>
   113.8 +//#include <sun_awt_motif_MComponentPeer.h>
   113.9  #endif
  113.10  
  113.11  #ifndef HEADLESS
   114.1 --- a/src/solaris/native/sun/awt/awt_xembed.c	Wed Sep 17 13:45:37 2008 -0700
   114.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   114.3 @@ -1,430 +0,0 @@
   114.4 -/*
   114.5 - * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
   114.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   114.7 - *
   114.8 - * This code is free software; you can redistribute it and/or modify it
   114.9 - * under the terms of the GNU General Public License version 2 only, as
  114.10 - * published by the Free Software Foundation.  Sun designates this
  114.11 - * particular file as subject to the "Classpath" exception as provided
  114.12 - * by Sun in the LICENSE file that accompanied this code.
  114.13 - *
  114.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  114.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  114.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  114.17 - * version 2 for more details (a copy is included in the LICENSE file that
  114.18 - * accompanied this code).
  114.19 - *
  114.20 - * You should have received a copy of the GNU General Public License version
  114.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  114.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  114.23 - *
  114.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  114.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  114.26 - * have any questions.
  114.27 - */
  114.28 -
  114.29 -#ifdef HEADLESS
  114.30 -    #error This file should not be included in headless library
  114.31 -#endif
  114.32 -
  114.33 -#include "awt_p.h"
  114.34 -
  114.35 -#include <X11/Xproto.h>
  114.36 -#include <X11/Xlib.h>
  114.37 -#include <X11/Xatom.h>
  114.38 -#include <Xm/MwmUtil.h>
  114.39 -
  114.40 -/* JNI headers */
  114.41 -#include "java_awt_Frame.h"     /* for frame state constants */
  114.42 -
  114.43 -#include "awt_wm.h"
  114.44 -#include "awt_util.h"           /* for X11 error handling macros */
  114.45 -#include "awt_xembed.h"
  114.46 -#include "awt_MToolkit.h"
  114.47 -#include "awt_DataTransferer.h"   /* for DECLARE_XXX macros */
  114.48 -
  114.49 -#ifdef DOTRACE
  114.50 -#define MTRACE(param) fprintf(myerr, param)
  114.51 -#define MTRACEP1(format, p1) fprintf(myerr, format, p1)
  114.52 -#define MTRACEP2(format, p1, p2) fprintf(myerr, format, p1, p2)
  114.53 -#define MTRACEP3(format, p1, p2, p3) fprintf(myerr, format, p1, p2, p3)
  114.54 -#define MTRACEP4(format, p1, p2, p3, p4) fprintf(myerr, format, p1, p2, p3, p4)
  114.55 -#define MTRACEP5(format, p1, p2, p3, p4, p5) fprintf(myerr, format, p1, p2, p3, p4, p5)
  114.56 -#define MTRACEP6(format, p1, p2, p3, p4, p5, p6) fprintf(myerr, format, p1, p2, p3, p4, p5, p6)
  114.57 -#define MTRACEP7(format, p1, p2, p3, p4, p5, p6, p7) fprintf(myerr, format, p1, p2, p3, p4, p5, p6, p7)
  114.58 -#else
  114.59 -#define MTRACE(param)
  114.60 -#define MTRACEP1(format, p1)
  114.61 -#define MTRACEP2(format, p1, p2)
  114.62 -#define MTRACEP3(format, p1, p2, p3)
  114.63 -#define MTRACEP4(format, p1, p2, p3, p4)
  114.64 -#define MTRACEP5(format, p1, p2, p3, p4, p5)
  114.65 -#define MTRACEP6(format, p1, p2, p3, p4, p5, p6)
  114.66 -#define MTRACEP7(format, p1, p2, p3, p4, p5, p6, p7)
  114.67 -#endif
  114.68 -
  114.69 -#ifdef DOTRACE
  114.70 -static FILE* myerr;
  114.71 -#endif
  114.72 -
  114.73 -static Window getParent(Window window);
  114.74 -static Window getEmbedder(Window client);
  114.75 -static jmethodID handleFocusInMID;
  114.76 -
  114.77 -const char * error_msg = "UNKNOWN XEMBED MESSAGE";
  114.78 -
  114.79 -const char * xembed_strs[] = {
  114.80 -    "EMBEDDED_NOTIFY",
  114.81 -    "WINDOW_ACTIVATE",
  114.82 -    "WINDOW_DEACTIVATE",
  114.83 -    "REQUEST_FOCUS",
  114.84 -    "FOCUS_IN",
  114.85 -    "FOCUS_OUT",
  114.86 -    "FOCUS_NEXT",
  114.87 -    "FOCUS_PREV" ,
  114.88 -    "GRAB_KEY",
  114.89 -    "UNGRAB_KEY",
  114.90 -    "MODALITY_ON" ,
  114.91 -    "MODALITY_OFF",
  114.92 -    "REGISTER_ACCELERATOR",
  114.93 -    "UNREGISTER_ACCELERATOR",
  114.94 -    "ACTIVATE_ACCELERATOR"
  114.95 -};
  114.96 -
  114.97 -const char *
  114.98 -msg_to_str(int msg) {
  114.99 -    if (msg >= 0 && msg <= XEMBED_LAST_MSG) {
 114.100 -        return xembed_strs[msg];
 114.101 -    } else {
 114.102 -        return error_msg;
 114.103 -    }
 114.104 -}
 114.105 -
 114.106 -DECLARE_JAVA_CLASS(MEmbeddedFramePeerClass, "sun/awt/motif/MEmbeddedFramePeer");
 114.107 -
 114.108 -typedef struct _xembed_info {
 114.109 -    CARD32 version;
 114.110 -    CARD32 flags;
 114.111 -} xembed_info;
 114.112 -
 114.113 -typedef struct _xembed_data {
 114.114 -    struct FrameData * wdata; // pointer to EmbeddedFrame wdata
 114.115 -    Window client; // pointer to plugin intermediate widget, XEmbed client
 114.116 -    Boolean active; // whether xembed is active for this client
 114.117 -    Boolean applicationActive; // whether the embedding application is active
 114.118 -    Window embedder; // Window ID of the embedder
 114.119 -    struct _xembed_data * next;
 114.120 -} xembed_data, * pxembed_data;
 114.121 -
 114.122 -static pxembed_data xembed_list = NULL;
 114.123 -
 114.124 -static pxembed_data
 114.125 -getData(Window client) {
 114.126 -    pxembed_data temp = xembed_list;
 114.127 -    while (temp != NULL) {
 114.128 -        if (temp->client == client) {
 114.129 -            return temp;
 114.130 -        }
 114.131 -        temp = temp->next;
 114.132 -    }
 114.133 -    return NULL;
 114.134 -}
 114.135 -
 114.136 -static pxembed_data
 114.137 -getDataByFrame(struct FrameData* wdata) {
 114.138 -    pxembed_data temp = xembed_list;
 114.139 -    while (temp != NULL) {
 114.140 -        if (temp->wdata == wdata) {
 114.141 -            return temp;
 114.142 -        }
 114.143 -        temp = temp->next;
 114.144 -    }
 114.145 -    return NULL;
 114.146 -}
 114.147 -
 114.148 -static pxembed_data
 114.149 -addData(Window client) {
 114.150 -    xembed_data * data = malloc(sizeof(xembed_data));
 114.151 -    memset(data, 0, sizeof(xembed_data));
 114.152 -    data->client = client;
 114.153 -    data->next = xembed_list;
 114.154 -    xembed_list = data;
 114.155 -    return data;
 114.156 -}
 114.157 -
 114.158 -static void
 114.159 -removeData(Window client) {
 114.160 -    pxembed_data * temp = &xembed_list;
 114.161 -    while (*temp != NULL) {
 114.162 -        if ((*temp)->client == client) {
 114.163 -            xembed_data * data = *temp;
 114.164 -            *temp = (*temp)->next;
 114.165 -            free(data);
 114.166 -            return;
 114.167 -        }
 114.168 -        temp = &(*temp)->next;
 114.169 -    }
 114.170 -}
 114.171 -
 114.172 -static Atom XA_XEmbedInfo;
 114.173 -static Atom XA_XEmbed;
 114.174 -
 114.175 -void
 114.176 -init_xembed() {
 114.177 -    XA_XEmbedInfo = XInternAtom(awt_display, "_XEMBED_INFO", False);
 114.178 -    XA_XEmbed = XInternAtom(awt_display, "_XEMBED", False);
 114.179 -#ifdef DOTRACE
 114.180 -    myerr = fopen("xembedclient.log","w");
 114.181 -#endif
 114.182 -}
 114.183 -
 114.184 -static Time
 114.185 -getCurrentServerTime() {
 114.186 -    return awt_util_getCurrentServerTime();
 114.187 -}
 114.188 -
 114.189 -
 114.190 -void
 114.191 -sendMessageHelper(Window window, int message, long detail,
 114.192 -                              long data1, long data2)
 114.193 -{
 114.194 -    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 114.195 -    XEvent ev;
 114.196 -    XClientMessageEvent * req = (XClientMessageEvent*)&ev;
 114.197 -    memset(&ev, 0, sizeof(ev));
 114.198 -
 114.199 -    req->type = ClientMessage;
 114.200 -    req->window = window;
 114.201 -    req->message_type = XA_XEmbed;
 114.202 -    req->format = 32;
 114.203 -    req->data.l[0] = getCurrentServerTime();
 114.204 -    req->data.l[1] = message;
 114.205 -    req->data.l[2] = detail;
 114.206 -    req->data.l[3] = data1;
 114.207 -    req->data.l[4] = data2;
 114.208 -    AWT_LOCK();
 114.209 -    XSendEvent(awt_display, window, False, NoEventMask, &ev);
 114.210 -    AWT_UNLOCK();
 114.211 -}
 114.212 -
 114.213 -void
 114.214 -sendMessage(Window window, int message) {
 114.215 -    sendMessageHelper(window, message, 0, 0, 0);
 114.216 -}
 114.217 -
 114.218 -
 114.219 -static Window
 114.220 -getParent(Window window) {
 114.221 -    Window root, parent = None, *children = NULL;
 114.222 -    unsigned int count;
 114.223 -    XQueryTree(awt_display, window, &root, &parent, &children, &count);
 114.224 -    if (children != NULL) {
 114.225 -        XFree(children);
 114.226 -    }
 114.227 -    return parent;
 114.228 -}
 114.229 -
 114.230 -static Window
 114.231 -getEmbedder(Window client) {
 114.232 -    return getParent(client);
 114.233 -}
 114.234 -
 114.235 -
 114.236 -static void
 114.237 -handleFocusIn(struct FrameData* wdata, int detail) {
 114.238 -    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 114.239 -    struct WidgetInfo* winfo;
 114.240 -    MTRACE("HandleFocusIn\n");
 114.241 -    winfo = findWidgetInfo(wdata->winData.comp.widget);
 114.242 -    if (winfo != NULL) {
 114.243 -        jobject peer = winfo->peer;
 114.244 -        if (handleFocusInMID == NULL) {
 114.245 -            jclass clazz = (*env)->FindClass(env, "sun/awt/motif/MEmbeddedFramePeer");
 114.246 -            DASSERT(clazz != NULL);
 114.247 -            handleFocusInMID = (*env)->GetMethodID(env, clazz, "handleFocusIn", "(I)V");
 114.248 -            DASSERT(handleFocusInMID != NULL);
 114.249 -            if (clazz != NULL) {
 114.250 -                (*env)->DeleteLocalRef(env, clazz);
 114.251 -            }
 114.252 -        }
 114.253 -        if (handleFocusInMID != NULL) {
 114.254 -            (*env)->CallVoidMethod(env, peer, handleFocusInMID, (jint)detail);
 114.255 -        }
 114.256 -    }
 114.257 -}
 114.258 -
 114.259 -static void
 114.260 -genWindowFocus(struct FrameData *wdata, Boolean gain) {
 114.261 -    XEvent ev;
 114.262 -    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 114.263 -    memset(&ev, 0, sizeof(ev));
 114.264 -
 114.265 -    ev.type = (gain?FocusIn:FocusOut);
 114.266 -    ev.xany.send_event = True;
 114.267 -    ev.xany.display = awt_display;
 114.268 -    ev.xfocus.mode = NotifyNormal;
 114.269 -    ev.xfocus.detail = NotifyNonlinear;
 114.270 -    ev.xfocus.window = XtWindow(wdata->winData.shell);
 114.271 -    awt_put_back_event(env, &ev);
 114.272 -}
 114.273 -
 114.274 -extern Boolean skipNextFocusIn;
 114.275 -
 114.276 -static void
 114.277 -callNotifyStarted(JNIEnv* env, jobject peer) {
 114.278 -    DECLARE_VOID_JAVA_METHOD(notifyStartedMID, MEmbeddedFramePeerClass,
 114.279 -                             "notifyStarted", "()V");
 114.280 -
 114.281 -    (*env)->CallVoidMethod(env, peer, notifyStartedMID);
 114.282 -}
 114.283 -
 114.284 -void
 114.285 -xembed_eventHandler(XEvent *event)
 114.286 -{
 114.287 -    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 114.288 -    struct FrameData *wdata;
 114.289 -    xembed_data * data;
 114.290 -
 114.291 -    data = getData(event->xany.window);
 114.292 -    if (data == NULL) {
 114.293 -        MTRACEP1("No XEMBED client registered for this window %x\n", event->xany.window);
 114.294 -        if (event->xany.type == ClientMessage) {
 114.295 -            MTRACEP7("Unprocessed handleClientMessage: type=%d 0=%ld 1=%ld(%s) 2=%ld 3=%ld 4=%ld\n",
 114.296 -                     event->xclient.message_type, event->xclient.data.l[0],
 114.297 -                     event->xclient.data.l[1], msg_to_str(event->xclient.data.l[1]),
 114.298 -                     event->xclient.data.l[2],
 114.299 -                     event->xclient.data.l[3], event->xclient.data.l[4]);
 114.300 -        }
 114.301 -        return;
 114.302 -    }
 114.303 -
 114.304 -    wdata = data->wdata;
 114.305 -
 114.306 -    if (event->xany.type == ClientMessage) {
 114.307 -        MTRACEP6("handleClientMessage: type=%d 0=%ld 1=%ld 2=%ld 3=%ld 4=%ld\n",
 114.308 -                 event->xclient.message_type, event->xclient.data.l[0],
 114.309 -                 event->xclient.data.l[1], event->xclient.data.l[2],
 114.310 -                 event->xclient.data.l[3], event->xclient.data.l[4]);
 114.311 -        // Probably a message from embedder
 114.312 -        if (event->xclient.message_type == XA_XEmbed) {
 114.313 -            // XEmbed message, data[1] contains message
 114.314 -            switch ((int)event->xclient.data.l[1]) {
 114.315 -              case XEMBED_EMBEDDED_NOTIFY:
 114.316 -                  MTRACE("EMBEDDED_NOTIFY\n");
 114.317 -                  data->active = True;
 114.318 -                  data->embedder = getEmbedder(data->client);
 114.319 -                  // If Frame has not been reparented already we should "reparent"
 114.320 -                  // it manually
 114.321 -                  if (!(wdata->reparented)) {
 114.322 -                      wdata->reparented = True;
 114.323 -                      // in XAWT we also update WM_NORMAL_HINTS here.
 114.324 -                  }
 114.325 -                  {
 114.326 -                      struct WidgetInfo* winfo =
 114.327 -                          findWidgetInfo(wdata->winData.comp.widget);
 114.328 -                      JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_4);
 114.329 -                      if (winfo != NULL) {
 114.330 -                          callNotifyStarted(env, winfo->peer);
 114.331 -                      }
 114.332 -                  }
 114.333 -                  MTRACE("Embedded notify in client\n");
 114.334 -                  break;
 114.335 -              case XEMBED_WINDOW_DEACTIVATE:
 114.336 -                  MTRACE("DEACTIVATE\n");
 114.337 -                  data->applicationActive = False;
 114.338 -                  break;
 114.339 -              case XEMBED_WINDOW_ACTIVATE:
 114.340 -                  MTRACE("ACTIVATE\n");
 114.341 -                  data->applicationActive = True;
 114.342 -                  break;
 114.343 -              case XEMBED_FOCUS_IN:
 114.344 -                  MTRACE("FOCUS IN\n");
 114.345 -                  skipNextFocusIn = False;
 114.346 -                  handleFocusIn(wdata, (int)(event->xclient.data.l[2]));
 114.347 -                  genWindowFocus(wdata, True);
 114.348 -                  break;
 114.349 -              case XEMBED_FOCUS_OUT:
 114.350 -                  MTRACE("FOCUS OUT\n");
 114.351 -                  genWindowFocus(wdata, False);
 114.352 -                  break;
 114.353 -            }
 114.354 -        }
 114.355 -    } else if (event->xany.type == ReparentNotify) {
 114.356 -        data->embedder = event->xreparent.parent;
 114.357 -    }
 114.358 -}
 114.359 -
 114.360 -void
 114.361 -notify_ready(Window client) {
 114.362 -    sendMessage(getEmbedder(client), _SUN_XEMBED_START);
 114.363 -}
 114.364 -
 114.365 -void
 114.366 -install_xembed(Widget client_widget, struct FrameData* wdata) {
 114.367 -    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 114.368 -    xembed_info info = {XEMBED_VERSION, XEMBED_MAPPED};
 114.369 -    Window client = XtWindow(client_widget);
 114.370 -    xembed_data * data;
 114.371 -
 114.372 -    AWT_LOCK();
 114.373 -    data = addData(client);
 114.374 -    data->wdata = wdata;
 114.375 -
 114.376 -    // Install event handler for messages from embedder
 114.377 -    XSelectInput(awt_display, client, StructureNotifyMask);
 114.378 -
 114.379 -    // Install XEMBED_INFO information
 114.380 -    XChangeProperty(awt_display, client, XA_XEmbedInfo,
 114.381 -                    XA_XEmbedInfo, 32, PropModeReplace,
 114.382 -                    (unsigned char*)&info, 2);
 114.383 -    MTRACE("Installing xembed\n");
 114.384 -
 114.385 -    notify_ready(client);
 114.386 -
 114.387 -    AWT_UNLOCK();
 114.388 -}
 114.389 -
 114.390 -void
 114.391 -deinstall_xembed(struct FrameData* wdata) {
 114.392 -    xembed_data * data = getDataByFrame(wdata);
 114.393 -
 114.394 -    if (data != NULL) {
 114.395 -        removeData(data->client);
 114.396 -    }
 114.397 -}
 114.398 -
 114.399 -void
 114.400 -requestXEmbedFocus(struct FrameData * wdata) {
 114.401 -    xembed_data * data = getDataByFrame(wdata);
 114.402 -
 114.403 -    if (data != NULL) {
 114.404 -        if (data->active && data->applicationActive) {
 114.405 -            sendMessage(data->embedder, XEMBED_REQUEST_FOCUS);
 114.406 -        }
 114.407 -    }
 114.408 -}
 114.409 -
 114.410 -Boolean
 114.411 -isXEmbedActive(struct FrameData * wdata) {
 114.412 -    xembed_data * data = getDataByFrame(wdata);
 114.413 -    return (data != NULL && data->active);
 114.414 -}
 114.415 -
 114.416 -Boolean
 114.417 -isXEmbedActiveByWindow(Window client) {
 114.418 -    xembed_data * data = getData(client);
 114.419 -    return (data != NULL && data->active);
 114.420 -}
 114.421 -
 114.422 -
 114.423 -Boolean
 114.424 -isXEmbedApplicationActive(struct FrameData * wdata) {
 114.425 -    xembed_data * data = getDataByFrame(wdata);
 114.426 -    return (data != NULL && data->applicationActive);
 114.427 -}
 114.428 -
 114.429 -void
 114.430 -xembed_traverse_out(struct FrameData * wdata, jboolean direction) {
 114.431 -    xembed_data * data = getDataByFrame(wdata);
 114.432 -    sendMessage(data->embedder, (direction == JNI_TRUE)?XEMBED_FOCUS_NEXT:XEMBED_FOCUS_PREV);
 114.433 -}
   115.1 --- a/src/solaris/native/sun/awt/canvas.c	Wed Sep 17 13:45:37 2008 -0700
   115.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   115.3 @@ -1,3227 +0,0 @@
   115.4 -/*
   115.5 - * Copyright 1995-2005 Sun Microsystems, Inc.  All Rights Reserved.
   115.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   115.7 - *
   115.8 - * This code is free software; you can redistribute it and/or modify it
   115.9 - * under the terms of the GNU General Public License version 2 only, as
  115.10 - * published by the Free Software Foundation.  Sun designates this
  115.11 - * particular file as subject to the "Classpath" exception as provided
  115.12 - * by Sun in the LICENSE file that accompanied this code.
  115.13 - *
  115.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  115.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  115.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  115.17 - * version 2 for more details (a copy is included in the LICENSE file that
  115.18 - * accompanied this code).
  115.19 - *
  115.20 - * You should have received a copy of the GNU General Public License version
  115.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  115.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  115.23 - *
  115.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  115.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  115.26 - * have any questions.
  115.27 - */
  115.28 -
  115.29 -#ifdef HEADLESS
  115.30 -    #error This file should not be included in headless library
  115.31 -#endif
  115.32 -
  115.33 -#include "awt_p.h"
  115.34 -#include <sys/time.h> /* timeval */
  115.35 -
  115.36 -#define XK_KATAKANA
  115.37 -#include <X11/keysym.h>     /* standard X keysyms */
  115.38 -#include <X11/DECkeysym.h>  /* DEC vendor-specific */
  115.39 -#include <X11/Sunkeysym.h>  /* Sun vendor-specific */
  115.40 -#include <X11/ap_keysym.h>  /* Apollo (HP) vendor-specific */
  115.41 -/*
  115.42 - * #include <X11/HPkeysym.h>    HP vendor-specific
  115.43 - * I checked HPkeysym.h into the workspace because it ships
  115.44 - * with X11R6.4.2 (and later) but not with X11R6.4.1.
  115.45 - * So, it ought to ship with Solaris 9, but not Solaris 8.
  115.46 - * Same deal for Linux - newer versions of XFree have it.
  115.47 - *
  115.48 - * Note: this is mainly done for the hp keysyms; it does NOT
  115.49 - * give us the osf keysyms that are also defined in HPkeysym.h.
  115.50 - * This is because we are already getting /Xm/VirtKeys.h
  115.51 - * from awt_p.h <- /Xm/Xm.h <- /Xm/VirtKeys.h, and VirtKeys.h
  115.52 - * #defines _OSF_Keysyms before we get here.  We are
  115.53 - * missing a couple of osf keysyms because of this,
  115.54 - * so I have #defined them below.
  115.55 - */
  115.56 -#include "HPkeysym.h"   /* HP vendor-specific */
  115.57 -
  115.58 -#include <Xm/Display.h>
  115.59 -#include <ctype.h>
  115.60 -#include "java_awt_Frame.h"
  115.61 -#include "java_awt_Component.h"
  115.62 -#include "java_awt_AWTEvent.h"
  115.63 -#include "java_awt_event_KeyEvent.h"
  115.64 -#include "java_awt_event_FocusEvent.h"
  115.65 -#include "java_awt_event_MouseEvent.h"
  115.66 -#include "java_awt_event_MouseWheelEvent.h"
  115.67 -#include "java_awt_event_InputEvent.h"
  115.68 -#include "java_awt_event_WindowEvent.h"
  115.69 -#include "sun_awt_motif_MComponentPeer.h"
  115.70 -#include "color.h"
  115.71 -#include "canvas.h"
  115.72 -#include "awt_Cursor.h"
  115.73 -#include "VDrawingArea.h"
  115.74 -#include "XDrawingArea.h"
  115.75 -#include "awt_Component.h"
  115.76 -#include "awt_AWTEvent.h"
  115.77 -#include "awt_Event.h"
  115.78 -#include "awt_KeyboardFocusManager.h"
  115.79 -#include "awt_MToolkit.h"
  115.80 -#include "awt_TopLevel.h"
  115.81 -#include "awt_util.h"
  115.82 -
  115.83 -#include <jni.h>
  115.84 -#include <jni_util.h>
  115.85 -#include <jvm.h>
  115.86 -#include <jawt.h>
  115.87 -
  115.88 -#ifdef NDEBUG   /* NDEBUG overrides DEBUG */
  115.89 -#undef DEBUG
  115.90 -#endif
  115.91 -
  115.92 -/*
  115.93 - * Two osf keys are not defined in standard keysym.h,
  115.94 - * /Xm/VirtKeys.h, or HPkeysym.h, so I added them below.
  115.95 - * I found them in /usr/openwin/lib/X11/XKeysymDB
  115.96 - */
  115.97 -#ifndef osfXK_Prior
  115.98 -#define osfXK_Prior 0x1004FF55
  115.99 -#endif
 115.100 -#ifndef osfXK_Next
 115.101 -#define osfXK_Next 0x1004FF56
 115.102 -#endif
 115.103 -/*
 115.104 - * osfXK_Escape is defined in HPkeysym.h, but not in
 115.105 - * /Xm/VirtKeys.h, so I added it below.  It is also in
 115.106 - * /usr/openwin/lib/X11/XKeysymDB
 115.107 - * Note: it is in /Xm/VirtKeys.h in the AWT motif workspace,
 115.108 - * but not in /usr/local/Motif/include/Xm/VirtKeys.h
 115.109 - * on the Solaris 7, 8, or 9 machines I tried.
 115.110 - */
 115.111 -#ifndef osfXK_Escape
 115.112 -#define osfXK_Escape 0x1004FF1B
 115.113 -#endif
 115.114 -
 115.115 -extern struct MComponentPeerIDs mComponentPeerIDs;
 115.116 -extern struct AWTEventIDs awtEventIDs;
 115.117 -extern struct KeyEventIDs keyEventIDs;
 115.118 -extern struct InputEventIDs inputEventIDs;
 115.119 -extern struct ComponentIDs componentIDs;
 115.120 -extern struct KeyboardFocusManagerIDs keyboardFocusManagerIDs;
 115.121 -
 115.122 -#ifdef DEBUG
 115.123 -static Boolean debugKeys = False;
 115.124 -#endif
 115.125 -
 115.126 -jint awt_multiclick_smudge = 4;
 115.127 -
 115.128 -extern Widget drag_source;
 115.129 -
 115.130 -Widget prevWidget = NULL; /* for bug fix 4017222 */
 115.131 -
 115.132 -FocusListElt *focusList = NULL, *focusListEnd = NULL;
 115.133 -
 115.134 -jweak forGained = NULL;
 115.135 -
 115.136 -extern Boolean scrollBugWorkAround;
 115.137 -extern jobject currentX11InputMethodInstance;
 115.138 -extern Window  currentFocusWindow;
 115.139 -extern Boolean awt_x11inputmethod_lookupString(XKeyPressedEvent *, KeySym *);
 115.140 -Boolean awt_UseType4Patch = True;
 115.141 -Boolean awt_ServerDetected = False;
 115.142 -Boolean awt_IsXsun = False;
 115.143 -Boolean awt_UseXKB = False;
 115.144 -
 115.145 -void awt_post_java_key_event(XtPointer client_data, jint id,
 115.146 -                             XEvent *xevent, Time when, jint keycode,
 115.147 -                             jchar keychar, jint modifiers,
 115.148 -                             jint keyLocation, XEvent *anEvent);
 115.149 -void awt_post_java_focus_event(XtPointer client_data, jint id, jobject cause,
 115.150 -                               XEvent *event);
 115.151 -void awt_post_java_mouse_event(XtPointer client_data, jint id,
 115.152 -                               XEvent *event, Time when, jint modifiers,
 115.153 -                               jint x, jint y,
 115.154 -                               jint xAbs, jint yAbs,
 115.155 -                               jint clickcount, Boolean popuptrigger,
 115.156 -                               jint wheelAmt, jint button);
 115.157 -
 115.158 -typedef struct KEYMAP_ENTRY {
 115.159 -    jint awtKey;
 115.160 -    KeySym x11Key;
 115.161 -    Boolean mapsToUnicodeChar;
 115.162 -    jint keyLocation;
 115.163 -} KeymapEntry;
 115.164 -
 115.165 -/* NB: XK_R? keysyms are for Type 4 keyboards.
 115.166 - * The corresponding XK_F? keysyms are for Type 5
 115.167 - *
 115.168 - * Note: this table must be kept in sorted order, since it is traversed
 115.169 - * according to both Java keycode and X keysym.  There are a number of
 115.170 - * keycodes that map to more than one corresponding keysym, and we need
 115.171 - * to choose the right one.  Unfortunately, there are some keysyms that
 115.172 - * can map to more than one keycode, depending on what kind of keyboard
 115.173 - * is in use (e.g. F11 and F12).
 115.174 - */
 115.175 -
 115.176 -KeymapEntry keymapTable[] =
 115.177 -{
 115.178 -    {java_awt_event_KeyEvent_VK_A, XK_a, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.179 -    {java_awt_event_KeyEvent_VK_B, XK_b, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.180 -    {java_awt_event_KeyEvent_VK_C, XK_c, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.181 -    {java_awt_event_KeyEvent_VK_D, XK_d, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.182 -    {java_awt_event_KeyEvent_VK_E, XK_e, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.183 -    {java_awt_event_KeyEvent_VK_F, XK_f, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.184 -    {java_awt_event_KeyEvent_VK_G, XK_g, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.185 -    {java_awt_event_KeyEvent_VK_H, XK_h, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.186 -    {java_awt_event_KeyEvent_VK_I, XK_i, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.187 -    {java_awt_event_KeyEvent_VK_J, XK_j, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.188 -    {java_awt_event_KeyEvent_VK_K, XK_k, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.189 -    {java_awt_event_KeyEvent_VK_L, XK_l, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.190 -    {java_awt_event_KeyEvent_VK_M, XK_m, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.191 -    {java_awt_event_KeyEvent_VK_N, XK_n, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.192 -    {java_awt_event_KeyEvent_VK_O, XK_o, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.193 -    {java_awt_event_KeyEvent_VK_P, XK_p, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.194 -    {java_awt_event_KeyEvent_VK_Q, XK_q, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.195 -    {java_awt_event_KeyEvent_VK_R, XK_r, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.196 -    {java_awt_event_KeyEvent_VK_S, XK_s, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.197 -    {java_awt_event_KeyEvent_VK_T, XK_t, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.198 -    {java_awt_event_KeyEvent_VK_U, XK_u, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.199 -    {java_awt_event_KeyEvent_VK_V, XK_v, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.200 -    {java_awt_event_KeyEvent_VK_W, XK_w, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.201 -    {java_awt_event_KeyEvent_VK_X, XK_x, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.202 -    {java_awt_event_KeyEvent_VK_Y, XK_y, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.203 -    {java_awt_event_KeyEvent_VK_Z, XK_z, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.204 -
 115.205 -    /* TTY Function keys */
 115.206 -    {java_awt_event_KeyEvent_VK_BACK_SPACE, XK_BackSpace, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.207 -    {java_awt_event_KeyEvent_VK_TAB, XK_Tab, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.208 -    {java_awt_event_KeyEvent_VK_CLEAR, XK_Clear, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.209 -    {java_awt_event_KeyEvent_VK_ENTER, XK_Return, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.210 -    {java_awt_event_KeyEvent_VK_ENTER, XK_Linefeed, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.211 -    {java_awt_event_KeyEvent_VK_PAUSE, XK_Pause, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.212 -    {java_awt_event_KeyEvent_VK_PAUSE, XK_F21, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.213 -    {java_awt_event_KeyEvent_VK_PAUSE, XK_R1, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.214 -    {java_awt_event_KeyEvent_VK_SCROLL_LOCK, XK_Scroll_Lock, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.215 -    {java_awt_event_KeyEvent_VK_SCROLL_LOCK, XK_F23, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.216 -    {java_awt_event_KeyEvent_VK_SCROLL_LOCK, XK_R3, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.217 -    {java_awt_event_KeyEvent_VK_ESCAPE, XK_Escape, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.218 -
 115.219 -    /* Other vendor-specific versions of TTY Function keys */
 115.220 -    {java_awt_event_KeyEvent_VK_BACK_SPACE, osfXK_BackSpace, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.221 -    {java_awt_event_KeyEvent_VK_CLEAR, osfXK_Clear, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.222 -    {java_awt_event_KeyEvent_VK_ESCAPE, osfXK_Escape, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.223 -
 115.224 -    /* Modifier keys */
 115.225 -    {java_awt_event_KeyEvent_VK_SHIFT, XK_Shift_L, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_LEFT},
 115.226 -    {java_awt_event_KeyEvent_VK_SHIFT, XK_Shift_R, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_RIGHT},
 115.227 -    {java_awt_event_KeyEvent_VK_CONTROL, XK_Control_L, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_LEFT},
 115.228 -    {java_awt_event_KeyEvent_VK_CONTROL, XK_Control_R, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_RIGHT},
 115.229 -    {java_awt_event_KeyEvent_VK_ALT, XK_Alt_L, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_LEFT},
 115.230 -    {java_awt_event_KeyEvent_VK_ALT, XK_Alt_R, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_RIGHT},
 115.231 -    {java_awt_event_KeyEvent_VK_META, XK_Meta_L, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_LEFT},
 115.232 -    {java_awt_event_KeyEvent_VK_META, XK_Meta_R, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_RIGHT},
 115.233 -    {java_awt_event_KeyEvent_VK_CAPS_LOCK, XK_Caps_Lock, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.234 -
 115.235 -    /* Misc Functions */
 115.236 -    {java_awt_event_KeyEvent_VK_PRINTSCREEN, XK_Print, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.237 -    {java_awt_event_KeyEvent_VK_PRINTSCREEN, XK_F22, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.238 -    {java_awt_event_KeyEvent_VK_PRINTSCREEN, XK_R2, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.239 -    {java_awt_event_KeyEvent_VK_CANCEL, XK_Cancel, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.240 -    {java_awt_event_KeyEvent_VK_HELP, XK_Help, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.241 -    {java_awt_event_KeyEvent_VK_NUM_LOCK, XK_Num_Lock, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.242 -
 115.243 -    /* Other vendor-specific versions of Misc Functions */
 115.244 -    {java_awt_event_KeyEvent_VK_CANCEL, osfXK_Cancel, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.245 -    {java_awt_event_KeyEvent_VK_HELP, osfXK_Help, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.246 -
 115.247 -    /* Rectangular Navigation Block */
 115.248 -    {java_awt_event_KeyEvent_VK_HOME, XK_Home, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.249 -    {java_awt_event_KeyEvent_VK_HOME, XK_R7, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.250 -    {java_awt_event_KeyEvent_VK_PAGE_UP, XK_Page_Up, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.251 -    {java_awt_event_KeyEvent_VK_PAGE_UP, XK_Prior, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.252 -    {java_awt_event_KeyEvent_VK_PAGE_UP, XK_R9, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.253 -    {java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_Page_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.254 -    {java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_Next, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.255 -    {java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_R15, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.256 -    {java_awt_event_KeyEvent_VK_END, XK_End, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.257 -    {java_awt_event_KeyEvent_VK_END, XK_R13, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.258 -    {java_awt_event_KeyEvent_VK_INSERT, XK_Insert, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.259 -    {java_awt_event_KeyEvent_VK_DELETE, XK_Delete, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.260 -
 115.261 -    /* Keypad equivalents of Rectangular Navigation Block */
 115.262 -    {java_awt_event_KeyEvent_VK_HOME, XK_KP_Home, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.263 -    {java_awt_event_KeyEvent_VK_PAGE_UP, XK_KP_Page_Up, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.264 -    {java_awt_event_KeyEvent_VK_PAGE_UP, XK_KP_Prior, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.265 -    {java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_KP_Page_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.266 -    {java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_KP_Next, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.267 -    {java_awt_event_KeyEvent_VK_END, XK_KP_End, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.268 -    {java_awt_event_KeyEvent_VK_INSERT, XK_KP_Insert, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.269 -    {java_awt_event_KeyEvent_VK_DELETE, XK_KP_Delete, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.270 -
 115.271 -    /* Other vendor-specific Rectangular Navigation Block */
 115.272 -    {java_awt_event_KeyEvent_VK_PAGE_UP, osfXK_PageUp, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.273 -    {java_awt_event_KeyEvent_VK_PAGE_UP, osfXK_Prior, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.274 -    {java_awt_event_KeyEvent_VK_PAGE_DOWN, osfXK_PageDown, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.275 -    {java_awt_event_KeyEvent_VK_PAGE_DOWN, osfXK_Next, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.276 -    {java_awt_event_KeyEvent_VK_END, osfXK_EndLine, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.277 -    {java_awt_event_KeyEvent_VK_INSERT, osfXK_Insert, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.278 -    {java_awt_event_KeyEvent_VK_DELETE, osfXK_Delete, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.279 -
 115.280 -    /* Triangular Navigation Block */
 115.281 -    {java_awt_event_KeyEvent_VK_LEFT, XK_Left, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.282 -    {java_awt_event_KeyEvent_VK_UP, XK_Up, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.283 -    {java_awt_event_KeyEvent_VK_RIGHT, XK_Right, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.284 -    {java_awt_event_KeyEvent_VK_DOWN, XK_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.285 -
 115.286 -    /* Keypad equivalents of Triangular Navigation Block */
 115.287 -    {java_awt_event_KeyEvent_VK_KP_LEFT, XK_KP_Left, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.288 -    {java_awt_event_KeyEvent_VK_KP_UP, XK_KP_Up, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.289 -    {java_awt_event_KeyEvent_VK_KP_RIGHT, XK_KP_Right, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.290 -    {java_awt_event_KeyEvent_VK_KP_DOWN, XK_KP_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.291 -
 115.292 -    /* Other vendor-specific Triangular Navigation Block */
 115.293 -    {java_awt_event_KeyEvent_VK_LEFT, osfXK_Left, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.294 -    {java_awt_event_KeyEvent_VK_UP, osfXK_Up, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.295 -    {java_awt_event_KeyEvent_VK_RIGHT, osfXK_Right, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.296 -    {java_awt_event_KeyEvent_VK_DOWN, osfXK_Down, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.297 -
 115.298 -    /* Remaining Cursor control & motion */
 115.299 -    {java_awt_event_KeyEvent_VK_BEGIN, XK_Begin, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.300 -    {java_awt_event_KeyEvent_VK_BEGIN, XK_KP_Begin, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.301 -
 115.302 -    {java_awt_event_KeyEvent_VK_0, XK_0, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.303 -    {java_awt_event_KeyEvent_VK_1, XK_1, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.304 -    {java_awt_event_KeyEvent_VK_2, XK_2, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.305 -    {java_awt_event_KeyEvent_VK_3, XK_3, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.306 -    {java_awt_event_KeyEvent_VK_4, XK_4, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.307 -    {java_awt_event_KeyEvent_VK_5, XK_5, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.308 -    {java_awt_event_KeyEvent_VK_6, XK_6, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.309 -    {java_awt_event_KeyEvent_VK_7, XK_7, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.310 -    {java_awt_event_KeyEvent_VK_8, XK_8, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.311 -    {java_awt_event_KeyEvent_VK_9, XK_9, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.312 -
 115.313 -    {java_awt_event_KeyEvent_VK_SPACE, XK_space, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.314 -    {java_awt_event_KeyEvent_VK_EXCLAMATION_MARK, XK_exclam, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.315 -    {java_awt_event_KeyEvent_VK_QUOTEDBL, XK_quotedbl, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.316 -    {java_awt_event_KeyEvent_VK_NUMBER_SIGN, XK_numbersign, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.317 -    {java_awt_event_KeyEvent_VK_DOLLAR, XK_dollar, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.318 -    {java_awt_event_KeyEvent_VK_AMPERSAND, XK_ampersand, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.319 -    {java_awt_event_KeyEvent_VK_QUOTE, XK_apostrophe, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.320 -    {java_awt_event_KeyEvent_VK_LEFT_PARENTHESIS, XK_parenleft, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.321 -    {java_awt_event_KeyEvent_VK_RIGHT_PARENTHESIS, XK_parenright, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.322 -    {java_awt_event_KeyEvent_VK_ASTERISK, XK_asterisk, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.323 -    {java_awt_event_KeyEvent_VK_PLUS, XK_plus, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.324 -    {java_awt_event_KeyEvent_VK_COMMA, XK_comma, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.325 -    {java_awt_event_KeyEvent_VK_MINUS, XK_minus, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.326 -    {java_awt_event_KeyEvent_VK_PERIOD, XK_period, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.327 -    {java_awt_event_KeyEvent_VK_SLASH, XK_slash, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.328 -
 115.329 -    {java_awt_event_KeyEvent_VK_COLON, XK_colon, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.330 -    {java_awt_event_KeyEvent_VK_SEMICOLON, XK_semicolon, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.331 -    {java_awt_event_KeyEvent_VK_LESS, XK_less, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.332 -    {java_awt_event_KeyEvent_VK_EQUALS, XK_equal, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.333 -    {java_awt_event_KeyEvent_VK_GREATER, XK_greater, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.334 -
 115.335 -    {java_awt_event_KeyEvent_VK_AT, XK_at, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.336 -
 115.337 -    {java_awt_event_KeyEvent_VK_OPEN_BRACKET, XK_bracketleft, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.338 -    {java_awt_event_KeyEvent_VK_BACK_SLASH, XK_backslash, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.339 -    {java_awt_event_KeyEvent_VK_CLOSE_BRACKET, XK_bracketright, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.340 -    {java_awt_event_KeyEvent_VK_CIRCUMFLEX, XK_asciicircum, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.341 -    {java_awt_event_KeyEvent_VK_UNDERSCORE, XK_underscore, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.342 -    {java_awt_event_KeyEvent_VK_BACK_QUOTE, XK_grave, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.343 -
 115.344 -    {java_awt_event_KeyEvent_VK_BRACELEFT, XK_braceleft, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.345 -    {java_awt_event_KeyEvent_VK_BRACERIGHT, XK_braceright, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.346 -
 115.347 -    {java_awt_event_KeyEvent_VK_INVERTED_EXCLAMATION_MARK, XK_exclamdown, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.348 -
 115.349 -    /* Remaining Numeric Keypad Keys */
 115.350 -    {java_awt_event_KeyEvent_VK_NUMPAD0, XK_KP_0, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.351 -    {java_awt_event_KeyEvent_VK_NUMPAD1, XK_KP_1, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.352 -    {java_awt_event_KeyEvent_VK_NUMPAD2, XK_KP_2, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.353 -    {java_awt_event_KeyEvent_VK_NUMPAD3, XK_KP_3, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.354 -    {java_awt_event_KeyEvent_VK_NUMPAD4, XK_KP_4, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.355 -    {java_awt_event_KeyEvent_VK_NUMPAD5, XK_KP_5, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.356 -    {java_awt_event_KeyEvent_VK_NUMPAD6, XK_KP_6, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.357 -    {java_awt_event_KeyEvent_VK_NUMPAD7, XK_KP_7, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.358 -    {java_awt_event_KeyEvent_VK_NUMPAD8, XK_KP_8, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.359 -    {java_awt_event_KeyEvent_VK_NUMPAD9, XK_KP_9, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.360 -    {java_awt_event_KeyEvent_VK_SPACE, XK_KP_Space, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.361 -    {java_awt_event_KeyEvent_VK_TAB, XK_KP_Tab, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.362 -    {java_awt_event_KeyEvent_VK_ENTER, XK_KP_Enter, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.363 -    {java_awt_event_KeyEvent_VK_EQUALS, XK_KP_Equal, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.364 -    {java_awt_event_KeyEvent_VK_EQUALS, XK_R4, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.365 -    {java_awt_event_KeyEvent_VK_MULTIPLY, XK_KP_Multiply, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.366 -    {java_awt_event_KeyEvent_VK_MULTIPLY, XK_F26, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.367 -    {java_awt_event_KeyEvent_VK_MULTIPLY, XK_R6, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.368 -    {java_awt_event_KeyEvent_VK_ADD, XK_KP_Add, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.369 -    {java_awt_event_KeyEvent_VK_SEPARATOR, XK_KP_Separator, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.370 -    {java_awt_event_KeyEvent_VK_SUBTRACT, XK_KP_Subtract, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.371 -    {java_awt_event_KeyEvent_VK_SUBTRACT, XK_F24, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.372 -    {java_awt_event_KeyEvent_VK_DECIMAL, XK_KP_Decimal, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.373 -    {java_awt_event_KeyEvent_VK_DIVIDE, XK_KP_Divide, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.374 -    {java_awt_event_KeyEvent_VK_DIVIDE, XK_F25, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.375 -    {java_awt_event_KeyEvent_VK_DIVIDE, XK_R5, TRUE, java_awt_event_KeyEvent_KEY_LOCATION_NUMPAD},
 115.376 -
 115.377 -    /* Function Keys */
 115.378 -    {java_awt_event_KeyEvent_VK_F1, XK_F1, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.379 -    {java_awt_event_KeyEvent_VK_F2, XK_F2, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.380 -    {java_awt_event_KeyEvent_VK_F3, XK_F3, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.381 -    {java_awt_event_KeyEvent_VK_F4, XK_F4, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.382 -    {java_awt_event_KeyEvent_VK_F5, XK_F5, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.383 -    {java_awt_event_KeyEvent_VK_F6, XK_F6, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.384 -    {java_awt_event_KeyEvent_VK_F7, XK_F7, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.385 -    {java_awt_event_KeyEvent_VK_F8, XK_F8, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.386 -    {java_awt_event_KeyEvent_VK_F9, XK_F9, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.387 -    {java_awt_event_KeyEvent_VK_F10, XK_F10, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.388 -    {java_awt_event_KeyEvent_VK_F11, XK_F11, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.389 -    {java_awt_event_KeyEvent_VK_F12, XK_F12, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.390 -
 115.391 -    /* Sun vendor-specific version of F11 and F12 */
 115.392 -    {java_awt_event_KeyEvent_VK_F11, SunXK_F36, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.393 -    {java_awt_event_KeyEvent_VK_F12, SunXK_F37, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.394 -
 115.395 -    /* X11 keysym names for input method related keys don't always
 115.396 -     * match keytop engravings or Java virtual key names, so here we
 115.397 -     * only map constants that we've found on real keyboards.
 115.398 -     */
 115.399 -    /* Type 5c Japanese keyboard: kakutei */
 115.400 -    {java_awt_event_KeyEvent_VK_ACCEPT, XK_Execute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.401 -    /* Type 5c Japanese keyboard: henkan */
 115.402 -    {java_awt_event_KeyEvent_VK_CONVERT, XK_Kanji, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.403 -    /* Type 5c Japanese keyboard: nihongo */
 115.404 -    {java_awt_event_KeyEvent_VK_INPUT_METHOD_ON_OFF, XK_Henkan_Mode, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.405 -    /* VK_KANA_LOCK is handled separately because it generates the
 115.406 -     * same keysym as ALT_GRAPH in spite of its different behavior.
 115.407 -     */
 115.408 -
 115.409 -    {java_awt_event_KeyEvent_VK_COMPOSE, XK_Multi_key, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.410 -    {java_awt_event_KeyEvent_VK_ALT_GRAPH, XK_Mode_switch, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.411 -
 115.412 -    /* Editing block */
 115.413 -    {java_awt_event_KeyEvent_VK_AGAIN, XK_Redo, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.414 -    {java_awt_event_KeyEvent_VK_AGAIN, XK_L2, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.415 -    {java_awt_event_KeyEvent_VK_UNDO, XK_Undo, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.416 -    {java_awt_event_KeyEvent_VK_UNDO, XK_L4, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.417 -    {java_awt_event_KeyEvent_VK_COPY, XK_L6, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.418 -    {java_awt_event_KeyEvent_VK_PASTE, XK_L8, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.419 -    {java_awt_event_KeyEvent_VK_CUT, XK_L10, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.420 -    {java_awt_event_KeyEvent_VK_FIND, XK_Find, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.421 -    {java_awt_event_KeyEvent_VK_FIND, XK_L9, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.422 -    {java_awt_event_KeyEvent_VK_PROPS, XK_L3, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.423 -    {java_awt_event_KeyEvent_VK_STOP, XK_L1, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.424 -
 115.425 -    /* Sun vendor-specific versions for editing block */
 115.426 -    {java_awt_event_KeyEvent_VK_AGAIN, SunXK_Again, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.427 -    {java_awt_event_KeyEvent_VK_UNDO, SunXK_Undo, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.428 -    {java_awt_event_KeyEvent_VK_COPY, SunXK_Copy, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.429 -    {java_awt_event_KeyEvent_VK_PASTE, SunXK_Paste, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.430 -    {java_awt_event_KeyEvent_VK_CUT, SunXK_Cut, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.431 -    {java_awt_event_KeyEvent_VK_FIND, SunXK_Find, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.432 -    {java_awt_event_KeyEvent_VK_PROPS, SunXK_Props, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.433 -    {java_awt_event_KeyEvent_VK_STOP, SunXK_Stop, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.434 -
 115.435 -    /* Apollo (HP) vendor-specific versions for editing block */
 115.436 -    {java_awt_event_KeyEvent_VK_COPY, apXK_Copy, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.437 -    {java_awt_event_KeyEvent_VK_CUT, apXK_Cut, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.438 -    {java_awt_event_KeyEvent_VK_PASTE, apXK_Paste, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.439 -
 115.440 -    /* Other vendor-specific versions for editing block */
 115.441 -    {java_awt_event_KeyEvent_VK_COPY, osfXK_Copy, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.442 -    {java_awt_event_KeyEvent_VK_CUT, osfXK_Cut, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.443 -    {java_awt_event_KeyEvent_VK_PASTE, osfXK_Paste, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.444 -    {java_awt_event_KeyEvent_VK_UNDO, osfXK_Undo, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.445 -
 115.446 -    /* Dead key mappings (for European keyboards) */
 115.447 -    {java_awt_event_KeyEvent_VK_DEAD_GRAVE, XK_dead_grave, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.448 -    {java_awt_event_KeyEvent_VK_DEAD_ACUTE, XK_dead_acute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.449 -    {java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX, XK_dead_circumflex, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.450 -    {java_awt_event_KeyEvent_VK_DEAD_TILDE, XK_dead_tilde, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.451 -    {java_awt_event_KeyEvent_VK_DEAD_MACRON, XK_dead_macron, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.452 -    {java_awt_event_KeyEvent_VK_DEAD_BREVE, XK_dead_breve, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.453 -    {java_awt_event_KeyEvent_VK_DEAD_ABOVEDOT, XK_dead_abovedot, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.454 -    {java_awt_event_KeyEvent_VK_DEAD_DIAERESIS, XK_dead_diaeresis, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.455 -    {java_awt_event_KeyEvent_VK_DEAD_ABOVERING, XK_dead_abovering, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.456 -    {java_awt_event_KeyEvent_VK_DEAD_DOUBLEACUTE, XK_dead_doubleacute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.457 -    {java_awt_event_KeyEvent_VK_DEAD_CARON, XK_dead_caron, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.458 -    {java_awt_event_KeyEvent_VK_DEAD_CEDILLA, XK_dead_cedilla, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.459 -    {java_awt_event_KeyEvent_VK_DEAD_OGONEK, XK_dead_ogonek, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.460 -    {java_awt_event_KeyEvent_VK_DEAD_IOTA, XK_dead_iota, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.461 -    {java_awt_event_KeyEvent_VK_DEAD_VOICED_SOUND, XK_dead_voiced_sound, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.462 -    {java_awt_event_KeyEvent_VK_DEAD_SEMIVOICED_SOUND, XK_dead_semivoiced_sound, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.463 -
 115.464 -    /* Sun vendor-specific dead key mappings (for European keyboards) */
 115.465 -    {java_awt_event_KeyEvent_VK_DEAD_GRAVE, SunXK_FA_Grave, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.466 -    {java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX, SunXK_FA_Circum, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.467 -    {java_awt_event_KeyEvent_VK_DEAD_TILDE, SunXK_FA_Tilde, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.468 -    {java_awt_event_KeyEvent_VK_DEAD_ACUTE, SunXK_FA_Acute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.469 -    {java_awt_event_KeyEvent_VK_DEAD_DIAERESIS, SunXK_FA_Diaeresis, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.470 -    {java_awt_event_KeyEvent_VK_DEAD_CEDILLA, SunXK_FA_Cedilla, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.471 -
 115.472 -    /* DEC vendor-specific dead key mappings (for European keyboards) */
 115.473 -    {java_awt_event_KeyEvent_VK_DEAD_ABOVERING, DXK_ring_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.474 -    {java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX, DXK_circumflex_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.475 -    {java_awt_event_KeyEvent_VK_DEAD_CEDILLA, DXK_cedilla_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.476 -    {java_awt_event_KeyEvent_VK_DEAD_ACUTE, DXK_acute_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.477 -    {java_awt_event_KeyEvent_VK_DEAD_GRAVE, DXK_grave_accent, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.478 -    {java_awt_event_KeyEvent_VK_DEAD_TILDE, DXK_tilde, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.479 -    {java_awt_event_KeyEvent_VK_DEAD_DIAERESIS, DXK_diaeresis, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.480 -
 115.481 -    /* Other vendor-specific dead key mappings (for European keyboards) */
 115.482 -    {java_awt_event_KeyEvent_VK_DEAD_ACUTE, hpXK_mute_acute, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.483 -    {java_awt_event_KeyEvent_VK_DEAD_GRAVE, hpXK_mute_grave, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.484 -    {java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX, hpXK_mute_asciicircum, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.485 -    {java_awt_event_KeyEvent_VK_DEAD_DIAERESIS, hpXK_mute_diaeresis, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.486 -    {java_awt_event_KeyEvent_VK_DEAD_TILDE, hpXK_mute_asciitilde, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD},
 115.487 -
 115.488 -    {java_awt_event_KeyEvent_VK_UNDEFINED, NoSymbol, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN}
 115.489 -};
 115.490 -
 115.491 -static Boolean
 115.492 -keyboardHasKanaLockKey()
 115.493 -{
 115.494 -    static Boolean haveResult = FALSE;
 115.495 -    static Boolean result = FALSE;
 115.496 -
 115.497 -    int32_t minKeyCode, maxKeyCode, keySymsPerKeyCode;
 115.498 -    KeySym *keySyms, *keySymsStart, keySym;
 115.499 -    int32_t i;
 115.500 -    int32_t kanaCount = 0;
 115.501 -
 115.502 -    // Solaris doesn't let you swap keyboards without rebooting,
 115.503 -    // so there's no need to check for the kana lock key more than once.
 115.504 -    if (haveResult) {
 115.505 -       return result;
 115.506 -    }
 115.507 -
 115.508 -    // There's no direct way to determine whether the keyboard has
 115.509 -    // a kana lock key. From available keyboard mapping tables, it looks
 115.510 -    // like only keyboards with the kana lock key can produce keysyms
 115.511 -    // for kana characters. So, as an indirect test, we check for those.
 115.512 -
 115.513 -    XDisplayKeycodes(awt_display, &minKeyCode, &maxKeyCode);
 115.514 -    keySyms = XGetKeyboardMapping(awt_display, minKeyCode, maxKeyCode - minKeyCode + 1, &keySymsPerKeyCode);
 115.515 -    keySymsStart = keySyms;
 115.516 -    for (i = 0; i < (maxKeyCode - minKeyCode + 1) * keySymsPerKeyCode; i++) {
 115.517 -        keySym = *keySyms++;
 115.518 -        if ((keySym & 0xff00) == 0x0400) {
 115.519 -            kanaCount++;
 115.520 -        }
 115.521 -    }
 115.522 -    XFree(keySymsStart);
 115.523 -
 115.524 -    // use a (somewhat arbitrary) minimum so we don't get confused by a stray function key
 115.525 -    result = kanaCount > 10;
 115.526 -    haveResult = TRUE;
 115.527 -    return result;
 115.528 -}
 115.529 -
 115.530 -void
 115.531 -keysymToAWTKeyCode(KeySym x11Key, jint *keycode, Boolean *mapsToUnicodeChar,
 115.532 -  jint *keyLocation)
 115.533 -{
 115.534 -    int32_t i;
 115.535 -
 115.536 -    // Solaris uses XK_Mode_switch for both the non-locking AltGraph
 115.537 -    // and the locking Kana key, but we want to keep them separate for
 115.538 -    // KeyEvent.
 115.539 -    if (x11Key == XK_Mode_switch && keyboardHasKanaLockKey()) {
 115.540 -        *keycode = java_awt_event_KeyEvent_VK_KANA_LOCK;
 115.541 -        *mapsToUnicodeChar = FALSE;
 115.542 -        *keyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN;
 115.543 -        return;
 115.544 -    }
 115.545 -
 115.546 -    for (i = 0;
 115.547 -         keymapTable[i].awtKey != java_awt_event_KeyEvent_VK_UNDEFINED;
 115.548 -         i++) {
 115.549 -        if (keymapTable[i].x11Key == x11Key) {
 115.550 -            *keycode = keymapTable[i].awtKey;
 115.551 -            *mapsToUnicodeChar = keymapTable[i].mapsToUnicodeChar;
 115.552 -            *keyLocation = keymapTable[i].keyLocation;
 115.553 -            return;
 115.554 -        }
 115.555 -    }
 115.556 -
 115.557 -    *keycode = java_awt_event_KeyEvent_VK_UNDEFINED;
 115.558 -    *mapsToUnicodeChar = FALSE;
 115.559 -    *keyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN;
 115.560 -
 115.561 -    DTRACE_PRINTLN1("keysymToAWTKeyCode: no key mapping found: keysym = %x", x11Key);
 115.562 -}
 115.563 -
 115.564 -KeySym
 115.565 -awt_getX11KeySym(jint awtKey)
 115.566 -{
 115.567 -    int32_t i;
 115.568 -
 115.569 -    if (awtKey == java_awt_event_KeyEvent_VK_KANA_LOCK && keyboardHasKanaLockKey()) {
 115.570 -        return XK_Mode_switch;
 115.571 -    }
 115.572 -
 115.573 -    for (i = 0; keymapTable[i].awtKey != 0; i++) {
 115.574 -        if (keymapTable[i].awtKey == awtKey) {
 115.575 -            return keymapTable[i].x11Key;
 115.576 -        }
 115.577 -    }
 115.578 -
 115.579 -    DTRACE_PRINTLN1("awt_getX11KeySym: no key mapping found: awtKey = %x", awtKey);
 115.580 -    return NoSymbol;
 115.581 -}
 115.582 -
 115.583 -
 115.584 -typedef struct COLLAPSE_INFO {
 115.585 -    Window win;
 115.586 -    DamageRect *r;
 115.587 -} CollapseInfo;
 115.588 -
 115.589 -static void
 115.590 -expandDamageRect(DamageRect * drect, XEvent * xev, Boolean debug, char *str)
 115.591 -{
 115.592 -    int32_t x1 = xev->xexpose.x;
 115.593 -    int32_t y1 = xev->xexpose.y;
 115.594 -    int32_t x2 = x1 + xev->xexpose.width;
 115.595 -    int32_t y2 = y1 + xev->xexpose.height;
 115.596 -
 115.597 -    /*
 115.598 -      if (debug) {
 115.599 -      printf("   %s: collapsing (%d,%d %dx%d) into (%d,%d %dx%d) ->>",
 115.600 -      str, x1, y1, xev->xexpose.width, xev->xexpose.height,
 115.601 -      drect->x1, drect->y1, drect->x2 - drect->x1, drect->y2 - drect->y1);
 115.602 -      }
 115.603 -    */
 115.604 -
 115.605 -    drect->x1 = MIN(x1, drect->x1);
 115.606 -    drect->y1 = MIN(y1, drect->y1);
 115.607 -    drect->x2 = MAX(x2, drect->x2);
 115.608 -    drect->y2 = MAX(y2, drect->y2);
 115.609 -
 115.610 -    /*
 115.611 -      if (debug) {
 115.612 -      printf("(%d,%d %dx%d) %s\n",
 115.613 -      drect->x1, drect->y1, drect->x2 - drect->x1, drect->y2 - drect->y1);
 115.614 -      }
 115.615 -    */
 115.616 -
 115.617 -}
 115.618 -
 115.619 -static Bool
 115.620 -checkForExpose(Display * dpy, XEvent * evt, XPointer client_data)
 115.621 -{
 115.622 -    CollapseInfo *cinfo = (CollapseInfo *) client_data;
 115.623 -
 115.624 -    if ((evt->type == Expose && evt->xexpose.window == cinfo->win &&
 115.625 -         INTERSECTS(cinfo->r->x1, cinfo->r->x2, cinfo->r->y1, cinfo->r->y2,
 115.626 -                    evt->xexpose.x,
 115.627 -                    evt->xexpose.x + evt->xexpose.width,
 115.628 -                    evt->xexpose.y,
 115.629 -                    evt->xexpose.y + evt->xexpose.height)) ||
 115.630 -        (evt->type == GraphicsExpose && evt->xgraphicsexpose.drawable == cinfo->win &&
 115.631 -         INTERSECTS(cinfo->r->x1, cinfo->r->x2, cinfo->r->y1, cinfo->r->y2,
 115.632 -                    evt->xgraphicsexpose.x,
 115.633 -                    evt->xgraphicsexpose.x + evt->xgraphicsexpose.width,
 115.634 -                    evt->xgraphicsexpose.y,
 115.635 -                    evt->xgraphicsexpose.y + evt->xgraphicsexpose.height))) {
 115.636 -
 115.637 -        return True;
 115.638 -    }
 115.639 -    return False;
 115.640 -}
 115.641 -
 115.642 -/*
 115.643 - * javaObject is an MComponentPeer instance
 115.644 - */
 115.645 -static void
 115.646 -HandleExposeEvent(Widget w, jobject javaObject, XEvent * event)
 115.647 -{
 115.648 -    jobject target;
 115.649 -    jint wdth, hght;
 115.650 -
 115.651 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 115.652 -
 115.653 -    switch (event->type) {
 115.654 -        case Expose:
 115.655 -        case GraphicsExpose:
 115.656 -        {
 115.657 -            struct ComponentData *cdata;
 115.658 -            Boolean debug = FALSE;
 115.659 -            jint drawState;
 115.660 -
 115.661 -            /* Set the draw state */
 115.662 -            drawState = (*env)->GetIntField(env, javaObject,
 115.663 -                mComponentPeerIDs.drawState);
 115.664 -            (*env)->SetIntField(env, javaObject, mComponentPeerIDs.drawState,
 115.665 -                drawState | JAWT_LOCK_CLIP_CHANGED);
 115.666 -            cdata = (struct ComponentData *)
 115.667 -              JNU_GetLongFieldAsPtr(env, javaObject, mComponentPeerIDs.pData);
 115.668 -            if (JNU_IsNull(env, javaObject) || (cdata == NULL)) {
 115.669 -                return;
 115.670 -            }
 115.671 -            if (event->xexpose.send_event) {
 115.672 -                if (cdata->repaintPending & RepaintPending_REPAINT) {
 115.673 -                    cdata->repaintPending &= ~RepaintPending_REPAINT;
 115.674 -
 115.675 -                    JNU_CallMethodByName(env,
 115.676 -                                         NULL,
 115.677 -                                         javaObject,
 115.678 -                                         "handleRepaint",
 115.679 -                                         "(IIII)V",
 115.680 -                                         (jint) cdata->repaintRect.x1,
 115.681 -                                         (jint) cdata->repaintRect.y1,
 115.682 -                                         (jint) cdata->repaintRect.x2
 115.683 -                                         - cdata->repaintRect.x1,
 115.684 -                                         (jint) cdata->repaintRect.y2
 115.685 -                                         - cdata->repaintRect.y1);
 115.686 -                    if ((*env)->ExceptionOccurred(env)) {
 115.687 -                        (*env)->ExceptionDescribe(env);
 115.688 -                        (*env)->ExceptionClear(env);
 115.689 -                    }
 115.690 -                }
 115.691 -                return;
 115.692 -            }
 115.693 -            if ((cdata->repaintPending & RepaintPending_EXPOSE) == 0) {
 115.694 -                cdata->exposeRect.x1 = event->xexpose.x;
 115.695 -                cdata->exposeRect.y1 = event->xexpose.y;
 115.696 -                cdata->exposeRect.x2 = cdata->exposeRect.x1 + event->xexpose.width;
 115.697 -                cdata->exposeRect.y2 = cdata->exposeRect.y1 + event->xexpose.height;
 115.698 -                cdata->repaintPending |= RepaintPending_EXPOSE;
 115.699 -            } else {
 115.700 -                expandDamageRect(&(cdata->exposeRect), event, debug, "1");
 115.701 -            }
 115.702 -
 115.703 -            /* Only post Expose/Repaint if we know others arn't following
 115.704 -             * directly in the queue.
 115.705 -             */
 115.706 -            if (event->xexpose.count == 0) {
 115.707 -                int32_t count = 0;
 115.708 -                CollapseInfo cinfo;
 115.709 -
 115.710 -                cinfo.win = XtWindow(w);
 115.711 -                cinfo.r = &(cdata->exposeRect);
 115.712 -
 115.713 -                /* Do a little more inspecting and collapse further if there
 115.714 -                 * are additional expose events pending on this window where
 115.715 -                 * the damage rects intersect with the current exposeRect.
 115.716 -                 */
 115.717 -                while (TRUE) {
 115.718 -                    XEvent xev;
 115.719 -
 115.720 -                    if (XCheckIfEvent(XtDisplay(w), &xev
 115.721 -                                      ,checkForExpose, (XtPointer) & cinfo)) {
 115.722 -                        count = xev.xexpose.count;
 115.723 -                        expandDamageRect(&(cdata->exposeRect), &xev, debug, "2");
 115.724 -
 115.725 -                    } else {
 115.726 -                        /* XCheckIfEvent Failed. */
 115.727 -                        break;
 115.728 -                    }
 115.729 -                }
 115.730 -
 115.731 -                cdata->repaintPending &= ~RepaintPending_EXPOSE;
 115.732 -
 115.733 -                /* Fix for bugtraq id 4262108. Paint events should not be
 115.734 -                 * delivered to components that have one of their
 115.735 -                 * dimensions equal to zero.
 115.736 -                 */
 115.737 -
 115.738 -                if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
 115.739 -                    return;
 115.740 -                }
 115.741 -
 115.742 -                target = (*env)->GetObjectField(env, javaObject,
 115.743 -                                                    mComponentPeerIDs.target);
 115.744 -                wdth = (*env)->GetIntField(env, target, componentIDs.width);
 115.745 -                hght = (*env)->GetIntField(env, target, componentIDs.height);
 115.746 -                (*env)->DeleteLocalRef(env, target);
 115.747 -
 115.748 -                if ( wdth != 0 && hght != 0) {
 115.749 -                    JNU_CallMethodByName(env,
 115.750 -                                        NULL,
 115.751 -                                        javaObject,
 115.752 -                                        "handleExpose",
 115.753 -                                        "(IIII)V",
 115.754 -                                        (jint) cdata->exposeRect.x1,
 115.755 -                                        (jint) cdata->exposeRect.y1,
 115.756 -                                        (jint) cdata->exposeRect.x2
 115.757 -                                        - cdata->exposeRect.x1,
 115.758 -                                        (jint) cdata->exposeRect.y2
 115.759 -                                        - cdata->exposeRect.y1);
 115.760 -                    if ((*env)->ExceptionOccurred(env)) {
 115.761 -                        (*env)->ExceptionDescribe(env);
 115.762 -                        (*env)->ExceptionClear(env);
 115.763 -                    }
 115.764 -                }
 115.765 -            }
 115.766 -        }
 115.767 -        break;
 115.768 -
 115.769 -        default:
 115.770 -            jio_fprintf(stderr, "Got event %d in HandleExposeEvent!\n", event->type);
 115.771 -    }
 115.772 -}
 115.773 -
 115.774 -/* We always store and return JNI GlobalRefs. */
 115.775 -static jweak focusOwnerPeer = NULL;
 115.776 -static jweak focusedWindowPeer = NULL;
 115.777 -
 115.778 -/*
 115.779 - * This function should only be called under the
 115.780 - * protection of AWT_LOCK(). Otherwise, multithreaded access
 115.781 - * can corrupt the value of focusOwnerPeer variable.
 115.782 - * This function returns LocalRef, result should be deleted
 115.783 - * explicitly if called on a thread that never returns to
 115.784 - * Java.
 115.785 - */
 115.786 -jobject
 115.787 -awt_canvas_getFocusOwnerPeer() {
 115.788 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 115.789 -    jobject res;
 115.790 -    AWT_LOCK();
 115.791 -    res = (*env)->NewLocalRef(env, focusOwnerPeer);
 115.792 -    AWT_UNLOCK();
 115.793 -    return res;
 115.794 -}
 115.795 -
 115.796 -/*
 115.797 - * This function should only be called under the
 115.798 - * protection of AWT_LOCK(). Otherwise, multithreaded access
 115.799 - * can corrupt the value of focusedWindowPeer variable.
 115.800 - * This function returns LocalRef, result should be deleted
 115.801 - * explicitly if called on a thread that never returns to
 115.802 - * Java.
 115.803 - */
 115.804 -jobject
 115.805 -awt_canvas_getFocusedWindowPeer() {
 115.806 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 115.807 -    jobject res;
 115.808 -    AWT_LOCK();
 115.809 -    res = (*env)->NewLocalRef(env, focusedWindowPeer);
 115.810 -    AWT_UNLOCK();
 115.811 -    return res;
 115.812 -}
 115.813 -
 115.814 -/*
 115.815 - * Only call this function under AWT_LOCK(). Otherwise, multithreaded
 115.816 - * access can corrupt the value of focusOwnerPeer variable.
 115.817 - */
 115.818 -void
 115.819 -awt_canvas_setFocusOwnerPeer(jobject peer) {
 115.820 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 115.821 -    AWT_LOCK();
 115.822 -    if (focusOwnerPeer != NULL) {
 115.823 -        (*env)->DeleteWeakGlobalRef(env, focusOwnerPeer);
 115.824 -    }
 115.825 -    focusOwnerPeer = (peer != NULL)
 115.826 -        ? (*env)->NewWeakGlobalRef(env, peer) : NULL;
 115.827 -    AWT_UNLOCK();
 115.828 -}
 115.829 -
 115.830 -/*
 115.831 - * Only call this function under AWT_LOCK(). Otherwise, multithreaded
 115.832 - * access can corrupt the value of focusedWindowPeer variable.
 115.833 - */
 115.834 -void
 115.835 -awt_canvas_setFocusedWindowPeer(jobject peer) {
 115.836 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 115.837 -    AWT_LOCK();
 115.838 -    if (focusedWindowPeer != NULL) {
 115.839 -        (*env)->DeleteWeakGlobalRef(env, focusedWindowPeer);
 115.840 -    }
 115.841 -    focusedWindowPeer = (peer != NULL)
 115.842 -        ? (*env)->NewWeakGlobalRef(env, peer) : NULL;
 115.843 -    AWT_UNLOCK();
 115.844 -}
 115.845 -
 115.846 -void callFocusCallback(jobject focusPeer, int focus_type, jobject cause) {
 115.847 -    awt_post_java_focus_event(focusPeer,
 115.848 -                              focus_type,
 115.849 -                              cause,
 115.850 -                              NULL);
 115.851 -    awt_canvas_setFocusOwnerPeer(focusPeer);
 115.852 -}
 115.853 -
 115.854 -
 115.855 -void
 115.856 -handleFocusEvent(Widget w,
 115.857 -                 XFocusChangeEvent * fevent,
 115.858 -                 XtPointer client_data,
 115.859 -                 Boolean * cont,
 115.860 -                 Boolean passEvent,
 115.861 -                 jobject cause)
 115.862 -{
 115.863 -    if (fevent->type == FocusIn) {
 115.864 -        if (fevent->mode == NotifyNormal &&
 115.865 -            fevent->detail != NotifyPointer && fevent->detail != NotifyVirtual)
 115.866 -        {
 115.867 -#ifdef DEBUG_FOCUS
 115.868 -            printf("window = %d, mode = %d, detail = %d\n", fevent->window, fevent->mode, fevent->detail);
 115.869 -            printf("----posting java FOCUS GAINED on window %d, pass = %d\n", XtWindow(w), passEvent);
 115.870 -#endif
 115.871 -            awt_post_java_focus_event(client_data,
 115.872 -                                      java_awt_event_FocusEvent_FOCUS_GAINED,
 115.873 -                                      cause,
 115.874 -                                      NULL);
 115.875 -            awt_canvas_setFocusOwnerPeer(client_data);
 115.876 -        }
 115.877 -    } else {
 115.878 -        /* FocusOut */
 115.879 -        if (fevent->mode == NotifyNormal &&
 115.880 -            fevent->detail != NotifyPointer && fevent->detail != NotifyVirtual)
 115.881 -        {
 115.882 -#ifdef DEBUG_FOCUS
 115.883 -          printf("window = %d, mode = %d, detail = %d\n", fevent->window, fevent->mode, fevent->detail);
 115.884 -          printf("----posting java FOCUS LOST on window %d, pass = %d, temp = %d\n", XtWindow(w), passEvent, temp);
 115.885 -#endif
 115.886 -            awt_post_java_focus_event(client_data,
 115.887 -                                      java_awt_event_FocusEvent_FOCUS_LOST,
 115.888 -                                      cause,
 115.889 -                                      NULL);
 115.890 -            awt_canvas_setFocusOwnerPeer(NULL);
 115.891 -        }
 115.892 -    }
 115.893 -    *cont = TRUE;
 115.894 -}
 115.895 -
 115.896 -void callFocusHandler(Widget w, int eventType, jobject cause) {
 115.897 -    jobject peer = NULL;
 115.898 -    XFocusChangeEvent event;
 115.899 -    Boolean cont;
 115.900 -    JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
 115.901 -
 115.902 -    if (w == NULL) {
 115.903 -        return;
 115.904 -    }
 115.905 -
 115.906 -    peer = findPeer(&w);
 115.907 -    if (peer == NULL) {
 115.908 -        w = findTopLevelByShell(w);
 115.909 -        if (w != NULL) {
 115.910 -            peer = findPeer(&w);
 115.911 -        }
 115.912 -    }
 115.913 -    if (peer == NULL) {
 115.914 -        return;
 115.915 -    }
 115.916 -    memset(&event, 0, sizeof(event));
 115.917 -    event.type = eventType;
 115.918 -    event.mode = NotifyNormal;
 115.919 -    event.detail = NotifyAncestor;
 115.920 -    event.window = XtWindow(w);
 115.921 -    cont = FALSE;
 115.922 -    handleFocusEvent(w, &event, (XtPointer)peer, &cont, TRUE, cause);
 115.923 -}
 115.924 -
 115.925 -/**
 115.926 - * Copy XEvent to jbyteArray and save it in AWTEvent
 115.927 - */
 115.928 -void
 115.929 -awt_copyXEventToAWTEvent(JNIEnv *env, XEvent * xev, jobject jevent)
 115.930 -{
 115.931 -    jbyteArray bdata;
 115.932 -    if (xev != NULL) {
 115.933 -        if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
 115.934 -            return;
 115.935 -        }
 115.936 -        bdata = (*env)->NewByteArray(env, sizeof(XEvent));
 115.937 -        if (bdata != NULL) {
 115.938 -            (*env)->SetByteArrayRegion(env, bdata, 0, sizeof(XEvent),
 115.939 -                                       (jbyte *)xev);
 115.940 -            (*env)->SetObjectField(env, jevent, awtEventIDs.bdata, bdata);
 115.941 -            (*env)->DeleteLocalRef(env, bdata);
 115.942 -        }
 115.943 -    }
 115.944 -}
 115.945 -
 115.946 -/* Returns new modifiers set like ???_DOWN_MASK for keyboard and mouse after the event.
 115.947 - * The modifiers on a Java key event reflect the state of the modifier keys
 115.948 - * immediately AFTER the key press or release.  This usually doesn't require
 115.949 - * us to change the modifiers: the exception is when the key pressed or
 115.950 - * released is a modifier key.  Since the state of an XEvent represents
 115.951 - * the modifiers BEFORE the event, we change the modifiers according to
 115.952 - * the button and keycode.
 115.953 - */
 115.954 -jint
 115.955 -getModifiers(uint32_t state, jint button, jint keyCode)
 115.956 -{
 115.957 -    jint modifiers = 0;
 115.958 -
 115.959 -    if (((state & ShiftMask) != 0) ^ (keyCode == java_awt_event_KeyEvent_VK_SHIFT))
 115.960 -    {
 115.961 -        modifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK;
 115.962 -    }
 115.963 -    if (((state & ControlMask) != 0) ^ (keyCode == java_awt_event_KeyEvent_VK_CONTROL))
 115.964 -    {
 115.965 -        modifiers |= java_awt_event_InputEvent_CTRL_DOWN_MASK;
 115.966 -    }
 115.967 -    if (((state & awt_MetaMask) != 0) ^ (keyCode == java_awt_event_KeyEvent_VK_META))
 115.968 -    {
 115.969 -        modifiers |= java_awt_event_InputEvent_META_DOWN_MASK;
 115.970 -    }
 115.971 -    if (((state & awt_AltMask) != 0) ^ (keyCode == java_awt_event_KeyEvent_VK_ALT))
 115.972 -    {
 115.973 -        modifiers |= java_awt_event_InputEvent_ALT_DOWN_MASK;
 115.974 -    }
 115.975 -    if (((state & awt_ModeSwitchMask) != 0) ^ (keyCode == java_awt_event_KeyEvent_VK_ALT_GRAPH))
 115.976 -    {
 115.977 -        modifiers |= java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK;
 115.978 -    }
 115.979 -    if (((state & Button1Mask) != 0) ^ (button == java_awt_event_MouseEvent_BUTTON1)) {
 115.980 -        modifiers |= java_awt_event_InputEvent_BUTTON1_DOWN_MASK;
 115.981 -    }
 115.982 -    if (((state & Button2Mask) != 0) ^ (button == java_awt_event_MouseEvent_BUTTON2)) {
 115.983 -        modifiers |= java_awt_event_InputEvent_BUTTON2_DOWN_MASK;
 115.984 -    }
 115.985 -    if (((state & Button3Mask) != 0) ^ (button == java_awt_event_MouseEvent_BUTTON3)) {
 115.986 -        modifiers |= java_awt_event_InputEvent_BUTTON3_DOWN_MASK;
 115.987 -    }
 115.988 -    return modifiers;
 115.989 -}
 115.990 -
 115.991 -/* Returns which mouse button has changed state
 115.992 - */
 115.993 -jint
 115.994 -getButton(uint32_t button)
 115.995 -{
 115.996 -    switch (button) {
 115.997 -    case Button1:
 115.998 -        return java_awt_event_MouseEvent_BUTTON1;
 115.999 -    case Button2:
115.1000 -        return java_awt_event_MouseEvent_BUTTON2;
115.1001 -    case Button3:
115.1002 -        return java_awt_event_MouseEvent_BUTTON3;
115.1003 -    }
115.1004 -    return java_awt_event_MouseEvent_NOBUTTON;
115.1005 -}
115.1006 -
115.1007 -
115.1008 -/* This function changes the state of the native XEvent AFTER
115.1009 - * the corresponding Java event has been processed.  The XEvent
115.1010 - * needs to be modified before it is dispatched to the native widget.
115.1011 - */
115.1012 -void
115.1013 -awt_modify_KeyEvent(JNIEnv *env, XEvent *xevent, jobject jevent)
115.1014 -{
115.1015 -    jint keyCode;
115.1016 -    jchar keyChar;
115.1017 -    jint modifiers;
115.1018 -    KeySym keysym = (KeySym) java_awt_event_KeyEvent_CHAR_UNDEFINED;
115.1019 -
115.1020 -    if (xevent->type != KeyPress && xevent->type != KeyRelease) {
115.1021 -        return;
115.1022 -    }
115.1023 -
115.1024 -    keyCode = (*env)->GetIntField(env, jevent, keyEventIDs.keyCode);
115.1025 -    keyChar = (*env)->GetCharField(env, jevent, keyEventIDs.keyChar);
115.1026 -    modifiers = (*env)->GetIntField(env, jevent, inputEventIDs.modifiers);
115.1027 -
115.1028 -    switch (keyCode) {
115.1029 -        case java_awt_event_KeyEvent_VK_MULTIPLY:
115.1030 -        case java_awt_event_KeyEvent_VK_SUBTRACT:
115.1031 -        case java_awt_event_KeyEvent_VK_DIVIDE:
115.1032 -            /* Bugid 4103229:  Change the X event so these three Numpad
115.1033 -             * keys work with the NumLock off.  For some reason, Motif
115.1034 -             * widgets ignore the events produced by these three keys
115.1035 -             * unless the NumLock is on.  It also ignores them if some
115.1036 -             * other modifiers are set.  Turn off ALL modifiers, then
115.1037 -             * turn NumLock mask on in the X event.
115.1038 -             */
115.1039 -            xevent->xkey.state = awt_NumLockMask;
115.1040 -            return;
115.1041 -        case java_awt_event_KeyEvent_VK_ENTER:
115.1042 -        case java_awt_event_KeyEvent_VK_BACK_SPACE:
115.1043 -        case java_awt_event_KeyEvent_VK_TAB:
115.1044 -        case java_awt_event_KeyEvent_VK_ESCAPE:
115.1045 -        case java_awt_event_KeyEvent_VK_ADD:
115.1046 -        case java_awt_event_KeyEvent_VK_DECIMAL:
115.1047 -        case java_awt_event_KeyEvent_VK_NUMPAD0:
115.1048 -        case java_awt_event_KeyEvent_VK_NUMPAD1:
115.1049 -        case java_awt_event_KeyEvent_VK_NUMPAD2:
115.1050 -        case java_awt_event_KeyEvent_VK_NUMPAD3:
115.1051 -        case java_awt_event_KeyEvent_VK_NUMPAD4:
115.1052 -        case java_awt_event_KeyEvent_VK_NUMPAD5:
115.1053 -        case java_awt_event_KeyEvent_VK_NUMPAD6:
115.1054 -        case java_awt_event_KeyEvent_VK_NUMPAD7:
115.1055 -        case java_awt_event_KeyEvent_VK_NUMPAD8:
115.1056 -        case java_awt_event_KeyEvent_VK_NUMPAD9:
115.1057 -            keysym = awt_getX11KeySym(keyCode);
115.1058 -            break;
115.1059 -        case java_awt_event_KeyEvent_VK_DELETE:
115.1060 -            /* For some reason XKeysymToKeycode returns incorrect value for
115.1061 -             * Delete, so we don't want to modify the original event
115.1062 -             */
115.1063 -            break;
115.1064 -        default:
115.1065 -            if (keyChar < (KeySym) 256) {
115.1066 -                keysym = (KeySym) keyChar;
115.1067 -            } else {
115.1068 -                keysym = awt_getX11KeySym(keyCode);
115.1069 -            }
115.1070 -            break;
115.1071 -    }
115.1072 -
115.1073 -    if (keysym < (KeySym) 256) {
115.1074 -        if (modifiers & java_awt_event_InputEvent_CTRL_MASK) {
115.1075 -            switch (keysym + 64) {
115.1076 -                case '[':
115.1077 -                case ']':
115.1078 -                case '\\':
115.1079 -                case '_':
115.1080 -                    keysym += 64;
115.1081 -                    break;
115.1082 -                default:
115.1083 -                    if (isalpha((int32_t)(keysym + 'a' - 1))) {
115.1084 -                        keysym += ('a' - 1);
115.1085 -                    }
115.1086 -                    break;
115.1087 -            }
115.1088 -        }
115.1089 -        /*
115.1090 -         * 0xff61 is Unicode value of first XK_kana_fullstop.
115.1091 -         * We need X Keysym to Unicode map in post1.1 release
115.1092 -         * to support more international keyboards.
115.1093 -         */
115.1094 -        if (keysym >= (KeySym) 0xff61 && keysym <= (KeySym) 0xff9f) {
115.1095 -            keysym = keysym - 0xff61 + XK_kana_fullstop;
115.1096 -        }
115.1097 -        xevent->xkey.keycode = XKeysymToKeycode(awt_display, keysym);
115.1098 -    }
115.1099 -
115.1100 -    if (keysym >= 'A' && keysym <= 'Z') {
115.1101 -        xevent->xkey.state |= ShiftMask;
115.1102 -    }
115.1103 -    if (modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK) {
115.1104 -        xevent->xkey.state |= ShiftMask;
115.1105 -    }
115.1106 -    if (modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK) {
115.1107 -        xevent->xkey.state |= ControlMask;
115.1108 -    }
115.1109 -    if (modifiers & java_awt_event_InputEvent_META_DOWN_MASK) {
115.1110 -        xevent->xkey.state |= awt_MetaMask;
115.1111 -    }
115.1112 -    if (modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK) {
115.1113 -        xevent->xkey.state |= awt_AltMask;
115.1114 -    }
115.1115 -    if (modifiers & java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK) {
115.1116 -        xevent->xkey.state |= awt_ModeSwitchMask;
115.1117 -    }
115.1118 -    if (modifiers & java_awt_event_InputEvent_BUTTON1_DOWN_MASK) {
115.1119 -        xevent->xkey.state |= Button1Mask;
115.1120 -    }
115.1121 -    if (modifiers & java_awt_event_InputEvent_BUTTON2_DOWN_MASK) {
115.1122 -        xevent->xkey.state |= Button2Mask;
115.1123 -    }
115.1124 -    if (modifiers & java_awt_event_InputEvent_BUTTON3_DOWN_MASK) {
115.1125 -        xevent->xkey.state |= Button3Mask;
115.1126 -    }
115.1127 -}
115.1128 -
115.1129 -
115.1130 -/* Called from handleKeyEvent.  The purpose of this function is
115.1131 - * to check for a list of vendor-specific keysyms, most of which
115.1132 - * have values greater than 0xFFFF.  Most of these keys don't map
115.1133 - * to unicode characters, but some do.
115.1134 - *
115.1135 - * For keys that don't map to unicode characters, the keysym
115.1136 - * is irrelevant at this point.  We set the keysym to zero
115.1137 - * to ensure that the switch statement immediately below
115.1138 - * this function call (in adjustKeySym) won't incorrectly act
115.1139 - * on them after the high bits are stripped off.
115.1140 - *
115.1141 - * For keys that do map to unicode characters, we change the keysym
115.1142 - * to the equivalent that is < 0xFFFF
115.1143 - */
115.1144 -static void
115.1145 -handleVendorKeySyms(XEvent *event, KeySym *keysym)
115.1146 -{
115.1147 -    KeySym originalKeysym = *keysym;
115.1148 -
115.1149 -    switch (*keysym) {
115.1150 -        /* Apollo (HP) vendor-specific from <X11/ap_keysym.h> */
115.1151 -        case apXK_Copy:
115.1152 -        case apXK_Cut:
115.1153 -        case apXK_Paste:
115.1154 -        /* DEC vendor-specific from <X11/DECkeysym.h> */
115.1155 -        case DXK_ring_accent:         /* syn usldead_ring */
115.1156 -        case DXK_circumflex_accent:
115.1157 -        case DXK_cedilla_accent:      /* syn usldead_cedilla */
115.1158 -        case DXK_acute_accent:
115.1159 -        case DXK_grave_accent:
115.1160 -        case DXK_tilde:
115.1161 -        case DXK_diaeresis:
115.1162 -        /* Sun vendor-specific from <X11/Sunkeysym.h> */
115.1163 -        case SunXK_FA_Grave:
115.1164 -        case SunXK_FA_Circum:
115.1165 -        case SunXK_FA_Tilde:
115.1166 -        case SunXK_FA_Acute:
115.1167 -        case SunXK_FA_Diaeresis:
115.1168 -        case SunXK_FA_Cedilla:
115.1169 -        case SunXK_F36:                /* Labeled F11 */
115.1170 -        case SunXK_F37:                /* Labeled F12 */
115.1171 -        case SunXK_Props:
115.1172 -        case SunXK_Copy:
115.1173 -        case SunXK_Open:
115.1174 -        case SunXK_Paste:
115.1175 -        case SunXK_Cut:
115.1176 -        /* Other vendor-specific from HPkeysym.h */
115.1177 -        case hpXK_mute_acute:          /* syn usldead_acute */
115.1178 -        case hpXK_mute_grave:          /* syn usldead_grave */
115.1179 -        case hpXK_mute_asciicircum:    /* syn usldead_asciicircum */
115.1180 -        case hpXK_mute_diaeresis:      /* syn usldead_diaeresis */
115.1181 -        case hpXK_mute_asciitilde:     /* syn usldead_asciitilde */
115.1182 -        case osfXK_Copy:
115.1183 -        case osfXK_Cut:
115.1184 -        case osfXK_Paste:
115.1185 -        case osfXK_PageUp:
115.1186 -        case osfXK_PageDown:
115.1187 -        case osfXK_EndLine:
115.1188 -        case osfXK_Clear:
115.1189 -        case osfXK_Left:
115.1190 -        case osfXK_Up:
115.1191 -        case osfXK_Right:
115.1192 -        case osfXK_Down:
115.1193 -        case osfXK_Prior:
115.1194 -        case osfXK_Next:
115.1195 -        case osfXK_Insert:
115.1196 -        case osfXK_Undo:
115.1197 -        case osfXK_Help:
115.1198 -            *keysym = 0;
115.1199 -            break;
115.1200 -        /*
115.1201 -         * The rest DO map to unicode characters, so translate them
115.1202 -         */
115.1203 -        case osfXK_BackSpace:
115.1204 -            *keysym = XK_BackSpace;
115.1205 -            break;
115.1206 -        case osfXK_Escape:
115.1207 -            *keysym = XK_Escape;
115.1208 -            break;
115.1209 -        case osfXK_Cancel:
115.1210 -            *keysym = XK_Cancel;
115.1211 -            break;
115.1212 -        case osfXK_Delete:
115.1213 -            *keysym = XK_Delete;
115.1214 -            break;
115.1215 -        default:
115.1216 -            break;
115.1217 -    }
115.1218 -
115.1219 -    if (originalKeysym != *keysym) {
115.1220 -        DTRACE_PRINTLN2("In handleVendorKeySyms: originalKeysym=%x, keysym=%x",
115.1221 -          originalKeysym, *keysym);
115.1222 -    }
115.1223 -}
115.1224 -
115.1225 -/* Called from handleKeyEvent.
115.1226 - * The purpose of this function is to adjust the keysym and XEvent
115.1227 - * keycode for a key event.  This is basically a conglomeration of
115.1228 - * bugfixes that require these adjustments.
115.1229 - */
115.1230 -static void
115.1231 -adjustKeySym(XEvent *event, KeySym *keysym)
115.1232 -{
115.1233 -    KeySym originalKeysym = *keysym;
115.1234 -
115.1235 -    /* We have seen bits set in the high two bytes on Linux,
115.1236 -     * which prevents this switch statement from executing
115.1237 -     * correctly.  Strip off the high order bits.
115.1238 -     */
115.1239 -    *keysym &= 0x0000FFFF;
115.1240 -
115.1241 -    switch (*keysym) {
115.1242 -        case XK_Return:
115.1243 -            *keysym = XK_Linefeed;     /* fall thru */
115.1244 -        case XK_BackSpace:
115.1245 -        case XK_Tab:
115.1246 -        case XK_Linefeed:
115.1247 -        case XK_Escape:
115.1248 -        case XK_Delete:
115.1249 -            /* strip off highorder bits defined in keysymdef.h
115.1250 -             * I think doing this converts them to values that
115.1251 -             * we can cast to jchars and use as java keychars.
115.1252 -             * If so, it's really a hack.
115.1253 -             */
115.1254 -            *keysym &= 0x007F;
115.1255 -            break;
115.1256 -        case XK_Cancel:
115.1257 -            *keysym = 0x0018;  /* the unicode char for Cancel */
115.1258 -            break;
115.1259 -        case XK_KP_Decimal:
115.1260 -            *keysym = '.';
115.1261 -            break;
115.1262 -        case XK_KP_Add:
115.1263 -            *keysym = '+';
115.1264 -            break;
115.1265 -        case XK_F24:           /* NumLock off */
115.1266 -        case XK_KP_Subtract:   /* NumLock on */
115.1267 -            *keysym = '-';
115.1268 -            break;
115.1269 -        case XK_F25:           /* NumLock off */
115.1270 -        case XK_KP_Divide:     /* NumLock on */
115.1271 -            *keysym = '/';
115.1272 -            break;
115.1273 -        case XK_F26:           /* NumLock off */
115.1274 -        case XK_KP_Multiply:   /* NumLock on */
115.1275 -            *keysym = '*';
115.1276 -            break;
115.1277 -        case XK_KP_Equal:
115.1278 -            *keysym = '=';
115.1279 -            break;
115.1280 -        case XK_KP_0:
115.1281 -            *keysym = '0';
115.1282 -            break;
115.1283 -        case XK_KP_1:
115.1284 -            *keysym = '1';
115.1285 -            break;
115.1286 -        case XK_KP_2:
115.1287 -            *keysym = '2';
115.1288 -            break;
115.1289 -        case XK_KP_3:
115.1290 -            *keysym = '3';
115.1291 -            break;
115.1292 -        case XK_KP_4:
115.1293 -            *keysym = '4';
115.1294 -            break;
115.1295 -        case XK_KP_5:
115.1296 -            *keysym = '5';
115.1297 -            break;
115.1298 -        case XK_KP_6:
115.1299 -            *keysym = '6';
115.1300 -            break;
115.1301 -        case XK_KP_7:
115.1302 -            *keysym = '7';
115.1303 -            break;
115.1304 -        case XK_KP_8:
115.1305 -            *keysym = '8';
115.1306 -            break;
115.1307 -        case XK_KP_9:
115.1308 -            *keysym = '9';
115.1309 -            break;
115.1310 -        case XK_KP_Left:  /* Bug 4350175 */
115.1311 -            *keysym = XK_Left;
115.1312 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1313 -            break;
115.1314 -        case XK_KP_Up:
115.1315 -            *keysym = XK_Up;
115.1316 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1317 -            break;
115.1318 -        case XK_KP_Right:
115.1319 -            *keysym = XK_Right;
115.1320 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1321 -            break;
115.1322 -        case XK_KP_Down:
115.1323 -            *keysym = XK_Down;
115.1324 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1325 -            break;
115.1326 -        case XK_KP_Home:
115.1327 -            *keysym = XK_Home;
115.1328 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1329 -            break;
115.1330 -        case XK_KP_End:
115.1331 -            *keysym = XK_End;
115.1332 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1333 -            break;
115.1334 -        case XK_KP_Page_Up:
115.1335 -            *keysym = XK_Page_Up;
115.1336 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1337 -            break;
115.1338 -        case XK_KP_Page_Down:
115.1339 -            *keysym = XK_Page_Down;
115.1340 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1341 -            break;
115.1342 -        case XK_KP_Begin:
115.1343 -            *keysym = XK_Begin;
115.1344 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1345 -            break;
115.1346 -        case XK_KP_Insert:
115.1347 -            *keysym = XK_Insert;
115.1348 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1349 -            break;
115.1350 -        case XK_KP_Delete:
115.1351 -            *keysym = XK_Delete;
115.1352 -            event->xkey.keycode = XKeysymToKeycode(awt_display, *keysym);
115.1353 -            *keysym &= 0x007F;
115.1354 -            break;
115.1355 -        case XK_KP_Enter:
115.1356 -            *keysym = XK_Linefeed;
115.1357 -            event->xkey.keycode = XKeysymToKeycode(awt_display, XK_Return);
115.1358 -            *keysym &= 0x007F;
115.1359 -            break;
115.1360 -        default:
115.1361 -            break;
115.1362 -    }
115.1363 -
115.1364 -    if (originalKeysym != *keysym) {
115.1365 -        DTRACE_PRINTLN2("In adjustKeySym: originalKeysym=%x, keysym=%x",
115.1366 -          originalKeysym, *keysym);
115.1367 -    }
115.1368 -}
115.1369 -
115.1370 -/*
115.1371 - * What a sniffer sez?
115.1372 - * Xsun and Xorg if NumLock is on do two thing different:
115.1373 - * keep Keypad key in different places of keysyms array and
115.1374 - * ignore/obey "ModLock is ShiftLock", so we should choose.
115.1375 - * People say, it's right to use behavior and not Vendor tags to decide.
115.1376 - * Maybe. But why these tags were invented, then?
115.1377 - * TODO: use behavior, not tags. Maybe.
115.1378 - */
115.1379 -static Boolean
115.1380 -isXsunServer(XEvent *event) {
115.1381 -    if( awt_ServerDetected ) return awt_IsXsun;
115.1382 -    if( strncmp( ServerVendor( event->xkey.display ), "Sun Microsystems, Inc.", 32) ) {
115.1383 -        awt_ServerDetected = True;
115.1384 -        awt_IsXsun = False;
115.1385 -        return False;
115.1386 -    }
115.1387 -    // Now, it's Sun. It still may be Xorg though, eg on Solaris 10, x86.
115.1388 -    // Today (2005), VendorRelease of Xorg is a Big Number unlike Xsun.
115.1389 -    if( VendorRelease( event->xkey.display ) > 10000 ) {
115.1390 -        awt_ServerDetected = True;
115.1391 -        awt_IsXsun = False;
115.1392 -        return False;
115.1393 -    }
115.1394 -    awt_ServerDetected = True;
115.1395 -    awt_IsXsun = True;
115.1396 -    return True;
115.1397 -}
115.1398 -static Boolean
115.1399 -isKPevent(XEvent *event)
115.1400 -{
115.1401 -    /*
115.1402 -       Xlib manual, ch 12.7 says, as a first rule for choice of keysym:
115.1403 -       The numlock modifier is on and the second KeySym is a keypad KeySym. In this case,
115.1404 -       if the Shift modifier is on, or if the Lock modifier is on and is interpreted as ShiftLock,
115.1405 -       then the first KeySym is used, otherwise the second KeySym is used.
115.1406 -
115.1407 -       However, Xsun server does ignore ShiftLock and always takes 3-rd element from an array.
115.1408 -
115.1409 -       So, is it a keypad keysym?
115.1410 -     */
115.1411 -    jint mods = getModifiers(event->xkey.state, 0, event->xkey.keycode);
115.1412 -    Boolean bsun = isXsunServer( event );
115.1413 -
115.1414 -    return IsKeypadKey( XKeycodeToKeysym(event->xkey.display, event->xkey.keycode,(bsun && !awt_UseXKB ? 2 : 1) ) );
115.1415 -}
115.1416 -/*
115.1417 - * In a next redesign, get rid of this code altogether.
115.1418 - *
115.1419 - */
115.1420 -static void
115.1421 -handleKeyEventWithNumLockMask_New(XEvent *event, KeySym *keysym)
115.1422 -{
115.1423 -    KeySym originalKeysym = *keysym;
115.1424 -    if( !isKPevent( event ) ) {
115.1425 -        return;
115.1426 -    }
115.1427 -    if( isXsunServer( event ) && !awt_UseXKB ) {
115.1428 -        if( (event->xkey.state & ShiftMask) ) { // shift modifier is on
115.1429 -            *keysym = XKeycodeToKeysym(event->xkey.display,
115.1430 -                                   event->xkey.keycode, 3);
115.1431 -         }else {
115.1432 -            *keysym = XKeycodeToKeysym(event->xkey.display,
115.1433 -                                   event->xkey.keycode, 2);
115.1434 -         }
115.1435 -    } else {
115.1436 -        if( (event->xkey.state & ShiftMask) || // shift modifier is on
115.1437 -            ((event->xkey.state & LockMask) && // lock modifier is on
115.1438 -             (awt_ModLockIsShiftLock)) ) {     // it is interpreted as ShiftLock
115.1439 -            *keysym = XKeycodeToKeysym(event->xkey.display,
115.1440 -                                   event->xkey.keycode, 0);
115.1441 -        }else{
115.1442 -            *keysym = XKeycodeToKeysym(event->xkey.display,
115.1443 -                                   event->xkey.keycode, 1);
115.1444 -        }
115.1445 -    }
115.1446 -}
115.1447 -
115.1448 -/* Called from handleKeyEvent.
115.1449 - * The purpose of this function is to make some adjustments to keysyms
115.1450 - * that have been found to be necessary when the NumLock mask is set.
115.1451 - * They come from various bug fixes and rearchitectures.
115.1452 - * This function is meant to be called when
115.1453 - * (event->xkey.state & awt_NumLockMask) is TRUE.
115.1454 - */
115.1455 -static void
115.1456 -handleKeyEventWithNumLockMask(XEvent *event, KeySym *keysym)
115.1457 -{
115.1458 -    KeySym originalKeysym = *keysym;
115.1459 -
115.1460 -#ifndef __linux__
115.1461 -    /* The following code on Linux will cause the keypad keys
115.1462 -     * not to echo on JTextField when the NumLock is on. The
115.1463 -     * keysyms will be 0, because the last parameter 2 is not defined.
115.1464 -     * See Xlib Programming Manual, O'Reilly & Associates, Section
115.1465 -     * 9.1.5 "Other Keyboard-handling Routines", "The meaning of
115.1466 -     * the keysym list beyond the first two (unmodified, Shift or
115.1467 -     * Shift Lock) is not defined."
115.1468 -     */
115.1469 -
115.1470 -    /* Translate again with NumLock as modifier. */
115.1471 -    /* ECH - I wonder why we think that NumLock corresponds to 2?
115.1472 -     * On Linux, we've seen xmodmap -pm yield mod2 as NumLock,
115.1473 -     * but I don't know that it will be for every configuration.
115.1474 -     * Perhaps using the index (modn in awt_MToolkit.c:setup_modifier_map)
115.1475 -     * would be more correct.
115.1476 -     */
115.1477 -    *keysym = XKeycodeToKeysym(event->xkey.display,
115.1478 -                               event->xkey.keycode, 2);
115.1479 -    if (originalKeysym != *keysym) {
115.1480 -        DTRACE_PRINTLN3("%s=%x, keysym=%x",
115.1481 -          "In handleKeyEventWithNumLockMask ifndef linux: originalKeysym",
115.1482 -          originalKeysym, *keysym);
115.1483 -    }
115.1484 -#endif
115.1485 -
115.1486 -    /* Note: the XK_R? key assignments are for Type 4 kbds */
115.1487 -    switch (*keysym) {
115.1488 -        case XK_R13:
115.1489 -            *keysym = XK_KP_1;
115.1490 -            break;
115.1491 -        case XK_R14:
115.1492 -            *keysym = XK_KP_2;
115.1493 -            break;
115.1494 -        case XK_R15:
115.1495 -            *keysym = XK_KP_3;
115.1496 -            break;
115.1497 -        case XK_R10:
115.1498 -            *keysym = XK_KP_4;
115.1499 -            break;
115.1500 -        case XK_R11:
115.1501 -            *keysym = XK_KP_5;
115.1502 -            break;
115.1503 -        case XK_R12:
115.1504 -            *keysym = XK_KP_6;
115.1505 -            break;
115.1506 -        case XK_R7:
115.1507 -            *keysym = XK_KP_7;
115.1508 -            break;
115.1509 -        case XK_R8:
115.1510 -            *keysym = XK_KP_8;
115.1511 -            break;
115.1512 -        case XK_R9:
115.1513 -            *keysym = XK_KP_9;
115.1514 -            break;
115.1515 -        case XK_KP_Insert:
115.1516 -            *keysym = XK_KP_0;
115.1517 -            break;
115.1518 -        case XK_KP_Delete:
115.1519 -            *keysym = XK_KP_Decimal;
115.1520 -            break;
115.1521 -        case XK_R4:
115.1522 -            *keysym = XK_KP_Equal;  /* Type 4 kbd */
115.1523 -            break;
115.1524 -        case XK_R5:
115.1525 -            *keysym = XK_KP_Divide;
115.1526 -            break;
115.1527 -        case XK_R6:
115.1528 -            *keysym = XK_KP_Multiply;
115.1529 -            break;
115.1530 -        /*
115.1531 -         * Need the following keysym changes for Linux key releases.
115.1532 -         * Sometimes the modifier state gets messed up, so we get a
115.1533 -         * KP_Left when we should get a KP_4, for example.
115.1534 -         * XK_KP_Insert and XK_KP_Delete were already handled above.
115.1535 -         */
115.1536 -        case XK_KP_Left:
115.1537 -            *keysym = XK_KP_4;
115.1538 -            break;
115.1539 -        case XK_KP_Up:
115.1540 -            *keysym = XK_KP_8;
115.1541 -            break;
115.1542 -        case XK_KP_Right:
115.1543 -            *keysym = XK_KP_6;
115.1544 -            break;
115.1545 -        case XK_KP_Down:
115.1546 -            *keysym = XK_KP_2;
115.1547 -            break;
115.1548 -        case XK_KP_Home:
115.1549 -            *keysym = XK_KP_7;
115.1550 -            break;
115.1551 -        case XK_KP_End:
115.1552 -            *keysym = XK_KP_1;
115.1553 -            break;
115.1554 -        case XK_KP_Page_Up:
115.1555 -            *keysym = XK_KP_9;
115.1556 -            break;
115.1557 -        case XK_KP_Page_Down:
115.1558 -            *keysym = XK_KP_3;
115.1559 -            break;
115.1560 -        case XK_KP_Begin:
115.1561 -            *keysym = XK_KP_5;
115.1562 -            break;
115.1563 -        default:
115.1564 -            break;
115.1565 -    }
115.1566 -
115.1567 -    if (originalKeysym != *keysym) {
115.1568 -        DTRACE_PRINTLN2("In handleKeyEventWithNumLockMask: originalKeysym=%x, keysym=%x",
115.1569 -          originalKeysym, *keysym);
115.1570 -    }
115.1571 -}
115.1572 -
115.1573 -static void
115.1574 -handleKeyEvent(jint keyEventId,
115.1575 -               XEvent *event,
115.1576 -               XtPointer *client_data,
115.1577 -               Boolean *cont,
115.1578 -               Boolean passEvent)
115.1579 -{
115.1580 -    KeySym keysym = NoSymbol;
115.1581 -    jint keycode = java_awt_event_KeyEvent_VK_UNDEFINED;
115.1582 -    Modifiers mods = 0;
115.1583 -    Boolean mapsToUnicodeChar = FALSE;
115.1584 -    jint keyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN;
115.1585 -    jint modifiers = 0;
115.1586 -
115.1587 -    DTRACE_PRINTLN4("\nEntered handleKeyEvent: type=%d, xkeycode=%x, xstate=%x, keysym=%x",
115.1588 -      event->type, event->xkey.keycode, event->xkey.state, keysym);
115.1589 -
115.1590 -    if (currentX11InputMethodInstance != NULL
115.1591 -        && keyEventId == java_awt_event_KeyEvent_KEY_PRESSED
115.1592 -        && event->xkey.window == currentFocusWindow)
115.1593 -    {
115.1594 -        /* invokes XmbLookupString to get a committed string or keysym if any.  */
115.1595 -        if (awt_x11inputmethod_lookupString((XKeyPressedEvent*)event, &keysym)) {
115.1596 -            *cont = FALSE;
115.1597 -            return;
115.1598 -        }
115.1599 -    }
115.1600 -
115.1601 -    /* Ignore the keysym found immediately above in
115.1602 -     * awt_x11inputmethod_lookupString; the methodology in that function
115.1603 -     * sometimes returns incorrect results.
115.1604 -     *
115.1605 -     * Get keysym without taking modifiers into account first.
115.1606 -     * This keysym is not necessarily for the character that was typed:
115.1607 -     * it is for the primary layer.  So, if $ were typed by pressing
115.1608 -     * shift-4, this call should give us 4, not $
115.1609 -     *
115.1610 -     * We only want this keysym so we can use it to index into the
115.1611 -     * keymapTable to get the Java keycode associated with the
115.1612 -     * primary layer key that was pressed.
115.1613 -     */
115.1614 -    keysym = XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 0);
115.1615 -
115.1616 -    /* Linux: Sometimes the keysym returned is uppercase when CapsLock is
115.1617 -     * on and LockMask is not set in event->xkey.state.
115.1618 -     */
115.1619 -    if (keysym >= (KeySym) 'A' && keysym <= (KeySym) 'Z') {
115.1620 -        event->xkey.state |= LockMask;
115.1621 -        keysym = (KeySym) tolower((int32_t) keysym);
115.1622 -    }
115.1623 -
115.1624 -    DTRACE_PRINTLN4("In handleKeyEvent: type=%d, xkeycode=%x, xstate=%x, keysym=%x",
115.1625 -      event->type, event->xkey.keycode, event->xkey.state, keysym);
115.1626 -
115.1627 -    if (keysym == NoSymbol) {
115.1628 -        *cont = TRUE;
115.1629 -        return;
115.1630 -    }
115.1631 -
115.1632 -    if (keysym < (KeySym) 256) {
115.1633 -        keysymToAWTKeyCode(keysym, &keycode, &mapsToUnicodeChar, &keyLocation);
115.1634 -
115.1635 -        /* Now get real keysym which looks at modifiers
115.1636 -         * XtGetActionKeySym() returns wrong value with Kana Lock,
115.1637 -         * so use XtTranslateKeycode().
115.1638 -         */
115.1639 -        XtTranslateKeycode(event->xkey.display, (KeyCode) event->xkey.keycode,
115.1640 -                           event->xkey.state, &mods, &keysym);
115.1641 -        DTRACE_PRINTLN6("%s: type=%d, xkeycode=%x, xstate=%x, keysym=%x, xmods=%d",
115.1642 -          "In handleKeyEvent keysym<256 ", event->type, event->xkey.keycode,
115.1643 -          event->xkey.state, keysym, mods);
115.1644 -
115.1645 -        /* Linux: With caps lock on, chars echo lowercase. */
115.1646 -        if ((event->xkey.state & LockMask) &&
115.1647 -             (keysym >= (KeySym) 'a' && keysym <= (KeySym) 'z'))
115.1648 -        {
115.1649 -            keysym = (KeySym) toupper((int32_t) keysym);
115.1650 -        }
115.1651 -
115.1652 -        if ((event->xkey.state & ControlMask)) {
115.1653 -            switch (keysym) {
115.1654 -                case '[':
115.1655 -                case ']':
115.1656 -                case '\\':
115.1657 -                case '_':
115.1658 -                    keysym -= 64;
115.1659 -                    break;
115.1660 -                default:
115.1661 -                    if (isalpha((int32_t) keysym)) {
115.1662 -                        keysym = (KeySym) tolower((int32_t) keysym) - 'a' + 1;
115.1663 -                    }
115.1664 -                    break;
115.1665 -            }
115.1666 -        }
115.1667 -
115.1668 -        if (keysym >= (KeySym) XK_kana_fullstop &&
115.1669 -            keysym <= (KeySym) XK_semivoicedsound) {
115.1670 -            /*
115.1671 -             * 0xff61 is Unicode value of first XK_kana_fullstop.
115.1672 -             * We need X Keysym to Unicode map in post1.1 release
115.1673 -             * to support more intenational keyboard.
115.1674 -             */
115.1675 -            keysym = keysym - XK_kana_fullstop + 0xff61;
115.1676 -        }
115.1677 -
115.1678 -        modifiers = getModifiers(event->xkey.state, 0, keycode);
115.1679 -        DTRACE_PRINTLN6("%s: type=%d, xkeycode=%x, xstate=%x, keysym=%x, AWTmodifiers=%d",
115.1680 -          "In handleKeyEvent keysym<256 ", event->type, event->xkey.keycode,
115.1681 -          event->xkey.state, keysym, modifiers);
115.1682 -
115.1683 -        awt_post_java_key_event(client_data,
115.1684 -                                keyEventId,
115.1685 -                                (passEvent == TRUE) ?  event : NULL,
115.1686 -                                event->xkey.time,
115.1687 -                                keycode,
115.1688 -                                (jchar) keysym,
115.1689 -                                modifiers,
115.1690 -                                keyLocation,
115.1691 -                                event);
115.1692 -
115.1693 -        if (keyEventId == java_awt_event_KeyEvent_KEY_PRESSED) {
115.1694 -            awt_post_java_key_event(client_data,
115.1695 -              java_awt_event_KeyEvent_KEY_TYPED,
115.1696 -              NULL,
115.1697 -              event->xkey.time,
115.1698 -              java_awt_event_KeyEvent_VK_UNDEFINED,
115.1699 -              (jchar) keysym,
115.1700 -              modifiers,
115.1701 -              java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN,
115.1702 -              event);
115.1703 -
115.1704 -        }
115.1705 -    } else {
115.1706 -        if (event->xkey.state & awt_NumLockMask) {
115.1707 -            if( awt_UseType4Patch ) {
115.1708 -                handleKeyEventWithNumLockMask(event, &keysym);
115.1709 -            }else{
115.1710 -                handleKeyEventWithNumLockMask_New(event, &keysym);
115.1711 -            }
115.1712 -        }
115.1713 -
115.1714 -        if (keysym == XK_ISO_Left_Tab) {
115.1715 -            keysym = XK_Tab;
115.1716 -        }
115.1717 -
115.1718 -        /* The keysym here does not consider modifiers, so these results
115.1719 -         * are relevant to the KEY_PRESSED event only, not the KEY_TYPED
115.1720 -         */
115.1721 -        keysymToAWTKeyCode(keysym, &keycode, &mapsToUnicodeChar, &keyLocation);
115.1722 -        DTRACE_PRINTLN3("In handleKeyEvent: keysym=%x, AWTkeycode=%x, mapsToUnicodeChar=%d",
115.1723 -          keysym, keycode, mapsToUnicodeChar);
115.1724 -
115.1725 -        if (keycode == java_awt_event_KeyEvent_VK_UNDEFINED) {
115.1726 -            *cont = TRUE;
115.1727 -            return;
115.1728 -        }
115.1729 -
115.1730 -        /* Need to take care of keysyms > 0xFFFF here
115.1731 -         * Most of these keys don't map to unicode characters, but some do.
115.1732 -         *
115.1733 -         * For keys that don't map to unicode characters, the keysym
115.1734 -         * is irrelevant at this point.  We set the keysym to zero
115.1735 -         * to ensure that the switch statement immediately below
115.1736 -         * this function call (in adjustKeySym) won't incorrectly act
115.1737 -         * on them after the high bits are stripped off.
115.1738 -         *
115.1739 -         * For keys that do map to unicode characters, we change the keysym
115.1740 -         * to the equivalent that is < 0xFFFF
115.1741 -         */
115.1742 -        handleVendorKeySyms(event, &keysym);
115.1743 -
115.1744 -        /* This function is a conglomeration of bug fixes that adjust
115.1745 -         * the keysym and XEvent keycode for this key event.
115.1746 -         */
115.1747 -        adjustKeySym(event, &keysym);
115.1748 -
115.1749 -        modifiers = getModifiers(event->xkey.state, 0, keycode);
115.1750 -
115.1751 -        DTRACE_PRINTLN6("%s: type=%d, xkeycode=%x, xstate=%x, keysym=%x, xmods=%d",
115.1752 -          "In handleKeyEvent keysym>=256 ", event->type, event->xkey.keycode,
115.1753 -          event->xkey.state, keysym, mods);
115.1754 -        DTRACE_PRINTLN2("                              AWTkeycode=%x, AWTmodifiers=%d",
115.1755 -          keycode, modifiers);
115.1756 -
115.1757 -        awt_post_java_key_event(client_data,
115.1758 -          keyEventId,
115.1759 -          (passEvent == TRUE) ? event : NULL,
115.1760 -          event->xkey.time,
115.1761 -          keycode,
115.1762 -          (jchar) (mapsToUnicodeChar ? keysym :
115.1763 -            java_awt_event_KeyEvent_CHAR_UNDEFINED),
115.1764 -          modifiers,
115.1765 -          keyLocation,
115.1766 -          event);
115.1767 -
115.1768 -        /* If this was a keyPressed event, we may need to post a
115.1769 -         * keyTyped event, too.  Otherwise, return.
115.1770 -         */
115.1771 -        if (keyEventId == java_awt_event_KeyEvent_KEY_RELEASED) {
115.1772 -            return;
115.1773 -        }
115.1774 -        DTRACE_PRINTLN("This is a keyPressed event");
115.1775 -
115.1776 -        /* XtTranslateKeycode seems to return slightly bogus values for the
115.1777 -         * Escape key (keysym==1004ff69==osfXK_Cancel, xmods=2) on Solaris,
115.1778 -         * so we just create the KEY_TYPED as a special case for Escape here.
115.1779 -         * (Linux works fine, and this was also okay running under VNC.)
115.1780 -         */
115.1781 -        if (keycode == java_awt_event_KeyEvent_VK_ESCAPE) {
115.1782 -            awt_post_java_key_event(client_data,
115.1783 -              java_awt_event_KeyEvent_KEY_TYPED,
115.1784 -              NULL,
115.1785 -              event->xkey.time,
115.1786 -              java_awt_event_KeyEvent_VK_UNDEFINED,
115.1787 -              (jchar) keysym,
115.1788 -              modifiers,
115.1789 -              java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN,
115.1790 -              event);
115.1791 -
115.1792 -            DTRACE_PRINTLN("Posted a keyTyped event for VK_ESCAPE");
115.1793 -            return;
115.1794 -        }
115.1795 -
115.1796 -        /* Now get real keysym which looks at modifiers for keyTyped event.
115.1797 -         * XtGetActionKeySym() returns wrong value with Kana Lock,
115.1798 -         * so use XtTranslateKeycode().
115.1799 -         */
115.1800 -        XtTranslateKeycode(event->xkey.display, (KeyCode) event->xkey.keycode,
115.1801 -                           event->xkey.state, &mods, &keysym);
115.1802 -        DTRACE_PRINTLN6("%s: type=%d, xkeycode=%x, xstate=%x, keysym=%x, xmods=%d",
115.1803 -          "In handleKeyEvent keysym>=256 ", event->type, event->xkey.keycode,
115.1804 -          event->xkey.state, keysym, mods);
115.1805 -
115.1806 -        if (keysym == NoSymbol) {
115.1807 -            return;
115.1808 -        }
115.1809 -
115.1810 -        if (event->xkey.state & awt_NumLockMask) {
115.1811 -            if( awt_UseType4Patch ) {
115.1812 -                handleKeyEventWithNumLockMask(event, &keysym);
115.1813 -            }else{
115.1814 -                handleKeyEventWithNumLockMask_New(event, &keysym);
115.1815 -            }
115.1816 -        }
115.1817 -
115.1818 -        if (keysym == XK_ISO_Left_Tab) {
115.1819 -            keysym = XK_Tab;
115.1820 -        }
115.1821 -
115.1822 -        /* Map the real keysym to a Java keycode */
115.1823 -        keysymToAWTKeyCode(keysym, &keycode, &mapsToUnicodeChar, &keyLocation);
115.1824 -        DTRACE_PRINTLN3("In handleKeyEvent: keysym=%x, AWTkeycode=%x, mapsToUnicodeChar=%d",
115.1825 -          keysym, keycode, mapsToUnicodeChar);
115.1826 -
115.1827 -        /* If it doesn't map to a Unicode character, don't post a keyTyped event */
115.1828 -        if (!mapsToUnicodeChar) {
115.1829 -            return;
115.1830 -        }
115.1831 -
115.1832 -        handleVendorKeySyms(event, &keysym);
115.1833 -        adjustKeySym(event, &keysym);
115.1834 -        DTRACE_PRINT4("In handleKeyEvent: type=%d, xkeycode=%x, xstate=%x, keysym=%x",
115.1835 -          event->type, event->xkey.keycode, event->xkey.state, keysym);
115.1836 -        DTRACE_PRINTLN2(", AWTkeycode=%x, AWTmodifiers=%d", keycode, modifiers);
115.1837 -
115.1838 -        awt_post_java_key_event(client_data,
115.1839 -          java_awt_event_KeyEvent_KEY_TYPED,
115.1840 -          NULL,
115.1841 -          event->xkey.time,
115.1842 -          java_awt_event_KeyEvent_VK_UNDEFINED,
115.1843 -          (jchar) keysym,
115.1844 -          modifiers,
115.1845 -          java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN,
115.1846 -          event);
115.1847 -    }
115.1848 -}
115.1849 -
115.1850 -
115.1851 -static void
115.1852 -translateXY(Widget w, jint *xp, jint *yp)
115.1853 -{
115.1854 -    Position wx, wy;
115.1855 -
115.1856 -    XtVaGetValues(w, XmNx, &wx, XmNy, &wy, NULL);
115.1857 -    *xp += wx;
115.1858 -    *yp += wy;
115.1859 -}
115.1860 -
115.1861 -
115.1862 -/*
115.1863 - * Part fix for bug id 4017222. Return the root widget of the Widget parameter.
115.1864 - */
115.1865 -Widget
115.1866 -getRootWidget(Widget w) {
115.1867 -    if(!w) return NULL;
115.1868 -
115.1869 -    if(XtParent(w))
115.1870 -        return getRootWidget(XtParent(w));
115.1871 -    else
115.1872 -        return w;
115.1873 -}
115.1874 -
115.1875 -#define ABS(x) ((x) < 0 ? -(x) : (x))
115.1876 -
115.1877 -/* This proc is the major AWT engine for processing X events
115.1878 - * for Java components and is the proc responsible for taking
115.1879 - * X events and posting their corresponding Java event to the
115.1880 - * AWT EventQueue.  It is set up to be called both from an Xt
115.1881 - * event handler and directly from MToolkit.c:shouldDispatchToWidget().
115.1882 - * For the latter case, the "passEvent" parameter will be true,
115.1883 - * which means that the event is being posted on the Java queue
115.1884 - * BEFORE it is being passed to Xt and so a copy of the X event
115.1885 - * must be stored within the Java event structure so it can be
115.1886 - * dispatched to Xt later on.
115.1887 - */
115.1888 -void
115.1889 -awt_canvas_handleEvent(Widget w, XtPointer client_data,
115.1890 -                       XEvent * event, struct WidgetInfo *winfo,
115.1891 -                       Boolean * cont, Boolean passEvent)
115.1892 -{
115.1893 -    static jint clickCount = 1;
115.1894 -    static XtPointer lastPeer = NULL;
115.1895 -    static Time lastTime = 0;
115.1896 -    static jint lastx = 0;
115.1897 -    static jint lasty = 0;
115.1898 -    static int32_t rbutton = 0;
115.1899 -    static int32_t lastButton = 0;
115.1900 -    Boolean popupTrigger;
115.1901 -    jint x, y;
115.1902 -    jint modifiers = 0;
115.1903 -    jint button = java_awt_event_MouseEvent_NOBUTTON;
115.1904 -    uint32_t fullRelease = 0;
115.1905 -    WidgetClass wclass = NULL;
115.1906 -
115.1907 -    /* Any event handlers which take peer instance pointers as
115.1908 -     * client_data should check to ensure the widget has not been
115.1909 -     * marked as destroyed as a result of a dispose() call on the peer
115.1910 -     * (which can result in the peer instance pointer already haven
115.1911 -     * been gc'd by the time this event is processed)
115.1912 -     */
115.1913 -    if (w->core.being_destroyed) {
115.1914 -        return;
115.1915 -    }
115.1916 -    *cont = FALSE;
115.1917 -
115.1918 -    switch (event->type) {
115.1919 -        case SelectionClear:
115.1920 -        case SelectionNotify:
115.1921 -        case SelectionRequest:
115.1922 -            *cont = TRUE;
115.1923 -            break;
115.1924 -        case GraphicsExpose:
115.1925 -        case Expose:
115.1926 -            HandleExposeEvent(w, (jobject) client_data, event);
115.1927 -            break;
115.1928 -        case FocusIn:
115.1929 -        case FocusOut:
115.1930 -            *cont = TRUE;
115.1931 -            updateCursor(client_data, CACHE_UPDATE); // 4840883
115.1932 -            // We no longer listen to the Motif focus notifications.
115.1933 -            // Instead we call focus callbacks in the times we think
115.1934 -            // appropriate trying to simulate correct Motif widget system
115.1935 -            // behavior.
115.1936 -            break;
115.1937 -        case ButtonPress:
115.1938 -            x = (jint) event->xbutton.x;
115.1939 -            y = (jint) event->xbutton.y;
115.1940 -
115.1941 -            if (lastPeer == client_data &&
115.1942 -                lastButton == event->xbutton.button &&
115.1943 -                (event->xbutton.time - lastTime) <= (Time) awt_multiclick_time) {
115.1944 -                    clickCount++;
115.1945 -            } else {
115.1946 -                clickCount = 1;
115.1947 -                lastPeer = client_data;
115.1948 -                lastButton = event->xbutton.button;
115.1949 -                lastx = x;
115.1950 -                lasty = y;
115.1951 -            }
115.1952 -            lastTime = event->xbutton.time;
115.1953 -
115.1954 -            /* On MouseEvent.MOUSE_PRESSED, RELEASED and CLICKED  only new modifiers and
115.1955 -             * modifier for changed mouse button are set.
115.1956 -             */
115.1957 -            button = getButton(event->xbutton.button);
115.1958 -            modifiers = getModifiers(event->xbutton.state, button, 0);
115.1959 -
115.1960 -
115.1961 -            /* If the widget is a subwidget on a component we need to
115.1962 -             * translate the x,y into the coordinate space of the component.
115.1963 -             */
115.1964 -            if (winfo != NULL && winfo->widget != winfo->origin) {
115.1965 -                translateXY(winfo->widget, &x, &y);
115.1966 -            }
115.1967 -
115.1968 -            if (XtIsSubclass(w, xmScrollBarWidgetClass) && findWidgetInfo(w) != NULL) {
115.1969 -                passEvent = FALSE;
115.1970 -                *cont = TRUE;
115.1971 -            }
115.1972 -
115.1973 -            /* Mouse wheel events come in as button 4 (wheel up) and
115.1974 -             * button 5 (wheel down).
115.1975 -             */
115.1976 -            if (lastButton == 4 || lastButton == 5) {
115.1977 -                *cont = FALSE;
115.1978 -                awt_post_java_mouse_event(client_data,
115.1979 -                                          java_awt_event_MouseEvent_MOUSE_WHEEL,
115.1980 -                                          (passEvent == TRUE) ? event : NULL,
115.1981 -                                          event->xbutton.time,
115.1982 -                                          modifiers,
115.1983 -                                          x, y,
115.1984 -                                          (jint) (event->xbutton.x_root),
115.1985 -                                          (jint) (event->xbutton.y_root),
115.1986 -                                          clickCount,
115.1987 -                                          False,
115.1988 -                                          lastButton == 4 ? -1 : 1,
115.1989 -                                          java_awt_event_MouseEvent_NOBUTTON);
115.1990 -                /* we're done with this event */
115.1991 -                break;
115.1992 -            }
115.1993 -
115.1994 -            /* (4168006) Find out out how many buttons we have
115.1995 -             * If this is a two button system Right == 2
115.1996 -             * If this is a three button system Right == 3
115.1997 -             */
115.1998 -            if ( rbutton == 0 ) {
115.1999 -                unsigned char map[5];
115.2000 -                rbutton = XGetPointerMapping ( awt_display, map, 3 );
115.2001 -            }
115.2002 -
115.2003 -            if (event->xbutton.button == rbutton || event->xbutton.button > 2) {
115.2004 -                popupTrigger = True;
115.2005 -            } else {
115.2006 -                popupTrigger = False;
115.2007 -            }
115.2008 -
115.2009 -            awt_post_java_mouse_event(client_data,
115.2010 -                                      java_awt_event_MouseEvent_MOUSE_PRESSED,
115.2011 -                                      (passEvent == TRUE) ? event : NULL,
115.2012 -                                      event->xbutton.time,
115.2013 -                                      modifiers,
115.2014 -                                      x, y,
115.2015 -                                      (jint) (event->xbutton.x_root),
115.2016 -                                      (jint) (event->xbutton.y_root),
115.2017 -                                      clickCount,
115.2018 -                                      popupTrigger, 0,
115.2019 -                                      button);
115.2020 -
115.2021 -            drag_source = w;
115.2022 -
115.2023 -            break;
115.2024 -        case ButtonRelease:
115.2025 -            if (XtIsSubclass(w, xmScrollBarWidgetClass) && findWidgetInfo(w) != NULL) {
115.2026 -                passEvent = FALSE;
115.2027 -                *cont = TRUE;
115.2028 -            }
115.2029 -
115.2030 -            /*
115.2031 -             * For button 4 & 5 (mouse wheel) we can simply ignore this event.
115.2032 -             * We dispatch the wheel on the ButtonPress.
115.2033 -             */
115.2034 -            if (event->xbutton.button == 4 ||
115.2035 -                event->xbutton.button == 5) {
115.2036 -                break;
115.2037 -            }
115.2038 -
115.2039 -            prevWidget = NULL;
115.2040 -            x = (jint) event->xbutton.x;
115.2041 -            y = (jint) event->xbutton.y;
115.2042 -            /* On MouseEvent.MOUSE_PRESSED, RELEASED and CLICKED  only new modifiers and
115.2043 -             * modifier for changed mouse button are set.
115.2044 -             */
115.2045 -            button = getButton(event->xbutton.button);
115.2046 -            modifiers = getModifiers(event->xbutton.state, button, 0);
115.2047 -
115.2048 -            fullRelease =
115.2049 -              ((event->xbutton.state & Button1Mask) &&
115.2050 -               !(event->xbutton.state & Button2Mask) &&
115.2051 -               !(event->xbutton.state & Button3Mask) &&
115.2052 -               (event->xbutton.button == Button1)) ||
115.2053 -              (!(event->xbutton.state & Button1Mask) &&
115.2054 -               (event->xbutton.state & Button2Mask) &&
115.2055 -               !(event->xbutton.state & Button3Mask) &&
115.2056 -               (event->xbutton.button == Button2)) ||
115.2057 -              (!(event->xbutton.state & Button1Mask) &&
115.2058 -               !(event->xbutton.state & Button2Mask) &&
115.2059 -               (event->xbutton.state & Button3Mask) &&
115.2060 -               (event->xbutton.button == Button3));
115.2061 -
115.2062 -            /* If the widget is a subwidget on a component we need to
115.2063 -             * translate the x,y into the coordinate space of the component.
115.2064 -             */
115.2065 -            if (winfo != NULL && winfo->widget != winfo->origin) {
115.2066 -                translateXY(winfo->widget, &x, &y);
115.2067 -            }
115.2068 -            drag_source = NULL;
115.2069 -            awt_post_java_mouse_event(client_data,
115.2070 -                                      java_awt_event_MouseEvent_MOUSE_RELEASED,
115.2071 -                                      (passEvent == TRUE) ? event : NULL,
115.2072 -                                      event->xbutton.time,
115.2073 -                                      modifiers,
115.2074 -                                      x, y,
115.2075 -                                      (jint) (event->xbutton.x_root),
115.2076 -                                      (jint) (event->xbutton.y_root),
115.2077 -                                      clickCount,
115.2078 -                                      FALSE, 0,
115.2079 -                                      button);
115.2080 -
115.2081 -            if (lastPeer == client_data) {
115.2082 -                awt_post_java_mouse_event(client_data,
115.2083 -                                          java_awt_event_MouseEvent_MOUSE_CLICKED,
115.2084 -                                          NULL,
115.2085 -                                          event->xbutton.time,
115.2086 -                                          modifiers,
115.2087 -                                          x, y,
115.2088 -                                          (jint) (event->xbutton.x_root),
115.2089 -                                          (jint) (event->xbutton.y_root),
115.2090 -                                          clickCount,
115.2091 -                                          FALSE, 0,
115.2092 -                                          button);
115.2093 -            }
115.2094 -
115.2095 -            if (fullRelease) {
115.2096 -                updateCursor(client_data, UPDATE_ONLY);
115.2097 -            }
115.2098 -
115.2099 -        break;
115.2100 -        case MotionNotify:
115.2101 -            if (XtIsSubclass(w, xmScrollBarWidgetClass) && findWidgetInfo(w) != NULL) {
115.2102 -                passEvent = FALSE;
115.2103 -                *cont = TRUE;
115.2104 -            }
115.2105 -
115.2106 -            x = (jint) event->xmotion.x;
115.2107 -            y = (jint) event->xmotion.y;
115.2108 -
115.2109 -            /* If a motion comes in while a multi-click is pending,
115.2110 -             * allow a smudge factor so that moving the mouse by a small
115.2111 -             * amount does not wipe out the multi-click state variables.
115.2112 -             */
115.2113 -            if (!(lastPeer == client_data &&
115.2114 -                  ((event->xmotion.time - lastTime) <= (Time) awt_multiclick_time) &&
115.2115 -                  (ABS(lastx - x) < awt_multiclick_smudge &&
115.2116 -                   ABS(lasty - y) < awt_multiclick_smudge))) {
115.2117 -                clickCount = (jint) 0;
115.2118 -                lastTime = (Time) 0;
115.2119 -                lastPeer = NULL;
115.2120 -                lastx = (jint) 0;
115.2121 -                lasty = (jint) 0;
115.2122 -            }
115.2123 -            /* On other MouseEvent only new modifiers and
115.2124 -             * old mouse modifiers are set.
115.2125 -             */
115.2126 -            modifiers = getModifiers(event->xmotion.state, 0, 0);
115.2127 -
115.2128 -            /* If the widget is a subwidget on a component we need to
115.2129 -             * translate the x,y into the coordinate space of the component.
115.2130 -             */
115.2131 -            if (winfo != NULL && winfo->widget != winfo->origin) {
115.2132 -                translateXY(winfo->widget, &x, &y);
115.2133 -            }
115.2134 -            if (event->xmotion.state & (Button1Mask | Button2Mask | Button3Mask)) {
115.2135 -                if (!clickCount) {
115.2136 -
115.2137 -            /*
115.2138 -                Fix for bug id 4017222. A button is down, so EnterNotify and
115.2139 -                LeaveNotify events are only being sent to this widget. If
115.2140 -                the pointer has moved over a new widget, manually generate
115.2141 -                MouseEnter and MouseExit and send them to the right widgets.
115.2142 -            */
115.2143 -
115.2144 -                extern Widget awt_WidgetAtXY(Widget root, Position x, Position y);
115.2145 -                extern Widget awt_GetWidgetAtPointer();
115.2146 -                Widget currentWidget=NULL, topLevelW;
115.2147 -                Position wx=0, wy=0;
115.2148 -
115.2149 -                XtTranslateCoords(w, (int32_t) x, (int32_t) y, &wx, &wy);
115.2150 -                /* Get the top level widget underneath the mouse pointer */
115.2151 -                currentWidget = awt_GetWidgetAtPointer();
115.2152 -                /* Get the exact widget at the current XY from the top level */
115.2153 -                currentWidget = awt_WidgetAtXY(currentWidget, wx, wy);
115.2154 -                if ((prevWidget != NULL) && (prevWidget != w) &&
115.2155 -                    (currentWidget != prevWidget) && awt_isAwtWidget(prevWidget) &&
115.2156 -                    !prevWidget->core.being_destroyed) {
115.2157 -                    XtPointer userData=NULL;
115.2158 -                    XtVaGetValues(prevWidget, XmNuserData, &userData, NULL);
115.2159 -                    if (userData) {
115.2160 -                        awt_post_java_mouse_event(userData,
115.2161 -                            java_awt_event_MouseEvent_MOUSE_EXITED,
115.2162 -                            (passEvent==TRUE) ? event : NULL,
115.2163 -                            event->xmotion.time,
115.2164 -                            modifiers,
115.2165 -                            x, y,
115.2166 -                            (jint) (event->xmotion.x_root),
115.2167 -                            (jint) (event->xmotion.y_root),
115.2168 -                            clickCount,
115.2169 -                            FALSE, 0,
115.2170 -                            java_awt_event_MouseEvent_NOBUTTON);
115.2171 -                    }
115.2172 -                }
115.2173 -
115.2174 -                if ((currentWidget != NULL) && (currentWidget != w) &&
115.2175 -                    (currentWidget != prevWidget) && awt_isAwtWidget(currentWidget)) {
115.2176 -                    XtPointer userData=NULL;
115.2177 -                    XtVaGetValues(currentWidget, XmNuserData, &userData, NULL);
115.2178 -                    if (userData) {
115.2179 -                        awt_post_java_mouse_event(userData,
115.2180 -                            java_awt_event_MouseEvent_MOUSE_ENTERED,
115.2181 -                            (passEvent==TRUE) ? event : NULL,
115.2182 -                            event->xmotion.time,
115.2183 -                            modifiers,
115.2184 -                            x, y,
115.2185 -                            (jint) (event->xmotion.x_root),
115.2186 -                            (jint) (event->xmotion.y_root),
115.2187 -                            clickCount,
115.2188 -                            FALSE, 0,
115.2189 -                            java_awt_event_MouseEvent_NOBUTTON);
115.2190 -                    }
115.2191 -
115.2192 -                    updateCursor(userData, CACHE_ONLY);
115.2193 -                    awt_util_setCursor(currentWidget, None);
115.2194 -                }
115.2195 -
115.2196 -                prevWidget = currentWidget;
115.2197 -                /* end 4017222 */
115.2198 -
115.2199 -
115.2200 -                awt_post_java_mouse_event(client_data,
115.2201 -                                          java_awt_event_MouseEvent_MOUSE_DRAGGED,
115.2202 -                                          (passEvent == TRUE) ? event : NULL,
115.2203 -                                          event->xmotion.time,
115.2204 -                                          modifiers,
115.2205 -                                          x, y,
115.2206 -                                          (jint) (event->xmotion.x_root),
115.2207 -                                          (jint) (event->xmotion.y_root),
115.2208 -                                          clickCount,
115.2209 -                                          FALSE, 0,
115.2210 -                                          java_awt_event_MouseEvent_NOBUTTON);
115.2211 -
115.2212 -            }
115.2213 -            } else {
115.2214 -
115.2215 -                awt_post_java_mouse_event(client_data,
115.2216 -                                          java_awt_event_MouseEvent_MOUSE_MOVED,
115.2217 -                                          (passEvent == TRUE) ? event : NULL,
115.2218 -                                          event->xmotion.time,
115.2219 -                                          modifiers,
115.2220 -                                          x, y,
115.2221 -                                          (jint) (event->xmotion.x_root),
115.2222 -                                          (jint) (event->xmotion.y_root),
115.2223 -                                          clickCount,
115.2224 -                                          FALSE, 0,
115.2225 -                                          java_awt_event_MouseEvent_NOBUTTON);
115.2226 -            }
115.2227 -            break;
115.2228 -        case KeyPress:
115.2229 -            handleKeyEvent(java_awt_event_KeyEvent_KEY_PRESSED,
115.2230 -                           event, client_data, cont, TRUE);
115.2231 -            break;
115.2232 -        case KeyRelease:
115.2233 -            handleKeyEvent(java_awt_event_KeyEvent_KEY_RELEASED,
115.2234 -                           event, client_data, cont, TRUE);
115.2235 -            break;
115.2236 -        case EnterNotify:
115.2237 -        case LeaveNotify:
115.2238 -/*
115.2239 -  printf("----->%s on %s(%x):mode=%d detail = %d\n",
115.2240 -  event->type == EnterNotify?"EnterNotify":"LeaveNotify",
115.2241 -  XtName(w), w,
115.2242 -  ((XCrossingEvent*)event)->mode, ((XCrossingEvent*)event)->detail);
115.2243 -*/
115.2244 -        if (event->xcrossing.mode != NotifyNormal ||
115.2245 -                ((event->xcrossing.detail == NotifyVirtual ||
115.2246 -                  event->xcrossing.detail == NotifyNonlinearVirtual) &&
115.2247 -                 !XtIsSubclass(w, xmScrolledWindowWidgetClass))) {
115.2248 -                *cont = TRUE;
115.2249 -                return;
115.2250 -            }
115.2251 -
115.2252 -            /* fix for 4454304.
115.2253 -             * We should not post MOUSE_ENTERED and MOUSE_EXITED events
115.2254 -             * if the mouse pointer is in the place between component
115.2255 -             * and its scrollbars.
115.2256 -             * kdm@sparc.spb.su
115.2257 -             */
115.2258 -            if (winfo != NULL && winfo->widget != NULL) {
115.2259 -                wclass = XtClass(winfo->widget);
115.2260 -                if (event->xcrossing.subwindow == NULL
115.2261 -                    && event->xcrossing.detail == NotifyInferior
115.2262 -                    && (wclass == xmTextWidgetClass
115.2263 -                        || wclass == xmListWidgetClass)) {
115.2264 -                    *cont = TRUE;
115.2265 -                    return;
115.2266 -                }
115.2267 -            }
115.2268 -
115.2269 -            clickCount = (jint) 0;
115.2270 -            lastTime = (Time) 0;
115.2271 -            lastPeer = NULL;
115.2272 -
115.2273 -            /* On other MouseEvent only new modifiers and
115.2274 -             * old mouse modifiers are set.
115.2275 -             */
115.2276 -            modifiers = getModifiers(event->xcrossing.state, 0, 0);
115.2277 -
115.2278 -            switch (event->type) {
115.2279 -                case EnterNotify:
115.2280 -                    awt_post_java_mouse_event(client_data,
115.2281 -                                              java_awt_event_MouseEvent_MOUSE_ENTERED,
115.2282 -                                              (passEvent == TRUE) ? event : NULL,
115.2283 -                                              event->xcrossing.time,
115.2284 -                                              modifiers,
115.2285 -                                              (jint) (event->xcrossing.x),
115.2286 -                                              (jint) (event->xcrossing.y),
115.2287 -                                              (jint) (event->xcrossing.x_root),
115.2288 -                                              (jint) (event->xcrossing.y_root),
115.2289 -                                              clickCount,
115.2290 -                                              FALSE, 0,
115.2291 -                                              java_awt_event_MouseEvent_NOBUTTON);
115.2292 -                    if (!(event->xcrossing.state
115.2293 -                        & (Button1Mask | Button2Mask | Button3Mask))) {
115.2294 -                        updateCursor(client_data, CACHE_UPDATE);
115.2295 -                    }
115.2296 -
115.2297 -                    break;
115.2298 -                case LeaveNotify:
115.2299 -                    awt_post_java_mouse_event(client_data,
115.2300 -                                              java_awt_event_MouseEvent_MOUSE_EXITED,
115.2301 -                                              (passEvent == TRUE) ? event : NULL,
115.2302 -                                              event->xcrossing.time,
115.2303 -                                              modifiers,
115.2304 -                                              (jint) (event->xcrossing.x),
115.2305 -                                              (jint) (event->xcrossing.y),
115.2306 -                                              (jint) (event->xcrossing.x_root),
115.2307 -                                              (jint) (event->xcrossing.y_root),
115.2308 -                                              clickCount,
115.2309 -                                              FALSE, 0,
115.2310 -                                              java_awt_event_MouseEvent_NOBUTTON);
115.2311 -                    break;
115.2312 -            }
115.2313 -            break;
115.2314 -
115.2315 -        default:
115.2316 -            break;
115.2317 -    }
115.2318 -}
115.2319 -
115.2320 -/*
115.2321 - * client_data is MComponentPeer subclass
115.2322 - */
115.2323 -void
115.2324 -awt_canvas_event_handler(Widget w, XtPointer client_data,
115.2325 -                         XEvent * event, Boolean * cont)
115.2326 -{
115.2327 -    awt_canvas_handleEvent(w, client_data, event, NULL, cont, FALSE);
115.2328 -}
115.2329 -
115.2330 -void
115.2331 -awt_canvas_reconfigure(struct FrameData *wdata)
115.2332 -{
115.2333 -    Dimension w, h;
115.2334 -
115.2335 -    if (wdata->winData.comp.widget == NULL ||
115.2336 -        XtParent(wdata->winData.comp.widget) == NULL) {
115.2337 -        return;
115.2338 -    }
115.2339 -    XtVaGetValues(XtParent(wdata->winData.comp.widget), XmNwidth, &w, XmNheight, &h, NULL);
115.2340 -    XtConfigureWidget(wdata->winData.comp.widget,
115.2341 -                      -(wdata->left),
115.2342 -                      -(wdata->top),
115.2343 -                      w + (wdata->left + wdata->right),
115.2344 -                      h + (wdata->top + wdata->bottom),
115.2345 -                      0);
115.2346 -}
115.2347 -
115.2348 -static void
115.2349 -Wrap_event_handler(Widget widget,
115.2350 -                   XtPointer client_data,
115.2351 -                   XmDrawingAreaCallbackStruct * call_data)
115.2352 -{
115.2353 -    awt_canvas_reconfigure((struct FrameData *) client_data);
115.2354 -}
115.2355 -
115.2356 -
115.2357 -Widget
115.2358 -awt_canvas_create(XtPointer this,
115.2359 -                  Widget parent,
115.2360 -                  char *base,
115.2361 -                  int32_t width,
115.2362 -                  int32_t height,
115.2363 -                  Boolean parentIsFrame,
115.2364 -                  struct FrameData *wdata,
115.2365 -                  AwtGraphicsConfigDataPtr awtData)
115.2366 -{
115.2367 -    Widget newCanvas;
115.2368 -    Widget wrap;
115.2369 -#define MAX_ARGC 20
115.2370 -    Arg args[MAX_ARGC];
115.2371 -    int32_t argc;
115.2372 -    char name[128];
115.2373 -    static XtTranslations translationKeyDown = NULL;
115.2374 -
115.2375 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
115.2376 -
115.2377 -
115.2378 -    if (parent == NULL) {
115.2379 -        JNU_ThrowNullPointerException(env, "NullPointerException");
115.2380 -        return NULL;
115.2381 -    }
115.2382 -    if (width == 0) {
115.2383 -        width = 1;
115.2384 -    }
115.2385 -    if (height == 0) {
115.2386 -        height = 1;
115.2387 -    }
115.2388 -
115.2389 -    if (wdata != NULL) {
115.2390 -        argc = 0;
115.2391 -        if  (!parentIsFrame)
115.2392 -        {
115.2393 -            XtSetArg(args[argc], XmNwidth, width);
115.2394 -            argc++;
115.2395 -            XtSetArg(args[argc], XmNheight, height);
115.2396 -            argc++;
115.2397 -        }
115.2398 -        XtSetArg(args[argc], XmNmarginWidth, 0);
115.2399 -        argc++;
115.2400 -        XtSetArg(args[argc], XmNmarginHeight, 0);
115.2401 -        argc++;
115.2402 -        XtSetArg(args[argc], XmNspacing, 0);
115.2403 -        argc++;
115.2404 -        XtSetArg(args[argc], XmNresizePolicy, XmRESIZE_NONE);
115.2405 -        argc++;
115.2406 -        /* check for overflowing name? */
115.2407 -        strcpy(name, base);
115.2408 -        strcat(name, "wrap");
115.2409 -
115.2410 -        DASSERT(!(argc > MAX_ARGC));
115.2411 -        wrap = XmCreateDrawingArea(parent, name, args, argc);
115.2412 -        if  (!parentIsFrame)
115.2413 -        {
115.2414 -            /* Fixing bugs in frame module (awt_Frame.c).  It will now
115.2415 -               provide the resize handling for this inner/parent canvas.*/
115.2416 -            XtAddCallback(wrap, XmNresizeCallback,
115.2417 -                          (XtCallbackProc) Wrap_event_handler, wdata);
115.2418 -        }
115.2419 -        XtManageChild(wrap);
115.2420 -    } else {
115.2421 -        wrap = parent;
115.2422 -    }
115.2423 -
115.2424 -    /* check for overflowing name? */
115.2425 -    strcpy(name, base);
115.2426 -    strcat(name, "canvas");
115.2427 -
115.2428 -    argc = 0;
115.2429 -    XtSetArg(args[argc], XmNspacing, 0);
115.2430 -    argc++;
115.2431 -    if  (!parentIsFrame)
115.2432 -    {
115.2433 -        XtSetArg(args[argc], XmNwidth, width);
115.2434 -        argc++;
115.2435 -        XtSetArg(args[argc], XmNheight, height);
115.2436 -        argc++;
115.2437 -    }
115.2438 -    XtSetArg(args[argc], XmNmarginHeight, 0);
115.2439 -    argc++;
115.2440 -    XtSetArg(args[argc], XmNmarginWidth, 0);
115.2441 -    argc++;
115.2442 -    XtSetArg(args[argc], XmNresizePolicy, XmRESIZE_NONE);
115.2443 -    argc++;
115.2444 -    XtSetArg(args[argc], XmNuserData, this);
115.2445 -    argc++;
115.2446 -    /* Fixed 4059430, 3/11/98, robi.khan@eng
115.2447 -     * install insert proc callback so components are ordered correctly
115.2448 -     * when added directly to frame/dialogs/windows
115.2449 -     */
115.2450 -    XtSetArg(args[argc], XmNinsertPosition, (XtPointer) awt_util_insertCallback);
115.2451 -    argc++;
115.2452 -
115.2453 -    if (awtData != getDefaultConfig(awtData->awt_visInfo.screen)) {
115.2454 -        XtSetArg (args[argc], XtNvisual, awtData->awt_visInfo.visual); argc++;
115.2455 -        XtSetArg (args[argc], XmNdepth, awtData->awt_depth); argc++;
115.2456 -        XtSetArg (args[argc], XmNscreen,
115.2457 -                  ScreenOfDisplay(awt_display,
115.2458 -                                  awtData->awt_visInfo.screen)); argc++;
115.2459 -
115.2460 -        if (awtData->awt_cmap == None) {
115.2461 -            awtJNI_CreateColorData (env, awtData, 1);
115.2462 -        }
115.2463 -
115.2464 -        XtSetArg (args[argc], XmNcolormap, awtData->awt_cmap); argc++;
115.2465 -
115.2466 -        DASSERT(!(argc > MAX_ARGC));
115.2467 -        newCanvas = XtCreateWidget(name, vDrawingAreaClass, wrap,
115.2468 -                                   args, argc);
115.2469 -
115.2470 -    } else {
115.2471 -        newCanvas = XtCreateWidget(name, xDrawingAreaClass,
115.2472 -            wrap, args, argc);
115.2473 -    }
115.2474 -
115.2475 -    XtSetMappedWhenManaged(newCanvas, False);
115.2476 -    XtManageChild(newCanvas);
115.2477 -/*
115.2478 -  XXX: causes problems on 2.5
115.2479 -  if (!scrollBugWorkAround) {
115.2480 -  awt_setWidgetGravity(newCanvas, StaticGravity);
115.2481 -  }
115.2482 -*/
115.2483 -    /* Fixed 4250354 7/28/99 ssi@sparc.spb.su
115.2484 -     * XtParseTranslationTable leaks in old ver of Xtoolkit
115.2485 -     * and result should be deletetd in any case
115.2486 -     *
115.2487 -     * XtOverrideTranslations(newCanvas,
115.2488 -     *                      XtParseTranslationTable("<KeyDown>:DrawingAreaInput()"));
115.2489 -     */
115.2490 -    if (NULL==translationKeyDown)
115.2491 -        translationKeyDown=XtParseTranslationTable("<KeyDown>:DrawingAreaInput()");
115.2492 -    XtOverrideTranslations(newCanvas,translationKeyDown);
115.2493 -
115.2494 -    XtSetSensitive(newCanvas, True);
115.2495 -
115.2496 -    return newCanvas;
115.2497 -}
115.2498 -
115.2499 -static void
115.2500 -messWithGravity(Widget w, int32_t gravity)
115.2501 -{
115.2502 -    extern void awt_changeAttributes(Display * dpy, Widget w,
115.2503 -                                     unsigned long mask,
115.2504 -                                     XSetWindowAttributes * xattr);
115.2505 -    XSetWindowAttributes xattr;
115.2506 -
115.2507 -    xattr.bit_gravity = gravity;
115.2508 -    xattr.win_gravity = gravity;
115.2509 -
115.2510 -    awt_changeAttributes(XtDisplay(w), w, (CWBitGravity | CWWinGravity), &xattr);
115.2511 -
115.2512 -}
115.2513 -
115.2514 -struct MoveRecord {
115.2515 -    long dx;
115.2516 -    long dy;
115.2517 -};
115.2518 -
115.2519 -void
115.2520 -moveWidget(Widget w, void *data)
115.2521 -{
115.2522 -    struct MoveRecord *rec = (struct MoveRecord *) data;
115.2523 -
115.2524 -    if (XtIsRealized(w) && XmIsRowColumn(w)) {
115.2525 -        w->core.x -= rec->dx;
115.2526 -        w->core.y -= rec->dy;
115.2527 -    }
115.2528 -}
115.2529 -
115.2530 -#if 0
115.2531 -/* Scroll entire contents of window by dx and dy.  Currently only
115.2532 -   dy is supported.  A negative dy means scroll backwards, i.e.,
115.2533 -   contents in window move down. */
115.2534 -void
115.2535 -awt_canvas_scroll(XtPointer this,
115.2536 -                  struct CanvasData *wdata,
115.2537 -                  long dx,
115.2538 -                  long dy)
115.2539 -{
115.2540 -
115.2541 -    Window win;
115.2542 -    XWindowChanges xchgs;
115.2543 -    Window root;
115.2544 -    int x, y;
115.2545 -    unsigned int width, height, junk;
115.2546 -    Display *dpy;
115.2547 -    struct MoveRecord mrec;
115.2548 -
115.2549 -    mrec.dx = dx;
115.2550 -    mrec.dy = dy;
115.2551 -
115.2552 -    dpy = XtDisplay(wdata->comp.widget);
115.2553 -    win = XtWindow(wdata->comp.widget);
115.2554 -
115.2555 -    /* REMIND: consider getting rid of this! */
115.2556 -    XGetGeometry(awt_display,
115.2557 -                 win,
115.2558 -                 &root,
115.2559 -                 &x,
115.2560 -                 &y,
115.2561 -                 &width,
115.2562 -                 &height,
115.2563 -                 &junk,
115.2564 -                 &junk);
115.2565 -
115.2566 -    /* we need to actually update the coordinates for manager widgets, */
115.2567 -    /* otherwise the parent won't pass down events to them properly */
115.2568 -    /* after scrolling... */
115.2569 -    awt_util_mapChildren(wdata->comp.widget, moveWidget, 0, &mrec);
115.2570 -
115.2571 -    if (dx < 0) {
115.2572 -        /* scrolling backward */
115.2573 -
115.2574 -        if (scrollBugWorkAround) {
115.2575 -            messWithGravity(wdata->comp.widget, NorthWestGravity);
115.2576 -        }
115.2577 -        xchgs.x = x + dx;
115.2578 -        xchgs.y = y;
115.2579 -        xchgs.width = width - dx;
115.2580 -        xchgs.height = height;
115.2581 -        XConfigureWindow(awt_display,
115.2582 -                         win,
115.2583 -                         CWX | CWY | CWWidth | CWHeight,
115.2584 -                         &xchgs);
115.2585 -
115.2586 -        if (scrollBugWorkAround) {
115.2587 -            messWithGravity(wdata->comp.widget, NorthWestGravity);
115.2588 -        }
115.2589 -        xchgs.x = x;
115.2590 -        xchgs.y = y;
115.2591 -        XConfigureWindow(awt_display,
115.2592 -                         win,
115.2593 -                         CWX | CWY,
115.2594 -                         &xchgs);
115.2595 -
115.2596 -        xchgs.width = width;
115.2597 -        xchgs.height = height;
115.2598 -        XConfigureWindow(awt_display,
115.2599 -                         win,
115.2600 -                         CWWidth | CWHeight,
115.2601 -                         &xchgs);
115.2602 -    } else {
115.2603 -        /* forward scrolling */
115.2604 -
115.2605 -        /* make window a little taller */
115.2606 -        xchgs.width = width + dx;
115.2607 -        xchgs.height = height;
115.2608 -        XConfigureWindow(awt_display,
115.2609 -                         win,
115.2610 -                         CWWidth | CWHeight,
115.2611 -                         &xchgs);
115.2612 -
115.2613 -        if (scrollBugWorkAround) {
115.2614 -            messWithGravity(wdata->comp.widget, NorthEastGravity);
115.2615 -        }
115.2616 -        /* move window by amount we're scrolling */
115.2617 -        xchgs.x = x - dx;
115.2618 -        xchgs.y = y;
115.2619 -        XConfigureWindow(awt_display,
115.2620 -                         win,
115.2621 -                         CWX | CWY,
115.2622 -                         &xchgs);
115.2623 -
115.2624 -        if (scrollBugWorkAround) {
115.2625 -            messWithGravity(wdata->comp.widget, NorthWestGravity);
115.2626 -        }
115.2627 -        /* resize to original size */
115.2628 -        xchgs.x = x;
115.2629 -        xchgs.y = y;
115.2630 -        xchgs.width = width;
115.2631 -        xchgs.height = height;
115.2632 -        XConfigureWindow(awt_display,
115.2633 -                         win,
115.2634 -                         CWX | CWY | CWWidth | CWHeight,
115.2635 -                         &xchgs);
115.2636 -    }
115.2637 -    /* Because of the weird way we're scrolling this window,
115.2638 -       we have to eat all the exposure events that result from
115.2639 -       scrolling forward, and translate them up by the amount we're
115.2640 -       scrolling by.
115.2641 -
115.2642 -       Rather than just eating all the exposures and having the
115.2643 -       java code fill in what it knows is exposed, we do it this
115.2644 -       way.  The reason is that there might be some other exposure
115.2645 -       events caused by overlapping windows on top of us that we
115.2646 -       also need to deal with. */
115.2647 -    {
115.2648 -        XRectangle rect;
115.2649 -
115.2650 -        rect.x = -1;
115.2651 -        eatAllExposures(dpy, win, &rect);
115.2652 -        if (rect.x != -1) {         /* we got at least one expose event */
115.2653 -            if (dx > 0) {
115.2654 -                rect.x -= dx;
115.2655 -                rect.width += dx;
115.2656 -            }
115.2657 -/*
115.2658 -  printf("EXPOSE (%d): %d, %d, %d, %d\n",
115.2659 -  dy, rect.x, rect.y, rect.width, rect.height);
115.2660 -*/
115.2661 -            callJavaExpose(this, &rect);
115.2662 -            XSync(awt_display, False);
115.2663 -        }
115.2664 -    }
115.2665 -    if (dy < 0) {
115.2666 -        /* scrolling backward */
115.2667 -
115.2668 -        if (scrollBugWorkAround) {
115.2669 -            messWithGravity(wdata->comp.widget, SouthGravity);
115.2670 -        }
115.2671 -        xchgs.x = x;
115.2672 -        xchgs.y = y + dy;
115.2673 -        xchgs.width = width;
115.2674 -        xchgs.height = height - dy;
115.2675 -        XConfigureWindow(awt_display,
115.2676 -                         win,
115.2677 -                         CWX | CWY | CWWidth | CWHeight,
115.2678 -                         &xchgs);
115.2679 -
115.2680 -        if (scrollBugWorkAround) {
115.2681 -            messWithGravity(wdata->comp.widget, NorthWestGravity);
115.2682 -        }
115.2683 -        xchgs.x = x;
115.2684 -        xchgs.y = y;
115.2685 -        XConfigureWindow(awt_display,
115.2686 -                         win,
115.2687 -                         CWX | CWY,
115.2688 -                         &xchgs);
115.2689 -
115.2690 -        xchgs.width = width;
115.2691 -        xchgs.height = height;
115.2692 -        XConfigureWindow(awt_display,
115.2693 -                         win,
115.2694 -                         CWWidth | CWHeight,
115.2695 -                         &xchgs);
115.2696 -    } else {
115.2697 -        /* forward scrolling */
115.2698 -
115.2699 -        /* make window a little taller */
115.2700 -        xchgs.width = width;
115.2701 -        xchgs.height = height + dy;
115.2702 -        XConfigureWindow(awt_display,
115.2703 -                         win,
115.2704 -                         CWWidth | CWHeight,
115.2705 -                         &xchgs);
115.2706 -
115.2707 -        /* move window by amount we're scrolling */
115.2708 -        xchgs.x = x;
115.2709 -        xchgs.y = y - dy;
115.2710 -        XConfigureWindow(awt_display,
115.2711 -                         win,
115.2712 -                         CWX | CWY,
115.2713 -                         &xchgs);
115.2714 -
115.2715 -        if (scrollBugWorkAround) {
115.2716 -            messWithGravity(wdata->comp.widget, SouthGravity);
115.2717 -        }
115.2718 -        /* resize to original size */
115.2719 -        xchgs.x = x;
115.2720 -        xchgs.y = y;
115.2721 -        xchgs.width = width;
115.2722 -        xchgs.height = height;
115.2723 -        XConfigureWindow(awt_display,
115.2724 -                         win,
115.2725 -                         CWX | CWY | CWWidth | CWHeight,
115.2726 -                         &xchgs);
115.2727 -        if (scrollBugWorkAround) {
115.2728 -            messWithGravity(wdata->comp.widget, NorthWestGravity);
115.2729 -        }
115.2730 -    }
115.2731 -    /* Because of the weird way we're scrolling this window,
115.2732 -       we have to eat all the exposure events that result from
115.2733 -       scrolling forward, and translate them up by the amount we're
115.2734 -       scrolling by.
115.2735 -
115.2736 -       Rather than just eating all the exposures and having the
115.2737 -       java code fill in what it knows is exposed, we do it this
115.2738 -       way.  The reason is that there might be some other exposure
115.2739 -       events caused by overlapping windows on top of us that we
115.2740 -       also need to deal with. */
115.2741 -    {
115.2742 -        XRectangle rect;
115.2743 -
115.2744 -        rect.x = -1;
115.2745 -        eatAllExposures(dpy, win, &rect);
115.2746 -        if (rect.x != -1) {         /* we got at least one expose event */
115.2747 -            if (dy > 0) {
115.2748 -                rect.y -= dy;
115.2749 -                rect.height += dy;
115.2750 -            }
115.2751 -            if (dx > 0) {
115.2752 -                rect.x -= dx;
115.2753 -                rect.width += dx;
115.2754 -            }
115.2755 -/*
115.2756 -  printf("EXPOSE (%d): %d, %d, %d, %d\n",
115.2757 -  dy, rect.x, rect.y, rect.width, rect.height);
115.2758 -*/
115.2759 -            callJavaExpose(this, &rect);
115.2760 -            XSync(awt_display, False);
115.2761 -        }
115.2762 -    }
115.2763 -}
115.2764 -#endif
115.2765 -
115.2766 -extern Window focusProxyWindow;
115.2767 -/*
115.2768 - * client_data is MComponentPeer instance
115.2769 - */
115.2770 -void
115.2771 -awt_post_java_key_event(XtPointer client_data, jint id, XEvent *event,
115.2772 -  Time when, jint keycode, jchar keychar, jint modifiers, jint keyLocation, XEvent *anEvent)
115.2773 -{
115.2774 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
115.2775 -    jobject peer = (jobject) client_data;
115.2776 -    jobject target;
115.2777 -    static jclass classKeyEvent = NULL;
115.2778 -    static jmethodID mid = NULL;
115.2779 -    char *clsName = "java/awt/event/KeyEvent";
115.2780 -    jobject hEvent;
115.2781 -    jlong jWhen;
115.2782 -    Boolean isProxyActive = (focusProxyWindow != None);
115.2783 -
115.2784 -    if (anEvent != NULL && anEvent->xany.send_event == 2){
115.2785 -        isProxyActive = False;
115.2786 -        if (event != NULL) {
115.2787 -            event->xany.send_event = 0;
115.2788 -        }
115.2789 -    }
115.2790 -    if ((*env)->PushLocalFrame(env, 16) < 0)
115.2791 -        return;
115.2792 -
115.2793 -    target = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
115.2794 -
115.2795 -    if (classKeyEvent == NULL) {
115.2796 -        jobject sysClass;
115.2797 -
115.2798 -        sysClass = (*env)->FindClass(env, clsName);
115.2799 -        if (sysClass != NULL) {
115.2800 -            /* Make this class 'sticky', we don't want it GC'd */
115.2801 -            classKeyEvent = (*env)->NewGlobalRef(env, sysClass);
115.2802 -            mid = (*env)->GetMethodID(env, classKeyEvent, "<init>",
115.2803 -              "(Ljava/awt/Component;IJIICIZ)V");
115.2804 -        }
115.2805 -        if (JNU_IsNull(env, classKeyEvent) || mid == NULL) {
115.2806 -            JNU_ThrowClassNotFoundException(env, clsName);
115.2807 -            (*env)->PopLocalFrame(env, 0);
115.2808 -            return;
115.2809 -        }
115.2810 -    }
115.2811 -
115.2812 -    jWhen = awt_util_nowMillisUTC_offset(when); /* convert Time to UTC */
115.2813 -
115.2814 -    hEvent = (*env)->NewObject(env, classKeyEvent, mid,
115.2815 -                               target, id, jWhen, modifiers,
115.2816 -                               keycode, keychar, keyLocation,
115.2817 -                               isProxyActive?JNI_TRUE:JNI_FALSE);
115.2818 -
115.2819 -    if ((*env)->ExceptionOccurred(env)) {
115.2820 -        (*env)->ExceptionDescribe(env);
115.2821 -        (*env)->ExceptionClear(env);
115.2822 -    }
115.2823 -    if (JNU_IsNull(env, hEvent)) {
115.2824 -        JNU_ThrowNullPointerException(env, "NullPointerException: constructor failed.");
115.2825 -        (*env)->PopLocalFrame(env, 0);
115.2826 -        return;
115.2827 -    }
115.2828 -    awt_copyXEventToAWTEvent(env, event, hEvent);
115.2829 -    #ifdef DEBUG
115.2830 -    if (debugKeys) {
115.2831 -        jio_fprintf(stderr, "native posting event id:%d  keychar:%c\n", (int)id, (char)keychar);
115.2832 -    }
115.2833 -    #endif
115.2834 -    JNU_CallMethodByName(env, NULL, peer,
115.2835 -                         "postEvent", "(Ljava/awt/AWTEvent;)V", hEvent);
115.2836 -    if ((*env)->ExceptionOccurred(env)) {
115.2837 -        (*env)->ExceptionDescribe(env);
115.2838 -        (*env)->ExceptionClear(env);
115.2839 -    }
115.2840 -    (*env)->PopLocalFrame(env, 0);
115.2841 -} /* awt_post_java_key_event() */
115.2842 -
115.2843 -/*
115.2844 - * Note: this routine returns a global reference which should be deleted
115.2845 - * after use.
115.2846 - */
115.2847 -jobject
115.2848 -awt_canvas_wrapInSequenced(jobject awtevent) {
115.2849 -    static jclass classSequencedEvent = NULL;
115.2850 -    static jmethodID mid = NULL;
115.2851 -    jobject wrapperEventLocal = NULL;
115.2852 -    jobject wrapperEvent = NULL;
115.2853 -
115.2854 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
115.2855 -
115.2856 -    if ((*env)->PushLocalFrame(env, 5) < 0)
115.2857 -        return NULL;
115.2858 -
115.2859 -    if (classSequencedEvent == NULL) {
115.2860 -        jobject sysClass = (*env)->FindClass(env, "java/awt/SequencedEvent");
115.2861 -        if (sysClass != NULL) {
115.2862 -            /* Make this class 'sticky', we don't want it GC'd */
115.2863 -            classSequencedEvent = (*env)->NewGlobalRef(env, sysClass);
115.2864 -            if (mid == NULL) {
115.2865 -              mid = (*env)->GetMethodID(env, classSequencedEvent
115.2866 -                                        ,"<init>"
115.2867 -                                        ,"(Ljava/awt/AWTEvent;)V");
115.2868 -            }
115.2869 -        }
115.2870 -        if (JNU_IsNull(env, classSequencedEvent) || mid == NULL) {
115.2871 -            JNU_ThrowClassNotFoundException(env, "java/awt/SequencedEvent");
115.2872 -            (*env)->PopLocalFrame(env, 0);
115.2873 -            return NULL;
115.2874 -        }
115.2875 -    }
115.2876 -    wrapperEventLocal = (*env)->NewObject(env, classSequencedEvent, mid, awtevent);
115.2877 -
115.2878 -    if ((*env)->ExceptionOccurred(env)) {
115.2879 -        (*env)->ExceptionDescribe(env);
115.2880 -        (*env)->ExceptionClear(env);
115.2881 -    }
115.2882 -    if (JNU_IsNull(env, wrapperEventLocal)) {
115.2883 -        JNU_ThrowNullPointerException(env, "constructor failed.");
115.2884 -        (*env)->PopLocalFrame(env, 0);
115.2885 -        return NULL;
115.2886 -    }
115.2887 -    wrapperEvent = (*env)->NewGlobalRef(env, wrapperEventLocal);
115.2888 -    if (!JNU_IsNull(env, ((*env)->ExceptionOccurred(env)))) {
115.2889 -        (*env)->ExceptionDescribe(env);
115.2890 -        (*env)->ExceptionClear(env);
115.2891 -        (*env)->PopLocalFrame(env, 0);
115.2892 -        return NULL;
115.2893 -    }
115.2894 -    if (JNU_IsNull(env, wrapperEvent)) {
115.2895 -        JNU_ThrowNullPointerException(env, "NewGlobalRef failed.");
115.2896 -        (*env)->PopLocalFrame(env, 0);
115.2897 -        return NULL;
115.2898 -    }
115.2899 -
115.2900 -    (*env)->PopLocalFrame(env, 0);
115.2901 -    return wrapperEvent;
115.2902 -}
115.2903 -
115.2904 -jobject
115.2905 -findTopLevelOpposite(JNIEnv *env, jint eventType)
115.2906 -{
115.2907 -    jobject target, peer, opposite;
115.2908 -
115.2909 -    if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
115.2910 -        return NULL;
115.2911 -    }
115.2912 -
115.2913 -    /* 4462056: Get a usable handle for a weakly referenced object */
115.2914 -    target = (*env)->NewLocalRef(env,
115.2915 -                 (eventType == java_awt_event_WindowEvent_WINDOW_GAINED_FOCUS)
115.2916 -                                 ? forGained
115.2917 -                                 : focusList->requestor);
115.2918 -    if (target == NULL) {
115.2919 -        return NULL;
115.2920 -    }
115.2921 -
115.2922 -    peer = (*env)->GetObjectField(env, target, componentIDs.peer);
115.2923 -    (*env)->DeleteLocalRef(env, target);
115.2924 -    if (peer == NULL) {
115.2925 -        return NULL;
115.2926 -    }
115.2927 -
115.2928 -    opposite = findTopLevel(peer, env);
115.2929 -    (*env)->DeleteLocalRef(env, peer);
115.2930 -
115.2931 -    return opposite;
115.2932 -}
115.2933 -
115.2934 -void
115.2935 -cleanFocusList(JNIEnv *env){
115.2936 -
115.2937 -  while(focusList) {
115.2938 -    FocusListElt *tmp = focusList->next;
115.2939 -    (*env)->DeleteWeakGlobalRef(env, focusList->requestor);
115.2940 -    free(focusList);
115.2941 -    focusList = tmp;
115.2942 -  }
115.2943 -  focusListEnd = NULL;
115.2944 -}
115.2945 -
115.2946 -static jweak
115.2947 -computeOpposite(jint id, jobject target)
115.2948 -{
115.2949 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
115.2950 -    jobject top;
115.2951 -    jboolean isSameObject;
115.2952 -
115.2953 -    if (focusList == NULL) {
115.2954 -        return NULL;
115.2955 -    }
115.2956 -
115.2957 -    /* 4462056: Get a usable handle for a weakly referenced object */
115.2958 -    top = (*env)->NewLocalRef(env, focusList->requestor);
115.2959 -    if (top == NULL) {
115.2960 -        /* weakly referenced component was deleted -- clean up focus list */
115.2961 -        cleanFocusList(env);
115.2962 -        return NULL;
115.2963 -    }
115.2964 -
115.2965 -    isSameObject = (*env)->IsSameObject(env, target, top);
115.2966 -    (*env)->DeleteLocalRef(env, top);
115.2967 -
115.2968 -    if (isSameObject) {
115.2969 -        if (id == java_awt_event_FocusEvent_FOCUS_GAINED) {
115.2970 -            return forGained;
115.2971 -        } else { /* focus lost */
115.2972 -            FocusListElt *tmp = focusList->next;
115.2973 -            (*env)->DeleteWeakGlobalRef(env, forGained);
115.2974 -            forGained = focusList->requestor;
115.2975 -            free(focusList);
115.2976 -            focusList = tmp;
115.2977 -
115.2978 -            if (focusList == NULL) {
115.2979 -                focusListEnd = NULL;
115.2980 -                return NULL;
115.2981 -            }
115.2982 -            return focusList->requestor;
115.2983 -        }
115.2984 -    } else { /* target does not match top of list */
115.2985 -        /* be gentle with focus lost for now... */
115.2986 -        if (id == java_awt_event_FocusEvent_FOCUS_LOST) {
115.2987 -            (*env)->DeleteWeakGlobalRef(env, forGained);
115.2988 -            forGained = (*env)->NewWeakGlobalRef(env, target);
115.2989 -            return NULL;
115.2990 -        }
115.2991 -
115.2992 -        cleanFocusList(env);
115.2993 -        return NULL;
115.2994 -    }
115.2995 -}
115.2996 -
115.2997 -
115.2998 -/*
115.2999 - * client_data is MComponentPeer instance
115.3000 - */
115.3001 -void
115.3002 -awt_post_java_focus_event(XtPointer client_data,
115.3003 -                          jint id, jobject cause,
115.3004 -                          XEvent* event)
115.3005 -{
115.3006 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
115.3007 -    jobject peer = (jobject) client_data;
115.3008 -    jobject target;
115.3009 -    jobject opposite;
115.3010 -    static jclass classFocusEvent = NULL;
115.3011 -    static jmethodID mid = NULL;
115.3012 -    char *clsName = "sun/awt/CausedFocusEvent";
115.3013 -    jobject hEvent;
115.3014 -
115.3015 -    if ((*env)->PushLocalFrame(env, 16) < 0)
115.3016 -        return;
115.3017 -
115.3018 -    target = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
115.3019 -
115.3020 -    opposite = (*env)->NewLocalRef(env, computeOpposite(id, target));
115.3021 -
115.3022 -   if (classFocusEvent == NULL) {
115.3023 -        jobject sysClass;
115.3024 -
115.3025 -        sysClass = (*env)->FindClass(env, clsName);
115.3026 -        if (sysClass != NULL) {
115.3027 -            /* Make this class 'sticky', we don't want it GC'd */
115.3028 -            classFocusEvent = (*env)->NewGlobalRef(env, sysClass);
115.3029 -            mid = (*env)->GetMethodID(env, classFocusEvent
115.3030 -                                      ,"<init>"
115.3031 -                                      ,"(Ljava/awt/Component;IZLjava/awt/Component;Lsun/awt/CausedFocusEvent$Cause;)V");
115.3032 -        }
115.3033 -        if (JNU_IsNull(env, classFocusEvent) || mid == 0) {
115.3034 -            JNU_ThrowClassNotFoundException(env, clsName);
115.3035 -            (*env)->PopLocalFrame(env, 0);
115.3036 -            return;
115.3037 -        }
115.3038 -    }
115.3039 -    hEvent = (*env)->NewObject(env, classFocusEvent, mid,
115.3040 -                               target, id, JNI_FALSE, opposite, cause);
115.3041 -    (*env)->DeleteLocalRef(env, opposite);
115.3042 -
115.3043 -    if ((*env)->ExceptionOccurred(env)) {
115.3044 -        (*env)->ExceptionDescribe(env);
115.3045 -        (*env)->ExceptionClear(env);
115.3046 -    }
115.3047 -    if (JNU_IsNull(env, hEvent)) {
115.3048 -        JNU_ThrowNullPointerException(env, "NullPointerException: constructor failed.");
115.3049 -        (*env)->PopLocalFrame(env, 0);
115.3050 -        return;
115.3051 -    }
115.3052 -    awt_copyXEventToAWTEvent(env, event, hEvent);
115.3053 -    {
115.3054 -        jobject awtEvent = awt_canvas_wrapInSequenced(hEvent);
115.3055 -        JNU_CallMethodByName(env, NULL, peer,
115.3056 -                             "postEvent", "(Ljava/awt/AWTEvent;)V",
115.3057 -                             awtEvent);
115.3058 -        (*env)->DeleteGlobalRef(env, awtEvent);
115.3059 -    }
115.3060 -    if ((*env)->ExceptionOccurred(env)) {
115.3061 -        (*env)->ExceptionDescribe(env);
115.3062 -        (*env)->ExceptionClear(env);
115.3063 -    }
115.3064 -    (*env)->PopLocalFrame(env, 0);
115.3065 -}
115.3066 -
115.3067 -
115.3068 -void
115.3069 -awt_canvas_addToFocusListDefault(jobject target) {
115.3070 -    awt_canvas_addToFocusListWithDuplicates(target, JNI_FALSE);
115.3071 -}
115.3072 -
115.3073 -void
115.3074 -awt_canvas_addToFocusListWithDuplicates(jobject target, jboolean acceptDuplicates)
115.3075 -{
115.3076 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
115.3077 -    jboolean isSameObject;
115.3078 -
115.3079 -    if (focusListEnd) {
115.3080 -        jobject localRef = (*env)->NewLocalRef(env, focusListEnd->requestor);
115.3081 -
115.3082 -        if (localRef == NULL) {
115.3083 -            isSameObject = JNI_FALSE;
115.3084 -        } else {
115.3085 -            isSameObject = (*env)->IsSameObject(env, target, localRef);
115.3086 -            (*env)->DeleteLocalRef(env, localRef);
115.3087 -        }
115.3088 -
115.3089 -        if (isSameObject && !acceptDuplicates) {
115.3090 -            return;
115.3091 -        }
115.3092 -
115.3093 -        focusListEnd->next = malloc(sizeof(FocusListElt));
115.3094 -        focusListEnd = focusListEnd->next;
115.3095 -    } else {
115.3096 -        jobject l_focusOwnerPeer = awt_canvas_getFocusOwnerPeer();
115.3097 -        if (l_focusOwnerPeer == NULL) {
115.3098 -            isSameObject = JNI_FALSE;
115.3099 -        } else {
115.3100 -            jobject l_focusOwner =
115.3101 -                (*env)->GetObjectField(env, l_focusOwnerPeer,
115.3102 -                                       mComponentPeerIDs.target);
115.3103 -            isSameObject =
115.3104 -                (*env)->IsSameObject(env, target, l_focusOwner);
115.3105 -            (*env)->DeleteLocalRef(env, l_focusOwner);
115.3106 -            (*env)->DeleteLocalRef(env, l_focusOwnerPeer);
115.3107 -        }
115.3108 -
115.3109 -        if (isSameObject && !acceptDuplicates) {
115.3110 -            return;
115.3111 -        }
115.3112 -
115.3113 -        focusList = focusListEnd = malloc(sizeof(FocusListElt));
115.3114 -    }
115.3115 -
115.3116 -    focusListEnd->requestor = (*env)->NewWeakGlobalRef(env, target);
115.3117 -    focusListEnd->next = NULL;
115.3118 -}
115.3119 -
115.3120 -/*
115.3121 - * client_data is MComponentPeer instance
115.3122 - */
115.3123 -void
115.3124 -awt_post_java_mouse_event(XtPointer client_data, jint id, XEvent* event,
115.3125 -                          Time when, jint modifiers, jint x, jint y,
115.3126 -                          jint xAbs, jint yAbs,
115.3127 -                          jint clickcount,
115.3128 -                          Boolean popuptrigger,
115.3129 -                          jint wheelAmt, jint button)
115.3130 -{
115.3131 -    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
115.3132 -    jobject peer = (jobject) client_data;
115.3133 -    jobject target;
115.3134 -
115.3135 -    static jclass classMouseEvent = NULL;
115.3136 -    static jclass classMouseWheelEvent = NULL;
115.3137 -
115.3138 -    static jmethodID mid = NULL;
115.3139 -    static jmethodID wheelmid = NULL;
115.3140 -
115.3141 -    char *clsName = "java/awt/event/MouseEvent";
115.3142 -    char *wheelClsName = "java/awt/event/MouseWheelEvent";
115.3143 -
115.3144 -    jobject hEvent;
115.3145 -    jobject sysClass;
115.3146 -    jlong jWhen;
115.3147 -
115.3148 -    if ((*env)->PushLocalFrame(env, 16) < 0)
115.3149 -        return;
115.3150 -
115.3151 -    target = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
115.3152 -
115.3153 -    if (classMouseEvent == NULL) {
115.3154 -        sysClass = (*env)->FindClass(env, clsName);
115.3155 -        if (sysClass != NULL) {
115.3156 -            /* Make this class 'sticky', we don't want it GC'd */
115.3157 -            classMouseEvent = (*env)->NewGlobalRef(env, sysClass);
115.3158 -            mid = (*env)->GetMethodID(env, classMouseEvent
115.3159 -                                      ,"<init>"
115.3160 -                                      ,"(Ljava/awt/Component;IJIIIIIIZI)V");
115.3161 -        }
115.3162 -        if (JNU_IsNull(env, classMouseEvent) || mid == 0) {
115.3163 -            JNU_ThrowClassNotFoundException(env, clsName);
115.3164 -            (*env)->PopLocalFrame(env, 0);
115.3165 -            return;
115.3166 -        }
115.3167 -    }
115.3168 -
115.3169 -    if (id == java_awt_event_MouseEvent_MOUSE_WHEEL &&
115.3170 -        classMouseWheelEvent == NULL) {
115.3171 -        sysClass = (*env)->FindClass(env, wheelClsName);
115.3172 -        if (sysClass != NULL) {
115.3173 -            /* Make this class 'sticky', we don't want it GC'd */
115.3174 -            classMouseWheelEvent = (*env)->NewGlobalRef(env, sysClass);
115.3175 -            wheelmid = (*env)->GetMethodID(env, classMouseWheelEvent,
115.3176 -                                       "<init>",
115.3177 -                                       "(Ljava/awt/Component;IJIIIIIIZIII)V");
115.3178 -        }
115.3179 -        if (JNU_IsNull(env, classMouseWheelEvent) || wheelmid == 0) {
115.3180 -            JNU_ThrowClassNotFoundException(env, wheelClsName);
115.3181 -            (*env)->PopLocalFrame(env, 0);
115.3182 -            return;
115.3183 -        }
115.3184 -    }
115.3185 -
115.3186 -    jWhen = awt_util_nowMillisUTC_offset(when); /* convert Time to UTC */
115.3187 -
115.3188 -    if (id == java_awt_event_MouseEvent_MOUSE_WHEEL) {
115.3189 -        hEvent = (*env)->NewObject(env, classMouseWheelEvent, wheelmid,
115.3190 -                              target, id, jWhen, modifiers,
115.3191 -                              x, y,
115.3192 -                              xAbs, yAbs,
115.3193 -                              clickcount, popuptrigger,
115.3194 -                              /* Linux has no API for setting how a Component
115.3195 -                               * should scroll in response to the mouse wheel,
115.3196 -                               * so we have to make up our own.
115.3197 -                               * The default behavior on Windows is 3 lines of
115.3198 -                               * text, so we use that to match.
115.3199 -                               */
115.3200 -                              java_awt_event_MouseWheelEvent_WHEEL_UNIT_SCROLL,
115.3201 -                              3,
115.3202 -                              wheelAmt);
115.3203 -    }
115.3204 -    else {
115.3205 -        hEvent = (*env)->NewObject(env, classMouseEvent, mid,
115.3206 -                                   target, id, jWhen, modifiers,
115.3207 -                                   x, y,
115.3208 -                                   xAbs, yAbs,
115.3209 -                                   clickcount, popuptrigger, button);
115.3210 -    }
115.3211 -
115.3212 -
115.3213 -    if ((*env)->ExceptionOccurred(env)) {
115.3214 -        (*env)->ExceptionDescribe(env);
115.3215 -        (*env)->ExceptionClear(env);
115.3216 -    }
115.3217 -    if (JNU_IsNull(env, hEvent)) {
115.3218 -        JNU_ThrowNullPointerException(env, "NullPointerException: constructor failed.");
115.3219 -        (*env)->PopLocalFrame(env, 0);
115.3220 -        return;
115.3221 -    }
115.3222 -    awt_copyXEventToAWTEvent(env, event, hEvent);
115.3223 -    JNU_CallMethodByName(env, NULL, peer,
115.3224 -                         "postEvent", "(Ljava/awt/AWTEvent;)V", hEvent);
115.3225 -    if ((*env)->ExceptionOccurred(env)) {
115.3226 -        (*env)->ExceptionDescribe(env);
115.3227 -        (*env)->ExceptionClear(env);
115.3228 -    }
115.3229 -    (*env)->PopLocalFrame(env, 0);
115.3230 -}
   116.1 --- a/src/solaris/native/sun/awt/cursor.c	Wed Sep 17 13:45:37 2008 -0700
   116.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   116.3 @@ -1,132 +0,0 @@
   116.4 -/*
   116.5 - * Copyright 1997-2003 Sun Microsystems, Inc.  All Rights Reserved.
   116.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   116.7 - *
   116.8 - * This code is free software; you can redistribute it and/or modify it
   116.9 - * under the terms of the GNU General Public License version 2 only, as
  116.10 - * published by the Free Software Foundation.  Sun designates this
  116.11 - * particular file as subject to the "Classpath" exception as provided
  116.12 - * by Sun in the LICENSE file that accompanied this code.
  116.13 - *
  116.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  116.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  116.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  116.17 - * version 2 for more details (a copy is included in the LICENSE file that
  116.18 - * accompanied this code).
  116.19 - *
  116.20 - * You should have received a copy of the GNU General Public License version
  116.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  116.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  116.23 - *
  116.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  116.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
  116.26 - * have any questions.
  116.27 - */
  116.28 -
  116.29 -#ifdef HEADLESS
  116.30 -    #error This file should not be included in headless library
  116.31 -#endif
  116.32 -
  116.33 -#include "awt_p.h"
  116.34 -#include "java_awt_Cursor.h"
  116.35 -#include "awt_Cursor.h"
  116.36 -#include "sun_awt_motif_MCustomCursor.h"
  116.37 -
  116.38 -#include "jni.h"
  116.39 -#include "jni_util.h"
  116.40 -
  116.41 -extern struct CursorIDs cursorIDs;
  116.42 -static jfieldID widthID;
  116.43 -static jfieldID heightID;
  116.44 -
  116.45 -/*
  116.46 - * Class:     sun_awt_motif_MCustomCursor
  116.47 - * Method:    cacheInit
  116.48 - * Signature: ()V
  116.49 - */
  116.50 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCustomCursor_cacheInit
  116.51 -  (JNIEnv *env, jclass cls)
  116.52 -{
  116.53 -    jclass clsDimension = (*env)->FindClass(env, "java/awt/Dimension");
  116.54 -    widthID = (*env)->GetFieldID(env, clsDimension, "width", "I");
  116.55 -    heightID = (*env)->GetFieldID(env, clsDimension, "height", "I");
  116.56 -}
  116.57 -
  116.58 -/*
  116.59 - * Class:     sun_awt_motif_MCustomCursor
  116.60 - * Method:    queryBestCursor
  116.61 - * Signature: (Ljava/awt/Dimension;)V
  116.62 - */
  116.63 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCustomCursor_queryBestCursor
  116.64 -  (JNIEnv *env, jclass cls, jobject dimension)
  116.65 -{
  116.66 -    Window root;
  116.67 -    uint32_t width, height;
  116.68 -
  116.69 -    AWT_LOCK();
  116.70 -    root = RootWindow(awt_display, DefaultScreen(awt_display));
  116.71 -    XQueryBestCursor(awt_display, root,
  116.72 -                     (*env)->GetIntField(env, dimension, widthID),
  116.73 -                     (*env)->GetIntField(env, dimension, heightID),
  116.74 -                     &width, &height);
  116.75 -    (*env)->SetIntField(env, dimension, widthID, (int32_t) width);
  116.76 -    (*env)->SetIntField(env, dimension, heightID, (int32_t) height);
  116.77 -    AWT_UNLOCK();
  116.78 -}
  116.79 -
  116.80 -/*
  116.81 - * Class:     sun_awt_motif_MCustomCursor
  116.82 - * Method:    createCursor
  116.83 - * Signature: ([B[BIIII)V
  116.84 - */
  116.85 -JNIEXPORT void JNICALL Java_sun_awt_motif_MCustomCursor_createCursor
  116.86 -  (JNIEnv *env , jobject this, jbyteArray xorMask, jbyteArray andMask,
  116.87 -   jint width, jint height, jint fc, jint bc, jint xHotSpot, jint yHotSpot)
  116.88 -{
  116.89 -    Cursor cursor;
  116.90 -    char *sourceBits, *maskBits;
  116.91 -    Window root;
  116.92 -    Pixmap source, mask;
  116.93 -    XColor fcolor, bcolor;
  116.94 -    AwtGraphicsConfigDataPtr defaultConfig =
  116.95 -        getDefaultConfig(DefaultScreen(awt_display));
  116.96 -
  116.97 -    AWT_LOCK();
  116.98 -
  116.99 -    root = RootWindow(awt_display, DefaultScreen(awt_display));
 116.100 -    fcolor.flags = DoRed | DoGreen | DoBlue;
 116.101 -    fcolor.red = ((fc >> 16) & 0x000000ff) << 8;
 116.102 -    fcolor.green = ((fc >> 8) & 0x000000ff) << 8;
 116.103 -    fcolor.blue = ((fc >> 0) & 0x000000ff) << 8;
 116.104 -    XAllocColor(awt_display, defaultConfig->awt_cmap, &fcolor);
 116.105 -    bcolor.flags = DoRed | DoGreen | DoBlue;
 116.106 -    bcolor.red = ((bc >> 16) & 0x000000ff) << 8;
 116.107 -    bcolor.green = ((bc >> 8) & 0x000000ff) << 8;
 116.108 -    bcolor.blue = ((bc >> 0) & 0x000000ff) << 8;
 116.109 -    XAllocColor(awt_display, defaultConfig->awt_cmap, &bcolor);
 116.110 -
 116.111 -    /* Create source pixmap. */
 116.112 -    sourceBits = (char *)(*env)->GetPrimitiveArrayCritical(env, xorMask, NULL);
 116.113 -    source = XCreateBitmapFromData(awt_display, root, sourceBits,
 116.114 -                                         width, height);
 116.115 -
 116.116 -    /* Create mask pixmap */
 116.117 -    maskBits = (char *)(*env)->GetPrimitiveArrayCritical(env, andMask, NULL);
 116.118 -    mask = XCreateBitmapFromData(awt_display, root, maskBits,
 116.119 -                                       width, height);
 116.120 -
 116.121 -    /* Create cursor */
 116.122 -    cursor = XCreatePixmapCursor(awt_display, source, mask, &fcolor, &bcolor,
 116.123 -                                 xHotSpot, yHotSpot);
 116.124 -
 116.125 -    /* Free resources */
 116.126 -    XFreePixmap(awt_display, source);
 116.127 -    XFreePixmap(awt_display, mask);
 116.128 -
 116.129 -    (*env)->ReleasePrimitiveArrayCritical(env, xorMask, sourceBits, JNI_ABORT);
 116.130 -    (*env)->ReleasePrimitiveArrayCritical(env, andMask, maskBits, JNI_ABORT);
 116.131 -
 116.132 -        JNU_SetLongFieldFromPtr(env, this, cursorIDs.pData, cursor);
 116.133 -
 116.134 -    AWT_FLUSH_UNLOCK();
 116.135 -}
   117.1 --- a/src/solaris/native/sun/awt/initIDs.c	Wed Sep 17 13:45:37 2008 -0700
   117.2 +++ b/src/solaris/native/sun/awt/initIDs.c	Fri Sep 19 19:38:12 2008 -0700
   117.3 @@ -26,7 +26,7 @@
   117.4  #include "java_awt_Color.h"
   117.5  #include "java_awt_Dimension.h"
   117.6  #include "java_awt_MenuBar.h"
   117.7 -#include "java_awt_Label.h"
   117.8 +//#include "java_awt_Label.h"
   117.9  #include "java_awt_FontMetrics.h"
  117.10  #include "java_awt_event_MouseEvent.h"
  117.11  #include "java_awt_Rectangle.h"
   118.1 --- a/src/solaris/native/sun/awt/multi_font.c	Wed Sep 17 13:45:37 2008 -0700
   118.2 +++ b/src/solaris/native/sun/awt/multi_font.c	Fri Sep 19 19:38:12 2008 -0700
   118.3 @@ -52,8 +52,8 @@
   118.4  extern XFontStruct *loadFont(Display *, char *, int32_t);
   118.5  
   118.6  extern struct FontIDs fontIDs;
   118.7 -extern struct MComponentPeerIDs mComponentPeerIDs;
   118.8 -extern struct MMenuItemPeerIDs mMenuItemPeerIDs;
   118.9 +//extern struct MComponentPeerIDs mComponentPeerIDs;
  118.10 +//extern struct MMenuItemPeerIDs mMenuItemPeerIDs;
  118.11  extern struct PlatformFontIDs platformFontIDs;
  118.12  extern struct MFontPeerIDs mFontPeerIDs;
  118.13  
  118.14 @@ -151,8 +151,8 @@
  118.15      struct gRefStruct *temp;
  118.16  
  118.17      gRef = (jobject)
  118.18 -      JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.jniGlobalRef);
  118.19 -    JNU_SetLongFieldFromPtr(env, this, mMenuItemPeerIDs.jniGlobalRef, NULL);
  118.20 +    //JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.jniGlobalRef);
  118.21 +    //JNU_SetLongFieldFromPtr(env, this, mMenuItemPeerIDs.jniGlobalRef, NULL);
  118.22  
  118.23      /*
  118.24       * Verra handy for tracking down race conditions. If you
   119.1 --- a/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c	Wed Sep 17 13:45:37 2008 -0700
   119.2 +++ b/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c	Fri Sep 19 19:38:12 2008 -0700
   119.3 @@ -40,6 +40,7 @@
   119.4  #include <langinfo.h>
   119.5  #include <locale.h>
   119.6  #include <fcntl.h>
   119.7 +#include <poll.h>
   119.8  
   119.9  static Bool shapeSupported;
  119.10  static int shapeEventBase, shapeErrorBase;
  119.11 @@ -534,40 +535,34 @@
  119.12  SplashEventLoop(Splash * splash) {
  119.13  
  119.14      /*      Different from win32 implementation - this loop
  119.15 -       uses select timeouts instead of a timer */
  119.16 +       uses poll timeouts instead of a timer */
  119.17      /* we should have splash _locked_ on entry!!! */
  119.18  
  119.19      int xconn = XConnectionNumber(splash->display);
  119.20  
  119.21      while (1) {
  119.22 +        struct pollfd pfd[2];
  119.23 +        int timeout = -1;
  119.24          int ctl = splash->controlpipe[0];
  119.25 -        fd_set fds[2];
  119.26 -        int n = 0;
  119.27 -        struct timeval tv, *ptv;
  119.28          int rc;
  119.29 -        int time;
  119.30          int pipes_empty;
  119.31  
  119.32 -        FD_ZERO(fds);
  119.33 -        FD_SET(xconn, fds);
  119.34 -        if (xconn+1 > n)
  119.35 -            n = xconn+1;
  119.36 -        FD_SET(ctl, fds);
  119.37 -        if (ctl+1 > n)
  119.38 -            n = ctl+1;
  119.39 +        pfd[0].fd = xconn;
  119.40 +        pfd[0].events = POLLIN | POLLPRI;
  119.41 +
  119.42 +        pfd[1].fd = ctl;
  119.43 +        pfd[1].events = POLLIN | POLLPRI;
  119.44 +
  119.45          errno = 0;
  119.46          if (splash->isVisible>0 && SplashIsStillLooping(splash)) {
  119.47 -            time = splash->time + splash->frames[splash->currentFrame].delay
  119.48 +            timeout = splash->time + splash->frames[splash->currentFrame].delay
  119.49                  - SplashTime();
  119.50 -            if (time < 0)
  119.51 -                time = 0;
  119.52 -            msec2timeval(time, &tv);
  119.53 -            ptv = &tv;
  119.54 -        } else {
  119.55 -            ptv = NULL;
  119.56 +            if (timeout < 0) {
  119.57 +                timeout = 0;
  119.58 +            }
  119.59          }
  119.60          SplashUnlock(splash);
  119.61 -        rc = select(n, fds, NULL, NULL, ptv);
  119.62 +        rc = poll(pfd, 2, timeout);
  119.63          SplashLock(splash);
  119.64          if (splash->isVisible>0 && SplashTime() >= splash->time +
  119.65                  splash->frames[splash->currentFrame].delay) {
   120.1 --- a/src/windows/native/sun/windows/ComCtl32Util.cpp	Wed Sep 17 13:45:37 2008 -0700
   120.2 +++ b/src/windows/native/sun/windows/ComCtl32Util.cpp	Fri Sep 19 19:38:12 2008 -0700
   120.3 @@ -49,6 +49,9 @@
   120.4              m_bNewSubclassing = (m_lpfnSetWindowSubclass != NULL) &&
   120.5                                  (m_lpfnRemoveWindowSubclass != NULL) &&
   120.6                                  (m_lpfnDefSubclassProc != NULL);
   120.7 +
   120.8 +            fn_InitCommonControlsEx = (ComCtl32Util::InitCommonControlsExType)::GetProcAddress(hModComCtl32, "InitCommonControlsEx");
   120.9 +            InitCommonControls();
  120.10          }
  120.11      }
  120.12  }
  120.13 @@ -108,3 +111,15 @@
  120.14  
  120.15      CATCH_BAD_ALLOC_RET(0);
  120.16  }
  120.17 +
  120.18 +void ComCtl32Util::InitCommonControls()
  120.19 +{
  120.20 +    if (fn_InitCommonControlsEx == NULL) {
  120.21 +        return;
  120.22 +    }
  120.23 +
  120.24 +    INITCOMMONCONTROLSEX iccex;
  120.25 +    memset(&iccex, 0, sizeof(INITCOMMONCONTROLSEX));
  120.26 +    iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  120.27 +    fn_InitCommonControlsEx(&iccex);
  120.28 +}
   121.1 --- a/src/windows/native/sun/windows/ComCtl32Util.h	Wed Sep 17 13:45:37 2008 -0700
   121.2 +++ b/src/windows/native/sun/windows/ComCtl32Util.h	Fri Sep 19 19:38:12 2008 -0700
   121.3 @@ -25,6 +25,8 @@
   121.4  
   121.5  #include "awt_Component.h"
   121.6  
   121.7 +#include <commctrl.h>
   121.8 +
   121.9  #ifndef _COMCTL32UTIL_H
  121.10  #define _COMCTL32UTIL_H
  121.11  
  121.12 @@ -81,6 +83,11 @@
  121.13          PFNREMOVEWINDOWSUBCLASS m_lpfnRemoveWindowSubclass;
  121.14          PFNDEFSUBCLASSPROC m_lpfnDefSubclassProc;
  121.15  
  121.16 +        typedef BOOL (WINAPI * InitCommonControlsExType)(const LPINITCOMMONCONTROLSEX lpInitCtrls);
  121.17 +        InitCommonControlsExType fn_InitCommonControlsEx;
  121.18 +
  121.19 +        void InitCommonControls();
  121.20 +
  121.21          BOOL m_bNewSubclassing;
  121.22  
  121.23          // comctl32.dll version 6 window proc
   122.1 --- a/src/windows/native/sun/windows/awt_Container.cpp	Wed Sep 17 13:45:37 2008 -0700
   122.2 +++ b/src/windows/native/sun/windows/awt_Container.cpp	Fri Sep 19 19:38:12 2008 -0700
   122.3 @@ -1,5 +1,5 @@
   122.4  /*
   122.5 - * Copyright 1998-2000 Sun Microsystems, Inc.  All Rights Reserved.
   122.6 + * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
   122.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   122.8   *
   122.9   * This code is free software; you can redistribute it and/or modify it
  122.10 @@ -30,8 +30,6 @@
  122.11   * AwtContainer fields
  122.12   */
  122.13  
  122.14 -jfieldID AwtContainer::ncomponentsID;
  122.15 -jfieldID AwtContainer::componentID;
  122.16  jfieldID AwtContainer::layoutMgrID;
  122.17  jmethodID AwtContainer::findComponentAtMID;
  122.18  
  122.19 @@ -45,18 +43,12 @@
  122.20  Java_java_awt_Container_initIDs(JNIEnv *env, jclass cls) {
  122.21      TRY;
  122.22  
  122.23 -    AwtContainer::ncomponentsID = env->GetFieldID(cls, "ncomponents", "I");
  122.24 -    AwtContainer::componentID =
  122.25 -        env->GetFieldID(cls, "component", "[Ljava/awt/Component;");
  122.26 -
  122.27      AwtContainer::layoutMgrID =
  122.28          env->GetFieldID(cls, "layoutMgr", "Ljava/awt/LayoutManager;");
  122.29  
  122.30      AwtContainer::findComponentAtMID =
  122.31          env->GetMethodID(cls, "findComponentAt", "(IIZ)Ljava/awt/Component;");
  122.32  
  122.33 -    DASSERT(AwtContainer::ncomponentsID != NULL);
  122.34 -    DASSERT(AwtContainer::componentID != NULL);
  122.35      DASSERT(AwtContainer::layoutMgrID != NULL);
  122.36      DASSERT(AwtContainer::findComponentAtMID);
  122.37  
   123.1 --- a/src/windows/native/sun/windows/awt_Container.h	Wed Sep 17 13:45:37 2008 -0700
   123.2 +++ b/src/windows/native/sun/windows/awt_Container.h	Fri Sep 19 19:38:12 2008 -0700
   123.3 @@ -1,5 +1,5 @@
   123.4  /*
   123.5 - * Copyright 1998-1999 Sun Microsystems, Inc.  All Rights Reserved.
   123.6 + * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
   123.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   123.8   *
   123.9   * This code is free software; you can redistribute it and/or modify it
  123.10 @@ -37,8 +37,6 @@
  123.11  public:
  123.12  
  123.13      /* java.awt.Container field ids */
  123.14 -    static jfieldID ncomponentsID;
  123.15 -    static jfieldID componentID;
  123.16      static jfieldID layoutMgrID;
  123.17      static jmethodID findComponentAtMID;
  123.18  
   124.1 --- a/src/windows/native/sun/windows/awt_TextArea.cpp	Wed Sep 17 13:45:37 2008 -0700
   124.2 +++ b/src/windows/native/sun/windows/awt_TextArea.cpp	Fri Sep 19 19:38:12 2008 -0700
   124.3 @@ -209,15 +209,13 @@
   124.4  
   124.5  void AwtTextArea::EditSetSel(CHARRANGE &cr) {
   124.6      // Fix for 5003402: added restoring/hiding selection to enable automatic scrolling
   124.7 -    LockWindowUpdate(GetHWnd());
   124.8      SendMessage(EM_HIDESELECTION, FALSE, TRUE);
   124.9      SendMessage(EM_EXSETSEL, 0, reinterpret_cast<LPARAM>(&cr));
  124.10      SendMessage(EM_HIDESELECTION, TRUE, TRUE);
  124.11 -    // 6417581: LockWindowUpdate doesn't force expected drawing
  124.12 +    // 6417581: force expected drawing
  124.13      if (IS_WINVISTA && cr.cpMin == cr.cpMax) {
  124.14          ::InvalidateRect(GetHWnd(), NULL, TRUE);
  124.15      }
  124.16 -    LockWindowUpdate(NULL);
  124.17  }
  124.18  
  124.19  void AwtTextArea::EditGetSel(CHARRANGE &cr) {
  124.20 @@ -993,12 +991,10 @@
  124.21        c->CheckLineSeparator(buffer);
  124.22        c->RemoveCR(buffer);
  124.23        // Fix for 5003402: added restoring/hiding selection to enable automatic scrolling
  124.24 -      LockWindowUpdate(c->GetHWnd());
  124.25        c->SendMessage(EM_HIDESELECTION, FALSE, TRUE);
  124.26        c->SendMessageW(EM_SETSEL, start, end);
  124.27        c->SendMessageW(EM_REPLACESEL, FALSE, (LPARAM)buffer);
  124.28        c->SendMessage(EM_HIDESELECTION, TRUE, TRUE);
  124.29 -      LockWindowUpdate(NULL);
  124.30  
  124.31        delete[] buffer;
  124.32      }
   125.1 --- a/src/windows/native/sun/windows/awt_Win32GraphicsDevice.cpp	Wed Sep 17 13:45:37 2008 -0700
   125.2 +++ b/src/windows/native/sun/windows/awt_Win32GraphicsDevice.cpp	Fri Sep 19 19:38:12 2008 -0700
   125.3 @@ -1021,6 +1021,10 @@
   125.4                                               // with the WWindowPeer object
   125.5      HWND hWnd = window->GetHWnd();
   125.6  
   125.7 +    jobject target = env->GetObjectField(windowPeer, AwtObject::targetID);
   125.8 +    jboolean alwaysOnTop = JNU_GetFieldByName(env, NULL, target, "alwaysOnTop", "Z").z;
   125.9 +    env->DeleteLocalRef(target);
  125.10 +
  125.11      if (!::SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0,
  125.12                          SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOSIZE))
  125.13      {
  125.14 @@ -1029,6 +1033,9 @@
  125.15                      ::GetLastError());
  125.16      }
  125.17  
  125.18 +    // We should restore alwaysOnTop state as it's anyway dropped here
  125.19 +    Java_sun_awt_windows_WWindowPeer_setAlwaysOnTopNative(env, windowPeer, alwaysOnTop);
  125.20 +
  125.21      CATCH_BAD_ALLOC;
  125.22  }
  125.23  
   126.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   126.2 +++ b/test/java/awt/Container/CheckZOrderChange/CheckZOrderChange.java	Fri Sep 19 19:38:12 2008 -0700
   126.3 @@ -0,0 +1,48 @@
   126.4 +/*
   126.5 +   @test %I% %E%
   126.6 +   @bug 2161766
   126.7 +   @summary Component is missing after changing the z-order of the component & focus is not transfered in
   126.8 +   @author  Andrei Dmitriev : area=awt.container
   126.9 +   @run main CheckZOrderChange
  126.10 +*/
  126.11 +import java.awt.*;
  126.12 +import java.awt.event.*;
  126.13 +
  126.14 +public class CheckZOrderChange {
  126.15 +
  126.16 +    private static Button content[] = new Button[]{new Button("Button 1"), new Button("Button 2"), new Button("Button 3"), new Button("Button 4")};
  126.17 +    private static Frame frame;
  126.18 +
  126.19 +    public static void main(String[] args) {
  126.20 +
  126.21 +        frame = new Frame("Test Frame");
  126.22 +        frame.setLayout(new FlowLayout());
  126.23 +
  126.24 +        for (Button b: content){
  126.25 +            frame.add(b);
  126.26 +        }
  126.27 +
  126.28 +        frame.setSize(300, 300);
  126.29 +        frame.setVisible(true);
  126.30 +
  126.31 +        /* INITIAL ZORDERS ARE*/
  126.32 +        for (Button b: content){
  126.33 +            System.out.println("frame.getComponentZOrder("+ b +") = " + frame.getComponentZOrder(b));
  126.34 +        }
  126.35 +
  126.36 +        //Change the Z Order
  126.37 +        frame.setComponentZOrder(content[0], 2);
  126.38 +        System.out.println("ZOrder of button1 changed to 2");
  126.39 +
  126.40 +        if (frame.getComponentZOrder(content[0]) != 2 ||
  126.41 +            frame.getComponentZOrder(content[1]) != 0 ||
  126.42 +            frame.getComponentZOrder(content[2]) != 1 ||
  126.43 +            frame.getComponentZOrder(content[3]) != 3)
  126.44 +        {
  126.45 +            for (Button b: content){
  126.46 +                System.out.println("frame.getComponentZOrder("+ b +") = " + frame.getComponentZOrder(b));
  126.47 +            }
  126.48 +            throw new RuntimeException("TEST FAILED: getComponentZOrder did not return the correct value");
  126.49 +        }
  126.50 +    }
  126.51 +}
   127.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   127.2 +++ b/test/java/awt/Focus/NoAutotransferToDisabledCompTest/NoAutotransferToDisabledCompTest.java	Fri Sep 19 19:38:12 2008 -0700
   127.3 @@ -0,0 +1,109 @@
   127.4 +/*
   127.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
   127.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   127.7 + *
   127.8 + * This code is free software; you can redistribute it and/or modify it
   127.9 + * under the terms of the GNU General Public License version 2 only, as
  127.10 + * published by the Free Software Foundation.
  127.11 + *
  127.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  127.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  127.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  127.15 + * version 2 for more details (a copy is included in the LICENSE file that
  127.16 + * accompanied this code).
  127.17 + *
  127.18 + * You should have received a copy of the GNU General Public License version
  127.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  127.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  127.21 + *
  127.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  127.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
  127.24 + * have any questions.
  127.25 + */
  127.26 +
  127.27 +/*
  127.28 +  @test
  127.29 +  @bug       4685768
  127.30 +  @summary   Tests that auto-transfering focus doesn't stuck on a disabled component.
  127.31 +  @author    Anton Tarasov: area=awt.focus
  127.32 +  @library   ../../regtesthelpers
  127.33 +  @build     Util
  127.34 +  @run       main NoAutotransferToDisabledCompTest
  127.35 +*/
  127.36 +
  127.37 +import java.awt.Robot;
  127.38 +import javax.swing.*;
  127.39 +import java.awt.*;
  127.40 +import java.awt.event.*;
  127.41 +import java.applet.Applet;
  127.42 +import test.java.awt.regtesthelpers.Util;
  127.43 +
  127.44 +public class NoAutotransferToDisabledCompTest extends Applet {
  127.45 +    Robot robot;
  127.46 +    JFrame frame = new JFrame("Frame");
  127.47 +    JButton b0 = new JButton("b0");
  127.48 +    JButton b1 = new JButton("b1");
  127.49 +    JButton b2 = new JButton("b2");
  127.50 +
  127.51 +    public static void main(String[] args) {
  127.52 +        NoAutotransferToDisabledCompTest app = new NoAutotransferToDisabledCompTest();
  127.53 +        app.init();
  127.54 +        app.start();
  127.55 +    }
  127.56 +
  127.57 +    public void init() {
  127.58 +        robot = Util.createRobot();
  127.59 +        frame.add(b0);
  127.60 +        frame.add(b1);
  127.61 +        frame.add(b2);
  127.62 +        frame.setLayout(new FlowLayout());
  127.63 +        frame.pack();
  127.64 +
  127.65 +        b1.addActionListener(new ActionListener() {
  127.66 +            public void actionPerformed(ActionEvent e) {
  127.67 +                b1.setEnabled(false);
  127.68 +                b2.setEnabled(false);
  127.69 +            }
  127.70 +        });
  127.71 +    }
  127.72 +
  127.73 +    public void start() {
  127.74 +        Util.showWindowWait(frame);
  127.75 +
  127.76 +        // Request focus on b1.
  127.77 +        if (!Util.focusComponent(b1, 2000)) {
  127.78 +            throw new TestErrorException("couldn't focus " + b1);
  127.79 +        }
  127.80 +
  127.81 +        // Activate b1.
  127.82 +        robot.keyPress(KeyEvent.VK_SPACE);
  127.83 +        robot.delay(50);
  127.84 +        robot.keyRelease(KeyEvent.VK_SPACE);
  127.85 +        Util.waitForIdle(robot);
  127.86 +
  127.87 +        // Check that focus has been transfered to b0.
  127.88 +        if (!b0.hasFocus()) {
  127.89 +            throw new TestFailedException("focus wasn't auto-transfered properly!");
  127.90 +        }
  127.91 +        System.out.println("Test passed.");
  127.92 +    }
  127.93 +}
  127.94 +
  127.95 +/**
  127.96 + * Thrown when the behavior being verified is found wrong.
  127.97 + */
  127.98 +class TestFailedException extends RuntimeException {
  127.99 +    TestFailedException(String msg) {
 127.100 +        super("Test failed: " + msg);
 127.101 +    }
 127.102 +}
 127.103 +
 127.104 +/**
 127.105 + * Thrown when an error not related to the behavior being verified is encountered.
 127.106 + */
 127.107 +class TestErrorException extends RuntimeException {
 127.108 +    TestErrorException(String msg) {
 127.109 +        super("Unexpected error: " + msg);
 127.110 +    }
 127.111 +}
 127.112 +
   128.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   128.2 +++ b/test/java/awt/Focus/RequestFocusToDisabledCompTest/RequestFocusToDisabledCompTest.java	Fri Sep 19 19:38:12 2008 -0700
   128.3 @@ -0,0 +1,97 @@
   128.4 +/*
   128.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
   128.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   128.7 + *
   128.8 + * This code is free software; you can redistribute it and/or modify it
   128.9 + * under the terms of the GNU General Public License version 2 only, as
  128.10 + * published by the Free Software Foundation.
  128.11 + *
  128.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  128.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  128.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  128.15 + * version 2 for more details (a copy is included in the LICENSE file that
  128.16 + * accompanied this code).
  128.17 + *
  128.18 + * You should have received a copy of the GNU General Public License version
  128.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  128.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  128.21 + *
  128.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  128.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
  128.24 + * have any questions.
  128.25 + */
  128.26 +
  128.27 +/*
  128.28 +  @test
  128.29 +  @bug       4685768
  128.30 +  @summary   Tests that it's possible to manually request focus on a disabled component.
  128.31 +  @author    Anton Tarasov: area=awt.focus
  128.32 +  @library   ../../regtesthelpers
  128.33 +  @build     Util
  128.34 +  @run       main RequestFocusToDisabledCompTest
  128.35 +*/
  128.36 +
  128.37 +import java.awt.Robot;
  128.38 +import javax.swing.*;
  128.39 +import java.awt.*;
  128.40 +import java.awt.event.*;
  128.41 +import java.applet.Applet;
  128.42 +import test.java.awt.regtesthelpers.Util;
  128.43 +
  128.44 +public class RequestFocusToDisabledCompTest extends Applet {
  128.45 +    Robot robot;
  128.46 +    JFrame frame = new JFrame("Frame");
  128.47 +    JButton b0 = new JButton("b0");
  128.48 +    JButton b1 = new JButton("b1");
  128.49 +
  128.50 +    public static void main(String[] args) {
  128.51 +        RequestFocusToDisabledCompTest app = new RequestFocusToDisabledCompTest();
  128.52 +        app.init();
  128.53 +        app.start();
  128.54 +    }
  128.55 +
  128.56 +    public void init() {
  128.57 +        robot = Util.createRobot();
  128.58 +        frame.add(b0);
  128.59 +        frame.add(b1);
  128.60 +        frame.setLayout(new FlowLayout());
  128.61 +        frame.pack();
  128.62 +
  128.63 +        b1.setEnabled(false);
  128.64 +    }
  128.65 +
  128.66 +    public void start() {
  128.67 +        Util.showWindowWait(frame);
  128.68 +
  128.69 +        if (!b0.hasFocus()) {
  128.70 +            // Request focus on b0.
  128.71 +            if (!Util.focusComponent(b0, 2000)) {
  128.72 +                throw new TestErrorException("couldn't focus " + b0);
  128.73 +            }
  128.74 +        }
  128.75 +
  128.76 +        // Try to request focus on b1.
  128.77 +        if (!Util.focusComponent(b1, 2000)) {
  128.78 +            throw new TestFailedException("focus wasn't requested on disabled " + b1);
  128.79 +        }
  128.80 +        System.out.println("Test passed.");
  128.81 +    }
  128.82 +}
  128.83 +
  128.84 +/**
  128.85 + * Thrown when the behavior being verified is found wrong.
  128.86 + */
  128.87 +class TestFailedException extends RuntimeException {
  128.88 +    TestFailedException(String msg) {
  128.89 +        super("Test failed: " + msg);
  128.90 +    }
  128.91 +}
  128.92 +
  128.93 +/**
  128.94 + * Thrown when an error not related to the behavior being verified is encountered.
  128.95 + */
  128.96 +class TestErrorException extends RuntimeException {
  128.97 +    TestErrorException(String msg) {
  128.98 +        super("Unexpected error: " + msg);
  128.99 +    }
 128.100 +}
   129.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   129.2 +++ b/test/java/awt/Mixing/Validating.java	Fri Sep 19 19:38:12 2008 -0700
   129.3 @@ -0,0 +1,405 @@
   129.4 +/*
   129.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
   129.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   129.7 + *
   129.8 + * This code is free software; you can redistribute it and/or modify it
   129.9 + * under the terms of the GNU General Public License version 2 only, as
  129.10 + * published by the Free Software Foundation.
  129.11 + *
  129.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  129.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  129.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  129.15 + * version 2 for more details (a copy is included in the LICENSE file that
  129.16 + * accompanied this code).
  129.17 + *
  129.18 + * You should have received a copy of the GNU General Public License version
  129.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  129.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  129.21 + *
  129.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  129.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
  129.24 + * have any questions.
  129.25 + */
  129.26 +
  129.27 +/*
  129.28 +  @test
  129.29 +  @bug 6682046
  129.30 +  @summary Mixing code does not always recalculate shapes correctly when resizing components
  129.31 +  @author anthony.petrov@...: area=awt.mixing
  129.32 +  @library ../regtesthelpers
  129.33 +  @build Util
  129.34 +  @run main Validating
  129.35 +*/
  129.36 +
  129.37 +/**
  129.38 + * Validating.java
  129.39 + *
  129.40 + * summary:  Mixing code does not always recalculate shapes correctly when resizing components
  129.41 + */
  129.42 +
  129.43 +import java.awt.*;
  129.44 +import java.awt.event.*;
  129.45 +import test.java.awt.regtesthelpers.Util;
  129.46 +
  129.47 +public class Validating
  129.48 +{
  129.49 +    static volatile boolean clickPassed = false;
  129.50 +
  129.51 +    private static void init()
  129.52 +    {
  129.53 +        //*** Create instructions for the user here ***
  129.54 +
  129.55 +        String[] instructions =
  129.56 +        {
  129.57 +            "This is an AUTOMATIC test, simply wait until it is done.",
  129.58 +            "The result (passed or failed) will be shown in the",
  129.59 +            "message window below."
  129.60 +        };
  129.61 +        Sysout.createDialog( );
  129.62 +        Sysout.printInstructions( instructions );
  129.63 +
  129.64 +        if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
  129.65 +            System.out.println("The test environment does not support maximization. The test cannot be performed.");
  129.66 +            pass();
  129.67 +            return;
  129.68 +        }
  129.69 +
  129.70 +        // Create the frame with a button.
  129.71 +        Frame f = new Frame();
  129.72 +        Button b = new Button("ok");
  129.73 +        b.addActionListener(new java.awt.event.ActionListener() {
  129.74 +            public void actionPerformed(java.awt.event.ActionEvent e) {
  129.75 +                clickPassed = true;
  129.76 +            }
  129.77 +        });
  129.78 +        f.add(b);
  129.79 +        // Make the frame maximized
  129.80 +        f.setExtendedState(Frame.MAXIMIZED_BOTH);
  129.81 +        f.pack();
  129.82 +        f.setVisible(true);
  129.83 +
  129.84 +        Robot robot = Util.createRobot();
  129.85 +        robot.setAutoDelay(20);
  129.86 +
  129.87 +        Util.waitForIdle(robot);
  129.88 +
  129.89 +        // Now let's attempt to click in the middle of the button
  129.90 +        // (i.e. in the middle of the window).
  129.91 +        // If the button doesn't receive the click, it means that the test
  129.92 +        // failed: the shape of the button was not enlarged.
  129.93 +        Point heavyLoc = b.getLocationOnScreen();
  129.94 +        robot.mouseMove(heavyLoc.x + b.getWidth() / 2, heavyLoc.y + b.getHeight() / 2);
  129.95 +
  129.96 +        robot.mousePress(InputEvent.BUTTON1_MASK);
  129.97 +        robot.mouseRelease(InputEvent.BUTTON1_MASK);
  129.98 +        Util.waitForIdle(robot);
  129.99 +
 129.100 +        if (clickPassed) {
 129.101 +            pass();
 129.102 +        } else {
 129.103 +            fail("The button cannot be clicked.");
 129.104 +        }
 129.105 +    }//End  init()
 129.106 +
 129.107 +
 129.108 +
 129.109 +    /*****************************************************
 129.110 +     * Standard Test Machinery Section
 129.111 +     * DO NOT modify anything in this section -- it's a
 129.112 +     * standard chunk of code which has all of the
 129.113 +     * synchronisation necessary for the test harness.
 129.114 +     * By keeping it the same in all tests, it is easier
 129.115 +     * to read and understand someone else's test, as
 129.116 +     * well as insuring that all tests behave correctly
 129.117 +     * with the test harness.
 129.118 +     * There is a section following this for test-
 129.119 +     * classes
 129.120 +     ******************************************************/
 129.121 +    private static boolean theTestPassed = false;
 129.122 +    private static boolean testGeneratedInterrupt = false;
 129.123 +    private static String failureMessage = "";
 129.124 +
 129.125 +    private static Thread mainThread = null;
 129.126 +
 129.127 +    private static int sleepTime = 300000;
 129.128 +
 129.129 +    // Not sure about what happens if multiple of this test are
 129.130 +    //  instantiated in the same VM.  Being static (and using
 129.131 +    //  static vars), it aint gonna work.  Not worrying about
 129.132 +    //  it for now.
 129.133 +    public static void main( String args[] ) throws InterruptedException
 129.134 +    {
 129.135 +        mainThread = Thread.currentThread();
 129.136 +        try
 129.137 +        {
 129.138 +            init();
 129.139 +        }
 129.140 +        catch( TestPassedException e )
 129.141 +        {
 129.142 +            //The test passed, so just return from main and harness will
 129.143 +            // interepret this return as a pass
 129.144 +            return;
 129.145 +        }
 129.146 +        //At this point, neither test pass nor test fail has been
 129.147 +        // called -- either would have thrown an exception and ended the
 129.148 +        // test, so we know we have multiple threads.
 129.149 +
 129.150 +        //Test involves other threads, so sleep and wait for them to
 129.151 +        // called pass() or fail()
 129.152 +        try
 129.153 +        {
 129.154 +            Thread.sleep( sleepTime );
 129.155 +            //Timed out, so fail the test
 129.156 +            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
 129.157 +        }
 129.158 +        catch (InterruptedException e)
 129.159 +        {
 129.160 +            //The test harness may have interrupted the test.  If so, rethrow the exception
 129.161 +            // so that the harness gets it and deals with it.
 129.162 +            if( ! testGeneratedInterrupt ) throw e;
 129.163 +
 129.164 +            //reset flag in case hit this code more than once for some reason (just safety)
 129.165 +            testGeneratedInterrupt = false;
 129.166 +
 129.167 +            if ( theTestPassed == false )
 129.168 +            {
 129.169 +                throw new RuntimeException( failureMessage );
 129.170 +            }
 129.171 +        }
 129.172 +
 129.173 +    }//main
 129.174 +
 129.175 +    public static synchronized void setTimeoutTo( int seconds )
 129.176 +    {
 129.177 +        sleepTime = seconds * 1000;
 129.178 +    }
 129.179 +
 129.180 +    public static synchronized void pass()
 129.181 +    {
 129.182 +        Sysout.println( "The test passed." );
 129.183 +        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
 129.184 +        //first check if this is executing in main thread
 129.185 +        if ( mainThread == Thread.currentThread() )
 129.186 +        {
 129.187 +            //Still in the main thread, so set the flag just for kicks,
 129.188 +            // and throw a test passed exception which will be caught
 129.189 +            // and end the test.
 129.190 +            theTestPassed = true;
 129.191 +            throw new TestPassedException();
 129.192 +        }
 129.193 +        theTestPassed = true;
 129.194 +        testGeneratedInterrupt = true;
 129.195 +        mainThread.interrupt();
 129.196 +    }//pass()
 129.197 +
 129.198 +    public static synchronized void fail()
 129.199 +    {
 129.200 +        //test writer didn't specify why test failed, so give generic
 129.201 +        fail( "it just plain failed! :-)" );
 129.202 +    }
 129.203 +
 129.204 +    public static synchronized void fail( String whyFailed )
 129.205 +    {
 129.206 +        Sysout.println( "The test failed: " + whyFailed );
 129.207 +        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
 129.208 +        //check if this called from main thread
 129.209 +        if ( mainThread == Thread.currentThread() )
 129.210 +        {
 129.211 +            //If main thread, fail now 'cause not sleeping
 129.212 +            throw new RuntimeException( whyFailed );
 129.213 +        }
 129.214 +        theTestPassed = false;
 129.215 +        testGeneratedInterrupt = true;
 129.216 +        failureMessage = whyFailed;
 129.217 +        mainThread.interrupt();
 129.218 +    }//fail()
 129.219 +
 129.220 +}// class Validating
 129.221 +
 129.222 +//This exception is used to exit from any level of call nesting
 129.223 +// when it's determined that the test has passed, and immediately
 129.224 +// end the test.
 129.225 +class TestPassedException extends RuntimeException
 129.226 +{
 129.227 +}
 129.228 +
 129.229 +//*********** End Standard Test Machinery Section **********
 129.230 +
 129.231 +
 129.232 +//************ Begin classes defined for the test ****************
 129.233 +
 129.234 +// if want to make listeners, here is the recommended place for them, then instantiate
 129.235 +//  them in init()
 129.236 +
 129.237 +/* Example of a class which may be written as part of a test
 129.238 +class NewClass implements anInterface
 129.239 + {
 129.240 +   static int newVar = 0;
 129.241 +
 129.242 +   public void eventDispatched(AWTEvent e)
 129.243 +    {
 129.244 +      //Counting events to see if we get enough
 129.245 +      eventCount++;
 129.246 +
 129.247 +      if( eventCount == 20 )
 129.248 +       {
 129.249 +         //got enough events, so pass
 129.250 +
 129.251 +         Validating.pass();
 129.252 +       }
 129.253 +      else if( tries == 20 )
 129.254 +       {
 129.255 +         //tried too many times without getting enough events so fail
 129.256 +
 129.257 +         Validating.fail();
 129.258 +       }
 129.259 +
 129.260 +    }// eventDispatched()
 129.261 +
 129.262 + }// NewClass class
 129.263 +
 129.264 +*/
 129.265 +
 129.266 +
 129.267 +//************** End classes defined for the test *******************
 129.268 +
 129.269 +
 129.270 +
 129.271 +
 129.272 +/****************************************************
 129.273 + Standard Test Machinery
 129.274 + DO NOT modify anything below -- it's a standard
 129.275 +  chunk of code whose purpose is to make user
 129.276 +  interaction uniform, and thereby make it simpler
 129.277 +  to read and understand someone else's test.
 129.278 + ****************************************************/
 129.279 +
 129.280 +/**
 129.281 + This is part of the standard test machinery.
 129.282 + It creates a dialog (with the instructions), and is the interface
 129.283 +  for sending text messages to the user.
 129.284 + To print the instructions, send an array of strings to Sysout.createDialog
 129.285 +  WithInstructions method.  Put one line of instructions per array entry.
 129.286 + To display a message for the tester to see, simply call Sysout.println
 129.287 +  with the string to be displayed.
 129.288 + This mimics System.out.println but works within the test harness as well
 129.289 +  as standalone.
 129.290 + */
 129.291 +
 129.292 +class Sysout
 129.293 +{
 129.294 +    private static TestDialog dialog;
 129.295 +
 129.296 +    public static void createDialogWithInstructions( String[] instructions )
 129.297 +    {
 129.298 +        dialog = new TestDialog( new Frame(), "Instructions" );
 129.299 +        dialog.printInstructions( instructions );
 129.300 +        dialog.setVisible(true);
 129.301 +        println( "Any messages for the tester will display here." );
 129.302 +    }
 129.303 +
 129.304 +    public static void createDialog( )
 129.305 +    {
 129.306 +        dialog = new TestDialog( new Frame(), "Instructions" );
 129.307 +        String[] defInstr = { "Instructions will appear here. ", "" } ;
 129.308 +        dialog.printInstructions( defInstr );
 129.309 +        dialog.setVisible(true);
 129.310 +        println( "Any messages for the tester will display here." );
 129.311 +    }
 129.312 +
 129.313 +
 129.314 +    public static void printInstructions( String[] instructions )
 129.315 +    {
 129.316 +        dialog.printInstructions( instructions );
 129.317 +    }
 129.318 +
 129.319 +
 129.320 +    public static void println( String messageIn )
 129.321 +    {
 129.322 +        dialog.displayMessage( messageIn );
 129.323 +        System.out.println(messageIn);
 129.324 +    }
 129.325 +
 129.326 +}// Sysout  class
 129.327 +
 129.328 +/**
 129.329 +  This is part of the standard test machinery.  It provides a place for the
 129.330 +   test instructions to be displayed, and a place for interactive messages
 129.331 +   to the user to be displayed.
 129.332 +  To have the test instructions displayed, see Sysout.
 129.333 +  To have a message to the user be displayed, see Sysout.
 129.334 +  Do not call anything in this dialog directly.
 129.335 +  */
 129.336 +class TestDialog extends Dialog
 129.337 +{
 129.338 +
 129.339 +    TextArea instructionsText;
 129.340 +    TextArea messageText;
 129.341 +    int maxStringLength = 80;
 129.342 +
 129.343 +    //DO NOT call this directly, go through Sysout
 129.344 +    public TestDialog( Frame frame, String name )
 129.345 +    {
 129.346 +        super( frame, name );
 129.347 +        int scrollBoth = TextArea.SCROLLBARS_BOTH;
 129.348 +        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
 129.349 +        add( "North", instructionsText );
 129.350 +
 129.351 +        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
 129.352 +        add("Center", messageText);
 129.353 +
 129.354 +        pack();
 129.355 +
 129.356 +        setVisible(true);
 129.357 +    }// TestDialog()
 129.358 +
 129.359 +    //DO NOT call this directly, go through Sysout
 129.360 +    public void printInstructions( String[] instructions )
 129.361 +    {
 129.362 +        //Clear out any current instructions
 129.363 +        instructionsText.setText( "" );
 129.364 +
 129.365 +        //Go down array of instruction strings
 129.366 +
 129.367 +        String printStr, remainingStr;
 129.368 +        for( int i=0; i < instructions.length; i++ )
 129.369 +        {
 129.370 +            //chop up each into pieces maxSringLength long
 129.371 +            remainingStr = instructions[ i ];
 129.372 +            while( remainingStr.length() > 0 )
 129.373 +            {
 129.374 +                //if longer than max then chop off first max chars to print
 129.375 +                if( remainingStr.length() >= maxStringLength )
 129.376 +                {
 129.377 +                    //Try to chop on a word boundary
 129.378 +                    int posOfSpace = remainingStr.
 129.379 +                        lastIndexOf( ' ', maxStringLength - 1 );
 129.380 +
 129.381 +                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
 129.382 +
 129.383 +                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
 129.384 +                    remainingStr = remainingStr.substring( posOfSpace + 1 );
 129.385 +                }
 129.386 +                //else just print
 129.387 +                else
 129.388 +                {
 129.389 +                    printStr = remainingStr;
 129.390 +                    remainingStr = "";
 129.391 +                }
 129.392 +
 129.393 +                instructionsText.append( printStr + "\n" );
 129.394 +
 129.395 +            }// while
 129.396 +
 129.397 +        }// for
 129.398 +
 129.399 +    }//printInstructions()
 129.400 +
 129.401 +    //DO NOT call this directly, go through Sysout
 129.402 +    public void displayMessage( String messageIn )
 129.403 +    {
 129.404 +        messageText.append( messageIn + "\n" );
 129.405 +        System.out.println(messageIn);
 129.406 +    }
 129.407 +
 129.408 +}// TestDialog  class
   130.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   130.2 +++ b/test/java/awt/Toolkit/HeadlessTray/HeadlessTray.java	Fri Sep 19 19:38:12 2008 -0700
   130.3 @@ -0,0 +1,49 @@
   130.4 +/*
   130.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
   130.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   130.7 + *
   130.8 + * This code is free software; you can redistribute it and/or modify it
   130.9 + * under the terms of the GNU General Public License version 2 only, as
  130.10 + * published by the Free Software Foundation.
  130.11 + *
  130.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  130.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  130.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  130.15 + * version 2 for more details (a copy is included in the LICENSE file that
  130.16 + * accompanied this code).
  130.17 + *
  130.18 + * You should have received a copy of the GNU General Public License version
  130.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  130.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  130.21 + *
  130.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  130.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
  130.24 + * have any questions.
  130.25 + */
  130.26 +
  130.27 +/*
  130.28 +  @test
  130.29 +  @bug 6737722
  130.30 +  @summary no tray support in headless mode
  130.31 +  @author dmitry.cherepanov: area=awt.headless
  130.32 +  @run main HeadlessTray
  130.33 +*/
  130.34 +
  130.35 +import java.awt.*;
  130.36 +
  130.37 +public class HeadlessTray
  130.38 +{
  130.39 +    public static void main (String args[]) {
  130.40 +
  130.41 +        System.setProperty("java.awt.headless", "true");
  130.42 +
  130.43 +        // We expect the method returns false and no exception thrown
  130.44 +        boolean isSupported = SystemTray.isSupported();
  130.45 +
  130.46 +        if (isSupported) {
  130.47 +            throw new RuntimeException("Tray shouldn't be supported in headless mode ");
  130.48 +        }
  130.49 +
  130.50 +    }
  130.51 +
  130.52 +}
   131.1 --- a/test/java/awt/event/MouseEvent/SpuriousExitEnter/SpuriousExitEnter_2.java	Wed Sep 17 13:45:37 2008 -0700
   131.2 +++ b/test/java/awt/event/MouseEvent/SpuriousExitEnter/SpuriousExitEnter_2.java	Fri Sep 19 19:38:12 2008 -0700
   131.3 @@ -1,5 +1,5 @@
   131.4  /*
   131.5 - * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
   131.6 + * Copyright (c) 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
   131.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   131.8   *
   131.9   * This code is free software; you can redistribute it and/or modify it
  131.10 @@ -100,7 +100,7 @@
  131.11          Sysout.printInstructions( instructions );
  131.12          Sysout.enableNumbering(true);
  131.13  
  131.14 -        MouseAdapter enterExitAdapter = new MouseAdapter {
  131.15 +        MouseAdapter enterExitAdapter = new MouseAdapter() {
  131.16                  public void mouseEntered(MouseEvent e){
  131.17                      Sysout.println("Entered on " + e.getSource().getClass().getName());
  131.18                  }
   132.1 --- a/test/java/awt/regtesthelpers/Util.java	Wed Sep 17 13:45:37 2008 -0700
   132.2 +++ b/test/java/awt/regtesthelpers/Util.java	Fri Sep 19 19:38:12 2008 -0700
   132.3 @@ -124,6 +124,14 @@
   132.4      }
   132.5  
   132.6      /**
   132.7 +     * Makes the window visible and waits until it's shown.
   132.8 +     */
   132.9 +    public static void showWindowWait(Window win) {
  132.10 +        win.setVisible(true);
  132.11 +        waitTillShown(win);
  132.12 +    }
  132.13 +
  132.14 +    /**
  132.15       * Moves mouse pointer in the center of given {@code comp} component
  132.16       * using {@code robot} parameter.
  132.17       */
  132.18 @@ -574,4 +582,22 @@
  132.19      public static boolean trackActionPerformed(Button button, Runnable action, int time, boolean printEvent) {
  132.20          return trackEvent(ActionEvent.ACTION_PERFORMED, button, action, time, printEvent);
  132.21      }
  132.22 +
  132.23 +    /*
  132.24 +     * Requests focus on the component provided and waits for the result.
  132.25 +     * @return true if the component has been focused, false otherwise.
  132.26 +     */
  132.27 +    public static boolean focusComponent(Component comp, int time) {
  132.28 +        return focusComponent(comp, time, false);
  132.29 +    }
  132.30 +    public static boolean focusComponent(final Component comp, int time, boolean printEvent) {
  132.31 +        return trackFocusGained(comp,
  132.32 +                                new Runnable() {
  132.33 +                                    public void run() {
  132.34 +                                        comp.requestFocus();
  132.35 +                                    }
  132.36 +                                },
  132.37 +                                time, printEvent);
  132.38 +
  132.39 +    }
  132.40  }