--- a/.hgtags Tue Dec 13 15:41:47 2011 -0800
+++ b/.hgtags Thu Dec 15 19:52:13 2011 -0800
@@ -136,3 +136,5 @@
86db042b3385c338e17f7664447fdc7d406dd19e jdk8-b12
4cc0ef72c812943743ef4765f1100e2fbe2b1a08 jdk8-b13
9ffaa48dbfb0f5936c2b789867d0785faec7071d jdk8-b14
+b5060eae3b32fd9f884a09774338cd8186d7fafa jdk8-b15
+736a63b854f321c7824b7e47890135f80aee05e3 jdk8-b16
--- a/.hgtags-top-repo Tue Dec 13 15:41:47 2011 -0800
+++ b/.hgtags-top-repo Thu Dec 15 19:52:13 2011 -0800
@@ -136,3 +136,4 @@
8e2104d565baee473895d5eba20e39f85ab4bf9f jdk8-b12
26fb81a1e9ceb9baffba216acd9ded62e9e9d5ab jdk8-b13
23aa7f2c80a2fa354c80decf03e7c2018177ef4e jdk8-b14
+a4f28069d44a379cda99dd1d921d19f819726d22 jdk8-b15
--- a/corba/.hgtags Tue Dec 13 15:41:47 2011 -0800
+++ b/corba/.hgtags Thu Dec 15 19:52:13 2011 -0800
@@ -136,3 +136,4 @@
31d70911b712c6b4e580a3110363d5f044cfed7a jdk8-b12
5b9d9b839d3d7fe02347827221c97c6d242a6f96 jdk8-b13
e59c47de1ad8982ff3b0e843773a6902b36c2337 jdk8-b14
+7da69e7175a7c7564ee6d0e52255cbb8a57ef577 jdk8-b15
--- a/hotspot/.hgtags Tue Dec 13 15:41:47 2011 -0800
+++ b/hotspot/.hgtags Thu Dec 15 19:52:13 2011 -0800
@@ -200,3 +200,4 @@
b92ca8e229d29004f840c67e620833d23a346761 jdk8-b13
088d09a130ff02d8f5f05e92256baabe412f0439 jdk8-b14
6c2a55d4902f202e1c2de1df17b7da083a2c31e8 hs23-b06
+fde2a39ed7f39233b287fbc278f437aac06c275b jdk8-b15
--- a/jaxp/.hgtags Tue Dec 13 15:41:47 2011 -0800
+++ b/jaxp/.hgtags Thu Dec 15 19:52:13 2011 -0800
@@ -136,3 +136,4 @@
ca977d167697a561c04894187fc1c4d927582ffa jdk8-b12
bcc739229f6384786c7ac0b52c1822c85674dcf1 jdk8-b13
9d0c9d638757cb09de18933b946fa04b4f3fb94f jdk8-b14
+804f666d6d44e33caac12ad8da3d2780ac44ef72 jdk8-b15
--- a/jaxp/build.properties Tue Dec 13 15:41:47 2011 -0800
+++ b/jaxp/build.properties Thu Dec 15 19:52:13 2011 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
# Base locations where bundles are located
slashjava=/java
-drops.dir=${slashjava}/devtools/share/jdk7-drops
+drops.dir=${slashjava}/devtools/share/jdk8-drops
# This is the JDK used to build and run the bootstrap version of javac.
# The bootstrap javac is used to compile both boostrap versions of the
--- a/jaxp/make/Makefile Tue Dec 13 15:41:47 2011 -0800
+++ b/jaxp/make/Makefile Thu Dec 15 19:52:13 2011 -0800
@@ -99,9 +99,9 @@
DROPS_DIR = $(ALT_DROPS_DIR)
else
ifdef ALT_JDK_DEVTOOLS_DIR
- DROPS_DIR = $(ALT_JDK_DEVTOOLS_DIR)/share/jdk7-drops
+ DROPS_DIR = $(ALT_JDK_DEVTOOLS_DIR)/share/jdk8-drops
else
- DROPS_DIR = $(_SLASHJAVA)/devtools/share/jdk7-drops
+ DROPS_DIR = $(_SLASHJAVA)/devtools/share/jdk8-drops
endif
endif
--- a/jaxws/.hgtags Tue Dec 13 15:41:47 2011 -0800
+++ b/jaxws/.hgtags Thu Dec 15 19:52:13 2011 -0800
@@ -136,3 +136,4 @@
e6eed2ff5d5f62bdc815beb5276d23347600c760 jdk8-b12
adf2a6b5fde14090beb9ebc40c4114132ddee731 jdk8-b13
54c4bf4b83ecc191351747d5d28da849d34c0243 jdk8-b14
+c9ab96ff23d52d85d5dcce1f9c0fd7a3de418c74 jdk8-b15
--- a/jaxws/build.properties Tue Dec 13 15:41:47 2011 -0800
+++ b/jaxws/build.properties Thu Dec 15 19:52:13 2011 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
# Base locations where bundles are located
slashjava=/java
-drops.dir=${slashjava}/devtools/share/jdk7-drops
+drops.dir=${slashjava}/devtools/share/jdk8-drops
# This is the JDK used to build and run the bootstrap version of javac.
# The bootstrap javac is used to compile both boostrap versions of the
--- a/jaxws/make/Makefile Tue Dec 13 15:41:47 2011 -0800
+++ b/jaxws/make/Makefile Thu Dec 15 19:52:13 2011 -0800
@@ -99,9 +99,9 @@
DROPS_DIR = $(ALT_DROPS_DIR)
else
ifdef ALT_JDK_DEVTOOLS_DIR
- DROPS_DIR = $(ALT_JDK_DEVTOOLS_DIR)/share/jdk7-drops
+ DROPS_DIR = $(ALT_JDK_DEVTOOLS_DIR)/share/jdk8-drops
else
- DROPS_DIR = $(_SLASHJAVA)/devtools/share/jdk7-drops
+ DROPS_DIR = $(_SLASHJAVA)/devtools/share/jdk8-drops
endif
endif
--- a/jdk/.hgtags Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/.hgtags Thu Dec 15 19:52:13 2011 -0800
@@ -136,3 +136,6 @@
09fd2067f715e4505c44b01c301258a4e8f8964e jdk8-b12
4cb2e8679b27432854690cb688ea06d3b2d8e008 jdk8-b13
99632935785e2038b2fc836da9f2ede69dea294b jdk8-b14
+3c248d0e2c486624cc0d7aba1e4df45ae5774ff7 jdk8-b15
+b71d1acfae5240d8c1359443cd02b5ddb587231c jdk8-b17
+929597c6e777f742ad252660045ebaa4a3ea4772 jdk8-b16
--- a/jdk/make/sun/awt/FILES_c_unix.gmk Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/make/sun/awt/FILES_c_unix.gmk Thu Dec 15 19:52:13 2011 -0800
@@ -140,71 +140,13 @@
debug_trace.c \
debug_util.c
-# These files rely on motif to be built, and should not be included
-# in a headless build.
-
-#FILES_MOTIF_c = \
-#keep awt_AWTEvent.c \
-# awt_Button.c \
-# awt_Canvas.c \
-# awt_Checkbox.c \
-#keep .h awt_Component.c \
-#keep .h awt_Cursor.c \
-# awt_DataTransferer.c \
-# awt_DrawingSurface.c \
-# awt_Event.c \
-# awt_FileDialog.c \
-# awt_GlobalCursorManager.c \
-# awt_GraphicsEnv.c \
-# awt_InputMethod.c \
-#keep awt_Insets.c \
-# awt_KeyboardFocusManager.c \
-# awt_Label.c \
-# awt_List.c \
-# awt_Menu.c \
-# awt_MenuBar.c \
-# awt_MenuComponent.c \
-# awt_MenuItem.c \
-# awt_motif.c \
-# awt_Plugin.c \
-# awt_PopupMenu.c \
-# awt_Robot.c \
-# awt_Scrollbar.c \
-# awt_ScrollPane.c \
-# awt_Selection.c \
-# awt_UNIXToolkit.c \
-# awt_TextArea.c \
-# awt_TextField.c \
-# awt_TopLevel.c \
-# awt_mgrsel.c \
-# awt_util.c \
-# awt_wm.c \
-# awt_XmDnD.c \
-# awt_dnd.c \
-# awt_dnd_ds.c \
-# awt_dnd_dt.c \
-# canvas.c \
-# cursor.c \
-# multi_font.c \
-# robot_common.c \
-# list.c \
-# multiVis.c \
-# XDrawingArea.c \
-# MouseInfo.c \
-# awt_xembed.c \
-# awt_xembed_server.c \
-# gtk2_interface.c \
-# swing_GTKEngine.c \
-# swing_GTKStyle.c
-
-
# These files are required to be built, with or without motif. Some of
# these are only dependent on X11, and some contain native source that
# is required, even in a headless build.
FILES_NO_MOTIF_c = \
awt_Font.c \
- awt_MToolkit.c \
+ HeadlessToolkit.c \
fontpath.c \
VDrawingArea.c \
X11Color.c \
--- a/jdk/make/sun/awt/FILES_export_unix.gmk Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/make/sun/awt/FILES_export_unix.gmk Thu Dec 15 19:52:13 2011 -0800
@@ -61,11 +61,8 @@
sun/awt/image/BufImgSurfaceData.java \
sun/awt/image/DataBufferNative.java \
\
- sun/awt/motif/X11FontMetrics.java \
sun/awt/X11InputMethod.java \
sun/awt/motif/MFontConfiguration.java \
- sun/awt/motif/MFontPeer.java \
- sun/awt/motif/MToolkit.java \
sun/awt/DebugSettings.java \
sun/awt/EmbeddedFrame.java \
sun/awt/PlatformFont.java \
@@ -93,7 +90,6 @@
sun/java2d/cmm/ColorTransform.java \
sun/awt/datatransfer/DataTransferer.java \
sun/awt/dnd/SunDragSourceContextPeer.java \
- sun/awt/motif/MToolkitThreadBlockedHandler.java \
sun/java2d/opengl/OGLBlitLoops.java \
sun/java2d/opengl/OGLContext.java \
sun/java2d/opengl/OGLMaskFill.java \
--- a/jdk/make/sun/awt/mapfile-mawt-vers Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/make/sun/awt/mapfile-mawt-vers Thu Dec 15 19:52:13 2011 -0800
@@ -31,7 +31,6 @@
global:
JNI_OnLoad;
- #Java_sun_awt_motif_MComponentPeer_restoreFocus;
Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords;
Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse;
Java_java_awt_AWTEvent_nativeSetSource;
@@ -56,230 +55,11 @@
Java_sun_awt_UNIXToolkit_load_1stock_1icon;
Java_sun_awt_UNIXToolkit_load_1gtk_1icon;
Java_sun_awt_UNIXToolkit_nativeSync;
- #Java_sun_awt_motif_MButtonPeer_create;
- #Java_sun_awt_motif_MButtonPeer_setLabel;
- #Java_sun_awt_motif_MPanelPeer_pEnsureIndex;
- #Java_sun_awt_motif_MPanelPeer_pRestack;
- #Java_sun_awt_motif_MCanvasPeer_create;
- #Java_sun_awt_motif_MCanvasPeer_initIDs;
- #Java_sun_awt_motif_MCanvasPeer_resetTargetGC;
- #Java_sun_awt_motif_MCheckboxMenuItemPeer_pSetState;
- #Java_sun_awt_motif_MCheckboxPeer_create;
- #Java_sun_awt_motif_MCheckboxPeer_setCheckboxGroup;
- #Java_sun_awt_motif_MCheckboxPeer_setLabel;
- #Java_sun_awt_motif_MCheckboxPeer_pSetState;
- #Java_sun_awt_motif_MCheckboxPeer_pGetState;
- #Java_sun_awt_motif_MChoicePeer_addItem;
- #Java_sun_awt_motif_MChoicePeer_appendItems;
- #Java_sun_awt_motif_MChoicePeer_create;
- #Java_sun_awt_motif_MChoicePeer_pReshape;
- #Java_sun_awt_motif_MChoicePeer_remove;
- #Java_sun_awt_motif_MChoicePeer_removeAll;
- #Java_sun_awt_motif_MChoicePeer_setBackground;
- #Java_sun_awt_motif_MChoicePeer_pSelect;
- #Java_sun_awt_motif_MChoicePeer_setFont;
- #Java_sun_awt_motif_MChoicePeer_setForeground;
- #Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
- #Java_sun_awt_motif_MComponentPeer_getNativeColor;
- #Java_sun_awt_motif_MComponentPeer_getWindow;
- #Java_sun_awt_motif_MComponentPeer_pDisable;
- #Java_sun_awt_motif_MComponentPeer_pDispose;
- #Java_sun_awt_motif_MComponentPeer_pEnable;
- #Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen;
- #Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2;
- #Java_sun_awt_motif_MComponentPeer_pHide;
- #Java_sun_awt_motif_MComponentPeer_pInitialize;
- #Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible;
- #Java_sun_awt_motif_MComponentPeer_pReshape;
- #Java_sun_awt_motif_MComponentPeer_pShow;
- #Java_sun_awt_motif_MComponentPeer_removeNativeDropTarget;
- #Java_sun_awt_motif_MComponentPeer_pSetBackground;
- #Java_sun_awt_motif_MComponentPeer_pSetFont;
- #Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer;
- #Java_sun_awt_motif_MComponentPeer__1requestFocus;
- #Java_sun_awt_motif_MComponentPeer_getNativeFocusedWindow;
- #Java_sun_awt_motif_MCheckboxMenuItemPeer_getState;
- #Java_sun_awt_motif_MComponentPeer_pSetForeground;
- #Java_sun_awt_motif_MDragSourceContextPeer_startDrag;
- #Java_sun_awt_motif_MDragSourceContextPeer_setNativeCursor;
- #Java_sun_awt_motif_MDropTargetContextPeer_addTransfer;
- #Java_sun_awt_motif_MDropTargetContextPeer_dropDone;
- #Java_sun_awt_motif_MDropTargetContextPeer_startTransfer;
- #Java_sun_awt_motif_X11DragSourceContextPeer_startDrag;
- #Java_sun_awt_motif_X11DragSourceContextPeer_setNativeCursor;
- #Java_sun_awt_motif_X11DropTargetContextPeer_sendResponse;
- #Java_sun_awt_motif_X11DropTargetContextPeer_dropDone;
- #Java_sun_awt_motif_X11DropTargetContextPeer_getData;
- #Java_sun_awt_motif_MEmbeddedFramePeer_NEFcreate;
- #Java_sun_awt_motif_MEmbeddedFramePeer_pShowImpl;
- #Java_sun_awt_motif_MEmbeddedFramePeer_requestXEmbedFocus;
- #Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedApplicationActive;
- #Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedActive;
- #Java_sun_awt_motif_MEmbeddedFramePeer_synthesizeFocusInOut;
- #Java_sun_awt_motif_MEmbeddedFramePeer_pReshapePrivate;
- #Java_sun_awt_motif_MEmbeddedFramePeer_getBoundsPrivate;
- #Java_sun_awt_motif_MEmbeddedFrame_getWidget;
- #Java_sun_awt_motif_MEmbeddedFrame_mapWidget;
- #Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded;
- #Java_sun_awt_motif_MFramePeer_pSetIconImage___3B_3I_3SII;
- #Java_sun_awt_motif_MFileDialogPeer_create;
- #Java_sun_awt_motif_MFileDialogPeer_pDispose;
- #Java_sun_awt_motif_MFileDialogPeer_pHide;
- #Java_sun_awt_motif_MFileDialogPeer_pReshape;
- #Java_sun_awt_motif_MFileDialogPeer_pShow;
- #Java_sun_awt_motif_MFileDialogPeer_setFileEntry;
- #Java_sun_awt_motif_MFileDialogPeer_setFont;
- #Java_sun_awt_motif_MFramePeer_pGetIconSize;
- #Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
- #Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
- #Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
- #Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
- #Java_sun_awt_motif_MGlobalCursorManager_getLocationOnScreen;
- #Java_sun_awt_motif_MLabelPeer_create;
- #Java_sun_awt_motif_MLabelPeer_setAlignment;
- #Java_sun_awt_motif_MLabelPeer_setText;
- #Java_sun_awt_motif_MListPeer_addItem;
- #Java_sun_awt_motif_MListPeer_create;
- #Java_sun_awt_motif_MListPeer_delItems;
- #Java_sun_awt_motif_MListPeer_deselect;
- #Java_sun_awt_motif_MListPeer_isSelected;
- #Java_sun_awt_motif_MListPeer_makeVisible;
- #Java_sun_awt_motif_MListPeer_nativeHandleMouseWheel;
- #Java_sun_awt_motif_MListPeer_select;
- #Java_sun_awt_motif_MListPeer_setMultipleSelections;
- #Java_sun_awt_motif_MMenuBarPeer_create;
- #Java_sun_awt_motif_MMenuItemPeer_createMenuItem;
- #Java_sun_awt_motif_MMenuItemPeer_pDisable;
- #Java_sun_awt_motif_MMenuItemPeer_pDispose;
- #Java_sun_awt_motif_MMenuItemPeer_pEnable;
- #Java_sun_awt_motif_MMenuItemPeer_pSetLabel;
- #Java_sun_awt_motif_MMenuPeer_createMenu;
- #Java_sun_awt_motif_MMenuPeer_createSubMenu;
- #Java_sun_awt_motif_MMenuPeer_pDispose;
- #Java_sun_awt_motif_MPopupMenuPeer_createMenu;
- #Java_sun_awt_motif_MPopupMenuPeer_pDispose;
- #Java_sun_awt_motif_MPopupMenuPeer_pShow;
- #Java_sun_awt_motif_MRobotPeer_getRGBPixelsImpl;
- #Java_sun_awt_motif_MRobotPeer_keyPressImpl;
- #Java_sun_awt_motif_MRobotPeer_keyReleaseImpl;
- #Java_sun_awt_motif_MRobotPeer_mouseMoveImpl;
- #Java_sun_awt_motif_MRobotPeer_mousePressImpl;
- #Java_sun_awt_motif_MRobotPeer_mouseReleaseImpl;
- #Java_sun_awt_motif_MRobotPeer_mouseWheelImpl;
- #Java_sun_awt_motif_MRobotPeer_setup;
- #Java_sun_awt_motif_MScrollbarPeer_create;
- #Java_sun_awt_motif_MScrollbarPeer_setLineIncrement;
- #Java_sun_awt_motif_MScrollbarPeer_setPageIncrement;
- #Java_sun_awt_motif_MScrollbarPeer_pSetValues;
- #Java_sun_awt_motif_MScrollPanePeer_create;
- #Java_sun_awt_motif_MScrollPanePeer_pGetBlockIncrement;
- #Java_sun_awt_motif_MScrollPanePeer_pGetScrollbarSpace;
- #Java_sun_awt_motif_MScrollPanePeer_pGetShadow;
- #Java_sun_awt_motif_MScrollPanePeer_pInsets;
- #Java_sun_awt_motif_MScrollPanePeer_pSetIncrement;
- #Java_sun_awt_motif_MScrollPanePeer_pSetScrollChild;
- #Java_sun_awt_motif_MScrollPanePeer_setScrollPosition;
- #Java_sun_awt_motif_MScrollPanePeer_setTypedValue;
- #Java_sun_awt_motif_MTextAreaPeer_initIDs;
- #Java_sun_awt_motif_MTextAreaPeer_pCreate;
- #Java_sun_awt_motif_MTextAreaPeer_getCaretPosition;
- #Java_sun_awt_motif_MTextAreaPeer_getExtraHeight;
- #Java_sun_awt_motif_MTextAreaPeer_getExtraWidth;
- #Java_sun_awt_motif_MTextAreaPeer_getSelectionEnd;
- #Java_sun_awt_motif_MTextAreaPeer_getSelectionStart;
- #Java_sun_awt_motif_MTextAreaPeer_getText;
- #Java_sun_awt_motif_MTextAreaPeer_insert;
- #Java_sun_awt_motif_MTextAreaPeer_nativeHandleMouseWheel;
- #Java_sun_awt_motif_MTextAreaPeer_pMakeCursorVisible;
- #Java_sun_awt_motif_MTextAreaPeer_pSetEditable;
- #Java_sun_awt_motif_MTextAreaPeer_pShow2;
- #Java_sun_awt_motif_MTextAreaPeer_replaceRange;
- #Java_sun_awt_motif_MTextAreaPeer_select;
- #Java_sun_awt_motif_MTextAreaPeer_setCaretPosition;
- #Java_sun_awt_motif_MTextAreaPeer_setFont;
- #Java_sun_awt_motif_MTextAreaPeer_setText;
- #Java_sun_awt_motif_MTextAreaPeer_setTextBackground;
- #Java_sun_awt_motif_MTextFieldPeer_initIDs;
- #Java_sun_awt_motif_MTextFieldPeer_pCreate;
- #Java_sun_awt_motif_MTextFieldPeer_getCaretPosition;
- #Java_sun_awt_motif_MTextFieldPeer_getSelectionEnd;
- #Java_sun_awt_motif_MTextFieldPeer_getSelectionStart;
- #Java_sun_awt_motif_MTextFieldPeer_getText;
- #Java_sun_awt_motif_MTextFieldPeer_insertReplaceText;
- #Java_sun_awt_motif_MTextFieldPeer_preDispose;
- #Java_sun_awt_motif_MTextFieldPeer_pSetEditable;
- #Java_sun_awt_motif_MTextFieldPeer_select;
- #Java_sun_awt_motif_MTextFieldPeer_setCaretPosition;
- #Java_sun_awt_motif_MTextFieldPeer_setEchoChar;
- #Java_sun_awt_motif_MTextFieldPeer_setFont;
- #Java_sun_awt_motif_MTextFieldPeer_setText;
- Java_sun_awt_motif_MToolkit_beep;
- Java_sun_awt_motif_MToolkit_getLockingKeyStateNative;
- Java_sun_awt_motif_MToolkit_getMulticlickTime;
- Java_sun_awt_motif_MToolkit_getNumMouseButtons;
- Java_sun_awt_motif_MToolkit_loadXSettings;
- Java_sun_awt_motif_MToolkit_getScreenHeight;
- Java_sun_awt_motif_MToolkit_getScreenResolution;
- Java_sun_awt_motif_MToolkit_getScreenWidth;
- Java_sun_awt_motif_MToolkit_init;
- Java_sun_awt_motif_MToolkit_isDynamicLayoutSupportedNative;
- Java_sun_awt_motif_MToolkit_isFrameStateSupported;
- Java_sun_awt_motif_MToolkit_loadSystemColors;
- Java_sun_awt_motif_MToolkit_makeColorModel;
- Java_sun_awt_motif_MToolkit_run;
- Java_sun_awt_motif_MToolkit_isAlwaysOnTopSupported;
- Java_sun_awt_motif_MToolkit_getEventNumber;
- Java_sun_awt_motif_MToolkit_updateSyncSelection;
- Java_sun_awt_motif_MToolkit_isSyncUpdated;
- Java_sun_awt_motif_MToolkit_isSyncFailed;
- Java_sun_awt_motif_MToolkit_nativeUnGrab;
- Java_sun_awt_motif_MToolkit_nativeGrab;
- Java_sun_awt_motif_MToolkit_getWMName;
- Java_sun_awt_motif_MWindowAttributes_initIDs;
- #Java_sun_awt_motif_MWindowPeer_pDispose;
- #Java_sun_awt_motif_MWindowPeer_pHide;
- #Java_sun_awt_motif_MWindowPeer_pReshape;
- #Java_sun_awt_motif_MWindowPeer_pSetTitle;
- #Java_sun_awt_motif_MWindowPeer_pShow;
- #Java_sun_awt_motif_MWindowPeer_setResizable;
- #Java_sun_awt_motif_MWindowPeer_toBack;
- #Java_sun_awt_motif_MWindowPeer_addTextComponentNative;
- #Java_sun_awt_motif_MWindowPeer_getState;
- #Java_sun_awt_motif_MWindowPeer_pSetIMMOption;
- #Java_sun_awt_motif_MWindowPeer_pSetMenuBar;
- #Java_sun_awt_motif_MWindowPeer_pShowModal;
- #Java_sun_awt_motif_MWindowPeer_removeTextComponentNative;
- #Java_sun_awt_motif_MWindowPeer_setSaveUnder;
- #Java_sun_awt_motif_MWindowPeer_setState;
- #Java_sun_awt_motif_MWindowPeer_resetTargetGC;
- #Java_sun_awt_motif_MWindowPeer_registerX11DropTarget;
- #Java_sun_awt_motif_MWindowPeer_unregisterX11DropTarget;
- #Java_sun_awt_motif_MWindowPeer_updateAlwaysOnTop;
- #Java_sun_awt_motif_MWindowPeer_setFocusableWindow;
- #Java_sun_awt_motif_MWindowPeer_pToFront;
- #Java_sun_awt_motif_MCustomCursor_cacheInit;
- #Java_sun_awt_motif_MCustomCursor_createCursor;
- #Java_sun_awt_motif_MCustomCursor_queryBestCursor;
- Java_sun_awt_motif_X11FontMetrics_bytesWidth;
- Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth;
- Java_sun_awt_motif_X11FontMetrics_init;
Java_sun_awt_X11InputMethod_disposeXIC;
Java_sun_awt_X11InputMethod_isCompositionEnabledNative;
Java_sun_awt_X11InputMethod_resetXIC;
Java_sun_awt_X11InputMethod_setCompositionEnabledNative;
Java_sun_awt_X11InputMethod_turnoffStatusWindow;
- #Java_sun_awt_motif_MInputMethod_openXIMNative;
- #Java_sun_awt_motif_MInputMethod_configureStatusAreaNative;
- #Java_sun_awt_motif_MInputMethod_createXICNative;
- #Java_sun_awt_motif_MInputMethod_reconfigureXICNative;
- #Java_sun_awt_motif_MInputMethod_setXICFocusNative;
- #Java_sun_awt_motif_X11Clipboard_getClipboardData;
- #Java_sun_awt_motif_X11Clipboard_getClipboardFormats;
- #Java_sun_awt_motif_X11Clipboard_registerClipboardViewer;
- #Java_sun_awt_motif_X11Clipboard_unregisterClipboardViewer;
- #Java_sun_awt_motif_X11Selection_init;
- #Java_sun_awt_motif_X11Selection_pGetSelectionOwnership;
- #Java_sun_awt_motif_X11Selection_clearNativeContext;
Java_sun_awt_SunToolkit_closeSplashScreen;
Java_sun_awt_PlatformFont_initIDs;
Java_sun_awt_X11GraphicsConfig_init;
@@ -313,25 +93,6 @@
Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama;
Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint;
Java_sun_awt_X11GraphicsEnvironment_initXRender;
- #Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer;
- #Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer;
- #Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive;
- #Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching;
- #Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching;
- #Java_sun_awt_motif_MEmbedCanvasPeer_embedChild;
- #Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds;
- #Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded;
- #Java_sun_awt_motif_MEmbedCanvasPeer_detachChild;
- #Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym;
- #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I;
- #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getWindow;
- #Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers;
- #Java_sun_awt_motif_MEmbeddedFramePeer_traverseOut;
Java_java_awt_AWTEvent_initIDs;
Java_java_awt_Button_initIDs;
Java_java_awt_Container_initIDs;
@@ -345,41 +106,6 @@
Java_java_awt_Insets_initIDs;
Java_java_awt_TextField_initIDs;
Java_java_awt_Window_initIDs;
- #Java_sun_awt_motif_MCheckboxPeer_getIndicatorSize;
- #Java_sun_awt_motif_MCheckboxPeer_getSpacing;
- #Java_sun_awt_motif_MChoicePeer_freeNativeData;
- #Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
- #Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
- #Java_sun_awt_motif_MComponentPeer_initIDs;
- #Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
- #Java_sun_awt_motif_MComponentPeer_pSetCursor;
- #Java_sun_awt_motif_MComponentPeer_pSetInnerForeground;
- #Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground;
- #Java_sun_awt_motif_MComponentPeer_setTargetBackground;
- #Java_sun_awt_motif_MDataTransferer_dragQueryFile;
- #Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
- #Java_sun_awt_motif_MDataTransferer_getTargetNameForAtom;
- #Java_sun_awt_motif_MFileDialogPeer_insertReplaceFileDialogText;
- Java_sun_awt_motif_MFontPeer_initIDs;
- #Java_sun_awt_motif_MListPeer_setBackground;
- #Java_sun_awt_motif_MMenuBarPeer_initIDs;
- #Java_sun_awt_motif_MMenuBarPeer_pDispose;
- #Java_sun_awt_motif_MMenuItemPeer_getParent_1NoClientCode;
- #Java_sun_awt_motif_MMenuItemPeer_initIDs;
- #Java_sun_awt_motif_MMenuItemPeer_pSetShortcut;
- #Java_sun_awt_motif_MPopupMenuPeer_initIDs;
- #Java_sun_awt_motif_MScrollbarPeer_initIDs;
- #Java_sun_awt_motif_MScrollPanePeer_initIDs;
- #Java_sun_awt_motif_MTextAreaPeer_pSetCursor;
- Java_sun_awt_motif_MToolkit_shutdown;
- #Java_sun_awt_motif_MWindowPeer_initIDs;
- #Java_sun_awt_motif_MWindowPeer_pCreate;
- #Java_sun_awt_motif_MWindowPeer_wrapInSequenced;
- Java_sun_awt_motif_X11FontMetrics_initIDs;
- #Java_sun_awt_X11InputMethod_initIDs;
- #Java_sun_awt_motif_X11Selection_initIDs;
- Java_sun_awt_motif_MToolkitThreadBlockedHandler_enter;
- Java_sun_awt_motif_MToolkitThreadBlockedHandler_exit;
Java_sun_awt_X11GraphicsConfig_init;
Java_sun_awt_X11GraphicsConfig_initIDs;
Java_sun_awt_X11GraphicsConfig_makeColorModel;
--- a/jdk/make/sun/awt/mapfile-vers-linux Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/make/sun/awt/mapfile-vers-linux Thu Dec 15 19:52:13 2011 -0800
@@ -170,7 +170,6 @@
GrPrim_Sg2dGetPixel;
GrPrim_Sg2dGetLCDTextContrast;
- #Java_sun_awt_motif_MComponentPeer_restoreFocus;
Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords;
Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse;
Java_java_awt_AWTEvent_nativeSetSource;
@@ -189,216 +188,11 @@
Java_java_awt_ScrollPane_initIDs;
Java_java_awt_TextArea_initIDs;
Java_sun_awt_FontDescriptor_initIDs;
- #Java_sun_awt_motif_MButtonPeer_create;
- #Java_sun_awt_motif_MButtonPeer_setLabel;
- #Java_sun_awt_motif_MCanvasPeer_create;
- #Java_sun_awt_motif_MCanvasPeer_initIDs;
- #Java_sun_awt_motif_MCanvasPeer_resetTargetGC;
- #Java_sun_awt_motif_MCheckboxMenuItemPeer_pSetState;
- #Java_sun_awt_motif_MCheckboxPeer_create;
- #Java_sun_awt_motif_MCheckboxPeer_setCheckboxGroup;
- #Java_sun_awt_motif_MCheckboxPeer_setLabel;
- #Java_sun_awt_motif_MCheckboxPeer_pSetState;
- #Java_sun_awt_motif_MCheckboxPeer_pGetState;
- #Java_sun_awt_motif_MChoicePeer_addItem;
- #Java_sun_awt_motif_MChoicePeer_appendItems;
- #Java_sun_awt_motif_MChoicePeer_create;
- #Java_sun_awt_motif_MChoicePeer_pReshape;
- #Java_sun_awt_motif_MChoicePeer_remove;
- #Java_sun_awt_motif_MChoicePeer_removeAll;
- #Java_sun_awt_motif_MChoicePeer_setBackground;
- #Java_sun_awt_motif_MChoicePeer_pSelect;
- #Java_sun_awt_motif_MChoicePeer_setFont;
- #Java_sun_awt_motif_MChoicePeer_setForeground;
- #Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
- #Java_sun_awt_motif_MComponentPeer_createBackBuffer;
- #Java_sun_awt_motif_MComponentPeer_destroyBackBuffer;
- #Java_sun_awt_motif_MComponentPeer_getNativeColor;
- #Java_sun_awt_motif_MComponentPeer_getWindow;
- #Java_sun_awt_motif_MComponentPeer_pDisable;
- #Java_sun_awt_motif_MComponentPeer_pDispose;
- #Java_sun_awt_motif_MComponentPeer_pEnable;
- #Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen;
- #Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2;
- #Java_sun_awt_motif_MComponentPeer_pHide;
- #Java_sun_awt_motif_MComponentPeer_pInitialize;
- #Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible;
- #Java_sun_awt_motif_MComponentPeer_pReshape;
- #Java_sun_awt_motif_MComponentPeer_pShow;
- #Java_sun_awt_motif_MComponentPeer_removeNativeDropTarget;
- #Java_sun_awt_motif_MComponentPeer_swapBuffers;
- #Java_sun_awt_motif_MComponentPeer_pSetBackground;
- #Java_sun_awt_motif_MComponentPeer_pSetFont;
- #Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer;
- #Java_sun_awt_motif_MComponentPeer__1requestFocus;
- #Java_sun_awt_motif_MCheckboxMenuItemPeer_getState;
- #Java_sun_awt_motif_MComponentPeer_pSetForeground;
- #Java_sun_awt_motif_MDragSourceContextPeer_startDrag;
- #Java_sun_awt_motif_MDragSourceContextPeer_setNativeCursor;
- #Java_sun_awt_motif_MDropTargetContextPeer_addTransfer;
- #Java_sun_awt_motif_MDropTargetContextPeer_dropDone;
- #Java_sun_awt_motif_MDropTargetContextPeer_startTransfer;
- #Java_sun_awt_motif_X11DragSourceContextPeer_startDrag;
- #Java_sun_awt_motif_X11DragSourceContextPeer_setNativeCursor;
- #Java_sun_awt_motif_X11DropTargetContextPeer_sendResponse;
- #Java_sun_awt_motif_X11DropTargetContextPeer_dropDone;
- #Java_sun_awt_motif_X11DropTargetContextPeer_getData;
- #Java_sun_awt_motif_MEmbeddedFramePeer_NEFcreate;
- #Java_sun_awt_motif_MEmbeddedFramePeer_pShowImpl;
- #Java_sun_awt_motif_MEmbeddedFramePeer_pReshapePrivate;
- #Java_sun_awt_motif_MEmbeddedFramePeer_getBoundsPrivate;
- #Java_sun_awt_motif_MFramePeer_pSetIconImage___3B_3I_3SII;
- #Java_sun_awt_motif_MEmbeddedFramePeer_requestXEmbedFocus;
- #Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedApplicationActive;
- #Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedActive;
- #Java_sun_awt_motif_MEmbeddedFrame_getWidget;
- #Java_sun_awt_motif_MEmbeddedFrame_mapWidget;
- #Java_sun_awt_motif_MFileDialogPeer_create;
- #Java_sun_awt_motif_MFileDialogPeer_pDispose;
- #Java_sun_awt_motif_MFileDialogPeer_pHide;
- #Java_sun_awt_motif_MFileDialogPeer_pReshape;
- #Java_sun_awt_motif_MFileDialogPeer_pShow;
- #Java_sun_awt_motif_MFileDialogPeer_setFileEntry;
- #Java_sun_awt_motif_MFileDialogPeer_setFont;
- #Java_sun_awt_motif_MFramePeer_pGetIconSize;
- #Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
- #Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
- #Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
- #Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
- #Java_sun_awt_motif_MGlobalCursorManager_getLocationOnScreen;
- #Java_sun_awt_motif_MLabelPeer_create;
- #Java_sun_awt_motif_MLabelPeer_setAlignment;
- #Java_sun_awt_motif_MLabelPeer_setText;
- #Java_sun_awt_motif_MListPeer_addItem;
- #Java_sun_awt_motif_MListPeer_create;
- #Java_sun_awt_motif_MListPeer_delItems;
- #Java_sun_awt_motif_MListPeer_deselect;
- #Java_sun_awt_motif_MListPeer_isSelected;
- #Java_sun_awt_motif_MListPeer_makeVisible;
- #Java_sun_awt_motif_MListPeer_select;
- #Java_sun_awt_motif_MListPeer_setMultipleSelections;
- #Java_sun_awt_motif_MMenuBarPeer_create;
- #Java_sun_awt_motif_MMenuItemPeer_createMenuItem;
- #Java_sun_awt_motif_MMenuItemPeer_pDisable;
- #Java_sun_awt_motif_MMenuItemPeer_pDispose;
- #Java_sun_awt_motif_MMenuItemPeer_pEnable;
- #Java_sun_awt_motif_MMenuItemPeer_pSetLabel;
- #Java_sun_awt_motif_MMenuPeer_createMenu;
- #Java_sun_awt_motif_MMenuPeer_createSubMenu;
- #Java_sun_awt_motif_MMenuPeer_pDispose;
- #Java_sun_awt_motif_MPopupMenuPeer_createMenu;
- #Java_sun_awt_motif_MPopupMenuPeer_pDispose;
- #Java_sun_awt_motif_MPopupMenuPeer_pShow;
- #Java_sun_awt_motif_MRobotPeer_getRGBPixelsImpl;
- #Java_sun_awt_motif_MRobotPeer_keyPressImpl;
- #Java_sun_awt_motif_MRobotPeer_keyReleaseImpl;
- #Java_sun_awt_motif_MRobotPeer_mouseMoveImpl;
- #Java_sun_awt_motif_MRobotPeer_mousePressImpl;
- #Java_sun_awt_motif_MRobotPeer_mouseReleaseImpl;
- #Java_sun_awt_motif_MRobotPeer_mouseWheelImpl;
- #Java_sun_awt_motif_MRobotPeer_setup;
- #Java_sun_awt_motif_MScrollbarPeer_create;
- #Java_sun_awt_motif_MScrollbarPeer_setLineIncrement;
- #Java_sun_awt_motif_MScrollbarPeer_setPageIncrement;
- #Java_sun_awt_motif_MScrollbarPeer_pSetValues;
- #Java_sun_awt_motif_MScrollPanePeer_create;
- #Java_sun_awt_motif_MScrollPanePeer_pGetBlockIncrement;
- #Java_sun_awt_motif_MScrollPanePeer_pGetScrollbarSpace;
- #Java_sun_awt_motif_MScrollPanePeer_pGetShadow;
- #Java_sun_awt_motif_MScrollPanePeer_pInsets;
- #Java_sun_awt_motif_MScrollPanePeer_pSetIncrement;
- #Java_sun_awt_motif_MScrollPanePeer_pSetScrollChild;
- #Java_sun_awt_motif_MScrollPanePeer_setScrollPosition;
- #Java_sun_awt_motif_MTextAreaPeer_initIDs;
- #Java_sun_awt_motif_MTextAreaPeer_pCreate;
- #Java_sun_awt_motif_MTextAreaPeer_getCaretPosition;
- #Java_sun_awt_motif_MTextAreaPeer_getExtraHeight;
- #Java_sun_awt_motif_MTextAreaPeer_getExtraWidth;
- #Java_sun_awt_motif_MTextAreaPeer_getSelectionEnd;
- #Java_sun_awt_motif_MTextAreaPeer_getSelectionStart;
- #Java_sun_awt_motif_MTextAreaPeer_getText;
- #Java_sun_awt_motif_MTextAreaPeer_insert;
- #Java_sun_awt_motif_MTextAreaPeer_pMakeCursorVisible;
- #Java_sun_awt_motif_MTextAreaPeer_pSetEditable;
- #Java_sun_awt_motif_MTextAreaPeer_pShow2;
- #Java_sun_awt_motif_MTextAreaPeer_replaceRange;
- #Java_sun_awt_motif_MTextAreaPeer_select;
- #Java_sun_awt_motif_MTextAreaPeer_setCaretPosition;
- #Java_sun_awt_motif_MTextAreaPeer_setFont;
- #Java_sun_awt_motif_MTextAreaPeer_setText;
- #Java_sun_awt_motif_MTextAreaPeer_setTextBackground;
- #Java_sun_awt_motif_MTextFieldPeer_initIDs;
- #Java_sun_awt_motif_MTextFieldPeer_pCreate;
- #Java_sun_awt_motif_MTextFieldPeer_getCaretPosition;
- #Java_sun_awt_motif_MTextFieldPeer_getSelectionEnd;
- #Java_sun_awt_motif_MTextFieldPeer_getSelectionStart;
- #Java_sun_awt_motif_MTextFieldPeer_getText;
- #Java_sun_awt_motif_MTextFieldPeer_insertReplaceText;
- #Java_sun_awt_motif_MTextFieldPeer_preDispose;
- #Java_sun_awt_motif_MTextFieldPeer_pSetEditable;
- #Java_sun_awt_motif_MTextFieldPeer_select;
- #Java_sun_awt_motif_MTextFieldPeer_setCaretPosition;
- #Java_sun_awt_motif_MTextFieldPeer_setEchoChar;
- #Java_sun_awt_motif_MTextFieldPeer_setFont;
- #Java_sun_awt_motif_MTextFieldPeer_setText;
- Java_sun_awt_motif_MToolkit_beep;
- Java_sun_awt_motif_MToolkit_getLockingKeyStateNative;
- Java_sun_awt_motif_MToolkit_getMulticlickTime;
- Java_sun_awt_motif_MToolkit_getNumMouseButtons;
- Java_sun_awt_motif_MToolkit_getScreenHeight;
- Java_sun_awt_motif_MToolkit_getScreenResolution;
- Java_sun_awt_motif_MToolkit_getScreenWidth;
- Java_sun_awt_motif_MToolkit_init;
- Java_sun_awt_motif_MToolkit_isDynamicLayoutSupportedNative;
- Java_sun_awt_motif_MToolkit_isFrameStateSupported;
- Java_sun_awt_motif_MToolkit_loadSystemColors;
- Java_sun_awt_motif_MToolkit_makeColorModel;
- Java_sun_awt_motif_MToolkit_run;
- Java_sun_awt_motif_MToolkit_sync;
- Java_sun_awt_motif_MToolkit_isAlwaysOnTopSupported;
- Java_sun_awt_motif_MWindowAttributes_initIDs;
- #Java_sun_awt_motif_MWindowPeer_pDispose;
- #Java_sun_awt_motif_MWindowPeer_pHide;
- #Java_sun_awt_motif_MWindowPeer_pReshape;
- #Java_sun_awt_motif_MWindowPeer_pSetTitle;
- #Java_sun_awt_motif_MWindowPeer_pShow;
- #Java_sun_awt_motif_MWindowPeer_setResizable;
- #Java_sun_awt_motif_MWindowPeer_toBack;
- #Java_sun_awt_motif_MWindowPeer_addTextComponentNative;
- #Java_sun_awt_motif_MWindowPeer_getState;
- #Java_sun_awt_motif_MWindowPeer_pSetIMMOption;
- #Java_sun_awt_motif_MWindowPeer_pSetMenuBar;
- #Java_sun_awt_motif_MWindowPeer_pShowModal;
- #Java_sun_awt_motif_MWindowPeer_removeTextComponentNative;
- #Java_sun_awt_motif_MWindowPeer_setSaveUnder;
- #Java_sun_awt_motif_MWindowPeer_setState;
- #Java_sun_awt_motif_MWindowPeer_resetTargetGC;
- #Java_sun_awt_motif_MWindowPeer_registerX11DropTarget;
- #Java_sun_awt_motif_MWindowPeer_unregisterX11DropTarget;
- #Java_sun_awt_motif_MWindowPeer_updateAlwaysOnTop;
- #Java_sun_awt_motif_X11CustomCursor_cacheInit;
- #Java_sun_awt_motif_X11CustomCursor_createCursor;
- #Java_sun_awt_motif_X11CustomCursor_queryBestCursor;
- Java_sun_awt_motif_X11FontMetrics_bytesWidth;
- Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth;
- Java_sun_awt_motif_X11FontMetrics_init;
Java_sun_awt_X11InputMethod_disposeXIC;
Java_sun_awt_X11InputMethod_isCompositionEnabledNative;
Java_sun_awt_X11InputMethod_resetXIC;
Java_sun_awt_X11InputMethod_setCompositionEnabledNative;
Java_sun_awt_X11InputMethod_turnoffStatusWindow;
- #Java_sun_awt_motif_MInputMethod_openXIMNative;
- #Java_sun_awt_motif_MInputMethod_configureStatusAreaNative;
- #Java_sun_awt_motif_MInputMethod_createXICNative;
- #Java_sun_awt_motif_MInputMethod_reconfigureXICNative;
- #Java_sun_awt_motif_MInputMethod_setXICFocusNative;
- #Java_sun_awt_motif_X11Clipboard_getClipboardData;
- #Java_sun_awt_motif_X11Clipboard_getClipboardFormats;
- #Java_sun_awt_motif_X11Clipboard_registerClipboardViewer;
- #Java_sun_awt_motif_X11Clipboard_unregisterClipboardViewer;
- #Java_sun_awt_motif_X11Selection_init;
- #Java_sun_awt_motif_X11Selection_pGetSelectionOwnership;
- #Java_sun_awt_motif_X11Selection_clearNativeContext;
Java_sun_awt_SunToolkit_closeSplashScreen;
Java_sun_awt_PlatformFont_initIDs;
Java_sun_awt_X11GraphicsConfig_init;
@@ -444,42 +238,7 @@
Java_java_awt_Insets_initIDs;
Java_java_awt_TextField_initIDs;
Java_java_awt_Window_initIDs;
- #Java_sun_awt_motif_MCheckboxPeer_getIndicatorSize;
- #Java_sun_awt_motif_MCheckboxPeer_getSpacing;
- #Java_sun_awt_motif_MChoicePeer_freeNativeData;
- #Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
- #Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
- #Java_sun_awt_motif_MComponentPeer_initIDs;
- #Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
- #Java_sun_awt_motif_MComponentPeer_pSetCursor;
- #Java_sun_awt_motif_MComponentPeer_pSetInnerForeground;
- #Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground;
- #Java_sun_awt_motif_MComponentPeer_setTargetBackground;
- #Java_sun_awt_motif_MDataTransferer_dragQueryFile;
- #Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
- #Java_sun_awt_motif_MDataTransferer_getTargetNameForAtom;
- #Java_sun_awt_motif_MFileDialogPeer_insertReplaceFileDialogText;
- Java_sun_awt_motif_MFontPeer_initIDs;
- #Java_sun_awt_motif_MListPeer_setBackground;
- #Java_sun_awt_motif_MMenuBarPeer_initIDs;
- #Java_sun_awt_motif_MMenuBarPeer_pDispose;
- #Java_sun_awt_motif_MMenuItemPeer_getParent_1NoClientCode;
- #Java_sun_awt_motif_MMenuItemPeer_initIDs;
- #Java_sun_awt_motif_MMenuItemPeer_pSetShortcut;
- #Java_sun_awt_motif_MPopupMenuPeer_initIDs;
- #Java_sun_awt_motif_MScrollbarPeer_initIDs;
- #Java_sun_awt_motif_MScrollPanePeer_initIDs;
- #Java_sun_awt_motif_MTextAreaPeer_pSetCursor;
- Java_sun_awt_motif_MToolkit_shutdown;
- #Java_sun_awt_motif_MWindowPeer_initIDs;
- #Java_sun_awt_motif_MWindowPeer_pCreate;
- #Java_sun_awt_motif_MWindowPeer_wrapInSequenced;
- Java_sun_awt_motif_X11FontMetrics_initIDs;
- #Java_sun_awt_X11InputMethod_initIDs;
Java_sun_awt_motif_X11OffScreenImage_updateBitmask;
- #Java_sun_awt_motif_X11Selection_initIDs;
- Java_sun_awt_motif_MToolkitThreadBlockedHandler_enter;
- Java_sun_awt_motif_MToolkitThreadBlockedHandler_exit;
Java_sun_awt_X11GraphicsConfig_init;
Java_sun_awt_X11GraphicsConfig_initIDs;
Java_sun_awt_X11GraphicsConfig_makeColorModel;
@@ -505,26 +264,6 @@
Java_sun_awt_X11SurfaceData_isDgaAvailable;
Java_sun_awt_X11SurfaceData_setInvalid;
Java_sun_awt_X11SurfaceData_flushNativeSurface;
- #Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer;
- #Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer;
- #Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive;
- #Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching;
- #Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching;
- #Java_sun_awt_motif_MEmbedCanvasPeer_embedChild;
- #Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds;
- #Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded;
- #Java_sun_awt_motif_MEmbedCanvasPeer_detachChild;
- #Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym;
- #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I;
- #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ;
- #Java_sun_awt_motif_MEmbedCanvasPeer_getWindow;
- #Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded;
- #Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers;
- #Java_sun_awt_motif_MEmbeddedFramePeer_traverseOut;
awt_display;
awt_lock;
awt_Lock;
--- a/jdk/make/sun/awt/mawt.gmk Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/make/sun/awt/mawt.gmk Thu Dec 15 19:52:13 2011 -0800
@@ -41,13 +41,7 @@
# Check which C files should be built. Headless uses only
# non-motif files. Also, a version-specific motif file is
# compiled based on the motif version.
-ifdef HEADLESS
- FILES_c = $(FILES_NO_MOTIF_c)
-else
-# FILES_c = $(FILES_MOTIF_c) $(FILES_NO_MOTIF_c)
-# XXX if in FILES_MOTIF_c there are unrelated to motif stuff, create a separate list!
- FILES_c = $(FILES_NO_MOTIF_c)
-endif
+FILES_c = $(FILES_NO_MOTIF_c)
ifeq ($(PLATFORM), solaris)
ifneq ($(ARCH), amd64)
@@ -116,32 +110,6 @@
CPPFLAGS += -DHEADLESS=$(HEADLESS)
OTHER_LDLIBS =
else
-#CFLAGS += -DMOTIF_VERSION=$(MOTIF_VERSION)
-
-#ifeq ($(STATIC_MOTIF),true)
-# LIBXM = $(MOTIF_LIB)/libXm.a -lXp -lXmu
-# ifeq ($(PLATFORM), linux)
-# ifeq ($(ARCH_DATA_MODEL), 64)
-# LIBXT = -lXt
-# else
-# # Allows for builds on Debian GNU Linux, X11 is in a different place
-# LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \
-# $(wildcard /usr/lib/libXt.a))
-# LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
-# $(wildcard /usr/lib/libSM.a))
-# LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \
-# $(wildcard /usr/lib/libICE.a))
-# endif
-# endif
-#else
-# LIBXM = -L$(MOTIF_LIB) -lXm -lXp
-# ifeq ($(PLATFORM), linux)
-# LIBXT = -lXt
-# LIBSM =
-# LIBICE =
-# endif
-#endif
-
LIBXTST = -lXtst
ifeq ($(PLATFORM), linux)
ifeq ($(ARCH_DATA_MODEL), 64)
--- a/jdk/make/sun/motif12/reorder-i586 Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-data = R0x2000;
-text = LOAD ?RXO;
-# Test Null
-# Test Exit
-# Test Hello
-# Test Sleep
-# Test IntToString
-# Test LoadToolkit
-text: .text%JNI_OnLoad;
-text: .text%awt_util_debug_init;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_initDisplay;
-text: .text%awt_init_Display;
-text: .text%makeDefaultConfig: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%awt_allocate_colors;
-text: .text%alloc_col: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11Color.o;
-text: .text%getVirtCubeSize;
-text: .text%uname: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11Color.o;
-text: .text%Java_sun_awt_font_NativeFontWrapper_getFontPath;
-text: .text%getPlatformFontPathChars: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%getSolarisFontLocations: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%fstat: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%AppendFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%freePlatformFontPathChars: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%checkFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_Font.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNativeFonts;
-text: .text%Java_sun_awt_font_NativeFontWrapper_setNativeFontPath;
-text: .text%isDisplayLocal;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_checkShmExt;
-text: .text%TryInitMITShm: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%awt_output_flush;
-text: .text%awtJNI_TimeMillis: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%AddFontsToX11FontPath: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNumScreens;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum;
-text: .text%Java_sun_awt_X11GraphicsDevice_getConfigVisualId;
-text: .text%Java_sun_awt_X11GraphicsDevice_isDBESupported;
-text: .text%Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals;
-text: .text%Java_sun_awt_X11GraphicsConfig_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_init;
-text: .text%getAllConfigs: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%Java_sun_awt_motif_MToolkit_init;
-text: .text%getDefaultConfig;
-text: .text%getScreenData;
-text: .text%Java_sun_awt_PlatformFont_initIDs;
-text: .text%Java_sun_awt_motif_MFontPeer_initIDs;
-text: .text%awt_wm_init;
-text: .text%awt_wm_initAtoms: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_getRunningWM;
-text: .text%xerror_detect_wm: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_prepareIsIceWM: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isNetSupporting: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_checkAnchor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_getProperty32: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isWinSupporting: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isIceWM: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isEnlightenment: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_getECommsWindowIDProperty: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isSawfish: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isNetWMName: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isKDE2: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isCDE: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_color_match;
-text: .text%setup_modifier_map: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%set_mod_mask: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_initialize_DataTransferer;
-text: .text%awt_initialize_Xm_DnD;
-text: .text%cacheDropDone: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_XmDnD.o;
-text: .text%awt_motif_enableSingleDragInitiator;
-text: .text%Java_java_awt_Cursor_initIDs;
-text: .text%Java_sun_awt_motif_X11CustomCursor_cacheInit;
-text: .text%Java_sun_awt_motif_MToolkit_run;
-text: .text%awtJNI_GetCurrentThread;
-text: .text%awt_MToolkit_loop: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_pipe_init: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_set_poll_timeout: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_events_pending: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%processOneEvent: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%set_toolkit_busy;
-text: .text%waitForEvents;
-text: .text%performPoll: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_get_poll_timeout: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awtJNI_CleanupGlobalRefs;
-text: .text%Java_java_awt_AWTEvent_initIDs;
-text: .text%Java_sun_awt_SunToolkit_wakeupEventQueue;
-text: .text%Java_sun_awt_motif_MToolkit_shutdown;
-text: .text%X11SD_LibDispose;
-text: .text%LibDisposeStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-# Test LoadFrame
-text: .text%Java_java_awt_Component_initIDs;
-text: .text%Java_java_awt_Container_initIDs;
-text: .text%Java_java_awt_Window_initIDs;
-text: .text%Java_java_awt_Frame_initIDs;
-text: .text%Java_sun_awt_SunToolkit_getPrivateKey;
-text: .text%Java_java_awt_MenuComponent_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_pGetBounds;
-text: .text%Java_java_awt_Insets_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowAttributes_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_pCreate;
-text: .text%awtJNI_CreateAndSetGlobalRef;
-text: .text%copyGraphicsConfigToPeer;
-text: .text%awt_Frame_guessInsets;
-text: .text%awtJNI_ChangeInsets: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%getMotifFontList;
-text: .text%getMotifFontStruct;
-text: .text%setDeleteCallback: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_canvas_create;
-text: .text%awt_util_show;
-text: .text%addTopLevel;
-text: .text%Java_sun_awt_motif_MWindowPeer_pHide;
-text: .text%Java_sun_awt_motif_MComponentPeer_pInitialize;
-text: .text%awt_addWidget;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetCursor;
-text: .text%getCursor;
-text: .text%awt_util_setCursor;
-text: .text%Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
-text: .text%Java_sun_awt_motif_MWindowPeer_pReshape;
-text: .text%reshape: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awtJNI_setMbAndWwHeightAndOffsets: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_configureGravityBuggy;
-text: .text%Java_sun_awt_X11SurfaceData_initIDs;
-text: .text%Java_sun_awt_motif_MToolkit_loadSystemColors;
-text: .text%colorToRGB: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_allocate_systemcolors;
-text: .text%Java_sun_awt_X11GraphicsConfig_makeColorModel;
-text: .text%awtJNI_GetColorModel;
-text: .text%Java_sun_awt_X11SurfaceData_initOps;
-text: .text%Java_sun_awt_motif_MWindowPeer_pSetTitle;
-text: .text%Java_sun_awt_motif_MWindowPeer_setResizable;
-text: .text%Java_java_awt_Font_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetFont;
-text: .text%awt_util_mapChildren;
-text: .text%changeFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_Component.o;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetBackground;
-text: .text%getGraphicsConfigFromComponentPeer;
-text: .text%awtJNI_GetColorForVis;
-text: .text%ColorProc;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetForeground;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShow;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShowModal;
-text: .text%awt_wm_setExtendedState;
-text: .text%awt_wm_doStateProtocolNet: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_doStateProtocolWin: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_setShellDecor;
-text: .text%awt_wm_setMotifDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_setOLDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_normalizeMotifDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_removeSizeHints;
-text: .text%shellEH: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_isStateChange;
-text: .text%awt_wm_getWMState;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
-text: .text%innerCanvasEH: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%reconfigureOuterCanvas: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%outerCanvasResizeCB: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
-text: .text%awt_wm_getInsetsFromProp;
-text: .text%syncTopLevelPos;
-text: .text%raiseInputMethodWindow;
-text: .text%awt_wm_getExtendedState: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_canvas_event_handler;
-text: .text%awt_canvas_handleEvent;
-text: .text%HandleExposeEvent: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%checkForExpose: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%expandDamageRect: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%getCurComponent;
-text: .text%Java_java_awt_KeyboardFocusManager_initIDs;
-text: .text%Java_java_awt_event_InputEvent_initIDs;
-text: .text%Java_java_awt_event_KeyEvent_initIDs;
-text: .text%Java_java_awt_AWTKeyStroke_allocateNewInstance;
-text: .text%Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
-text: .text%Java_java_awt_Event_initIDs;
-# Test LoadJFrame
-text: .text%Java_sun_awt_motif_MToolkit_getScreenWidth;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenHeight;
-text: .text%X11SD_Lock: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_InitWindow: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%GetLockStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_GetRasInfo: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_Unlock: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_InitClip: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%XRequestSentStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-# Test JHello
-text: .text%AWTLoadFont;
-text: .text%AWTFontMaxByte1;
-text: .text%AWTFontMaxCharOrByte2;
-text: .text%AWTFontMaxBounds;
-text: .text%AWTCharAscent;
-text: .text%AWTCharDescent;
-text: .text%AWTCharWidth;
-text: .text%AWTFontMinByte1;
-text: .text%AWTFontMinCharOrByte2;
-text: .text%AWTFontPerChar;
-text: .text%AWTCharRBearing;
-text: .text%AWTCharLBearing;
-text: .text%Java_sun_awt_X11SurfaceData_setInvalid;
-text: .text%Java_sun_awt_X11SurfaceData_nativeDispose;
-text: .text%X11SurfaceData_GetOps;
-# SwingSet
-text: .text%Java_sun_awt_motif_MWindowPeer_setSaveUnder;
-text: .text%Java_sun_awt_motif_MCanvasPeer_create;
-text: .text%awt_util_insertCallback;
-text: .text%Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
-text: .text%Java_sun_awt_motif_MComponentPeer_pReshape;
-text: .text%awt_util_reshape;
-text: .text%Java_sun_awt_motif_MComponentPeer_pShow;
-text: .text%Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
-text: .text%Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
-text: .text%register_drop_site;
-text: .text%update_drop_site_hierarchy: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_XmDnD.o;
-text: .text%AWTFontDefaultChar;
-text: .text%AWTFontGenerateImage;
-text: .text%CreatePixmapAndGC;
-text: .text%isAncestor;
-text: .text%xerror_handler;
--- a/jdk/make/sun/motif12/reorder-sparc Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-data = R0x2000;
-text = LOAD ?RXO;
-# Test Null
-# Test Exit
-# Test Hello
-# Test Sleep
-# Test IntToString
-# Test LoadToolkit
-text: .text%JNI_OnLoad;
-text: .text%awt_util_debug_init;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_initDisplay;
-text: .text%awt_init_Display;
-text: .text%makeDefaultConfig: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%awt_allocate_colors;
-text: .text%Java_sun_awt_font_NativeFontWrapper_getFontPath;
-text: .text%getPlatformFontPathChars: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%getSolarisFontLocations: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%AppendFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%freePlatformFontPathChars: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%checkFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_Font.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNativeFonts;
-text: .text%Java_sun_awt_font_NativeFontWrapper_setNativeFontPath;
-text: .text%isDisplayLocal;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_checkShmExt;
-text: .text%TryInitMITShm: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%awt_output_flush;
-text: .text%awtJNI_TimeMillis: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%AddFontsToX11FontPath: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNumScreens;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum;
-text: .text%Java_sun_awt_X11GraphicsDevice_getConfigVisualId;
-text: .text%Java_sun_awt_X11GraphicsDevice_isDBESupported;
-text: .text%Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals;
-text: .text%Java_sun_awt_X11GraphicsConfig_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_init;
-text: .text%getAllConfigs: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%Java_sun_awt_motif_MToolkit_init;
-text: .text%getDefaultConfig;
-text: .text%getScreenData;
-text: .text%Java_sun_awt_PlatformFont_initIDs;
-text: .text%Java_sun_awt_motif_MFontPeer_initIDs;
-text: .text%awt_wm_init;
-text: .text%awt_wm_initAtoms: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_getRunningWM;
-text: .text%xerror_detect_wm: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_prepareIsIceWM: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isNetSupporting: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_checkAnchor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_getProperty32: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isWinSupporting: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isIceWM: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isEnlightenment: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_getECommsWindowIDProperty: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isSawfish: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isNetWMName: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isKDE2: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isCDE: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_color_matchTC;
-text: .text%setup_modifier_map: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%set_mod_mask: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_initialize_DataTransferer;
-text: .text%awt_initialize_Xm_DnD;
-text: .text%cacheDropDone: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_XmDnD.o;
-text: .text%awt_motif_enableSingleDragInitiator;
-text: .text%Java_java_awt_Cursor_initIDs;
-text: .text%Java_sun_awt_motif_X11CustomCursor_cacheInit;
-text: .text%Java_sun_awt_motif_MToolkit_run;
-text: .text%awtJNI_GetCurrentThread;
-text: .text%awt_MToolkit_loop: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_pipe_init: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_set_poll_timeout: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_events_pending: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%processOneEvent: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%set_toolkit_busy;
-text: .text%waitForEvents;
-text: .text%performPoll: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_get_poll_timeout: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awtJNI_CleanupGlobalRefs;
-text: .text%Java_java_awt_AWTEvent_initIDs;
-text: .text%Java_sun_awt_SunToolkit_wakeupEventQueue;
-text: .text%Java_sun_awt_motif_MToolkit_shutdown;
-text: .text%X11SD_LibDispose;
-text: .text%LibDisposeStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-# Test LoadFrame
-text: .text%Java_java_awt_Component_initIDs;
-text: .text%Java_java_awt_Container_initIDs;
-text: .text%Java_java_awt_Window_initIDs;
-text: .text%Java_java_awt_Frame_initIDs;
-text: .text%Java_sun_awt_SunToolkit_getPrivateKey;
-text: .text%Java_java_awt_MenuComponent_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_pGetBounds;
-text: .text%Java_java_awt_Insets_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowAttributes_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_pCreate;
-text: .text%awtJNI_CreateAndSetGlobalRef;
-text: .text%copyGraphicsConfigToPeer;
-text: .text%awt_Frame_guessInsets;
-text: .text%awtJNI_ChangeInsets: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%getMotifFontList;
-text: .text%getMotifFontStruct;
-text: .text%setDeleteCallback: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%ColorProc;
-text: .text%awt_canvas_create;
-text: .text%awt_util_show;
-text: .text%addTopLevel;
-text: .text%Java_sun_awt_motif_MWindowPeer_pHide;
-text: .text%Java_sun_awt_motif_MComponentPeer_pInitialize;
-text: .text%awt_addWidget;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetCursor;
-text: .text%getCursor;
-text: .text%awt_util_setCursor;
-text: .text%Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
-text: .text%Java_sun_awt_motif_MWindowPeer_pReshape;
-text: .text%reshape: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awtJNI_setMbAndWwHeightAndOffsets: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_configureGravityBuggy;
-text: .text%Java_sun_awt_X11SurfaceData_initIDs;
-text: .text%Java_sun_awt_motif_MToolkit_loadSystemColors;
-text: .text%colorToRGB: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%Java_sun_awt_X11GraphicsConfig_makeColorModel;
-text: .text%awtJNI_GetColorModel;
-text: .text%Java_sun_awt_X11SurfaceData_initOps;
-text: .text%Java_sun_awt_motif_MWindowPeer_pSetTitle;
-text: .text%Java_sun_awt_motif_MWindowPeer_setResizable;
-text: .text%Java_java_awt_Font_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetFont;
-text: .text%awt_util_mapChildren;
-text: .text%changeFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_Component.o;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetBackground;
-text: .text%getGraphicsConfigFromComponentPeer;
-text: .text%awtJNI_GetColorForVis;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetForeground;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShow;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShowModal;
-text: .text%awt_wm_setExtendedState;
-text: .text%awt_wm_doStateProtocolNet: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_doStateProtocolWin: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_setShellDecor;
-text: .text%awt_wm_setMotifDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_setOLDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_normalizeMotifDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_removeSizeHints;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
-text: .text%getCurComponent;
-text: .text%shellEH: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_isStateChange;
-text: .text%awt_wm_getWMState;
-text: .text%innerCanvasEH: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%reconfigureOuterCanvas: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%outerCanvasResizeCB: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_getInsetsFromProp;
-text: .text%syncTopLevelPos;
-text: .text%raiseInputMethodWindow;
-text: .text%awt_canvas_event_handler;
-text: .text%awt_canvas_handleEvent;
-text: .text%HandleExposeEvent: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%checkForExpose: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%awt_wm_getExtendedState: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%expandDamageRect: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%Java_java_awt_KeyboardFocusManager_initIDs;
-text: .text%Java_java_awt_event_InputEvent_initIDs;
-text: .text%Java_java_awt_event_KeyEvent_initIDs;
-text: .text%Java_java_awt_AWTKeyStroke_allocateNewInstance;
-text: .text%Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
-text: .text%Java_java_awt_Event_initIDs;
-# Test LoadJFrame
-text: .text%awtJNI_ThreadYield;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenWidth;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenHeight;
-text: .text%X11SD_Lock: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_InitWindow: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%GetLockStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_GetRasInfo: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_Unlock: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_InitClip: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%XRequestSentStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-# Test JHello
-text: .text%AWTLoadFont;
-text: .text%AWTFontMaxByte1;
-text: .text%AWTFontMaxCharOrByte2;
-text: .text%AWTFontMaxBounds;
-text: .text%AWTCharAscent;
-text: .text%AWTCharDescent;
-text: .text%AWTCharWidth;
-text: .text%AWTFontMinByte1;
-text: .text%AWTFontMinCharOrByte2;
-text: .text%AWTFontPerChar;
-text: .text%AWTCharRBearing;
-text: .text%AWTCharLBearing;
-text: .text%Java_sun_awt_X11SurfaceData_setInvalid;
-# SwingSet
-text: .text%Java_sun_awt_motif_MWindowPeer_setSaveUnder;
-text: .text%Java_sun_awt_X11SurfaceData_nativeDispose;
-text: .text%X11SurfaceData_GetOps;
-text: .text%Java_sun_awt_motif_MCanvasPeer_create;
-text: .text%awt_util_insertCallback;
-text: .text%Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
-text: .text%Java_sun_awt_motif_MComponentPeer_pReshape;
-text: .text%awt_util_reshape;
-text: .text%Java_sun_awt_motif_MComponentPeer_pShow;
-text: .text%Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
-text: .text%Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
-text: .text%register_drop_site;
-text: .text%update_drop_site_hierarchy: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_XmDnD.o;
-text: .text%AWTFontDefaultChar;
-text: .text%isAncestor;
-text: .text%xerror_handler;
-text: .text%AWTFontGenerateImage;
-text: .text%CreatePixmapAndGC;
--- a/jdk/make/sun/motif12/reorder-sparcv9 Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-data = R0x2000;
-text = LOAD ?RXO;
-# Test Null
-# Test Exit
-# Test Hello
-# Test Sleep
-# Test IntToString
-# Test LoadToolkit
-text: .text%JNI_OnLoad;
-text: .text%awt_util_debug_init;
-text: .text%Java_java_awt_Toolkit_initIDs;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_initDisplay;
-text: .text%awt_init_Display;
-text: .text%makeDefaultConfig: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_GraphicsEnv.o;
-text: .text%awt_allocate_colors;
-text: .text%make_uns_ordered_dither_array;
-text: .text%checkFont: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Font.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNativeFonts;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNumScreens;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum;
-text: .text%Java_sun_awt_X11GraphicsDevice_getConfigVisualId;
-text: .text%Java_sun_awt_X11GraphicsConfig_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_init;
-text: .text%getAllConfigs: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_GraphicsEnv.o;
-text: .text%awt_output_flush;
-text: .text%awtJNI_TimeMillis: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%Java_sun_awt_motif_MToolkit_init;
-text: .text%getDefaultConfig;
-text: .text%getScreenData;
-text: .text%Java_sun_awt_PlatformFont_initIDs;
-text: .text%Java_sun_awt_motif_MFontPeer_initIDs;
-text: .text%awt_color_matchTC;
-text: .text%setup_modifier_map: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%set_mod_mask: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_initialize_Xm_DnD;
-text: .text%Java_java_awt_Cursor_initIDs;
-text: .text%Java_sun_awt_motif_X11CustomCursor_cacheInit;
-text: .text%Java_java_awt_Dimension_initIDs;
-text: .text%Java_sun_awt_motif_MToolkit_run;
-text: .text%awtJNI_GetCurrentThread;
-text: .text%awt_MToolkit_loop: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_pipe_init: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_set_poll_timeout: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_events_pending: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%processOneEvent: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%waitForEvents: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%performPoll: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_get_poll_timeout: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awtJNI_CleanupGlobalRefs;
-# Test LoadFrame
-text: .text%Java_java_awt_Component_initIDs;
-text: .text%Java_java_awt_Container_initIDs;
-text: .text%Java_java_awt_Window_initIDs;
-text: .text%Java_java_awt_Frame_initIDs;
-text: .text%Java_sun_awt_SunToolkit_getPrivateKey;
-text: .text%Java_java_awt_MenuComponent_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_pGetBounds;
-text: .text%Java_java_awt_Rectangle_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_initIDs;
-text: .text%Java_java_awt_Insets_initIDs;
-text: .text%Java_sun_awt_motif_MWindowAttributes_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_create;
-text: .text%awtJNI_CreateAndSetGlobalRef;
-text: .text%copyGraphicsConfigToPeer;
-text: .text%awt_Frame_guessInsets;
-text: .text%awt_util_runningWindowManager;
-text: .text%awt_winmgrerr: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_util.o;
-text: .text%awtJNI_ChangeInsets: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%getMotifFontList;
-text: .text%getMotifFontStruct;
-text: .text%setDeleteCallback: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%ColorProc;
-text: .text%awt_canvas_create;
-text: .text%awt_util_show;
-text: .text%addTopLevel;
-text: .text%Java_sun_awt_motif_MWindowPeer_pHide;
-text: .text%Java_sun_awt_motif_MComponentPeer_pInitialize;
-text: .text%awt_addWidget;
-text: .text%Java_sun_awt_motif_MComponentPeer_setCursor;
-text: .text%getCursor;
-text: .text%awt_util_setCursor;
-text: .text%Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
-text: .text%Java_sun_awt_motif_MWindowPeer_pReshape;
-text: .text%reshape: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%awtJNI_setMbAndWwHeightAndOffsets: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%awt_util_wmPositionsShellXY;
-text: .text%Java_sun_awt_motif_MWindowPeer_pSetTitle;
-text: .text%Java_sun_awt_motif_MWindowPeer_setResizable;
-text: .text%Java_java_awt_Font_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetFont;
-text: .text%awt_util_mapChildren;
-text: .text%changeFont: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Component.o;
-text: .text%Java_java_awt_Color_initIDs;
-text: .text%Java_sun_awt_motif_MToolkit_loadSystemColors;
-text: .text%colorToRGB: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetBackground;
-text: .text%getGraphicsConfigFromComponentPeer;
-text: .text%awtJNI_GetColorForVis;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetForeground;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShow;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShowModal;
-text: .text%setStateHints: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%awt_util_setMinMaxSizeProps;
-text: .text%innerCanvasEH: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%reconfigureOuterCanvas: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%Java_java_awt_AWTEvent_initIDs;
-text: .text%outerCanvasResizeCB: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
-text: .text%shellEH: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
-text: .text%getCurComponent;
-text: .text%get_awt_TopLevelInsetsProp;
-text: .text%syncTopLevelPos;
-text: .text%Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
-text: .text%raiseInputMethodWindow;
-text: .text%getWindowState: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%awt_canvas_event_handler;
-text: .text%awt_canvas_handleEvent;
-text: .text%HandleExposeEvent: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/canvas.o;
-text: .text%checkForExpose: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/canvas.o;
-text: .text%Java_java_awt_Event_initIDs;
-text: .text%Java_java_awt_image_ColorModel_initIDs;
-text: .text%Java_sun_awt_motif_X11Graphics_cacheInit;
-text: .text%InitMITShm: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%Java_sun_java2d_loops_RasterOutputManager_getPlatformFontVar;
-text: .text%Java_sun_awt_motif_X11Graphics_createFromComponent;
-text: .text%Java_sun_awt_motif_X11Graphics_pSetForeground;
-text: .text%awt_init_gc;
-text: .text%Java_sun_awt_motif_X11Graphics_pSetFont;
-text: .text%awtJNI_GetFontData;
-text: .text%awtJNI_IsMultiFont;
-text: .text%Java_sun_awt_FontDescriptor_initIDs;
-text: .text%loadFont;
-text: .text%Java_sun_awt_motif_X11Graphics_setOrigin;
-text: .text%Java_sun_awt_motif_X11Graphics_setLineAttrs;
-text: .text%Java_sun_awt_motif_X11Graphics_changeClip;
-text: .text%Java_sun_awt_motif_X11Graphics_devClearRect;
-text: .text%Java_sun_awt_motif_X11Graphics_disposeImpl;
-# Test LoadJFrame
-text: .text%Java_java_awt_event_InputEvent_initIDs;
-text: .text%Java_java_awt_event_KeyEvent_initIDs;
-text: .text%expandDamageRect: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/canvas.o;
-text: .text%awtJNI_ThreadYield;
-text: .text%Java_sun_awt_motif_X11Graphics_createFromGraphics;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenWidth;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenHeight;
-text: .text%Java_sun_awt_X11GraphicsConfig_makeColorModel;
-text: .text%awtJNI_GetColorModel;
-text: .text%Java_java_awt_image_BufferedImage_initIDs;
-text: .text%Java_java_awt_image_Raster_initIDs;
-text: .text%Java_java_awt_image_SampleModel_initIDs;
-text: .text%Java_java_awt_image_SinglePixelPackedSampleModel_initIDs;
-text: .text%Java_sun_awt_image_IntegerComponentRaster_initIDs;
-text: .text%Java_sun_java2d_loops_ImageData_initIDs;
-text: .text%Java_sun_java2d_loops_IntDiscreteRenderer_devSetRect;
-text: .text%Java_sun_awt_motif_X11Graphics_X11LockViewResources;
-text: .text%X11DeferredLockViewResources: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%getLockMethod: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%DGA_DeferredLockViewResources;
-text: .text%setLockMethod: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%getPrimitiveType: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%Java_sun_awt_motif_X11Graphics_X11UnLockViewResources;
-text: .text%DGA_UnlockViewResources;
-text: .text%Java_sun_java2d_loops_DefaultComponent_IntIsomorphicCopy;
-text: .text%minImageWidths;
-text: .text%minImageRows;
-text: .text%getIntImageLockInfo;
-text: .text%lockIntImageData;
-text: .text%unlockIntImageData;
-# Test JHello
-text: .text%Java_java_awt_FontMetrics_initIDs;
-# SwingSet
-text: .text%Java_sun_awt_image_Image_initIDs;
-text: .text%Java_sun_awt_image_ImageRepresentation_initIDs;
-text: .text%Java_java_awt_image_IndexColorModel_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_setSaveUnder;
-text: .text%Java_java_awt_AWTEvent_freeNativeData;
-text: .text%Java_sun_java2d_loops_DefaultComponent_IntRgbToXbgr;
-text: .text%Java_sun_awt_motif_MCanvasPeer_create;
-text: .text%awt_util_insertCallback;
-text: .text%Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
-text: .text%Java_sun_awt_motif_MComponentPeer_pReshape;
-text: .text%awt_util_reshape;
-text: .text%Java_sun_awt_motif_MComponentPeer_pShow;
-text: .text%Java_sun_java2d_loops_IntDiscreteRenderer_devDrawLine;
-text: .text%doDrawLine: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/IntDiscreteRenderer.o;
-text: .text%adjustLine: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/IntDiscreteRenderer.o;
-text: .text%Java_sun_awt_image_GifImageDecoder_initIDs;
-text: .text%Java_java_awt_image_ComponentSampleModel_initIDs;
-text: .text%Java_sun_awt_image_ByteComponentRaster_initIDs;
-text: .text%Java_sun_awt_image_GifImageDecoder_parseImage;
-text: .text%Java_sun_awt_image_ImageRepresentation_setBytePixels;
-text: .text%Java_sun_java2d_loops_IntDiscreteRenderer_devDrawRect;
-text: .text%outcode: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/IntDiscreteRenderer.o;
-text: .text%Java_sun_java2d_loops_ImageData_isAllOpaqueGrayICM;
-text: .text%Java_sun_java2d_loops_GIFAcceleratorLoops_LUTcopyTo32BitXBgr;
-text: .text%getByteIndexedImageLockInfo;
-text: .text%lockByteIndexedImageData;
-text: .text%unlockByteIndexedImageData;
-text: .text%Java_sun_java2d_loops_GIFAcceleratorLoops_LUTxparTo32BitXBgr;
-text: .text%shouldDispatchToWidget: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awtMenuIsActive;
-text: .text%awt_util_focusIsOnMenu;
-text: .text%awt_isModal;
-text: .text%findWidgetInfo: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_copyXEvent;
-text: .text%awt_post_java_mouse_event;
-text: .text%Java_java_awt_event_MouseEvent_initIDs;
-text: .text%sysTimeMillis;
-text: .text%updateCursor;
-text: .text%awt_setActivatedShell;
-text: .text%handleFocusEvent;
-text: .text%awt_post_java_focus_event;
-text: .text%getModifiers;
-text: .text%Java_java_awt_AWTEvent_copyDataFieldInto;
-text: .text%Java_sun_awt_motif_X11InputMethod_initIDs;
-text: .text%Java_sun_awt_motif_X11InputMethod_openXIM;
-text: .text%awt_put_back_event;
-text: .text%awt_get_next_put_back_event: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%null_event_handler: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
-text: .text%Java_sun_awt_motif_MWindowPeer_hasTextComponents;
-text: .text%Java_sun_awt_motif_X11InputMethod_createXICNative;
-text: .text%findClass: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_InputMethod.o;
-text: .text%createXIC: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_InputMethod.o;
-text: .text%Java_sun_awt_motif_X11InputMethod_setXICFocus;
-text: .text%setXICWindowFocus: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_InputMethod.o;
-text: .text%setXICFocus: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_InputMethod.o;
-text: .text%getAncestorShell;
-text: .text%Java_sun_awt_motif_X11InputMethod_turnoffStatusWindow;
-text: .text%Frame_quit: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
--- a/jdk/make/sun/xawt/mapfile-vers Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/make/sun/xawt/mapfile-vers Thu Dec 15 19:52:13 2011 -0800
@@ -256,8 +256,6 @@
Java_sun_awt_X11_XToolkit_waitForEvents;
Java_java_awt_Event_initIDs;
- Java_sun_awt_motif_X11FontMetrics_initIDs;
- Java_sun_awt_motif_X11FontMetrics_init;
Java_sun_awt_X11_XWindow_x11inputMethodLookupString;
Java_sun_awt_X11_XWindow_haveCurrentX11InputMethodInstance;
Java_java_awt_AWTEvent_nativeSetSource;
@@ -265,7 +263,6 @@
Java_sun_awt_PlatformFont_initIDs;
Java_sun_awt_FontDescriptor_initIDs;
Java_sun_awt_X11_XFontPeer_initIDs;
- Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth;
Java_sun_awt_X11InputMethod_initIDs;
Java_sun_awt_X11InputMethod_resetXIC;
Java_sun_awt_X11InputMethod_disposeXIC;
@@ -322,6 +319,8 @@
Java_sun_awt_X11_XlibWrapper_XSynchronize;
Java_java_awt_FileDialog_initIDs;
Java_sun_awt_X11_XWindow_initIDs;
+ Java_sun_awt_X11_XWindowPeer_getLocalHostname;
+ Java_sun_awt_X11_XWindowPeer_getJvmPID;
Java_sun_java2d_opengl_OGLContext_getOGLIdString;
Java_sun_java2d_opengl_OGLMaskFill_maskFill;
--- a/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java Thu Dec 15 19:52:13 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@
/**
* Returns an array of {@code Class} objects
- * that represent the formal parameter types of the method
+ * that represent the formal parameter types of the method.
* Returns an empty array if the method takes no parameters.
*
* @param method the object that represents method
--- a/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java Thu Dec 15 19:52:13 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -87,7 +87,7 @@
/**
* Returns an array of {@code Class} objects
- * that represent the formal parameter types of the constructor
+ * that represent the formal parameter types of the constructor.
* Returns an empty array if the constructor takes no parameters.
*
* @param constructor the object that represents constructor
--- a/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java Thu Dec 15 19:52:13 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -190,7 +190,7 @@
/**
* Returns an array of {@code Class} objects
- * that represent the formal parameter types of the method
+ * that represent the formal parameter types of the method.
* Returns an empty array if the method takes no parameters.
*
* @param method the object that represents method
@@ -226,6 +226,6 @@
*/
@Override
protected boolean isValid(Method method) {
- return Modifier.isPublic(method.getModifiers()) && method.getName().equals(this.name);
+ return !method.isBridge() && Modifier.isPublic(method.getModifiers()) && method.getName().equals(this.name);
}
}
--- a/jdk/src/share/classes/java/awt/Component.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/Component.java Thu Dec 15 19:52:13 2011 -0800
@@ -666,9 +666,10 @@
* can lead to a deadlock if client code also uses synchronization
* by a component object. For every such situation revealed we should
* consider possibility of replacing "this" with the package private
- * objectLock object introduced below. So far there're 2 issues known:
+ * objectLock object introduced below. So far there're 3 issues known:
* - CR 6708322 (the getName/setName methods);
- * - CR 6608764 (the PropertyChangeListener machinery).
+ * - CR 6608764 (the PropertyChangeListener machinery);
+ * - CR 7108598 (the Container.paint/KeyboardFocusManager.clearMostRecentFocusOwner methods).
*
* Note: this field is considered final, though readObject() prohibits
* initializing final fields.
@@ -1158,6 +1159,10 @@
boolean updateGraphicsData(GraphicsConfiguration gc) {
checkTreeLock();
+ if (graphicsConfig == gc) {
+ return false;
+ }
+
graphicsConfig = gc;
ComponentPeer peer = getPeer();
--- a/jdk/src/share/classes/java/awt/Container.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/Container.java Thu Dec 15 19:52:13 2011 -0800
@@ -1950,7 +1950,7 @@
*/
public void paint(Graphics g) {
if (isShowing()) {
- synchronized (this) {
+ synchronized (getObjectLock()) {
if (printing) {
if (printingThreads.contains(Thread.currentThread())) {
return;
@@ -2004,7 +2004,7 @@
if (isShowing()) {
Thread t = Thread.currentThread();
try {
- synchronized (this) {
+ synchronized (getObjectLock()) {
if (printingThreads == null) {
printingThreads = new HashSet();
}
@@ -2013,7 +2013,7 @@
}
super.print(g); // By default, Component.print() calls paint()
} finally {
- synchronized (this) {
+ synchronized (getObjectLock()) {
printingThreads.remove(t);
printing = !printingThreads.isEmpty();
}
--- a/jdk/src/share/classes/java/awt/font/StyledParagraph.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/StyledParagraph.java Thu Dec 15 19:52:13 2011 -0800
@@ -34,6 +34,7 @@
import java.awt.im.InputMethodHighlight;
import java.text.Annotation;
import java.text.AttributedCharacterIterator;
+import java.text.AttributedCharacterIterator.Attribute;
import java.util.Vector;
import java.util.HashMap;
import java.util.Map;
@@ -65,7 +66,7 @@
// If there are multiple Decorations in the paragraph, they are
// stored in this Vector, in order. Otherwise this vector and
// the decorationStarts array are null.
- private Vector decorations;
+ private Vector<Decoration> decorations;
// If there are multiple Decorations in the paragraph,
// decorationStarts[i] contains the index where decoration i
// starts. For convenience, there is an extra entry at the
@@ -76,7 +77,7 @@
// they are
// stored in this Vector, in order. Otherwise this vector and
// the fontStarts array are null.
- private Vector fonts;
+ private Vector<Object> fonts;
// If there are multiple Fonts/GraphicAttributes in the paragraph,
// fontStarts[i] contains the index where decoration i
// starts. For convenience, there is an extra entry at the
@@ -104,7 +105,7 @@
final int nextRunStart = aci.getRunLimit();
final int localIndex = index-start;
- Map attributes = aci.getAttributes();
+ Map<? extends Attribute, ?> attributes = aci.getAttributes();
attributes = addInputMethodAttrs(attributes);
Decoration d = Decoration.getDecoration(attributes);
addDecoration(d, localIndex);
@@ -168,7 +169,8 @@
char ch = aci.setIndex(insertPos);
int relativePos = Math.max(insertPos - aci.getBeginIndex() - 1, 0);
- Map attributes = addInputMethodAttrs(aci.getAttributes());
+ Map<? extends Attribute, ?> attributes =
+ addInputMethodAttrs(aci.getAttributes());
Decoration d = Decoration.getDecoration(attributes);
if (!oldParagraph.getDecorationAt(relativePos).equals(d)) {
return new StyledParagraph(aci, chars);
@@ -297,7 +299,7 @@
return decoration;
}
int run = findRunContaining(index, decorationStarts);
- return (Decoration) decorations.elementAt(run);
+ return decorations.elementAt(run);
}
/**
@@ -339,6 +341,7 @@
* starts array does not have room for the index, a
* new array is created and returned.
*/
+ @SuppressWarnings({"rawtypes", "unchecked"})
private static int[] addToVector(Object obj,
int index,
Vector v,
@@ -374,7 +377,7 @@
}
else {
if (!decoration.equals(d)) {
- decorations = new Vector(INITIAL_SIZE);
+ decorations = new Vector<Decoration>(INITIAL_SIZE);
decorations.addElement(decoration);
decorations.addElement(d);
decorationStarts = new int[INITIAL_SIZE];
@@ -398,7 +401,7 @@
}
else {
if (!font.equals(f)) {
- fonts = new Vector(INITIAL_SIZE);
+ fonts = new Vector<Object>(INITIAL_SIZE);
fonts.addElement(font);
fonts.addElement(f);
fontStarts = new int[INITIAL_SIZE];
@@ -412,7 +415,8 @@
* Resolve the given chars into Fonts using FontResolver, then add
* font runs for each.
*/
- private void addFonts(char[] chars, Map attributes, int start, int limit) {
+ private void addFonts(char[] chars, Map<? extends Attribute, ?> attributes,
+ int start, int limit) {
FontResolver resolver = FontResolver.getInstance();
CodePointIterator iter = CodePointIterator.create(chars, start, limit);
@@ -426,7 +430,8 @@
* Return a Map with entries from oldStyles, as well as input
* method entries, if any.
*/
- static Map addInputMethodAttrs(Map oldStyles) {
+ static Map<? extends Attribute, ?>
+ addInputMethodAttrs(Map<? extends Attribute, ?> oldStyles) {
Object value = oldStyles.get(TextAttribute.INPUT_METHOD_HIGHLIGHT);
@@ -439,7 +444,7 @@
InputMethodHighlight hl;
hl = (InputMethodHighlight) value;
- Map imStyles = null;
+ Map<? extends Attribute, ?> imStyles = null;
try {
imStyles = hl.getStyle();
} catch (NoSuchMethodError e) {
@@ -451,7 +456,8 @@
}
if (imStyles != null) {
- HashMap newStyles = new HashMap(5, (float)0.9);
+ HashMap<Attribute, Object>
+ newStyles = new HashMap<>(5, (float)0.9);
newStyles.putAll(oldStyles);
newStyles.putAll(imStyles);
@@ -471,7 +477,8 @@
* If attributes does not contain a GraphicAttribute, Font, or
* Font family entry this method returns null.
*/
- private static Object getGraphicOrFont(Map attributes) {
+ private static Object getGraphicOrFont(
+ Map<? extends Attribute, ?> attributes) {
Object value = attributes.get(TextAttribute.CHAR_REPLACEMENT);
if (value != null) {
--- a/jdk/src/share/classes/java/awt/font/TextAttribute.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/TextAttribute.java Thu Dec 15 19:52:13 2011 -0800
@@ -257,7 +257,8 @@
public final class TextAttribute extends Attribute {
// table of all instances in this class, used by readResolve
- private static final Map instanceMap = new HashMap(29);
+ private static final Map<String, TextAttribute>
+ instanceMap = new HashMap<String, TextAttribute>(29);
/**
* Constructs a <code>TextAttribute</code> with the specified name.
@@ -280,7 +281,7 @@
"subclass didn't correctly implement readResolve");
}
- TextAttribute instance = (TextAttribute) instanceMap.get(getName());
+ TextAttribute instance = instanceMap.get(getName());
if (instance != null) {
return instance;
} else {
--- a/jdk/src/share/classes/java/awt/font/TextLayout.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/TextLayout.java Thu Dec 15 19:52:13 2011 -0800
@@ -55,6 +55,7 @@
import java.text.AttributedString;
import java.text.AttributedCharacterIterator;
import java.text.AttributedCharacterIterator.Attribute;
+import java.text.CharacterIterator;
import java.util.Map;
import java.util.HashMap;
import java.util.Hashtable;
@@ -382,7 +383,7 @@
throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
}
- Map attributes = null;
+ Map<? extends Attribute, ?> attributes = null;
if (font.hasLayoutAttributes()) {
attributes = font.getAttributes();
}
@@ -451,7 +452,7 @@
private static Font singleFont(char[] text,
int start,
int limit,
- Map attributes) {
+ Map<? extends Attribute, ?> attributes) {
if (attributes.get(TextAttribute.CHAR_REPLACEMENT) != null) {
return null;
@@ -516,14 +517,17 @@
text.first();
char[] chars = new char[len];
int n = 0;
- for (char c = text.first(); c != text.DONE; c = text.next()) {
+ for (char c = text.first();
+ c != CharacterIterator.DONE;
+ c = text.next())
+ {
chars[n++] = c;
}
text.first();
if (text.getRunLimit() == limit) {
- Map attributes = text.getAttributes();
+ Map<? extends Attribute, ?> attributes = text.getAttributes();
Font font = singleFont(chars, 0, len, attributes);
if (font != null) {
fastInit(chars, font, attributes, frc);
@@ -561,7 +565,9 @@
/**
* Initialize the paragraph-specific data.
*/
- private void paragraphInit(byte aBaseline, CoreMetrics lm, Map paragraphAttrs, char[] text) {
+ private void paragraphInit(byte aBaseline, CoreMetrics lm,
+ Map<? extends Attribute, ?> paragraphAttrs,
+ char[] text) {
baseline = aBaseline;
@@ -581,7 +587,10 @@
* all renderable by one font (ie no embedded graphics)
* all on one baseline
*/
- private void fastInit(char[] chars, Font font, Map attrs, FontRenderContext frc) {
+ private void fastInit(char[] chars, Font font,
+ Map<? extends Attribute, ?> attrs,
+ FontRenderContext frc) {
+
// Object vf = attrs.get(TextAttribute.ORIENTATION);
// isVerticalLine = TextAttribute.ORIENTATION_VERTICAL.equals(vf);
isVerticalLine = false;
@@ -619,7 +628,7 @@
// and use it and its font to initialize the paragraph.
// If not, use the first graphic to initialize.
- Map paragraphAttrs = text.getAttributes();
+ Map<? extends Attribute, ?> paragraphAttrs = text.getAttributes();
boolean haveFont = TextLine.advanceToFirstFont(text);
--- a/jdk/src/share/classes/java/awt/font/TextLine.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/TextLine.java Thu Dec 15 19:52:13 2011 -0800
@@ -43,6 +43,7 @@
import java.awt.image.BufferedImage;
import java.text.Annotation;
import java.text.AttributedCharacterIterator;
+import java.text.AttributedCharacterIterator.Attribute;
import java.text.Bidi;
import java.text.CharacterIterator;
import java.util.Hashtable;
@@ -318,7 +319,8 @@
for (int i = 0, n = 0; i < fComponents.length; ++i, n += 2) {
tlc = fComponents[getComponentLogicalIndex(i)];
AffineTransform at = tlc.getBaselineTransform();
- if (at != null && ((at.getType() & at.TYPE_TRANSLATION) != 0)) {
+ if (at != null &&
+ ((at.getType() & AffineTransform.TYPE_TRANSLATION) != 0)) {
double dx = at.getTranslateX();
double dy = at.getTranslateY();
builder.moveTo(tx += dx, ty += dy);
@@ -903,7 +905,7 @@
char[] chars,
Font font,
CoreMetrics lm,
- Map attributes) {
+ Map<? extends Attribute, ?> attributes) {
boolean isDirectionLTR = true;
byte[] levels = null;
@@ -1250,7 +1252,10 @@
*/
static boolean advanceToFirstFont(AttributedCharacterIterator aci) {
- for (char ch = aci.first(); ch != aci.DONE; ch = aci.setIndex(aci.getRunLimit())) {
+ for (char ch = aci.first();
+ ch != CharacterIterator.DONE;
+ ch = aci.setIndex(aci.getRunLimit()))
+ {
if (aci.getAttribute(TextAttribute.CHAR_REPLACEMENT) == null) {
return true;
--- a/jdk/src/share/classes/java/awt/font/TextMeasurer.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/TextMeasurer.java Thu Dec 15 19:52:13 2011 -0800
@@ -43,6 +43,7 @@
import java.awt.Font;
import java.text.AttributedCharacterIterator;
+import java.text.AttributedCharacterIterator.Attribute;
import java.text.AttributedString;
import java.text.Bidi;
import java.text.BreakIterator;
@@ -176,7 +177,7 @@
throw new Error();
}
if (fComponents != null) {
- other.fComponents = (TextLineComponent[]) fComponents.clone();
+ other.fComponents = fComponents.clone();
}
return other;
}
@@ -199,7 +200,10 @@
fChars = new char[text.getEndIndex() - fStart];
int n = 0;
- for (char c = text.first(); c != text.DONE; c = text.next()) {
+ for (char c = text.first();
+ c != CharacterIterator.DONE;
+ c = text.next())
+ {
fChars[n++] = c;
}
@@ -211,7 +215,7 @@
}
text.first();
- Map paragraphAttrs = text.getAttributes();
+ Map<? extends Attribute, ?> paragraphAttrs = text.getAttributes();
NumericShaper shaper = AttributeValues.getNumericShaping(paragraphAttrs);
if (shaper != null) {
shaper.shape(fChars, 0, fChars.length);
@@ -243,7 +247,8 @@
GraphicAttribute graphic = (GraphicAttribute)
paragraphAttrs.get(TextAttribute.CHAR_REPLACEMENT);
fBaseline = TextLayout.getBaselineFromGraphic(graphic);
- Font dummyFont = new Font(new Hashtable(5, (float)0.9));
+ Hashtable<Attribute, ?> fmap = new Hashtable<>(5, (float)0.9);
+ Font dummyFont = new Font(fmap);
LineMetrics lm = dummyFont.getLineMetrics(" ", 0, 1, fFrc);
fBaselineOffsets = lm.getBaselineOffsets();
}
--- a/jdk/src/share/classes/java/awt/geom/Path2D.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/geom/Path2D.java Thu Dec 15 19:52:13 2011 -0800
@@ -667,7 +667,8 @@
// Collapse out initial moveto/lineto
break;
}
- // NO BREAK;
+ lineTo(coords[0], coords[1]);
+ break;
case SEG_LINETO:
lineTo(coords[0], coords[1]);
break;
@@ -1392,7 +1393,8 @@
// Collapse out initial moveto/lineto
break;
}
- // NO BREAK;
+ lineTo(coords[0], coords[1]);
+ break;
case SEG_LINETO:
lineTo(coords[0], coords[1]);
break;
@@ -2456,7 +2458,7 @@
}
}
}
- s.writeByte((byte) SERIAL_PATH_END);
+ s.writeByte(SERIAL_PATH_END);
}
final void readObject(java.io.ObjectInputStream s, boolean storedbl)
--- a/jdk/src/share/classes/java/beans/Beans.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/Beans.java Thu Dec 15 19:52:13 2011 -0800
@@ -32,7 +32,6 @@
import java.applet.AppletStub;
import java.applet.AudioClip;
-import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.beans.beancontext.BeanContext;
@@ -53,15 +52,11 @@
import java.util.Iterator;
import java.util.Vector;
-import sun.awt.AppContext;
-
/**
* This class provides some general purpose beans control methods.
*/
public class Beans {
- private static final Object DESIGN_TIME = new Object();
- private static final Object GUI_AVAILABLE = new Object();
/**
* <p>
@@ -399,8 +394,7 @@
* @see DesignMode
*/
public static boolean isDesignTime() {
- Object value = AppContext.getAppContext().get(DESIGN_TIME);
- return (value instanceof Boolean) && (Boolean) value;
+ return ThreadGroupContext.getContext().isDesignTime();
}
/**
@@ -417,8 +411,7 @@
*
*/
public static boolean isGuiAvailable() {
- Object value = AppContext.getAppContext().get(GUI_AVAILABLE);
- return (value instanceof Boolean) ? (Boolean) value : !GraphicsEnvironment.isHeadless();
+ return ThreadGroupContext.getContext().isGuiAvailable();
}
/**
@@ -444,7 +437,7 @@
if (sm != null) {
sm.checkPropertiesAccess();
}
- AppContext.getAppContext().put(DESIGN_TIME, Boolean.valueOf(isDesignTime));
+ ThreadGroupContext.getContext().setDesignTime(isDesignTime);
}
/**
@@ -470,7 +463,7 @@
if (sm != null) {
sm.checkPropertiesAccess();
}
- AppContext.getAppContext().put(GUI_AVAILABLE, Boolean.valueOf(isGuiAvailable));
+ ThreadGroupContext.getContext().setGuiAvailable(isGuiAvailable);
}
}
--- a/jdk/src/share/classes/java/beans/Encoder.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/Encoder.java Thu Dec 15 19:52:13 2011 -0800
@@ -195,7 +195,13 @@
*/
public PersistenceDelegate getPersistenceDelegate(Class<?> type) {
PersistenceDelegate pd = this.finder.find(type);
- return (pd != null) ? pd : MetaData.getPersistenceDelegate(type);
+ if (pd == null) {
+ pd = MetaData.getPersistenceDelegate(type);
+ if (pd != null) {
+ this.finder.register(type, pd);
+ }
+ }
+ return pd;
}
/**
--- a/jdk/src/share/classes/java/beans/Introspector.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/Introspector.java Thu Dec 15 19:52:13 2011 -0800
@@ -26,7 +26,6 @@
package java.beans;
import com.sun.beans.WeakCache;
-import com.sun.beans.finder.BeanInfoFinder;
import com.sun.beans.finder.ClassFinder;
import java.awt.Component;
@@ -44,9 +43,7 @@
import java.util.EventObject;
import java.util.List;
import java.util.TreeMap;
-import java.util.WeakHashMap;
-import sun.awt.AppContext;
import sun.reflect.misc.ReflectUtil;
/**
@@ -98,10 +95,7 @@
public final static int IGNORE_ALL_BEANINFO = 3;
// Static Caches to speed up introspection.
- private static WeakCache<Class<?>, Method[]> declaredMethodCache =
- new WeakCache<>();
-
- private static final Object BEANINFO_CACHE = new Object();
+ private static final WeakCache<Class<?>, Method[]> declaredMethodCache = new WeakCache<>();
private Class<?> beanClass;
private BeanInfo explicitBeanInfo;
@@ -134,8 +128,6 @@
static final String SET_PREFIX = "set";
static final String IS_PREFIX = "is";
- private static final Object FINDER_KEY = new Object();
-
//======================================================================
// Public methods
//======================================================================
@@ -160,22 +152,15 @@
if (!ReflectUtil.isPackageAccessible(beanClass)) {
return (new Introspector(beanClass, null, USE_ALL_BEANINFO)).getBeanInfo();
}
- Map<Class<?>, BeanInfo> beanInfoCache;
+ ThreadGroupContext context = ThreadGroupContext.getContext();
BeanInfo beanInfo;
- synchronized (BEANINFO_CACHE) {
- @SuppressWarnings("unchecked")
- Map<Class<?>, BeanInfo> temp = beanInfoCache =
- (Map<Class<?>, BeanInfo>) AppContext.getAppContext().get(BEANINFO_CACHE);
- if (beanInfoCache == null) {
- beanInfoCache = new WeakHashMap<>();
- AppContext.getAppContext().put(BEANINFO_CACHE, beanInfoCache);
- }
- beanInfo = beanInfoCache.get(beanClass);
+ synchronized (declaredMethodCache) {
+ beanInfo = context.getBeanInfo(beanClass);
}
if (beanInfo == null) {
beanInfo = new Introspector(beanClass, null, USE_ALL_BEANINFO).getBeanInfo();
- synchronized (BEANINFO_CACHE) {
- beanInfoCache.put(beanClass, beanInfo);
+ synchronized (declaredMethodCache) {
+ context.putBeanInfo(beanClass, beanInfo);
}
}
return beanInfo;
@@ -308,7 +293,7 @@
*/
public static String[] getBeanInfoSearchPath() {
- return getFinder().getPackages();
+ return ThreadGroupContext.getContext().getBeanInfoFinder().getPackages();
}
/**
@@ -332,7 +317,7 @@
if (sm != null) {
sm.checkPropertiesAccess();
}
- getFinder().setPackages(path);
+ ThreadGroupContext.getContext().getBeanInfoFinder().setPackages(path);
}
@@ -344,11 +329,8 @@
*/
public static void flushCaches() {
- synchronized (BEANINFO_CACHE) {
- Map<?,?> beanInfoCache = (Map) AppContext.getAppContext().get(BEANINFO_CACHE);
- if (beanInfoCache != null) {
- beanInfoCache.clear();
- }
+ synchronized (declaredMethodCache) {
+ ThreadGroupContext.getContext().clearBeanInfoCache();
declaredMethodCache.clear();
}
}
@@ -372,12 +354,8 @@
if (clz == null) {
throw new NullPointerException();
}
- synchronized (BEANINFO_CACHE) {
- @SuppressWarnings("unchecked")
- Map<Class<?>, ?> beanInfoCache = (Map<Class<?>, ?>) AppContext.getAppContext().get(BEANINFO_CACHE);
- if (beanInfoCache != null) {
- beanInfoCache.put(clz, null);
- }
+ synchronized (declaredMethodCache) {
+ ThreadGroupContext.getContext().removeBeanInfo(clz);
declaredMethodCache.put(clz, null);
}
}
@@ -455,7 +433,7 @@
* @return Instance of an explicit BeanInfo class or null if one isn't found.
*/
private static BeanInfo findExplicitBeanInfo(Class<?> beanClass) {
- return getFinder().find(beanClass);
+ return ThreadGroupContext.getContext().getBeanInfoFinder().find(beanClass);
}
/**
@@ -1278,7 +1256,7 @@
if (!ReflectUtil.isPackageAccessible(clz)) {
return new Method[0];
}
- synchronized (BEANINFO_CACHE) {
+ synchronized (declaredMethodCache) {
Method[] result = declaredMethodCache.get(clz);
if (result == null) {
result = clz.getMethods();
@@ -1429,17 +1407,6 @@
return false;
}
- private static BeanInfoFinder getFinder() {
- AppContext context = AppContext.getAppContext();
- Object object = context.get(FINDER_KEY);
- if (object instanceof BeanInfoFinder) {
- return (BeanInfoFinder) object;
- }
- BeanInfoFinder finder = new BeanInfoFinder();
- context.put(FINDER_KEY, finder);
- return finder;
- }
-
/**
* Try to create an instance of a named class.
* First try the classloader of "sibling", then try the system
--- a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java Thu Dec 15 19:52:13 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
package java.beans;
+import java.util.EventObject;
+
/**
* A "PropertyChange" event gets delivered whenever a bean changes a "bound"
* or "constrained" property. A PropertyChangeEvent object is sent as an
@@ -42,21 +44,21 @@
* arbitrary set of if its properties have changed. In this case the
* old and new values should also be null.
*/
-
-public class PropertyChangeEvent extends java.util.EventObject {
+public class PropertyChangeEvent extends EventObject {
private static final long serialVersionUID = 7042693688939648123L;
/**
- * Constructs a new <code>PropertyChangeEvent</code>.
+ * Constructs a new {@code PropertyChangeEvent}.
*
- * @param source The bean that fired the event.
- * @param propertyName The programmatic name of the property
- * that was changed.
- * @param oldValue The old value of the property.
- * @param newValue The new value of the property.
+ * @param source the bean that fired the event
+ * @param propertyName the programmatic name of the property that was changed
+ * @param oldValue the old value of the property
+ * @param newValue the new value of the property
+ *
+ * @throws IllegalArgumentException if {@code source} is {@code null}
*/
public PropertyChangeEvent(Object source, String propertyName,
- Object oldValue, Object newValue) {
+ Object oldValue, Object newValue) {
super(source);
this.propertyName = propertyName;
this.newValue = newValue;
--- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java Thu Dec 15 19:52:13 2011 -0800
@@ -454,10 +454,7 @@
editor = ctor.newInstance(new Object[] { bean });
}
} catch (Exception ex) {
- // A serious error has occured.
- // Proably due to an invalid property editor.
- throw new RuntimeException("PropertyEditor not instantiated",
- ex);
+ // Fall through
}
}
return (PropertyEditor)editor;
--- a/jdk/src/share/classes/java/beans/PropertyEditorManager.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/PropertyEditorManager.java Thu Dec 15 19:52:13 2011 -0800
@@ -25,9 +25,6 @@
package java.beans;
-import com.sun.beans.finder.PropertyEditorFinder;
-import sun.awt.AppContext;
-
/**
* The PropertyEditorManager can be used to locate a property editor for
* any given type name. This property editor must support the
@@ -55,8 +52,6 @@
public class PropertyEditorManager {
- private static final Object FINDER_KEY = new Object();
-
/**
* Registers an editor class to edit values of the given target class.
* If the editor class is {@code null},
@@ -81,7 +76,7 @@
if (sm != null) {
sm.checkPropertiesAccess();
}
- getFinder().register(targetType, editorClass);
+ ThreadGroupContext.getContext().getPropertyEditorFinder().register(targetType, editorClass);
}
/**
@@ -92,7 +87,7 @@
* The result is null if no suitable editor can be found.
*/
public static PropertyEditor findEditor(Class<?> targetType) {
- return getFinder().find(targetType);
+ return ThreadGroupContext.getContext().getPropertyEditorFinder().find(targetType);
}
/**
@@ -104,7 +99,7 @@
* e.g. Sun implementation initially sets to {"sun.beans.editors"}.
*/
public static String[] getEditorSearchPath() {
- return getFinder().getPackages();
+ return ThreadGroupContext.getContext().getPropertyEditorFinder().getPackages();
}
/**
@@ -125,17 +120,6 @@
if (sm != null) {
sm.checkPropertiesAccess();
}
- getFinder().setPackages(path);
- }
-
- private static PropertyEditorFinder getFinder() {
- AppContext context = AppContext.getAppContext();
- Object object = context.get(FINDER_KEY);
- if (object instanceof PropertyEditorFinder) {
- return (PropertyEditorFinder) object;
- }
- PropertyEditorFinder finder = new PropertyEditorFinder();
- context.put(FINDER_KEY, finder);
- return finder;
+ ThreadGroupContext.getContext().getPropertyEditorFinder().setPackages(path);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/beans/ThreadGroupContext.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.beans;
+
+import com.sun.beans.finder.BeanInfoFinder;
+import com.sun.beans.finder.PropertyEditorFinder;
+
+import java.awt.GraphicsEnvironment;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * The {@code ThreadGroupContext} is an application-dependent
+ * context referenced by the specific {@link ThreadGroup}.
+ * This is a replacement for the {@link sun.awt.AppContext}.
+ *
+ * @author Sergey Malenkov
+ */
+final class ThreadGroupContext {
+
+ private static final Map<ThreadGroup, ThreadGroupContext> contexts = new WeakHashMap<>();
+
+ /**
+ * Returns the appropriate {@code AppContext} for the caller,
+ * as determined by its {@code ThreadGroup}.
+ *
+ * @return the application-dependent context
+ */
+ static ThreadGroupContext getContext() {
+ ThreadGroup group = Thread.currentThread().getThreadGroup();
+ synchronized (contexts) {
+ ThreadGroupContext context = contexts.get(group);
+ if (context == null) {
+ context = new ThreadGroupContext();
+ contexts.put(group, context);
+ }
+ return context;
+ }
+ }
+
+ private volatile boolean isDesignTime;
+ private volatile Boolean isGuiAvailable;
+
+ private Map<Class<?>, BeanInfo> beanInfoCache;
+ private BeanInfoFinder beanInfoFinder;
+ private PropertyEditorFinder propertyEditorFinder;
+
+
+ boolean isDesignTime() {
+ return this.isDesignTime;
+ }
+
+ void setDesignTime(boolean isDesignTime) {
+ this.isDesignTime = isDesignTime;
+ }
+
+
+ boolean isGuiAvailable() {
+ Boolean isGuiAvailable = this.isGuiAvailable;
+ return (isGuiAvailable != null)
+ ? isGuiAvailable.booleanValue()
+ : !GraphicsEnvironment.isHeadless();
+ }
+
+ void setGuiAvailable(boolean isGuiAvailable) {
+ this.isGuiAvailable = Boolean.valueOf(isGuiAvailable);
+ }
+
+
+ BeanInfo getBeanInfo(Class<?> type) {
+ return (this.beanInfoCache != null)
+ ? this.beanInfoCache.get(type)
+ : null;
+ }
+
+ BeanInfo putBeanInfo(Class<?> type, BeanInfo info) {
+ if (this.beanInfoCache == null) {
+ this.beanInfoCache = new WeakHashMap<>();
+ }
+ return this.beanInfoCache.put(type, info);
+ }
+
+ void removeBeanInfo(Class<?> type) {
+ if (this.beanInfoCache != null) {
+ this.beanInfoCache.remove(type);
+ }
+ }
+
+ void clearBeanInfoCache() {
+ if (this.beanInfoCache != null) {
+ this.beanInfoCache.clear();
+ }
+ }
+
+
+ synchronized BeanInfoFinder getBeanInfoFinder() {
+ if (this.beanInfoFinder == null) {
+ this.beanInfoFinder = new BeanInfoFinder();
+ }
+ return this.beanInfoFinder;
+ }
+
+ synchronized PropertyEditorFinder getPropertyEditorFinder() {
+ if (this.propertyEditorFinder == null) {
+ this.propertyEditorFinder = new PropertyEditorFinder();
+ }
+ return this.propertyEditorFinder;
+ }
+}
--- a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Thu Dec 15 19:52:13 2011 -0800
@@ -403,6 +403,10 @@
* @see MouseListener#mouseClicked
*/
public void mouseClicked(MouseEvent e) {
+ if (getComponent() == null) {
+ return;
+ }
+
int nclicks = SwingUtilities2.getAdjustedClickCount(getComponent(), e);
if (! e.isConsumed()) {
--- a/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java Thu Dec 15 19:52:13 2011 -0800
@@ -323,8 +323,8 @@
}
public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
- if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
- sg2d.compositeState <= sg2d.COMP_ISCOPY)
+ if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
+ sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY)
{
return solidloops;
}
--- a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java Thu Dec 15 19:52:13 2011 -0800
@@ -941,7 +941,7 @@
}
}
}
- Class paintClass = paint.getClass();
+ Class<? extends Paint> paintClass = paint.getClass();
if (paintClass == GradientPaint.class) {
paintState = PAINT_GRADIENT;
} else if (paintClass == LinearGradientPaint.class) {
@@ -1280,7 +1280,7 @@
interpolationHint = -1;
interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;
boolean customHintPresent = false;
- Iterator iter = hints.keySet().iterator();
+ Iterator<?> iter = hints.keySet().iterator();
while (iter.hasNext()) {
Object key = iter.next();
if (key == SunHints.KEY_RENDERING ||
@@ -1311,7 +1311,7 @@
*/
public void addRenderingHints(Map<?,?> hints) {
boolean customHintPresent = false;
- Iterator iter = hints.keySet().iterator();
+ Iterator<?> iter = hints.keySet().iterator();
while (iter.hasNext()) {
Object key = iter.next();
if (key == SunHints.KEY_RENDERING ||
--- a/jdk/src/share/classes/sun/java2d/SurfaceData.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/SurfaceData.java Thu Dec 15 19:52:13 2011 -0800
@@ -520,8 +520,8 @@
}
public boolean canRenderParallelograms(SunGraphics2D sg2d) {
- if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
- if (sg2d.compositeState == sg2d.COMP_XOR) {
+ if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
+ if (sg2d.compositeState == SunGraphics2D.COMP_XOR) {
if (havePgramXORLoop == LOOP_UNKNOWN) {
FillParallelogram loop =
FillParallelogram.locate(SurfaceType.AnyColor,
@@ -531,9 +531,9 @@
(loop != null) ? LOOP_FOUND : LOOP_NOTFOUND;
}
return havePgramXORLoop == LOOP_FOUND;
- } else if (sg2d.compositeState <= sg2d.COMP_ISCOPY &&
+ } else if (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
- sg2d.clipState != sg2d.CLIP_SHAPE)
+ sg2d.clipState != SunGraphics2D.CLIP_SHAPE)
{
if (havePgramSolidLoop == LOOP_UNKNOWN) {
FillParallelogram loop =
@@ -551,8 +551,8 @@
public void validatePipe(SunGraphics2D sg2d) {
sg2d.imagepipe = imagepipe;
- if (sg2d.compositeState == sg2d.COMP_XOR) {
- if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) {
+ if (sg2d.compositeState == SunGraphics2D.COMP_XOR) {
+ if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
sg2d.drawpipe = paintViaShape;
sg2d.fillpipe = paintViaShape;
sg2d.shapepipe = paintShape;
@@ -576,7 +576,7 @@
converter = colorViaShape;
sg2d.shapepipe = colorPrimitives;
}
- if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+ if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
sg2d.drawpipe = converter;
sg2d.fillpipe = converter;
// REMIND: We should not be changing text strategies
@@ -589,11 +589,11 @@
// which is not defined for XOR.
sg2d.textpipe = outlineTextRenderer;
} else {
- if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+ if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
sg2d.drawpipe = converter;
sg2d.fillpipe = converter;
} else {
- if (sg2d.strokeState != sg2d.STROKE_THIN) {
+ if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
sg2d.drawpipe = converter;
} else {
sg2d.drawpipe = colorPrimitives;
@@ -604,9 +604,9 @@
}
// assert(sg2d.surfaceData == this);
}
- } else if (sg2d.compositeState == sg2d.COMP_CUSTOM) {
+ } else if (sg2d.compositeState == SunGraphics2D.COMP_CUSTOM) {
if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON) {
- if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+ if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
sg2d.drawpipe = AAClipCompViaShape;
sg2d.fillpipe = AAClipCompViaShape;
sg2d.shapepipe = AAClipCompViaShape;
@@ -621,7 +621,7 @@
sg2d.drawpipe = compViaShape;
sg2d.fillpipe = compViaShape;
sg2d.shapepipe = compShape;
- if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+ if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
sg2d.textpipe = clipCompText;
} else {
sg2d.textpipe = compText;
@@ -631,7 +631,7 @@
sg2d.alphafill = getMaskFill(sg2d);
// assert(sg2d.surfaceData == this);
if (sg2d.alphafill != null) {
- if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+ if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
sg2d.drawpipe = AAClipColorViaShape;
sg2d.fillpipe = AAClipColorViaShape;
sg2d.shapepipe = AAClipColorViaShape;
@@ -644,8 +644,8 @@
sg2d.drawpipe = converter;
sg2d.fillpipe = converter;
sg2d.shapepipe = converter;
- if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR ||
- sg2d.compositeState > sg2d.COMP_ISCOPY)
+ if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR ||
+ sg2d.compositeState > SunGraphics2D.COMP_ISCOPY)
{
sg2d.textpipe = colorText;
} else {
@@ -653,7 +653,7 @@
}
}
} else {
- if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+ if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
sg2d.drawpipe = AAClipPaintViaShape;
sg2d.fillpipe = AAClipPaintViaShape;
sg2d.shapepipe = AAClipPaintViaShape;
@@ -665,9 +665,9 @@
sg2d.textpipe = paintText;
}
}
- } else if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR ||
- sg2d.compositeState > sg2d.COMP_ISCOPY ||
- sg2d.clipState == sg2d.CLIP_SHAPE)
+ } else if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR ||
+ sg2d.compositeState > SunGraphics2D.COMP_ISCOPY ||
+ sg2d.clipState == SunGraphics2D.CLIP_SHAPE)
{
sg2d.drawpipe = paintViaShape;
sg2d.fillpipe = paintViaShape;
@@ -675,13 +675,13 @@
sg2d.alphafill = getMaskFill(sg2d);
// assert(sg2d.surfaceData == this);
if (sg2d.alphafill != null) {
- if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+ if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
sg2d.textpipe = clipColorText;
} else {
sg2d.textpipe = colorText;
}
} else {
- if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+ if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
sg2d.textpipe = clipPaintText;
} else {
sg2d.textpipe = paintText;
@@ -700,11 +700,11 @@
converter = colorViaShape;
sg2d.shapepipe = colorPrimitives;
}
- if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+ if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
sg2d.drawpipe = converter;
sg2d.fillpipe = converter;
} else {
- if (sg2d.strokeState != sg2d.STROKE_THIN) {
+ if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
sg2d.drawpipe = converter;
} else {
sg2d.drawpipe = colorPrimitives;
@@ -817,7 +817,7 @@
private static CompositeType getFillCompositeType(SunGraphics2D sg2d) {
CompositeType compType = sg2d.imageComp;
- if (sg2d.compositeState == sg2d.COMP_ISCOPY) {
+ if (sg2d.compositeState == SunGraphics2D.COMP_ISCOPY) {
if (compType == CompositeType.SrcOverNoEa) {
compType = CompositeType.OpaqueSrcOverNoEa;
} else {
--- a/jdk/src/share/classes/sun/java2d/SurfaceDataProxy.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/SurfaceDataProxy.java Thu Dec 15 19:52:13 2011 -0800
@@ -71,7 +71,7 @@
static {
cachingAllowed = true;
- String manimg = (String)AccessController.doPrivileged(
+ String manimg = AccessController.doPrivileged(
new GetPropertyAction("sun.java2d.managedimages"));
if (manimg != null && manimg.equals("false")) {
cachingAllowed = false;
@@ -79,7 +79,7 @@
}
defaultThreshold = 1;
- String num = (String)AccessController.doPrivileged(
+ String num = AccessController.doPrivileged(
new GetPropertyAction("sun.java2d.accthreshold"));
if (num != null) {
try {
--- a/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java Thu Dec 15 19:52:13 2011 -0800
@@ -328,7 +328,7 @@
static {
GetPropertyAction gpa = new GetPropertyAction("sun.java2d.trace");
- String trace = (String)AccessController.doPrivileged(gpa);
+ String trace = AccessController.doPrivileged(gpa);
if (trace != null) {
boolean verbose = false;
int traceflags = 0;
@@ -391,9 +391,9 @@
private static PrintStream getTraceOutputFile() {
if (traceout == null) {
if (tracefile != null) {
- Object o =
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ FileOutputStream o = AccessController.doPrivileged(
+ new PrivilegedAction<FileOutputStream>() {
+ public FileOutputStream run() {
try {
return new FileOutputStream(tracefile);
} catch (FileNotFoundException e) {
@@ -402,7 +402,7 @@
}
});
if (o != null) {
- traceout = new PrintStream((OutputStream) o);
+ traceout = new PrintStream(o);
} else {
traceout = System.err;
}
@@ -415,8 +415,8 @@
public static class TraceReporter extends Thread {
public static void setShutdownHook() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
TraceReporter t = new TraceReporter();
t.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(t);
--- a/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java Thu Dec 15 19:52:13 2011 -0800
@@ -56,7 +56,7 @@
public final class SurfaceType {
private static int unusedUID = 1;
- private static HashMap surfaceUIDMap = new HashMap(100);
+ private static HashMap<String, Integer> surfaceUIDMap = new HashMap<>(100);
/*
* CONSTANTS USED BY ALL PRIMITIVES TO DESCRIBE THE SURFACES
@@ -402,7 +402,7 @@
}
public synchronized static final int makeUniqueID(String desc) {
- Integer i = (Integer) surfaceUIDMap.get((Object) desc);
+ Integer i = surfaceUIDMap.get(desc);
if (i == null) {
if (unusedUID > 255) {
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLBufImgOps.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLBufImgOps.java Thu Dec 15 19:52:13 2011 -0800
@@ -78,12 +78,12 @@
}
SurfaceData srcData =
- dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
+ dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
CompositeType.SrcOver, null);
if (!(srcData instanceof OGLSurfaceData)) {
// REMIND: this hack tries to ensure that we have a cached texture
srcData =
- dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
+ dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
CompositeType.SrcOver, null);
if (!(srcData instanceof OGLSurfaceData)) {
return false;
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLDrawImage.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLDrawImage.java Thu Dec 15 19:52:13 2011 -0800
@@ -60,7 +60,7 @@
SurfaceData dstData = sg.surfaceData;
SurfaceData srcData =
dstData.getSourceSurfaceData(img,
- sg.TRANSFORM_GENERIC,
+ SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLPaints.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLPaints.java Thu Dec 15 19:52:13 2011 -0800
@@ -123,14 +123,16 @@
}
SurfaceData srcData =
- dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
+ dstData.getSourceSurfaceData(bi,
+ SunGraphics2D.TRANSFORM_ISIDENT,
CompositeType.SrcOver, null);
if (!(srcData instanceof OGLSurfaceData)) {
// REMIND: this is a hack that attempts to cache the system
// memory image from the TexturePaint instance into an
// OpenGL texture...
srcData =
- dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
+ dstData.getSourceSurfaceData(bi,
+ SunGraphics2D.TRANSFORM_ISIDENT,
CompositeType.SrcOver, null);
if (!(srcData instanceof OGLSurfaceData)) {
return false;
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java Thu Dec 15 19:52:13 2011 -0800
@@ -428,18 +428,18 @@
// by the CompositeType.SrcNoEa (any color) test below.)
if (/* CompositeType.SrcNoEa (any color) */
- (sg2d.compositeState <= sg2d.COMP_ISCOPY &&
- sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) ||
+ (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
+ sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) ||
/* CompositeType.SrcOver (any color) */
- (sg2d.compositeState == sg2d.COMP_ALPHA &&
- sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
+ (sg2d.compositeState == SunGraphics2D.COMP_ALPHA &&
+ sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
(((AlphaComposite)sg2d.composite).getRule() ==
- AlphaComposite.SRC_OVER)) ||
+ AlphaComposite.SRC_OVER)) ||
/* CompositeType.Xor (any color) */
- (sg2d.compositeState == sg2d.COMP_XOR &&
- sg2d.paintState <= sg2d.PAINT_ALPHACOLOR))
+ (sg2d.compositeState == SunGraphics2D.COMP_XOR &&
+ sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR))
{
textpipe = oglTextPipe;
} else {
@@ -454,12 +454,12 @@
OGLRenderer nonTxPipe = null;
if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
- if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
- if (sg2d.compositeState <= sg2d.COMP_XOR) {
+ if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
+ if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
txPipe = oglTxRenderPipe;
nonTxPipe = oglRenderPipe;
}
- } else if (sg2d.compositeState <= sg2d.COMP_ALPHA) {
+ } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
if (OGLPaints.isValid(sg2d)) {
txPipe = oglTxRenderPipe;
nonTxPipe = oglRenderPipe;
@@ -467,7 +467,7 @@
// custom paints handled by super.validatePipe() below
}
} else {
- if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
+ if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
if (graphicsConfig.isCapPresent(CAPS_PS30) &&
(sg2d.imageComp == CompositeType.SrcOverNoEa ||
sg2d.imageComp == CompositeType.SrcOver))
@@ -484,7 +484,7 @@
sg2d.drawpipe = aaConverter;
sg2d.fillpipe = aaConverter;
sg2d.shapepipe = aaConverter;
- } else if (sg2d.compositeState == sg2d.COMP_XOR) {
+ } else if (sg2d.compositeState == SunGraphics2D.COMP_XOR) {
// install the solid pipes when AA and XOR are both enabled
txPipe = oglTxRenderPipe;
nonTxPipe = oglRenderPipe;
@@ -494,10 +494,10 @@
}
if (txPipe != null) {
- if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+ if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
sg2d.drawpipe = txPipe;
sg2d.fillpipe = txPipe;
- } else if (sg2d.strokeState != sg2d.STROKE_THIN) {
+ } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
sg2d.drawpipe = txPipe;
sg2d.fillpipe = nonTxPipe;
} else {
@@ -524,7 +524,7 @@
@Override
protected MaskFill getMaskFill(SunGraphics2D sg2d) {
- if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) {
+ if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
/*
* We can only accelerate non-Color MaskFill operations if
* all of the following conditions hold true:
@@ -548,8 +548,8 @@
public boolean copyArea(SunGraphics2D sg2d,
int x, int y, int w, int h, int dx, int dy)
{
- if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
- sg2d.compositeState < sg2d.COMP_XOR)
+ if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
+ sg2d.compositeState < SunGraphics2D.COMP_XOR)
{
x += sg2d.transX;
y += sg2d.transY;
--- a/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java Thu Dec 15 19:52:13 2011 -0800
@@ -144,7 +144,7 @@
public void renderPath(SunGraphics2D sg, Shape s, BasicStroke bs) {
boolean adjust = (bs != null &&
sg.strokeHint != SunHints.INTVAL_STROKE_PURE);
- boolean thin = (sg.strokeState <= sg.STROKE_THINDASHED);
+ boolean thin = (sg.strokeState <= SunGraphics2D.STROKE_THINDASHED);
Region clip = sg.getCompClip();
int abox[] = new int[4];
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java Thu Dec 15 19:52:13 2011 -0800
@@ -247,7 +247,7 @@
BufferedImage bi = paint.getImage();
SurfaceData dstData = sg2d.surfaceData;
SurfaceData srcData =
- dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
+ dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT,
CompositeType.SrcOver, null);
boolean filter =
(sg2d.interpolationType !=
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java Thu Dec 15 19:52:13 2011 -0800
@@ -508,9 +508,9 @@
}
public void draw(SunGraphics2D sg2d, Shape s) {
- if (sg2d.strokeState == sg2d.STROKE_THIN) {
+ if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
if (s instanceof Polygon) {
- if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE) {
+ if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
Polygon p = (Polygon)s;
drawPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
return;
@@ -518,7 +518,7 @@
}
Path2D.Float p2df;
int transx, transy;
- if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+ if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
if (s instanceof Path2D.Float) {
p2df = (Path2D.Float)s;
} else {
@@ -532,7 +532,7 @@
transy = 0;
}
drawPath(sg2d, p2df, transx, transy);
- } else if (sg2d.strokeState < sg2d.STROKE_CUSTOM) {
+ } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
try {
fillSpans(sg2d, si, 0, 0);
@@ -547,11 +547,11 @@
public void fill(SunGraphics2D sg2d, Shape s) {
int transx, transy;
- if (sg2d.strokeState == sg2d.STROKE_THIN) {
+ if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
// Here we are able to use fillPath() for
// high-quality fills.
Path2D.Float p2df;
- if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+ if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
if (s instanceof Path2D.Float) {
p2df = (Path2D.Float)s;
} else {
@@ -569,7 +569,7 @@
}
AffineTransform at;
- if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+ if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
// Transform (translation) will be done by FillSpans (we could
// delegate to fillPolygon() here, but most hardware accelerated
// libraries cannot handle non-convex polygons, so we will use
--- a/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java Thu Dec 15 19:52:13 2011 -0800
@@ -146,7 +146,7 @@
int imgh = img.getHeight(null);
boolean checkfinalxform;
- if (sg.transformState <= sg.TRANSFORM_ANY_TRANSLATE &&
+ if (sg.transformState <= SunGraphics2D.TRANSFORM_ANY_TRANSLATE &&
(txtype == AffineTransform.TYPE_IDENTITY ||
txtype == AffineTransform.TYPE_TRANSLATION))
{
@@ -166,7 +166,7 @@
return;
}
checkfinalxform = false;
- } else if (sg.transformState <= sg.TRANSFORM_TRANSLATESCALE &&
+ } else if (sg.transformState <= SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
((txtype & (AffineTransform.TYPE_FLIP |
AffineTransform.TYPE_MASK_ROTATION |
AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0))
@@ -344,14 +344,14 @@
Region clip = sg.getCompClip();
SurfaceData dstData = sg.surfaceData;
SurfaceData srcData = dstData.getSourceSurfaceData(img,
- sg.TRANSFORM_GENERIC,
+ SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
if (srcData == null) {
img = getBufferedImage(img);
srcData = dstData.getSourceSurfaceData(img,
- sg.TRANSFORM_GENERIC,
+ SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
if (srcData == null) {
@@ -372,7 +372,7 @@
sx1 = sy1 = 0;
srcData = dstData.getSourceSurfaceData(img,
- sg.TRANSFORM_GENERIC,
+ SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
}
@@ -398,7 +398,7 @@
sx1 = sy1 = 0;
srcData = dstData.getSourceSurfaceData(img,
- sg.TRANSFORM_GENERIC,
+ SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
null);
srcType = srcData.getSurfaceType();
@@ -449,7 +449,7 @@
SurfaceType dstType = dstData.getSurfaceType();
MaskBlit maskblit;
Blit blit;
- if (sg.compositeState <= sg.COMP_ALPHA) {
+ if (sg.compositeState <= SunGraphics2D.COMP_ALPHA) {
/* NOTE: We either have, or we can make,
* a MaskBlit for any alpha composite type
*/
@@ -565,7 +565,7 @@
while (true) {
SurfaceData srcData =
dstData.getSourceSurfaceData(img,
- sg.TRANSFORM_ISIDENT,
+ SunGraphics2D.TRANSFORM_ISIDENT,
sg.imageComp,
bgColor);
if (srcData == null) {
@@ -628,7 +628,7 @@
while (true) {
SurfaceData srcData =
dstData.getSourceSurfaceData(img,
- sg.TRANSFORM_TRANSLATESCALE,
+ SunGraphics2D.TRANSFORM_TRANSLATESCALE,
sg.imageComp,
bgColor);
@@ -800,11 +800,11 @@
public static boolean isSimpleTranslate(SunGraphics2D sg) {
int ts = sg.transformState;
- if (ts <= sg.TRANSFORM_INT_TRANSLATE) {
+ if (ts <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
// Integer translates are always "simple"
return true;
}
- if (ts >= sg.TRANSFORM_TRANSLATESCALE) {
+ if (ts >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
// Scales and beyond are always "not simple"
return false;
}
@@ -846,8 +846,11 @@
}
int type = tx.getType();
boolean needTrans =
- ((type&(tx.TYPE_MASK_ROTATION|tx.TYPE_GENERAL_TRANSFORM)) != 0);
- if (! needTrans && type != tx.TYPE_TRANSLATION && type != tx.TYPE_IDENTITY)
+ ((type & (AffineTransform.TYPE_MASK_ROTATION |
+ AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0);
+ if (! needTrans &&
+ type != AffineTransform.TYPE_TRANSLATION &&
+ type != AffineTransform.TYPE_IDENTITY)
{
double[] mtx = new double[4];
tx.getMatrix(mtx);
@@ -861,7 +864,7 @@
Raster raster = bImg.getRaster();
IndexColorModel icm = (IndexColorModel) cm;
// Just need to make sure that we have a transparent pixel
- if (needTrans && cm.getTransparency() == cm.OPAQUE) {
+ if (needTrans && cm.getTransparency() == Transparency.OPAQUE) {
// Fix 4221407
if (raster instanceof sun.awt.image.BytePackedRaster) {
dstCM = ColorModel.getRGBdefault();
@@ -892,7 +895,7 @@
} /* raster instanceof sun.awt.image.BytePackedRaster */
} /* if (cm.getTransparency() == cm.OPAQUE) */
} /* if (cm instanceof IndexColorModel) */
- else if (needTrans && cm.getTransparency() == cm.OPAQUE) {
+ else if (needTrans && cm.getTransparency() == Transparency.OPAQUE) {
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
// for bitmask
@@ -902,7 +905,7 @@
else {
if (cm instanceof IndexColorModel ||
- (needTrans && cm.getTransparency() == cm.OPAQUE))
+ (needTrans && cm.getTransparency() == Transparency.OPAQUE))
{
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
--- a/jdk/src/share/classes/sun/java2d/pipe/GlyphListPipe.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/GlyphListPipe.java Thu Dec 15 19:52:13 2011 -0800
@@ -54,7 +54,7 @@
}
float devx, devy;
- if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+ if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
double origin[] = {x + info.originX, y + info.originY};
sg2d.transform.transform(origin, 0, origin, 0, 1);
devx = (float)origin[0];
@@ -90,7 +90,7 @@
sg2d, data, offset, length, ix, iy);
return;
}
- if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+ if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
double origin[] = {ix + info.originX, iy + info.originY};
sg2d.transform.transform(origin, 0, origin, 0, 1);
x = (float) origin[0];
@@ -122,7 +122,7 @@
SurfaceData.outlineTextRenderer.drawGlyphVector(sg2d, gv, x, y);
return;
}
- if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+ if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
double origin[] = {x, y};
sg2d.transform.transform(origin, 0, origin, 0, 1);
x = (float) origin[0];
--- a/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java Thu Dec 15 19:52:13 2011 -0800
@@ -171,11 +171,11 @@
public void draw(SunGraphics2D sg2d, Shape s) {
- if (sg2d.strokeState == sg2d.STROKE_THIN) {
+ if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
Path2D.Float p2df;
int transX;
int transY;
- if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+ if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
if (s instanceof Path2D.Float) {
p2df = (Path2D.Float)s;
} else {
@@ -193,7 +193,7 @@
return;
}
- if (sg2d.strokeState == sg2d.STROKE_CUSTOM) {
+ if (sg2d.strokeState == SunGraphics2D.STROKE_CUSTOM) {
fill(sg2d, sg2d.stroke.createStrokedShape(s));
return;
}
@@ -271,7 +271,7 @@
sr.setRule(PathIterator.WIND_NON_ZERO);
BasicStroke bs = (BasicStroke) sg2d.stroke;
- boolean thin = (sg2d.strokeState <= sg2d.STROKE_THINDASHED);
+ boolean thin = (sg2d.strokeState <= SunGraphics2D.STROKE_THINDASHED);
boolean normalize =
(sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE);
@@ -288,11 +288,11 @@
}
public void fill(SunGraphics2D sg2d, Shape s) {
- if (sg2d.strokeState == sg2d.STROKE_THIN) {
+ if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
Path2D.Float p2df;
int transX;
int transY;
- if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+ if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
if (s instanceof Path2D.Float) {
p2df = (Path2D.Float)s;
} else {
@@ -314,7 +314,7 @@
try {
sr.setOutputArea(sg2d.getCompClip());
AffineTransform at =
- ((sg2d.transformState == sg2d.TRANSFORM_ISIDENT)
+ ((sg2d.transformState == SunGraphics2D.TRANSFORM_ISIDENT)
? null
: sg2d.transform);
sr.appendPath(s.getPathIterator(at));
@@ -328,7 +328,7 @@
// REMIND: Eventually, the plan is that it will not be possible for
// fs to be null since the FillSpans loop will be the fundamental
// loop implemented for any destination type...
- if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+ if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
si = sg2d.clipRegion.filter(si);
// REMIND: Region.filter produces a Java-only iterator
// with no native counterpart...
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java Thu Dec 15 19:52:13 2011 -0800
@@ -117,16 +117,16 @@
return reImpl;
}
- reImpl = (RenderingEngine)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ reImpl =
+ AccessController.doPrivileged(new PrivilegedAction<RenderingEngine>() {
+ public RenderingEngine run() {
final String ductusREClass = "sun.dc.DuctusRenderingEngine";
String reClass =
System.getProperty("sun.java2d.renderer", ductusREClass);
if (reClass.equals(ductusREClass)) {
try {
- Class cls = Class.forName(ductusREClass);
- return cls.newInstance();
+ Class<?> cls = Class.forName(ductusREClass);
+ return (RenderingEngine) cls.newInstance();
} catch (ReflectiveOperationException ignored) {
// not found
}
@@ -153,7 +153,7 @@
GetPropertyAction gpa =
new GetPropertyAction("sun.java2d.renderer.trace");
- String reTrace = (String) AccessController.doPrivileged(gpa);
+ String reTrace = AccessController.doPrivileged(gpa);
if (reTrace != null) {
reImpl = new Tracer(reImpl);
}
--- a/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java Thu Dec 15 19:52:13 2011 -0800
@@ -29,10 +29,8 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.AdjustmentEvent;
-import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
-import sun.awt.motif.X11FontMetrics;
import sun.util.logging.PlatformLogger;
// FIXME: implement multi-select
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java Thu Dec 15 19:52:13 2011 -0800
@@ -35,7 +35,6 @@
import java.awt.image.VolatileImage;
import java.awt.peer.*;
import sun.awt.*;
-import sun.awt.motif.X11FontMetrics;
import java.lang.reflect.*;
import sun.util.logging.PlatformLogger;
import java.util.*;
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java Thu Dec 15 19:52:13 2011 -0800
@@ -34,8 +34,6 @@
import java.awt.peer.*;
import sun.java2d.pipe.Region;
import sun.awt.*;
-import sun.awt.motif.MToolkit;
-import sun.awt.motif.X11FontMetrics;
public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
XEmbeddingContainer container;
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Thu Dec 15 19:52:13 2011 -0800
@@ -51,6 +51,7 @@
import sun.awt.*;
import sun.font.FontConfigManager;
import sun.font.FontManager;
+import sun.java2d.SunGraphicsEnvironment;
import sun.misc.PerformanceLogger;
import sun.print.PrintJob2D;
import sun.security.action.GetBooleanAction;
@@ -109,7 +110,7 @@
static int awt_multiclick_time;
static boolean securityWarningEnabled;
- private static int screenWidth = -1, screenHeight = -1; // Dimensions of default screen
+ private static volatile int screenWidth = -1, screenHeight = -1; // Dimensions of default screen
static long awt_defaultFg; // Pixel
private static XMouseInfoPeer xPeer;
private static Method m_removeSourceEvents;
@@ -310,6 +311,19 @@
System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
+
+ // Detect display mode changes
+ XlibWrapper.XSelectInput(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), XConstants.StructureNotifyMask);
+ XToolkit.addEventDispatcher(XToolkit.getDefaultRootWindow(), new XEventDispatcher() {
+ @Override
+ public void dispatchEvent(XEvent ev) {
+ if (ev.get_type() == XConstants.ConfigureNotify) {
+ ((X11GraphicsEnvironment)GraphicsEnvironment.
+ getLocalGraphicsEnvironment()).
+ displayChanged();
+ }
+ }
+ });
} finally {
awtUnlock();
}
@@ -684,29 +698,49 @@
}
}
- static int getDefaultScreenWidth() {
- if (screenWidth == -1) {
- long display = getDisplay();
+ static {
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ if (ge instanceof SunGraphicsEnvironment) {
+ ((SunGraphicsEnvironment)ge).addDisplayChangedListener(
+ new DisplayChangedListener() {
+ @Override
+ public void displayChanged() {
+ // 7045370: Reset the cached values
+ XToolkit.screenWidth = -1;
+ XToolkit.screenHeight = -1;
+ }
+
+ @Override
+ public void paletteChanged() {}
+ });
+ }
+ }
+
+ private static void initScreenSize() {
+ if (screenWidth == -1 || screenHeight == -1) {
awtLock();
try {
- screenWidth = (int) XlibWrapper.DisplayWidth(display, XlibWrapper.DefaultScreen(display));
+ XWindowAttributes pattr = new XWindowAttributes();
+ try {
+ XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), pattr.pData);
+ screenWidth = (int) pattr.get_width();
+ screenHeight = (int) pattr.get_height();
+ } finally {
+ pattr.dispose();
+ }
} finally {
awtUnlock();
}
}
+ }
+
+ static int getDefaultScreenWidth() {
+ initScreenSize();
return screenWidth;
}
static int getDefaultScreenHeight() {
- if (screenHeight == -1) {
- long display = getDisplay();
- awtLock();
- try {
- screenHeight = (int) XlibWrapper.DisplayHeight(display, XlibWrapper.DefaultScreen(display));
- } finally {
- awtUnlock();
- }
- }
+ initScreenSize();
return screenHeight;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Thu Dec 15 19:52:13 2011 -0800
@@ -208,12 +208,19 @@
return name;
}
+ private static native String getLocalHostname();
+ private static native int getJvmPID();
+
void postInit(XCreateWindowParams params) {
super.postInit(params);
// Init WM_PROTOCOLS atom
initWMProtocols();
+ // Set _NET_WM_PID and WM_CLIENT_MACHINE using this JVM
+ XAtom.get("WM_CLIENT_MACHINE").setProperty(getWindow(), getLocalHostname());
+ XAtom.get("_NET_WM_PID").setCard32Property(getWindow(), getJvmPID());
+
// Set WM_TRANSIENT_FOR and group_leader
Window t_window = (Window)target;
Window owner = t_window.getOwner();
--- a/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java Thu Dec 15 19:52:13 2011 -0800
@@ -487,14 +487,9 @@
* X11GraphicsEnvironment when the display mode has been changed.
*/
public synchronized void displayChanged() {
- // reset the list of configs (and default config)
- defaultConfig = null;
- configs = null;
- doubleBufferVisuals = null;
-
- // reset the native data structures associated with this device (they
- // will be reinitialized when the GraphicsConfigs are configured)
- resetNativeData(screen);
+ // On X11 the visuals do not change, and therefore we don't need
+ // to reset the defaultConfig, config, doubleBufferVisuals,
+ // neither do we need to reset the native data.
// pass on to all top-level windows on this screen
topLevels.notifyListeners();
--- a/jdk/src/solaris/classes/sun/awt/motif/AWTLockAccess.java Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt.motif;
-
-final class AWTLockAccess {
- static native void awtLock();
- static native void awtUnlock();
- static void awtWait() { awtWait(0); }
- static native void awtWait(long timeout);
- static native void awtNotifyAll();
-}
--- a/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java Thu Dec 15 19:52:13 2011 -0800
@@ -25,26 +25,19 @@
package sun.awt.motif;
-import java.awt.Font;
-import java.io.BufferedReader;
+import sun.awt.FontConfiguration;
+import sun.awt.X11FontManager;
+import sun.font.FontUtilities;
+import sun.font.SunFontManager;
+import sun.util.logging.PlatformLogger;
+
import java.io.File;
import java.io.FileInputStream;
-import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Locale;
import java.util.Properties;
import java.util.Scanner;
-import sun.awt.FontConfiguration;
-import sun.awt.X11FontManager;
-import sun.awt.X11GraphicsEnvironment;
-import sun.font.FontManager;
-import sun.font.SunFontManager;
-import sun.font.FontManagerFactory;
-import sun.font.FontUtilities;
-import sun.java2d.SunGraphicsEnvironment;
-import sun.util.logging.PlatformLogger;
public class MFontConfiguration extends FontConfiguration {
@@ -258,47 +251,6 @@
return Charset.forName("ISO8859_1");
}
- /* methods for Motif support *********************************************/
-
- private String[][] motifFontSets = new String[NUM_FONTS][NUM_STYLES];
-
- public String getMotifFontSet(String fontName, int style) {
- assert isLogicalFontFamilyName(fontName);
- fontName = fontName.toLowerCase(Locale.ENGLISH);
- int fontIndex = getFontIndex(fontName);
- int styleIndex = getStyleIndex(style);
- return getMotifFontSet(fontIndex, styleIndex);
- }
-
- private String getMotifFontSet(int fontIndex, int styleIndex) {
- String fontSet = motifFontSets[fontIndex][styleIndex];
- if (fontSet == null) {
- fontSet = buildMotifFontSet(fontIndex, styleIndex);
- motifFontSets[fontIndex][styleIndex] = fontSet;
- }
- return fontSet;
- }
-
- private String buildMotifFontSet(int fontIndex, int styleIndex) {
- StringBuilder buffer = new StringBuilder();
- short[] scripts = getCoreScripts(fontIndex);
- for (int i = 0; i < scripts.length; i++) {
- short nameID = getComponentFontIDMotif(scripts[i], fontIndex, styleIndex);
- if (nameID == 0) {
- nameID = getComponentFontID(scripts[i], fontIndex, styleIndex);
- }
- String name = getComponentFontName(nameID);
- if (name == null || name.endsWith("fontspecific")) {
- continue;
- }
- if (buffer.length() > 0) {
- buffer.append(',');
- }
- buffer.append(name);
- }
- return buffer.toString();
- }
-
protected String getFaceNameFromComponentFontName(String componentFontName) {
return null;
}
@@ -315,36 +267,6 @@
return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
- /**
- * Get default font for Motif widgets to use, preventing them from
- * wasting time accessing inappropriate X resources. This is called
- * only from native code.
- *
- * This is part of a Motif specific performance enhancement. By
- * default, when Motif widgets are created and initialized, Motif will
- * set up default fonts for the widgets, which we ALWAYS override.
- * This set up includes finding the default font in the widget's X
- * resources and fairly expensive requests of the X server to identify
- * the specific font or fontset. We avoid all of this overhead by
- * providing a well known font to use at the creation of widgets, where
- * possible.
- *
- * The X11 fonts are specified by XLFD strings which have %d as a
- * marker to indicate where the fontsize should be substituted. [The
- * libc function sprintf() is used to replace it.] The value 140
- * specifies a font size of 14 points.
- */
- private static String getDefaultMotifFontSet() {
- String font = ((MFontConfiguration) getFontConfiguration()).getMotifFontSet("sansserif", Font.PLAIN);
- if (font != null) {
- int i;
- while ((i = font.indexOf("%d")) >= 0) {
- font = font.substring(0, i) + "140" + font.substring(i+2);
- }
- }
- return font;
- }
-
public HashSet<String> getAWTFontPathSet() {
HashSet<String> fontDirs = new HashSet<String>();
short[] scripts = getCoreScripts(0);
--- a/jdk/src/solaris/classes/sun/awt/motif/MFontPeer.java Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.awt.motif;
-
-import java.awt.GraphicsEnvironment;
-import sun.awt.PlatformFont;
-
-public class MFontPeer extends PlatformFont {
-
- /*
- * XLFD name for XFontSet.
- */
- private String xfsname;
-
- /*
- * converter name for this XFontSet encoding.
- */
- private String converter;
-
- static {
- if (!GraphicsEnvironment.isHeadless()) {
- initIDs();
- }
- }
-
- /**
- * Initialize JNI field and method IDs for fields that may be
- accessed from C.
- */
- private static native void initIDs();
-
- public MFontPeer(String name, int style){
- super(name, style);
-
- if (fontConfig != null) {
- xfsname = ((MFontConfiguration) fontConfig).getMotifFontSet(familyName, style);
- }
- }
-
- protected char getMissingGlyphCharacter() {
- return '\u274F';
- }
-}
--- a/jdk/src/solaris/classes/sun/awt/motif/MToolkit.java Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,849 +0,0 @@
-/*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt.motif;
-
-import java.awt.*;
-import java.awt.im.InputMethodHighlight;
-import java.awt.im.spi.InputMethodDescriptor;
-import java.awt.image.*;
-import java.awt.peer.*;
-import java.awt.datatransfer.Clipboard;
-import java.awt.event.*;
-import java.lang.reflect.*;
-import java.lang.Math;
-import java.io.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import java.util.Properties;
-import java.util.Map;
-import java.util.Iterator;
-
-import sun.awt.AppContext;
-import sun.awt.AWTAutoShutdown;
-import sun.awt.SunToolkit;
-import sun.awt.UNIXToolkit;
-import sun.awt.GlobalCursorManager;
-import sun.awt.datatransfer.DataTransferer;
-
-import java.awt.dnd.DragSource;
-import java.awt.dnd.DragGestureListener;
-import java.awt.dnd.DragGestureEvent;
-import java.awt.dnd.DragGestureRecognizer;
-import java.awt.dnd.MouseDragGestureRecognizer;
-import java.awt.dnd.InvalidDnDOperationException;
-import java.awt.dnd.peer.DragSourceContextPeer;
-
-//import sun.awt.motif.MInputMethod;
-import sun.awt.X11FontManager;
-import sun.awt.X11GraphicsConfig;
-import sun.awt.X11GraphicsEnvironment;
-import sun.awt.XSettings;
-
-//import sun.awt.motif.MDragSourceContextPeer;
-
-import sun.print.PrintJob2D;
-
-import sun.misc.PerformanceLogger;
-import sun.misc.Unsafe;
-
-import sun.security.action.GetBooleanAction;
-import sun.util.logging.PlatformLogger;
-
-public class MToolkit extends UNIXToolkit implements Runnable {
-
- private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.motif.MToolkit");
-
- // the system clipboard - CLIPBOARD selection
- //X11Clipboard clipboard;
- // the system selection - PRIMARY selection
- //X11Clipboard selection;
-
- // Dynamic Layout Resize client code setting
- protected static boolean dynamicLayoutSetting = false;
-
- /**
- * True when the x settings have been loaded.
- */
- private boolean loadedXSettings;
-
- /**
- * XSETTINGS for the default screen.
- * <p>
- * <strong>XXX:</strong> see <code>MToolkit.parseXSettings</code>
- * and <code>awt_xsettings_update</code> in
- * <samp>awt_MToolkit.c</samp>
- */
- private XSettings xs;
-
- /*
- * Note: The MToolkit object depends on the static initializer
- * of X11GraphicsEnvironment to initialize the connection to
- * the X11 server.
- */
- static final X11GraphicsConfig config;
-
- private static final boolean motifdnd;
-
- static {
- if (GraphicsEnvironment.isHeadless()) {
- config = null;
- } else {
- config = (X11GraphicsConfig) (GraphicsEnvironment.
- getLocalGraphicsEnvironment().
- getDefaultScreenDevice().
- getDefaultConfiguration());
- }
-
- motifdnd = ((Boolean)java.security.AccessController.doPrivileged(
- new GetBooleanAction("awt.dnd.motifdnd"))).booleanValue();
- }
-
- //public static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.motif.MDataTransferer";
-
- public MToolkit() {
- super();
- if (PerformanceLogger.loggingEnabled()) {
- PerformanceLogger.setTime("MToolkit construction");
- }
- if (!GraphicsEnvironment.isHeadless()) {
- String mainClassName = null;
-
- StackTraceElement trace[] = (new Throwable()).getStackTrace();
- int bottom = trace.length - 1;
- if (bottom >= 0) {
- mainClassName = trace[bottom].getClassName();
- }
- if (mainClassName == null || mainClassName.equals("")) {
- mainClassName = "AWT";
- }
-
- init(mainClassName);
- //SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
-
- Thread toolkitThread = new Thread(this, "AWT-Motif");
- toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
- toolkitThread.setDaemon(true);
-
- PrivilegedAction<Void> a = new PrivilegedAction<Void>() {
- public Void run() {
- ThreadGroup mainTG = Thread.currentThread().getThreadGroup();
- ThreadGroup parentTG = mainTG.getParent();
-
- while (parentTG != null) {
- mainTG = parentTG;
- parentTG = mainTG.getParent();
- }
- Thread shutdownThread = new Thread(mainTG, new Runnable() {
- public void run() {
- shutdown();
- }
- }, "Shutdown-Thread");
- shutdownThread.setContextClassLoader(null);
- Runtime.getRuntime().addShutdownHook(shutdownThread);
- return null;
- }
- };
- AccessController.doPrivileged(a);
-
- /*
- * Fix for 4701990.
- * AWTAutoShutdown state must be changed before the toolkit thread
- * starts to avoid race condition.
- */
- AWTAutoShutdown.notifyToolkitThreadBusy();
-
- toolkitThread.start();
- }
- }
-
- public native void init(String mainClassName);
- public native void run();
- private native void shutdown();
-
- /*
- * Create peer objects.
- */
-
- public ButtonPeer createButton(Button target) {
- //ButtonPeer peer = new MButtonPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public TextFieldPeer createTextField(TextField target) {
- //TextFieldPeer peer = new MTextFieldPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public LabelPeer createLabel(Label target) {
- //LabelPeer peer = new MLabelPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public ListPeer createList(List target) {
- //ListPeer peer = new MListPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public CheckboxPeer createCheckbox(Checkbox target) {
- //CheckboxPeer peer = new MCheckboxPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public ScrollbarPeer createScrollbar(Scrollbar target) {
- //ScrollbarPeer peer = new MScrollbarPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public ScrollPanePeer createScrollPane(ScrollPane target) {
- //ScrollPanePeer peer = new MScrollPanePeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public TextAreaPeer createTextArea(TextArea target) {
- //TextAreaPeer peer = new MTextAreaPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public ChoicePeer createChoice(Choice target) {
- //ChoicePeer peer = new MChoicePeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public FramePeer createFrame(Frame target) {
- //FramePeer peer = new MFramePeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public CanvasPeer createCanvas(Canvas target) {
- //CanvasPeer peer = (isXEmbedServerRequested() ? new MEmbedCanvasPeer(target) : new MCanvasPeer(target));
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public PanelPeer createPanel(Panel target) {
- //PanelPeer peer = new MPanelPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public WindowPeer createWindow(Window target) {
- //WindowPeer peer = new MWindowPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public DialogPeer createDialog(Dialog target) {
- //DialogPeer peer = new MDialogPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public FileDialogPeer createFileDialog(FileDialog target) {
- //FileDialogPeer peer = new MFileDialogPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public MenuBarPeer createMenuBar(MenuBar target) {
- //MenuBarPeer peer = new MMenuBarPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public MenuPeer createMenu(Menu target) {
- //MenuPeer peer = new MMenuPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public PopupMenuPeer createPopupMenu(PopupMenu target) {
- //PopupMenuPeer peer = new MPopupMenuPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public MenuItemPeer createMenuItem(MenuItem target) {
- //MenuItemPeer peer = new MMenuItemPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) {
- //CheckboxMenuItemPeer peer = new MCheckboxMenuItemPeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- return null;
- }
-
- public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
- return null;
- }
-
- //public MEmbeddedFramePeer createEmbeddedFrame(MEmbeddedFrame target)
- //{
- //MEmbeddedFramePeer peer = new MEmbeddedFramePeer(target);
- //targetCreatedPeer(target, peer);
- //return peer;
- // return null;
- //}
-
-
- public FontPeer getFontPeer(String name, int style){
- return new MFontPeer(name, style);
- }
-
- /*
- * On X, support for dynamic layout on resizing is governed by the
- * window manager. If the window manager supports it, it happens
- * automatically. The setter method for this property is
- * irrelevant on X.
- */
- public void setDynamicLayout(boolean b) {
- dynamicLayoutSetting = b;
- }
-
- protected boolean isDynamicLayoutSet() {
- return dynamicLayoutSetting;
- }
-
- /* Called from isDynamicLayoutActive() and from
- * lazilyLoadDynamicLayoutSupportedProperty()
- */
- protected native boolean isDynamicLayoutSupportedNative();
-
- public boolean isDynamicLayoutActive() {
- return isDynamicLayoutSupportedNative();
- }
-
- public native boolean isFrameStateSupported(int state);
-
- public TrayIconPeer createTrayIcon(TrayIcon target) throws HeadlessException {
- return null;
- }
-
- public SystemTrayPeer createSystemTray(SystemTray target) throws HeadlessException {
- return null;
- }
-
- public boolean isTraySupported() {
- return false;
- }
-
- static native ColorModel makeColorModel();
- static ColorModel screenmodel;
-
- static ColorModel getStaticColorModel() {
- if (screenmodel == null) {
- screenmodel = config.getColorModel ();
- }
- return screenmodel;
- }
-
- public ColorModel getColorModel() {
- return getStaticColorModel();
- }
-
- public native int getScreenResolution();
-
- public Insets getScreenInsets(GraphicsConfiguration gc) {
- return new Insets(0,0,0,0);
- }
-
- protected native int getScreenWidth();
- protected native int getScreenHeight();
-
- public FontMetrics getFontMetrics(Font font) {
- /*
- // REMIND: platform font flag should be obsolete soon
- if (!RasterOutputManager.usesPlatformFont()) {
- return super.getFontMetrics(font);
- } else {
- return X11FontMetrics.getFontMetrics(font);
- }
- */
- return super.getFontMetrics(font);
- }
-
- public PrintJob getPrintJob(final Frame frame, final String doctitle,
- final Properties props) {
-
- if (GraphicsEnvironment.isHeadless()) {
- throw new IllegalArgumentException();
- }
-
- PrintJob2D printJob = new PrintJob2D(frame, doctitle, props);
-
- if (printJob.printDialog() == false) {
- printJob = null;
- }
-
- return printJob;
- }
-
- public PrintJob getPrintJob(final Frame frame, final String doctitle,
- final JobAttributes jobAttributes,
- final PageAttributes pageAttributes) {
-
-
- if (GraphicsEnvironment.isHeadless()) {
- throw new IllegalArgumentException();
- }
-
- PrintJob2D printJob = new PrintJob2D(frame, doctitle,
- jobAttributes, pageAttributes);
-
- if (printJob.printDialog() == false) {
- printJob = null;
- }
-
- return printJob;
- }
-
- public native void beep();
-
- public Clipboard getSystemClipboard() {
- //SecurityManager security = System.getSecurityManager();
- //if (security != null) {
- // security.checkSystemClipboardAccess();
- //}
- //synchronized (this) {
- // if (clipboard == null) {
- // clipboard = new X11Clipboard("System", "CLIPBOARD");
- // }
- //}
- //return clipboard;
- return null;
- }
-
- public Clipboard getSystemSelection() {
- //SecurityManager security = System.getSecurityManager();
- //if (security != null) {
- // security.checkSystemClipboardAccess();
- //}
- //synchronized (this) {
- // if (selection == null) {
- // selection = new X11Clipboard("Selection", "PRIMARY");
- // }
- //}
- //return selection;
- return null;
- }
-
- public boolean getLockingKeyState(int key) {
- if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
- key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
- throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
- }
- return getLockingKeyStateNative(key);
- }
-
- public native boolean getLockingKeyStateNative(int key);
-
- public native void loadSystemColors(int[] systemColors);
-
- /**
- * Give native peers the ability to query the native container
- * given a native component (e.g. the direct parent may be lightweight).
- */
- public static Container getNativeContainer(Component c) {
- return Toolkit.getNativeContainer(c);
- }
-
- protected static final Object targetToPeer(Object target) {
- return SunToolkit.targetToPeer(target);
- }
-
- protected static final void targetDisposedPeer(Object target, Object peer) {
- SunToolkit.targetDisposedPeer(target, peer);
- }
-
- public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
- //if (MToolkit.useMotifDnD()) {
- // return MDragSourceContextPeer.createDragSourceContextPeer(dge);
- //} else {
- // return X11DragSourceContextPeer.createDragSourceContextPeer(dge);
- //}
- return null;
- }
-
- public <T extends DragGestureRecognizer> T
- createDragGestureRecognizer(Class<T> abstractRecognizerClass,
- DragSource ds, Component c, int srcActions,
- DragGestureListener dgl)
- {
- //if (MouseDragGestureRecognizer.class.equals(abstractRecognizerClass))
- // return (T)new MMouseDragGestureRecognizer(ds, c, srcActions, dgl);
- //else
- return null;
- }
-
- /**
- * Returns a new input method adapter descriptor for native input methods.
- */
- public InputMethodDescriptor getInputMethodAdapterDescriptor() throws AWTException {
- return null; // return new MInputMethodDescriptor();
- }
-
- /**
- * Returns a style map for the input method highlight.
- */
- public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
- return null; //return MInputMethod.mapInputMethodHighlight(highlight);
- }
-
- /**
- * Returns a new custom cursor.
- */
- public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
- throws IndexOutOfBoundsException {
- return null; //return new MCustomCursor(cursor, hotSpot, name);
- }
-
- /**
- * Returns the supported cursor size
- */
- public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
- return null; //MCustomCursor.getBestCursorSize(
- //java.lang.Math.max(1,preferredWidth), java.lang.Math.max(1,preferredHeight));
- }
-
- public int getMaximumCursorColors() {
- return 2; // Black and white.
- }
-
- private final static String prefix = "DnD.Cursor.";
- private final static String postfix = ".32x32";
- private static final String dndPrefix = "DnD.";
-
- protected Object lazilyLoadDesktopProperty(String name) {
- if (name.startsWith(prefix)) {
- String cursorName = name.substring(prefix.length(), name.length()) + postfix;
-
- try {
- return Cursor.getSystemCustomCursor(cursorName);
- } catch (AWTException awte) {
- System.err.println("cannot load system cursor: " + cursorName);
-
- return null;
- }
- }
-
- if (name.equals("awt.dynamicLayoutSupported")) {
- return lazilyLoadDynamicLayoutSupportedProperty(name);
- }
-
- if (!loadedXSettings &&
- (name.startsWith("gnome.") ||
- name.equals(SunToolkit.DESKTOPFONTHINTS) ||
- name.startsWith(dndPrefix))) {
- loadedXSettings = true;
- if (!GraphicsEnvironment.isHeadless()) {
- loadXSettings();
- desktopProperties.put(SunToolkit.DESKTOPFONTHINTS,
- SunToolkit.getDesktopFontHints());
- return desktopProperties.get(name);
- }
- }
-
- return super.lazilyLoadDesktopProperty(name);
- }
-
- /*
- * Called from lazilyLoadDesktopProperty because we may not know if
- * the user has quit the previous window manager and started another.
- */
- protected Boolean lazilyLoadDynamicLayoutSupportedProperty(String name) {
- boolean nativeDynamic = isDynamicLayoutSupportedNative();
-
- if (log.isLoggable(PlatformLogger.FINER)) {
- log.finer("nativeDynamic == " + nativeDynamic);
- }
-
- return Boolean.valueOf(nativeDynamic);
- }
-
- private native int getMulticlickTime();
-
- protected void initializeDesktopProperties() {
- desktopProperties.put("DnD.Autoscroll.initialDelay", Integer.valueOf(50));
- desktopProperties.put("DnD.Autoscroll.interval", Integer.valueOf(50));
- desktopProperties.put("DnD.Autoscroll.cursorHysteresis", Integer.valueOf(5));
-
- /* As of 1.4, no wheel mice are supported on Solaris
- * however, they are on Linux, and there isn't a way to detect them,
- * so we leave this property unset to indicate we're not sure if there's
- * a wheel mouse or not.
- */
- //desktopProperties.put("awt.wheelMousePresent", Boolean.valueOf(false));
-
- // We don't want to call getMultilclickTime() if we're headless
- if (!GraphicsEnvironment.isHeadless()) {
- desktopProperties.put("awt.multiClickInterval",
- Integer.valueOf(getMulticlickTime()));
- desktopProperties.put("awt.mouse.numButtons",
- Integer.valueOf(getNumberOfButtons()));
- }
- }
-
- public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
- /* 'target' is unused for now... */
- //return new MRobotPeer(screen.getDefaultConfiguration());
- return null;
- }
-
- static boolean useMotifDnD() {
- return motifdnd;
- }
-
- //
- // The following support Gnome's equivalent of desktop properties.
- // A writeup of this can be found at:
- // http://www.freedesktop.org/standards/xsettings/xsettings.html
- //
-
- /**
- * Triggers a callback to parseXSettings with the x settings values
- * from the window server. Note that this will NOT call
- * parseXSettings if we are not running on a GNOME desktop.
- */
- private native void loadXSettings();
-
- /**
- * Callback from the native side indicating some, or all, of the
- * desktop properties have changed and need to be reloaded.
- * <code>data</code> is the byte array directly from the x server and
- * may be in little endian format.
- * <p>
- * NB: This could be called from any thread if triggered by
- * <code>loadXSettings</code>. It is called from the toolkit
- * thread if triggered by an XSETTINGS change.
- */
- private void parseXSettings(int screen_XXX_ignored, byte[] data) {
- // XXX: notyet: map screen -> per screen XSettings object
- // for now native code only calls us for default screen
- // see awt_MToolkit.c awt_xsettings_update().
- if (xs == null) {
- xs = new XSettings();
- }
-
- Map updatedSettings = xs.update(data);
- if (updatedSettings == null || updatedSettings.isEmpty()) {
- return;
- }
-
- Iterator i = updatedSettings.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry e = (Map.Entry)i.next();
- String name = (String)e.getKey();
-
- name = "gnome." + name;
- setDesktopProperty(name, e.getValue());
-
- // XXX: we probably want to do something smarter. In
- // particular, "Net" properties are of interest to the
- // "core" AWT itself. E.g.
- //
- // Net/DndDragThreshold -> ???
- // Net/DoubleClickTime -> awt.multiClickInterval
- }
-
- setDesktopProperty(SunToolkit.DESKTOPFONTHINTS,
- SunToolkit.getDesktopFontHints());
-
- Integer dragThreshold = null;
- synchronized (this) {
- dragThreshold = (Integer)desktopProperties.get("gnome.Net/DndDragThreshold");
- }
- if (dragThreshold != null) {
- setDesktopProperty("DnD.gestureMotionThreshold", dragThreshold);
- }
- }
-
- protected boolean needsXEmbedImpl() {
- return true;
- }
-
- public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
- return (modalityType == Dialog.ModalityType.MODELESS) ||
- (modalityType == Dialog.ModalityType.APPLICATION_MODAL);
- }
-
- public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
- return (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE);
- }
-
- private native boolean isSyncUpdated();
- private native boolean isSyncFailed();
- private native int getEventNumber();
- private native void updateSyncSelection();
- private static final long WORKAROUND_SLEEP = 100;
-
- /**
- * @inheritDoc
- */
- protected boolean syncNativeQueue(final long timeout) {
- awtLock();
- try {
- long event_number = getEventNumber();
- updateSyncSelection();
-
- // Wait for selection notify for oops on win
- long start = System.currentTimeMillis();
- while (!isSyncUpdated() && !isSyncFailed()) {
- try {
- awtLockWait(timeout);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- // This "while" is a protection from spurious
- // wake-ups. However, we shouldn't wait for too long
- if (((System.currentTimeMillis() - start) > timeout) && (timeout >= 0)) {
- throw new OperationTimedOut();
- }
- }
- if (isSyncFailed() && getEventNumber() - event_number == 1) {
- awtUnlock();
- try {
- Thread.sleep(WORKAROUND_SLEEP);
- } catch (InterruptedException ie) {
- throw new RuntimeException(ie);
- } finally {
- awtLock();
- }
- }
- return getEventNumber() - event_number > 2;
- } finally {
- awtUnlock();
- }
- }
-
- public void grab(Window w) {
- WindowPeer peer = (WindowPeer)w.getPeer();
- if (peer != null) {
- nativeGrab(peer);
- }
- }
-
- public void ungrab(Window w) {
- WindowPeer peer = (WindowPeer)w.getPeer();
- if (peer != null) {
- nativeUnGrab(peer);
- }
- }
- private native void nativeGrab(WindowPeer peer);
- private native void nativeUnGrab(WindowPeer peer);
-
-
- public boolean isDesktopSupported(){
- return false;
- }
-
- public DesktopPeer createDesktopPeer(Desktop target)
- throws HeadlessException{
- throw new UnsupportedOperationException();
- }
-
- public final static int
- UNDETERMINED_WM = 1,
- NO_WM = 2,
- OTHER_WM = 3,
- OPENLOOK_WM = 4,
- MOTIF_WM = 5,
- CDE_WM = 6,
- ENLIGHTEN_WM = 7,
- KDE2_WM = 8,
- SAWFISH_WM = 9,
- ICE_WM = 10,
- METACITY_WM = 11,
- COMPIZ_WM = 12,
- LG3D_WM = 13;
-
- public static int getWMID() {
- String wmName = getWMName();
-
- if ("NO_WM".equals(wmName)) {
- return NO_WM;
- } else if ("OTHER_WM".equals(wmName)) {
- return OTHER_WM;
- } else if ("ENLIGHTEN_WM".equals(wmName)) {
- return ENLIGHTEN_WM;
- } else if ("KDE2_WM".equals(wmName)) {
- return KDE2_WM;
- } else if ("SAWFISH_WM".equals(wmName)) {
- return SAWFISH_WM;
- } else if ("ICE_WM".equals(wmName)) {
- return ICE_WM;
- } else if ("METACITY_WM".equals(wmName)) {
- return METACITY_WM;
- } else if ("OPENLOOK_WM".equals(wmName)) {
- return OPENLOOK_WM;
- } else if ("MOTIF_WM".equals(wmName)) {
- return MOTIF_WM;
- } else if ("CDE_WM".equals(wmName)) {
- return CDE_WM;
- } else if ("COMPIZ_WM".equals(wmName)) {
- return COMPIZ_WM;
- } else if ("LG3D_WM".equals(wmName)) {
- return LG3D_WM;
- }
- return UNDETERMINED_WM;
- }
-
- private static native String getWMName();
-
-} // class MToolkit
--- a/jdk/src/solaris/classes/sun/awt/motif/MToolkitThreadBlockedHandler.java Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt.motif;
-
-import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
-import sun.awt.SunToolkit;
-
-final class MToolkitThreadBlockedHandler implements
- ToolkitThreadBlockedHandler {
- private static ToolkitThreadBlockedHandler priveleged_lock = null;
- static {
- priveleged_lock = new MToolkitThreadBlockedHandler();
- }
- private MToolkitThreadBlockedHandler() {}
- static ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() {
- return priveleged_lock;
- }
- public void lock() {
- SunToolkit.awtLock();
- }
- public void unlock() {
- SunToolkit.awtUnlock();
- }
- public native void enter();
- public native void exit();
-}
--- a/jdk/src/solaris/classes/sun/awt/motif/MWindowAttributes.java Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.awt.motif;
-import java.awt.Image;
-
-class MWindowAttributes {
- static int NORMAL = 0;
- static int ICONIC = 1;
- static int MAXIMIZED = 2;
-
- static int AWT_DECOR_NONE = 0;
- static int AWT_DECOR_ALL = 1;
- static int AWT_DECOR_BORDER = 2;
- static int AWT_DECOR_RESIZEH = 4;
- static int AWT_DECOR_TITLE = 8;
- static int AWT_DECOR_MENU = 0x10;
- static int AWT_DECOR_MINIMIZE = 0x20;
- static int AWT_DECOR_MAXIMIZE = 0x40;
- static int AWT_UNOBSCURED = 0; // X11 VisibilityUnobscured
- static int AWT_PARTIALLY_OBSCURED = 1; // X11 VisibilityPartiallyObscured
- static int AWT_FULLY_OBSCURED = 2; // X11 VisibilityFullyObscured
- static int AWT_UNKNOWN_OBSCURITY = 3;
-
- boolean nativeDecor;
- boolean initialFocus;
- boolean isResizable;
- int initialState;
- int visibilityState; // updated by native X11 event handling code.
- String title;
- java.awt.Image icon;
- int decorations; // for future expansion to be able to
- // specify native decorations
-
- private static native void initIDs();
-
- static {
- initIDs();
- }
-
- MWindowAttributes() {
- nativeDecor = false;
- initialFocus = false;
- isResizable = false;
- initialState = NORMAL;
- visibilityState = AWT_UNKNOWN_OBSCURITY;
- title = null;
- icon = null;
- decorations = 0;
- }
-}
--- a/jdk/src/solaris/classes/sun/awt/motif/X11FontMetrics.java Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt.motif;
-
-import java.awt.*;
-import java.util.Hashtable;
-import sun.awt.PlatformFont;
-
-/**
- * A font metrics object for a WServer font.
- *
- * @author Jim Graham
- */
-public class X11FontMetrics extends FontMetrics {
- /**
- * The widths of the first 256 characters.
- */
- int widths[];
-
- /**
- * The standard ascent of the font. This is the logical height
- * above the baseline for the Alphanumeric characters and should
- * be used for determining line spacing. Note, however, that some
- * characters in the font may extend above this height.
- */
- int ascent;
-
- /**
- * The standard descent of the font. This is the logical height
- * below the baseline for the Alphanumeric characters and should
- * be used for determining line spacing. Note, however, that some
- * characters in the font may extend below this height.
- */
- int descent;
-
- /**
- * The standard leading for the font. This is the logical amount
- * of space to be reserved between the descent of one line of text
- * and the ascent of the next line. The height metric is calculated
- * to include this extra space.
- */
- int leading;
-
- /**
- * The standard height of a line of text in this font. This is
- * the distance between the baseline of adjacent lines of text.
- * It is the sum of the ascent+descent+leading. There is no
- * guarantee that lines of text spaced at this distance will be
- * disjoint; such lines may overlap if some characters overshoot
- * the standard ascent and descent metrics.
- */
- int height;
-
- /**
- * The maximum ascent for all characters in this font. No character
- * will extend further above the baseline than this metric.
- */
- int maxAscent;
-
- /**
- * The maximum descent for all characters in this font. No character
- * will descend further below the baseline than this metric.
- */
- int maxDescent;
-
- /**
- * The maximum possible height of a line of text in this font.
- * Adjacent lines of text spaced this distance apart will be
- * guaranteed not to overlap. Note, however, that many paragraphs
- * that contain ordinary alphanumeric text may look too widely
- * spaced if this metric is used to determine line spacing. The
- * height field should be preferred unless the text in a given
- * line contains particularly tall characters.
- */
- int maxHeight;
-
- /**
- * The maximum advance width of any character in this font.
- */
- int maxAdvance;
-
- static {
- initIDs();
- }
-
- /**
- * Initialize JNI field and method IDs for fields that may be
- accessed from C.
- */
- private static native void initIDs();
-
- /**
- * Calculate the metrics from the given WServer and font.
- */
- public X11FontMetrics(Font font) {
- super(font);
- init();
- }
-
- /**
- * Get leading
- */
- public int getLeading() {
- return leading;
- }
-
- /**
- * Get ascent.
- */
- public int getAscent() {
- return ascent;
- }
-
- /**
- * Get descent
- */
- public int getDescent() {
- return descent;
- }
-
- /**
- * Get height
- */
- public int getHeight() {
- return height;
- }
-
- /**
- * Get maxAscent
- */
- public int getMaxAscent() {
- return maxAscent;
- }
-
- /**
- * Get maxDescent
- */
- public int getMaxDescent() {
- return maxDescent;
- }
-
- /**
- * Get maxAdvance
- */
- public int getMaxAdvance() {
- return maxAdvance;
- }
-
- /**
- * Return the width of the specified string in this Font.
- */
- public int stringWidth(String string) {
- return charsWidth(string.toCharArray(), 0, string.length());
- }
-
- /**
- * Return the width of the specified char[] in this Font.
- */
- public int charsWidth(char chars[], int offset, int length) {
- Font font = getFont();
- PlatformFont pf = ((PlatformFont) font.getPeer());
- if (pf.mightHaveMultiFontMetrics()) {
- return getMFCharsWidth(chars, offset, length, font);
- } else {
- if (widths != null) {
- int w = 0;
- for (int i = offset; i < offset + length; i++) {
- int ch = chars[i];
- if (ch < 0 || ch >= widths.length) {
- w += maxAdvance;
- } else {
- w += widths[ch];
- }
- }
- return w;
- } else {
- return maxAdvance * length;
- }
- }
- }
-
- private native int getMFCharsWidth(char chars[], int offset, int length, Font font);
-
- /**
- * Return the width of the specified byte[] in this Font.
- */
- public native int bytesWidth(byte data[], int off, int len);
-
- /**
- * Get the widths of the first 256 characters in the font.
- */
- public int[] getWidths() {
- return widths;
- }
-
- native void init();
-
- static Hashtable table = new Hashtable();
-
- static synchronized FontMetrics getFontMetrics(Font font) {
- FontMetrics fm = (FontMetrics)table.get(font);
- if (fm == null) {
- table.put(font, fm = new X11FontMetrics(font));
- }
- return fm;
- }
-}
--- a/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java Thu Dec 15 19:52:13 2011 -0800
@@ -299,7 +299,7 @@
private void doPath(SunGraphics2D sg2d, Shape s, boolean isFill) {
Path2D.Float p2df;
int transx, transy;
- if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+ if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
if (s instanceof Path2D.Float) {
p2df = (Path2D.Float)s;
} else {
@@ -323,10 +323,10 @@
}
public void draw(SunGraphics2D sg2d, Shape s) {
- if (sg2d.strokeState == sg2d.STROKE_THIN) {
+ if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
// Delegate to drawPolygon() if possible...
if (s instanceof Polygon &&
- sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE)
+ sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE)
{
Polygon p = (Polygon) s;
drawPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
@@ -336,7 +336,7 @@
// Otherwise we will use drawPath() for
// high-quality thin paths.
doPath(sg2d, s, false);
- } else if (sg2d.strokeState < sg2d.STROKE_CUSTOM) {
+ } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
// REMIND: X11 can handle uniform scaled wide lines
// and dashed lines itself if we set the appropriate
// XGC attributes (TBD).
@@ -360,10 +360,10 @@
}
public void fill(SunGraphics2D sg2d, Shape s) {
- if (sg2d.strokeState == sg2d.STROKE_THIN) {
+ if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
// Delegate to fillPolygon() if possible...
if (s instanceof Polygon &&
- sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE)
+ sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE)
{
Polygon p = (Polygon) s;
fillPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
@@ -378,7 +378,7 @@
AffineTransform at;
int transx, transy;
- if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE) {
+ if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
// Transform (translation) will be done by XFillSpans
at = null;
transx = sg2d.transX;
--- a/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java Thu Dec 15 19:52:13 2011 -0800
@@ -295,9 +295,9 @@
public void validatePipe(SunGraphics2D sg2d) {
if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
- sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
- (sg2d.compositeState <= sg2d.COMP_ISCOPY ||
- sg2d.compositeState == sg2d.COMP_XOR))
+ sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
+ (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
+ sg2d.compositeState == SunGraphics2D.COMP_XOR))
{
if (x11txpipe == null) {
/*
@@ -315,7 +315,7 @@
return;
}
- if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+ if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
// Do this to init textpipe correctly; we will override the
// other non-text pipes below
// REMIND: we should clean this up eventually instead of
@@ -329,7 +329,7 @@
case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
// Use X11 pipe even if DGA is available since DGA
// text slows everything down when mixed with X11 calls
- if (sg2d.compositeState == sg2d.COMP_ISCOPY) {
+ if (sg2d.compositeState == SunGraphics2D.COMP_ISCOPY) {
sg2d.textpipe = x11textpipe;
} else {
sg2d.textpipe = solidTextRenderer;
@@ -353,7 +353,7 @@
case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
// Use X11 pipe even if DGA is available since DGA
// text slows everything down when mixed with X11 calls
- if (sg2d.compositeState == sg2d.COMP_ISCOPY) {
+ if (sg2d.compositeState == SunGraphics2D.COMP_ISCOPY) {
sg2d.textpipe = x11textpipe;
} else {
sg2d.textpipe = solidTextRenderer;
@@ -370,10 +370,10 @@
}
}
- if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+ if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
sg2d.drawpipe = x11txpipe;
sg2d.fillpipe = x11txpipe;
- } else if (sg2d.strokeState != sg2d.STROKE_THIN){
+ } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN){
sg2d.drawpipe = x11txpipe;
sg2d.fillpipe = x11pipe;
} else {
@@ -398,8 +398,8 @@
}
public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
- if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
- sg2d.compositeState <= sg2d.COMP_ISCOPY)
+ if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
+ sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY)
{
return solidloops;
}
@@ -488,7 +488,7 @@
makePipes();
}
CompositeType comptype = sg2d.imageComp;
- if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
+ if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
(CompositeType.SrcOverNoEa.equals(comptype) ||
CompositeType.SrcNoEa.equals(comptype)))
{
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/awt/HeadlessToolkit.c Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+#include <jni_util.h>
+
+#ifdef HEADLESS
+
+extern JavaVM *jvm;
+
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+ jvm = vm;
+ return JNI_VERSION_1_2;
+}
+
+JNIEXPORT jboolean JNICALL AWTIsHeadless() {
+ return JNI_TRUE;
+}
+
+#endif
--- a/jdk/src/solaris/native/sun/awt/MouseInfo.c Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifdef HEADLESS
- #error This file should not be included in headless library
-#endif
-
-#include "awt_p.h"
-#include "awt_Component.h"
-
-#include <jni.h>
-#include <jni_util.h>
-
-extern int awt_numScreens;
-extern AwtScreenDataPtr x11Screens;
-extern struct ComponentIDs componentIDs;
-extern struct MComponentPeerIDs mComponentPeerIDs;
-
-/*
- * Class: sun_awt_DefaultMouseInfoPeer
- * Method: fillPointWithCoords
- * Signature: (Ljava/awt/Point)I
- */
-JNIEXPORT jint JNICALL
-Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls,
- jobject point)
-{
- static jclass pointClass = NULL;
- jclass pointClassLocal;
- static jfieldID xID, yID;
- Window rootWindow, childWindow;
- int i;
- int32_t xr, yr, xw, yw;
- uint32_t keys;
- Bool pointerFound;
-
- AWT_LOCK();
- if (pointClass == NULL) {
- pointClassLocal = (*env)->FindClass(env, "java/awt/Point");
- DASSERT(pointClassLocal != NULL);
- if (pointClassLocal == NULL) {
- AWT_UNLOCK();
- return (jint)0;
- }
- pointClass = (jclass)(*env)->NewGlobalRef(env, pointClassLocal);
- (*env)->DeleteLocalRef(env, pointClassLocal);
- xID = (*env)->GetFieldID(env, pointClass, "x", "I");
- yID = (*env)->GetFieldID(env, pointClass, "y", "I");
- }
-
- for (i = 0; i < awt_numScreens; i++) {
- pointerFound = XQueryPointer(awt_display, x11Screens[i].root,
- &rootWindow, &childWindow,
- &xr, &yr, &xw, &yw, &keys);
- if (pointerFound) {
- (*env)->SetIntField(env, point, xID, xr);
- (*env)->SetIntField(env, point, yID, yr);
- AWT_UNLOCK();
- return (jint)i;
- }
- }
- /* This should never happen */
- DASSERT(FALSE);
- AWT_UNLOCK();
- return (jint)0;
-}
-
-/*
- * Class: sun_awt_DefaultMouseInfoPeer
- * Method: isWindowUnderMouse
- * Signature: (Ljava/awt/Window)Z
- */
-JNIEXPORT jboolean JNICALL Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse
- (JNIEnv * env, jclass cls, jobject window)
-{
- Window rootWindow = None, parentWindow = None, siblingWindow = None;
- Window * children = NULL;
- int i = 0;
- int is_the_same_screen = 0;
- int32_t xr = 0, yr = 0, xw = 0, yw = 0;
- uint32_t keys = 0;
- uint32_t nchildren = 0;
- Bool pointerFound = 0;
- struct FrameData *wdata = NULL;
- jobject winPeer = NULL;
-
- if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
- return JNI_FALSE;
- }
- winPeer = (*env)->GetObjectField(env, window, componentIDs.peer);
- if (JNU_IsNull(env, winPeer)) {
- return JNI_FALSE;
- }
-
- wdata = (struct FrameData *)
- JNU_GetLongFieldAsPtr(env, winPeer, mComponentPeerIDs.pData);
- (*env)->DeleteLocalRef(env, winPeer);
-
- if (wdata == NULL) {
- return JNI_FALSE;
- }
-
- AWT_LOCK();
-
- XQueryTree(awt_display, XtWindow(wdata->winData.comp.widget),
- &rootWindow, &parentWindow, &children, &nchildren);
-
- is_the_same_screen = XQueryPointer(awt_display, parentWindow,
- &rootWindow, &siblingWindow, &xr, &yr, &xw, &yw, &keys);
-
- if (siblingWindow == XtWindow(wdata->winData.comp.widget) && is_the_same_screen) {
- AWT_UNLOCK();
- return JNI_TRUE;
- }
-
- AWT_UNLOCK();
- return JNI_FALSE ;
-
-}
--- a/jdk/src/solaris/native/sun/awt/XDrawingArea.c Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- */
-
-#include <X11/IntrinsicP.h>
-#include "XDrawingAreaP.h"
-#include <Xm/XmP.h>
-
-#include <stdio.h>
-#include <malloc.h>
-
-#ifdef DEBUG
-#include <jvm.h> /* To get jio_fprintf() */
-#endif
-
-/******************************************************************
- *
- * Provides Canvas widget which allows the X11 visual to be
- * changed (the Motif DrawingArea restricts the visual to that
- * of the parent widget).
- *
- ******************************************************************/
-
-
-static XmNavigability WidgetNavigable();
-static void ClassInitialize();
-
-static XmBaseClassExtRec baseClassExtRec = {
- NULL,
- NULLQUARK,
- XmBaseClassExtVersion,
- sizeof(XmBaseClassExtRec),
- NULL, /* InitializePrehook */
- NULL, /* SetValuesPrehook */
- NULL, /* InitializePosthook */
- NULL, /* SetValuesPosthook */
- NULL, /* secondaryObjectClass */
- NULL, /* secondaryCreate */
- NULL, /* getSecRes data */
- { 0 }, /* fastSubclass flags */
- NULL, /* getValuesPrehook */
- NULL, /* getValuesPosthook */
- NULL, /* classPartInitPrehook */
- NULL, /* classPartInitPosthook*/
- NULL, /* ext_resources */
- NULL, /* compiled_ext_resources*/
- 0, /* num_ext_resources */
- FALSE, /* use_sub_resources */
- WidgetNavigable, /* widgetNavigable */
- NULL /* focusChange */
-};
-
-XDrawingAreaClassRec xDrawingAreaClassRec = {
-{
- /* Core class part */
-
- /* superclass */ (WidgetClass)&xmDrawingAreaClassRec,
- /* class_name */ "XDrawingArea",
- /* widget_size */ sizeof(XDrawingAreaRec),
- /* class_initialize */ ClassInitialize,
- /* class_part_initialize*/ NULL,
- /* class_inited */ FALSE,
- /* initialize */ NULL,
- /* initialize_hook */ NULL,
- /* realize */ XtInheritRealize,
- /* actions */ NULL,
- /* num_actions */ 0,
- /* resources */ NULL,
- /* num_resources */ 0,
- /* xrm_class */ NULLQUARK,
- /* compress_motion */ FALSE,
- /* compress_exposure */ FALSE,
- /* compress_enterleave*/ FALSE,
- /* visible_interest */ FALSE,
- /* destroy */ NULL,
- /* resize */ XtInheritResize,
- /* expose */ XtInheritExpose,
- /* set_values */ NULL,
- /* set_values_hook */ NULL,
- /* set_values_almost */ XtInheritSetValuesAlmost,
- /* get_values_hook */ NULL,
- /* accept_focus */ NULL,
- /* version */ XtVersion,
- /* callback_offsets */ NULL,
- /* tm_table */ NULL,
- /* query_geometry */ NULL,
- /* display_accelerator */ NULL,
- /* extension */ (XtPointer)&baseClassExtRec
- },
-
- { /* composite_class fields */
- XtInheritGeometryManager, /* geometry_manager */
- XtInheritChangeManaged, /* change_managed */
- XtInheritInsertChild, /* insert_child */
- XtInheritDeleteChild, /* delete_child */
- NULL, /* extension */
- },
-
- { /* constraint_class fields */
- NULL, /* resource list */
- 0, /* num resources */
- 0, /* constraint size */
- NULL, /* init proc */
- NULL, /* destroy proc */
- NULL, /* set values proc */
- NULL, /* extension */
- },
-
- { /* manager_class fields */
- XtInheritTranslations, /* translations */
- NULL, /* syn_resources */
- 0, /* num_get_resources */
- NULL, /* syn_cont_resources */
- 0, /* num_get_cont_resources */
- XmInheritParentProcess, /* parent_process */
- NULL, /* extension */
- },
-
- { /* drawingArea class */
- /* extension */ NULL
- },
-
- /* XDrawingArea class part */
- {
- /* extension */ NULL
- }
-};
-
-WidgetClass xDrawingAreaClass = (WidgetClass)&xDrawingAreaClassRec;
-
-static void ClassInitialize( void )
-{
- baseClassExtRec.record_type = XmQmotif ;
-}
-
-static XmNavigability WidgetNavigable(Widget wid)
-{
- return XmCONTROL_NAVIGABLE;
-}
--- a/jdk/src/solaris/native/sun/awt/XDrawingArea.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- */
-
-#ifndef _XDrawingArea_h_
-#define _XDrawingArea_h_
-
-extern WidgetClass xDrawingAreaClass;
-
-typedef struct _XDrawingAreaClassRec *XDrawingAreaWidgetClass;
-typedef struct _XDrawingAreaRec *XDrawingAreaWidget;
-
-#endif /* !_VDrawingArea_h_ */
--- a/jdk/src/solaris/native/sun/awt/XDrawingAreaP.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- */
-
-#ifndef _XDrawingAreaP_h_
-#define _XDrawingAreaP_h_
-
-#include <Xm/DrawingAP.h>
-#include "XDrawingArea.h"
-
-
-/***************************************************************
- * VDrawingArea Widget Data Structures
- *
- *
- **************************************************************/
-
-/* Define part class structure */
-typedef struct _XDrawingAreaClass {
- XtPointer extension;
-} XDrawingAreaClassPart;
-
-/* Define the full class record */
-typedef struct _XDrawingAreaClassRec {
- CoreClassPart core_class;
- CompositeClassPart composite_class;
- ConstraintClassPart constraint_class;
- XmManagerClassPart manager_class;
- XmDrawingAreaClassPart drawing_area_class;
- XDrawingAreaClassPart xdrawingarea_class;
-} XDrawingAreaClassRec;
-
-/* External definition for class record */
-extern XDrawingAreaClassRec xDrawingAreaClassRec;
-
-/****************************************************************
- *
-* Full instance record declaration
- *
- ****************************************************************/
-
-typedef struct _XDrawingAreaRec
-{
- CorePart core;
- CompositePart composite;
- ConstraintPart constraint;
- XmManagerPart manager;
- XmDrawingAreaPart drawing_area;
-} XDrawingAreaRec;
-
-
-
-#endif /* !_VDrawingAreaP_h_ */
--- a/jdk/src/solaris/native/sun/awt/awt.h Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt.h Thu Dec 15 19:52:13 2011 -0800
@@ -90,74 +90,12 @@
* Unfortunately AWT_LOCK debugging does not work with XAWT due to mixed
* Java/C use of AWT lock.
*/
-#if defined(DEBUG_AWT_LOCK) && !defined(XAWT)
-extern int awt_locked;
-extern char *lastF;
-extern int lastL;
-
-#define AWT_LOCK() do { \
- if (!awtLockInited) { \
- jio_fprintf(stderr, "AWT lock error, awt_lock is null\n"); \
- } \
- if (awt_locked < 0) { \
- jio_fprintf(stderr, \
- "AWT lock error (%s,%d) (last held by %s,%d) %d\n", \
- __FILE__, __LINE__, lastF, lastL, awt_locked); \
- } \
- lastF = __FILE__; \
- lastL = __LINE__; \
- AWT_LOCK_IMPL(); \
- ++awt_locked; \
-} while (0)
-
-#define AWT_NOFLUSH_UNLOCK() do { \
- lastF = ""; \
- lastL = -1; \
- if (awt_locked < 1) { \
- jio_fprintf(stderr, "AWT unlock error (%s,%d,%d)\n", \
- __FILE__, __LINE__, awt_locked); \
- } \
- --awt_locked; \
- AWT_NOFLUSH_UNLOCK_IMPL(); \
-} while (0)
-
-#define AWT_WAIT(tm) do { \
- int old_lockcount = awt_locked; \
- if (awt_locked < 1) { \
- jio_fprintf(stderr, "AWT wait error (%s,%d,%d)\n", \
- __FILE__, __LINE__, awt_locked); \
- } \
- awt_locked = 0; \
- AWT_WAIT_IMPL(tm); \
- awt_locked = old_lockcount; \
-} while (0)
-
-#define AWT_NOTIFY() do { \
- if (awt_locked < 1) { \
- jio_fprintf(stderr, "AWT notify error (%s,%d,%d)\n", \
- __FILE__, __LINE__, awt_locked); \
- } \
- AWT_NOTIFY_IMPL(); \
-} while(0)
-
-#define AWT_NOTIFY_ALL() do { \
- if (awt_locked < 1) { \
- jio_fprintf(stderr, "AWT notify all error (%s,%d,%d)\n", \
- __FILE__, __LINE__, awt_locked); \
- } \
- AWT_NOTIFY_ALL_IMPL(); \
-} while (0)
-
-#else
-
#define AWT_LOCK() AWT_LOCK_IMPL()
#define AWT_NOFLUSH_UNLOCK() AWT_NOFLUSH_UNLOCK_IMPL()
#define AWT_WAIT(tm) AWT_WAIT_IMPL(tm)
#define AWT_NOTIFY() AWT_NOTIFY_IMPL()
#define AWT_NOTIFY_ALL() AWT_NOTIFY_ALL_IMPL()
-#endif /* DEBUG_AWT_LOCK && !XAWT */
-
#ifndef HEADLESS
extern Display *awt_display; /* awt_GraphicsEnv.c */
extern Boolean awt_ModLockIsShiftLock; /* XToolkit.c */
--- a/jdk/src/solaris/native/sun/awt/awt_AWTEvent.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_AWTEvent.c Thu Dec 15 19:52:13 2011 -0800
@@ -40,14 +40,11 @@
#include "java_awt_event_KeyEvent.h"
#include "jni_util.h"
-#include "canvas.h"
#include "awt_AWTEvent.h"
-#include "awt_Component.h"
struct AWTEventIDs awtEventIDs;
struct InputEventIDs inputEventIDs;
struct KeyEventIDs keyEventIDs;
-struct MComponentPeerIDs mComponentPeerIDs;
JNIEXPORT void JNICALL
Java_java_awt_AWTEvent_initIDs(JNIEnv *env, jclass cls)
@@ -69,61 +66,10 @@
keyEventIDs.keyCode = (*env)->GetFieldID(env, cls, "keyCode", "I");
keyEventIDs.keyChar = (*env)->GetFieldID(env, cls, "keyChar", "C");
}
-#ifndef XAWT
-JNIEXPORT void JNICALL
-Java_java_awt_AWTEvent_nativeSetSource(JNIEnv *env, jobject self,
- jobject newSource)
-{
- jbyteArray bdata;
- AWT_LOCK();
-
- bdata = (jbyteArray)(*env)->GetObjectField(env, self, awtEventIDs.bdata);
-
- if (bdata != NULL) {
- XEvent *xev;
- Window w;
- jboolean dummy;
-
- /* get the widget out of the peer newSource */
- struct ComponentData *cdata = (struct ComponentData *)
- JNU_GetLongFieldAsPtr(env, newSource, mComponentPeerIDs.pData);
- if (JNU_IsNull(env, cdata) || (cdata == NULL) ||
- ((cdata->widget != NULL) && (XtIsObject(cdata->widget)) &&
- (cdata->widget->core.being_destroyed))) {
- JNU_ThrowNullPointerException(env, "null widget");
- AWT_UNLOCK();
- return;
- }
-
- /* get the Window out of the widget */
- w = XtWindow(cdata->widget);
-
- if (w == None) {
- JNU_ThrowNullPointerException(env, "null window");
- AWT_UNLOCK();
- return;
- }
-
- /* reset the filed in the event */
- xev = (XEvent *)(*env)->GetPrimitiveArrayCritical(env, bdata, &dummy);
- if (xev == NULL) {
- JNU_ThrowNullPointerException(env, "null data");
- AWT_UNLOCK();
- return;
- }
- xev->xany.window = w;
- (*env)->ReleasePrimitiveArrayCritical(env, bdata, (void *)xev, 0);
- }
-
- AWT_UNLOCK();
-}
-#else
JNIEXPORT void JNICALL
Java_java_awt_AWTEvent_nativeSetSource(JNIEnv *env, jobject self,
jobject newSource)
{
}
-
-#endif
--- a/jdk/src/solaris/native/sun/awt/awt_Component.h Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_Component.h Thu Dec 15 19:52:13 2011 -0800
@@ -42,25 +42,3 @@
jmethodID getParent;
jmethodID getLocationOnScreen;
};
-
-/* field and method IDs for Container */
-struct ContainerIDs {
- jfieldID layoutMgr;
- jmethodID getComponents;
- jmethodID findComponentAt;
-};
-
-/* fieldIDs for MComponentPeer fields that may be accessed from C */
-struct MComponentPeerIDs {
- jfieldID pData;
- jfieldID target;
- jfieldID jniGlobalRef;
- jfieldID graphicsConfig;
- jfieldID drawState;
- jmethodID isFocusableMID;
-};
-
-#ifndef HEADLESS
-extern void processTree(Widget from, Widget to, Boolean action);
-#endif // HEADLESS
-
--- a/jdk/src/solaris/native/sun/awt/awt_Cursor.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "jni_util.h"
-#include "awt_p.h"
-
-#define CACHE_UPDATE 0 /* cache the component and update cursor */
-#define UPDATE_ONLY 1 /* update cursor, but not cache component */
-#define CACHE_ONLY 2 /* cache the component, no cursor update */
-
-/* fieldIDs for Cursor fields that may be accessed from C */
-struct CursorIDs {
- jfieldID type;
- jmethodID mSetPData;
- jfieldID pData;
-};
-
-#ifndef HEADLESS
-Cursor getCursor(JNIEnv *env, jobject jCur);
-void updateCursor(XPointer client_data, int32_t replace);
-#endif /* !HEADLESS */
--- a/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c Thu Dec 15 19:52:13 2011 -0800
@@ -29,30 +29,21 @@
#include "awt_p.h"
#include "java_awt_Component.h"
-//#include "sun_awt_motif_MComponentPeer.h"
#include "awt_Component.h"
-
#include <jni.h>
#include <jni_util.h>
#include <jawt_md.h>
-extern struct MComponentPeerIDs mComponentPeerIDs;
extern struct ComponentIDs componentIDs;
-#ifndef XAWT
-extern AwtGraphicsConfigDataPtr
-getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
-#endif
-#ifdef XAWT
#include "awt_GraphicsEnv.h"
extern jfieldID windowID;
extern jfieldID targetID;
extern jfieldID graphicsConfigID;
extern jfieldID drawStateID;
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
-#endif
/*
* Lock the surface of the target component for native rendering.
@@ -109,13 +100,8 @@
return (jint)JAWT_LOCK_ERROR;
}
-#ifndef XAWT
- drawState = (*env)->GetIntField(env, peer, mComponentPeerIDs.drawState);
- (*env)->SetIntField(env, peer, mComponentPeerIDs.drawState, 0);
-#else
drawState = (*env)->GetIntField(env, peer, drawStateID);
(*env)->SetIntField(env, peer, drawStateID, 0);
-#endif
return drawState;
}
@@ -127,9 +113,7 @@
jclass componentClass;
AwtGraphicsConfigDataPtr adata;
int32_t result;
-#ifdef XAWT
jobject gc_object;
-#endif
if (ds == NULL) {
#ifdef DEBUG
fprintf(stderr, "Drawing Surface is NULL\n");
@@ -164,9 +148,6 @@
AWT_UNLOCK();
return (int32_t) 0;
}
-#ifndef XAWT
- adata = getGraphicsConfigFromComponentPeer(env, peer);
-#else
/* GraphicsConfiguration object of MComponentPeer */
gc_object = (*env)->GetObjectField(env, peer, graphicsConfigID);
@@ -177,7 +158,6 @@
} else {
adata = getDefaultConfig(DefaultScreen(awt_display));
}
-#endif
result = adata->AwtColorMatch(r, g, b, adata);
AWT_UNLOCK();
@@ -201,9 +181,6 @@
jclass componentClass;
JAWT_X11DrawingSurfaceInfo* px;
JAWT_DrawingSurfaceInfo* p;
-#ifndef XAWT
- struct ComponentData *cdata;
-#endif
XWindowAttributes attrs;
if (ds == NULL) {
@@ -241,31 +218,14 @@
return NULL;
}
-#ifndef XAWT
- /* Get the component data from the peer */
- cdata = (struct ComponentData *)
- JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
- if (cdata == NULL) {
-#ifdef DEBUG
- fprintf(stderr, "Component data is NULL\n");
-#endif
- AWT_UNLOCK();
- return NULL;
- }
-#endif
-
- AWT_UNLOCK();
+ AWT_UNLOCK();
/* Allocate platform-specific data */
px = (JAWT_X11DrawingSurfaceInfo*)
malloc(sizeof(JAWT_X11DrawingSurfaceInfo));
/* Set drawable and display */
-#ifndef XAWT
- px->drawable = XtWindow(cdata->widget);
-#else
px->drawable = (*env)->GetLongField(env, peer, windowID);
-#endif
px->display = awt_display;
/* Get window attributes to set other values */
@@ -392,21 +352,7 @@
AWT_LOCK();
-#ifndef XAWT
- if (window != None) {
- widget = XtWindowToWidget(awt_display, window);
- }
-
- if (widget != NULL) {
- XtVaGetValues (widget, XmNuserData, &peer, NULL);
- }
-
- if (peer != NULL) {
- target = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
- }
-#else
target = (*env)->GetObjectField(env, peer, targetID);
-#endif
if (target == NULL) {
JNU_ThrowNullPointerException(env, "NullPointerException");
--- a/jdk/src/solaris/native/sun/awt/awt_Font.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_Font.c Thu Dec 15 19:52:13 2011 -0800
@@ -30,8 +30,6 @@
#include "java_awt_Component.h"
#include "java_awt_Font.h"
#include "java_awt_FontMetrics.h"
-#include "sun_awt_motif_MToolkit.h"
-#include "sun_awt_motif_X11FontMetrics.h"
#include "sun_awt_X11GraphicsEnvironment.h"
#include "awt_Font.h"
@@ -100,57 +98,6 @@
}
#ifndef HEADLESS
-
-/* fieldIDs for X11FontMetrics fields that may be accessed from C */
-static struct X11FontMetricsIDs {
- jfieldID widths;
- jfieldID font;
- jfieldID ascent;
- jfieldID descent;
- jfieldID leading;
- jfieldID height;
- jfieldID maxAscent;
- jfieldID maxDescent;
- jfieldID maxHeight;
- jfieldID maxAdvance;
-} x11FontMetricsIDs;
-
-/*
- * Class: sun_awt_motif_X11FontMetrics
- * Method: initIDs
- * Signature: ()V
- */
-
-/* This function gets called from the static initializer for
- X11FontMetrics.java to initialize the fieldIDs for fields
- that may be accessed from C */
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_X11FontMetrics_initIDs
- (JNIEnv *env, jclass cls)
-{
- x11FontMetricsIDs.widths = (*env)->GetFieldID(env, cls, "widths", "[I");
- x11FontMetricsIDs.font =
- (*env)->GetFieldID(env, cls, "font", "Ljava/awt/Font;");
- x11FontMetricsIDs.ascent =
- (*env)->GetFieldID(env, cls, "ascent", "I");
- x11FontMetricsIDs.descent =
- (*env)->GetFieldID(env, cls, "descent", "I");
- x11FontMetricsIDs.leading =
- (*env)->GetFieldID(env, cls, "leading", "I");
- x11FontMetricsIDs.height =
- (*env)->GetFieldID(env, cls, "height", "I");
- x11FontMetricsIDs.maxAscent =
- (*env)->GetFieldID(env, cls, "maxAscent", "I");
- x11FontMetricsIDs.maxDescent =
- (*env)->GetFieldID(env, cls, "maxDescent", "I");
- x11FontMetricsIDs.maxHeight =
- (*env)->GetFieldID(env, cls, "maxHeight", "I");
- x11FontMetricsIDs.maxAdvance =
- (*env)->GetFieldID(env, cls, "maxAdvance", "I");
-}
-
-
/* fieldIDs for FontDescriptor fields that may be accessed from C */
static struct FontDescriptorIDs {
jfieldID nativeName;
@@ -182,27 +129,6 @@
#endif /* !HEADLESS */
}
-#ifndef HEADLESS
-struct MFontPeerIDs mFontPeerIDs;
-/*
- * Class: sun_awt_motif_MFontPeer
- * Method: initIDs
- * Signature: ()V
- */
-
-/* This function gets called from the static initializer for
- MFontPeer.java to initialize the fieldIDs for fields
- that may be accessed from C */
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MFontPeer_initIDs
- (JNIEnv *env, jclass cls)
-{
- mFontPeerIDs.xfsname =
- (*env)->GetFieldID(env, cls, "xfsname", "Ljava/lang/String;");
-}
-#endif /* !HEADLESS */
-
/*
* Class: sun_awt_PlatformFont
* Method: initIDs
@@ -747,193 +673,6 @@
}
/*
- * Class: sun_awt_motif_X11FontMetrics
- * Method: getMFCharsWidth
- * Signature: ([CIILjava/awt/Font;)I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth
- (JNIEnv *env, jobject this, jcharArray data, jint offset, jint length, jobject font)
-{
- jint retVal = 0;
-
- AWT_LOCK();
-
- retVal = awtJNI_GetMFStringWidth(env, data, offset, length, font);
-
- AWT_UNLOCK();
- return retVal;
-}
-
-/*
- * Class: sun_awt_motif_X11FontMetrics
- * Method: bytesWidth
- * Signature: ([BII)I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_X11FontMetrics_bytesWidth
- (JNIEnv *env, jobject this, jbyteArray str, jint off, jint len)
-{
- jint w = 0;
- unsigned char *s = NULL, *tmpPointer = NULL;
- int32_t ch = 0;
- int32_t cnt = 0;
- jobject widths = NULL;
- jint tempWidths[256];
- jint maxAdvance = 0;
- int32_t widlen = 0;
-
- if (JNU_IsNull(env, str)) {
- JNU_ThrowNullPointerException(env, "NullPointerException");
- return 0;
- }
-
- cnt = (*env)->GetArrayLength(env, str);
- if (cnt == 0) {
- return 0;
- }
-
- widths = (*env)->GetObjectField(env, this, x11FontMetricsIDs.widths);
- maxAdvance = (*env)->GetIntField(env, this, x11FontMetricsIDs.maxAdvance);
- if (!JNU_IsNull(env, widths)) {
- w = 0;
- widlen = (*env)->GetArrayLength(env, widths);
- (*env)->GetIntArrayRegion(env, widths, 0, widlen, (jint *) tempWidths);
-
- s = tmpPointer = (unsigned char *) (*env)->GetPrimitiveArrayCritical(env, str, NULL);
- if (s == NULL) {
- return 0;
- }
-
- while (--cnt >= 0) {
- ch = *tmpPointer++;
- if (ch < widlen) {
- w += tempWidths[ch];
- } else {
- w += maxAdvance;
- }
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, str, (jchar *) s, JNI_ABORT);
- } else {
- w = maxAdvance * cnt;
- }
- return w;
-}
-
-/*
- * Class: sun_awt_motif_X11FontMetrics
- * Method: init
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_awt_motif_X11FontMetrics_init
- (JNIEnv *env, jobject this)
-{
- jobject font = NULL;
- struct FontData *fdata = NULL;
- jint tempWidths[256];
- jintArray widths = NULL;
- int32_t ccount = 0;
- int32_t i = 0;
- int32_t tempWidthsIndex = 0;
- char *err = NULL;
-
- if (JNU_IsNull(env, this)) {
- JNU_ThrowNullPointerException(env, "NullPointerException");
- return;
- }
- AWT_LOCK();
-
- font = (*env)->GetObjectField(env, this, x11FontMetricsIDs.font);
- if (JNU_IsNull(env, this)) {
- JNU_ThrowNullPointerException(env, "NullPointerException");
- AWT_UNLOCK();
- return;
- }
- fdata = awtJNI_GetFontData(env, font, &err);
- if (fdata == NULL) {
- JNU_ThrowInternalError(env, err);
- AWT_UNLOCK();
- return;
- }
-
- /*
- * Bug 4103248, 4120310. We must take all of the fonts into
- * consideration in providing the metrics, not just the 8859-1 font,
- * because the underlying Motif widgets are.
- */
- if (awtJNI_IsMultiFont(env, font) && fdata->xfs == NULL) {
- fdata->xfs = awtJNI_MakeFontSet(env, font);
- }
- if (fdata->xfs != NULL) {
- XFontSetExtents *fs_extents = NULL;
- fs_extents = XExtentsOfFontSet(fdata->xfs);
-
- (*env)->SetIntField(env, this, x11FontMetricsIDs.maxAscent,
- (jint)(-fs_extents->max_logical_extent.y));
- (*env)->SetIntField(env, this, x11FontMetricsIDs.maxDescent,
- (jint)(fs_extents->max_logical_extent.height +
- fs_extents->max_logical_extent.y));
- (*env)->SetIntField(env, this, x11FontMetricsIDs.maxAdvance,
- (jint)(fs_extents->max_logical_extent.width));
- (*env)->SetIntField(env, this, x11FontMetricsIDs.ascent,
- (jint)(-fs_extents->max_ink_extent.y));
- (*env)->SetIntField(env, this, x11FontMetricsIDs.descent,
- (jint)(fs_extents->max_ink_extent.height +
- fs_extents->max_ink_extent.y));
- } else {
- (*env)->SetIntField(env, this, x11FontMetricsIDs.maxAscent,
- (jint) fdata->xfont->max_bounds.ascent);
- (*env)->SetIntField(env, this, x11FontMetricsIDs.maxDescent,
- (jint) fdata->xfont->max_bounds.descent);
- (*env)->SetIntField(env, this, x11FontMetricsIDs.maxAdvance,
- (jint) fdata->xfont->max_bounds.width);
- (*env)->SetIntField(env, this, x11FontMetricsIDs.ascent,
- (jint) fdata->xfont->ascent);
- (*env)->SetIntField(env, this, x11FontMetricsIDs.descent,
- (jint) fdata->xfont->descent);
- }
-
- (*env)->SetIntField(env, this, x11FontMetricsIDs.leading, (jint) 1);
- (*env)->SetIntField(env, this, x11FontMetricsIDs.height,
- (jint) fdata->xfont->ascent + fdata->xfont->descent + 1);
- (*env)->SetIntField(env, this, x11FontMetricsIDs.maxHeight,
- (jint) fdata->xfont->max_bounds.ascent
- + fdata->xfont->max_bounds.descent + 1);
-
-
- widths = (*env)->NewIntArray(env, 256);
- (*env)->SetObjectField(env, this, x11FontMetricsIDs.widths, widths);
- if (JNU_IsNull(env, widths)) {
- JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
- AWT_UNLOCK();
- return;
- }
- /*
- * We could pin the array and then release it, but I believe this method
- * is faster and perturbs the VM less
- *
- */
- memset(tempWidths, 0, 256 * sizeof(jint));
-
- tempWidthsIndex = fdata->xfont->min_char_or_byte2;
-
- ccount = fdata->xfont->max_char_or_byte2 - fdata->xfont->min_char_or_byte2;
-
- if (fdata->xfont->per_char) {
- for (i = 0; i <= ccount; i++) {
- tempWidths[tempWidthsIndex++] = (jint) fdata->xfont->per_char[i].width;
- }
- } else {
- for (i = 0; i <= ccount; i++) {
- tempWidths[tempWidthsIndex++] = (jint) fdata->xfont->max_bounds.width;
- }
- }
-
- (*env)->SetIntArrayRegion(env, widths, 0, 256, (jint *) tempWidths);
-
- AWT_UNLOCK();
-}
-
-/*
* Registered with the 2D disposer to be called after the Font is GC'd.
*/
static void pDataDisposeMethod(JNIEnv *env, jlong pData)
--- a/jdk/src/solaris/native/sun/awt/awt_Font.h Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_Font.h Thu Dec 15 19:52:13 2011 -0800
@@ -34,8 +34,8 @@
jmethodID getFamily;
};
-/* fieldIDs for MFontPeer fields that may be accessed from C */
-struct MFontPeerIDs {
+/* fieldIDs for XFontPeer fields that may be accessed from C */
+struct XFontPeerIDs {
jfieldID xfsname;
};
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c Thu Dec 15 19:52:13 2011 -0800
@@ -45,7 +45,6 @@
#include <stdlib.h>
#include "awt_GraphicsEnv.h"
-#include "awt_Window.h"
#include "awt_util.h"
#include "gdefs.h"
#include <dlfcn.h>
@@ -94,8 +93,6 @@
struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
struct X11GraphicsDeviceIDs x11GraphicsDeviceIDs;
-extern struct WindowIDs mWindowIDs;
-extern struct MWindowPeerIDs mWindowPeerIDs;
#ifndef HEADLESS
int awtCreateX11Colormap(AwtGraphicsConfigDataPtr adata);
@@ -570,75 +567,6 @@
AWT_UNLOCK ();
}
-/*
- * Determing if this top-level has been moved onto another Xinerama screen.
- * Called from awt_TopLevel.c
- *
- * ASSUME: wdata != null
- */
-#ifndef HEADLESS
-void checkNewXineramaScreen(JNIEnv* env, jobject peer, struct FrameData* wdata,
- int32_t newX, int32_t newY,
- int32_t newWidth, int32_t newHeight) {
- int i;
- int amt;
- int totAmt = 0;
- int largestAmt = 0;
- int largestAmtScr = 0;
-
- int horiz;
- int vert;
-
- if (!usingXinerama) { return; }
-
- totAmt = newWidth * newHeight;
-
- /* assert that peer implements WindowPeer */
- DASSERT(JNU_IsInstanceOfByName(env, peer, "java/awt/peer/WindowPeer"));
-
- DTRACE_PRINTLN4("checkNewXineramaScreen() x=%i y=%i w=%i h=%i\n",newX, newY, newWidth, newHeight);
-
- /* decide which screen we're on
- * if we're spanning, figure out which screen we're most on
- */
- for (i = 0; i < awt_numScreens; i++) {
- if (INTERSECTS(newX, newX + newWidth, newY, newY + newHeight,
- fbrects[i].x, fbrects[i].x + fbrects[i].width,
- fbrects[i].y, fbrects[i].y + fbrects[i].height)) {
-
- /* calc how much of window is on this screen */
- horiz = MIN(newX + newWidth, fbrects[i].x + fbrects[i].width) -
- MAX(newX, fbrects[i].x);
- vert = MIN(newY + newHeight, fbrects[i].y + fbrects[i].height) -
- MAX(newY, fbrects[i].y);
- DASSERT(horiz > 0);
- DASSERT(vert > 0);
-
- amt = horiz * vert;
- if (amt == totAmt) {
- /* completely on this screen - done! */
- largestAmtScr = i;
- break;
- }
- if (amt > largestAmt) {
- largestAmt = amt;
- largestAmtScr = i;
- }
- }
- }
-
-#ifndef XAWT
- /* check if we're on a new screen */
- if (largestAmtScr != wdata->screenNum) {
- wdata->screenNum = largestAmtScr;
- /* update peer, target Comp */
- (*env)->CallVoidMethod(env, peer,
- mWindowPeerIDs.draggedToScreenMID, largestAmtScr);
- }
-#endif /* XAWT */
-}
-#endif /* HEADLESS */
-
#ifndef HEADLESS
#ifdef __linux__
static void xinerama_init_linux()
@@ -1434,11 +1362,17 @@
fbrects[screen].height);
}
else {
+ XWindowAttributes xwa;
+ memset(&xwa, 0, sizeof(xwa));
+
+ AWT_LOCK ();
+ XGetWindowAttributes(awt_display,
+ RootWindow(awt_display, adata->awt_visInfo.screen),
+ &xwa);
+ AWT_UNLOCK ();
+
bounds = (*env)->NewObject(env, clazz, mid, 0, 0,
- DisplayWidth(awt_display,
- adata->awt_visInfo.screen),
- DisplayHeight(awt_display,
- adata->awt_visInfo.screen));
+ xwa.width, xwa.height);
}
if ((*env)->ExceptionOccurred(env)) {
--- a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c Thu Dec 15 19:52:13 2011 -0800
@@ -30,28 +30,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
-#ifdef XAWT
#include <sys/time.h>
-#else /* !XAWT */
-#include <Xm/Xm.h>
-#include <Xm/RowColumn.h>
-#include <Xm/MwmUtil.h>
-#include <Xm/MenuShell.h>
-#endif /* XAWT */
#include "awt.h"
#include "awt_p.h"
#include <sun_awt_X11InputMethod.h>
-#ifdef XAWT
#include <sun_awt_X11_XComponentPeer.h>
#include <sun_awt_X11_XInputMethod.h>
-#else /* !XAWT */
-#include <sun_awt_motif_MComponentPeer.h>
-#include <sun_awt_motif_MInputMethod.h>
-
-#define MCOMPONENTPEER_CLASS_NAME "sun/awt/motif/MComponentPeer"
-#endif /* XAWT */
#define THROW_OUT_OF_MEMORY_ERROR() \
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL)
@@ -111,11 +97,7 @@
typedef struct {
Window w; /*status window id */
Window root; /*the root window id */
-#ifdef XAWT
Window parent; /*parent shell window */
-#else
- Widget parent; /*parent shell window */
-#endif
int x, y; /*parent's upperleft position */
int width, height; /*parent's width, height */
GC lightGC; /*gc for light border */
@@ -141,17 +123,10 @@
XIC ic_active; /* X Input Context for active clients */
XIC ic_passive; /* X Input Context for passive clients */
XIMCallback *callbacks; /* callback parameters */
-#ifndef XAWT
- jobject peer; /* MComponentPeer of client Window */
-#endif /* XAWT */
jobject x11inputmethod; /* global ref to X11InputMethod instance */
/* associated with the XIC */
#ifdef __linux__
StatusWindow *statusWindow; /* our own status window */
-#else
-#ifndef XAWT
- Widget statusWidget; /* IM status window widget */
-#endif /* XAWT */
#endif
char *lookup_buf; /* buffer used for XmbLookupString */
int lookup_buf_len; /* lookup buffer size in bytes */
@@ -191,12 +166,6 @@
#define GetJNIEnv() (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2)
-#ifndef XAWT
-static jobject mcompClass = NULL;
-static jobject awteventClass = NULL;
-static jfieldID mcompPDataID = NULL;
-#endif /* XAWT */
-
static void DestroyXIMCallback(XIM, XPointer, XPointer);
static void OpenXIMCallback(Display *, XPointer, XPointer);
/* Solaris XIM Extention */
@@ -261,28 +230,6 @@
return mbs;
}
-#ifndef XAWT
-/*
- * Find a class for the given class name and return a global reference to the
- * class.
- */
-static jobject
-findClass(const char *className)
-{
- JNIEnv *env = GetJNIEnv();
- jclass classClass;
- jobject objectClass;
-
- classClass = (*env)->FindClass(env, className);
- objectClass = (*env)->NewGlobalRef(env,classClass);
-
- if (JNU_IsNull(env, objectClass)) {
- JNU_ThrowClassNotFoundException(env, className);
- }
- return objectClass;
-}
-#endif /* XAWT */
-
/*
* Returns True if the global reference is still in the list,
* otherwise False.
@@ -444,9 +391,6 @@
free((void *)pX11IMData->callbacks);
if (env) {
-#ifndef XAWT
- (*env)->DeleteGlobalRef(env, pX11IMData->peer);
-#endif /* XAWT */
/* Remove the global reference from the list, so that
the callback function or whoever refers to it could know.
*/
@@ -580,23 +524,10 @@
/* Get keysym without taking modifiers into account first to map
* to AWT keyCode table.
*/
-#ifndef XAWT
- if (((event->state & ShiftMask) ||
- (event->state & LockMask)) &&
- keysym >= 'A' && keysym <= 'Z')
- {
- keysym = XLookupKeysym(event, 0);
- }
-#endif
-
switch (status) {
case XLookupBoth:
if (!composing) {
-#ifdef XAWT
if (event->keycode != 0) {
-#else
- if (keysym < 128 || ((keysym & 0xff00) == 0xff00)) {
-#endif
*keysymp = keysym;
result = False;
break;
@@ -650,11 +581,7 @@
#ifdef __linux__
static StatusWindow *createStatusWindow(
-#ifdef XAWT
Window parent) {
-#else
- Widget parent) {
-#endif
StatusWindow *statusWindow;
XSetWindowAttributes attrib;
unsigned long attribmask;
@@ -682,22 +609,12 @@
Window *ignoreWindowPtr;
unsigned int ignoreUnit;
-#ifdef XAWT
XGetGeometry(dpy, parent, &rootWindow, &x, &y, &w, &h, &bw, &depth);
-#else
- while (!XtIsShell(parent)){
- parent = XtParent(parent);
- }
-#endif
attrib.override_redirect = True;
attribmask = CWOverrideRedirect;
for (i = 0; i < awt_numScreens; i++) {
-#ifdef XAWT
if (RootWindow(dpy, i) == rootWindow) {
-#else
- if (ScreenOfDisplay(dpy, i) == XtScreen(parent)) {
-#endif
screen = i;
break;
}
@@ -798,11 +715,7 @@
/* This method is to turn off or turn on the status window. */
static void onoffStatusWindow(X11InputMethodData* pX11IMData,
-#ifdef XAWT
Window parent,
-#else
- Widget parent,
-#endif
Bool ON){
XWindowAttributes xwa;
Window child;
@@ -820,15 +733,9 @@
statusWindow->on = False;
return;
}
-#ifdef XAWT
parent = JNU_CallMethodByName(GetJNIEnv(), NULL, pX11IMData->x11inputmethod,
"getCurrentParentWindow",
"()J").j;
-#else
- while (!XtIsShell(parent)){
- parent = XtParent(parent);
- }
-#endif
if (statusWindow->parent != parent){
statusWindow->parent = parent;
}
@@ -941,11 +848,7 @@
}
}
-#ifdef XAWT
static void adjustStatusWindow(Window shell){
-#else
-void adjustStatusWindow(Widget shell){
-#endif
JNIEnv *env = GetJNIEnv();
X11InputMethodData *pX11IMData = NULL;
StatusWindow *statusWindow;
@@ -957,11 +860,7 @@
|| !statusWindow->on) {
return;
}
-#ifdef XAWT
{
-#else
- if (statusWindow->parent == shell) {
-#endif
XWindowAttributes xwa;
int x, y;
Window child;
@@ -1009,12 +908,7 @@
* fallback to None styles.
*/
static Bool
-#ifdef XAWT
createXIC(JNIEnv * env, X11InputMethodData *pX11IMData, Window w)
-#else /* !XAWT */
-createXIC(Widget w, X11InputMethodData *pX11IMData,
- jobject tc, jobject peer)
-#endif /* XAWT */
{
XIC active_ic, passive_ic;
XVaNestedList preedit = NULL;
@@ -1031,17 +925,9 @@
if (X11im == NULL) {
return False;
}
-#ifdef XAWT
if (!w) {
return False;
}
-#else /* !XAWT */
- /*
- * If the parent window has one or more TextComponents, the status
- * area of Motif will be shared with the created XIC. Otherwise,
- * root-window style status is used.
- */
-#endif /* XAWT */
ret = XGetIMValues(X11im, XNQueryInputStyle, &im_styles, NULL);
@@ -1064,28 +950,7 @@
}
}
#else /*! __linux__ */
-#ifdef XAWT
on_the_spot_styles |= XIMStatusNothing;
-#else /* !XAWT */
- /*
- * If the parent window has one or more TextComponents, the status
- * area of Motif will be shared with the created XIC. Otherwise,
- * root-window style status is used.
- */
- if (tc != NULL){
- XVaNestedList status = NULL;
- status = awt_motif_getXICStatusAreaList(w, tc);
- if (status != NULL){
- on_the_spot_styles |= XIMStatusArea;
- XFree(status);
- }
- else
- on_the_spot_styles |= XIMStatusNothing;
- }
- else
- on_the_spot_styles |= XIMStatusNothing;
-
-#endif /* XAWT */
#endif /* __linux__ */
for (i = 0; i < im_styles->count_styles; i++) {
@@ -1157,32 +1022,12 @@
XFree((void *)preedit);
}
#else /* !__linux__ */
-#ifndef XAWT
- if (on_the_spot_styles & XIMStatusArea) {
- Widget parent;
- status = awt_motif_getXICStatusAreaList(w, tc);
- if (status == NULL)
- goto err;
- pX11IMData->statusWidget = awt_util_getXICStatusAreaWindow(w);
- pX11IMData->ic_active = XCreateIC(X11im,
- XNClientWindow, pX11IMData->statusWidget,
- XNFocusWindow, w,
- XNInputStyle, active_styles,
- XNPreeditAttributes, preedit,
- XNStatusAttributes, status,
- NULL);
- XFree((void *)status);
- } else {
-#endif /* XAWT */
pX11IMData->ic_active = XCreateIC(X11im,
XNClientWindow, w,
XNFocusWindow, w,
XNInputStyle, active_styles,
XNPreeditAttributes, preedit,
NULL);
-#ifndef XAWT
- }
-#endif /* XAWT */
XFree((void *)preedit);
#endif /* __linux__ */
pX11IMData->ic_passive = XCreateIC(X11im,
@@ -1479,7 +1324,7 @@
}
/*
- * Class: java_sun_awt_motif_X11InputMethod
+ * Class: sun_awt_X11InputMethod
* Method: initIDs
* Signature: ()V
*/
@@ -1495,24 +1340,15 @@
JNIEXPORT jboolean JNICALL
-#ifdef XAWT
Java_sun_awt_X11_XInputMethod_openXIMNative(JNIEnv *env,
jobject this,
jlong display)
-#else
-Java_sun_awt_motif_MInputMethod_openXIMNative(JNIEnv *env,
- jobject this)
-#endif
{
Bool registered;
AWT_LOCK();
-#ifdef XAWT
dpy = (Display *)jlong_to_ptr(display);
-#else
- dpy = awt_display;
-#endif
/* Use IMInstantiate call back only on Linux, as there is a bug in Solaris
(4768335)
@@ -1534,30 +1370,17 @@
}
JNIEXPORT jboolean JNICALL
-#ifdef XAWT
Java_sun_awt_X11_XInputMethod_createXICNative(JNIEnv *env,
jobject this,
jlong window)
{
-#else /* !XAWT */
-Java_sun_awt_motif_MInputMethod_createXICNative(JNIEnv *env,
- jobject this,
- jobject comp,
- jobject tc)
-{
- struct ComponentData *cdata;
-#endif /* XAWT */
X11InputMethodData *pX11IMData;
jobject globalRef;
XIC ic;
AWT_LOCK();
-#ifdef XAWT
if (!window) {
-#else /* !XAWT */
- if (JNU_IsNull(env, comp)) {
-#endif /* XAWT */
JNU_ThrowNullPointerException(env, "NullPointerException");
AWT_UNLOCK();
return JNI_FALSE;
@@ -1570,40 +1393,16 @@
return JNI_FALSE;
}
-#ifndef XAWT
- if (mcompClass == NULL) {
- mcompClass = findClass(MCOMPONENTPEER_CLASS_NAME);
- mcompPDataID = (*env)->GetFieldID(env, mcompClass, "pData", "J");
- }
- cdata = (struct ComponentData *) JNU_GetLongFieldAsPtr(env,comp,mcompPDataID);
-
- if (cdata == 0) {
- free((void *)pX11IMData);
- JNU_ThrowNullPointerException(env, "createXIC");
- AWT_UNLOCK();
- return JNI_FALSE;
- }
-
- pX11IMData->peer = (*env)->NewGlobalRef(env, comp);
-#endif /* XAWT */
globalRef = (*env)->NewGlobalRef(env, this);
pX11IMData->x11inputmethod = globalRef;
#ifdef __linux__
pX11IMData->statusWindow = NULL;
-#else /* __linux__ */
-#ifndef XAWT
- pX11IMData->statusWidget = (Widget) NULL;
-#endif /* XAWT */
#endif /* __linux__ */
pX11IMData->lookup_buf = 0;
pX11IMData->lookup_buf_len = 0;
-#ifdef XAWT
if (createXIC(env, pX11IMData, (Window)window)
-#else /* !XAWT */
- if (createXIC(cdata->widget, pX11IMData, tc, comp)
-#endif /* XAWT */
== False) {
destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
pX11IMData = (X11InputMethodData *) NULL;
@@ -1615,77 +1414,6 @@
return (pX11IMData != NULL);
}
-#ifndef XAWT
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MInputMethod_reconfigureXICNative(JNIEnv *env,
- jobject this,
- jobject comp,
- jobject tc)
-{
- X11InputMethodData *pX11IMData;
-
- AWT_LOCK();
-
- pX11IMData = getX11InputMethodData(env, this);
- if (pX11IMData == NULL) {
- AWT_UNLOCK();
- return;
- }
-
- if (pX11IMData->current_ic == (XIC)0) {
- destroyX11InputMethodData(env, pX11IMData);
- pX11IMData = (X11InputMethodData *)NULL;
- } else {
- Bool active;
- struct ComponentData *cdata;
-
- active = pX11IMData->current_ic == pX11IMData->ic_active;
- if (mcompClass == NULL) {
- mcompClass = findClass(MCOMPONENTPEER_CLASS_NAME);
- mcompPDataID = (*env)->GetFieldID(env, mcompClass, "pData", "J");
- }
- cdata = (struct ComponentData *) JNU_GetLongFieldAsPtr(env,comp,mcompPDataID);
- if (cdata == 0) {
- JNU_ThrowNullPointerException(env, "reconfigureXICNative");
- destroyX11InputMethodData(env, pX11IMData);
- pX11IMData = (X11InputMethodData *)NULL;
- }
- XDestroyIC(pX11IMData->ic_active);
- if (pX11IMData->ic_active != pX11IMData->ic_passive)
- XDestroyIC(pX11IMData->ic_passive);
- pX11IMData->current_ic = (XIC)0;
- pX11IMData->ic_active = (XIC)0;
- pX11IMData->ic_passive = (XIC)0;
- if (createXIC(cdata->widget, pX11IMData, tc, comp)) {
- pX11IMData->current_ic = active ?
- pX11IMData->ic_active : pX11IMData->ic_passive;
- /*
- * On Solaris2.6, setXICWindowFocus() has to be invoked
- * before setting focus.
- */
- setXICWindowFocus(pX11IMData->current_ic, cdata->widget);
- setXICFocus(pX11IMData->current_ic, True);
- } else {
- destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
- pX11IMData = (X11InputMethodData *)NULL;
- }
- }
-
- setX11InputMethodData(env, this, pX11IMData);
-
- AWT_UNLOCK();
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MInputMethod_setXICFocusNative(JNIEnv *env,
- jobject this,
- jobject comp,
- jboolean req,
- jboolean active)
-{
- struct ComponentData *cdata;
- Widget w;
-#else /* !XAWT */
JNIEXPORT void JNICALL
Java_sun_awt_X11_XInputMethod_setXICFocusNative(JNIEnv *env,
jobject this,
@@ -1693,7 +1421,6 @@
jboolean req,
jboolean active)
{
-#endif /* XAWT */
X11InputMethodData *pX11IMData;
AWT_LOCK();
pX11IMData = getX11InputMethodData(env, this);
@@ -1703,40 +1430,16 @@
}
if (req) {
-#ifdef XAWT
if (!w) {
AWT_UNLOCK();
return;
}
-#else /* !XAWT */
- struct ComponentData *cdata;
-
- if (JNU_IsNull(env, comp)) {
- AWT_UNLOCK();
- return;
- }
- if (mcompClass == NULL) {
- mcompClass = findClass(MCOMPONENTPEER_CLASS_NAME);
- mcompPDataID = (*env)->GetFieldID(env, mcompClass, "pData", "J");
- }
- cdata = (struct ComponentData *)JNU_GetLongFieldAsPtr(env, comp,
- mcompPDataID);
- if (cdata == 0) {
- JNU_ThrowNullPointerException(env, "setXICFocus pData");
- AWT_UNLOCK();
- return;
- }
-#endif /* XAWT */
-
pX11IMData->current_ic = active ?
pX11IMData->ic_active : pX11IMData->ic_passive;
/*
* On Solaris2.6, setXICWindowFocus() has to be invoked
* before setting focus.
*/
-#ifndef XAWT
- w = cdata->widget;
-#endif /* XAWT */
setXICWindowFocus(pX11IMData->current_ic, w);
setXICFocus(pX11IMData->current_ic, req);
currentX11InputMethodInstance = pX11IMData->x11inputmethod;
@@ -1853,40 +1556,6 @@
return jText;
}
-#ifndef XAWT
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MInputMethod_configureStatusAreaNative(JNIEnv *env,
- jobject this,
- jobject tc)
-{
- X11InputMethodData *pX11IMData;
- XVaNestedList status;
-
-#ifdef __linux__
- /*do nothing for linux? */
-#else
- AWT_LOCK();
- pX11IMData = getX11InputMethodData(env, this);
-
- if ((pX11IMData == NULL) || (pX11IMData->ic_active == (XIC)0)) {
- AWT_UNLOCK();
- return;
- }
-
- if (pX11IMData->statusWidget) {
- status = awt_motif_getXICStatusAreaList(pX11IMData->statusWidget, tc);
- if (status != (XVaNestedList)NULL) {
- XSetICValues(pX11IMData->ic_active,
- XNStatusAttributes, status,
- NULL);
- XFree((void *)status);
- }
- }
- AWT_UNLOCK();
-#endif
-}
-#endif /* XAWT */
-
/*
* Class: sun_awt_X11InputMethod
* Method: setCompositionEnabledNative
@@ -1964,7 +1633,6 @@
return (jboolean)(state == XIMPreeditEnable);
}
-#ifdef XAWT
JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
(JNIEnv *env, jobject this, jlong window)
{
@@ -1974,4 +1642,3 @@
AWT_UNLOCK();
#endif
}
-#endif
--- a/jdk/src/solaris/native/sun/awt/awt_KeyboardFocusManager.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "jni.h"
-
-struct KeyboardFocusManagerIDs {
- jclass keyboardFocusManagerCls;
- jmethodID shouldNativelyFocusHeavyweightMID;
- jmethodID heavyweightButtonDownMID;
- jmethodID heavyweightButtonDownZMID;
- jmethodID markClearGlobalFocusOwnerMID;
- jmethodID processSynchronousTransferMID;
- jfieldID isProxyActive;
-};
--- a/jdk/src/solaris/native/sun/awt/awt_MToolkit.c Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3430 +0,0 @@
-/*
- * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "awt_p.h"
-
-#include <sys/time.h>
-#include <limits.h>
-#include <locale.h>
-
-#ifndef HEADLESS
-#include <X11/cursorfont.h>
-#include <Xm/MenuShell.h>
-#include <Xm/RowColumn.h>
-#endif /* !HEADLESS */
-
-#include <jvm.h>
-#include <jni.h>
-#include <jlong.h>
-#include <jni_util.h>
-
-/* JNI headers */
-#include "java_awt_AWTEvent.h"
-#include "java_awt_Frame.h"
-#include "java_awt_SystemColor.h"
-#include "sun_awt_motif_MToolkit.h"
-
-/* JNI field and method ids */
-#include "awt_Component.h"
-//#include "awt_Cursor.h"
-#include "awt_MenuComponent.h"
-#include "awt_TopLevel.h"
-#include "canvas.h"
-#include "color.h"
-#include "awt_mgrsel.h"
-#include "awt_wm.h"
-#include "awt_DrawingSurface.h"
-#include "awt_Window.h"
-#include "awt_xembed.h"
-#include "awt_xembed_server.h"
-
-extern JavaVM *jvm;
-
-#ifndef HEADLESS
-#ifdef __linux__
-extern void statusWindowEventHandler(XEvent event);
-#endif
-#endif /* !HEADLESS */
-
-JNIEXPORT jint JNICALL
-JNI_OnLoad(JavaVM *vm, void *reserved)
-{
-#ifndef HEADLESS
- awt_util_debug_init();
-#endif /* !HEADLESS */
- jvm = vm;
- return JNI_VERSION_1_2;
-}
-
-JNIEXPORT jboolean JNICALL AWTIsHeadless() {
-#ifdef HEADLESS
- return JNI_TRUE;
-#else
- return JNI_FALSE;
-#endif
-}
-
-#ifndef HEADLESS
-static jlong awtJNI_TimeMillis(void);
-extern void awt_initialize_Xm_DnD(Display*);
-extern void awt_initialize_DataTransferer();
-
-extern Display *awt_init_Display(JNIEnv *env);
-
-extern void X11SD_LibDispose(JNIEnv *env);
-
-extern Widget drag_source = NULL;
-
-extern struct ComponentIDs componentIDs;
-extern struct MenuComponentIDs menuComponentIDs;
-extern struct MComponentPeerIDs mComponentPeerIDs;
-extern struct WindowIDs windowIDs;
-
-static Atom _XA_XSETTINGS_SETTINGS = None;
-struct xsettings_callback_cookie {
- jobject mtoolkit;
- jmethodID upcallMID;
-};
-
-static struct xsettings_callback_cookie xsettings_callback_cookie;
-
-
-static XEvent focusOutEvent;
-
-static void awt_pipe_init(void);
-static void processOneEvent(XtInputMask iMask);
-extern void waitForEvents(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe);
-#ifdef USE_SELECT
-static void performSelect(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe);
-#else
-static void performPoll(JNIEnv *env,int32_t fdXPipe, int32_t fdAWTPipe);
-#endif
-
-
-#include <X11/Intrinsic.h>
-#include <dlfcn.h>
-#include <fcntl.h>
-
-#ifdef USE_SELECT
-#if defined(AIX)
-#include <sys/select.h>
-#endif
-#else
-#include <poll.h>
-#ifndef POLLRDNORM
-#define POLLRDNORM POLLIN
-#endif
-#endif
-
-#ifdef NDEBUG
-#undef DEBUG /* NDEBUG overrides DEBUG */
-#endif
-
-static struct WidgetInfo *awt_winfo = (struct WidgetInfo *) NULL;
-static struct MenuList* menu_list = (struct MenuList*) NULL;
-
-#ifndef bzero
-#define bzero(a,b) memset(a, 0, b)
-#endif
-
-static jboolean syncUpdated = JNI_FALSE;
-static jboolean syncFailed = JNI_FALSE;
-static jint eventNumber = 0;
-static void syncWait_eventHandler(XEvent *);
-static Atom oops_atom = None;
-static Atom wm_selection = None;
-static Atom version_atom = None;
-
-static Boolean inSyncWait = False;
-
-Widget grabbed_widget = NULL;
-
-XtAppContext awt_appContext;
-Widget awt_root_shell;
-Pixel awt_defaultBg;
-Pixel awt_defaultFg;
-int32_t awt_multiclick_time; /* milliseconds */
-uint32_t awt_MetaMask = 0;
-uint32_t awt_AltMask = 0;
-uint32_t awt_NumLockMask = 0;
-uint32_t awt_ModeSwitchMask = 0;
-Cursor awt_scrollCursor;
-Boolean awt_ModLockIsShiftLock = False;
-extern Boolean awt_UseType4Patch;
-extern Boolean awt_UseXKB;
-
-#define SPECIAL_KEY_EVENT 2
-
-/* implement a "putback queue" -- see comments on awt_put_back_event() */
-#define PUTBACK_QUEUE_MIN_INCREMENT 5 /* min size increase */
-static XEvent *putbackQueue = NULL; /* the queue -- next event is 0 */
-static int32_t putbackQueueCount = 0; /* # of events available on queue */
-static int32_t putbackQueueCapacity = 0; /* total capacity of queue */
-static XtInputMask awt_events_pending(XtAppContext appContext);
-static int32_t awt_get_next_put_back_event(XEvent *xev_out);
-
-#define AWT_FLUSH_TIMEOUT ((uint32_t)100) /* milliseconds */
-#define AWT_MIN_POLL_TIMEOUT ((uint32_t)0) /* milliseconds */
-#define AWT_MAX_POLL_TIMEOUT ((uint32_t)250) /* milliseconds */
-
-#define AWT_POLL_BUFSIZE 100
-#define AWT_READPIPE (awt_pipe_fds[0])
-#define AWT_WRITEPIPE (awt_pipe_fds[1])
-#define AWT_FLUSHOUTPUT_NOW() \
-{ \
- XFlush(awt_display); \
- awt_next_flush_time = 0LL; \
-}
-
-typedef XtIntervalId (*XTFUNC)();
-
-static jobject awt_MainThread = NULL;
-static char read_buf[AWT_POLL_BUFSIZE + 1]; /* dummy buf to empty pipe */
-static int32_t awt_pipe_fds[2]; /* fds for wkaeup pipe */
-static Boolean awt_pipe_inited = False; /* make sure pipe is initialized before write */
-static int32_t def_poll_timeout = AWT_MAX_POLL_TIMEOUT; /* default value for timeout */
-static jlong awt_next_flush_time = 0LL; /* 0 == no scheduled flush */
-static void *xt_lib = NULL;
-static XTFUNC xt_timeout = NULL;
-
-#ifdef DEBUG_AWT_LOCK
-
-int32_t awt_locked = 0;
-char *lastF = "";
-int32_t lastL = -1;
-
-#endif
-
-#ifndef NOMODALFIX
-extern Boolean awt_isModal();
-extern Boolean awt_isWidgetModal(Widget w);
-#endif
-
-Boolean keyboardGrabbed = False;
-
-static uint32_t curPollTimeout = AWT_MAX_POLL_TIMEOUT;
-
-/* Font information to feed Motif widgets. */
-static const char *motifFontList;
-static XFontSet defaultMotifFontSet;
-static XFontStruct *defaultMotifFontStruct;
-static const char *defaultMotifFont = /* a.k.a "fixed", known everywhere */
- "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1";
-
-XFontSet getMotifFontSet() {
- char **missingList;
- int32_t missingCount;
- char *defChar;
-
- return XCreateFontSet(awt_display, motifFontList,
- &missingList, &missingCount, &defChar);
-}
-
-XFontStruct *getMotifFontStruct() {
- return XLoadQueryFont(awt_display, defaultMotifFont);
-}
-
-XmFontList getMotifFontList() {
- XmFontListEntry motifFontListEntry;
- XmFontList fontlist;
-
- if (strchr(motifFontList, ',') == NULL) {
- /* If the default font is a single font. */
- if (defaultMotifFontStruct == NULL)
- defaultMotifFontStruct = getMotifFontStruct();
- motifFontListEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
- XmFONT_IS_FONT,
- (XtPointer)defaultMotifFontStruct);
- }
- else {
- /* If the default font is multiple fonts. */
- if (defaultMotifFontSet == NULL)
- defaultMotifFontSet = getMotifFontSet();
- motifFontListEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
- XmFONT_IS_FONTSET,
- (XtPointer)defaultMotifFontSet);
- }
- fontlist = XmFontListAppendEntry(NULL, motifFontListEntry);
- XmFontListEntryFree(&motifFontListEntry);
- return fontlist;
-}
-
-static void
-awt_set_poll_timeout (uint32_t newTimeout)
-{
- DTRACE_PRINTLN1("awt_set_poll_timeout(%lu)", newTimeout);
-
- newTimeout = max(AWT_MIN_POLL_TIMEOUT, newTimeout);
- newTimeout = min(AWT_MAX_POLL_TIMEOUT, newTimeout);
- newTimeout = min(newTimeout, curPollTimeout);
- curPollTimeout = newTimeout;
-
-} /* awt_set_poll_timeout */
-
-/*
- * Gets the best timeout for the next call to poll() or select().
- * If timedOut is True, we assume that our previous timeout elapsed
- * with no events/timers arriving. Therefore, we can increase the
- * next timeout slightly.
- */
-static uint32_t
-awt_get_poll_timeout( Boolean timedOut )
-{
- uint32_t timeout = AWT_MAX_POLL_TIMEOUT;
-
- DTRACE_PRINTLN2("awt_get_poll_timeout(%s), awt_next_flush_time:%ld",
- (remove?"true":"false"),
- awt_next_flush_time);
-
- if (timedOut) {
- /* add 1/16 (plus 1, in case the division truncates to 0) */
- curPollTimeout += ((curPollTimeout>>4) + 1);
- curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
- }
- if (awt_next_flush_time > 0) {
- int32_t flushDiff = (int32_t)(awt_next_flush_time - awtJNI_TimeMillis());
- timeout = min(curPollTimeout, flushDiff);
- } else {
- timeout = curPollTimeout;
- }
-
- return timeout;
-} /* awt_get_poll_timeout() */
-
-static jlong
-awtJNI_TimeMillis(void)
-{
- struct timeval t;
-
- gettimeofday(&t, 0);
-
- return jlong_add(jlong_mul(jint_to_jlong(t.tv_sec), jint_to_jlong(1000)),
- jint_to_jlong(t.tv_usec / 1000));
-}
-
-static int32_t
-xtError()
-{
-#ifdef DEBUG
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
- jio_fprintf(stderr, "Xt error\n");
- JNU_ThrowNullPointerException(env, "NullPointerException");
-#endif
- return 0;
-}
-
-static int32_t
-xIOError(Display *dpy)
-{
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- jclass cl = (*env)->FindClass(env, "java/lang/Thread");
-
- if (errno == EPIPE) {
- jio_fprintf(stderr, "X connection to %s host broken (explicit kill or server shutdown)\n", XDisplayName(NULL));
- }
- AWT_NOFLUSH_UNLOCK();
- JVM_RaiseSignal(JVM_SIGTERM); /* Shut down cleanly */
- if (cl != NULL) {
- JVM_Sleep(env, cl, 20000);
- }
-
- return 0; /* to keep compiler happy */
-}
-
-/* Like XKeysymToKeycode, but ensures that keysym is the primary
- * symbol on the keycode returned. Returns zero otherwise.
- */
-static int32_t
-keysym_to_keycode_if_primary(Display *dpy, KeySym sym)
-{
- KeyCode code;
- KeySym primary;
-
- code = XKeysymToKeycode(dpy, sym);
- if (code == 0) {
- return 0;
- }
-
- primary = XKeycodeToKeysym(dpy, code, 0);
- if (sym == primary) {
- return code;
- } else {
- return 0;
- }
-}
-/*
- * +kb or -kb ?
- */
-static Boolean
-isXKBenabled(Display *display) {
- int mop, beve, berr;
- /*
- * NB: TODO: hope it will return False if XkbIgnoreExtension was called!
- */
- return XQueryExtension(display, "XKEYBOARD", &mop, &beve, &berr);
-}
-
-
-/* Assign meaning - alt, meta, etc. - to X modifiers mod1 ... mod5.
- * Only consider primary symbols on keycodes attached to modifiers.
- */
-static void
-setup_modifier_map(Display *disp)
-{
- KeyCode metaL = keysym_to_keycode_if_primary(disp, XK_Meta_L);
- KeyCode metaR = keysym_to_keycode_if_primary(disp, XK_Meta_R);
- KeyCode altL = keysym_to_keycode_if_primary(disp, XK_Alt_L);
- KeyCode altR = keysym_to_keycode_if_primary(disp, XK_Alt_R);
- KeyCode numLock = keysym_to_keycode_if_primary(disp, XK_Num_Lock);
- KeyCode modeSwitch = keysym_to_keycode_if_primary(disp, XK_Mode_switch);
- KeyCode shiftLock = keysym_to_keycode_if_primary(disp, XK_Shift_Lock);
- KeyCode capsLock = keysym_to_keycode_if_primary(disp, XK_Caps_Lock);
-
- XModifierKeymap *modmap = NULL;
- int32_t nkeys, modn, i;
- char *ptr = NULL;
-
- DTRACE_PRINTLN("In setup_modifier_map");
-
- modmap = XGetModifierMapping(disp);
- nkeys = modmap->max_keypermod;
-
- for (modn = Mod1MapIndex;
- (modn <= Mod5MapIndex) &&
- (awt_MetaMask == 0 || awt_AltMask == 0 ||
- awt_NumLockMask == 0 || awt_ModeSwitchMask == 0);
- ++modn)
- {
- static const uint32_t modmask[8] = {
- ShiftMask, LockMask, ControlMask,
- Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
- };
-
-
- for (i = 0; i < nkeys; ++i) {
- /* for each keycode attached to this modifier */
- KeyCode keycode = modmap->modifiermap[modn * nkeys + i];
- if (keycode == 0) {
- continue;
- }
-
- if (awt_MetaMask == 0 && (keycode == metaL || keycode == metaR)) {
- awt_MetaMask = modmask[modn];
- DTRACE_PRINTLN2(" awt_MetaMask = %d, modn = %d", awt_MetaMask, modn);
- break;
- } else if (awt_AltMask == 0 && (keycode == altL || keycode == altR)) {
- awt_AltMask = modmask[modn];
- DTRACE_PRINTLN2(" awt_AltMask = %d, modn = %d", awt_AltMask, modn);
- break;
- } else if (awt_NumLockMask == 0 && keycode == numLock) {
- awt_NumLockMask = modmask[modn];
- DTRACE_PRINTLN2(" awt_NumLockMask = %d, modn = %d", awt_NumLockMask, modn);
- break;
- } else if (awt_ModeSwitchMask == 0 && keycode == modeSwitch) {
- awt_ModeSwitchMask = modmask[modn];
- DTRACE_PRINTLN2(" awt_ModeSwitchMask = %d, modn = %d", awt_ModeSwitchMask, modn);
- break;
- }
- }
- }
- for(i = 0; i < nkeys; i++) {
- KeyCode keycode = modmap->modifiermap[LockMapIndex * nkeys + i];
- if (keycode == 0) {
- break;
- }
- if (keycode == shiftLock) {
- awt_ModLockIsShiftLock = True;
- break;
- }
- if (keycode == capsLock) {
- break;
- }
- }
-
- DTRACE_PRINTLN1(" ShiftMask = %d", ShiftMask);
- DTRACE_PRINTLN1(" ControlMask = %d", ControlMask);
-
- XFreeModifiermap(modmap);
- ptr = getenv("_AWT_USE_TYPE4_PATCH");
- if( ptr != NULL && ptr[0] != 0 ) {
- if( strncmp("true", ptr, 4) == 0 ) {
- awt_UseType4Patch = True;
- }else if( strncmp("false", ptr, 5) == 0 ) {
- awt_UseType4Patch = False;
- }
- }
- awt_UseXKB = isXKBenabled(disp);
-
-}
-
-
-Boolean scrollBugWorkAround;
-
-
-void
-awt_output_flush()
-{
- char c = 'p';
-
- if (awt_next_flush_time == 0)
- {
- Boolean needsWakeup = False;
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- if (awt_pipe_inited && (awt_get_poll_timeout(False) > (2*AWT_FLUSH_TIMEOUT))){
- needsWakeup = True;
- }
- /* awt_next_flush_time affects awt_get_poll_timeout(), so set
- * the variable *after* calling the function.
- */
- awt_next_flush_time = awtJNI_TimeMillis() + AWT_FLUSH_TIMEOUT;
- if (needsWakeup)
- {
- /* write to the utility pipe to wake up the event
- * loop, if it's sleeping
- */
- write ( AWT_WRITEPIPE, &c, 1 );
- }
- }
-#ifdef FLUSHDEBUG
-else
-jio_fprintf(stderr, "!");
-#endif
-} /* awt_output_flush() */
-
-void
-null_event_handler(Widget w, XtPointer client_data,
- XEvent * event, Boolean * cont)
-{
- /* do nothing */
-}
-
-struct WidgetInfo *
-findWidgetInfo(Widget widget)
-{
- struct WidgetInfo *cw;
-
- for (cw = awt_winfo; cw != NULL; cw = cw->next) {
- if (cw->widget == widget || cw->origin == widget) {
- return cw;
- }
- }
- return NULL;
-}
-
-void
-awt_addWidget(Widget w, Widget origin, void *peer, jlong event_flags)
-{
- if (findWidgetInfo(w) != NULL) return;
-
- if (!XtIsSubclass(w, xmFileSelectionBoxWidgetClass)) {
- struct WidgetInfo *nw = (struct WidgetInfo *) malloc(sizeof(struct WidgetInfo));
-
- if (nw) {
- nw->widget = w;
- nw->origin = origin;
- nw->peer = peer;
- nw->event_mask = event_flags;
- nw->next = awt_winfo;
- awt_winfo = nw;
-
- if (event_flags & java_awt_AWTEvent_MOUSE_EVENT_MASK) {
- XtAddEventHandler(w,
- ButtonPressMask | ButtonReleaseMask |
- EnterWindowMask | LeaveWindowMask,
- False, null_event_handler, NULL);
- if (w != origin) {
- XtAddEventHandler(origin,
- ButtonPressMask | ButtonReleaseMask |
- EnterWindowMask | LeaveWindowMask,
- False, null_event_handler, NULL);
- }
- }
- if (event_flags & java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK) {
- XtAddEventHandler(w,
- PointerMotionMask,
- False, null_event_handler, NULL);
- if (w != origin) {
- XtAddEventHandler(origin,
- PointerMotionMask,
- False, null_event_handler, NULL);
- }
- }
- if (event_flags & java_awt_AWTEvent_KEY_EVENT_MASK) {
- XtAddEventHandler(w,
- KeyPressMask | KeyReleaseMask,
- False, null_event_handler, NULL);
- if (w != origin) {
- XtAddEventHandler(origin,
- KeyPressMask | KeyReleaseMask,
- False, null_event_handler, NULL);
- }
- }
- } else {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
- }
-
- }
-}
-
-void
-awt_delWidget(Widget w)
-{
- struct WidgetInfo *cw;
-
- if (awt_winfo != NULL) {
- if ((awt_winfo->widget == w) ||
- (awt_winfo->origin == w)) {
- cw = awt_winfo;
- awt_winfo = awt_winfo->next;
- free((void *) cw);
- } else {
- struct WidgetInfo *pw;
-
- for (pw = awt_winfo, cw = awt_winfo->next;
- cw != NULL;
- pw = cw, cw = cw->next) {
- if ((cw->widget == w) ||
- (cw->origin == w)) {
- pw->next = cw->next;
- free((void *) cw);
- break;
- }
- }
- }
- }
-}
-
-
-void *
-findPeer(Widget * pwidget)
-{
- struct WidgetInfo *cw;
- Widget widgetParent;
- void * peer;
-
- if ((cw = findWidgetInfo(*pwidget)) != NULL) {
- return cw->peer;
- }
- /* fix for 4053856, robi.khan@eng
- couldn't find peer corresponding to widget
- but the widget may be child of one with
- a peer, so recurse up the hierarchy */
- widgetParent = XtParent(*pwidget);
- if (widgetParent != NULL ) {
- peer = findPeer(&widgetParent);
- if( peer != NULL ) {
- /* found peer attached to ancestor of given
- widget, so set widget return value as well */
- *pwidget = widgetParent;
- return peer;
- }
- }
-
- return NULL;
-}
-
-Boolean
-awt_isAwtWidget(Widget widget)
-{
- return (findWidgetInfo(widget) != NULL);
-}
-
-
-static Boolean
-awt_isAwtMenuWidget(Widget wdgt) {
- struct MenuList* cur;
-
- if (!XtIsSubclass(wdgt, xmRowColumnWidgetClass)) {
- return False;
- }
- for (cur = menu_list; cur != NULL; cur = cur->next) {
- if (cur->menu == wdgt) {
- return True;
- }
- }
- return False;
-}
-
-void
-awt_addMenuWidget(Widget wdgt) {
- DASSERT(XtIsSubclass(wdgt, xmRowColumnWidgetClass));
-
- if (!awt_isAwtMenuWidget(wdgt)) {
- struct MenuList* ml = (struct MenuList*) malloc(sizeof(struct MenuList));
- if (ml != NULL) {
- ml->menu = wdgt;
- ml->next = menu_list;
- menu_list = ml;
- } else {
- JNIEnv* env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
- }
- }
-}
-
-void
-awt_delMenuWidget(Widget wdgt) {
- struct MenuList** pp;
- struct MenuList* p;
-
- DASSERT(XtIsSubclass(wdgt, xmRowColumnWidgetClass));
-
- for (pp = &menu_list; *pp != NULL; pp = &((*pp)->next)) {
- if ((*pp)->menu == wdgt) {
- p = *pp;
- *pp = (*pp)->next;
- free((void*)p);
- break;
- }
- }
-}
-
-
-static Widget
-getShellWidgetByPart(Widget part) {
- int i;
- for (i = 0; i < 3; i++) {
- if (part == NULL) return NULL;
- if (XtIsShell(part)) return part;
- part = XtParent(part);
- }
- return NULL;
-}
-
-static Boolean
-isTheSameShellWidget(Widget shell, Widget w) {
- Widget s1, s2;
- if (shell == NULL || w == NULL) return False;
- s1 = getShellWidgetByPart(shell);
- s2 = getShellWidgetByPart(w);
- if (s1 == s2 && s1 != NULL) {
- return True;
- } else {
- return False;
- }
-}
-
-static Boolean
-shouldDispatchToWidget(XEvent * xev)
-{
- /* If this function returns False, that means that it has not pre-posted
- this event to Java. The caller will then dispatch the event to Motif,
- and our handlers will be called to post it to Java.
- If this function returns true, then this function has posted this event
- to java before returning. The caller will not dispatch it to Motif;
- it will be dispatched to Motif via the putbackQueue after it has been
- processed by Java */
-
- Window win;
- Widget widget = NULL;
- struct WidgetInfo *winfo;
- void *peer = NULL;
- Boolean cont = FALSE;
-
- switch (xev->type) {
- case KeyPress:
- case KeyRelease:
- win = xev->xkey.window;
- break;
- case FocusIn:
- case FocusOut:
- win = xev->xfocus.window;
- break;
- case ButtonPress:
- case ButtonRelease:
- win = xev->xbutton.window;
- break;
- case MotionNotify:
- win = xev->xmotion.window;
- break;
- case EnterNotify:
- case LeaveNotify:
- win = xev->xcrossing.window;
- break;
- default:
- return False;
- }
-
- if ((widget = XtWindowToWidget(awt_display, win)) == NULL) {
- return False;
- }
-
- if (xev->type == KeyPress || xev->type == KeyRelease) {
- Widget focusWidget = XmGetFocusWidget(widget);
-
- /* Fix for 4328561 by ibd@sparc.spb.su
- If the widget is a Choice, the widget with focus is probably lying
- outside the current widget's sub-hierarchy, so we have to go up the
- hierarchy to reach it */
-
- if ((focusWidget == NULL) && XmIsMenuShell(widget)) {
- if ((widget = XtParent(widget)) != NULL) {
- focusWidget = XmGetFocusWidget(widget);
- } else {
- return False;
- }
-
- /* In this case, focus widget should be CascadeButtonGadget type,
- but we should send the events to its parent */
- if (focusWidget != NULL && XmIsCascadeButtonGadget(focusWidget)) {
- widget = XtParent(focusWidget);
- } else {
- /* If something went wrong, restore the original status */
- widget = XtWindowToWidget(awt_display, win);
- }
- }
-
- /* if focus owner is null, redirect key events to focused window */
- if (focusWidget == NULL && findWidgetInfo(widget) == NULL) {
- focusWidget = findTopLevelByShell(widget);
- }
-
- /* If we are on a non-choice widget, process events in a normal way */
- if ((focusWidget != NULL) && (focusWidget != widget)) {
- if (isTheSameShellWidget(focusWidget, widget)) {
- focusWidget = findTopLevelByShell(widget);
- }
- if (focusWidget != NULL) {
- peer = findPeer(&focusWidget);
- }
- if (peer != NULL) {
- widget = focusWidget;
- win = xev->xkey.window = XtWindow(focusWidget);
- }
- }
- }
-
- if ((winfo = findWidgetInfo(widget)) == NULL) {
- return False;
- }
-
- /*
- * Fix for bug 4145193
- *
- * If a menu is up (not just a popup menu), prevent awt components from
- * getting any events until the menu is popped down.
- * Before this fix, the fact that mouse/button events were
- * preposted to the Java event queue was causing the ButtonRelease
- * (needed to pop menu down) to be seen by the menu's parent and
- * not the menu.
- */
- if (awtMenuIsActive()) {
- Widget focusWidget = XmGetFocusWidget(widget);
-
- if (focusWidget == NULL) {
- return False;
- }
-
- /* If we are on a choice, dispatch the events to widget, but do not
- * dispatch the events if we are on popped up menu.
- */
- if (!XmIsRowColumn(widget) || !XmIsCascadeButtonGadget(focusWidget)) {
- /* Fix for 4328557 by ibd@sparc.spb.su
- * If we are dragging mouse from choice and are currently outside
- * of it, dispatch events to the choice - the source of dragging.
- */
-
- if ((drag_source != NULL) && (widget != drag_source) &&
- (peer = findPeer(&drag_source))) {
- awt_canvas_handleEvent(drag_source, peer, xev, winfo, &cont, TRUE);
- }
- return False;
- }
- }
-
- /* If the keyboard is grabbed by a popup (such as a choice) during
- a time when a focus proxy is in effect, the abovefocusIsOnMenu
- test will not detect the sitation because the focus will be on
- the proxy. But we need events to go to Motif first, so that the
- grab can be undone when appropriate. */
- if (keyboardGrabbed) {
- return False;
- }
-
- /* If it's a keyboard event, we need to find the peer associated */
- /* with the widget that has the focus rather than the widget */
- /* associated with the window in the X event. */
-
- switch (xev->type) {
- case KeyPress:
- case KeyRelease:
- if (!(winfo->event_mask & java_awt_AWTEvent_KEY_EVENT_MASK))
- return False;
- break;
- case FocusIn:
- case FocusOut:
- if (!(winfo->event_mask & java_awt_AWTEvent_FOCUS_EVENT_MASK))
- return False;
- break;
- case ButtonPress:
- case ButtonRelease:
- if (!(winfo->event_mask & java_awt_AWTEvent_MOUSE_EVENT_MASK)) {
- return False;
- }
- break;
- case EnterNotify:
- case LeaveNotify:
- /*
- * Do not post the enter/leave event if it's on a subwidget
- * within the component.
- */
- if (!(winfo->event_mask & java_awt_AWTEvent_MOUSE_EVENT_MASK) ||
- widget != winfo->origin)
- return False;
- break;
- case MotionNotify:
- if (!(winfo->event_mask & java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK))
- return False;
- break;
- default:
- return False;
- }
-
- peer = winfo->peer;
-
- /* If we found a widget and a suitable peer (either the focus
- peer above or the one associated with the widget then we
- dispatch to it. */
- if (peer == NULL) {
- return False;
- }
-
- /*
- * Fix for bug 4173714 - java.awt.button behaves differently under
- * Win32/Solaris.
- * Component should not get any events when it's disabled.
- */
- if (!XtIsSensitive(widget)) {
- if (xev->type == EnterNotify) {
- updateCursor(peer, CACHE_UPDATE);
- }
- return False;
- }
-
- awt_canvas_handleEvent(widget, peer, xev, winfo, &cont, TRUE);
- return (!cont);
-} /* shouldDispatchToWidget() */
-
-
-void set_toolkit_busy(Boolean busy) {
-
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
- static jclass awtAutoShutdownClass = NULL;
- static jmethodID notifyBusyMethodID = NULL;
- static jmethodID notifyFreeMethodID = NULL;
-
- if (awtAutoShutdownClass == NULL) {
- jclass awtAutoShutdownClassLocal = (*env)->FindClass(env, "sun/awt/AWTAutoShutdown");
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
- DASSERT(awtAutoShutdownClassLocal != NULL);
- if (awtAutoShutdownClassLocal == NULL) {
- return;
- }
-
- awtAutoShutdownClass = (jclass)(*env)->NewGlobalRef(env, awtAutoShutdownClassLocal);
- (*env)->DeleteLocalRef(env, awtAutoShutdownClassLocal);
-
- notifyBusyMethodID = (*env)->GetStaticMethodID(env, awtAutoShutdownClass,
- "notifyToolkitThreadBusy", "()V");
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
- notifyFreeMethodID = (*env)->GetStaticMethodID(env, awtAutoShutdownClass,
- "notifyToolkitThreadFree", "()V");
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
- DASSERT(notifyBusyMethodID != NULL);
- DASSERT(notifyFreeMethodID != NULL);
- if (notifyBusyMethodID == NULL || notifyFreeMethodID == NULL) {
- return;
- }
- } /* awtAutoShutdownClass == NULL*/
-
- if (busy) {
- (*env)->CallStaticVoidMethod(env, awtAutoShutdownClass,
- notifyBusyMethodID);
- } else {
- (*env)->CallStaticVoidMethod(env, awtAutoShutdownClass,
- notifyFreeMethodID);
- }
-
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
-}
-
-#ifdef DEBUG
-static int32_t debugPrintLineCount = 0; /* limit debug output per line */
-#endif
-
-/*
- * This is the main Xt event loop for the AWT.
- *
- * Because java applications are multithreaded, but X and Xt
- * are thread-dumb, we must make special considerations to
- * make ensure that the X/Xt libraries are not entered by
- * multiple threads simultaneously.
- *
- * The biggest difference between the standard Xt loop
- * and this loop is that we go to great lengths never to block
- * in the X libraries. We poll() on the X event pipe, waiting
- * for events, rather than simply calling XtAppNextEvent() and
- * blocking. If this thread were to block in XtAppNextEvent(),
- * no other thread could enter (e.g., to perform a paint or
- * retrieve data).
- */
-/* #ifdef DEBUG */
- int32_t numEventsHandled = 0;
-/* #endif */
-static void
-awt_MToolkit_loop(JNIEnv *env)
-{
- XtInputMask iMask;
- int32_t fdXPipe = -1; /* pipe where X events arrive */
-
- /* only privileged thread should be running here */
- DASSERT(awt_currentThreadIsPrivileged(env));
-
- /* The pipe where X events arrive */
- fdXPipe = ConnectionNumber(awt_display) ;
-
- /* We execute events while locked, unlocking only when waiting
- * for an event
- */
- AWT_LOCK();
-
- /* Create the AWT utility pipe. See the comments on awt_pipe_init() */
- awt_pipe_init();
-
- /*
- * Need to flush here in case data on the connection was read
- * before we acquired the monitor.
- *
- * I don't get this, but I'm too chicken to remove it. -jethro 2Sep98
- */
- AWT_FLUSHOUTPUT_NOW();
-
- /*
- * ACTUALLY PROCESS EVENTS
- */
- while(True) {
-
- /* process all events in the queue */
-/* #ifdef DEBUG */
-/* numEventsHandled = 0; */
-/* #endif */
- while (((iMask = awt_events_pending(awt_appContext)) & XtIMAll) > 0) {
-
-/* #ifdef DEBUG */
- ++numEventsHandled;
-/* #endif */
- processOneEvent(iMask);
-
- } /* end while awt_events_pending() */
- /* At this point, we have exhausted the event queue */
-
- /* print the number of events handled in parens */
- DTRACE_PRINT1("(%d events)",(int32_t)numEventsHandled);
-#ifdef DEBUG
- if (++debugPrintLineCount > 8) {
- DTRACE_PRINTLN("");
- debugPrintLineCount = 0;
- }
-#endif
-
- AWT_NOTIFY_ALL(); /* wake up modalWait() */
-
- set_toolkit_busy(False);
-
- /* Here, we wait for X events, outside of the X libs. When
- * it's likely that an event is waiting, we process the queue
- */
- waitForEvents(env, fdXPipe, AWT_READPIPE);
-
- set_toolkit_busy(True);
-
- } /* while(True) */
-
- /* If we ever exit the loop, must unlock the toolkit */
-
-} /* awt_MToolkit_loop() */
-
-/*
- * Creates the AWT utility pipe. This pipe exists solely so that
- * we can cause the main event thread to wake up from a poll() or
- * select() by writing to this pipe.
- */
-static void
-awt_pipe_init(void) {
-
- if (awt_pipe_inited) {
- return;
- }
-
- if ( pipe ( awt_pipe_fds ) == 0 )
- {
- /*
- ** the write wakes us up from the infinite sleep, which
- ** then we cause a delay of AWT_FLUSHTIME and then we
- ** flush.
- */
- int32_t flags = 0;
- awt_set_poll_timeout (def_poll_timeout);
- /* set the pipe to be non-blocking */
- flags = fcntl ( AWT_READPIPE, F_GETFL, 0 );
- fcntl( AWT_READPIPE, F_SETFL, flags | O_NDELAY | O_NONBLOCK );
- flags = fcntl ( AWT_WRITEPIPE, F_GETFL, 0 );
- fcntl( AWT_WRITEPIPE, F_SETFL, flags | O_NDELAY | O_NONBLOCK );
- awt_pipe_inited = True;
- }
- else
- {
- AWT_READPIPE = -1;
- AWT_WRITEPIPE = -1;
- awt_pipe_inited = False;
- }
-} /* awt_pipe_init() */
-
-static Window
-proxyTopLevel(Window proxyWindow) {
- Window parent = None, root = None, *children = NULL, retvalue = None;
- uint32_t nchildren = 0;
- Status res = XQueryTree(awt_display, proxyWindow, &root, &parent,
- &children, &nchildren);
- if (res != 0) {
- if (nchildren > 0) {
- retvalue = children[0];
- }
- else retvalue = None;
- if (children != NULL) {
- XFree(children);
- }
- return retvalue;
- } else {
- return None;
- }
-}
-
-static jclass clazzF, clazzD = NULL;
-
-static Boolean
-initClazzD(JNIEnv *env) {
- jclass t_clazzD = (*env)->FindClass(env, "java/awt/Dialog");
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
- DASSERT(t_clazzD != NULL);
- if (t_clazzD == NULL) {
- return False;
- }
- clazzD = (*env)->NewGlobalRef(env, t_clazzD);
- DASSERT(clazzD != NULL);
- (*env)->DeleteLocalRef(env, t_clazzD);
- return True;
-}
-
-Boolean
-isFrameOrDialog(jobject target, JNIEnv *env) {
- if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
- return False;
- }
-
- if (clazzF == NULL) {
- jclass t_clazzF = (*env)->FindClass(env, "java/awt/Frame");
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
- DASSERT(t_clazzF != NULL);
- if (t_clazzF == NULL) {
- return False;
- }
- clazzF = (*env)->NewGlobalRef(env, t_clazzF);
- DASSERT(clazzF != NULL);
- (*env)->DeleteLocalRef(env, t_clazzF);
- }
-
- if (clazzD == NULL && !initClazzD(env)) {
- return False;
- }
-
- return (*env)->IsInstanceOf(env, target, clazzF) ||
- (*env)->IsInstanceOf(env, target, clazzD);
-}
-
-Boolean
-isDialog(jobject target, JNIEnv *env) {
- if (clazzD == NULL && !initClazzD(env)) {
- return False;
- }
- return (*env)->IsInstanceOf(env, target, clazzD);
-}
-
-// Returns a local ref to a decorated owner of the target,
-// or NULL if the target is Frame or Dialog itself.
-// The local ref returned should be deleted by the caller.
-jobject
-getOwningFrameOrDialog(jobject target, JNIEnv *env) {
- jobject _target = (*env)->NewLocalRef(env, target);
- jobject parent = _target;
- Boolean isSelfFrameOrDialog = True;
-
- while (!isFrameOrDialog(parent, env)) {
- isSelfFrameOrDialog = False;
- parent = (*env)->CallObjectMethod(env, _target, componentIDs.getParent);
- (*env)->DeleteLocalRef(env, _target);
- _target = parent;
- }
-
- if (isSelfFrameOrDialog) {
- (*env)->DeleteLocalRef(env, parent);
- return NULL;
- }
- return parent;
-}
-
-Widget
-findWindowsProxy(jobject window, JNIEnv *env) {
- struct ComponentData *cdata;
- jobject tlPeer;
- jobject owner_prev = NULL, owner_new = NULL;
- /* the owner of a Window is in its parent field */
- /* we may have a chain of Windows; go up the chain till we find the
- owning Frame or Dialog */
- if ((*env)->EnsureLocalCapacity(env, 4) < 0) {
- return NULL;
- }
-
- if (window == NULL) return NULL;
-
- owner_prev = (*env)->NewLocalRef(env, window);
- while (!JNU_IsNull(env, owner_prev) && !(isFrameOrDialog(owner_prev, env))) {
- owner_new = (*env)->CallObjectMethod(env, owner_prev, componentIDs.getParent);
- (*env)->DeleteLocalRef(env, owner_prev);
- owner_prev = owner_new;
- }
-
- if (owner_prev == NULL) return NULL;
-
- tlPeer = (*env)->GetObjectField(env, owner_prev, componentIDs.peer);
- (*env)->DeleteLocalRef(env, owner_prev);
- if (tlPeer == NULL) return NULL;
-
- cdata = (struct ComponentData *)
- JNU_GetLongFieldAsPtr(env, tlPeer, mComponentPeerIDs.pData);
- (*env)->DeleteLocalRef(env, tlPeer);
-
- if (cdata == NULL) return NULL;
- return(findFocusProxy(cdata->widget));
-}
-
-jobject
-findTopLevel(jobject peer, JNIEnv *env) {
- jobject target_prev = NULL;
- static jclass clazzW = NULL;
-
- if ((*env)->EnsureLocalCapacity(env, 3) < 0) {
- return NULL;
- }
-
- if (clazzW == NULL) {
- jclass t_clazzW = (*env)->FindClass(env, "java/awt/Window");
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
- DASSERT(t_clazzW != NULL);
- if (t_clazzW == NULL) {
- return NULL;
- }
- clazzW = (*env)->NewGlobalRef(env, t_clazzW);
- DASSERT(clazzW != NULL);
- (*env)->DeleteLocalRef(env, t_clazzW);
- }
- target_prev = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
- if (target_prev == NULL) {
- return NULL;
- }
-
- while ((target_prev != NULL)
- && !(*env)->IsInstanceOf(env, target_prev, clazzW) )
- {
- /* go up the hierarchy until we find a window */
- jobject target_new = (*env)->CallObjectMethod(env, target_prev, componentIDs.getParent);
- (*env)->DeleteLocalRef(env, target_prev);
- target_prev = target_new;
- }
- return target_prev;
-}
-
-static Window
-rootWindow(Window w) {
- Window root = None;
- Window parent = None;
- Window *children = NULL;
- uint32_t nchildren = 0;
-
- if (w != None) {
- Status res = XQueryTree(awt_display, w, &root, &parent, &children, &nchildren);
- if (res == 0) {
- return None;
- }
- if (children != NULL) {
- XFree(children);
- }
- return root;
- } else {
- return None;
- }
-}
-
-Boolean IsRootOf(Window root, Window child) {
- Window w_root = None, w_parent = None, * children = NULL;
- uint32_t c_count = 0;
- if (root == None || child == None) {
- return False;
- }
- do {
- w_root = None;
- w_parent = None;
- children = NULL;
- c_count = 0;
- if (XQueryTree(awt_display, child, &w_root, &w_parent,
- &children, &c_count)) {
- if (children != NULL) {
- XFree(children);
- }
- if (w_parent == None) {
- return False;
- }
- if (w_parent == root) {
- return True;
- }
- } else {
- return False;
- }
- child = w_parent;
- } while (True);
-}
-
-Window findShellByProxy(Window proxy) {
- Widget proxy_wid = XtWindowToWidget(awt_display, proxy);
- while (proxy_wid != NULL && !XtIsShell(proxy_wid)) {
- proxy_wid = XtParent(proxy_wid);
- }
- if (proxy_wid == NULL) {
- return None;
- }
- return XtWindow(proxy_wid);
-}
-
-// Window which contains focus owner when focus proxy is enabled
-Window trueFocusWindow = None;
-// Window which works as proxy for input events for real focus owner.
-Window focusProxyWindow = None;
-
-void clearFocusPathOnWindow(Window win) {
- if (focusProxyWindow != None && IsRootOf(win, trueFocusWindow)) {
- XEvent ev;
- memset(&ev, 0, sizeof(ev));
- ev.type = FocusOut;
- ev.xany.send_event = True;
- ev.xany.display = awt_display;
- ev.xfocus.mode = NotifyNormal;
- ev.xfocus.detail = NotifyNonlinear;
- {
- Window root = rootWindow(trueFocusWindow);
- JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
- ev.xfocus.window = trueFocusWindow;
- while (ev.xfocus.window != root &&
- ev.xfocus.window != None) {
- Widget w = XtWindowToWidget(awt_display,
- ev.xfocus.window);
- awt_put_back_event(env, &ev);
- if (w == NULL) {
- break;
- }
- if (XtParent(w) != NULL) {
- ev.xfocus.window = XtWindow(XtParent(w));
- } else {
- ev.xfocus.window = None;
- }
- }
- }
- XSetInputFocus(awt_display, findShellByProxy(focusProxyWindow), RevertToPointerRoot, CurrentTime);
- trueFocusWindow = None;
- focusProxyWindow = None;
- }
-}
-void clearFocusPath(Widget shell) {
- Window w = None;
- if (shell == NULL) {
- return;
- }
- w = XtWindow(shell);
- clearFocusPathOnWindow(w);
-}
-
-void globalClearFocusPath(Widget focusOwnerShell ) {
- if (focusProxyWindow != None) {
- Window shellWindow = findShellByProxy(trueFocusWindow);
- if (shellWindow != None) {
- Widget shell = XtWindowToWidget(awt_display, shellWindow);
- if (shell != NULL && shell != focusOwnerShell) {
- clearFocusPath(shell);
- }
- }
- }
-}
-
-static void
-focusEventForProxy(XEvent xev,
- JNIEnv *env,
- Window *trueFocusWindow,
- Window *focusProxyWindow) {
-
- DASSERT (trueFocusWindow != NULL && focusProxyWindow != NULL);
- if (xev.type == FocusOut) {
- if (xev.xfocus.window == *focusProxyWindow) {
- if (*trueFocusWindow != None) {
- Window root = rootWindow(*trueFocusWindow);
- focusOutEvent.xfocus.window = *trueFocusWindow;
-#ifdef DEBUG_FOCUS
- printf(" nulling out proxy; putting back event"
- "\n");
-#endif
-
- while (focusOutEvent.xfocus.window != root &&
- focusOutEvent.xfocus.window != None) {
- Widget w = XtWindowToWidget(awt_display,
- focusOutEvent.xfocus.window);
- awt_put_back_event(env, &focusOutEvent);
- if (w != NULL && XtParent(w) != NULL) {
- focusOutEvent.xfocus.window = XtWindow(XtParent(w));
- } else {
- focusOutEvent.xfocus.window = None;
- }
- }
- *trueFocusWindow = None;
- *focusProxyWindow = None;
- return;
- } else {
-#ifdef DEBUG_FOCUS
- printf("\n");
-#endif
- return;
- }
- } else {
-#ifdef DEBUG_FOCUS
- printf("\n");
-#endif
- return;
- }
- }
-}
-
-static void
-focusEventForFrame(XEvent xev, Window focusProxyWindow) {
- if (xev.type == FocusIn) {
- if (focusProxyWindow != None) {
- /* eat it */
- return;
- } else /* FocusIn on Frame or Dialog */ {
- XtDispatchEvent(&xev);
- }
- } else /* FocusOut on Frame or Dialog */{
- XtDispatchEvent(&xev);
- }
-}
-
-static void
-focusEventForWindow(XEvent xev, JNIEnv *env, Window *trueFocusWindow,
- Window *focusProxyWindow, jobject target) {
- XEvent pev;
- if (xev.type == FocusIn && xev.xfocus.mode == NotifyNormal) {
- /* If it's a FocusIn, allow it to process, then set
- focus to focus proxy */
- Widget focusProxy;
- focusProxy = findWindowsProxy(target, env);
- if (focusProxy != NULL) {
- XtDispatchEvent(&xev);
- *focusProxyWindow = XtWindow(focusProxy);
-
- XSetInputFocus(awt_display, *focusProxyWindow,
- RevertToParent,
- CurrentTime);
-
- XPeekEvent(awt_display, &pev);
- while (pev.type == FocusIn) {
- XNextEvent(awt_display, &xev);
- XPeekEvent(awt_display, &pev);
- }
- *trueFocusWindow = xev.xany.window;
-
- } /* otherwise error */
- } else /* FocusOut */ {
- /* If it's a FocusOut on a Window, discard it unless
- it's an event generated by us. */
- if (xev.xany.send_event) {
- XtDispatchEvent(&xev);
- }
- }
-}
-
-Boolean
-isAncestor(Window ancestor, Window child) {
- Window *children;
- uint32_t nchildren;
- Boolean retvalue = False;
-
- while (child != ancestor) {
- Window parent, root;
- Status status;
-
- status = XQueryTree(awt_display, child, &root, &parent,
- &children, &nchildren);
- if (status == 0) return False; /* should be an error of some sort? */
-
- if (parent == root) {
- if (child != ancestor) {
- retvalue = False;
- break;
- } else {
- retvalue = True;
- break;
- }
- }
- if (parent == ancestor) { retvalue = True; break; }
- if (nchildren > 0) XFree(children);
- child = parent;
- }
- if (nchildren > 0) XFree(children);
- return retvalue;
-}
-
-/**
- * Returns focusability of the corresponding Java Window object
- */
-Boolean
-isFocusableWindow(Window w) {
- Widget wid = NULL;
- JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
- wid = XtWindowToWidget(awt_display, w);
- while (wid != NULL && !XtIsShell(wid)) {
- wid = XtParent(wid);
- }
-
- // If the window doesn't have shell consider it focusable as all windows
- // are focusable by default
- if (wid == NULL) return True;
-
- return isFocusableWindowByShell(env, wid);
-}
-
-void postUngrabEvent(Widget shell) {
- JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
- Widget canvas = findTopLevelByShell(shell);
- if (canvas != NULL) {
- jobject peer = findPeer(&canvas);
- if (peer != NULL) {
- JNU_CallMethodByName(env, NULL, peer, "postUngrabEvent", "()V", NULL);
- }
- }
-}
-
-Boolean eventInsideGrabbed(XEvent * ev) {
- if (grabbed_widget == NULL) {
- return False;
- }
-
- switch (ev->xany.type) {
- case LeaveNotify:
- case ButtonPress:
- case ButtonRelease:
- case MotionNotify:
- case EnterNotify:
- {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- Widget grab = findTopLevelByShell(grabbed_widget);
- if (grab != NULL) {
- jobject peer = findPeer(&grab);
- Widget target = XtWindowToWidget(awt_display, ev->xbutton.window);
- jobject targetPeer = findPeer(&target);
- if (peer != NULL) {
- return JNU_CallMethodByName(env, NULL, peer, "processUngrabMouseEvent", "(Lsun/awt/motif/MComponentPeer;III)Z",
- targetPeer, ev->xbutton.x_root, ev->xbutton.y_root,
- ev->xany.type, NULL).z;
- }
- }
- return False;
- }
- case FocusOut:
- if (ev->xfocus.window == XtWindow(grabbed_widget) ||
- isAncestor(XtWindow(grabbed_widget), ev->xfocus.window))
- {
- postUngrabEvent(grabbed_widget);
- return True;
- }
- default:
- return True;
- }
-}
-
-/**
- * Processes and removes one X/Xt event from the Xt event queue.
- * Handles events pushed back via awt_put_back_event() FIRST,
- * then new events on the X queue
- */
-static void
-processOneEvent(XtInputMask iMask) {
- XEvent xev;
- Boolean haveEvent = False;
- if (putbackQueueCount > 0) {
- // There is a pushed-back event - handle it first
- if (awt_get_next_put_back_event(&xev) == 0) {
- if (xev.xany.send_event != SPECIAL_KEY_EVENT) {
-#ifdef DEBUG_FOCUS
- if (xev.type == FocusOut) {
- printf("putback FocusOut on window %d, mode %d, "
- "detail %d, send_event %d\n",
- xev.xfocus.window, xev.xfocus.mode,
- xev.xfocus.detail, xev.xfocus.send_event);
- }
-#endif
- eventNumber++;
- XtDispatchEvent(&xev);
- return;
- } else {
- haveEvent = True;
- }
- }
- }
-
- if (haveEvent || XtAppPeekEvent(awt_appContext, &xev)) {
- /*
- * Fix for BugTraq ID 4041235, 4100167:
- * First check that the event still has a widget, because
- * the widget may have been destroyed by another thread.
- */
- Widget widget=XtWindowToWidget(awt_display, xev.xany.window);
- eventNumber++;
-#ifdef __linux__
- statusWindowEventHandler(xev);
-#endif
- xembed_eventHandler(&xev);
- xembed_serverEventHandler(&xev);
- syncWait_eventHandler(&xev);
-
- if (!haveEvent && awt_dnd_process_event(&xev)) {
- return;
- }
-
- if ((widget == NULL) || (!XtIsObject(widget)) ||
- (widget->core.being_destroyed)) {
- /*
- * if we get here, the event could be one of
- * the following:
- * - notification that a "container" of
- * any of our embedded frame has been moved
- * - event understandable by XFilterEvent
- * - for one of our old widget which has gone away
- */
- XNextEvent(awt_display, &xev);
-
- if (widget == NULL) {
- /* an embedded frame container has been moved? */
- if (awt_util_processEventForEmbeddedFrame(&xev)) {
- return;
- }
-
- /* manager selections related event? */
- if (awt_mgrsel_processEvent(&xev)) {
- return;
- }
- }
-
- /*
- * Fix for BugTraq ID 4196573:
- * Call XFilterEvent() to give a chance to X Input
- * Method to process this event before being
- * discarded.
- */
- (void) XFilterEvent(&xev, NULL);
- return;
- }
-
- /* There is an X event on the queue. */
- switch (xev.type) {
- case KeyPress:
- case KeyRelease:
- case ButtonPress:
- case ButtonRelease:
- case MotionNotify:
- case EnterNotify:
- case LeaveNotify:
- /* Fix for BugTraq ID 4048060. Dispatch scrolling events
- immediately to the ScrollBar widget to prevent spurious
- continuous scrolling. Otherwise, if the application is busy,
- the ButtonRelease event is not dispatched in time to prevent
- a ScrollBar timeout from expiring, and restarting the
- continuous scrolling timer.
- */
- if ((xev.type == ButtonPress ||
- xev.type == ButtonRelease ||
- (xev.type == MotionNotify &&
- (xev.xmotion.state == Button1Mask ||
- xev.xmotion.state == Button2Mask ||
- xev.xmotion.state == Button3Mask))) &&
- (XtIsSubclass(widget, xmScrollBarWidgetClass))) {
- /* Use XNextEvent instead of XtAppNextEvent, because
- XtAppNextEvent processes timers before getting the next X
- event, causing a race condition, since the TimerEvent
- callback in the ScrollBar widget restarts the continuous
- scrolling timer.
- */
- XNextEvent(awt_display, &xev);
-
- XtDispatchEvent(&xev);
- XSync(awt_display, False);
-
- // This is the event on scrollbar. Key, Motion,
- // Enter/Leave dispatch as usual, Button should
- // generate Ungrab after Java mouse event
- if (xev.type == ButtonPress && grabbed_widget != NULL) {
- eventInsideGrabbed(&xev);
- }
- }
- else {
- if (!haveEvent) XtAppNextEvent(awt_appContext, &xev);
-
- // This is an event on one of our widgets. Key,
- // Motion, Enter/Leave dispatch as usual, Button
- // should generate Ungrab after Java mouse event
-/* if (grabbed_widget != NULL && !eventInsideGrabbed(&xev)) { */
-/* return; */
-/* } */
-
- if (xev.type == ButtonPress) {
- Window window = findShellByProxy(xev.xbutton.window);
- if (window != None) {
- XWindowAttributes winAttr;
- memset(&winAttr, 0, sizeof(XWindowAttributes));
- XGetWindowAttributes(awt_display, window, &winAttr);
- if (winAttr.override_redirect == TRUE && isFocusableWindow(window)) {
- XSetInputFocus(awt_display, window, RevertToPointerRoot, CurrentTime);
- }
- }
- }
- if(xev.type == KeyPress) {
-#ifdef DEBUG_FOCUS
- printf("KeyPress on window %d\n", xev.xany.window);
-#endif
- }
-
- /* this could be moved to shouldDispatchToWidget */
- /* if there is a proxy in effect, dispatch key events
- through the proxy */
- if ((xev.type == KeyPress || xev.type == KeyRelease) &&
- !keyboardGrabbed && !haveEvent) {
- if (focusProxyWindow != None) {
- Widget widget;
- struct WidgetInfo *winfo;
- Boolean cont;
- /* Key event should be posted to the top-level
- widget of the proxy */
- xev.xany.window = proxyTopLevel(focusProxyWindow);
- widget = XtWindowToWidget(awt_display,
- xev.xany.window);
- if (widget == NULL) return;
- if ((winfo = findWidgetInfo(widget)) == NULL) {
- return;
- }
- awt_canvas_handleEvent(widget, winfo->peer, &xev,
- winfo, &cont, TRUE);
- return;
- }
- }
- if (!shouldDispatchToWidget(&xev)) {
- XtDispatchEvent(&xev);
- }
-
- // See comment above - "after time" is here.
- if (grabbed_widget != NULL && xev.type == ButtonPress) {
- eventInsideGrabbed(&xev);
- }
- }
-
-
- break;
-
- case FocusIn:
- case FocusOut: {
- void *peer;
- jobject target;
-
- JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
-#ifdef DEBUG_FOCUS
- if (xev.type == FocusIn) {
-
- fprintf(stderr, "FocusIn on window %x, mode %d, detail %d, "
- "send_event %d\n", xev.xfocus.window,
- xev.xfocus.mode, xev.xfocus.detail,
- xev.xfocus.send_event);
- } else {
- fprintf(stderr, "FocusOut on window %x, mode %d, detail %d, "
- "send_event %d\n", xev.xfocus.window,
- xev.xfocus.mode, xev.xfocus.detail,
- xev.xfocus.send_event);
- }
-#endif
- XtAppNextEvent(awt_appContext, &xev);
-
- if (xev.xfocus.detail == NotifyVirtual ||
- xev.xfocus.detail == NotifyNonlinearVirtual) {
-#ifdef DEBUG_FOCUS
- printf("discarding\n");
-#endif
- return;
- }
-
- // Check for xembed on this window. If it is active and this is not XEmbed focus
- // event(send_event = 0) then we should skip it
- if (isXEmbedActiveByWindow(xev.xfocus.window) && !xev.xfocus.send_event) {
- return;
- }
-
- /* In general, we need to to block out focus events
- that are caused by keybaord grabs initiated by
- dragging the title bar or the scrollbar. But we
- need to let through the ones that are aimed at
- choice boxes or menus. So we keep track of when
- the keyboard is grabbed by a popup. */
-
- if (awt_isAwtMenuWidget(widget)) {
- if (xev.type == FocusIn &&
- xev.xfocus.mode == NotifyGrab) {
- extern Boolean poppingDown;
- if (!poppingDown) {
- keyboardGrabbed = True;
- }
- } else /* FocusOut */ {
- if (xev.type == FocusOut &&
- xev.xfocus.mode == NotifyUngrab) {
- keyboardGrabbed = False;
- }
- }
- }
-
- if (focusProxyWindow != None) {
-#ifdef DEBUG_FOCUS
- printf("non-null proxy; proxy = %d ", focusProxyWindow);
-#endif
- if (trueFocusWindow != None) {
- /* trueFocusWindow should never be None here, but if
- things ever get skewed, we want to be able to
- recover rather than crash */
- focusEventForProxy(xev, env, &trueFocusWindow,
- &focusProxyWindow);
- return;
- } else {
- /* beartrap -- remove before shipping */
- /* printf("trueFocusWindow None in processOneEvent;\n"); */
- /* printf("Please file a bug\n"); */
- }
- }
-
- peer = findPeer(&widget);
- if (peer == NULL) {
-#ifdef DEBUG_FOCUS
- printf("null peer -- shouldn't see in java handler\n");
-#endif
- XtDispatchEvent(&xev);
- return;
- }
-
- /* Find the top-level component */
-
- if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
- return;
- }
- target = findTopLevel(peer, env);
- if (target == NULL) {
- JNU_ThrowNullPointerException(env, "component without a "
- "window");
- return;
- }
-
- if (isFrameOrDialog(target, env)) {
-#ifdef DEBUG_FOCUS
- printf("Focus event directed at a frame; frame = %d\n",
- xev.xany.window);
-#endif
- focusEventForFrame(xev, focusProxyWindow);
- (*env)->DeleteLocalRef(env, target);
- return;
- } else {
-#ifdef DEBUG_FOCUS
- printf("Focus event directed at a window; window = %d\n",
- xev.xany.window);
-#endif
- focusEventForWindow(xev, env, &trueFocusWindow,
- &focusProxyWindow, target);
- (*env)->DeleteLocalRef(env, target);
- return;
- }
- }
-
- case UnmapNotify:
-#ifdef DEBUG_FOCUS
- printf("Unmap on window %d\n", xev.xany.window);
- printf("True focus window is %d\n", trueFocusWindow);
-#endif
- clearFocusPathOnWindow(xev.xunmap.window);
-
- default:
- XtAppProcessEvent(awt_appContext, iMask);
- break;
- }
- }
- else {
- /* There must be a timer, alternate input, or signal event. */
- XtAppProcessEvent(awt_appContext, iMask & ~XtIMXEvent);
- }
-
-} /* processOneEvent() */
-
-/*
- * Waits for X/Xt events to appear on the pipe. Returns only when
- * it is likely (but not definite) that there are events waiting to
- * be processed.
- *
- * This routine also flushes the outgoing X queue, when the
- * awt_next_flush_time has been reached.
- *
- * If fdAWTPipe is greater or equal than zero the routine also
- * checks if there are events pending on the putback queue.
- */
-void
-waitForEvents(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe) {
-
- while ((fdAWTPipe >= 0 && awt_events_pending(awt_appContext) == 0) ||
- (fdAWTPipe < 0 && XtAppPending(awt_appContext) == 0)) {
-#ifdef USE_SELECT
- performSelect(env,fdXPipe,fdAWTPipe);
-#else
- performPoll(env,fdXPipe,fdAWTPipe);
-#endif
- if ((awt_next_flush_time > 0) &&
- (awtJNI_TimeMillis() > awt_next_flush_time)) {
- AWT_FLUSHOUTPUT_NOW();
- }
- } /* end while awt_events_pending() == 0 */
-} /* waitForEvents() */
-
-/*************************************************************************
- ** **
- ** WE USE EITHER select() OR poll(), DEPENDING ON THE USE_SELECT **
- ** COMPILE-TIME CONSTANT. **
- ** **
- *************************************************************************/
-
-#ifdef USE_SELECT
-
-static struct fd_set rdset;
-struct timeval sel_time;
-
-/*
- * Performs select() on both the X pipe and our AWT utility pipe.
- * Returns when data arrives or the operation times out.
- *
- * Not all Xt events come across the X pipe (e.g., timers
- * and alternate inputs), so we must time out every now and
- * then to check the Xt event queue.
- *
- * The fdAWTPipe will be empty when this returns.
- */
-static void
-performSelect(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe) {
-
- int32_t result;
- int32_t count;
- int32_t nfds = 1;
- uint32_t timeout = awt_get_poll_timeout(False);
-
- /* Fixed 4250354 7/28/99 ssi@sparc.spb.su
- * Cleaning up Global Refs in case of No Events
- */
- awtJNI_CleanupGlobalRefs();
-
- FD_ZERO( &rdset );
- FD_SET(fdXPipe, &rdset);
- if (fdAWTPipe >= 0) {
- nfds++;
- FD_SET(fdAWTPipe, &rdset);
- }
- if (timeout == 0) {
- // be sure other threads get a chance
- awtJNI_ThreadYield(env);
- }
- // set the appropriate time values. The DASSERT() in
- // MToolkit_run() makes sure that this will not overflow
- sel_time.tv_sec = (timeout * 1000) / (1000 * 1000);
- sel_time.tv_usec = (timeout * 1000) % (1000 * 1000);
- AWT_NOFLUSH_UNLOCK();
- result = select(nfds, &rdset, 0, 0, &sel_time);
- AWT_LOCK();
-
- /* reset tick if this was not a time out */
- if (result == 0) {
- /* select() timed out -- update timeout value */
- awt_get_poll_timeout(True);
- }
- if (fdAWTPipe >= 0 && FD_ISSET ( fdAWTPipe, &rdset ) )
- {
- /* There is data on the AWT pipe - empty it */
- do {
- count = read(fdAWTPipe, read_buf, AWT_POLL_BUFSIZE );
- } while (count == AWT_POLL_BUFSIZE );
- }
-} /* performSelect() */
-
-#else /* !USE_SELECT */
-
-/*
- * Polls both the X pipe and our AWT utility pipe. Returns
- * when there is data on one of the pipes, or the operation times
- * out.
- *
- * Not all Xt events come across the X pipe (e.g., timers
- * and alternate inputs), so we must time out every now and
- * then to check the Xt event queue.
- *
- * The fdAWTPipe will be empty when this returns.
- */
-static void
-performPoll(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe) {
-
- static struct pollfd pollFds[2];
- uint32_t timeout = awt_get_poll_timeout(False);
- int32_t result;
- int32_t count;
-
- /* Fixed 4250354 7/28/99 ssi@sparc.spb.su
- * Cleaning up Global Refs in case of No Events
- */
- awtJNI_CleanupGlobalRefs();
-
- pollFds[0].fd = fdXPipe;
- pollFds[0].events = POLLRDNORM;
- pollFds[0].revents = 0;
-
- pollFds[1].fd = fdAWTPipe;
- pollFds[1].events = POLLRDNORM;
- pollFds[1].revents = 0;
-
- AWT_NOFLUSH_UNLOCK();
-
- /* print the poll timeout time in brackets */
- DTRACE_PRINT1("[%dms]",(int32_t)timeout);
-#ifdef DEBUG
- if (++debugPrintLineCount > 8) {
- DTRACE_PRINTLN("");
- debugPrintLineCount = 0;
- }
-#endif
- /* ACTUALLY DO THE POLL() */
- if (timeout == 0) {
- // be sure other threads get a chance
- awtJNI_ThreadYield(env);
- }
- result = poll( pollFds, 2, (int32_t) timeout );
-
-#ifdef DEBUG
- DTRACE_PRINT1("[poll()->%d]", result);
- if (++debugPrintLineCount > 8) {
- DTRACE_PRINTLN("");
- debugPrintLineCount = 0;
- }
-#endif
- AWT_LOCK();
- if (result == 0) {
- /* poll() timed out -- update timeout value */
- awt_get_poll_timeout(True);
- }
- if ( pollFds[1].revents )
- {
- /* There is data on the AWT pipe - empty it */
- do {
- count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE );
- } while (count == AWT_POLL_BUFSIZE );
- DTRACE_PRINTLN1("wokeup on AWTPIPE, timeout:%d", timeout);
- }
- return;
-
-} /* performPoll() */
-
-#endif /* !USE_SELECT */
-
-/*
- * Pushes an X event back on the queue to be handled
- * later.
- *
- * Ignores the request if event is NULL
- */
-void
-awt_put_back_event(JNIEnv *env, XEvent *event) {
-
- Boolean addIt = True;
- if (putbackQueueCount >= putbackQueueCapacity) {
- /* not enough room - alloc 50% more space */
- int32_t newCapacity;
- XEvent *newQueue;
- newCapacity = putbackQueueCapacity * 3 / 2;
- if ((newCapacity - putbackQueueCapacity)
- < PUTBACK_QUEUE_MIN_INCREMENT) {
- /* always increase by at least min increment */
- newCapacity = putbackQueueCapacity + PUTBACK_QUEUE_MIN_INCREMENT;
- }
- newQueue = (XEvent*)realloc(
- putbackQueue, newCapacity*(sizeof(XEvent)));
- if (newQueue == NULL) {
- JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
- addIt = False;
- } else {
- putbackQueue = newQueue;
- putbackQueueCapacity = newCapacity;
- }
- }
- if (addIt) {
- char oneChar = 'p';
- memcpy(&(putbackQueue[putbackQueueCount]), event, sizeof(XEvent));
- putbackQueueCount++;
-
- // wake up the event loop, if it's sleeping
- write (AWT_WRITEPIPE, &oneChar, 1);
- }
-
- return;
-} /* awt_put_back_event() */
-
-/*
- * Gets the next event that has been pushed back onto the queue.
- * Returns 0 and fills in xev_out if successful
- */
-static int32_t
-awt_get_next_put_back_event(XEvent *xev_out) {
-
- Boolean err = False;
- if (putbackQueueCount < 1) {
- err = True;
- } else {
- memcpy(xev_out, &(putbackQueue[0]), sizeof(XEvent));
- }
- if (!err) {
- /* remove it from the queue */
- if (putbackQueueCount == 1) {
-
- // queue is now empty
- if (putbackQueueCapacity > PUTBACK_QUEUE_MIN_INCREMENT) {
-
- /* Too much space -- delete it and rebuild later */
- free(putbackQueue);
- putbackQueue = NULL;
- putbackQueueCapacity = 0;
- }
- } else {
- /* more than 1 event in queue - shift all events to the left */
- /* We don't free the allocated memory until the queue
- becomes empty, just 'cause it's easier that way. */
- /* NOTE: use memmove(), because the memory blocks overlap */
- memmove(&(putbackQueue[0]), &(putbackQueue[1]),
- (putbackQueueCount-1)*sizeof(XEvent));
- }
- --putbackQueueCount;
- }
- DASSERT(putbackQueueCount >= 0);
-
- return (err? -1:0);
-
-} /* awt_get_next_put_back_event() */
-
-/**
- * Determines whether or not there are X or Xt events pending.
- * Looks at the putbackQueue.
- */
-static XtInputMask
-awt_events_pending(XtAppContext appContext) {
- XtInputMask imask = 0L;
- imask = XtAppPending(appContext);
- if (putbackQueueCount > 0) {
- imask |= XtIMXEvent;
- }
- return imask;
-}
-
-
-#ifndef NOMODALFIX
-#define WIDGET_ARRAY_SIZE 5;
-static int32_t arraySize = 0;
-static int32_t arrayIndx = 0;
-static Widget *dShells = NULL;
-
-void
-awt_shellPoppedUp(Widget shell,
- XtPointer modal,
- XtPointer call_data)
-{
- if (arrayIndx == arraySize ) {
- /* if we have not allocate an array, do it first */
- if (arraySize == 0) {
- arraySize += WIDGET_ARRAY_SIZE;
- dShells = (Widget *) malloc(sizeof(Widget) * arraySize);
- } else {
- arraySize += WIDGET_ARRAY_SIZE;
- dShells = (Widget *) realloc((void *)dShells, sizeof(Widget) * arraySize);
- }
- }
-
- dShells[arrayIndx] = shell;
- arrayIndx++;
-}
-
-void
-awt_shellPoppedDown(Widget shell,
- XtPointer modal,
- XtPointer call_data)
-{
- arrayIndx--;
-
- if (dShells[arrayIndx] == shell) {
- dShells[arrayIndx] = NULL;
- return;
- } else {
- int32_t i;
-
- /* find the position of the shell in the array */
- for (i = arrayIndx; i >= 0; i--) {
- if (dShells[i] == shell) {
- break;
- }
- }
-
- /* remove the found element */
- while (i <= arrayIndx-1) {
- dShells[i] = dShells[i+1];
- i++;
- }
- }
-}
-
-Boolean
-awt_isWidgetModal(Widget widget)
-{
- Widget w;
-
- for (w = widget; !XtIsShell(w); w = XtParent(w)) { }
-
- while (w != NULL) {
- if (w == dShells[arrayIndx-1]) {
- return True;
- }
- w = XtParent(w);
- }
- return False;
-}
-
-Boolean
-awt_isModal()
-{
- return (arrayIndx > 0);
-}
-#endif // NOMODALFIX
-
-
-/*
- * Simply waits for terminateFn() to return True. Waits on the
- * awt lock and is notified to check its state by the main event
- * loop whenever the Xt event queue is empty.
- *
- * NOTE: when you use this routine check if it can be called on the event
- * dispatch thread during drag-n-drop operation and update
- * secondary_loop_event() predicate to prevent deadlock.
- */
-void
-awt_MToolkit_modalWait(int32_t (*terminateFn) (void *data), void *data )
-{
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
- AWT_LOCK();
- AWT_FLUSHOUTPUT_NOW();
- while ((*terminateFn) (data) == 0) {
- AWT_WAIT(AWT_MAX_POLL_TIMEOUT);
- if ((*env)->ExceptionCheck(env)) {
- (*env)->ExceptionClear(env);
- break;
- }
- }
- AWT_NOTIFY_ALL();
- AWT_UNLOCK();
-}
-
-static uint32_t
-colorToRGB(XColor * color)
-{
- int32_t rgb = 0;
-
- rgb |= ((color->red >> 8) << 16);
- rgb |= ((color->green >> 8) << 8);
- rgb |= ((color->blue >> 8) << 0);
-
- return rgb;
-}
-
-/*
- * fix for bug #4088106 - ugly text boxes and grayed out looking text
- */
-
-XmColorProc oldColorProc;
-
-void
-ColorProc(XColor* bg_color,
- XColor* fg_color,
- XColor* sel_color,
- XColor* ts_color,
- XColor* bs_color)
-{
- unsigned long plane_masks[1];
- unsigned long colors[5];
-
- AwtGraphicsConfigDataPtr defaultConfig =
- getDefaultConfig(DefaultScreen(awt_display));
-
- /* use the default procedure to calculate colors */
- oldColorProc(bg_color, fg_color, sel_color, ts_color, bs_color);
-
- /* check if there is enought free color cells */
- if (XAllocColorCells(awt_display, defaultConfig->awt_cmap, False,
- plane_masks, 0, colors, 5)) {
- XFreeColors(awt_display, defaultConfig->awt_cmap, colors, 5, 0);
- return;
- }
-
- /* find the closest matches currently available */
- fg_color->pixel = defaultConfig->AwtColorMatch(fg_color->red >> 8,
- fg_color->green >> 8,
- fg_color->blue >> 8,
- defaultConfig);
- fg_color->flags = DoRed | DoGreen | DoBlue;
- XQueryColor(awt_display, defaultConfig->awt_cmap, fg_color);
- sel_color->pixel = defaultConfig->AwtColorMatch(sel_color->red >> 8,
- sel_color->green >> 8,
- sel_color->blue >> 8,
- defaultConfig);
- sel_color->flags = DoRed | DoGreen | DoBlue;
- XQueryColor(awt_display, defaultConfig->awt_cmap, sel_color);
- ts_color->pixel = defaultConfig->AwtColorMatch(ts_color->red >> 8,
- ts_color->green >> 8,
- ts_color->blue >> 8,
- defaultConfig);
- ts_color->flags = DoRed | DoGreen | DoBlue;
- XQueryColor(awt_display, defaultConfig->awt_cmap, ts_color);
- bs_color->pixel = defaultConfig->AwtColorMatch(bs_color->red >> 8,
- bs_color->green >> 8,
- bs_color->blue >> 8,
- defaultConfig);
- bs_color->flags = DoRed | DoGreen | DoBlue;
- XQueryColor(awt_display, defaultConfig->awt_cmap, bs_color);
-}
-
-
-/*
- * Read _XSETTINGS_SETTINGS property from _XSETTINGS selection owner
- * and pass its value to the java world for processing.
- */
-/*static*/ void
-awt_xsettings_update(int scr, Window owner, void *cookie)
-{
- Display *dpy = awt_display;
- int status;
-
- JNIEnv *env;
- jobject mtoolkit;
- jmethodID upcall;
- jbyteArray array;
-
- struct xsettings_callback_cookie *upcall_cookie = cookie;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- unsigned char *xsettings;
-
- DTRACE_PRINTLN2("XS: update screen %d, owner 0x%08lx",
- scr, owner);
-
-#if 1 /* XXX: kludge */
- /*
- * As toolkit cannot yet cope with per-screen desktop properties,
- * only report XSETTINGS changes on the default screen. This
- * should be "good enough" for most cases.
- */
- if (scr != DefaultScreen(dpy)) {
- DTRACE_PRINTLN2("XS: XXX: default screen is %d, update is for %d, ignoring", DefaultScreen(dpy), scr);
- return;
- }
-#endif /* kludge */
-
- env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- DASSERT(env != NULL);
-
- DASSERT(upcall_cookie != NULL);
- mtoolkit = upcall_cookie->mtoolkit;
- upcall = upcall_cookie->upcallMID;
-
- DASSERT(!JNU_IsNull(env, mtoolkit));
- DASSERT(upcall != NULL);
-
- /*
- * XXX: move awt_getPropertyFOO from awt_wm.c to awt_util.c and
- * use the appropriate one.
- */
- status = XGetWindowProperty(dpy, owner,
- _XA_XSETTINGS_SETTINGS, 0, 0xFFFF, False,
- _XA_XSETTINGS_SETTINGS,
- &actual_type, &actual_format, &nitems, &bytes_after,
- &xsettings);
-
- if (status != Success) {
- DTRACE_PRINTLN("XS: unable to read _XSETTINGS");
- return;
- }
-
- if (xsettings == NULL) {
- DTRACE_PRINTLN("XS: reading _XSETTINGS, got NULL");
- return;
- }
-
- if (actual_type != _XA_XSETTINGS_SETTINGS) {
- XFree(xsettings); /* NULL data already catched above */
- DTRACE_PRINTLN("XS: _XSETTINGS_SETTINGS is not of type _XSETTINGS_SETTINGS");
- return;
- }
-
- DTRACE_PRINTLN1("XS: read %lu bytes of _XSETTINGS_SETTINGS",
- nitems);
-
- /* ok, propagate xsettings to the toolkit for processing */
- if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
- DTRACE_PRINTLN("XS: EnsureLocalCapacity failed");
- XFree(xsettings);
- return;
- }
-
- array = (*env)->NewByteArray(env, (jint)nitems);
- if (JNU_IsNull(env, array)) {
- DTRACE_PRINTLN("awt_xsettings_update: NewByteArray failed");
- XFree(xsettings);
- return;
- }
-
- (*env)->SetByteArrayRegion(env, array, 0, (jint)nitems,
- (jbyte *)xsettings);
- XFree(xsettings);
-
- (*env)->CallVoidMethod(env, mtoolkit, upcall, (jint)scr, array);
- (*env)->DeleteLocalRef(env, array);
-}
-
-
-/*
- * Event handler for events on XSETTINGS selection owner.
- * We are interested in PropertyNotify only.
- */
-static void
-awt_xsettings_callback(int scr, XEvent *xev, void *cookie)
-{
- Display *dpy = awt_display; /* xev->xany.display */
- XPropertyEvent *ev;
-
- if (xev->type != PropertyNotify) {
- DTRACE_PRINTLN2("XS: awt_xsettings_callback(%d) event %d ignored",
- scr, xev->type);
- return;
- }
-
- ev = &xev->xproperty;
-
- if (ev->atom == None) {
- DTRACE_PRINTLN("XS: awt_xsettings_callback(%d) atom == None");
- return;
- }
-
-#ifdef DEBUG
- {
- char *name;
-
- DTRACE_PRINT2("XS: awt_xsettings_callback(%d) 0x%08lx ",
- scr, ev->window);
- name = XGetAtomName(dpy, ev->atom);
- if (name == NULL) {
- DTRACE_PRINT1("atom #%d", ev->atom);
- } else {
- DTRACE_PRINT1("%s", name);
- XFree(name);
- }
- DTRACE_PRINTLN1(" %s", ev->state == PropertyNewValue ?
- "changed" : "deleted");
- }
-#endif
-
- if (ev->atom != _XA_XSETTINGS_SETTINGS) {
- DTRACE_PRINTLN("XS: property != _XSETTINGS_SETTINGS ... ignoring");
- return;
- }
-
-
- if (ev->state == PropertyDelete) {
- /* XXX: notify toolkit to reset to "defaults"? */
- return;
- }
-
- awt_xsettings_update(scr, ev->window, cookie);
-}
-
-
-/*
- * Owner of XSETTINGS selection changed on the given screen.
- */
-static void
-awt_xsettings_owner_callback(int scr, Window owner, long *data_unused,
- void *cookie)
-{
- if (owner == None) {
- DTRACE_PRINTLN("XS: awt_xsettings_owner_callback: owner = None");
- /* XXX: reset to defaults??? */
- return;
- }
-
- DTRACE_PRINTLN1("XS: awt_xsettings_owner_callback: owner = 0x%08lx",
- owner);
-
- awt_xsettings_update(scr, owner, cookie);
-}
-
-/*
- * Returns a reference to the class java.awt.Component.
- */
-jclass
-getComponentClass(JNIEnv *env)
-{
- static jclass componentCls = NULL;
-
- // get global reference of java/awt/Component class (run only once)
- if (componentCls == NULL) {
- jclass componentClsLocal = (*env)->FindClass(env, "java/awt/Component");
- DASSERT(componentClsLocal != NULL);
- if (componentClsLocal == NULL) {
- /* exception already thrown */
- return NULL;
- }
- componentCls = (jclass)(*env)->NewGlobalRef(env, componentClsLocal);
- (*env)->DeleteLocalRef(env, componentClsLocal);
- }
- return componentCls;
-}
-
-
-/*
- * Returns a reference to the class java.awt.MenuComponent.
- */
-jclass
-getMenuComponentClass(JNIEnv *env)
-{
- static jclass menuComponentCls = NULL;
-
- // get global reference of java/awt/MenuComponent class (run only once)
- if (menuComponentCls == NULL) {
- jclass menuComponentClsLocal = (*env)->FindClass(env, "java/awt/MenuComponent");
- DASSERT(menuComponentClsLocal != NULL);
- if (menuComponentClsLocal == NULL) {
- /* exception already thrown */
- return NULL;
- }
- menuComponentCls = (jclass)(*env)->NewGlobalRef(env, menuComponentClsLocal);
- (*env)->DeleteLocalRef(env, menuComponentClsLocal);
- }
- return menuComponentCls;
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: init
- * Signature: (Ljava/lang/String;)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_init(JNIEnv *env, jobject this,
- jstring mainClassName)
-{
- char *appName = NULL;
- char *mainChars = NULL;
-
- int32_t argc = 0;
- char *argv[10] = { NULL };
-
- /*
- * Note: The MToolkit object depends on the static initializer
- * of X11GraphicsEnvironment to initialize the connection to
- * the X11 server.
- */
- XFontStruct *xfont;
- XmFontListEntry tmpFontListEntry;
- char *multiclick_time_query;
- AwtGraphicsConfigDataPtr defaultConfig =
- getDefaultConfig(DefaultScreen(awt_display));
- AwtScreenDataPtr defaultScreen =
- getScreenData(DefaultScreen(awt_display));
-
- static String fallback_resources[] =
- {
- "*enableThinThickness: True",
- "*XmFileSelectionBox.fileFilterStyle: XmFILTER_HIDDEN_FILES",
- "*XmFileSelectionBox.pathMode: XmPATH_MODE_RELATIVE",
- "*XmFileSelectionBox.resizePolicy: XmRESIZE_GROW",
- "*XmFileSelectionBox*dirTextLabelString: Enter path or folder name:",
- "*XmFileSelectionBox*applyLabelString: Update",
- "*XmFileSelectionBox*selectionLabelString: Enter file name:",
- "*XmFileSelectionBox*dirListLabelString: Folders",
- NULL /* Must be NULL terminated */
- };
-
- focusOutEvent.type = FocusOut;
- focusOutEvent.xfocus.send_event = True;
- focusOutEvent.xfocus.display = awt_display;
- focusOutEvent.xfocus.mode = NotifyNormal;
- focusOutEvent.xfocus.detail = NotifyNonlinear;
-
- /* Need to make sure this is deleted someplace! */
- AWT_LOCK();
-
- XSetIOErrorHandler(xIOError);
-
- if (!XSupportsLocale()) {
- jio_fprintf(stderr,
- "current locale is not supported in X11, locale is set to C");
- setlocale(LC_ALL, "C");
- }
- if (!XSetLocaleModifiers("")) {
- jio_fprintf(stderr, "X locale modifiers are not supported, using default");
- }
-#ifdef NETSCAPE
- if (awt_init_xt) {
- XtToolkitInitialize();
- }
-#else
- XtToolkitInitialize();
-#endif
-
- {
- jclass fontConfigClass;
- jmethodID methID;
- jstring jFontList;
- char *cFontRsrc;
- char *cFontRsrc2;
-
- fontConfigClass = (*env)->FindClass(env, "sun/awt/motif/MFontConfiguration");
- methID = (*env)->GetStaticMethodID(env, fontConfigClass,
- "getDefaultMotifFontSet",
- "()Ljava/lang/String;");
- jFontList = (*env)->CallStaticObjectMethod(env, fontConfigClass, methID);
- if (jFontList == NULL) {
- motifFontList =
- "-monotype-arial-regular-r-normal--*-140-*-*-p-*-iso8859-1";
- } else {
- motifFontList = JNU_GetStringPlatformChars(env, jFontList, NULL);
- }
-
- /* fprintf(stderr, "motifFontList: %s\n", motifFontList); */
-
- cFontRsrc = malloc(strlen(motifFontList) + 20);
- strcpy(cFontRsrc, "*fontList: ");
- strcat(cFontRsrc, motifFontList);
- cFontRsrc2 = malloc(strlen(motifFontList) + 20);
- strcpy(cFontRsrc2, "*labelFontList: ");
- strcat(cFontRsrc2, motifFontList);
-
- argc = 1;
- argv[argc++] = "-xrm";
- argv[argc++] = cFontRsrc;
- argv[argc++] = "-xrm";
- argv[argc++] = cFontRsrc2;
- argv[argc++] = "-font";
- argv[argc++] = (char *)defaultMotifFont;
- }
-
- awt_appContext = XtCreateApplicationContext();
- XtAppSetErrorHandler(awt_appContext, (XtErrorHandler) xtError);
- XtAppSetFallbackResources(awt_appContext, fallback_resources);
-
- appName = NULL;
- mainChars = NULL;
- if (!JNU_IsNull(env, mainClassName)) {
- mainChars = (char *)JNU_GetStringPlatformChars(env, mainClassName, NULL);
- appName = mainChars;
- }
- if (appName == NULL || appName[0] == '\0') {
- appName = "AWT";
- }
-
- XtDisplayInitialize(awt_appContext, awt_display,
- appName, /* application name */
- appName, /* application class */
- NULL, 0, &argc, argv);
-
- /* Root shell widget that serves as a parent for all AWT top-levels. */
- awt_root_shell = XtVaAppCreateShell(appName, /* application name */
- appName, /* application class */
- applicationShellWidgetClass,
- awt_display,
- /* va_list */
- XmNmappedWhenManaged, False,
- NULL);
- XtRealizeWidget(awt_root_shell);
-
- if (mainChars != NULL) {
- JNU_ReleaseStringPlatformChars(env, mainClassName, mainChars);
- }
-
- awt_mgrsel_init();
- awt_wm_init();
- init_xembed();
-
- /*
- * Find the correct awt_multiclick_time to use. We normally
- * would call XtMultiClickTime() and wouldn't have to do
- * anything special, but because OpenWindows defines its own
- * version (OpenWindows.MultiClickTimeout), we need to
- * determine out which resource to use.
- *
- * We do this by searching in order for:
- *
- * 1) an explicit definition of multiClickTime
- * (this is the resource that XtGetMultiClickTime uses)
- *
- * if that fails, search for:
- *
- * 2) an explicit definition of Openwindows.MultiClickTimeout
- *
- * if both searches fail:
- *
- * 3) use the fallback provided by XtGetMultiClickTime()
- * (which is 200 milliseconds... I looked at the source :-)
- *
- */
- multiclick_time_query = XGetDefault(awt_display, "*", "multiClickTime");
- if (multiclick_time_query) {
- awt_multiclick_time = XtGetMultiClickTime(awt_display);
- } else {
- multiclick_time_query = XGetDefault(awt_display,
- "OpenWindows", "MultiClickTimeout");
- if (multiclick_time_query) {
- /* Note: OpenWindows.MultiClickTimeout is in tenths of
- a second, so we need to multiply by 100 to convert to
- milliseconds */
- awt_multiclick_time = atoi(multiclick_time_query) * 100;
- } else {
- awt_multiclick_time = XtGetMultiClickTime(awt_display);
- }
- }
-
- scrollBugWorkAround = TRUE;
-
- /*
- * Create the cursor for TextArea scrollbars...
- */
- awt_scrollCursor = XCreateFontCursor(awt_display, XC_left_ptr);
-
- awt_defaultBg = defaultConfig->AwtColorMatch(200, 200, 200, defaultConfig);
- awt_defaultFg = defaultScreen->blackpixel;
- setup_modifier_map(awt_display);
-
- awt_initialize_DataTransferer();
- awt_initialize_Xm_DnD(awt_display);
-
- /*
- * fix for bug #4088106 - ugly text boxes and grayed out looking text
- */
- oldColorProc = XmGetColorCalculation();
- XmSetColorCalculation(ColorProc);
-
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: run
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_awt_motif_MToolkit_run
- (JNIEnv *env, jobject this)
-{
- /*
- * in performSelect(), we multiply the timeout by 1000. Make sure
- * that the maximum value will not cause an overflow.
- */
- DASSERT(AWT_MAX_POLL_TIMEOUT <= (ULONG_MAX/1000));
-
- awt_MainThread = (*env)->NewGlobalRef(env, awtJNI_GetCurrentThread(env));
- awt_MToolkit_loop(env); /* never returns */
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: makeColorModel
- * Signature: ()Ljava/awt/image/ColorModel;
- */
-JNIEXPORT jobject JNICALL Java_sun_awt_motif_MToolkit_makeColorModel
- (JNIEnv *env, jclass this)
-{
- AwtGraphicsConfigDataPtr defaultConfig =
- getDefaultConfig(DefaultScreen(awt_display));
-
- return awtJNI_GetColorModel(env, defaultConfig);
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: getScreenResolution
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getScreenResolution
- (JNIEnv *env, jobject this)
-{
- return (jint) ((DisplayWidth(awt_display, DefaultScreen(awt_display))
- * 25.4) /
- DisplayWidthMM(awt_display, DefaultScreen(awt_display)));
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: getScreenWidth
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getScreenWidth
- (JNIEnv *env, jobject this)
-{
- return DisplayWidth(awt_display, DefaultScreen(awt_display));
-}
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: getScreenHeight
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getScreenHeight
- (JNIEnv *env, jobject this)
-{
- return DisplayHeight(awt_display, DefaultScreen(awt_display));
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: beep
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_awt_motif_MToolkit_beep
- (JNIEnv *env, jobject this)
-{
- AWT_LOCK();
- XBell(awt_display, 0);
- AWT_FLUSH_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: shutdown
- * Signature: ()V
- */
-
-JNIEXPORT void JNICALL Java_sun_awt_motif_MToolkit_shutdown
- (JNIEnv *env, jobject this)
-{
- X11SD_LibDispose(env);
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: getLockingKeyStateNative
- * Signature: (I)B
- */
-JNIEXPORT jboolean JNICALL Java_sun_awt_motif_MToolkit_getLockingKeyStateNative
- (JNIEnv *env, jobject this, jint awtKey)
-{
- KeySym sym;
- KeyCode keyCode;
- uint32_t byteIndex;
- uint32_t bitIndex;
- char keyVector[32];
-
- AWT_LOCK();
-
- sym = awt_getX11KeySym(awtKey);
- keyCode = XKeysymToKeycode(awt_display, sym);
- if (sym == NoSymbol || keyCode == 0) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", "Keyboard doesn't have requested key");
- AWT_UNLOCK();
- return False;
- }
-
- byteIndex = (keyCode/8);
- bitIndex = keyCode & 7;
- XQueryKeymap(awt_display, keyVector);
-
- AWT_UNLOCK();
-
- return (1 & (keyVector[byteIndex] >> bitIndex));
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: loadSystemColors
- * Signature: ([I)V
- */
-JNIEXPORT void JNICALL Java_sun_awt_motif_MToolkit_loadSystemColors
- (JNIEnv *env, jobject this, jintArray systemColors)
-{
- Widget frame, panel, control, menu, text, scrollbar;
- Colormap cmap;
- Pixel bg, fg, highlight, shadow;
- Pixel pixels[java_awt_SystemColor_NUM_COLORS];
- XColor *colorsPtr;
- jint rgbColors[java_awt_SystemColor_NUM_COLORS];
- int32_t count = 0;
- int32_t i, j;
- Arg args[10];
- int32_t argc;
- AwtGraphicsConfigDataPtr defaultConfig =
- getDefaultConfig(DefaultScreen(awt_display));
-
- AWT_LOCK();
-
- /*
- * initialize array of pixels
- */
- for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) {
- pixels[i] = -1;
- }
-
- /*
- * Create phantom widgets in order to determine the default
- * colors; this is somewhat inelegant, however it is the simplest
- * and most reliable way to determine the system's default colors
- * for objects.
- */
- argc = 0;
- XtSetArg(args[argc], XmNbuttonFontList, getMotifFontList()); argc++;
- XtSetArg(args[argc], XmNlabelFontList, getMotifFontList()); argc++;
- XtSetArg(args[argc], XmNtextFontList, getMotifFontList()); argc++;
- frame = XtAppCreateShell("AWTColors", "XApplication",
- vendorShellWidgetClass,
- awt_display,
- args, argc);
- /*
- XtSetMappedWhenManaged(frame, False);
- XtRealizeWidget(frame);
- */
- panel = XmCreateDrawingArea(frame, "awtPanelColor", NULL, 0);
- argc = 0;
- XtSetArg(args[argc], XmNfontList, getMotifFontList()); argc++;
- control = XmCreatePushButton(panel, "awtControlColor", args, argc);
- argc = 0;
- XtSetArg(args[argc], XmNlabelFontList, getMotifFontList()); argc++;
- XtSetArg(args[argc], XmNbuttonFontList, getMotifFontList()); argc++;
- menu = XmCreatePulldownMenu(control, "awtColorMenu", args, argc);
- argc = 0;
- XtSetArg(args[argc], XmNfontList, getMotifFontList()); argc++;
- text = XmCreateText(panel, "awtTextColor", args, argc);
- scrollbar = XmCreateScrollBar(panel, "awtScrollbarColor", NULL, 0);
-
- XtVaGetValues(panel,
- XmNbackground, &bg,
- XmNforeground, &fg,
- XmNcolormap, &cmap,
- NULL);
-
- pixels[java_awt_SystemColor_WINDOW] = bg;
- count++;
- pixels[java_awt_SystemColor_INFO] = bg;
- count++;
- pixels[java_awt_SystemColor_WINDOW_TEXT] = fg;
- count++;
- pixels[java_awt_SystemColor_INFO_TEXT] = fg;
- count++;
-
- XtVaGetValues(menu,
- XmNbackground, &bg,
- XmNforeground, &fg,
- NULL);
-
- pixels[java_awt_SystemColor_MENU] = bg;
- count++;
- pixels[java_awt_SystemColor_MENU_TEXT] = fg;
- count++;
-
- XtVaGetValues(text,
- XmNbackground, &bg,
- XmNforeground, &fg,
- NULL);
-
- pixels[java_awt_SystemColor_TEXT] = bg;
- count++;
- pixels[java_awt_SystemColor_TEXT_TEXT] = fg;
- count++;
- pixels[java_awt_SystemColor_TEXT_HIGHLIGHT] = fg;
- count++;
- pixels[java_awt_SystemColor_TEXT_HIGHLIGHT_TEXT] = bg;
- count++;
-
- XtVaGetValues(control,
- XmNbackground, &bg,
- XmNforeground, &fg,
- XmNtopShadowColor, &highlight,
- XmNbottomShadowColor, &shadow,
- NULL);
-
- pixels[java_awt_SystemColor_CONTROL] = bg;
- count++;
- pixels[java_awt_SystemColor_CONTROL_TEXT] = fg;
- count++;
- pixels[java_awt_SystemColor_CONTROL_HIGHLIGHT] = highlight;
- count++;
- pixels[java_awt_SystemColor_CONTROL_LT_HIGHLIGHT] = highlight;
- count++;
- pixels[java_awt_SystemColor_CONTROL_SHADOW] = shadow;
- count++;
- pixels[java_awt_SystemColor_CONTROL_DK_SHADOW] = shadow;
- count++;
-
- XtVaGetValues(scrollbar,
- XmNbackground, &bg,
- NULL);
- pixels[java_awt_SystemColor_SCROLLBAR] = bg;
- count++;
-
- /*
- * Convert pixel values to RGB
- */
- colorsPtr = (XColor *) malloc(count * sizeof(XColor));
- j = 0;
- for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) {
- if (pixels[i] != -1) {
- colorsPtr[j++].pixel = pixels[i];
- }
- }
- XQueryColors(awt_display, cmap, colorsPtr, count);
-
- /* Get current System Colors */
-
- (*env)->GetIntArrayRegion (env, systemColors, 0,
- java_awt_SystemColor_NUM_COLORS,
- rgbColors);
-
- /*
- * Fill systemColor array with new rgb values
- */
-
- j = 0;
- for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) {
- if (pixels[i] != -1) {
- uint32_t rgb = colorToRGB(&colorsPtr[j++]);
-
- /*
- printf("SystemColor[%d] = %x\n", i, rgb);
- */
- rgbColors[i] = (rgb | 0xFF000000);
- }
- }
-
- (*env)->SetIntArrayRegion(env,
- systemColors,
- 0,
- java_awt_SystemColor_NUM_COLORS,
- rgbColors);
-
- /* Duplicate system colors. If color allocation is unsuccessful,
- system colors will be approximated with matched colors */
- if (defaultConfig->awt_depth == 8)
- awt_allocate_systemcolors(colorsPtr, count, defaultConfig);
-
- /*
- * Cleanup
- */
- XtDestroyWidget(frame);
- free(colorsPtr);
-
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: isDynamicLayoutSupportedNative
- * Signature: ()Z
- *
- * Note: there doesn't seem to be a protocol for querying the WM
- * about its opaque resize settings, so this function just returns
- * whether there is a solid resize option available for that WM.
- */
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isDynamicLayoutSupportedNative(JNIEnv *env, jobject this)
-{
- enum wmgr_t wm;
-
- AWT_LOCK();
- wm = awt_wm_getRunningWM();
- AWT_UNLOCK();
-
- switch (wm) {
- case ENLIGHTEN_WM:
- case KDE2_WM:
- case SAWFISH_WM:
- case ICE_WM:
- case METACITY_WM:
- return JNI_TRUE;
- case OPENLOOK_WM:
- case MOTIF_WM:
- case CDE_WM:
- return JNI_FALSE;
- default:
- return JNI_FALSE;
- }
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: isFrameStateSupported
- * Signature: (I)Z
- */
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isFrameStateSupported(JNIEnv *env, jobject this,
- jint state)
-{
- if (state == java_awt_Frame_NORMAL || state == java_awt_Frame_ICONIFIED) {
- return JNI_TRUE;
- } else {
- return awt_wm_supportsExtendedState(state) ? JNI_TRUE : JNI_FALSE;
- }
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: getMulticlickTime
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getMulticlickTime
- (JNIEnv *env, jobject this)
-{
- return awt_multiclick_time;
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: loadXSettings
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_loadXSettings(JNIEnv *env, jobject this)
-{
- static Boolean registered = False;
-
- jclass mtoolkitCLS;
- Display *dpy = awt_display;
- const Window *owners;
- int scr;
-
- AWT_LOCK();
-
- if (registered) {
- AWT_UNLOCK();
- return;
- }
-
- if (_XA_XSETTINGS_SETTINGS == None) {
- _XA_XSETTINGS_SETTINGS = XInternAtom(dpy, "_XSETTINGS_SETTINGS", False);
- if (_XA_XSETTINGS_SETTINGS == None) {
- JNU_ThrowNullPointerException(env,
- "unable to intern _XSETTINGS_SETTINGS");
- AWT_UNLOCK();
- return;
- }
- }
-
- mtoolkitCLS = (*env)->GetObjectClass(env, this);
-
- xsettings_callback_cookie.mtoolkit =
- (*env)->NewGlobalRef(env, this);
- xsettings_callback_cookie.upcallMID =
- (*env)->GetMethodID(env, mtoolkitCLS,
- "parseXSettings", "(I[B)V");
-
- if (JNU_IsNull(env, xsettings_callback_cookie.upcallMID)) {
- JNU_ThrowNoSuchMethodException(env,
- "sun.awt.motif.MToolkit.parseXSettings");
- AWT_UNLOCK();
- return;
- }
-
- owners = awt_mgrsel_select("_XSETTINGS", PropertyChangeMask,
- &xsettings_callback_cookie,
- awt_xsettings_callback,
- awt_xsettings_owner_callback);
- if (owners == NULL) {
- JNU_ThrowNullPointerException(env,
- "unable to regiser _XSETTINGS with mgrsel");
- AWT_UNLOCK();
- return;
- }
-
- registered = True;
-
- for (scr = 0; scr < ScreenCount(dpy); ++scr) {
- if (owners[scr] == None) {
- DTRACE_PRINTLN1("XS: MToolkit.loadXSettings: none on screen %d",
- scr);
- continue;
- }
-
- awt_xsettings_update(scr, owners[scr], &xsettings_callback_cookie);
- }
-
- AWT_UNLOCK();
-}
-
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isAlwaysOnTopSupported(JNIEnv *env, jobject toolkit) {
- Boolean res;
- AWT_LOCK();
- res = awt_wm_supportsAlwaysOnTop();
- AWT_UNLOCK();
- return res;
-}
-
-/*
- * Returns true if the current thread is privileged. Currently,
- * only the main event loop thread is considered to be privileged.
- */
-Boolean
-awt_currentThreadIsPrivileged(JNIEnv *env) {
- return (*env)->IsSameObject(env,
- awt_MainThread, awtJNI_GetCurrentThread(env));
-}
-
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isSyncUpdated(JNIEnv *env, jobject toolkit) {
- return syncUpdated;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isSyncFailed(JNIEnv *env, jobject toolkit) {
- return syncFailed;
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_updateSyncSelection(JNIEnv *env, jobject toolkit) {
-
- // AWT_LOCK is held by calling function
- if (wm_selection == None) {
- wm_selection = XInternAtom(awt_display, "WM_S0", False);
- }
- if (version_atom == None) {
- version_atom = XInternAtom(awt_display, "VERSION", False);
- }
- if (oops_atom == None) {
- oops_atom = XInternAtom(awt_display, "OOPS", False);
- }
- syncUpdated = False;
- syncFailed = False;
- XConvertSelection(awt_display, wm_selection, version_atom, oops_atom, XtWindow(awt_root_shell), CurrentTime);
- XSync(awt_display, False);
- inSyncWait = True; // Protect from spurious events
- // Calling function will call AWT_LOCK_WAIT instead of AWT_UNLOCK
-}
-
-JNIEXPORT jint JNICALL
-Java_sun_awt_motif_MToolkit_getEventNumber(JNIEnv *env, jobject toolkit) {
- // AWT_LOCK must be held by the calling method
- return eventNumber;
-}
-
-static void
-syncWait_eventHandler(XEvent * event) {
- static jmethodID syncNotifyMID = NULL;
- if (event != NULL && event->xany.type == SelectionNotify &&
- event->xselection.requestor == XtWindow(awt_root_shell) &&
- event->xselection.property == oops_atom &&
- inSyncWait)
- {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- syncUpdated = True;
- inSyncWait = False;
- AWT_NOTIFY_ALL();
- } else if (event != NULL && event->xany.type == SelectionNotify &&
- event->xselection.requestor == XtWindow(awt_root_shell) &&
- event->xselection.target == version_atom &&
- event->xselection.property == None &&
- XGetSelectionOwner(awt_display, wm_selection) == None &&
- event->xselection.selection == wm_selection)
- {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- syncFailed = True;
- inSyncWait = False;
- AWT_NOTIFY_ALL();
- }
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_nativeGrab(JNIEnv *env, jobject toolkit, jobject window) {
- struct FrameData *wdata;
- static Cursor cursor = None;
- int grab_result;
-
- AWT_LOCK();
-
- wdata = (struct FrameData *)
- JNU_GetLongFieldAsPtr(env, window, mComponentPeerIDs.pData);
-
- if (wdata == NULL ||
- wdata->winData.comp.widget == NULL ||
- wdata->winData.shell == NULL)
- {
- AWT_UNLOCK();
- return;
- }
- if (None == cursor) {
- cursor = XCreateFontCursor(awt_display, XC_hand2);
- }
- grabbed_widget = wdata->winData.shell;
- grab_result = XGrabPointer(awt_display, XtWindow(wdata->winData.shell),
- True, (ButtonPressMask | ButtonReleaseMask
- | EnterWindowMask | LeaveWindowMask | PointerMotionMask
- | ButtonMotionMask),
- GrabModeAsync, GrabModeAsync, None,
- cursor, CurrentTime);
- if (GrabSuccess != grab_result) {
- XUngrabPointer(awt_display, CurrentTime);
- AWT_UNLOCK();
- DTRACE_PRINTLN1("XGrabPointer() failed, result %d", grab_result);
- return;
- }
- grab_result = XGrabKeyboard(awt_display, XtWindow(wdata->winData.shell),
- True,
- GrabModeAsync, GrabModeAsync, CurrentTime);
- if (GrabSuccess != grab_result) {
- XUngrabKeyboard(awt_display, CurrentTime);
- XUngrabPointer(awt_display, CurrentTime);
- DTRACE_PRINTLN1("XGrabKeyboard() failed, result %d", grab_result);
- }
- AWT_UNLOCK();
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_nativeUnGrab(JNIEnv *env, jobject toolkit, jobject window) {
- struct FrameData *wdata;
-
- AWT_LOCK();
-
- wdata = (struct FrameData *)
- JNU_GetLongFieldAsPtr(env, window, mComponentPeerIDs.pData);
-
- if (wdata == NULL ||
- wdata->winData.comp.widget == NULL ||
- wdata->winData.shell == NULL)
- {
- AWT_UNLOCK();
- return;
- }
-
- XUngrabPointer(awt_display, CurrentTime);
- XUngrabKeyboard(awt_display, CurrentTime);
- grabbed_widget = NULL;
- AWT_FLUSHOUTPUT_NOW();
-
- AWT_UNLOCK();
-
-}
-
-/*
- * Class: sun_awt_motif_MToolkit
- * Method: getWMName
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT jstring JNICALL
-Java_sun_awt_motif_MToolkit_getWMName(JNIEnv *env, jclass this)
-{
- enum wmgr_t wm;
-
- AWT_LOCK();
- wm = awt_wm_getRunningWM();
- AWT_UNLOCK();
-
- switch (wm) {
- case NO_WM:
- return (*env)->NewStringUTF(env, "NO_WM");
- case OTHER_WM:
- return (*env)->NewStringUTF(env, "OTHER_WM");
- case ENLIGHTEN_WM:
- return (*env)->NewStringUTF(env, "ENLIGHTEN_WM");
- case KDE2_WM:
- return (*env)->NewStringUTF(env, "KDE2_WM");
- case SAWFISH_WM:
- return (*env)->NewStringUTF(env, "SAWFISH_WM");
- case ICE_WM:
- return (*env)->NewStringUTF(env, "ICE_WM");
- case METACITY_WM:
- return (*env)->NewStringUTF(env, "METACITY_WM");
- case OPENLOOK_WM:
- return (*env)->NewStringUTF(env, "OPENLOOK_WM");
- case MOTIF_WM:
- return (*env)->NewStringUTF(env, "MOTIF_WM");
- case CDE_WM:
- return (*env)->NewStringUTF(env, "CDE_WM");
- }
- return (*env)->NewStringUTF(env, "UNDETERMINED_WM");
-}
-
-
-#endif /* !HEADLESS */
--- a/jdk/src/solaris/native/sun/awt/awt_MToolkit.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-#ifndef _MTOOLKIT_H_
-#define _MTOOLKIT_H_
-#ifndef HEADLESS
-extern void *findPeer(Widget * pwidget);
-extern Widget findWindowsProxy(jobject window, JNIEnv *env);
-extern struct WidgetInfo *findWidgetInfo(Widget widget);
-extern Boolean isAncestor(Window ancestor, Window child);
-extern void clearFocusPath(Widget shell);
-extern void globalClearFocusPath(Widget focusOwnerShell);
-extern Boolean isFrameOrDialog(jobject target, JNIEnv * env);
-extern jobject getOwningFrameOrDialog(jobject target, JNIEnv *env);
-
-#define SPECIAL_KEY_EVENT 2
-
-#endif /* !HEADLESS */
-#endif /* _MTOOLKIT_H_ */
--- a/jdk/src/solaris/native/sun/awt/awt_MenuItem.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <jni_util.h>
-
-/* fieldIDs for MenuItem fields that may be accessed from C */
-struct MenuItemIDs {
- jfieldID label;
- jfieldID enabled;
- jfieldID shortcut;
-};
-
-/* fieldIDs for MMenuItemPeer fields that may be accessed from C */
-struct MMenuItemPeerIDs {
- jfieldID target;
- jfieldID pData;
- jfieldID isCheckbox;
- jfieldID jniGlobalRef;
-};
--- a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* methodsIDs for MPopupMenuPeer methods that may be accessed from C */
-struct MPopupMenuPeerIDs {
- jmethodID destroyNativeWidgetAfterGettingTreeLock;
-};
--- a/jdk/src/solaris/native/sun/awt/awt_Robot.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_Robot.c Thu Dec 15 19:52:13 2011 -0800
@@ -28,7 +28,6 @@
#endif
#include "awt_p.h"
-#include "awt_Component.h"
#include "awt_GraphicsEnv.h"
#define XK_MISCELLANY
#include <X11/keysymdef.h>
--- a/jdk/src/solaris/native/sun/awt/awt_TopLevel.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- */
-#ifndef _TOPLEVEL_H_
-#define _TOPLEVEL_H_
-#ifndef HEADLESS
-
-extern Widget findFocusProxy(Widget widget);
-extern Widget findTopLevelByShell(Widget widget);
-extern jobject findTopLevel(jobject peer, JNIEnv *env);
-extern void shellEH(Widget w, XtPointer data, XEvent *event, Boolean *continueToDispatch);
-extern Boolean isFocusableWindowByShell(JNIEnv * env, Widget shell);
-extern Boolean isFocusableWindowByPeer(JNIEnv * env, jobject peer);
-extern Widget getShellWidget(Widget child);
-extern Boolean isFocusableComponentTopLevelByWidget(JNIEnv * env, Widget child);
-#endif /* !HEADLESS */
-#endif /* _TOPLEVEL_H_ */
--- a/jdk/src/solaris/native/sun/awt/awt_Window.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <jni_util.h>
-
-/* fieldIDs for Window fields that may be accessed from C */
-struct WindowIDs {
- jfieldID warningString;
- jfieldID locationByPlatform;
- jfieldID isAutoRequestFocus;
-};
-
-/* fieldIDs for MWindowPeer fields that may be accessed from C */
-struct MWindowPeerIDs {
- jfieldID insets;
- jfieldID iconWidth;
- jfieldID iconHeight;
- jfieldID winAttr;
- jmethodID handleWindowFocusIn;
- jmethodID handleWindowFocusOut;
- jmethodID handleIconify;
- jmethodID handleDeiconify;
- jmethodID handleStateChange;
- jmethodID draggedToScreenMID;
-};
--- a/jdk/src/solaris/native/sun/awt/awt_mgrsel.c Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,449 +0,0 @@
-/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifdef HEADLESS
- #error This file should not be included in headless library
-#endif
-
-#include "awt_mgrsel.h"
-
-static Atom XA_MANAGER = None;
-
-/*
- * Structures that describes the manager selection AWT listens to with
- * callabacks to the subsytems interested in the selection. (We only
- * listen to a couple of selections, so linear search is enough).
- */
-struct AwtMgrsel {
- char *selname; /* base name of selection atoms */
- Atom *per_scr_atoms; /* per-screen selection atoms (ICCCM 1.2.6) */
- Atom *per_scr_owners; /* windows currently owning the selection */
- long extra_mask; /* extra events to listen to on owners */
- void *cookie;
- void (*callback_event)(int, XEvent *, void *); /* extra_mask events */
- void (*callback_owner)(int, Window, long *, void *); /* owner changes */
- struct AwtMgrsel *next;
-};
-
-static struct AwtMgrsel *mgrsel_list = NULL;
-
-
-static int awt_mgrsel_screen(Window w);
-static Window awt_mgrsel_select_per_screen(Atom, long);
-static int awt_mgrsel_managed(XClientMessageEvent *mgrown);
-static int awt_mgrsel_unmanaged(XDestroyWindowEvent *ev);
-
-#ifdef DEBUG
-static void awt_mgrsel_dtraceManaged(XClientMessageEvent *mgrown);
-#endif
-
-
-
-/*
- * Find which screen the window W is the root of.
- * Returns the screen number, or -1 if W is not a root.
- */
-static int
-awt_mgrsel_screen(Window w)
-{
- Display *dpy = awt_display;
- int scr;
-
- for (scr = 0; scr < ScreenCount(dpy); ++scr) {
- if (w == RootWindow(dpy, scr)) {
- return (scr);
- }
- }
-
- return (-1);
-}
-
-
-/************************************************************************
- * For every one that asketh receiveth; and he that seeketh findeth;
- * and to him that knocketh it shall be opened. (Luke 11:10).
- */
-
-
-/*
- * A method for a subsytem to express its interest in a certain
- * manager selection.
- *
- * If owner changes, the callback_owner will be called with the screen
- * number and the new owning window when onwership is established, or
- * None if the owner is gone.
- *
- * Events in extra_mask are selected for on owning windows (exsiting
- * ones and on new owners when established) and callback_event will be
- * called with the screen number and an event.
- *
- * The function returns an array of current owners. The size of the
- * array is ScreenCount(awt_display). The array is "owned" by this
- * module and should be considered by the caller as read-only.
- */
-const Window *
-awt_mgrsel_select(const char *selname, long extra_mask,
- void *cookie,
- void (*callback_event)(int, XEvent *, void *),
- void (*callback_owner)(int, Window, long *, void *))
-{
- Display *dpy = awt_display;
- struct AwtMgrsel *mgrsel;
- Atom *per_scr_atoms;
- Window *per_scr_owners;
- char *namesbuf;
- char **names;
- int per_scr_sz;
- int nscreens = ScreenCount(dpy);
- int scr;
- Status status;
-
- DASSERT(selname != NULL);
- DTRACE_PRINTLN1("MG: select: %s", selname);
-
- /* buffer size for one per-screen atom name */
- per_scr_sz = strlen(selname) + /* "_S" */ 2 + /* %2d */ + 2 /* '\0' */+ 1;
-
- namesbuf = malloc(per_scr_sz * nscreens); /* actual storage for names */
- names = malloc(sizeof(char *) * nscreens); /* pointers to names */
- per_scr_atoms = malloc(sizeof(Atom) * nscreens);
- per_scr_owners = malloc(sizeof(Window) * nscreens);
- mgrsel = malloc(sizeof(struct AwtMgrsel));
-
- if (namesbuf == NULL || names == NULL || per_scr_atoms == NULL
- || per_scr_owners == NULL || mgrsel == NULL)
- {
- DTRACE_PRINTLN("MG: select: unable to allocate memory");
- if (namesbuf != NULL) free(namesbuf);
- if (names != NULL) free(names);
- if (per_scr_atoms != NULL) free(per_scr_atoms);
- if (per_scr_owners != NULL) free(per_scr_owners);
- if (mgrsel != NULL) free(mgrsel);
- return (NULL);
- }
-
-
- for (scr = 0; scr < nscreens; ++scr) {
- size_t sz;
-
- names[scr] = &namesbuf[per_scr_sz * scr];
- sz = snprintf(names[scr], per_scr_sz, "%s_S%-d", selname, scr);
- DASSERT(sz < per_scr_sz);
- }
-
- status = XInternAtoms(dpy, names, nscreens, False, per_scr_atoms);
-
- free(names);
- free(namesbuf);
-
- if (status == 0) {
- DTRACE_PRINTLN("MG: select: XInternAtoms failed");
- free(per_scr_atoms);
- free(per_scr_owners);
- return (NULL);
- }
-
- mgrsel->selname = strdup(selname);
- mgrsel->per_scr_atoms = per_scr_atoms;
- mgrsel->per_scr_owners = per_scr_owners;
- mgrsel->extra_mask = extra_mask;
- mgrsel->cookie = cookie;
- mgrsel->callback_event = callback_event;
- mgrsel->callback_owner = callback_owner;
-
- for (scr = 0; scr < nscreens; ++scr) {
- Window owner;
-
- owner = awt_mgrsel_select_per_screen(per_scr_atoms[scr], extra_mask);
- mgrsel->per_scr_owners[scr] = owner;
-#ifdef DEBUG
- if (owner == None) {
- DTRACE_PRINTLN1("MG: screen %d - None", scr);
- } else {
- DTRACE_PRINTLN2("MG: screen %d - 0x%08lx", scr, owner);
- }
-#endif
- }
-
- mgrsel->next = mgrsel_list;
- mgrsel_list = mgrsel;
-
- return (per_scr_owners);
-}
-
-
-static Window
-awt_mgrsel_select_per_screen(Atom selection, long extra_mask)
-{
- Display *dpy = awt_display;
- Window owner;
-
- XGrabServer(dpy);
-
- owner = XGetSelectionOwner(dpy, selection);
- if (owner == None) {
- /* we'll get notified later if one arrives */
- XUngrabServer(dpy);
- /* Workaround for bug 5039226 */
- XSync(dpy, False);
- return (None);
- }
-
- /*
- * Select for StructureNotifyMask to get DestroyNotify when owner
- * is gone. Also select for any additional events caller is
- * interested in (e.g. PropertyChangeMask). Caller will be
- * notifed of these events via ... XXX ...
- */
- XSelectInput(dpy, owner, StructureNotifyMask | extra_mask);
-
- XUngrabServer(dpy);
- /* Workaround for bug 5039226 */
- XSync(dpy, False);
- return (owner);
-}
-
-
-/************************************************************************
- * And so I saw the wicked buried, who had come and gone from the
- * place of the holy, and they were forgotten in the city where they
- * had so done: this is also vanity. (Eccl 8:10)
- */
-
-#ifdef DEBUG
-/*
- * Print the message from the new manager that announces it acquired
- * ownership.
- */
-static void
-awt_mgrsel_dtraceManaged(XClientMessageEvent *mgrown)
-{
- Display *dpy = awt_display;
- Atom selection;
- char *selname, *print_selname;
- int scr;
-
- scr = awt_mgrsel_screen(mgrown->window);
-
- selection = mgrown->data.l[1];
- print_selname = selname = XGetAtomName(dpy, selection);
- if (selname == NULL) {
- if (selection == None) {
- print_selname = "<None>";
- } else {
- print_selname = "<Unknown>";
- }
- }
-
- DTRACE_PRINTLN4("MG: new MANAGER for %s: screen %d, owner 0x%08lx (@%lu)",
- print_selname, scr,
- mgrown->data.l[2], /* the window owning the selection */
- mgrown->data.l[0]); /* timestamp */
- DTRACE_PRINTLN4("MG: %ld %ld / 0x%lx 0x%lx", /* extra data */
- mgrown->data.l[3], mgrown->data.l[4],
- mgrown->data.l[3], mgrown->data.l[4]);
-
- if (selname != NULL) {
- XFree(selname);
- }
-}
-#endif /* DEBUG */
-
-
-static int
-awt_mgrsel_managed(XClientMessageEvent *mgrown)
-{
- Display *dpy = awt_display;
- struct AwtMgrsel *mgrsel;
- int scr;
-
- long timestamp;
- Atom selection;
- Window owner;
- long *data;
-
- if (mgrown->message_type != XA_MANAGER) {
- DTRACE_PRINTLN("MG: ClientMessage type != MANAGER, ignoring");
- return (0);
- }
-
- scr = awt_mgrsel_screen(mgrown->window);
-
-#ifdef DEBUG
- awt_mgrsel_dtraceManaged(mgrown);
-#endif
-
- if (scr < 0) {
- DTRACE_PRINTLN("MG: MANAGER ClientMessage with a non-root window!");
- return (0);
- }
-
- timestamp = mgrown->data.l[0];
- selection = mgrown->data.l[1];
- owner = mgrown->data.l[2];
- data = &mgrown->data.l[3]; /* long[2], selection specific */
-
- /* is this a selection we are intrested in? */
- for (mgrsel = mgrsel_list; mgrsel != NULL; mgrsel = mgrsel->next) {
- if (selection == mgrsel->per_scr_atoms[scr])
- break;
- }
-
- if (mgrsel == NULL) {
- DTRACE_PRINTLN("MG: not interested in this selection, ignoring");
- return (0);
- }
-
-
- mgrsel->per_scr_owners[scr] = owner;
-
- XSelectInput(dpy, owner, StructureNotifyMask | mgrsel->extra_mask);
-
- /* notify the listener */
- if (mgrsel->callback_owner != NULL) {
- (*mgrsel->callback_owner)(scr, owner, data, mgrsel->cookie);
- }
-
- return (1);
-}
-
-
-static int
-awt_mgrsel_unmanaged(XDestroyWindowEvent *ev)
-{
- Display *dpy = awt_display;
- struct AwtMgrsel *mgrsel;
- Window exowner;
- int scr;
-
- exowner = ev->window; /* selection owner that's gone */
-
- /* is this a selection we are intrested in? */
- for (mgrsel = mgrsel_list; mgrsel != NULL; mgrsel = mgrsel->next) {
- for (scr = 0; scr < ScreenCount(dpy); ++scr) {
- if (exowner == mgrsel->per_scr_owners[scr]) {
- /* can one window own selections for more than one screen? */
- goto out; /* XXX??? */
- }
- }
- }
- out:
- if (mgrsel == NULL) {
- DTRACE_PRINTLN1("MG: DestroyNotify for 0x%08lx ignored", exowner);
- return (0);
- }
-
- DTRACE_PRINTLN3("MG: DestroyNotify for 0x%08lx, owner of %s at screen %d",
- exowner, mgrsel->selname, scr);
-
- /* notify the listener (pass exowner as data???) */
- if (mgrsel->callback_owner != NULL) {
- (*mgrsel->callback_owner)(scr, None, NULL, mgrsel->cookie);
- }
-
- return (1);
-}
-
-
-/*
- * Hook to be called from toolkit event loop.
- */
-int
-awt_mgrsel_processEvent(XEvent *ev)
-{
- Display *dpy = awt_display;
- struct AwtMgrsel *mgrsel;
- int scr;
-
- if (ev->type == ClientMessage) { /* new manager announces ownership? */
- if (awt_mgrsel_managed(&ev->xclient))
- return (1);
- }
-
- if (ev->type == DestroyNotify) { /* manager gives up selection? */
- if (awt_mgrsel_unmanaged(&ev->xdestroywindow))
- return (1);
- }
-
- /* is this an event selected on one of selection owners? */
- for (mgrsel = mgrsel_list; mgrsel != NULL; mgrsel = mgrsel->next) {
- for (scr = 0; scr < ScreenCount(dpy); ++scr) {
- if (ev->xany.window == mgrsel->per_scr_owners[scr]) {
- /* can one window own selections for more than one screen? */
- goto out; /* XXX??? */
- }
- }
- }
- out:
- DTRACE_PRINT2("MG: screen %d, event %d ... ",
- scr, ev->xany.type);
- if (mgrsel == NULL) {
- DTRACE_PRINTLN("ignored");
- return (0); /* not interested */
- }
-
- DTRACE_PRINT1("%s ... ", mgrsel->selname);
- if (mgrsel->callback_event != NULL) {
- DTRACE_PRINTLN("dispatching");
- (*mgrsel->callback_event)(scr, ev, mgrsel->cookie);
- }
-#ifdef DEBUG
- else {
- DTRACE_PRINTLN("no callback");
- }
-#endif
-
- return (1);
-}
-
-
-void
-awt_mgrsel_init(void)
-{
- static Boolean inited = False;
-
- Display *dpy = awt_display;
- int scr;
-
- if (inited) {
- return;
- }
-
- XA_MANAGER = XInternAtom(dpy, "MANAGER", False);
- DASSERT(XA_MANAGER != None);
-
-
- /*
- * Listen for ClientMessage's on each screen's root. We hook into
- * the message loop in the toolkit (with awt_mgrsel_processEvent)
- * to get the events processed. We need this for notifications of
- * new manager acquiring ownership of the manager selection.
- */
- for (scr = 0; scr < ScreenCount(dpy); ++scr) {
- XSelectInput(dpy, RootWindow(dpy, scr), StructureNotifyMask);
- }
-
- inited = True;
-}
--- a/jdk/src/solaris/native/sun/awt/awt_mgrsel.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef _AWT_MGRSEL_H_
-#define _AWT_MGRSEL_H_
-
-#ifndef HEADLESS
-
-#include "awt_p.h"
-
-extern void awt_mgrsel_init(void);
-extern int awt_mgrsel_processEvent(XEvent *);
-
-extern const Window * awt_mgrsel_select(const char *, long,
- void *,
- void (*)(int, XEvent *, void *),
- void (*)(int, Window, long *, void *));
-
-#endif /* !HEADLESS */
-#endif /* _AWT_MGRSEL_H_ */
--- a/jdk/src/solaris/native/sun/awt/awt_motif.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef _SWITCHXM_P_H_
-#define _SWITCHXM_P_H_
-
-#include <sun_awt_motif_MComponentPeer.h>
-
-#include "gdefs.h"
-#include <X11/Xlib.h>
-#include <X11/Intrinsic.h>
-
-#define MOTIF_NA sun_awt_motif_MComponentPeer_MOTIF_NA
-#define MOTIF_V1 sun_awt_motif_MComponentPeer_MOTIF_V1
-#define MOTIF_V2 sun_awt_motif_MComponentPeer_MOTIF_V2
-
-
-extern int32_t awt_motif_getIMStatusHeight(Widget w, jobject tc);
-extern XVaNestedList awt_motif_getXICStatusAreaList(Widget w, jobject tc);
-extern void awt_motif_Scrollbar_ButtonReleaseHandler (Widget,
- XtPointer,
- XEvent *,
- Boolean *) ;
-
- /* This function causes an UnsatisfiedLinkError on Linux.
- * It's a no-op for Motif 2.1.
- * Since Linux only links against Motif 2.1, we can safely remove
- * this function altogether from the Linux build.
- * bchristi 1/22/2001
- */
-#ifdef __solaris__
-extern void awt_motif_adjustDragTriggerEvent(XEvent* xevent);
-#endif
-
-void awt_motif_enableSingleDragInitiator(Widget w);
-
-#endif /* _SWITCHXM_P_H_ */
--- a/jdk/src/solaris/native/sun/awt/awt_p.h Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_p.h Thu Dec 15 19:52:13 2011 -0800
@@ -49,28 +49,6 @@
#include <X11/keysym.h>
#include <X11/keysymdef.h>
#include <X11/extensions/Xrender.h>
-#ifndef XAWT
-#include <Xm/CascadeB.h>
-#include <Xm/DrawingA.h>
-#include <Xm/FileSB.h>
-#include <Xm/BulletinB.h>
-#include <Xm/Form.h>
-#include <Xm/Frame.h>
-#include <Xm/Label.h>
-#include <Xm/PushB.h>
-#include <Xm/PushBG.h>
-#include <Xm/RowColumn.h>
-#include <Xm/ScrollBar.h>
-#include <Xm/ScrolledW.h>
-#include <Xm/SelectioB.h>
-#include <Xm/SeparatoG.h>
-#include <Xm/ToggleB.h>
-#include <Xm/TextF.h>
-#include <Xm/Text.h>
-#include <Xm/List.h>
-#include <Xm/Xm.h>
-#include <Xm/MainW.h>
-#endif
#endif /* !HEADLESS */
#include "awt.h"
#include "awt_util.h"
@@ -78,33 +56,13 @@
#include "colordata.h"
#include "gdefs.h"
-#ifndef XAWT
-#include "GLXGraphicsConfig.h"
-//#include <sun_awt_motif_MComponentPeer.h>
-#endif
-
#ifndef HEADLESS
-#ifndef XAWT
-#include "awt_motif.h"
-#endif
#ifndef min
#define min(a,b) ((a) <= (b)? (a):(b))
#endif
#ifndef max
#define max(a,b) ((a) >= (b)? (a):(b))
#endif
-
-extern Pixel awt_pixel_by_name(Display *dpy, char *color, char *defaultColor);
-
-typedef struct DropSiteInfo* DropSitePtr;
-
-struct WidgetInfo {
- Widget widget;
- Widget origin;
- void* peer;
- jlong event_mask;
- struct WidgetInfo* next;
-};
#endif /* !HEADLESS */
#define RepaintPending_NONE 0
@@ -112,13 +70,6 @@
#define RepaintPending_EXPOSE (1 << 1)
#define LOOKUPSIZE 32
-typedef struct _DamageRect {
- int x1;
- int y1;
- int x2;
- int y2;
-} DamageRect;
-
#ifndef HEADLESS
typedef XRenderPictFormat *
@@ -157,110 +108,9 @@
typedef AwtScreenData* AwtScreenDataPtr;
-struct ComponentData {
- Widget widget;
- int repaintPending;
- DamageRect repaintRect;
- DamageRect exposeRect;
- DropSitePtr dsi;
-};
-
-struct MessageDialogData {
- struct ComponentData comp;
- int isModal;
-};
-
-struct CanvasData {
- struct ComponentData comp;
- Widget shell;
- int flags;
-};
-
-struct MenuItemData {
- struct ComponentData comp;
- int index;
-};
-
-struct MenuData {
- struct ComponentData comp;
- struct MenuItemData itemData;
-};
-
-
#define W_GRAVITY_INITIALIZED 1
#define W_IS_EMBEDDED 2
-struct FrameData {
- struct CanvasData winData;
- int isModal;
- Widget mainWindow;
- Widget focusProxy; /* for all key events */
- Widget menuBar;
- Widget warningWindow;
- int top; /* these four are the insets... */
- int bottom;
- int left;
- int right;
- int topGuess; /* these four are the guessed insets */
- int bottomGuess;
- int leftGuess;
- int rightGuess;
- int mbHeight; /* height of the menubar window */
- int wwHeight; /* height of the warning window */
- jint state; /* java.awt.Frame.state bits */
- Boolean reparented;
- Boolean configure_seen;
- Boolean shellResized; /* frame shell has been resized */
- Boolean canvasResized; /* frame inner canvas resized */
- Boolean menuBarReset; /* frame menu bar added/removed */
- Boolean isResizable; /* is this window resizable ? */
- Boolean isFixedSizeSet; /* is fixed size already set ? */
- Boolean isShowing; /* is this window now showing ? */
- Boolean hasTextComponentNative;
- Boolean need_reshape;
- Boolean callbacksAdded; /* needed for fix for 4078176 */
- Pixmap iconPixmap; /* Pixmap to hold icon image */
- int iconWidth;
- int iconHeight;
- int imHeight; /* imStatusBar's height */
- Boolean imRemove; /* ImStatusBar is being removed */
- Boolean fixInsets; /* [jk] REMINDER: remove if possible */
- int decor; /* type of native decorations */
- Boolean initialFocus; /* does Window take focus initially */
- Boolean isInputMethodWindow;
-
- /*
- * Fix for BugTraq ID 4060975.
- * firstShellEH() stores to this field handle of the widget that had
- * focus before the shell was resized so that we can later restore it.
- */
- Widget focusWidget;
- int screenNum; /* Which screen this Window is on. Xinerama-aware. */
- Boolean isDisposeScheduled;
- Boolean isFocusableWindow; /* a cache of Window.isFocusableWindow() return value */
-};
-
-struct ListData {
- struct ComponentData comp;
- Widget list;
-};
-
-struct TextAreaData {
- struct ComponentData comp;
- Widget txt;
-};
-
-struct TextFieldData {
- struct ComponentData comp;
- int echoContextID;
- Boolean echoContextIDInit;
-};
-
-struct FileDialogData {
- struct ComponentData comp;
- char *file;
-};
-
typedef struct awtFontList {
char *xlfd;
int index_length;
@@ -276,33 +126,6 @@
XFontStruct *xfont; /* Latin1 font */
};
-#ifndef XAWT
-extern XmFontList getMotifFontList(void);
-extern XFontSet getMotifFontSet(void);
-extern XFontStruct *getMotifFontStruct(void);
-extern Boolean awt_isAwtWidget(Widget widget);
-#endif
-
-struct ChoiceData {
- struct ComponentData comp;
- Widget menu;
- Widget *items;
- int maxitems;
- int n_items;
- short n_columns;
-/* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
- * actual size
- * y and height which Choice takes in pReshape
-*/
- jint bounds_y;
- jint bounds_height;
-};
-
-struct MenuList {
- Widget menu;
- struct MenuList* next;
-};
-
extern struct FontData *awtJNI_GetFontData(JNIEnv *env,jobject font, char **errmsg);
extern AwtGraphicsConfigDataPtr getDefaultConfig(int screen);
@@ -315,20 +138,6 @@
#ifndef HEADLESS
#define XDISPLAY awt_display;
-extern Boolean awt_currentThreadIsPrivileged(JNIEnv *env);
-extern void null_event_handler(Widget w, XtPointer client_data,
- XEvent * event, Boolean * cont);
-
-extern void awt_put_back_event(JNIEnv *env, XEvent *event);
-extern void awt_MToolkit_modalWait(int (*terminateFn)(void *data), void *data);
-extern void awt_Frame_guessInsets(struct FrameData *fdata);
-
-extern void awt_addWidget(Widget w, Widget origin, void *peer, jlong event_mask);
-extern void awt_delWidget(Widget w);
-
-extern void awt_addMenuWidget(Widget w);
-extern void awt_delMenuWidget(Widget w);
-
extern int awt_allocate_colors(AwtGraphicsConfigDataPtr);
extern void awt_allocate_systemcolors(XColor *, int, AwtGraphicsConfigDataPtr);
extern void awt_allocate_systemrgbcolors(jint *, int, AwtGraphicsConfigDataPtr);
@@ -338,24 +147,5 @@
extern jobject awtJNI_GetColorModel(JNIEnv *, AwtGraphicsConfigDataPtr);
extern void awtJNI_CreateColorData (JNIEnv *, AwtGraphicsConfigDataPtr, int lock);
-extern Boolean awtJNI_isSelectionOwner(JNIEnv *env, char *sel_str);
-extern void awtJNI_notifySelectionLost(JNIEnv *env, char *sel_str);
-extern void removePopupMenus();
-extern Boolean awtMenuIsActive();
#endif /* !HEADLESS */
-
-extern void awtJNI_DeleteGlobalRef(JNIEnv *env,jobject thiscomp);
-extern void awtJNI_DeleteGlobalMenuRef(JNIEnv *env,jobject thismenu);
-extern jobject awtJNI_CreateAndSetGlobalRef(JNIEnv *env,jobject thiscomp);
-extern void awtJNI_CleanupGlobalRefs(void);
-
-#ifndef HEADLESS
-/* XXX: Motif internals. Need to fix 4090493. */
-#define MOTIF_XmINVALID_DIMENSION ((Dimension) 0xFFFF)
-#define MOTIF_XmDEFAULT_INDICATOR_DIM ((Dimension) 9)
-
-extern Dimension awt_computeIndicatorSize(struct FontData *fdata);
-extern Dimension awt_adjustIndicatorSizeForMenu(Dimension indSize);
-#endif /* !HEADLESS */
-
#endif /* _AWT_P_H_ */
--- a/jdk/src/solaris/native/sun/awt/awt_util.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_util.c Thu Dec 15 19:52:13 2011 -0800
@@ -29,31 +29,15 @@
#include "awt_p.h"
#include "color.h"
-#include "awt_TopLevel.h"
#include <X11/IntrinsicP.h>
#include <X11/Xatom.h>
#include <X11/Xmd.h>
#include <X11/Xutil.h>
#include <X11/Xproto.h>
-#ifndef XAWT
-#include <Xm/MenuShell.h>
-#include <Xm/List.h>
-#include <Xm/Form.h>
-#include <Xm/RowColumn.h>
-#include <Xm/MwmUtil.h>
-#endif /* XAWT */
#include <jni.h>
#include <jni_util.h>
#include <sys/time.h>
-#include "awt_xembed.h"
-
-
-#ifndef XAWT
-#if MOTIF_VERSION!=1
- #include <Xm/GrabShell.h>
-#endif
-#endif
#include "java_awt_event_MouseWheelEvent.h"
@@ -72,7 +56,6 @@
extern jint getModifiers(uint32_t state, jint button, jint keyCode);
extern jint getButton(uint32_t button);
-static int32_t winmgr_running = 0;
static Atom OLDecorDelAtom = 0;
static Atom MWMHints = 0;
static Atom DTWMHints = 0;
@@ -86,840 +69,6 @@
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
-#ifndef XAWT
-/*
- * The following three funtions are to work around menu problems
- */
-
-/*
- * test if there is a menu that has the current focus
- * called from awt_Dialog.c and awt_Component.c
- */
-Boolean
-awt_util_focusIsOnMenu(Display *display)
-{
- Window window;
- Widget widget;
- int32_t rtr;
-
- XGetInputFocus(display, &window, &rtr);
- if (window == None) {
- return False;
- }
-
- widget = XtWindowToWidget(display, window);
- if (widget == NULL) {
- return False;
- }
-
- if (XtIsSubclass(widget, xmMenuShellWidgetClass)) {
- return True;
- }
-
- #if MOTIF_VERSION!=1
- /* Motif 2.1 uses XmGrabShell on XmComboBox instead
- of XmMenuShell
- */
- if (XtIsSubclass(widget, xmGrabShellWidgetClass)) {
- return True;
- }
- /* Fix 4800638 check the ancestor of focus widget is
- GrabSell
- */
- if (XtIsSubclass(widget, xmListWidgetClass))
- {
- Widget shell = getShellWidget(widget);
- if (shell && XtIsSubclass(shell,
- xmGrabShellWidgetClass))
- {
- return True;
- }
- }
- #endif
-
- if (XtIsSubclass(widget, xmRowColumnWidgetClass)) {
- unsigned char type;
- XtVaGetValues(widget, XmNrowColumnType, &type, NULL);
- if (type == XmMENU_BAR) {
- return True;
- }
- }
- return False;
-}
-
-static
-void fillButtonEvent(XButtonEvent *ev, int32_t type, Display *display, Window window) {
- ev->type = type;
- ev->display = display;
- ev->window = window;
- ev->send_event = True;
-
- /* REMIND: multi-screen */
- ev->root = RootWindow(display, DefaultScreen(display));
- ev->subwindow = (Window)None;
- ev->time = CurrentTime;
- ev->x = 0;
- ev->y = 0;
- ev->x_root = 0;
- ev->y_root = 0;
- ev->same_screen = True;
- ev->button = Button1;
- ev->state = Button1Mask;
-}
-
-/*
- * generates a mouse press event and a release event
- * called from awt_Dialog.c
- */
-int32_t
-awt_util_sendButtonClick(Display *display, Window window)
-{
- XButtonEvent ev;
- int32_t status;
-
- fillButtonEvent(&ev, ButtonPress, display, window);
- status = XSendEvent(display, window, True, ButtonPressMask, (XEvent *)&ev);
-
- if (status != 0) {
- fillButtonEvent(&ev, ButtonRelease, display, window);
- status = XSendEvent(display, window, False, ButtonReleaseMask,
- (XEvent *)&ev);
- }
- return status;
-}
-
-Widget
-awt_util_createWarningWindow(Widget parent, char *warning)
-{
- Widget warningWindow;
-#ifdef NETSCAPE
- extern Widget FE_MakeAppletSecurityChrome(Widget parent, char* message);
- warningWindow = FE_MakeAppletSecurityChrome(parent, warning);
-#else
- Widget label;
- int32_t argc;
-#define MAX_ARGC 10
- Arg args[MAX_ARGC];
- int32_t screen = 0;
- int32_t i;
- AwtGraphicsConfigDataPtr adata;
- extern int32_t awt_numScreens;
-
- Pixel gray;
- Pixel black;
-
- for (i = 0; i < awt_numScreens; i++) {
- if (ScreenOfDisplay(awt_display, i) == XtScreen(parent)) {
- screen = i;
- break;
- }
- }
- adata = getDefaultConfig(screen);
-
- gray = adata->AwtColorMatch(192, 192, 192, adata);
- black = adata->AwtColorMatch(0, 0, 0, adata);
-
- argc = 0;
- XtSetArg(args[argc], XmNbackground, gray); argc++;
- XtSetArg(args[argc], XmNmarginHeight, 0); argc++;
- XtSetArg(args[argc], XmNmarginWidth, 0); argc++;
- XtSetArg (args[argc], XmNscreen, XtScreen(parent)); argc++;
-
- DASSERT(!(argc > MAX_ARGC));
- warningWindow = XmCreateForm(parent, "main", args, argc);
-
- XtManageChild(warningWindow);
- label = XtVaCreateManagedWidget(warning,
- xmLabelWidgetClass, warningWindow,
- XmNhighlightThickness, 0,
- XmNbackground, gray,
- XmNforeground, black,
- XmNalignment, XmALIGNMENT_CENTER,
- XmNrecomputeSize, False,
- NULL);
- XtVaSetValues(label,
- XmNbottomAttachment, XmATTACH_FORM,
- XmNtopAttachment, XmATTACH_FORM,
- XmNleftAttachment, XmATTACH_FORM,
- XmNrightAttachment, XmATTACH_FORM,
- NULL);
-#endif
- return warningWindow;
-}
-
-void
-awt_setWidgetGravity(Widget w, int32_t gravity)
-{
- XSetWindowAttributes xattr;
- Window win = XtWindow(w);
-
- if (win != None) {
- xattr.bit_gravity = StaticGravity;
- xattr.win_gravity = StaticGravity;
- XChangeWindowAttributes(XtDisplay(w), win,
- CWBitGravity|CWWinGravity,
- &xattr);
- }
-}
-
-Widget get_shell_focused_widget(Widget w) {
- while (w != NULL && !XtIsShell(w)) {
- w = XtParent(w);
- }
- if (w != NULL) {
- return XmGetFocusWidget(w);
- } else {
- return NULL;
- }
-}
-
-void
-awt_util_reshape(Widget w, jint x, jint y, jint wd, jint ht)
-{
- Widget parent;
- Dimension ww, wh;
- Position wx, wy;
- Boolean move = False;
- Boolean resize = False;
- Boolean mapped_when_managed = False;
- Boolean need_to_unmanage = True;
- Widget saved_focus_widget = NULL;
-
- if (w == NULL) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- JNU_ThrowNullPointerException(env,"NullPointerException");
- return;
- }
- parent = XtParent(w);
-
- /* Aim: hack to prevent direct children of scrollpane from
- * being unmanaged during a reshape operation (which results
- * in too many expose events).
- */
- if (parent != NULL && XtParent(parent) != NULL &&
- XtIsSubclass(XtParent(parent), xmScrolledWindowWidgetClass)) {
- need_to_unmanage = False;
- }
-
- XtVaGetValues(w,
- XmNwidth, &ww,
- XmNheight, &wh,
- XmNx, &wx,
- XmNy, &wy,
- NULL);
-
- if (x != wx || y != wy) {
- move = True;
- }
- if (wd != ww || ht != wh) {
- resize = True;
- }
- if (!move && !resize) {
- return;
- }
-
- if (need_to_unmanage) {
- if (!resize) {
- mapped_when_managed = w->core.mapped_when_managed;
- w->core.mapped_when_managed = False;
- }
- saved_focus_widget = get_shell_focused_widget(w);
- XtUnmanageChild(w);
- }
-
- /* GES: AVH's hack:
- * Motif ignores attempts to move a toplevel window to 0,0.
- * Instead we set the position to 1,1. The expected value is
- * returned by Frame.getBounds() since it uses the internally
- * held rectangle rather than querying the peer.
- * N.B. [pauly, 9/97] This is only required for wm shells
- * under the Motif Window Manager (MWM), not for any others.
- * Note. Utilizes C short-circuiting if w is not a wm shell.
- */
- if ((x == 0) && (y == 0) &&
- (XtIsSubclass(w, wmShellWidgetClass)) &&
- (XmIsMotifWMRunning(w))) {
- XtVaSetValues(w, XmNx, 1, XmNy, 1, NULL);
- }
-
- if (move && !resize) {
- XtVaSetValues(w, XmNx, x, XmNy, y, NULL);
-
- } else if (resize && !move) {
- XtVaSetValues(w,
- XmNwidth, (wd > 0) ? wd : 1,
- XmNheight, (ht > 0) ? ht : 1,
- NULL);
-
- } else {
- XtVaSetValues(w,
- XmNx, x,
- XmNy, y,
- XmNwidth, (wd > 0) ? wd : 1,
- XmNheight, (ht > 0) ? ht : 1,
- NULL);
- }
-
- if (need_to_unmanage) {
- XtManageChild(w);
- if (!resize) {
- w->core.mapped_when_managed = mapped_when_managed;
- }
- if (saved_focus_widget != NULL) {
- Boolean result = XmProcessTraversal(saved_focus_widget, XmTRAVERSE_CURRENT);
- if (!result)
- {
- Widget shell = saved_focus_widget;
- while(shell != NULL && !XtIsShell(shell)) {
- shell = XtParent(shell);
- }
- XtSetKeyboardFocus(shell, saved_focus_widget);
- }
- }
- }
-}
-
-void
-awt_util_hide(Widget w)
-{
- if (w == NULL) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- JNU_ThrowNullPointerException(env,"NullPointerException");
- return;
- }
- XtSetMappedWhenManaged(w, False);
-}
-
-void
-awt_util_show(Widget w)
-{
-/*
- extern Boolean scrollBugWorkAround;
-*/
- if (w == NULL) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- JNU_ThrowNullPointerException(env,"NullPointerException");
- return;
- }
- XtSetMappedWhenManaged(w, True);
-/*
- XXX: causes problems on 2.5
- if (!scrollBugWorkAround) {
- awt_setWidgetGravity(w, StaticGravity);
- }
-*/
-}
-
-void
-awt_util_enable(Widget w)
-{
- XtSetSensitive(w, True);
-}
-
-void
-awt_util_disable(Widget w)
-{
- XtSetSensitive(w, False);
-}
-
-void
-awt_util_mapChildren(Widget w, void (*func)(Widget,void *),
- int32_t applyToCurrent, void *data) {
- WidgetList wlist;
- Cardinal wlen = 0;
- Cardinal i;
-
- /* The widget may have been destroyed by another thread. */
- if ((w == NULL) || (!XtIsObject(w)) || (w->core.being_destroyed))
- return;
-
- if (applyToCurrent != 0) {
- (*func)(w, data);
- }
- if (!XtIsComposite(w)) {
- return;
- }
-
- XtVaGetValues(w,
- XmNchildren, &wlist,
- XmNnumChildren, &wlen,
- NULL);
- if (wlen > 0) {
- for (i=0; i < wlen; i++) {
- awt_util_mapChildren(wlist[i], func, 1, data);
- }
- }
-}
-
-void
-awt_changeAttributes(Display *dpy, Widget w, unsigned long mask,
- XSetWindowAttributes *xattr)
-{
- WidgetList wlist;
- Cardinal wlen = 0;
- Cardinal i;
-
- if (XtWindow(w) && XtIsRealized(w)) {
- XChangeWindowAttributes(dpy,
- XtWindow(w),
- mask,
- xattr);
- } else {
- return;
- }
- XtVaGetValues(w,
- XmNchildren, &wlist,
- XmNnumChildren, &wlen,
- NULL);
- for (i = 0; i < wlen; i++) {
- if (XtWindow(wlist[i]) && XtIsRealized(wlist[i])) {
- XChangeWindowAttributes(dpy,
- XtWindow(wlist[i]),
- mask,
- xattr);
- }
- }
-}
-
-static Widget prevWgt = NULL;
-
-static void
-DestroyCB(Widget w, XtPointer client_data, XtPointer call_data) {
- if (prevWgt == w) {
- prevWgt = NULL;
- }
-}
-
-int32_t
-awt_util_setCursor(Widget w, Cursor c) {
- static Cursor prevCur = None;
-
- if (XtIsRealized(w)) {
- unsigned long valuemask = 0;
- XSetWindowAttributes attributes;
-
- valuemask = CWCursor;
- if (prevWgt != NULL) {
- attributes.cursor = None;
- XChangeWindowAttributes(awt_display,
- XtWindow(prevWgt),
- valuemask,
- &attributes);
- }
-
- if (c == None) {
- c = prevCur;
- if (w != NULL) {
- XtAddCallback(w, XmNdestroyCallback, DestroyCB, NULL);
- }
- prevWgt = w;
- } else {
- prevCur = c;
- prevWgt = NULL;
- }
- attributes.cursor = c;
- XChangeWindowAttributes(awt_display,
- XtWindow(w),
- valuemask,
- &attributes);
- XFlush(awt_display);
- return 1;
- } else
- return 0;
-}
-
-void
-awt_util_convertEventTimeAndModifiers(XEvent *event,
- ConvertEventTimeAndModifiers *output) {
- switch (event->type) {
- case KeyPress:
- case KeyRelease:
- output->when = awt_util_nowMillisUTC_offset(event->xkey.time);
- output->modifiers = getModifiers(event->xkey.state, 0, 0);
- break;
- case ButtonPress:
- case ButtonRelease:
- output->when = awt_util_nowMillisUTC_offset(event->xbutton.time);
- output->modifiers = getModifiers(event->xbutton.state,
- getButton(event->xbutton.button), 0);
- break;
- default:
- output->when = awt_util_nowMillisUTC();
- output->modifiers =0;
- break;
- }
-}
-
-
-/*
- Part fix for bug id 4017222. Return the widget at the given screen coords
- by searching the widget tree beginning at root. This function will return
- null if the pointer is not over the root widget or child of the root widget.
-
- Additionally, this function will only return a Widget with non-nil XmNuserData.
- In 1.2.1, when the mouse was dragged over a Choice component, this function
- returned the GadgetButton associated with the Choice. This GadgetButton had
- nil as its XmNuserData. This lead to a crash when the nil XmNuserData was
- extracted and used as a reference to a peer. Ooops.
- Now the GadgetButton is not returned and the function goes on to find a widget
- which contains the correct peer reference in XmNuserData.
-*/
-Widget
-awt_WidgetAtXY(Widget root, Position pointerx, Position pointery) {
- Widget answer = NULL;
-
- if(!root) return NULL;
-
- if(XtIsComposite(root)) {
- int32_t i=0;
- WidgetList wl=NULL;
- Cardinal wlen=0;
-
- XtVaGetValues(root, XmNchildren, &wl, XmNnumChildren, &wlen, NULL);
-
- if(wlen>0) {
- for(i=0; i<wlen && !answer; i++) {
- answer = awt_WidgetAtXY(wl[i], pointerx, pointery);
- }
- }
- }
-
- if(!answer) {
- Position wx=0, wy=0;
- Dimension width=0, height=0;
- int32_t lastx=0, lasty=0;
- XtPointer widgetUserData=NULL;
-
- XtVaGetValues(root, XmNwidth, &width, XmNheight, &height,
- XmNuserData, &widgetUserData,
- NULL);
-
- XtTranslateCoords(root, 0, 0, &wx, &wy);
- lastx = wx + width;
- lasty = wy + height;
-
- if(pointerx>=wx && pointerx<=lastx && pointery>=wy && pointery<=lasty &&
- widgetUserData)
- answer = root;
- }
-
- return answer;
-}
-#ifdef __linux__
-
-
-#define MAXARGS 10
-static Arg xic_vlist[MAXARGS];
-static Arg status_vlist[MAXARGS];
-static Arg preedit_vlist[MAXARGS];
-
-#define NO_ARG_VAL -1
-#define SEPARATOR_HEIGHT 2
-
-static XFontSet extract_fontset(XmFontList);
-
-/* get_im_height: returns height of the input method status area in pixels.
- *
- * This function assumes that if any XIM related information cannot be
- * queried then the app must not have an input method status area in the
- * current locale and returns zero as the status area height
- */
-
-static XtPointer*
-get_im_info_ptr(Widget w,
- Boolean create)
-{
- Widget p;
- XmVendorShellExtObject ve;
- XmWidgetExtData extData;
- XmImShellInfo im_info;
- XmImDisplayInfo xim_info;
-
- if (w == NULL)
- return NULL;
-
- p = w;
- while (!XtIsShell(p))
- p = XtParent(p);
-
- /* Check extension data since app could be attempting to create
- * a text widget as child of menu shell. This is illegal, and will
- * be detected later, but check here so we don't core dump.
- */
- if ((extData = _XmGetWidgetExtData((Widget)p, XmSHELL_EXTENSION)) == NULL)
- return NULL;
-
- ve = (XmVendorShellExtObject) extData->widget;
-
- return &ve->vendor.im_info;
-}
-
-static XmImShellInfo
-get_im_info(Widget w,
- Boolean create)
-{
- XmImShellInfo* ptr = (XmImShellInfo *) get_im_info_ptr(w, create);
- if (ptr != NULL)
- return *ptr;
- else
- return NULL;
-}
-
-#endif /* !linux */
-
-Widget
-awt_util_getXICStatusAreaWindow(Widget w)
-{
- while (!XtIsShell(w)){
- w = XtParent(w);
- }
- return w;
-}
-
-#ifdef __linux__
-static XRectangle geometryRect;
-XVaNestedList awt_util_getXICStatusAreaList(Widget w)
-{
- XIC xic;
- XmImXICInfo icp;
- XmVendorShellExtObject ve;
- XmWidgetExtData extData;
- XmImShellInfo im_info;
- XmFontList fl=NULL;
-
- XRectangle *ssgeometry = &geometryRect;
- XRectangle geomRect ;
- XRectangle *im_rect;
- XFontSet *im_font;
-
- Pixel bg ;
- Pixel fg ;
- Dimension height, width ;
- Position x,y ;
- Pixmap bpm, *bpmout ;
-
- XVaNestedList list = NULL;
-
- char *ret;
- Widget p=w;
-
- while (!XtIsShell(p)) {
- p = XtParent(p);
- }
-
- XtVaGetValues(p,
- XmNx, &x,
- XmNy, &y,
- XmNwidth, &width,
- XmNheight, &height,
- XmNbackgroundPixmap, &bpm,
- NULL);
-
- extData = _XmGetWidgetExtData((Widget) p, XmSHELL_EXTENSION);
- if (extData == NULL) {
- return NULL;
- }
- ve = (XmVendorShellExtObject) extData->widget;
- im_info = get_im_info(w, False);
-
- if (im_info == NULL) {
- return NULL;
- } else {
- icp = im_info->iclist;
- }
-
- if (icp) {
- /*
- * We have at least a textfield/textarea in the frame, use the
- * first one.
- */
- ssgeometry->x = 0;
- ssgeometry->y = height - icp->sp_height;
- ssgeometry->width = icp->status_width;
- ssgeometry->height = icp->sp_height;
- XtVaGetValues(w, XmNbackground, &bg, NULL);
- XtVaGetValues(w, XmNforeground, &fg, NULL);
- XtVaGetValues(w, XmNfontList, &fl, NULL);
- /*
- * use motif TextComponent's resource
- */
-
- list = XVaCreateNestedList(0,
- XNFontSet, extract_fontset(fl),
- XNArea, ssgeometry,
- XNBackground, bg,
- XNForeground, fg,
- NULL);
- }
- return list ;
-}
-
-static XFontSet
-extract_fontset(XmFontList fl)
-{
- XmFontContext context;
- XmFontListEntry next_entry;
- XmFontType type_return;
- XtPointer tmp_font;
- XFontSet first_fs = NULL;
- char *font_tag;
-
- if (!XmFontListInitFontContext(&context, fl))
- return NULL;
-
- do {
- next_entry = XmFontListNextEntry(context);
- if (next_entry) {
- tmp_font = XmFontListEntryGetFont(next_entry, &type_return);
- if (type_return == XmFONT_IS_FONTSET) {
- font_tag = XmFontListEntryGetTag(next_entry);
- if (!strcmp(font_tag, XmFONTLIST_DEFAULT_TAG)) {
- XmFontListFreeFontContext(context);
- XtFree(font_tag);
- return (XFontSet) tmp_font;
- }
- XtFree(font_tag);
- if (first_fs == NULL)
- first_fs = (XFontSet) tmp_font;
- }
- }
- } while (next_entry);
-
- XmFontListFreeFontContext(context);
- return first_fs;
-}
-#endif
-
-/*the caller does have the responsibility to free the memory return
- from this function...*/
-char* awt_util_makeWMMenuItem(char *target, Atom protocol){
- char *buf = NULL;
- int32_t buflen = 0;
-
- /*a label in a menuitem is not supposed to be a FullOfSpaceString... */
- buflen = strlen(target) * 3;
- buf = (char*)malloc(buflen + 20);
- if (buf == NULL){
- JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
- }
- else{
- int32_t off = 0;
- char *ptr = target;
- while ((off < (buflen - 20)) && (*ptr != '\0')){
- if (*ptr == ' '){
- *(buf + off++) = 0x5c;
- }
- *(buf + off++) = *ptr++;
- }
- sprintf(buf + off, " f.send_msg %ld", protocol);
- }
- return buf;
-}
-
-/*
- * This callback proc is installed via setting the XmNinsertPosition
- * resource on a widget. It ensures that components added
- * to a widget are inserted in the correct z-order position
- * to match up with their peer/target ordering in Container.java
- */
-Cardinal
-awt_util_insertCallback(Widget w)
-{
- jobject peer;
- WidgetList children;
- Cardinal num_children;
- Widget parent;
- XtPointer userdata;
- Cardinal index;
- int32_t pos;
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
- parent = XtParent(w);
- XtVaGetValues(parent,
- XmNnumChildren, &num_children,
- XmNchildren, &children,
- NULL);
- XtVaGetValues(w, XmNuserData, &userdata, NULL);
-
- index = num_children; /* default is to add to end */
-
- if (userdata != NULL) {
- peer = (jobject) userdata;
-
- // SECURITY: We are running on the privileged toolkit thread.
- // The peer must *NOT* call into user code
- pos = (int32_t) JNU_CallMethodByName(env
- ,NULL
- ,(jobject) peer
- ,"getZOrderPosition_NoClientCode"
- ,"()I").i;
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
- }
- index = (Cardinal) (pos != -1 ? pos : num_children);
- }
- return index;
-}
-
-void
-awt_util_consumeAllXEvents(Widget widget)
-{
- /* Remove all queued X Events for the window of the widget. */
-
-#define ALL_EVENTS_MASK 0xFFFF
-
- XEvent xev;
-
- XFlush(awt_display);
- while (XCheckWindowEvent(awt_display, XtWindow(widget),
- ALL_EVENTS_MASK, &xev)) ;
-}
-
-#endif /* XAWT */
-/**
- * Gets the thread we are currently executing on
- */
-jobject
-awtJNI_GetCurrentThread(JNIEnv *env) {
- static jclass threadClass = NULL;
- static jmethodID currentThreadMethodID = NULL;
-
- jobject currentThread = NULL;
-
- /* Initialize our java identifiers once. Checking before locking
- * is a huge performance win.
- */
- if (threadClass == NULL) {
- // should enter a monitor here...
- Boolean err = FALSE;
- if (threadClass == NULL) {
- jclass tc = (*env)->FindClass(env, "java/lang/Thread");
- threadClass = (*env)->NewGlobalRef(env, tc);
- if (threadClass != NULL) {
- currentThreadMethodID = (*env)->GetStaticMethodID(env,
- threadClass,
- "currentThread",
- "()Ljava/lang/Thread;"
- );
- }
- }
- if (currentThreadMethodID == NULL) {
- threadClass = NULL;
- err = TRUE;
- }
- if (err) {
- return NULL;
- }
- } /* threadClass == NULL*/
-
- currentThread = (*env)->CallStaticObjectMethod(
- env, threadClass, currentThreadMethodID);
- DASSERT(!((*env)->ExceptionOccurred(env)));
- /*JNU_PrintString(env, "getCurrentThread() -> ", JNU_ToString(env,currentThread));*/
- return currentThread;
-} /* awtJNI_GetCurrentThread() */
-
void
awtJNI_ThreadYield(JNIEnv *env) {
@@ -956,426 +105,3 @@
(*env)->CallStaticVoidMethod(env, threadClass, yieldMethodID);
DASSERT(!((*env)->ExceptionOccurred(env)));
} /* awtJNI_ThreadYield() */
-
-#ifndef XAWT
-
-void
-awt_util_cleanupBeforeDestroyWidget(Widget widget)
-{
- /* Bug 4017222: Drag processing uses global prevWidget. */
- if (widget == prevWidget) {
- prevWidget = NULL;
- }
-}
-
-static Boolean timeStampUpdated = False;
-
-static int32_t
-isTimeStampUpdated(void* p) {
- return timeStampUpdated;
-}
-
-static void
-propertyChangeEventHandler(Widget w, XtPointer client_data,
- XEvent* event, Boolean* continue_to_dispatch) {
- timeStampUpdated = True;
-}
-
-/*
- * If the application doesn't receive events with timestamp for a long time
- * XtLastTimestampProcessed() will return out-of-date value. This may cause
- * selection handling routines to fail (see BugTraq ID 4085183).
- * This routine is to resolve this problem. It queries the current X server
- * time by appending a zero-length data to a property as prescribed by
- * X11 Reference Manual.
- * Note that this is a round-trip request, so it can be slow. If you know
- * that the Xt timestamp is up-to-date use XtLastTimestampProcessed().
- */
-Time
-awt_util_getCurrentServerTime() {
-
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- static Atom _XA_JAVA_TIME_PROPERTY_ATOM = 0;
- Time server_time = 0;
-
- AWT_LOCK();
-
- if (_XA_JAVA_TIME_PROPERTY_ATOM == 0) {
- XtAddEventHandler(awt_root_shell, PropertyChangeMask, False,
- propertyChangeEventHandler, NULL);
- _XA_JAVA_TIME_PROPERTY_ATOM = XInternAtom(awt_display, "_SUNW_JAVA_AWT_TIME", False);
- }
-
- timeStampUpdated = False;
- XChangeProperty(awt_display, XtWindow(awt_root_shell),
- _XA_JAVA_TIME_PROPERTY_ATOM, XA_ATOM, 32, PropModeAppend,
- (unsigned char *)"", 0);
- XFlush(awt_display);
-
- if (awt_currentThreadIsPrivileged(env)) {
- XEvent event;
- XMaskEvent(awt_display, PropertyChangeMask, &event);
- XtDispatchEvent(&event);
- } else {
- awt_MToolkit_modalWait(isTimeStampUpdated, NULL);
- }
- server_time = XtLastTimestampProcessed(awt_display);
-
- AWT_UNLOCK();
-
- return server_time;
-}
-
-/*
- * This function is stolen from /src/solaris/hpi/src/system_md.c
- * It is used in setting the time in Java-level InputEvents
- */
-jlong
-awt_util_nowMillisUTC()
-{
- struct timeval t;
- gettimeofday(&t, NULL);
- return ((jlong)t.tv_sec) * 1000 + (jlong)(t.tv_usec/1000);
-}
-
-/*
- * This function converts between the X server time (number of milliseconds
- * since the last server reset) and the UTC time for the 'when' field of an
- * InputEvent (or another event type with a timestamp).
- */
-jlong
-awt_util_nowMillisUTC_offset(Time server_offset)
-{
- /*
- * Because Time is of type 'unsigned long', it is possible that Time will
- * never wrap when using 64-bit Xlib. However, if a 64-bit client
- * connects to a 32-bit server, I suspect the values will still wrap. So
- * we should not attempt to remove the wrap checking even if _LP64 is
- * true.
- */
- static const jlong WRAP_TIME_MILLIS = (jlong)((uint32_t)-1);
- static jlong reset_time_utc;
-
- jlong current_time_utc = awt_util_nowMillisUTC();
-
- if ((current_time_utc - reset_time_utc) > WRAP_TIME_MILLIS) {
- reset_time_utc = awt_util_nowMillisUTC() -
- awt_util_getCurrentServerTime();
- }
-
- return reset_time_utc + server_offset;
-}
-
-void awt_util_do_wheel_scroll(Widget scrolled_window, jint scrollType,
- jint scrollAmt, jint wheelAmt) {
- Widget scrollbar = NULL;
- int value;
- int slider_size;
- int min;
- int max;
- int increment;
- int page_increment;
- int scrollAdjustment;
- int newValue;
-
- /* TODO:
- * If a TextArea's scrollbar policy is set to never, it should still
- * wheel scroll, but right now it doesn't.
- */
-
- scrollbar = awt_util_get_scrollbar_to_scroll(scrolled_window);
- if (scrollbar == NULL) { /* no suitable scrollbar for scrolling */
- return;
- }
-
- XtVaGetValues(scrollbar, XmNvalue, &value,
- XmNsliderSize, &slider_size,
- XmNminimum, &min,
- XmNmaximum, &max,
- XmNincrement, &increment,
- XmNpageIncrement, &page_increment, NULL);
-
- if (scrollType == java_awt_event_MouseWheelEvent_WHEEL_BLOCK_SCROLL) {
- scrollAdjustment = page_increment;
- }
- else { // WHEEL_UNIT_SCROLL
- scrollAdjustment = increment * scrollAmt;
- }
-
- if (wheelAmt < 0) {
- // Don't need to check that newValue < max - slider_size because
- // newValue < current value. If scrollAmt is ever user-configurable,
- // we'll have to check this.
- newValue = MAX(min, value+ (scrollAdjustment * wheelAmt));
- }
- else {
- newValue = MIN(max - slider_size,
- value + (scrollAdjustment * wheelAmt));
- }
-
- XtVaSetValues(scrollbar, XmNvalue, newValue, NULL);
- XtCallCallbacks(scrollbar, XmNvalueChangedCallback, NULL);
-}
-
-
-/* Given a ScrollWindow widget, return the Scrollbar that the wheel should
- * scroll. A null return value means that the ScrollWindow has a scrollbar
- * display policy of none, or that neither scrollbar can be scrolled.
- */
-Widget awt_util_get_scrollbar_to_scroll(Widget scrolled_window) {
- Widget scrollbar = NULL;
- int value;
- int slider_size;
- int min;
- int max;
-
- /* first, try the vertical scrollbar */
- XtVaGetValues(scrolled_window, XmNverticalScrollBar, &scrollbar, NULL);
- if (scrollbar != NULL) {
- XtVaGetValues(scrollbar, XmNvalue, &value,
- XmNsliderSize, &slider_size,
- XmNminimum, &min,
- XmNmaximum, &max, NULL);
- if (slider_size < max - min) {
- return scrollbar;
- }
- }
-
- /* then, try the horiz */
- XtVaGetValues(scrolled_window, XmNhorizontalScrollBar, &scrollbar, NULL);
- if (scrollbar != NULL) {
- XtVaGetValues(scrollbar, XmNvalue, &value,
- XmNsliderSize, &slider_size,
- XmNminimum, &min,
- XmNmaximum, &max, NULL);
- if (slider_size < max - min) {
- return scrollbar;
- }
- }
- /* neither is suitable for scrolling */
- return NULL;
-}
-
-EmbeddedFrame *theEmbeddedFrameList = NULL;
-
-static void awt_util_updateXtCoordinatesForEmbeddedFrame(Widget ef)
-{
- Window ef_window;
- Window win;
- int32_t x, y;
- ef_window = XtWindow(ef);
- if (ef_window != None) {
- if (XTranslateCoordinates(awt_display, ef_window,
- RootWindowOfScreen(XtScreen(ef)),
- 0, 0, &x, &y, &win)) {
- DTRACE_PRINTLN("correcting coordinates");
- ef->core.x = x;
- ef->core.y = y;
- }
- }
-}
-
-Boolean awt_util_processEventForEmbeddedFrame(XEvent *ev)
-{
- EmbeddedFrame *ef;
- Boolean dummy;
- Boolean eventProcessed = False;
- switch (ev->type) {
- case FocusIn:
- case FocusOut:
- ef = theEmbeddedFrameList;
- while (ef != NULL) {
- if (ef->frameContainer == ev->xfocus.window) {
- eventProcessed = True;
- if (isXEmbedActiveByWindow(XtWindow(ef->embeddedFrame))) {
- return True;
- }
- // pretend that the embedded frame gets a focus event
- // the event's window field is not the same as
- // the embeddedFrame's widget, but luckily the shellEH
- // doesnt seem to care about this.
- shellEH(ef->embeddedFrame, ef->javaRef, ev, &dummy);
- }
- ef = ef->next;
- }
- return eventProcessed;
- case ConfigureNotify:
- for (ef = theEmbeddedFrameList; ef != NULL; ef = ef->next) {
- awt_util_updateXtCoordinatesForEmbeddedFrame(ef->embeddedFrame);
- }
- return True;
- }
- return False;
-}
-
-void awt_util_addEmbeddedFrame(Widget embeddedFrame, jobject javaRef)
-{
- EmbeddedFrame *ef, *eflist;
- Atom WM_STATE;
- Window win;
- Window parent, root;
- Window *children;
- uint32_t nchildren;
- Atom type = None;
- int32_t format;
- unsigned long nitems, after;
- unsigned char * data;
- XWindowAttributes win_attributes;
-
- WM_STATE = XInternAtom(awt_display, "WM_STATE", True);
- if (WM_STATE == None) {
- return;
- }
- win = XtWindow(embeddedFrame);
- if (win == None)
- return;
- /*
- * according to XICCM, we search our toplevel window
- * by looking for WM_STATE property
- */
- while (True) {
- if (!XQueryTree(awt_display, win, &root, &parent,
- &children, &nchildren)) {
- return;
- }
- if (children) {
- XFree(children);
- }
- if (parent == NULL || parent == root) {
- return;
- }
- win = parent;
- /*
- * Add StructureNotifyMask through hierarchy upto toplevel
- */
- XGetWindowAttributes(awt_display, win, &win_attributes);
- XSelectInput(awt_display, win, win_attributes.your_event_mask |
- StructureNotifyMask);
-
- if (XGetWindowProperty(awt_display, win, WM_STATE,
- 0, 0, False, AnyPropertyType,
- &type, &format, &nitems, &after, &data) == Success) {
- XFree(data);
- if (type) {
- break;
- }
- }
- }
- ef = (EmbeddedFrame *) malloc(sizeof(EmbeddedFrame));
- if (ef == NULL) {
- JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2),
- "OutOfMemory in awt_util_addEmbeddedFrame");
- return;
- }
- ef->embeddedFrame = embeddedFrame;
- ef->frameContainer = win;
- ef->javaRef = javaRef;
- ef->eventSelectedPreviously = False;
- /* initialize the xt coordinates */
- awt_util_updateXtCoordinatesForEmbeddedFrame(embeddedFrame);
-
- /*
- * go through the exisiting embedded frames see if we have
- * already selected the event on the same frameContainer
- */
- eflist = theEmbeddedFrameList;
- while (eflist != NULL) {
- if (eflist->frameContainer == win) {
- break;
- }
- eflist = eflist->next;
- }
- if (eflist != NULL) {
- /*
- * we already have a embedded frame selecting this container's
- * event, we remember its eventSelectedPreviously value
- * so that we know whether to deselect later when we are removed
- */
- ef->eventSelectedPreviously = eflist->eventSelectedPreviously;
- } else {
- XGetWindowAttributes(awt_display, ef->frameContainer,
- &win_attributes);
- XSelectInput(awt_display, ef->frameContainer,
- win_attributes.your_event_mask | FocusChangeMask);
- }
-
- /* ef will become the head of the embedded frame list */
- ef->next = theEmbeddedFrameList;
- if (theEmbeddedFrameList != NULL) {
- theEmbeddedFrameList->prev = ef;
- }
- ef->prev = NULL;
- theEmbeddedFrameList = ef;
-}
-
-void awt_util_delEmbeddedFrame(Widget embeddedFrame)
-{
- EmbeddedFrame *ef = theEmbeddedFrameList;
- Window frameContainer;
- XWindowAttributes win_attributes;
- Boolean needToDeselect;
-
- while (ef != NULL) {
- if (ef->embeddedFrame == embeddedFrame) {
- break;
- }
- ef = ef->next;
- }
- if (ef == NULL) { /* cannot find specified embedded frame */
- return;
- }
- /* remove ef from link list EmbeddedFrameList */
- if (ef->prev) {
- ef->prev->next = ef->next;
- }
- if (ef->next) {
- ef->next->prev = ef->prev;
- }
- if (theEmbeddedFrameList == ef) {
- theEmbeddedFrameList = ef->next;
- }
-
- frameContainer = ef->frameContainer;
- needToDeselect = ef->eventSelectedPreviously ? False : True;
- free(ef);
- if (!needToDeselect) {
- return;
- }
- /*
- * now decide whether we need to stop listenning event for
- * frameContainer
- */
- ef = theEmbeddedFrameList;
- while (ef != NULL) {
- if (ef->frameContainer == frameContainer) {
- break;
- }
- ef = ef->next;
- }
- if (ef == NULL) {
- /*
- * if we get here, no one is interested in this frame
- * and StructureNotify was not selected by anyone else
- * so we deselect it
- */
- DTRACE_PRINTLN("remove event from frame");
- XGetWindowAttributes(awt_display, frameContainer, &win_attributes);
- XSelectInput(awt_display, frameContainer,
- win_attributes.your_event_mask &
- (~FocusChangeMask));
- }
-}
-
-#endif /* XAWT */
-
-void awt_util_debug_init() {
-#if defined(DEBUG)
- DTrace_Initialize();
-#endif
-}
-
-static void awt_util_debug_fini() {
-#if defined(DEBUG)
- DTrace_Shutdown();
-#endif
-}
--- a/jdk/src/solaris/native/sun/awt/awt_util.h Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_util.h Thu Dec 15 19:52:13 2011 -0800
@@ -27,58 +27,8 @@
#define _AWT_UTIL_H_
#ifndef HEADLESS
-#ifndef XAWT
-#include <Xm/VendorSEP.h>
-#include <Xm/VendorSP.h>
-#endif
#include "gdefs.h"
-typedef struct ConvertEventTimeAndModifiers {
- jlong when;
- jint modifiers;
-} ConvertEventTimeAndModifiers;
-
-Boolean awt_util_focusIsOnMenu(Display *display);
-int32_t awt_util_sendButtonClick(Display *display, Window window);
-
-Widget awt_util_createWarningWindow(Widget parent, char *warning);
-void awt_util_show(Widget w);
-void awt_util_hide(Widget w);
-void awt_util_enable(Widget w);
-void awt_util_disable(Widget w);
-void awt_util_reshape(Widget w, jint x, jint y, jint wd, jint ht);
-void awt_util_mapChildren(Widget w, void (*func)(Widget,void *),
- int32_t applyToSelf, void *data);
-int32_t awt_util_setCursor(Widget w, Cursor c);
-void awt_util_convertEventTimeAndModifiers
- (XEvent *event, ConvertEventTimeAndModifiers *output);
-Widget awt_WidgetAtXY(Widget root, Position x, Position y);
-char *awt_util_makeWMMenuItem(char *target, Atom protocol);
-Cardinal awt_util_insertCallback(Widget w);
-void awt_util_consumeAllXEvents(Widget widget);
-void awt_util_cleanupBeforeDestroyWidget(Widget widget);
-void awt_util_debug_init();
-Time awt_util_getCurrentServerTime();
-jlong awt_util_nowMillisUTC();
-jlong awt_util_nowMillisUTC_offset(Time server_offset);
-void awt_util_do_wheel_scroll(Widget scrolled_window, jint scrollType,
- jint scrollAmt, jint wheelAmt);
-Widget awt_util_get_scrollbar_to_scroll(Widget window);
-
-
-typedef struct _EmbeddedFrame {
- Widget embeddedFrame;
- Window frameContainer;
- jobject javaRef;
- Boolean eventSelectedPreviously;
- struct _EmbeddedFrame * next;
- struct _EmbeddedFrame * prev;
-} EmbeddedFrame;
-
-void awt_util_addEmbeddedFrame(Widget embeddedFrame, jobject javaRef);
-void awt_util_delEmbeddedFrame(Widget embeddedFrame);
-Boolean awt_util_processEventForEmbeddedFrame(XEvent *ev);
-
#define WITH_XERROR_HANDLER(f) do { \
XSync(awt_display, False); \
xerror_code = Success; \
@@ -115,8 +65,6 @@
*/
extern unsigned char xerror_code;
-extern int xerror_ignore_bad_window(Display *dpy, XErrorEvent *err);
-
#endif /* !HEADLESS */
#ifndef INTERSECTS
@@ -143,13 +91,8 @@
int32_t echoC;
};
-extern jobject awtJNI_GetCurrentThread(JNIEnv *env);
extern void awtJNI_ThreadYield(JNIEnv *env);
-#ifndef HEADLESS
-extern Widget prevWidget;
-#endif /* !HEADLESS */
-
/*
* Functions for accessing fields by name and signature
*/
@@ -183,69 +126,4 @@
JNIEXPORT jint JNICALL
JNU_GetCharField(JNIEnv *env, jobject self, const char *name);
-#ifndef HEADLESS
-#ifdef __solaris__
-extern Widget awt_util_getXICStatusAreaWindow(Widget w);
-#else
-int32_t awt_util_getIMStatusHeight(Widget vw);
-XVaNestedList awt_util_getXICStatusAreaList(Widget w);
-Widget awt_util_getXICStatusAreaWindow(Widget w);
-#endif
-
-
-
-
-#ifdef __linux__
-typedef struct _XmImRefRec {
- Cardinal num_refs; /* Number of referencing widgets. */
- Cardinal max_refs; /* Maximum length of refs array. */
- Widget* refs; /* Array of referencing widgets. */
- XtPointer **callbacks;
-} XmImRefRec, *XmImRefInfo;
-
-typedef struct _PreeditBufferRec {
- unsigned short length;
- wchar_t *text;
- XIMFeedback *feedback;
- int32_t caret;
- XIMCaretStyle style;
-} PreeditBufferRec, *PreeditBuffer;
-
-typedef struct _XmImXICRec {
- struct _XmImXICRec *next; /* Links all have the same XIM. */
- XIC xic; /* The XIC. */
- Window focus_window; /* Cached information about the XIC. */
- XIMStyle input_style; /* ...ditto... */
- int32_t status_width; /* ...ditto... */
- int32_t preedit_width; /* ...ditto... */
- int32_t sp_height; /* ...ditto... */
- Boolean has_focus; /* Does this XIC have keyboard focus. */
- Boolean anonymous; /* Do we have exclusive rights to this XIC. */
- XmImRefRec widget_refs; /* Widgets referencing this XIC. */
- struct _XmImXICRec **source; /* Original source of shared XICs. */
- PreeditBuffer preedit_buffer;
-} XmImXICRec, *XmImXICInfo;
-
-typedef struct _XmImShellRec {
- /* per-Shell fields. */
- Widget im_widget; /* Dummy widget to make intrinsics behave. */
- Widget current_widget; /* Widget whose visual we're matching. */
-
- /* per <Shell,XIM> fields. */
- XmImXICInfo shell_xic; /* For PER_SHELL sharing policy. */
- XmImXICInfo iclist; /* All known XICs for this <XIM,Shell>. */
-} XmImShellRec, *XmImShellInfo;
-
-typedef struct {
- /* per-Display fields. */
- XContext current_xics; /* Map widget -> current XmImXICInfo. */
-
- /* per-XIM fields. */
- XIM xim; /* The XIM. */
- XIMStyles *styles; /* XNQueryInputStyle result. */
- XmImRefRec shell_refs; /* Shells referencing this XIM. */
-} XmImDisplayRec, *XmImDisplayInfo;
-
-#endif
-#endif /* !HEADLESS */
#endif /* _AWT_UTIL_H_ */
--- a/jdk/src/solaris/native/sun/awt/awt_wm.c Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2869 +0,0 @@
-/*
- * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifdef HEADLESS
- #error This file should not be included in headless library
-#endif
-
-/*
- * Some SCIENCE stuff happens, and it is CONFUSING
- */
-
-#include "awt_p.h"
-
-#include <X11/Xproto.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <Xm/MwmUtil.h>
-
-/* JNI headers */
-#include "java_awt_Frame.h" /* for frame state constants */
-
-#include "awt_wm.h"
-#include "awt_util.h" /* for X11 error handling macros */
-
-/*
- * NB: 64 bit awareness.
- *
- * Since this code reads/writes window properties heavily, one thing
- * should be noted well. Xlib uses C type 'long' for properties of
- * format 32. Fortunately, typedef for Atom is 'long' as well, so
- * passing property data as or casting returned property data to
- * arrays of atoms is safe.
- */
-
-
-/*
- * Atoms used to communicate with window manager(s).
- * Naming convention:
- * o for atom "FOO" the variable is "XA_FOO"
- * o for atom "_BAR" the variable is "_XA_BAR"
- * Don't forget to add initialization to awt_wm_initAtoms below.
- */
-
-/*
- * Before WM rototill JDK used to check for running WM by just testing
- * if certain atom is interned or not. We'd better not confuse older
- * JDK by interning these atoms. Use awt_wm_atomInterned() to intern
- * them lazily.
- *
- * ENLIGHTENMENT_COMMS
- * _ICEWM_WINOPTHINT
- * _SAWMILL_TIMESTAMP
- * _DT_SM_WINDOW_INFO
- * _MOTIF_WM_INFO
- * _SUN_WM_PROTOCOLS
- */
-
-/* Good old ICCCM */
-static Atom XA_WM_STATE;
-
-/* New "netwm" spec from www.freedesktop.org */
-static Atom XA_UTF8_STRING; /* like STRING but encoding is UTF-8 */
-static Atom _XA_NET_SUPPORTING_WM_CHECK;
-static Atom _XA_NET_SUPPORTED; /* list of protocols (property of root) */
-static Atom _XA_NET_WM_NAME; /* window property */
-static Atom _XA_NET_WM_STATE; /* both window property and request */
-
-/*
- * _NET_WM_STATE is a list of atoms.
- * NB: Standard spelling is "HORZ" (yes, without an 'I'), but KDE2
- * uses misspelled "HORIZ" (see KDE bug #20229). This was fixed in
- * KDE 2.2. Under earlier versions of KDE2 horizontal and full
- * maximization doesn't work .
- */
-static Atom _XA_NET_WM_STATE_MAXIMIZED_HORZ;
-static Atom _XA_NET_WM_STATE_MAXIMIZED_VERT;
-static Atom _XA_NET_WM_STATE_SHADED;
-static Atom _XA_NET_WM_STATE_ABOVE;
-static Atom _XA_NET_WM_STATE_BELOW;
-static Atom _XA_NET_WM_STATE_HIDDEN;
-
-/* Currently we only care about max_v and max_h in _NET_WM_STATE */
-#define AWT_NET_N_KNOWN_STATES 2
-
-/* Gnome WM spec (superseded by "netwm" above, but still in use) */
-static Atom _XA_WIN_SUPPORTING_WM_CHECK;
-static Atom _XA_WIN_PROTOCOLS;
-static Atom _XA_WIN_STATE;
-static Atom _XA_WIN_LAYER;
-
-/* Enlightenment */
-static Atom _XA_E_FRAME_SIZE;
-
-/* KWin (KDE2) */
-static Atom _XA_KDE_NET_WM_FRAME_STRUT;
-
-/* KWM (KDE 1.x) OBSOLETE??? */
-static Atom XA_KWM_WIN_ICONIFIED;
-static Atom XA_KWM_WIN_MAXIMIZED;
-
-/* OpenLook */
-static Atom _XA_OL_DECOR_DEL;
-static Atom _XA_OL_DECOR_HEADER;
-static Atom _XA_OL_DECOR_RESIZE;
-static Atom _XA_OL_DECOR_PIN;
-static Atom _XA_OL_DECOR_CLOSE;
-
-/* For _NET_WM_STATE ClientMessage requests */
-#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
-#define _NET_WM_STATE_ADD 1 /* add/set property */
-#define _NET_WM_STATE_TOGGLE 2 /* toggle property */
-
-/* _WIN_STATE bits */
-#define WIN_STATE_STICKY (1<<0) /* everyone knows sticky */
-#define WIN_STATE_MINIMIZED (1<<1) /* Reserved - definition is unclear */
-#define WIN_STATE_MAXIMIZED_VERT (1<<2) /* window in maximized V state */
-#define WIN_STATE_MAXIMIZED_HORIZ (1<<3) /* window in maximized H state */
-#define WIN_STATE_HIDDEN (1<<4) /* not on taskbar but window visible*/
-#define WIN_STATE_SHADED (1<<5) /* shaded (MacOS / Afterstep style) */
-#define WIN_LAYER_ONTOP 6
-#define WIN_LAYER_NORMAL 4
-
-#define URGENCY_HINT (1<<8)
-#define LAYER_ALWAYS_ON_TOP 1
-#define LAYER_NORMAL 0
-
-
-/*
- * Intern a bunch of atoms we are going use.
- */
-static void
-awt_wm_initAtoms(void)
-{
- /* Minimize X traffic by creating atoms en mass... This requires
- slightly more code but reduces number of server requests. */
- struct atominit {
- Atom *atomptr;
- const char *name;
- };
-
- /* Just add new atoms to this list */
- static struct atominit atom_list[] = {
- { &XA_WM_STATE, "WM_STATE" },
-
- { &XA_UTF8_STRING, "UTF8_STRING" },
-
- { &_XA_NET_SUPPORTING_WM_CHECK, "_NET_SUPPORTING_WM_CHECK" },
- { &_XA_NET_SUPPORTED, "_NET_SUPPORTED" },
- { &_XA_NET_WM_STATE, "_NET_WM_STATE" },
- { &_XA_NET_WM_STATE_MAXIMIZED_VERT, "_NET_WM_STATE_MAXIMIZED_VERT" },
- { &_XA_NET_WM_STATE_MAXIMIZED_HORZ, "_NET_WM_STATE_MAXIMIZED_HORZ" },
- { &_XA_NET_WM_STATE_SHADED, "_NET_WM_STATE_SHADED" },
- { &_XA_NET_WM_STATE_ABOVE, "_NET_WM_STATE_ABOVE" },
- { &_XA_NET_WM_STATE_BELOW, "_NET_WM_STATE_BELOW" },
- { &_XA_NET_WM_STATE_HIDDEN, "_NET_WM_STATE_HIDDEN" },
- { &_XA_NET_WM_NAME, "_NET_WM_NAME" },
-
- { &_XA_WIN_SUPPORTING_WM_CHECK, "_WIN_SUPPORTING_WM_CHECK" },
- { &_XA_WIN_PROTOCOLS, "_WIN_PROTOCOLS" },
- { &_XA_WIN_STATE, "_WIN_STATE" },
- { &_XA_WIN_LAYER, "_WIN_LAYER" },
-
- { &_XA_KDE_NET_WM_FRAME_STRUT, "_KDE_NET_WM_FRAME_STRUT" },
-
- { &_XA_E_FRAME_SIZE, "_E_FRAME_SIZE" },
-
- { &XA_KWM_WIN_ICONIFIED, "KWM_WIN_ICONIFIED" },
- { &XA_KWM_WIN_MAXIMIZED, "KWM_WIN_MAXIMIZED" },
-
- { &_XA_OL_DECOR_DEL, "_OL_DECOR_DEL" },
- { &_XA_OL_DECOR_HEADER, "_OL_DECOR_HEADER" },
- { &_XA_OL_DECOR_RESIZE, "_OL_DECOR_RESIZE" },
- { &_XA_OL_DECOR_PIN, "_OL_DECOR_PIN" },
- { &_XA_OL_DECOR_CLOSE, "_OL_DECOR_CLOSE" }
- };
-#define ATOM_LIST_LENGTH (sizeof(atom_list)/sizeof(atom_list[0]))
-
- const char *names[ATOM_LIST_LENGTH];
- Atom atoms[ATOM_LIST_LENGTH];
- Status status;
- size_t i;
-
- /* Fill the array of atom names */
- for (i = 0; i < ATOM_LIST_LENGTH; ++i) {
- names[i] = atom_list[i].name;
- }
-
- DTRACE_PRINT("WM: initializing atoms ... ");
- status = XInternAtoms(awt_display, (char**)names, ATOM_LIST_LENGTH,
- False, atoms);
- if (status == 0) {
- DTRACE_PRINTLN("failed");
- return;
- }
-
- /* Store returned atoms into corresponding global variables */
- DTRACE_PRINTLN("ok");
- for (i = 0; i < ATOM_LIST_LENGTH; ++i) {
- *atom_list[i].atomptr = atoms[i];
- }
-#undef ATOM_LIST_LENGTH
-}
-
-
-/*
- * When checking for various WMs don't intern certain atoms we use to
- * distinguish those WMs. Rather check if the atom is interned first.
- * If it's not, further tests are not necessary anyway.
- * This also saves older JDK a great deal of confusion (4487993).
- */
-static Boolean
-awt_wm_atomInterned(Atom *pa, const char *name)
-{
- DASSERT(pa != NULL);
- if (*pa == None) {
- DASSERT(name != NULL);
- *pa = XInternAtom(awt_display, name, True);
- if (*pa == None) {
- DTRACE_PRINTLN1("\"%s\" is not interned", name);
- return False;
- } else {
- return True;
- }
- } else {
- return True;
- }
-}
-
-
-
-/*****************************************************************************\
- *
- * DTRACE utils for various states ...
- *
-\*****************************************************************************/
-
-
-static void
-awt_wm_dtraceWMState(uint32_t wm_state)
-{
-#ifdef DEBUG
- DTRACE_PRINT("WM_STATE = ");
- switch (wm_state) {
- case WithdrawnState:
- DTRACE_PRINTLN("Withdrawn");
- break;
- case NormalState:
- DTRACE_PRINTLN("Normal");
- break;
- case IconicState:
- DTRACE_PRINTLN("Iconic");
- break;
- default:
- DTRACE_PRINTLN1("unknown state %d", wm_state);
- break;
- }
-#endif /* DEBUG */
-}
-
-static void
-awt_wm_dtraceStateNet(Atom *net_wm_state, unsigned long nitems)
-{
-#ifdef DEBUG
- unsigned long i;
-
- DTRACE_PRINT("_NET_WM_STATE = {");
- for (i = 0; i < nitems; ++i) {
- char *name, *print_name;
- name = XGetAtomName(awt_display, net_wm_state[i]);
- if (name == NULL) {
- print_name = "???";
- } else if (strncmp(name, "_NET_WM_STATE", 13) == 0) {
- print_name = name + 13; /* skip common prefix to reduce noice */
- } else {
- print_name = name;
- }
- DTRACE_PRINT1(" %s", print_name);
- if (name) {
- XFree(name);
- }
- }
- DTRACE_PRINTLN(" }");
-#endif
-}
-
-
-static void
-awt_wm_dtraceStateWin(uint32_t win_state)
-{
-#ifdef DEBUG
- DTRACE_PRINT("_WIN_STATE = {");
- if (win_state & WIN_STATE_STICKY) {
- DTRACE_PRINT(" STICKY");
- }
- if (win_state & WIN_STATE_MINIMIZED) {
- DTRACE_PRINT(" MINIMIZED");
- }
- if (win_state & WIN_STATE_MAXIMIZED_VERT) {
- DTRACE_PRINT(" MAXIMIZED_VERT");
- }
- if (win_state & WIN_STATE_MAXIMIZED_HORIZ) {
- DTRACE_PRINT(" MAXIMIZED_HORIZ");
- }
- if (win_state & WIN_STATE_HIDDEN) {
- DTRACE_PRINT(" HIDDEN");
- }
- if (win_state & WIN_STATE_SHADED) {
- DTRACE_PRINT(" SHADED");
- }
- DTRACE_PRINTLN(" }");
-#endif
-}
-
-
-static void
-awt_wm_dtraceStateJava(jint java_state)
-{
-#ifdef DEBUG
- DTRACE_PRINT("java state = ");
- if (java_state == java_awt_Frame_NORMAL) {
- DTRACE_PRINTLN("NORMAL");
- }
- else {
- DTRACE_PRINT("{");
- if (java_state & java_awt_Frame_ICONIFIED) {
- DTRACE_PRINT(" ICONIFIED");
- }
- if ((java_state & java_awt_Frame_MAXIMIZED_BOTH)
- == java_awt_Frame_MAXIMIZED_BOTH)
- {
- DTRACE_PRINT(" MAXIMIZED_BOTH");
- }
- else if (java_state & java_awt_Frame_MAXIMIZED_HORIZ) {
- DTRACE_PRINT(" MAXIMIZED_HORIZ");
- }
- else if (java_state & java_awt_Frame_MAXIMIZED_VERT) {
- DTRACE_PRINT(" MAXIMIZED_VERT");
- }
- DTRACE_PRINTLN(" }");
- }
-#endif /* DEBUG */
-}
-
-
-
-/*****************************************************************************\
- *
- * Utility functions ...
- *
-\*****************************************************************************/
-
-/*
- * Instead of validating window id, we simply call XGetWindowProperty,
- * but temporary install this function as the error handler to ignore
- * BadWindow error.
- */
-int /* but ingored */
-xerror_ignore_bad_window(Display *dpy, XErrorEvent *err)
-{
- XERROR_SAVE(err);
- if (err->error_code == BadWindow) {
- DTRACE_PRINTLN("IGNORING BadWindow");
- return 0; /* ok to fail */
- }
- else {
- return (*xerror_saved_handler)(dpy, err);
- }
-}
-
-
-/*
- * Convenience wrapper for XGetWindowProperty for XA_ATOM properties.
- * E.g. WM_PROTOCOLS, _NET_WM_STATE, _OL_DECOR_DEL.
- * It's up to caller to XFree returned value.
- * Number of items returned is stored to nitems_ptr (if non-null).
- */
-static Atom *
-awt_getAtomListProperty(Window w, Atom property, unsigned long *nitems_ptr)
-{
- /* Request status */
- int status;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems_stub;
- unsigned long bytes_after;
- Atom *list;
-
- if (nitems_ptr == NULL) {
- /* Caller is not interested in the number of items,
- provide a stub for XGetWindowProperty */
- nitems_ptr = &nitems_stub;
- }
-
- status = XGetWindowProperty(awt_display, w,
- property, 0, 0xFFFF, False, XA_ATOM,
- &actual_type, &actual_format, nitems_ptr, &bytes_after,
- (unsigned char **)&list);
-
- if (status != Success || list == NULL) {
- *nitems_ptr = 0;
- return NULL;
- }
-
- if (actual_type != XA_ATOM || actual_format != 32) {
- XFree(list);
- *nitems_ptr = 0;
- return NULL;
- }
-
- if (*nitems_ptr == 0) {
- XFree(list);
- return NULL;
- }
-
- return list;
-}
-
-
-/*
- * Auxiliary function that returns the value of 'property' of type
- * 'property_type' on window 'w'. Format of the property must be 8.
- * Terminating zero added by XGetWindowProperty is preserved.
- * It's up to caller to XFree the result.
- */
-static unsigned char *
-awt_getProperty8(Window w, Atom property, Atom property_type)
-{
- /* Request status */
- int status;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- unsigned char *string;
-
- /* BadWindow is ok and will be blocked by our special handler */
- WITH_XERROR_HANDLER(xerror_ignore_bad_window);
- {
- status = XGetWindowProperty(awt_display, w,
- property, 0, 0xFFFF, False, property_type,
- &actual_type, &actual_format, &nitems, &bytes_after,
- &string);
- }
- RESTORE_XERROR_HANDLER;
-
- if (status != Success || string == NULL) {
- return NULL;
- }
-
- if (actual_type != property_type || actual_format != 8) {
- XFree(string);
- return NULL;
- }
-
- /* XGetWindowProperty kindly supplies terminating zero */
- return string;
-}
-
-
-/*
- * Auxiliary function that returns the value of 'property' of type
- * 'property_type' on window 'w'. Format of the property must be 32.
- */
-static int32_t
-awt_getProperty32(Window w, Atom property, Atom property_type)
-{
- /* Property value*/
- int32_t value;
-
- /* Request status */
- int status;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- long *data; /* NB: 64 bit: Format 32 props are 'long' */
-
- /* BadWindow is ok and will be blocked by our special handler */
- WITH_XERROR_HANDLER(xerror_ignore_bad_window);
- {
- status = XGetWindowProperty(awt_display, w,
- property, 0, 1, False, property_type,
- &actual_type, &actual_format, &nitems, &bytes_after,
- (unsigned char **)&data);
- }
- RESTORE_XERROR_HANDLER;
-
- if (status != Success || data == NULL) {
- return 0;
- }
-
- if (actual_type != property_type || actual_format != 32) {
- XFree(data); /* NULL data already catched above */
- return 0;
- }
-
- value = (int32_t)*data;
- XFree(data);
-
- return value;
-}
-
-
-
-/*****************************************************************************\
- *
- * Detecting WM ...
- *
-\*****************************************************************************/
-
-
-
-/*
- * Check for anchor_prop(anchor_type) on root, take the value as the
- * window id and check if that window exists and has anchor_prop(anchor_type)
- * with the same value (i.e. pointing back to self).
- *
- * Returns the anchor window, as some WM may put interesting stuff in
- * its properties (e.g. sawfish).
- */
-static Window
-awt_wm_checkAnchor(Atom anchor_prop, Atom anchor_type)
-{
- Window root_xref;
- Window self_xref;
-
- root_xref = (Window)awt_getProperty32(DefaultRootWindow(awt_display),
- anchor_prop, anchor_type);
- if (root_xref == None) {
- DTRACE_PRINTLN("no");
- return None;
- }
-
- DTRACE_PRINT1("0x%x ... ", (unsigned int)root_xref);
- self_xref = (Window)awt_getProperty32(root_xref,
- anchor_prop, anchor_type);
- if (self_xref != root_xref) {
- DTRACE_PRINTLN("stale");
- return None;
- }
-
- DTRACE_PRINTLN("ok");
- return self_xref;
-}
-
-
-/*
- * New WM spec: KDE 2.0.1, sawfish 0.3x, ...
- * <http://www.freedesktop.org/standards/wm-spec.html>
- */
-static Window
-awt_wm_isNetSupporting(void)
-{
- static Boolean checked = False;
- static Window isNetSupporting = None;
-
- if (checked) {
- return isNetSupporting;
- }
-
- DTRACE_PRINT("WM: checking for _NET_SUPPORTING ... ");
- isNetSupporting = awt_wm_checkAnchor(_XA_NET_SUPPORTING_WM_CHECK,
- XA_WINDOW);
- checked = True;
- return isNetSupporting;
-}
-
-
-/*
- * Old Gnome WM spec: WindowMaker, Enlightenment, IceWM ...
- * <http://developer.gnome.org/doc/standards/wm/book1.html>
- */
-static Window
-awt_wm_isWinSupporting(void)
-{
- static Boolean checked = False;
- static Window isWinSupporting = None;
-
- if (checked) {
- return isWinSupporting;
- }
-
- DTRACE_PRINT("WM: checking for _WIN_SUPPORTING ... ");
- isWinSupporting = awt_wm_checkAnchor(_XA_WIN_SUPPORTING_WM_CHECK,
- XA_CARDINAL);
- checked = True;
- return isWinSupporting;
-}
-
-
-/*
- * Check that that the list of protocols specified by WM in property
- * named LIST_NAME on the root window contains protocol PROTO.
- */
-static Boolean
-awt_wm_checkProtocol(Atom list_name, Atom proto)
-{
- Atom *protocols;
- unsigned long nproto;
- Boolean found;
- unsigned long i;
-
- protocols = awt_getAtomListProperty(DefaultRootWindow(awt_display),
- list_name, &nproto);
- if (protocols == NULL) {
- return False;
- }
-
- found = False;
- for (i = 0; i < nproto; ++i) {
- if (protocols[i] == proto) {
- found = True;
- break;
- }
- }
-
- if (protocols != NULL) {
- XFree(protocols);
- }
- return found;
-}
-
-static Boolean
-awt_wm_doStateProtocolNet(void)
-{
- static Boolean checked = False;
- static Boolean supported = False;
-
- if (checked) {
- return supported;
- }
-
- if (awt_wm_isNetSupporting()) {
- DTRACE_PRINT("WM: checking for _NET_WM_STATE in _NET_SUPPORTED ... ");
- supported = awt_wm_checkProtocol(_XA_NET_SUPPORTED, _XA_NET_WM_STATE);
- DTRACE_PRINTLN1("%s", supported ? "yes" : "no");
- }
-
- checked = True;
- return supported;
-}
-
-static Boolean
-awt_wm_doStateProtocolWin(void)
-{
- static Boolean checked = False;
- static Boolean supported = False;
-
- if (checked) {
- return supported;
- }
-
- if (awt_wm_isWinSupporting()) {
- DTRACE_PRINT("WM: checking for _WIN_STATE in _WIN_PROTOCOLS ... ");
- supported = awt_wm_checkProtocol(_XA_WIN_PROTOCOLS, _XA_WIN_STATE);
- DTRACE_PRINTLN1("%s", supported ? "yes" : "no");
- }
- checked = True;
- return supported;
-}
-
-
-
-/*
- * Helper function for awt_wm_isEnlightenment.
- * Enlightenment uses STRING property for its comms window id. Gaaa!
- * The property is ENLIGHTENMENT_COMMS, STRING/8 and the string format
- * is "WINID %8x". Gee, I haven't been using scanf for *ages*... :-)
- */
-static Window
-awt_getECommsWindowIDProperty(Window w)
-{
- static Atom XA_ENLIGHTENMENT_COMMS = None;
-
- /* Property value*/
- Window value;
-
- /* Request status */
- int status;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- unsigned char *data;
-
- if (!awt_wm_atomInterned(&XA_ENLIGHTENMENT_COMMS, "ENLIGHTENMENT_COMMS")) {
- return False;
- }
-
- /* BadWindow is ok and will be blocked by our special handler */
- WITH_XERROR_HANDLER(xerror_ignore_bad_window);
- {
- status = XGetWindowProperty(awt_display, w,
- XA_ENLIGHTENMENT_COMMS, 0, 14, False, XA_STRING,
- &actual_type, &actual_format, &nitems, &bytes_after,
- &data);
- }
- RESTORE_XERROR_HANDLER;
-
- if (status != Success || data == NULL) {
- DTRACE_PRINTLN("no ENLIGHTENMENT_COMMS");
- return None;
- }
-
- if (actual_type != XA_STRING || actual_format != 8
- || nitems != 14 || bytes_after != 0)
- {
- DTRACE_PRINTLN("malformed ENLIGHTENMENT_COMMS");
- XFree(data); /* NULL data already catched above */
- return None;
- }
-
- value = None;
- sscanf((char *)data, "WINID %8lx", &value); /* NB: 64 bit: XID is long */
- XFree(data);
-
- return value;
-}
-
-
-/*
- * Is Enlightenment WM running? Congruent to awt_wm_checkAnchor, but
- * uses STRING property peculiar to Enlightenment.
- */
-static Boolean
-awt_wm_isEnlightenment(void)
-{
- Window root_xref;
- Window self_xref;
-
- DTRACE_PRINT("WM: checking for Enlightenment ... ");
- root_xref = awt_getECommsWindowIDProperty(DefaultRootWindow(awt_display));
- if (root_xref == None) {
- return False;
- }
-
- DTRACE_PRINT1("0x%x ... ", root_xref);
- self_xref = awt_getECommsWindowIDProperty(root_xref);
- if (self_xref != root_xref) {
- return False;
- }
-
- DTRACE_PRINTLN("ok");
- return True;
-}
-
-
-/*
- * Is CDE running?
- *
- * XXX: This is hairy... CDE is MWM as well. It seems we simply test
- * for default setup and will be bitten if user changes things...
- *
- * Check for _DT_SM_WINDOW_INFO(_DT_SM_WINDOW_INFO) on root. Take the
- * second element of the property and check for presence of
- * _DT_SM_STATE_INFO(_DT_SM_STATE_INFO) on that window.
- *
- * XXX: Any header that defines this structures???
- */
-static Boolean
-awt_wm_isCDE(void)
-{
- static Atom _XA_DT_SM_WINDOW_INFO = None;
- static Atom _XA_DT_SM_STATE_INFO = None;
-
- /* Property value*/
- Window wmwin;
-
- /* Request status */
- int status;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- long *data; /* NB: 64 bit: Format 32 props are 'long' */
-
- DTRACE_PRINT("WM: checking for CDE ... ");
-
- if (!awt_wm_atomInterned(&_XA_DT_SM_WINDOW_INFO, "_DT_SM_WINDOW_INFO")) {
- return False;
- }
-
- status = XGetWindowProperty(awt_display, DefaultRootWindow(awt_display),
- _XA_DT_SM_WINDOW_INFO, 0, 2, False, _XA_DT_SM_WINDOW_INFO,
- &actual_type, &actual_format, &nitems, &bytes_after,
- (unsigned char **)&data);
-
- if (status != Success || data == NULL) {
- DTRACE_PRINTLN("no _DT_SM_WINDOW_INFO on root");
- return False;
- }
-
- if (actual_type != _XA_DT_SM_WINDOW_INFO || actual_format != 32
- || nitems != 2 || bytes_after != 0)
- {
- DTRACE_PRINTLN("malformed _DT_SM_WINDOW_INFO on root");
- XFree(data); /* NULL data already catched above */
- return False;
- }
-
- wmwin = (Window)data[1];
- XFree(data);
-
- /* Now check that this window has _DT_SM_STATE_INFO (ignore contents) */
-
- if (!awt_wm_atomInterned(&_XA_DT_SM_STATE_INFO, "_DT_SM_STATE_INFO")) {
- return False;
- }
-
- /* BadWindow is ok and will be blocked by our special handler */
- WITH_XERROR_HANDLER(xerror_ignore_bad_window);
- {
- status = XGetWindowProperty(awt_display, wmwin,
- _XA_DT_SM_STATE_INFO, 0, 1, False, _XA_DT_SM_STATE_INFO,
- &actual_type, &actual_format, &nitems, &bytes_after,
- (unsigned char **)&data);
- }
- RESTORE_XERROR_HANDLER;
-
- if (status != Success || data == NULL) {
- DTRACE_PRINTLN("no _DT_SM_STATE_INFO");
- return False;
- }
-
- if (actual_type != _XA_DT_SM_STATE_INFO || actual_format != 32) {
- DTRACE_PRINTLN("malformed _DT_SM_STATE_INFO");
- XFree(data); /* NULL data already catched above */
- return False;
- }
-
- DTRACE_PRINTLN("yes");
- XFree(data);
- return True;
-}
-
-/*
- * Is MWM running? (Note that CDE will test positive as well).
- *
- * Check for _MOTIF_WM_INFO(_MOTIF_WM_INFO) on root. Take the
- * second element of the property and check for presence of
- * _DT_SM_STATE_INFO(_DT_SM_STATE_INFO) on that window.
- */
-static Boolean
-awt_wm_isMotif(void)
-{
- /*
- * Grr. Motif just had to be different, ain't it!? Everyone use
- * "XA" for things of type Atom, but motif folks chose to define
- * _XA_MOTIF_* to be atom *names*. How pathetic...
- */
-#undef _XA_MOTIF_WM_INFO
- static Atom _XA_MOTIF_WM_INFO = None;
- static Atom _XA_DT_WORKSPACE_CURRENT = None;
-
- /* Property value */
- Window wmwin;
- Atom *curws;
-
- /* Request status */
- int status;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- long *data; /* NB: 64 bit: Format 32 props are 'long' */
-
- DTRACE_PRINT("WM: checking for MWM ... ");
-
- if (!awt_wm_atomInterned(&_XA_MOTIF_WM_INFO, "_MOTIF_WM_INFO")
- || !awt_wm_atomInterned(&_XA_DT_WORKSPACE_CURRENT, "_DT_WORKSPACE_CURRENT"))
- {
- return False;
- }
-
-
- status = XGetWindowProperty(awt_display, DefaultRootWindow(awt_display),
- _XA_MOTIF_WM_INFO, 0, PROP_MOTIF_WM_INFO_ELEMENTS, False,
- _XA_MOTIF_WM_INFO, &actual_type,
- &actual_format, &nitems, &bytes_after,
- (unsigned char **)&data);
-
- if (status != Success || data == NULL) {
- DTRACE_PRINTLN("no _MOTIF_WM_INFO on root");
- return False;
- }
-
- if (actual_type != _XA_MOTIF_WM_INFO || actual_format != 32
- || nitems != PROP_MOTIF_WM_INFO_ELEMENTS || bytes_after != 0)
- {
- DTRACE_PRINTLN("malformed _MOTIF_WM_INFO on root");
- XFree(data); /* NULL data already catched above */
- return False;
- }
-
- /* NB: 64 bit: Cannot cast data to MotifWmInfo */
- wmwin = (Window)data[1];
- XFree(data);
-
- /* Now check that this window has _DT_WORKSPACE_CURRENT */
- curws = awt_getAtomListProperty(wmwin, _XA_DT_WORKSPACE_CURRENT, NULL);
- if (curws == NULL) {
- DTRACE_PRINTLN("no _DT_WORKSPACE_CURRENT");
- return False;
- }
-
- DTRACE_PRINTLN("yes");
- XFree(curws);
- return True;
-}
-
-
-static Boolean
-awt_wm_isNetWMName(char *name)
-{
- Window anchor;
- unsigned char *net_wm_name;
- Boolean matched;
-
- anchor = awt_wm_isNetSupporting();
- if (anchor == None) {
- return False;
- }
-
- DTRACE_PRINT1("WM: checking for %s by _NET_WM_NAME ... ", name);
-
- /*
- * Check both UTF8_STRING and STRING. We only call this function
- * with ASCII names and UTF8 preserves ASCII bit-wise. wm-spec
- * mandates UTF8_STRING for _NET_WM_NAME but at least sawfish-1.0
- * still uses STRING. (mmm, moving targets...).
- */
- net_wm_name = awt_getProperty8(anchor, _XA_NET_WM_NAME, XA_UTF8_STRING);
- if (net_wm_name == NULL) {
- net_wm_name = awt_getProperty8(anchor, _XA_NET_WM_NAME, XA_STRING);
- }
-
- if (net_wm_name == NULL) {
- DTRACE_PRINTLN("no (missing _NET_WM_NAME)");
- return False;
- }
-
- matched = (strcmp((char *)net_wm_name, name) == 0);
- if (matched) {
- DTRACE_PRINTLN("yes");
- } else {
- DTRACE_PRINTLN1("no (_NET_WM_NAME = \"%s\")", net_wm_name);
- }
- XFree(net_wm_name);
- return matched;
-}
-
-/*
- * Is Sawfish running?
- */
-static Boolean
-awt_wm_isSawfish(void)
-{
- return awt_wm_isNetWMName("Sawfish");
-}
-
-/*
- * Is KDE2 (KWin) running?
- */
-static Boolean
-awt_wm_isKDE2(void)
-{
- return awt_wm_isNetWMName("KWin");
-}
-
-
-/*
- * Is Metacity running?
- */
-static Boolean
-awt_wm_isMetacity(void)
-{
- return awt_wm_isNetWMName("Metacity");
-}
-
-
-/*
- * Temporary error handler that ensures that we know if
- * XChangeProperty succeeded or not.
- */
-static int /* but ignored */
-xerror_verify_change_property(Display *dpy, XErrorEvent *err)
-{
- XERROR_SAVE(err);
- if (err->request_code == X_ChangeProperty) {
- return 0;
- }
- else {
- return (*xerror_saved_handler)(dpy, err);
- }
-}
-
-
-/*
- * Prepare IceWM check.
- *
- * The only way to detect IceWM, seems to be by setting
- * _ICEWM_WINOPTHINT(_ICEWM_WINOPTHINT/8) on root and checking if it
- * was immediately deleted by IceWM.
- *
- * But messing with PropertyNotify here is way too much trouble, so
- * approximate the check by setting the property in this function and
- * checking if it still exists later on.
- *
- * Gaa, dirty dances...
- */
-static Boolean
-awt_wm_prepareIsIceWM(void)
-{
- static Atom _XA_ICEWM_WINOPTHINT = None;
-
- /*
- * Choose something innocuous: "AWT_ICEWM_TEST allWorkspaces 0".
- * IceWM expects "class\0option\0arg\0" with zero bytes as delimiters.
- */
- static unsigned char opt[] = {
- 'A','W','T','_','I','C','E','W','M','_','T','E','S','T','\0',
- 'a','l','l','W','o','r','k','s','p','a','c','e','s','\0',
- '0','\0'
- };
-
- DTRACE_PRINT("WM: scheduling check for IceWM ... ");
-
- if (!awt_wm_atomInterned(&_XA_ICEWM_WINOPTHINT, "_ICEWM_WINOPTHINT")) {
- return False;
- }
-
- WITH_XERROR_HANDLER(xerror_verify_change_property);
- {
- XChangeProperty(awt_display, DefaultRootWindow(awt_display),
- _XA_ICEWM_WINOPTHINT, _XA_ICEWM_WINOPTHINT, 8,
- PropModeReplace, opt, sizeof(opt));
- }
- RESTORE_XERROR_HANDLER;
-
- if (xerror_code != Success) {
- DTRACE_PRINTLN1("can't set _ICEWM_WINOPTHINT, error = %d",
- xerror_code);
- return False;
- }
- else {
- DTRACE_PRINTLN("scheduled");
- return True;
- }
-}
-
-/*
- * Is IceWM running?
- *
- * Note well: Only call this if awt_wm_prepareIsIceWM succeeded, or a
- * false positive will be reported.
- */
-static Boolean
-awt_wm_isIceWM(void)
-{
- static Atom _XA_ICEWM_WINOPTHINT = None;
-
- /* Request status */
- int status;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- unsigned char *data;
-
- DTRACE_PRINT("WM: checking for IceWM ... ");
-
- if (!awt_wm_atomInterned(&_XA_ICEWM_WINOPTHINT, "_ICEWM_WINOPTHINT")) {
- return False;
- }
-
- XGetWindowProperty(awt_display, DefaultRootWindow(awt_display),
- _XA_ICEWM_WINOPTHINT, 0, 0xFFFF, True, /* NB: deleting! */
- _XA_ICEWM_WINOPTHINT, &actual_type,
- &actual_format, &nitems, &bytes_after,
- &data);
-
- if (data != NULL) {
- XFree(data);
- }
-
- if (actual_type == None) {
- DTRACE_PRINTLN("yes");
- return True;
- }
- else {
- DTRACE_PRINTLN("no");
- return False;
- }
-}
-
-/*
- * Is OpenLook WM running?
- *
- * This one is pretty lame, but the only property peculiar to OLWM is
- * _SUN_WM_PROTOCOLS(ATOM[]). Fortunately, olwm deletes it on exit.
- */
-static Boolean
-awt_wm_isOpenLook(void)
-{
- static Atom _XA_SUN_WM_PROTOCOLS = None;
- Atom *list;
-
- DTRACE_PRINT("WM: checking for OpenLook WM ... ");
-
- if (!awt_wm_atomInterned(&_XA_SUN_WM_PROTOCOLS, "_SUN_WM_PROTOCOLS")) {
- return False;
- }
-
- list = awt_getAtomListProperty(DefaultRootWindow(awt_display),
- _XA_SUN_WM_PROTOCOLS, NULL);
- if (list == NULL) {
- DTRACE_PRINTLN("no _SUN_WM_PROTOCOLS on root");
- return False;
- }
-
- DTRACE_PRINTLN("yes");
- XFree(list);
- return True;
-}
-
-
-
-static Boolean winmgr_running = False;
-
-/*
- * Temporary error handler that checks if selecting for
- * SubstructureRedirect failed.
- */
-static int /* but ignored */
-xerror_detect_wm(Display *dpy, XErrorEvent *err)
-{
- XERROR_SAVE(err);
- if (err->request_code == X_ChangeWindowAttributes
- && err->error_code == BadAccess)
- {
- DTRACE_PRINTLN("some WM is running (hmm, we'll see)");
- winmgr_running = True;
- return 0;
- }
- else {
- return (*xerror_saved_handler)(dpy, err);
- }
-}
-
-
-/*
- * Make an educated guess about running window manager.
- * XXX: ideally, we should detect wm restart.
- */
-enum wmgr_t
-awt_wm_getRunningWM(void)
-{
- /*
- * Ideally, we should support cases when a different WM is started
- * during a Java app lifetime.
- */
- static enum wmgr_t awt_wmgr = UNDETERMINED_WM;
-
- XSetWindowAttributes substruct;
- const char *vendor_string;
- Boolean doIsIceWM;
-
- if (awt_wmgr != UNDETERMINED_WM) {
- return awt_wmgr;
- }
-
- /*
- * Quick checks for specific servers.
- */
- vendor_string = ServerVendor(awt_display);
- if (strstr(vendor_string, "eXcursion") != NULL) {
- /*
- * Use NO_WM since in all other aspects eXcursion is like not
- * having a window manager running. I.e. it does not reparent
- * top level shells.
- */
- DTRACE_PRINTLN("WM: eXcursion detected - treating as NO_WM");
- awt_wmgr = NO_WM;
- return awt_wmgr;
- }
-
- /*
- * If *any* window manager is running?
- *
- * Try selecting for SubstructureRedirect, that only one client
- * can select for, and if the request fails, than some other WM is
- * already running.
- */
- winmgr_running = 0;
- substruct.event_mask = SubstructureRedirectMask;
-
- DTRACE_PRINT("WM: trying SubstructureRedirect ... ");
- WITH_XERROR_HANDLER(xerror_detect_wm);
- {
- XChangeWindowAttributes(awt_display, DefaultRootWindow(awt_display),
- CWEventMask, &substruct);
- }
- RESTORE_XERROR_HANDLER;
-
- /*
- * If no WM is running than our selection for SubstructureRedirect
- * succeeded and needs to be undone (hey we are *not* a WM ;-).
- */
- if (!winmgr_running) {
- DTRACE_PRINTLN("no WM is running");
- awt_wmgr = NO_WM;
- substruct.event_mask = 0;
- XChangeWindowAttributes(awt_display, DefaultRootWindow(awt_display),
- CWEventMask, &substruct);
- return NO_WM;
- }
-
- /* actual check for IceWM to follow below */
- doIsIceWM = awt_wm_prepareIsIceWM(); /* and let IceWM to act */
-
- if (awt_wm_isNetSupporting()) {
- awt_wm_doStateProtocolNet();
- }
- if (awt_wm_isWinSupporting()) {
- awt_wm_doStateProtocolWin();
- }
-
- /*
- * Ok, some WM is out there. Check which one by testing for
- * "distinguishing" atoms.
- */
- if (doIsIceWM && awt_wm_isIceWM()) {
- awt_wmgr = ICE_WM;
- }
- else if (awt_wm_isEnlightenment()) {
- awt_wmgr = ENLIGHTEN_WM;
- }
- else if (awt_wm_isMetacity()) {
- awt_wmgr = METACITY_WM;
- }
- else if (awt_wm_isSawfish()) {
- awt_wmgr = SAWFISH_WM;
- }
- else if (awt_wm_isKDE2()) {
- awt_wmgr = KDE2_WM;
- }
- /*
- * We don't check for legacy WM when we already know that WM
- * supports WIN or _NET wm spec.
- */
- else if (awt_wm_isNetSupporting()) {
- DTRACE_PRINTLN("WM: other WM (supports _NET)");
- awt_wmgr = OTHER_WM;
- }
- else if (awt_wm_isWinSupporting()) {
- DTRACE_PRINTLN("WM: other WM (supports _WIN)");
- awt_wmgr = OTHER_WM;
- }
- /*
- * Check for legacy WMs.
- */
- else if (awt_wm_isCDE()) { /* XXX: must come before isMotif */
- awt_wmgr = CDE_WM;
- }
- else if (awt_wm_isMotif()) {
- awt_wmgr = MOTIF_WM;
- }
- else if (awt_wm_isOpenLook()) {
- awt_wmgr = OPENLOOK_WM;
- }
- else {
- DTRACE_PRINTLN("WM: some other legacy WM");
- awt_wmgr = OTHER_WM;
- }
-
- return awt_wmgr;
-}
-
-
-/*
- * Some buggy WMs ignore window gravity when processing
- * ConfigureRequest and position window as if the gravity is Static.
- * We work around this in MWindowPeer.pReshape().
- */
-Boolean
-awt_wm_configureGravityBuggy(void)
-{
- static int env_not_checked = 1;
- static int env_buggy = 0;
-
- if (env_not_checked) {
- DTRACE_PRINT("WM: checking for _JAVA_AWT_WM_STATIC_GRAVITY in environment ... ");
- if (getenv("_JAVA_AWT_WM_STATIC_GRAVITY") != NULL) {
- DTRACE_PRINTLN("set");
- env_buggy = 1;
- } else {
- DTRACE_PRINTLN("no");
- }
- env_not_checked = 0;
- }
-
- if (env_buggy) {
- return True;
- }
-
- switch (awt_wm_getRunningWM()) {
- case ICE_WM:
- /*
- * See bug #228981 at IceWM's SourceForge pages.
- * Latest stable version 1.0.8-6 still has this problem.
- */
- return True;
-
- case ENLIGHTEN_WM:
- /* At least E16 is buggy. */
- return True;
-
- default:
- return False;
- }
-}
-
-/**
- * Check if state is supported.
- * Note that a compound state is always reported as not supported.
- * Note also that MAXIMIZED_BOTH is considered not a compound state.
- * Therefore, a compound state is just ICONIFIED | anything else.
- *
- */
-Boolean
-awt_wm_supportsExtendedState(jint state)
-{
- switch (state) {
- case java_awt_Frame_MAXIMIZED_VERT:
- case java_awt_Frame_MAXIMIZED_HORIZ:
- /*
- * WMs that talk NET/WIN protocol, but do not support
- * unidirectional maximization.
- */
- if (awt_wm_getRunningWM() == METACITY_WM) {
- /* "This is a deliberate policy decision." -hp */
- return JNI_FALSE;
- }
- /* FALLTROUGH */
- case java_awt_Frame_MAXIMIZED_BOTH:
- return (awt_wm_doStateProtocolNet() || awt_wm_doStateProtocolWin());
- default:
- return JNI_FALSE;
- }
-}
-
-
-
-
-/*****************************************************************************\
- *
- * Size and decoration hints ...
- *
-\*****************************************************************************/
-
-
-/*
- * Remove size hints specified by the mask.
- * XXX: Why do we need this in the first place???
- */
-void
-awt_wm_removeSizeHints(Widget shell, long mask)
-{
- Display *dpy = XtDisplay(shell);
- Window shell_win = XtWindow(shell);
- XSizeHints *hints = XAllocSizeHints();
- long ignore = 0;
-
- if (hints == NULL) {
- DTRACE_PRINTLN("WM: removeSizeHints FAILED to allocate XSizeHints");
- return;
- }
-
- /* sanitize the mask, only do these hints */
- mask &= (PMaxSize|PMinSize|USPosition|PPosition);
-
- XGetWMNormalHints(dpy, shell_win, hints, &ignore);
- if ((hints->flags & mask) == 0) {
- XFree(hints);
- return;
- }
-
-#ifdef DEBUG
- DTRACE_PRINT("WM: removing hints");
-
- if (mask & PMaxSize) {
- DTRACE_PRINT(" Max = ");
- if (hints->flags & PMaxSize) {
- DTRACE_PRINT2("%d x %d;", hints->max_width, hints->max_height);
- } else {
- DTRACE_PRINT("none;");
- }
- }
-
- if (mask & PMinSize) {
- DTRACE_PRINT(" Min = ");
- if (hints->flags & PMinSize) {
- DTRACE_PRINT2("%d x %d;", hints->min_width, hints->min_height);
- } else {
- DTRACE_PRINT("none;");
- }
- }
-
- DTRACE_PRINTLN("");
-#endif
-
- hints->flags &= ~mask;
- XSetWMNormalHints(dpy, shell_win, hints);
- XFree(hints);
-}
-
-/*
- *
- *
- */
-static void
-awt_wm_proclaimUrgency(struct FrameData *wdata)
-{
- Display *dpy = XtDisplay(wdata->winData.shell);
- Window shell_win = XtWindow(wdata->winData.shell);
-
- XWMHints *hints = XGetWMHints(dpy, shell_win);
- if( hints == NULL ) {
- /* For now just */ return;
- }
- if ((hints->flags & URGENCY_HINT) != 0) {
- /* it's here already */
- XFree(hints);
- return;
- }
- hints->flags |= URGENCY_HINT;
- XSetWMHints(dpy, shell_win, hints);
- XFree(hints);
-}
-
-/*
- * If MWM_DECOR_ALL bit is set, then the rest of the bit-mask is taken
- * to be subtracted from the decorations. Normalize decoration spec
- * so that we can map motif decor to something else bit-by-bit in the
- * rest of the code.
- */
-static int
-awt_wm_normalizeMotifDecor(int decorations)
-{
- int d;
-
- if (!(decorations & MWM_DECOR_ALL))
- return decorations; /* already normalized */
-
- d = MWM_DECOR_BORDER |MWM_DECOR_RESIZEH | MWM_DECOR_TITLE
- | MWM_DECOR_MENU | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE;
- d &= ~decorations;
- return d;
-}
-
-
-/*
- * Infer OL properties from MWM decorations.
- * Use _OL_DECOR_DEL(ATOM[]) to remove unwanted ones.
- */
-static void
-awt_wm_setOLDecor(struct FrameData *wdata, Boolean resizable, int decorations)
-{
- Window shell_win = XtWindow(wdata->winData.shell);
- Atom decorDel[3];
- int nitems;
-
- if (shell_win == None) {
- DTRACE_PRINTLN("WM: setOLDecor - no window, returning");
- return;
- }
-
- decorations = awt_wm_normalizeMotifDecor(decorations);
- DTRACE_PRINT("WM: _OL_DECOR_DEL = {");
-
- nitems = 0;
- if (!(decorations & MWM_DECOR_TITLE)) {
- DTRACE_PRINT(" _OL_DECOR_HEADER");
- decorDel[nitems++] = _XA_OL_DECOR_HEADER;
- }
- if (!(decorations & (MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE))) {
- DTRACE_PRINT(" _OL_DECOR_RESIZE");
- decorDel[nitems++] = _XA_OL_DECOR_RESIZE;
- }
- if (!(decorations & (MWM_DECOR_MENU | MWM_DECOR_MAXIMIZE
- | MWM_DECOR_MINIMIZE)))
- {
- DTRACE_PRINT(" _OL_DECOR_CLOSE");
- decorDel[nitems++] = _XA_OL_DECOR_CLOSE;
- }
- DTRACE_PRINT(" }");
-
- if (nitems == 0) {
- DTRACE_PRINTLN(" ... removing");
- XDeleteProperty(awt_display, shell_win, _XA_OL_DECOR_DEL);
- }
- else {
- DTRACE_PRINTLN(" ... setting");
- XChangeProperty(awt_display, shell_win,
- _XA_OL_DECOR_DEL, XA_ATOM, 32,
- PropModeReplace, (unsigned char *)decorDel, nitems);
- }
-}
-
-/*
- * Set MWM decorations. Infer MWM functions from decorations.
- */
-static void
-awt_wm_setMotifDecor(struct FrameData *wdata, Boolean resizable, int decorations)
-{
- int functions;
-
- /* Apparently some WMs don't implement MWM_*_ALL semantic correctly */
- if ((decorations & MWM_DECOR_ALL) && (decorations != MWM_DECOR_ALL)) {
- decorations = awt_wm_normalizeMotifDecor(decorations);
- DTRACE_PRINTLN1("WM: setMotifDecor normalize exclusions, decor = 0x%X",
- decorations);
- }
-
- DTRACE_PRINT("WM: setMotifDecor functions = {");
- functions = 0;
-
- if (decorations & MWM_DECOR_ALL) {
- DTRACE_PRINT(" ALL");
- functions |= MWM_FUNC_ALL;
- }
- else {
- /*
- * Functions we always want to be enabled as mwm(1) and
- * descendants not only hide disabled functions away from
- * user, but also ignore corresponding requests from the
- * program itself (e.g. 4442047).
- */
- DTRACE_PRINT(" CLOSE MOVE MINIMIZE");
- functions |= (MWM_FUNC_CLOSE | MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE);
-
- if (resizable) {
- DTRACE_PRINT(" RESIZE MAXIMIZE");
- functions |= MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE;
- }
- }
-
- DTRACE_PRINTLN(" }");
-
- XtVaSetValues(wdata->winData.shell,
- XmNmwmDecorations, decorations,
- XmNmwmFunctions, functions,
- NULL);
-}
-
-
-/*
- * Under some window managers if shell is already mapped, we MUST
- * unmap and later remap in order to effect the changes we make in the
- * window manager decorations.
- *
- * N.B. This unmapping / remapping of the shell exposes a bug in
- * X/Motif or the Motif Window Manager. When you attempt to map a
- * widget which is positioned (partially) off-screen, the window is
- * relocated to be entirely on screen. Good idea. But if both the x
- * and the y coordinates are less than the origin (0,0), the first
- * (re)map will move the window to the origin, and any subsequent
- * (re)map will relocate the window at some other point on the screen.
- * I have written a short Motif test program to discover this bug.
- * This should occur infrequently and it does not cause any real
- * problem. So for now we'll let it be.
- */
-static Boolean
-awt_wm_needRemap()
-{
- switch (awt_wm_getRunningWM()) {
-#if 0 /* XXX */
- case OPENLOOK_WM:
- case MOTIF_WM:
- case CDE_WM:
- case ICE_WM:
- case ENLIGHTEN_WM:
- return True;
-#endif
- default:
- return True;
- }
-}
-
-/*
- * Set decoration hints on the shell to wdata->decor adjusted
- * appropriately if not resizable.
- */
-void
-awt_wm_setShellDecor(struct FrameData *wdata, Boolean resizable)
-{
- int decorations = wdata->decor;
-
- DTRACE_PRINTLN3("WM: setShellDecor(0x%x/0x%x, %s)",
- wdata->winData.shell, XtWindow(wdata->winData.shell),
- resizable ? "resizable" : "not resizable");
-
- if (!resizable) {
- if (decorations & MWM_DECOR_ALL) {
- decorations |= (MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE);
- }
- else {
- decorations &= ~(MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE);
- }
- }
-
- DTRACE_PRINTLN1("WM: decorations = 0x%X", decorations);
- awt_wm_setMotifDecor(wdata, resizable, decorations);
- awt_wm_setOLDecor(wdata, resizable, decorations);
-
- /* Some WMs need remap to redecorate the window */
- if (wdata->isShowing && awt_wm_needRemap()) {
- /*
- * Do the re/mapping at the Xlib level. Since we essentially
- * work around a WM bug we don't want this hack to be exposed
- * to Intrinsics (i.e. don't mess with grabs, callbacks etc).
- */
- Display *dpy = XtDisplay(wdata->winData.shell);
- Window shell_win = XtWindow(wdata->winData.shell);
-
- DTRACE_PRINT("WM: setShellDecor REMAPPING ... ");
- XUnmapWindow(dpy, shell_win);
- XSync(dpy, False); /* give WM a chance to catch up */
- XMapWindow(dpy, shell_win);
- DTRACE_PRINTLN("done");
- }
-}
-
-
-/*
- * Make specified shell resizable.
- */
-void
-awt_wm_setShellResizable(struct FrameData *wdata)
-{
- DTRACE_PRINTLN2("WM: setShellResizable(0x%x/0x%x)",
- wdata->winData.shell, XtWindow(wdata->winData.shell));
-
- XtVaSetValues(wdata->winData.shell,
- XmNallowShellResize, True,
- XmNminWidth, XtUnspecifiedShellInt,
- XmNminHeight, XtUnspecifiedShellInt,
- XmNmaxWidth, XtUnspecifiedShellInt,
- XmNmaxHeight, XtUnspecifiedShellInt,
- NULL);
-
- /* REMINDER: will need to revisit when setExtendedStateBounds is added */
- awt_wm_removeSizeHints(wdata->winData.shell, PMinSize|PMaxSize);
-
- /* Restore decorations */
- awt_wm_setShellDecor(wdata, True);
-}
-
-
-/*
- * Make specified shell non-resizable.
- * If justChangeSize is false, update decorations as well.
- */
-void
-awt_wm_setShellNotResizable(struct FrameData *wdata,
- int32_t width, int32_t height,
- Boolean justChangeSize)
-{
- DTRACE_PRINTLN5("WM: setShellNotResizable(0x%x/0x%x, %d, %d, %s)",
- wdata->winData.shell, XtWindow(wdata->winData.shell),
- width, height,
- justChangeSize ? "size only" : "redecorate");
-
- /* Fix min/max size hints at the specified values */
- if ((width > 0) && (height > 0)) {
- XtVaSetValues(wdata->winData.shell,
- XmNwidth, (XtArgVal)width,
- XmNheight, (XtArgVal)height,
- XmNminWidth, (XtArgVal)width,
- XmNminHeight, (XtArgVal)height,
- XmNmaxWidth, (XtArgVal)width,
- XmNmaxHeight, (XtArgVal)height,
- NULL);
- }
-
- if (!justChangeSize) { /* update decorations */
- awt_wm_setShellDecor(wdata, False);
- }
-}
-
-
-/*
- * Helper function for awt_wm_getInsetsFromProp.
- * Read property of type CARDINAL[4] = { left, right, top, bottom }
- */
-static Boolean
-awt_wm_readInsetsArray(Window shell_win, Atom insets_property,
- int32_t *top, int32_t *left, int32_t *bottom, int32_t *right)
-{
- /* Request status */
- int status;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- long *insets = NULL; /* NB: 64 bit: Format 32 props are 'long' */
-
- status = XGetWindowProperty (awt_display, shell_win,
- insets_property, 0, 4, False, XA_CARDINAL,
- &actual_type, &actual_format, &nitems, &bytes_after,
- (unsigned char **)&insets);
-
- if (status != Success || insets == NULL) {
- DTRACE_PRINTLN("failed");
- return False;
- }
-
- if (actual_type != XA_CARDINAL || actual_format != 32) {
- DTRACE_PRINTLN("type/format mismatch");
- XFree(insets);
- return False;
- }
-
- *left = (int32_t)insets[0];
- *right = (int32_t)insets[1];
- *top = (int32_t)insets[2];
- *bottom = (int32_t)insets[3];
- XFree(insets);
-
- /* Order is that of java.awt.Insets.toString */
- DTRACE_PRINTLN4("[top=%d,left=%d,bottom=%d,right=%d]",
- *top, *left, *bottom, *right);
- return True;
-}
-
-/*
- * If WM implements the insets property - fill insets with values
- * specified in that property.
- */
-Boolean
-awt_wm_getInsetsFromProp(Window shell_win,
- int32_t *top, int32_t *left, int32_t *bottom, int32_t *right)
-{
- switch (awt_wm_getRunningWM()) {
-
- case ENLIGHTEN_WM:
- DTRACE_PRINT("WM: reading _E_FRAME_SIZE ... ");
- return awt_wm_readInsetsArray(shell_win, _XA_E_FRAME_SIZE,
- top, left, bottom, right);
-
-#if 0
- /*
- * uwe: disabled for now, as KDE seems to supply bogus values
- * when we maximize iconified frame. Need to verify with KDE2.1.
- * NB: Also note, that "external" handles (e.g. in laptop decor)
- * are also included in the frame strut, which is probably not
- * what we want.
- */
- case KDE2_WM:
- DTRACE_PRINT("WM: reading _KDE_NET_WM_FRAME_STRUT ... ");
- return awt_wm_readInsetsArray(shell_win, _XA_KDE_NET_WM_FRAME_STRUT,
- top, left, bottom, right);
-#endif
-
- default:
- return False;
- }
-}
-
-/*
- * XmNiconic and Map/UnmapNotify (that XmNiconic relies on) are
- * unreliable, since mapping changes can happen for a virtual desktop
- * switch or MacOS style shading that became quite popular under X as
- * well. Yes, it probably should not be this way, as it violates
- * ICCCM, but reality is that quite a lot of window managers abuse
- * mapping state.
- */
-int
-awt_wm_getWMState(Window shell_win)
-{
- /* Request status */
- int status;
-
- /* Returns of XGetWindowProperty */
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- long *data; /* NB: 64 bit: Format 32 props are 'long' */
-
- int wm_state;
-
- status = XGetWindowProperty(awt_display, shell_win,
- XA_WM_STATE, 0, 1, False, XA_WM_STATE,
- &actual_type, &actual_format, &nitems, &bytes_after,
- (unsigned char **)&data);
-
- if (status != Success || data == NULL) {
- return WithdrawnState;
- }
-
- if (actual_type != XA_WM_STATE) {
- DTRACE_PRINTLN1("WM: WM_STATE(0x%x) - wrong type", shell_win);
- XFree(data);
- return WithdrawnState;
- }
-
- wm_state = (int)*data;
- XFree(data);
- return wm_state;
-}
-
-
-
-/*****************************************************************************\
- *
- * Reading state from properties WM puts on our window ...
- *
-\*****************************************************************************/
-
-/*
- * New "NET" WM spec: _NET_WM_STATE/Atom[]
- */
-static jint
-awt_wm_getStateNet(Window shell_win)
-{
- Atom *net_wm_state;
- jint java_state;
- unsigned long nitems;
- unsigned long i;
-
- net_wm_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
- if (nitems == 0) {
- DTRACE_PRINTLN("WM: _NET_WM_STATE = { }");
- if (net_wm_state) {
- XFree(net_wm_state);
- }
- return java_awt_Frame_NORMAL;
- }
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
- java_state = java_awt_Frame_NORMAL;
- for (i = 0; i < nitems; ++i) {
- if (net_wm_state[i] == _XA_NET_WM_STATE_MAXIMIZED_VERT) {
- java_state |= java_awt_Frame_MAXIMIZED_VERT;
- }
- else if (net_wm_state[i] == _XA_NET_WM_STATE_MAXIMIZED_HORZ) {
- java_state |= java_awt_Frame_MAXIMIZED_HORIZ;
- }
- }
- XFree(net_wm_state);
- return java_state;
-}
-
-Boolean
-awt_wm_isStateNetHidden(Window shell_win)
-{
- Atom *net_wm_state;
- Boolean result = False;
- unsigned long nitems;
- unsigned long i;
-
- net_wm_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
- if (nitems == 0) {
- DTRACE_PRINTLN("WM: _NET_WM_STATE = { }");
- if (net_wm_state) {
- XFree(net_wm_state);
- }
- return False;
- }
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
- for (i = 0; i < nitems; ++i) {
- if (net_wm_state[i] == _XA_NET_WM_STATE_HIDDEN) {
- result = True;
- }
- }
- XFree(net_wm_state);
- return result;
-}
-
-/*
- * Similar code to getStateNet, to get layer state.
- */
-static int
-awt_wm_getLayerNet(Window shell_win)
-{
- Atom *net_wm_state;
- int java_state;
- unsigned long nitems;
- unsigned long i;
-
- net_wm_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
- if (nitems == 0) {
- DTRACE_PRINTLN("WM: _NET_WM_STATE = { }");
- if (net_wm_state) {
- XFree(net_wm_state);
- }
- return LAYER_NORMAL;
- }
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
- java_state = LAYER_NORMAL;
- for (i = 0; i < nitems; ++i) {
- if (net_wm_state[i] == _XA_NET_WM_STATE_ABOVE) {
- java_state = LAYER_ALWAYS_ON_TOP;
- }
- }
- XFree(net_wm_state);
- return java_state;
-}
-
-/*
- * Old Gnome spec: _WIN_STATE/CARDINAL
- */
-static jint
-awt_wm_getStateWin(Window shell_win)
-{
- long win_state;
- jint java_state;
-
- win_state = awt_getProperty32(shell_win, _XA_WIN_STATE, XA_CARDINAL);
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateWin(win_state);
-#endif
-
- java_state = java_awt_Frame_NORMAL;
- if (win_state & WIN_STATE_MAXIMIZED_VERT) {
- java_state |= java_awt_Frame_MAXIMIZED_VERT;
- }
- if (win_state & WIN_STATE_MAXIMIZED_HORIZ) {
- java_state |= java_awt_Frame_MAXIMIZED_HORIZ;
- }
- return java_state;
-}
-
-/*
- * Code similar to getStateWin, to get layer state.
- */
-static int
-awt_wm_getLayerWin(Window shell_win)
-{
- long win_state;
- jint java_state;
-
- win_state = awt_getProperty32(shell_win, _XA_WIN_LAYER, XA_CARDINAL);
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateWin(win_state);
-#endif
-
- java_state = LAYER_NORMAL;
- if (win_state == WIN_LAYER_ONTOP) {
- java_state = LAYER_ALWAYS_ON_TOP;
- }
- return java_state;
-}
-
-
-static jint
-awt_wm_getExtendedState(Window shell_win)
-{
- if (awt_wm_doStateProtocolNet()) {
- return awt_wm_getStateNet(shell_win);
- }
- else if (awt_wm_doStateProtocolWin()) {
- return awt_wm_getStateWin(shell_win);
- }
- else {
- return java_awt_Frame_NORMAL;
- }
-}
-
-jint
-awt_wm_getState(struct FrameData *wdata)
-{
- Window shell_win = XtWindow(wdata->winData.shell);
- jint java_state;
-
- DTRACE_PRINTLN2("WM: getState(0x%x/0x%x)",
- wdata->winData.shell, shell_win);
-
- if (shell_win == None) {
- DTRACE_PRINTLN("WM: no window, use wdata");
- java_state = wdata->state;
- }
- else {
- int wm_state = awt_wm_getWMState(shell_win);
- if (wm_state == WithdrawnState) {
- DTRACE_PRINTLN("WM: window withdrawn, use wdata");
- java_state = wdata->state;
- }
- else {
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceWMState(wm_state);
-#endif
- if (wm_state == IconicState) {
- java_state = java_awt_Frame_ICONIFIED;
- } else {
- java_state = java_awt_Frame_NORMAL;
- }
- java_state |= awt_wm_getExtendedState(shell_win);
- }
- }
-
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateJava(java_state);
-#endif
-
- return java_state;
-}
-
-
-
-/*****************************************************************************\
- *
- * Notice window state change when WM changes a property on the window ...
- *
-\*****************************************************************************/
-
-
-/*
- * Check if property change is a window state protocol message.
- * If it is - return True and return the new state in *pstate.
- */
-Boolean
-awt_wm_isStateChange(struct FrameData *wdata, XPropertyEvent *e, jint *pstate)
-{
- Window shell_win = XtWindow(wdata->winData.shell);
- Boolean is_state_change = False;
- int wm_state;
-
- if (!wdata->isShowing) {
- return False;
- }
-
- wm_state = awt_wm_getWMState(shell_win);
- if (wm_state == WithdrawnState) {
- return False;
- }
-
- if (e->atom == XA_WM_STATE) {
- is_state_change = True;
- }
- else if (e->atom == _XA_NET_WM_STATE) {
- is_state_change = awt_wm_doStateProtocolNet();
- }
- else if (e->atom == _XA_WIN_STATE) {
- is_state_change = awt_wm_doStateProtocolWin();
- }
-
- if (is_state_change) {
-#ifdef DEBUG
- Widget shell = wdata->winData.shell;
- char *name = XGetAtomName(XtDisplay(shell), e->atom);
- DTRACE_PRINTLN4("WM: PropertyNotify(0x%x/0x%x) %s %s",
- shell, XtWindow(shell),
- name != NULL ? name : "???",
- e->state == PropertyNewValue ? "changed" : "deleted");
- if (name != NULL) {
- XFree(name);
- }
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceWMState(wm_state);
-#endif
- if (wm_state == IconicState) {
- *pstate = java_awt_Frame_ICONIFIED;
- } else {
- *pstate = java_awt_Frame_NORMAL;
- }
- *pstate |= awt_wm_getExtendedState(shell_win);
-
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateJava(*pstate);
-#endif
- }
-
- return is_state_change;
-}
-
-
-
-
-/*****************************************************************************\
- *
- * Setting/changing window state ...
- *
-\*****************************************************************************/
-
-/*
- * Request a state transition from a _NET supporting WM by sending
- * _NET_WM_STATE ClientMessage to root window.
- */
-static void
-awt_wm_requestStateNet(struct FrameData *wdata, jint state)
-{
- Widget shell = wdata->winData.shell;
- Window shell_win = XtWindow(shell);
- XClientMessageEvent req;
- jint old_net_state;
- jint max_changed;
-
- /* must use awt_wm_setInitialStateNet for withdrawn windows */
- DASSERT(wdata->isShowing);
-
- /*
- * We have to use toggle for maximization because of transitions
- * from maximization in one direction only to maximization in the
- * other direction only.
- */
- old_net_state = awt_wm_getStateNet(shell_win);
- max_changed = (state ^ old_net_state) & java_awt_Frame_MAXIMIZED_BOTH;
-
- switch (max_changed) {
- case 0:
- DTRACE_PRINTLN("WM: requestStateNet - maximization unchanged");
- return;
-
- case java_awt_Frame_MAXIMIZED_HORIZ:
- DTRACE_PRINTLN("WM: requestStateNet - toggling MAX_HORZ");
- req.data.l[1] = _XA_NET_WM_STATE_MAXIMIZED_HORZ;
- req.data.l[2] = 0;
- break;
-
- case java_awt_Frame_MAXIMIZED_VERT:
- DTRACE_PRINTLN("WM: requestStateNet - toggling MAX_VERT");
- req.data.l[1] = _XA_NET_WM_STATE_MAXIMIZED_VERT;
- req.data.l[2] = 0;
- break;
-
- default: /* both */
- DTRACE_PRINTLN("WM: requestStateNet - toggling HORZ + VERT");
- req.data.l[1] = _XA_NET_WM_STATE_MAXIMIZED_HORZ;
- req.data.l[2] = _XA_NET_WM_STATE_MAXIMIZED_VERT;
- break;
- }
-
- req.type = ClientMessage;
- req.window = XtWindow(shell);
- req.message_type = _XA_NET_WM_STATE;
- req.format = 32;
- req.data.l[0] = _NET_WM_STATE_TOGGLE;
-
- XSendEvent(XtDisplay(shell), RootWindowOfScreen(XtScreen(shell)), False,
- (SubstructureRedirectMask | SubstructureNotifyMask),
- (XEvent *)&req);
-}
-
-
-/*
- * Request state transition from a Gnome WM (_WIN protocol) by sending
- * _WIN_STATE ClientMessage to root window.
- */
-static void
-awt_wm_requestStateWin(struct FrameData *wdata, jint state)
-{
- Widget shell = wdata->winData.shell;
- XClientMessageEvent req;
- long win_state; /* typeof(XClientMessageEvent.data.l) */
-
- /* must use awt_wm_setInitialStateWin for withdrawn windows */
- DASSERT(wdata->isShowing);
-
- win_state = 0;
- if (state & java_awt_Frame_MAXIMIZED_VERT) {
- win_state |= WIN_STATE_MAXIMIZED_VERT;
- }
- if (state & java_awt_Frame_MAXIMIZED_HORIZ) {
- win_state |= WIN_STATE_MAXIMIZED_HORIZ;
- }
-
- req.type = ClientMessage;
- req.window = XtWindow(shell);
- req.message_type = _XA_WIN_STATE;
- req.format = 32;
- req.data.l[0] = (WIN_STATE_MAXIMIZED_HORIZ | WIN_STATE_MAXIMIZED_VERT);
- req.data.l[1] = win_state;
-
- XSendEvent(XtDisplay(shell), RootWindowOfScreen(XtScreen(shell)), False,
- (SubstructureRedirectMask | SubstructureNotifyMask),
- (XEvent *)&req);
-}
-
-
-/*
- * Specify initial state for _NET supporting WM by setting
- * _NET_WM_STATE property on the window to the desired state before
- * mapping it.
- */
-static void
-awt_wm_setInitialStateNet(struct FrameData *wdata, jint state)
-{
- Widget shell = wdata->winData.shell;
- Window shell_win = XtWindow(shell);
- Display *dpy = XtDisplay(shell);
-
- Atom *old_state;
- unsigned long nitems;
-
- /* must use awt_wm_requestStateNet for managed windows */
- DASSERT(!wdata->isShowing);
-
- /* Be careful to not wipe out state bits we don't understand */
- old_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
-
- if (nitems == 0) {
- /*
- * Empty or absent _NET_WM_STATE - set a new one if necessary.
- */
- Atom net_wm_state[AWT_NET_N_KNOWN_STATES];
-
- if (old_state != NULL) {
- XFree(old_state);
- }
-
- if (state & java_awt_Frame_MAXIMIZED_VERT) {
- net_wm_state[nitems++] = _XA_NET_WM_STATE_MAXIMIZED_VERT;
- }
- if (state & java_awt_Frame_MAXIMIZED_HORIZ) {
- net_wm_state[nitems++] = _XA_NET_WM_STATE_MAXIMIZED_HORZ;
- }
- DASSERT(nitems <= AWT_NET_N_KNOWN_STATES);
-
- if (nitems == 0) {
- DTRACE_PRINTLN("WM: initial _NET_WM_STATE not necessary");
- return;
- }
-
-#ifdef DEBUG
- DTRACE_PRINT("WM: setting initial ");
- awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
- XChangeProperty(dpy, shell_win,
- _XA_NET_WM_STATE, XA_ATOM, 32, PropModeReplace,
- (unsigned char *)net_wm_state, nitems);
- }
- else {
- /*
- * Tweak existing _NET_WM_STATE, preserving bits we don't use.
- */
- jint want= state /* which flags we want */
- & (java_awt_Frame_MAXIMIZED_HORIZ | java_awt_Frame_MAXIMIZED_VERT);
-
- jint has = 0; /* which flags the window already has */
- int mode; /* property mode: replace/append */
-
- Atom *new_state; /* new _net_wm_state value */
- int new_nitems;
- unsigned long i;
-
-#ifdef DEBUG
- DTRACE_PRINT("WM: already has ");
- awt_wm_dtraceStateNet(old_state, nitems);
-#endif
-
- for (i = 0; i < nitems; ++i) {
- if (old_state[i] == _XA_NET_WM_STATE_MAXIMIZED_HORZ) {
- has |= java_awt_Frame_MAXIMIZED_HORIZ;
- }
- else if (old_state[i] == _XA_NET_WM_STATE_MAXIMIZED_VERT) {
- has |= java_awt_Frame_MAXIMIZED_VERT;
- }
- }
-
- if ((has ^ want) == 0) {
- DTRACE_PRINTLN("WM: no changes to _NET_WM_STATE necessary");
- XFree(old_state);
- return;
- }
-
- new_nitems = 0;
- if (has == 0) { /* only adding flags */
- new_state = calloc(AWT_NET_N_KNOWN_STATES, sizeof(Atom));
- mode = PropModeAppend;
- }
- else {
- new_state = calloc(nitems + AWT_NET_N_KNOWN_STATES, sizeof(Atom));
- mode = PropModeReplace;
- }
-
- if (has != 0) { /* copy existing flags */
- DTRACE_PRINT("WM: ");
- for (i = 0; i < nitems; ++i) {
- if (old_state[i] == _XA_NET_WM_STATE_MAXIMIZED_HORZ) {
- if (want & java_awt_Frame_MAXIMIZED_HORIZ) {
- DTRACE_PRINT(" keep _HORZ");
- } else {
- DTRACE_PRINT(" drop _HORZ");
- continue;
- }
- }
- else if (old_state[i] == _XA_NET_WM_STATE_MAXIMIZED_VERT) {
- if (want & java_awt_Frame_MAXIMIZED_VERT) {
- DTRACE_PRINT(" keep _VERT");
- } else {
- DTRACE_PRINT(" drop _VERT");
- continue;
- }
- }
- new_state[new_nitems++] = old_state[i];
- }
- }
-
- /* Add missing flags */
- if ((want & java_awt_Frame_MAXIMIZED_HORIZ)
- && !(has & java_awt_Frame_MAXIMIZED_HORIZ))
- {
- DTRACE_PRINT(" add _HORZ");
- new_state[new_nitems] = _XA_NET_WM_STATE_MAXIMIZED_HORZ;
- ++new_nitems;
- }
- if ((want & java_awt_Frame_MAXIMIZED_VERT)
- && !(has & java_awt_Frame_MAXIMIZED_VERT))
- {
- DTRACE_PRINT(" add _VERT");
- new_state[new_nitems] = _XA_NET_WM_STATE_MAXIMIZED_VERT;
- ++new_nitems;
- }
-
- DTRACE_PRINTLN(mode == PropModeReplace ?
- " ... replacing" : " ... appending");
- XChangeProperty(dpy, shell_win,
- _XA_NET_WM_STATE, XA_ATOM, 32, mode,
- (unsigned char *)new_state, new_nitems);
- XFree(old_state);
- XFree(new_state);
- }
-}
-
-
-/*
- * Specify initial state for a Gnome WM (_WIN protocol) by setting
- * WIN_STATE property on the window to the desired state before
- * mapping it.
- */
-static void
-awt_wm_setInitialStateWin(struct FrameData *wdata, jint state)
-{
- Display *dpy = XtDisplay(wdata->winData.shell);
- Window shell_win = XtWindow(wdata->winData.shell);
- long win_state, old_win_state;
-
- /* must use awt_wm_requestStateWin for managed windows */
- DASSERT(!wdata->isShowing);
-
- /* Be careful to not wipe out state bits we don't understand */
- win_state = awt_getProperty32(shell_win, _XA_WIN_STATE, XA_CARDINAL);
- old_win_state = win_state;
-#ifdef DEBUG
- if (win_state != 0) {
- DTRACE_PRINT("WM: already has ");
- awt_wm_dtraceStateWin(win_state);
- }
-#endif
-
- /*
- * In their stupid quest of reinventing every wheel, Gnome WM spec
- * have its own "minimized" hint (instead of using initial state
- * and WM_STATE hints). This is bogus, but, apparently, some WMs
- * pay attention.
- */
- if (state & java_awt_Frame_ICONIFIED) {
- win_state |= WIN_STATE_MINIMIZED;
- } else {
- win_state &= ~WIN_STATE_MINIMIZED;
- }
-
- if (state & java_awt_Frame_MAXIMIZED_VERT) {
- win_state |= WIN_STATE_MAXIMIZED_VERT;
- } else {
- win_state &= ~WIN_STATE_MAXIMIZED_VERT;
- }
-
- if (state & java_awt_Frame_MAXIMIZED_HORIZ) {
- win_state |= WIN_STATE_MAXIMIZED_HORIZ;
- } else {
- win_state &= ~WIN_STATE_MAXIMIZED_HORIZ;
- }
-
- if (old_win_state ^ win_state) {
-#ifdef DEBUG
- DTRACE_PRINT("WM: setting initial ");
- awt_wm_dtraceStateWin(win_state);
-#endif
- XChangeProperty(dpy, shell_win,
- _XA_WIN_STATE, XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *)&win_state, 1);
- }
-#ifdef DEBUG
- else {
- DTRACE_PRINTLN("WM: no changes to _WIN_STATE necessary");
- }
-#endif
-}
-
-/*
- * Request a layer change from a _NET supporting WM by sending
- * _NET_WM_STATE ClientMessage to root window.
- */
-static void
-awt_wm_requestLayerNet(struct FrameData *wdata, int state)
-{
- Widget shell = wdata->winData.shell;
- Window shell_win = XtWindow(shell);
- XClientMessageEvent req;
- int currentLayer;
- long cmd;
-
- /* must use awt_wm_setInitialLayerNet for withdrawn windows */
- DASSERT(wdata->isShowing);
-
- currentLayer = awt_wm_getLayerNet(shell_win);
- if(state == currentLayer) {
- return;
- }
- cmd = currentLayer == LAYER_ALWAYS_ON_TOP && state == LAYER_NORMAL ?
- _NET_WM_STATE_REMOVE :
- currentLayer == LAYER_NORMAL && state == LAYER_ALWAYS_ON_TOP ?
- _NET_WM_STATE_ADD :
- _NET_WM_STATE_ADD;
- req.type = ClientMessage;
- req.window = XtWindow(shell);
- req.message_type = _XA_NET_WM_STATE;
- req.format = 32;
- req.data.l[0] = cmd;
- req.data.l[1] = _XA_NET_WM_STATE_ABOVE;
- req.data.l[2] = 0L;
-
- XSendEvent(XtDisplay(shell), RootWindowOfScreen(XtScreen(shell)), False,
- (SubstructureRedirectMask | SubstructureNotifyMask),
- (XEvent *)&req);
-}
-
-/*
- * Request a layer change from a Gnome WM (_WIN protocol) by sending
- * _WIN_LAYER ClientMessage to root window.
- */
-static void
-awt_wm_requestLayerWin(struct FrameData *wdata, int state)
-{
- Widget shell = wdata->winData.shell;
- XClientMessageEvent req;
- Display *dpy = XtDisplay(shell);
-
- /* must use awt_wm_setInitialLayerWin for withdrawn windows */
- DASSERT(wdata->isShowing);
-
- req.type = ClientMessage;
- req.window = XtWindow(shell);
- req.message_type = _XA_WIN_LAYER;
- req.format = 32;
- req.data.l[0] = state == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP;
- req.data.l[1] = 0L;
- req.data.l[2] = 0L;
-
- XSendEvent(XtDisplay(shell), RootWindowOfScreen(XtScreen(shell)), False,
- /*(SubstructureRedirectMask |*/
- SubstructureNotifyMask,
- (XEvent *)&req);
-}
-/*
- * Specify initial layer for _NET supporting WM by setting
- * _NET_WM_STATE property on the window to the desired state before
- * mapping it.
- * NB: looks like it doesn't have any effect.
- */
-static void
-awt_wm_setInitialLayerNet(struct FrameData *wdata, int state)
-{
- Widget shell = wdata->winData.shell;
- Window shell_win = XtWindow(shell);
- Display *dpy = XtDisplay(shell);
-
- Atom *old_state;
- unsigned long nitems;
- Atom new_state = _XA_NET_WM_STATE_ABOVE;
-
- /* must use awt_wm_requestLayerNet for managed windows */
- DASSERT(!wdata->isShowing);
-
- /* Be careful to not wipe out state bits we don't understand */
- old_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
-
- if (nitems == 0 && state != LAYER_ALWAYS_ON_TOP) {
- if (old_state != NULL) {
- XFree(old_state);
- }
- return;
- }else if( nitems == 0 && state == LAYER_ALWAYS_ON_TOP) {
- unsigned long data[2];
- /* create new state */
- if (old_state != NULL) {
- XFree(old_state);
- }
- nitems = 1;
- data[0] = new_state;
- data[1] = 0;
- XChangeProperty(dpy, shell_win,
- _XA_NET_WM_STATE, XA_ATOM, 32, PropModeReplace,
- (unsigned char *)data, nitems);
- XSync(dpy, False);
- }else { /* nitems > 0 */
- unsigned long i;
- Boolean bShift = False;
- int mode;
- for(i = 0; i < nitems; i++) {
- if( bShift ) {
- old_state[i-1] = old_state[i];
- }else if( old_state[i] == _XA_NET_WM_STATE_ABOVE ) {
- if(state == LAYER_ALWAYS_ON_TOP) {
- /* no change necessary */
- XFree(old_state);
- return;
- }else{
- /* wipe off this atom */
- bShift = True;
- }
- }
- }
-
- if( bShift ) {
- /* atom was found and removed: change property */
- mode = PropModeReplace;
- nitems--;
- }else if( state != LAYER_ALWAYS_ON_TOP ) {
- /* atom was not found and not needed */
- XFree( old_state);
- return;
- }else {
- /* must add new atom */
- mode = PropModeAppend;
- nitems = 1;
- }
-
- XChangeProperty(dpy, shell_win,
- _XA_NET_WM_STATE, XA_ATOM, 32, mode,
- mode == PropModeAppend ?
- (unsigned char *)(&new_state) :
- (unsigned char *)old_state, nitems);
- XFree(old_state);
- XSync(dpy, False);
- }
-}
-
-/*
- * Specify initial layer for a Gnome WM (_WIN protocol) by setting
- * WIN_LAYER property on the window to the desired state before
- * mapping it.
- */
-static void
-awt_wm_setInitialLayerWin(struct FrameData *wdata, int state)
-{
- Display *dpy = XtDisplay(wdata->winData.shell);
- Window shell_win = XtWindow(wdata->winData.shell);
- long win_state, old_win_state;
- int currentLayer;
-
- /* must use awt_wm_requestLayerWin for managed windows */
- DASSERT(!wdata->isShowing);
-
- currentLayer = awt_wm_getLayerWin(shell_win);
- if( currentLayer == state ) {
- /* no change necessary */
- return;
- }
- if( state == LAYER_ALWAYS_ON_TOP ) {
- win_state = WIN_LAYER_ONTOP;
- }else {
- win_state = WIN_LAYER_NORMAL;
- }
-
- XChangeProperty(dpy, shell_win,
- _XA_WIN_LAYER, XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *)&win_state, 1);
-}
-
-void
-awt_wm_setExtendedState(struct FrameData *wdata, jint state)
-{
- Display *dpy = XtDisplay(wdata->winData.shell);
- Window shell_win = XtWindow(wdata->winData.shell);
-
-#ifdef DEBUG
- DTRACE_PRINT2("WM: setExtendedState(0x%x/0x%x) ",
- wdata->winData.shell, shell_win);
- awt_wm_dtraceStateJava(state);
-#endif
-
- if (wdata->isShowing) {
- /*
- * If the window is managed by WM, we should send
- * ClientMessage requests.
- */
- if (awt_wm_doStateProtocolNet()) {
- awt_wm_requestStateNet(wdata, state);
- }
- else if (awt_wm_doStateProtocolWin()) {
- awt_wm_requestStateWin(wdata, state);
- }
- XSync(dpy, False);
- }
- else {
- /*
- * If the window is withdrawn we should set necessary
- * properties directly to the window before mapping it.
- */
- if (awt_wm_doStateProtocolNet()) {
- awt_wm_setInitialStateNet(wdata, state);
- }
- else if (awt_wm_doStateProtocolWin()) {
- awt_wm_setInitialStateWin(wdata, state);
- }
-#if 1
- /*
- * Purge KWM bits.
- * Not really tested with KWM, only with WindowMaker.
- */
- XDeleteProperty(dpy, shell_win, XA_KWM_WIN_ICONIFIED);
- XDeleteProperty(dpy, shell_win, XA_KWM_WIN_MAXIMIZED);
-#endif /* 1 */
- }
-}
-
-static Boolean
-awt_wm_supportsLayersNet() {
- Boolean supported = awt_wm_doStateProtocolNet();
-
- /*
- In fact, WM may report this not supported but do support.
- */
- supported &= awt_wm_checkProtocol(_XA_NET_SUPPORTED, _XA_NET_WM_STATE_ABOVE);
- return supported;
-}
-
-static Boolean
-awt_wm_supportsLayersWin() {
- Boolean supported = awt_wm_doStateProtocolWin();
- /*
- * In fact, WM may report this supported but do not support.
- */
- supported &= awt_wm_checkProtocol(_XA_WIN_PROTOCOLS, _XA_WIN_LAYER);
- return supported;
-}
-
-void
-awt_wm_updateAlwaysOnTop(struct FrameData *wdata, jboolean bLayerState) {
- Display *dpy = XtDisplay(wdata->winData.shell);
- Window shell_win = XtWindow(wdata->winData.shell);
- int layerState = bLayerState ? LAYER_ALWAYS_ON_TOP : LAYER_NORMAL;
-
- if (wdata->isShowing) {
- /**
- We don't believe anyone, and now send both ClientMessage requests.
- And eg Metacity under RH 6.1 required both to work.
- **/
- awt_wm_requestLayerNet(wdata, layerState);
- awt_wm_requestLayerWin(wdata, layerState);
- } else {
- /**
- We don't believe anyone, and now set both atoms.
- And eg Metacity under RH 6.1 required both to work.
- **/
- awt_wm_setInitialLayerNet(wdata, layerState);
- awt_wm_setInitialLayerWin(wdata, layerState);
- }
- XSync(dpy, False);
-}
-
-/*
- * Work around for 4775545. _NET version.
- */
-static void
-awt_wm_unshadeKludgeNet(struct FrameData *wdata)
-{
- Display *dpy = XtDisplay(wdata->winData.shell);
- Window shell_win = XtWindow(wdata->winData.shell);
- Atom *net_wm_state;
- Boolean shaded;
- unsigned long nitems;
- unsigned long i;
-
- net_wm_state = awt_getAtomListProperty(shell_win,
- _XA_NET_WM_STATE, &nitems);
- if (nitems == 0) {
- DTRACE_PRINTLN("WM: _NET_WM_STATE = { }");
- if (net_wm_state) {
- XFree(net_wm_state);
- }
- return;
- }
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
- shaded = False;
- for (i = 0; i < nitems; ++i) {
- if (net_wm_state[i] == _XA_NET_WM_STATE_SHADED) {
- shaded = True;
- break;
- }
- }
-
- if (!shaded) {
- DTRACE_PRINTLN("WM: not _SHADED, no workaround necessary");
- return;
- }
-
- DTRACE_PRINTLN("WM: removing _SHADED");
- ++i; /* skip _SHADED */
- while (i < nitems) { /* copy the rest */
- net_wm_state[i-1] = net_wm_state[i];
- ++i;
- }
- --nitems; /* _SHADED has been removed */
-
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
- WITH_XERROR_HANDLER(xerror_verify_change_property);
- {
- XChangeProperty(dpy, shell_win,
- _XA_NET_WM_STATE, XA_ATOM, 32, PropModeReplace,
- (unsigned char *)net_wm_state, nitems);
- }
- RESTORE_XERROR_HANDLER;
-
- if (xerror_code != Success) {
- DTRACE_PRINTLN1("WM: XChangeProperty failed, error = %d",
- xerror_code);
- }
-
- XFree(net_wm_state);
-}
-
-
-/*
- * Work around for 4775545. _WIN version.
- */
-static void
-awt_wm_unshadeKludgeWin(struct FrameData *wdata)
-{
- Display *dpy = XtDisplay(wdata->winData.shell);
- Window shell_win = XtWindow(wdata->winData.shell);
- long win_state;
-
- win_state = awt_getProperty32(shell_win, _XA_WIN_STATE, XA_CARDINAL);
-#ifdef DEBUG
- DTRACE_PRINT("WM: ");
- awt_wm_dtraceStateWin(win_state);
-#endif
-
- if ((win_state & WIN_STATE_SHADED) == 0) {
- DTRACE_PRINTLN("WM: not _SHADED, no workaround necessary");
- return;
- }
-
- win_state &= ~WIN_STATE_SHADED;
- XChangeProperty(dpy, shell_win,
- _XA_WIN_STATE, XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *)&win_state, 1);
-}
-
-
-/*
- * Work around for 4775545.
- *
- * If WM exits while the top-level is shaded, the shaded hint remains
- * on the top-level properties. When WM restarts and sees the shaded
- * window it can reparent it into a "pre-shaded" decoration frame
- * (Metacity does), and our insets logic will go crazy, b/c it will
- * see a huge nagative bottom inset. There's no clean solution for
- * this, so let's just be weasels and drop the shaded hint if we
- * detect that WM exited. NB: we are in for a race condition with WM
- * restart here. NB2: e.g. WindowMaker saves the state in a private
- * property that this code knows nothing about, so this workaround is
- * not effective; other WMs might play similar tricks.
- */
-void
-awt_wm_unshadeKludge(struct FrameData *wdata)
-{
- DTRACE_PRINTLN("WM: unshade kludge");
- DASSERT(wdata->isShowing);
-
- if (awt_wm_doStateProtocolNet()) {
- awt_wm_unshadeKludgeNet(wdata);
- }
- else if (awt_wm_doStateProtocolWin()) {
- awt_wm_unshadeKludgeWin(wdata);
- }
-#ifdef DEBUG
- else {
- DTRACE_PRINTLN("WM: not a _NET or _WIN supporting WM");
- }
-#endif
-
- XSync(XtDisplay(wdata->winData.shell), False);
-}
-
-
-void
-awt_wm_init(void)
-{
- static Boolean inited = False;
- if (inited) {
- return;
- }
-
- awt_wm_initAtoms();
- awt_wm_getRunningWM();
- inited = True;
-}
-
-Boolean awt_wm_supportsAlwaysOnTop() {
- return awt_wm_supportsLayersNet() || awt_wm_supportsLayersWin();
-}
--- a/jdk/src/solaris/native/sun/awt/awt_wm.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef _AWT_WM_H_
-#define _AWT_WM_H_
-
-#ifndef HEADLESS
-
-#include "awt_p.h"
-
-/*
- * Window Managers we care to distinguish.
- * See awt_wm_getRunningWM()
- */
-enum wmgr_t {
- UNDETERMINED_WM,
- NO_WM,
- OTHER_WM,
- OPENLOOK_WM,
- MOTIF_WM,
- CDE_WM,
- ENLIGHTEN_WM,
- KDE2_WM,
- SAWFISH_WM,
- ICE_WM,
- METACITY_WM
-};
-
-extern void awt_wm_init(void);
-
-extern enum wmgr_t awt_wm_getRunningWM(void);
-extern Boolean awt_wm_configureGravityBuggy(void);
-extern Boolean awt_wm_supportsExtendedState(jint state);
-
-/* XWMHints.flags is declared long, so 'mask' argument is declared long too */
-extern void awt_wm_removeSizeHints(Widget shell, long mask);
-
-extern void awt_wm_setShellDecor(struct FrameData *wdata, Boolean resizable);
-extern void awt_wm_setShellResizable(struct FrameData *wdata);
-extern void awt_wm_setShellNotResizable(struct FrameData *wdata,
- int32_t width, int32_t height,
- Boolean justChangeSize);
-
-extern Boolean awt_wm_getInsetsFromProp(Window w,
- int32_t *top, int32_t *left, int32_t *bottom, int32_t *right);
-
-/*
- * WM_STATE: WithdrawnState, NormalState, IconicState.
- * Absence of WM_STATE is treated as WithdrawnState.
- */
-extern int awt_wm_getWMState(Window w);
-
-extern void awt_wm_setExtendedState(struct FrameData *wdata, jint state);
-extern Boolean awt_wm_isStateChange(struct FrameData *wdata, XPropertyEvent *e,
- jint *pstate);
-
-extern void awt_wm_unshadeKludge(struct FrameData *wdata);
-extern void awt_wm_updateAlwaysOnTop(struct FrameData *wdata, jboolean bLayerState);
-extern Boolean awt_wm_supportsAlwaysOnTop();
-
-#endif /* !HEADLESS */
-#endif /* _AWT_WM_H_ */
--- a/jdk/src/solaris/native/sun/awt/awt_xembed.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef _AWT_XEMBED_H_
-#define _AWT_XEMBED_H_
-
-#ifndef HEADLESS
-
-#include "awt_p.h"
-
-#define XEMBED_VERSION 0
-#define XEMBED_MAPPED (1 << 0)
-/* XEMBED messages */
-#define XEMBED_EMBEDDED_NOTIFY 0
-#define XEMBED_WINDOW_ACTIVATE 1
-#define XEMBED_WINDOW_DEACTIVATE 2
-#define XEMBED_REQUEST_FOCUS 3
-#define XEMBED_FOCUS_IN 4
-#define XEMBED_FOCUS_OUT 5
-#define XEMBED_FOCUS_NEXT 6
-#define XEMBED_FOCUS_PREV 7
-/* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */
-#define XEMBED_MODALITY_ON 10
-#define XEMBED_MODALITY_OFF 11
-#define XEMBED_REGISTER_ACCELERATOR 12
-#define XEMBED_UNREGISTER_ACCELERATOR 13
-#define XEMBED_ACTIVATE_ACCELERATOR 14
-
-#define XEMBED_LAST_MSG XEMBED_ACTIVATE_ACCELERATOR
-
-#define NON_STANDARD_XEMBED_GTK_GRAB_KEY 108
-#define NON_STANDARD_XEMBED_GTK_UNGRAB_KEY 109
-
-// Sun internal special message, to resolve start race condition
-#define _SUN_XEMBED_START 1119
-
-
-// A detail code is required for XEMBED_FOCUS_IN. The following values are valid:
-/* Details for XEMBED_FOCUS_IN: */
-#define XEMBED_FOCUS_CURRENT 0
-#define XEMBED_FOCUS_FIRST 1
-#define XEMBED_FOCUS_LAST 2
-
-
-extern void init_xembed();
-extern void xembed_eventHandler(XEvent *event);
-extern void requestXEmbedFocus(struct FrameData * wdata);
-extern void install_xembed(Widget client, struct FrameData* wdata);
-extern void deinstall_xembed(struct FrameData* wdata);
-extern Boolean isXEmbedActive(struct FrameData * wdata);
-extern Boolean isXEmbedActiveByWindow(Window client);
-extern Boolean isXEmbedApplicationActive(struct FrameData * wdata);
-extern void sendMessageHelper(Window window, int message, long detail,
- long data1, long data2);
-extern void sendMessage(Window window, int message);
-extern void xembed_traverse_out(struct FrameData * wdata, jboolean);
-#endif
-#endif
--- a/jdk/src/solaris/native/sun/awt/awt_xembed_server.c Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,969 +0,0 @@
-/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// TODO: Propogate applicationActive from Java
-
-#ifdef HEADLESS
- #error This file should not be included in headless library
-#endif
-
-#include "awt_p.h"
-
-#include <X11/Xproto.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <Xm/MwmUtil.h>
-#ifdef __linux__
-#include <execinfo.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-
-/* JNI headers */
-#include "java_awt_Frame.h" /* for frame state constants */
-#include "java_awt_event_KeyEvent.h"
-#include "awt_wm.h"
-#include "awt_util.h" /* for X11 error handling macros */
-#include "awt_xembed.h"
-#include "awt_Component.h"
-#include "awt_AWTEvent.h"
-#include "canvas.h"
-#include "sun_awt_motif_MEmbedCanvasPeer.h"
-
-#ifdef DOTRACE
-#define MTRACE(param) fprintf(stderr, param)
-#define MTRACEP1(format, p1) fprintf(stderr, format, p1)
-#define MTRACEP2(format, p1, p2) fprintf(stderr, format, p1, p2)
-#define MTRACEP3(format, p1, p2, p3) fprintf(stderr, format, p1, p2, p3)
-#define MTRACEP4(format, p1, p2, p3, p4) fprintf(stderr, format, p1, p2, p3, p4)
-#define MTRACEP5(format, p1, p2, p3, p4, p5) fprintf(stderr, format, p1, p2, p3, p4, p5)
-#define MTRACEP6(format, p1, p2, p3, p4, p5, p6) fprintf(stderr, format, p1, p2, p3, p4, p5, p6)
-#define MTRACEP7(format, p1, p2, p3, p4, p5, p6, p7) fprintf(stderr, format, p1, p2, p3, p4, p5, p6, p7)
-#else
-#define MTRACE(param)
-#define MTRACEP1(format, p1)
-#define MTRACEP2(format, p1, p2)
-#define MTRACEP3(format, p1, p2, p3)
-#define MTRACEP4(format, p1, p2, p3, p4)
-#define MTRACEP5(format, p1, p2, p3, p4, p5)
-#define MTRACEP6(format, p1, p2, p3, p4, p5, p6)
-#define MTRACEP7(format, p1, p2, p3, p4, p5, p6, p7)
-#endif
-
-/**************************** XEmbed server DnD support ***********************/
-extern Atom XA_XdndAware;
-extern Boolean
-register_xembed_drop_site(JNIEnv* env, Display* dpy, jobject server,
- Window serverHandle, Window clientHandle);
-extern Boolean
-unregister_xembed_drop_site(JNIEnv* env, Display* dpy, jobject server,
- Window serverHandle, Window clientHandle);
-extern void
-forward_event_to_embedded(Window embedded, jlong ctxt, jint eventID);
-
-extern const char * msg_to_str(int msg);
-
-void
-set_xembed_drop_target(JNIEnv* env, jobject server);
-void
-remove_xembed_drop_target(JNIEnv* env, jobject server);
-Boolean
-is_xembed_client(Window window);
-/******************************************************************************/
-extern struct MComponentPeerIDs mComponentPeerIDs;
-static jobject createRectangle(JNIEnv* env, int x, int y, int width, int height);
-static jobject createDimension(JNIEnv* env, int width, int height);
-static void processXEmbedInfo(JNIEnv* env, jobject this);
-static Atom XA_XEmbedInfo;
-static Atom XA_XEmbed;
-static jmethodID requestXEmbedFocusMID, focusNextMID, focusPrevMID,
- registerAcceleratorMID, unregisterAcceleratorMID,
- grabKeyMID, ungrabKeyMID, childResizedMID,
- setXEmbedDropTargetMID, removeXEmbedDropTargetMID;
-static jfieldID keysymFID, modifiersFID, applicationActiveFID;
-
-typedef struct _xembed_server_data {
- Window handle; // pointer to plugin intermediate widget, XEmbed client
- Window serverHandle;
- Widget serverWidget;
- Boolean dispatching; // whether we dispatch messages for handle
- int version;
- jobject server;
- struct _xembed_server_data * next;
-} xembed_server_data, * pxembed_server_data;
-
-static pxembed_server_data xembed_list = NULL;
-
-static pxembed_server_data
-getData(Window handle) {
- pxembed_server_data temp = xembed_list;
- while (temp != NULL) {
- if (temp->handle == handle) {
- return temp;
- }
- temp = temp->next;
- }
- return NULL;
-}
-
-static pxembed_server_data
-getDataByEmbedder(jobject server) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- pxembed_server_data temp = xembed_list;
- DASSERT(server != NULL);
- while (temp != NULL) {
- if ((*env)->IsSameObject(env, temp->server, server)) {
- return temp;
- }
- temp = temp->next;
- }
- return NULL;
-}
-
-static pxembed_server_data
-getDataByServerHandle(Window serverHandle) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- pxembed_server_data temp = xembed_list;
- Widget serverWidget = NULL;
- if (serverHandle == None) {
- return NULL;
- }
- serverWidget = XtWindowToWidget(awt_display, serverHandle);
- while (temp != NULL) {
- if (temp->serverHandle == serverHandle || temp->serverWidget == serverWidget) {
- temp->serverHandle = serverWidget;
- return temp;
- }
- temp = temp->next;
- }
- return NULL;
-}
-
-static pxembed_server_data
-addData(jobject server) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- struct ComponentData *cdata;
- xembed_server_data * data = malloc(sizeof(xembed_server_data));
- DASSERT(server != NULL);
- memset(data, 0, sizeof(xembed_server_data));
- data->server = server;
- cdata = (struct ComponentData *)
- JNU_GetLongFieldAsPtr(env, server, mComponentPeerIDs.pData);
- DASSERT(cdata != NULL);
- data->serverHandle = XtWindow(cdata->widget);
- data->serverWidget = cdata->widget;
- data->next = xembed_list;
- xembed_list = data;
- return data;
-}
-
-static void
-removeData(jobject server) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- pxembed_server_data * temp = &xembed_list;
- DASSERT(server != NULL);
- while (*temp != NULL) {
- if ((*env)->IsSameObject(env, (*temp)->server, server)) {
- xembed_server_data * data = *temp;
- *temp = (*temp)->next;
- DASSERT(data->server != NULL);
- (*env)->DeleteGlobalRef(env, data->server);
- free(data);
- return;
- }
- temp = &(*temp)->next;
- }
-}
-
-void
-initXEmbedServerData() {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- jclass clazz;
- MTRACE("initXEmbedServerData\n");
- XA_XEmbedInfo = XInternAtom(awt_display, "_XEMBED_INFO", False);
- XA_XEmbed = XInternAtom(awt_display, "_XEMBED", False);
-
- clazz = (*env)->FindClass(env, "sun/awt/motif/MEmbedCanvasPeer");
- DASSERT(clazz != NULL);
- requestXEmbedFocusMID = (*env)->GetMethodID(env, clazz, "requestXEmbedFocus", "()V");
- DASSERT(requestXEmbedFocusMID != NULL);
- focusNextMID = (*env)->GetMethodID(env, clazz, "focusNext", "()V");
- DASSERT(focusNextMID != NULL);
- focusPrevMID = (*env)->GetMethodID(env, clazz, "focusPrev", "()V");
- DASSERT(focusPrevMID != NULL);
- registerAcceleratorMID = (*env)->GetMethodID(env, clazz, "registerAccelerator", "(JJJ)V");
- DASSERT(registerAcceleratorMID != NULL);
- unregisterAcceleratorMID = (*env)->GetMethodID(env, clazz, "unregisterAccelerator", "(J)V");
- DASSERT(unregisterAcceleratorMID != NULL);
- grabKeyMID = (*env)->GetMethodID(env, clazz, "grabKey", "(JJ)V");
- DASSERT(grabKeyMID != NULL);
- ungrabKeyMID = (*env)->GetMethodID(env, clazz, "ungrabKey", "(JJ)V");
- DASSERT(ungrabKeyMID != NULL);
- childResizedMID = (*env)->GetMethodID(env, clazz, "childResized", "()V");
- DASSERT(childResizedMID != NULL);
- setXEmbedDropTargetMID =
- (*env)->GetMethodID(env, clazz, "setXEmbedDropTarget", "()V");
- DASSERT(setXEmbedDropTargetMID != NULL);
- removeXEmbedDropTargetMID =
- (*env)->GetMethodID(env, clazz, "removeXEmbedDropTarget", "()V");
- DASSERT(removeXEmbedDropTargetMID != NULL);
-
- applicationActiveFID = (*env)->GetFieldID(env, clazz, "applicationActive", "Z");
- DASSERT(applicationActiveFID != NULL);
- (*env)->DeleteLocalRef(env, clazz);
-
- clazz = (*env)->FindClass(env, "sun/awt/motif/GrabbedKey");
- DASSERT(clazz != NULL);
- keysymFID = (*env)->GetFieldID(env, clazz, "keysym", "J");
- DASSERT(keysymFID != NULL);
- modifiersFID = (*env)->GetFieldID(env, clazz, "modifiers", "J");
- DASSERT(modifiersFID != NULL);
- (*env)->DeleteLocalRef(env, clazz);
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: initXEmbedServer
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer(JNIEnv *env, jobject this) {
- struct ComponentData *cdata;
- AWT_LOCK();
- MTRACE("initXEmbedServer\n");
- addData((*env)->NewGlobalRef(env, this));
- if (XA_XEmbedInfo == None) {
- initXEmbedServerData();
- }
- cdata = (struct ComponentData *)
- JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
-/* XSelectInput(awt_display, XtWindow(cdata->widget), SubstructureNotifyMask); */
- XtAddEventHandler(cdata->widget,
- SubstructureNotifyMask,
- False, null_event_handler, NULL);
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: destroyXEmbedServer
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer(JNIEnv *env, jobject this) {
- AWT_LOCK();
- MTRACE("destroyXEmbedServer\n");
- removeData(this);
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: isXEmbedActive
- * Signature: ()Z
- */
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive(JNIEnv *env, jobject this) {
- pxembed_server_data sdata;
- jboolean res = JNI_FALSE;
- AWT_LOCK();
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- res = (sdata->handle != None)?JNI_TRUE:JNI_FALSE;
- }
- AWT_UNLOCK();
- return res;
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: initDispatching
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching (JNIEnv *env, jobject this) {
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACE("initDispatching\n");
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- XSelectInput(awt_display, sdata->handle, StructureNotifyMask | PropertyChangeMask);
- sdata->dispatching = True;
- register_xembed_drop_site(env, awt_display, sdata->server,
- sdata->serverHandle, sdata->handle);
- }
- processXEmbedInfo(env, this);
- Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded(env, this);
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: endDispatching
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching (JNIEnv *env, jobject this) {
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACE("endDispatching\n");
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- unregister_xembed_drop_site(env, awt_display, sdata->server,
- sdata->serverHandle, sdata->handle);
- sdata->dispatching = False;
- }
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: embedChild
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_embedChild (JNIEnv * env, jobject this, jlong handle) {
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACE("embedChild\n");
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- if (sdata->handle != None) {
- Java_sun_awt_motif_MEmbedCanvasPeer_detachChild(env, this);
- }
- sdata->handle = (Window)handle;
- Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching(env, this);
- }
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: childDestroyed
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed (JNIEnv *env, jobject this) {
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACE("childDestroyed\n");
- Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching(env, this);
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- sdata->handle = None;
- }
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: getEmbedPreferredSize
- * Signature: ()Ljava/awt/Dimension;
- */
-JNIEXPORT jobject JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize (JNIEnv *env, jobject this) {
- pxembed_server_data sdata;
- jobject res = NULL;
- XSizeHints * hints;
- long dummy;
- AWT_LOCK();
- MTRACE("getPreferredSize\n");
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- hints = XAllocSizeHints();
- DASSERT(hints != NULL);
- DASSERT(sdata->handle != None);
- if (XGetWMNormalHints(awt_display, sdata->handle, hints, &dummy) == Success) {
- res = createDimension(env, hints->width, hints->height);
- }
- XFree(hints);
- }
- AWT_UNLOCK();
- return res;
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: getEmbedMinimumSize
- * Signature: ()Ljava/awt/Dimension;
- */
-JNIEXPORT jobject JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize (JNIEnv *env, jobject this) {
- pxembed_server_data sdata;
- jobject res = NULL;
- XSizeHints * hints;
- long dummy;
- AWT_LOCK();
- MTRACE("getMinimumSize\n");
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- hints = XAllocSizeHints();
- DASSERT(hints != NULL);
- DASSERT(sdata->handle != None);
- if (XGetWMNormalHints(awt_display, sdata->handle, hints, &dummy) == Success) {
- res = createDimension(env, hints->min_width, hints->min_height);
- }
- XFree(hints);
- }
- AWT_UNLOCK();
- return res;
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: getClientBounds
- * Signature: ()Ljava/awt/Rectangle;
- */
-JNIEXPORT jobject JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds (JNIEnv *env, jobject this) {
- pxembed_server_data sdata;
- jobject res = NULL;
- AWT_LOCK();
- MTRACE("getClientBounds\n");
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- XWindowAttributes attrs;
- DASSERT(sdata->handle != None);
- if (XGetWindowAttributes(awt_display, sdata->handle, &attrs) == Success) {
- res = createRectangle(env, attrs.x, attrs.y, attrs.width, attrs.height);
- }
- }
- AWT_UNLOCK();
- return res;
-}
-
-Boolean
-isApplicationActive(JNIEnv * env, jobject this) {
- return (*env)->GetBooleanField(env, this, applicationActiveFID);
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: notifyChildEmbedded
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded (JNIEnv *env, jobject this) {
- struct ComponentData *cdata;
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACE("notifyChildEmbedded\n");
- cdata = (struct ComponentData *)
- JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- DASSERT(sdata->handle != None);
- DASSERT(cdata != NULL);
- DASSERT(XtWindow(cdata->widget) != None);
- sendMessageHelper(sdata->handle, XEMBED_EMBEDDED_NOTIFY, XtWindow(cdata->widget), min(sdata->version, XEMBED_VERSION), 0);
- if (isApplicationActive(env, this)) {
- sendMessage(sdata->handle, XEMBED_WINDOW_ACTIVATE);
- }
- }
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: detachChild
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_detachChild (JNIEnv *env, jobject this) {
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACE("detachChild\n");
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- /**
- * XEmbed specification:
- * "The embedder can unmap the client and reparent the client window to the root window. If the
- * client receives an ReparentNotify event, it should check the parent field of the XReparentEvent
- * structure. If this is the root window of the window's screen, then the protocol is finished and
- * there is no further interaction. If it is a window other than the root window, then the protocol
- * continues with the new parent acting as the embedder window."
- */
- DASSERT(sdata->handle != None);
- XUnmapWindow(awt_display, sdata->handle);
- XReparentWindow(awt_display, sdata->handle, DefaultRootWindow(awt_display), 0, 0);
- Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching(env, this);
- sdata->handle = None;
- }
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: forwardKeyEvent
- * Signature: (Ljava/awt/event/KeyEvent;)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent (JNIEnv *env, jobject this, jobject event) {
- pxembed_server_data sdata;
- jbyteArray array;
- XEvent *xevent;
- AWT_LOCK();
- MTRACE("forwardKeyEvent\n");
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- DASSERT(sdata->handle != None);
- array = (jbyteArray)(*env)->GetObjectField(env, event, awtEventIDs.bdata);
- if (array == NULL) {
- MTRACE("array is null\n");
- AWT_UNLOCK();
- return;
- }
-
- xevent = (XEvent *)(*env)->GetByteArrayElements(env, array, NULL);
- if (xevent == NULL) {
- (*env)->DeleteLocalRef(env, array);
- MTRACE("xevent is null\n");
- AWT_UNLOCK();
- return;
- }
- xevent->xany.window = sdata->handle;
- XSendEvent(awt_display, sdata->handle, False, NoEventMask, xevent);
- (*env)->DeleteLocalRef(env, array);
- }
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: getAWTKeyCodeForKeySym
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym (JNIEnv *env, jobject this, jint keysym) {
- jint keycode = java_awt_event_KeyEvent_VK_UNDEFINED;
- Boolean mapsToUnicodeChar;
- jint keyLocation;
- keysymToAWTKeyCode(keysym, &keycode, &mapsToUnicodeChar, &keyLocation);
- return keycode;
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: sendMessage
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I (JNIEnv *env, jobject this, jint msg) {
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACEP2("sendMessage %d(%s)\n", msg, msg_to_str(msg));
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- DASSERT(sdata->handle != None);
- sendMessage(sdata->handle, msg);
- }
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: sendMessage
- * Signature: (IJJJ)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ (JNIEnv *env, jobject this, jint msg, jlong detail, jlong data1, jlong data2) {
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACEP5("sendMessage2 msg %d(%s) detail %d data: %d %d\n", msg, msg_to_str(msg), detail, data1, data2);
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- DASSERT(sdata->handle != None);
- sendMessageHelper(sdata->handle, msg, detail, data1, data2);
- }
- AWT_UNLOCK();
-}
-
-static jobject
-createRectangle(JNIEnv* env, int x, int y, int width, int height) {
- static jclass clazz;
- static jmethodID mid;
- jobject rect = NULL;
- if (mid == 0) {
- jclass l_clazz = (*env)->FindClass(env, "java/awt/Rectangle");
- DASSERT(l_clazz != NULL);
- mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
- DASSERT(mid != NULL);
- clazz = (*env)->NewGlobalRef(env, l_clazz);
- (*env)->DeleteLocalRef(env, l_clazz);
- }
- if (mid != NULL) {
- rect = (*env)->NewObject(env, clazz, mid, x, y, width, height);
- if ((*env)->ExceptionOccurred(env)) {
- return NULL;
- }
- }
- return rect;
-}
-
-static jobject
-createDimension(JNIEnv* env, int width, int height) {
- static jclass clazz;
- static jmethodID mid;
- jobject dim = NULL;
- if (mid == 0) {
- jclass l_clazz = (*env)->FindClass(env, "java/awt/Dimension");
- DASSERT(l_clazz != NULL);
- mid = (*env)->GetMethodID(env, clazz, "<init>", "(II)V");
- DASSERT(mid != NULL);
- clazz = (*env)->NewGlobalRef(env, l_clazz);
- (*env)->DeleteLocalRef(env, l_clazz);
- }
- if (mid != NULL) {
- dim = (*env)->NewObject(env, clazz, mid, width, height);
- if ((*env)->ExceptionOccurred(env)) {
- return NULL;
- }
- }
- return dim;
-}
-
-Boolean isMapped(Window w) {
- XWindowAttributes attr;
- Status status = 0;
- WITH_XERROR_HANDLER(xerror_ignore_bad_window);
- status = XGetWindowAttributes(awt_display, w, &attr);
- RESTORE_XERROR_HANDLER;
- if (status == 0 || xerror_code != Success) {
- return False;
- }
- return !(attr.map_state == IsUnmapped);
-}
-
-static void
-processXEmbedInfo(JNIEnv * env, jobject this) {
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACE("processXEmbedInfo\n");
- sdata = getDataByEmbedder(this);
- if (Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive(env, this)) {
- Atom actual_type;
- int actual_format;
- unsigned long nitems;
- unsigned long bytes_after;
- CARD32 * data = NULL;
- DASSERT(sdata->handle != None);
- if (XGetWindowProperty(awt_display, sdata->handle, XA_XEmbedInfo,
- 0, 2, False, XA_XEmbedInfo, &actual_type,
- &actual_format, &nitems, &bytes_after,
- (unsigned char**)&data) != Success)
- {
- AWT_UNLOCK();
- return;
- }
- if (actual_type == XA_XEmbedInfo && actual_format == 32
- && nitems == 2)
- {
- CARD32 flags;
- Boolean new_mapped, currently_mapped;
- sdata->version = *data;
- flags = *(data+1);
- new_mapped = (flags & XEMBED_MAPPED) != 0;
- currently_mapped = isMapped(sdata->handle);
- if (new_mapped != currently_mapped) {
- if (new_mapped) {
- XMapWindow(awt_display, sdata->handle);
- } else {
- XUnmapWindow(awt_display, sdata->handle);
- }
- }
- }
- if (data != NULL) {
- XFree(data);
- }
- }
- AWT_UNLOCK();
-}
-
-/**
- * Handles client message on embedder
- */
-static void
-handleClientMessage(JNIEnv* env, jobject this, XClientMessageEvent * ev) {
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACEP5("handleClientMessage: 0=%ld 1=%ld 2=%ld 3=%ld 4=%ld\n",
- ev->data.l[0], ev->data.l[1], ev->data.l[2], ev->data.l[3], ev->data.l[4]);
- sdata = getDataByEmbedder(this);
- if (sdata != NULL && sdata->handle != None) {
- switch ((int)ev->data.l[1]) {
- case XEMBED_REQUEST_FOCUS:
- MTRACE("REQUEST_FOCUS\n");
- (*env)->CallVoidMethod(env, this, requestXEmbedFocusMID);
- break;
- case XEMBED_FOCUS_NEXT:
- MTRACE("FOCUS_NEXT\n");
- (*env)->CallVoidMethod(env, this, focusNextMID);
- break;
- case XEMBED_FOCUS_PREV:
- MTRACE("FOCUS_PREV\n");
- (*env)->CallVoidMethod(env, this, focusPrevMID);
- break;
- case XEMBED_REGISTER_ACCELERATOR:
- MTRACE("REGISTER_ACCEL\n");
- (*env)->CallVoidMethod(env, this, registerAcceleratorMID,
- (jlong)ev->data.l[2],
- (jlong)ev->data.l[3],
- (jlong)ev->data.l[4]);
- break;
- case XEMBED_UNREGISTER_ACCELERATOR:
- MTRACE("UNREGISTER_ACCEL\n");
- (*env)->CallVoidMethod(env, this, unregisterAcceleratorMID,
- (jlong)ev->data.l[2]);
- break;
- case NON_STANDARD_XEMBED_GTK_GRAB_KEY:
- MTRACE("GRAB_KEY\n");
- (*env)->CallVoidMethod(env, this, grabKeyMID,
- (jlong)ev->data.l[3],
- (jlong)ev->data.l[4]);
- break;
- case NON_STANDARD_XEMBED_GTK_UNGRAB_KEY:
- MTRACE("UNGRAB_KEY\n");
- (*env)->CallVoidMethod(env, this, ungrabKeyMID,
- (jlong)ev->data.l[3],
- (jlong)ev->data.l[4]);
- case _SUN_XEMBED_START:
- MTRACE("XEMBED_START\n");
- processXEmbedInfo(env, this);
- Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded(env, this);
- break;
- }
- }
- AWT_UNLOCK();
-}
-
-/**
- * Handles property changes on xembed client
- */
-static void
-handlePropertyNotify(XPropertyEvent * ev) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACE("handlePropertyNotify\n");
- sdata = getData(ev->window);
- if (sdata != NULL) {
- if (ev->atom == XA_WM_NORMAL_HINTS) {
- DASSERT(sdata->server != NULL);
- (*env)->CallVoidMethod(env, sdata->server, childResizedMID);
- MTRACE("NORMAL_HINTS have changed\n");
- } else if (ev->atom == XA_XdndAware) {
- unregister_xembed_drop_site(env, awt_display, sdata->server,
- sdata->serverHandle, sdata->handle);
- if (ev->state == PropertyNewValue) {
- register_xembed_drop_site(env, awt_display, sdata->server,
- sdata->serverHandle, sdata->handle);
- }
- } else if (ev->atom == XA_XEmbedInfo) {
- DASSERT(sdata->server != NULL);
- MTRACE("XEMBED_INFO has changed\n");
- processXEmbedInfo(env, sdata->server);
- }
- }
- AWT_UNLOCK();
-}
-
-static void
-handleConfigureNotify(XConfigureEvent * ev) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- pxembed_server_data sdata;
- AWT_LOCK();
- MTRACE("handleConfigureNotify\n");
- sdata = getData(ev->window);
- if (sdata != NULL) {
- DASSERT(sdata->server != NULL);
- (*env)->CallVoidMethod(env, sdata->server, childResizedMID);
- }
- AWT_UNLOCK();
-}
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: sendMessage
- * Signature: (IJJJ)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers (JNIEnv *env, jobject this, jobject keyevent) {
- jbyteArray array;
- XEvent *xevent;
- int keysym, modifiers;
- int keycode;
- AWT_LOCK();
- array = (jbyteArray)(*env)->GetObjectField(env, keyevent, awtEventIDs.bdata);
- if (array == NULL) {
- AWT_UNLOCK();
- return;
- }
- xevent = (XEvent *)(*env)->GetByteArrayElements(env, array, NULL);
- if (xevent == NULL) {
- (*env)->DeleteLocalRef(env, array);
- AWT_UNLOCK();
- return;
- }
- keycode = (*env)->GetIntField(env, keyevent, keyEventIDs.keyCode);
- keysym = awt_getX11KeySym(keycode);
- modifiers = xevent->xkey.state;
- (*env)->SetLongField(env, this, keysymFID, (jlong)keysym);
- (*env)->SetLongField(env, this, modifiersFID, (jlong)modifiers);
- (*env)->DeleteLocalRef(env, array);
- AWT_UNLOCK();
-}
-
-#ifdef __linux__
-void
-print_stack (void)
-{
- void *array[10];
- size_t size;
- char **strings;
- size_t i;
-
- size = backtrace (array, 10);
- strings = backtrace_symbols (array, size);
-
- fprintf (stderr, "Obtained %zd stack frames.\n", size);
-
- for (i = 0; i < size; i++)
- fprintf (stderr, "%s\n", strings[i]);
-
- free (strings);
-}
-#endif
-
-extern int32_t numEventsHandled;
-
-XCreateWindowEvent cr;
-
-void
-dispatchEmbedderEvent(jobject server, XEvent * ev) {
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- DASSERT(server != NULL);
- DASSERT(ev != NULL);
- AWT_LOCK();
-/* MTRACE("dispatchEmebddedEvent\n"); */
- switch (ev->type) {
- case CreateNotify:
-
- MTRACEP3("CreateNotify for %x, serial %d, num events %d\n", (ev->xcreatewindow.window), (ev->xany.serial), (numEventsHandled));
- Java_sun_awt_motif_MEmbedCanvasPeer_embedChild(env, server, ev->xcreatewindow.window);
- break;
- case DestroyNotify:
- MTRACE("DestroyNotify\n");
- Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed(env, server);
- break;
- case ReparentNotify:
- MTRACEP2("ReparentNotify for %x, parent %x\n", (ev->xreparent.window), (ev->xreparent.parent));
- Java_sun_awt_motif_MEmbedCanvasPeer_embedChild(env, server, ev->xreparent.window);
- break;
- case ClientMessage:
- MTRACE("ClientMessage\n");
- handleClientMessage(env, server, &ev->xclient);
- break;
- }
- AWT_UNLOCK();
-}
-
-void
-dispatchEmbeddingClientEvent(XEvent * ev) {
- DASSERT(ev != NULL);
- MTRACE("dispatchEmbeddingClientEvent\n");
- switch (ev->type) {
- case PropertyNotify:
- handlePropertyNotify(&ev->xproperty);
- break;
- case ConfigureNotify:
- handleConfigureNotify(&ev->xconfigure);
- break;
- }
-}
-
-void
-xembed_serverEventHandler(XEvent * ev) {
- pxembed_server_data sdata;
- sdata = getData(ev->xany.window);
- if (sdata != NULL) { // Event on client
- dispatchEmbeddingClientEvent(ev);
- } else {
- sdata = getDataByServerHandle(ev->xany.window);
- if (sdata != NULL) {
- DASSERT(sdata->server != NULL);
- dispatchEmbedderEvent(sdata->server, ev);
- }
- }
-}
-
-/**************************** XEmbed server DnD support ***********************/
-void
-set_xembed_drop_target(JNIEnv* env, jobject server) {
-
- (*env)->CallVoidMethod(env, server, setXEmbedDropTargetMID);
-}
-
-void
-remove_xembed_drop_target(JNIEnv* env, jobject server) {
- (*env)->CallVoidMethod(env, server, removeXEmbedDropTargetMID);
-}
-
-Boolean
-is_xembed_client(Window window) {
- return getData(window) != NULL;
-}
-/******************************************************************************/
-
-/*
- * Class: sun_awt_motif_MEmbedCanvasPeer
- * Method: getWindow
- * Signature: ()V
- */
-JNIEXPORT jlong JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getWindow(JNIEnv *env, jobject this) {
- struct ComponentData *cdata;
- Window res = None;
- AWT_LOCK();
- cdata = (struct ComponentData *)
- JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
- DASSERT(cdata != NULL);
- res = XtWindow(cdata->widget);
- AWT_UNLOCK();
- return (jlong)res;
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded(JNIEnv *env,
- jobject this,
- jlong ctxt,
- jint eventID){
- pxembed_server_data sdata;
- AWT_LOCK();
- sdata = getDataByEmbedder(this);
- if (sdata != NULL) {
- forward_event_to_embedded(sdata->handle, ctxt, eventID);
- }
- AWT_UNLOCK();
-}
--- a/jdk/src/solaris/native/sun/awt/awt_xembed_server.h Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef _AWT_XEMBED_SERVER_H_
-#define _AWT_XEMBED_SERVER_H_
-
-#ifndef HEADLESS
-
-#include "awt_p.h"
-
-extern void xembed_serverEventHandler(XEvent *);
-
-#endif
-#endif
--- a/jdk/src/solaris/native/sun/awt/canvas.h Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/canvas.h Thu Dec 15 19:52:13 2011 -0800
@@ -26,44 +26,7 @@
#define _CANVAS_H_
#ifndef HEADLESS
-void awt_canvas_reconfigure(struct FrameData *wdata);
-Widget awt_canvas_create(XtPointer this,
- Widget parent,
- char *base,
- int32_t width,
- int32_t height,
- Boolean parentIsFrame,
- struct FrameData *wdata,
- AwtGraphicsConfigDataPtr awtData);
-void awt_canvas_scroll(XtPointer this, struct CanvasData *wdata, long dx, long dy);
-void awt_canvas_event_handler(Widget w, XtPointer client_data,
- XEvent *event, Boolean *cont);
-void awt_canvas_handleEvent(Widget w, XtPointer client_data,
- XEvent *event, struct WidgetInfo *winfo,
- Boolean *cont, Boolean passEvent);
-
-void awt_copyXEventToAWTEvent(JNIEnv* env, XEvent * xevent, jobject jevent);
KeySym awt_getX11KeySym(jint awtKey);
-jobject awt_canvas_getFocusOwnerPeer();
-jobject awt_canvas_getFocusedWindowPeer();
-void awt_canvas_setFocusOwnerPeer(jobject peer);
-void awt_canvas_setFocusedWindowPeer(jobject peer);
-jobject awt_canvas_wrapInSequenced(jobject awtevent);
-extern void keysymToAWTKeyCode(KeySym x11Key, jint *keycode, Boolean *mapsToUnicodeChar,
- jint *keyLocation);
-#define awt_canvas_addToFocusList awt_canvas_addToFocusListDefault
-void awt_canvas_addToFocusListDefault(jobject target);
-void awt_canvas_addToFocusListWithDuplicates(jobject target, jboolean acceptDuplicate);
-extern void callFocusCallback(jobject focusPeer, int focus_type, jobject cause);
-extern void callFocusHandler(Widget w, int eventType, jobject cause);
-
-typedef struct FocusListElt{
- jweak requestor;
- struct FocusListElt * next;
-} FocusListElt;
-extern FocusListElt *focusList;
-extern FocusListElt *focusListEnd;
-extern jweak forGained;
#endif /* !HEADLESS */
#endif /* _CANVAS_H_ */
--- a/jdk/src/solaris/native/sun/awt/multi_font.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/multi_font.c Thu Dec 15 19:52:13 2011 -0800
@@ -38,24 +38,15 @@
#include <jni.h>
#include <jni_util.h>
#include <jvm.h>
-#ifndef XAWT
-#include <Xm/Display.h>
-#endif
#include "awt_Font.h"
-#ifndef XAWT
-#include "awt_Component.h"
-#endif
-#include "awt_MenuItem.h"
#include "awt_p.h"
#include "multi_font.h"
extern XFontStruct *loadFont(Display *, char *, int32_t);
extern struct FontIDs fontIDs;
-//extern struct MComponentPeerIDs mComponentPeerIDs;
-//extern struct MMenuItemPeerIDs mMenuItemPeerIDs;
extern struct PlatformFontIDs platformFontIDs;
-extern struct MFontPeerIDs mFontPeerIDs;
+extern struct XFontPeerIDs xFontPeerIDs;
/*
* make string with str + string representation of num
@@ -70,145 +61,7 @@
buf[len] = '0' + num % 100;
buf[len + 1] = '\0';
}
-#ifndef XAWT
-jobject
-awtJNI_CreateAndSetGlobalRef(JNIEnv * env, jobject this)
-{
- jobject gRef;
- gRef = (*env)->NewGlobalRef(env, this);
-
- JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.jniGlobalRef, gRef);
-
- return gRef;
-}
-
-struct gRefStruct
-{
- jobject gRef;
- struct gRefStruct *next;
-};
-
-static struct gRefStruct *gRefHead = NULL;
-static struct gRefStruct *gRefTail = NULL;
-
-/*
- * This function is called by components that
- * are being disposed. It used to invalidate
- * the global ref immediately, but the awt is
- * rather full of thread race conditions involving
- * component disposal and outstanding events.
- * Now we queue up 'to be deleted' global refs
- * as they come in, and don't invalidate them
- * until the X event queue is empty. Callers of
- * either of these functions _must_ have AWT_LOCK'd
- * before using them!
- */
-void
-awtJNI_DeleteGlobalRef(JNIEnv * env, jobject this)
-{
- jobject gRef;
- struct gRefStruct *newGRef;
- struct gRefStruct *temp;
-
- gRef = (jobject)
- JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.jniGlobalRef);
- JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.jniGlobalRef, NULL);
-
- /*
- * Verra handy for tracking down race conditions. If you
- * have a peer getting called after its been disposed...
- */
- /* jio_fprintf(stderr,"%p\n",(void *)gRef); */
-
- newGRef = (struct gRefStruct *)malloc((size_t)sizeof(struct gRefStruct));
-
- if(newGRef == NULL)
- (*env)->DeleteGlobalRef(env, gRef);
- else
- {
- newGRef->gRef = gRef;
- newGRef->next = NULL;
-
- if(gRefHead == NULL)
- {
- gRefTail = newGRef;
- gRefHead = newGRef;
- }
- else
- {
- gRefTail->next = newGRef;
- gRefTail = newGRef;
- }
- }
-}
-
-void
-awtJNI_DeleteGlobalMenuRef(JNIEnv * env, jobject this)
-{
- jobject gRef;
- struct gRefStruct *newGRef;
- struct gRefStruct *temp;
-
- gRef = (jobject)
- //JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.jniGlobalRef);
- //JNU_SetLongFieldFromPtr(env, this, mMenuItemPeerIDs.jniGlobalRef, NULL);
-
- /*
- * Verra handy for tracking down race conditions. If you
- * have a peer getting called after its been disposed...
- */
- /* jio_fprintf(stderr,"%p\n",(void *)gRef); */
-
- newGRef = (struct gRefStruct *)malloc((size_t)sizeof(struct gRefStruct));
-
- if(newGRef == NULL)
- (*env)->DeleteGlobalRef(env, gRef);
- else
- {
- newGRef->gRef = gRef;
- newGRef->next = NULL;
-
- if(gRefHead == NULL)
- {
- gRefTail = newGRef;
- gRefHead = newGRef;
- }
- else
- {
- gRefTail->next = newGRef;
- gRefTail = newGRef;
- }
- }
-}
-
-void awtJNI_CleanupGlobalRefs()
-{
- struct gRefStruct *working,*next;
- JNIEnv *env;
- int32_t count = 0;
-
- if(gRefHead == NULL) {
- return;
- }
-
- env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
- working = gRefHead;
- gRefHead = gRefTail = NULL;
-
- while(working != NULL)
- {
- count++;
- next = working->next;
- (*env)->DeleteGlobalRef(env, working->gRef);
-
- free((void *)working);
-
- working = next;
- }
-}
-#endif
static int32_t
awtJNI_GetFontDescriptorNumber(JNIEnv * env
,jobject font
@@ -255,25 +108,7 @@
return 0;
}
-#ifndef XAWT
-jobject
-awtJNI_GetFont(JNIEnv * env, jobject this)
-{
- jobject target = NULL;
- jobject font = NULL;
- target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
- // SECURITY: Must call _NoClientCode() methods to ensure that we
- // are not invoking client code on the privileged thread
- font = JNU_CallMethodByName(env,
- NULL,
- target,
- "getFont_NoClientCode",
- "()Ljava/awt/Font;").l;
- (*env)->DeleteLocalRef(env, target);
- return font;
-}
-#endif
jobject
awtJNI_GetFMFont(JNIEnv * env, jobject this)
{
@@ -347,258 +182,7 @@
return JNI_TRUE;
}
-#ifndef XAWT
-#ifdef __linux__
-XmString
-unicodeXmStringCreate(char* text, char* tag, int len) {
- XmString ret_val;
- XtProcessLock();
- ret_val = _XmStringNCreate (text, tag, len);
- XtProcessUnlock();
- return ret_val;
-}
-#endif
-/*
- * Unicode to Motif Multi Font Compound String converter
- *
- * ASSUMES: We are not running on a privileged thread
- */
-XmString
-awtJNI_MakeMultiFontString(JNIEnv * env, jstring s, jobject font)
-{
- XmString xmstr = NULL, xmtmp1, xmtmp2;
- jobjectArray dataArray = NULL;
- char *err = NULL;
- int32_t stringCount,i;
- int32_t fdnumber;
- struct FontData *fdata = awtJNI_GetFontData(env, font, &err);
- jobject fontDescriptor = NULL;
- jbyteArray data = NULL;
- char *stringData = NULL;
- char tag[BUFSIZ];
-
- if ((*env)->PushLocalFrame(env, 16) < 0)
- return NULL;
-
- if (!JNU_IsNull(env, s) && !JNU_IsNull(env, font)) {
- jobject peer;
-
- peer = (*env)->CallObjectMethod(env,font,fontIDs.getPeer);
-
- DASSERT(!awt_currentThreadIsPrivileged(env));
- dataArray =
- (*env)->CallObjectMethod(
- env,
- peer,
- platformFontIDs.makeConvertedMultiFontString,
- s);
-
- if ((*env)->ExceptionOccurred(env)) {
- (*env)->ExceptionDescribe(env);
- (*env)->ExceptionClear(env);
-
- (*env)->PopLocalFrame(env, NULL);
- return (XmString) NULL;
- }
-
- if(dataArray == NULL) {
- (*env)->PopLocalFrame(env, NULL);
- return (XmString) NULL;
- }
- } else {
- (*env)->PopLocalFrame(env, NULL);
- return (XmString) NULL;
- }
-
- stringCount = (*env)->GetArrayLength(env, dataArray);
-
- for (i = 0; i < stringCount; i+=2) {
- fontDescriptor = (*env)->GetObjectArrayElement(env, dataArray, i);
- data = (*env)->GetObjectArrayElement(env, dataArray, i + 1);
-
- /* Bail if we've finished */
- if(fontDescriptor == NULL || data == NULL)
- break;
-
- fdnumber = awtJNI_GetFontDescriptorNumber(env, font, fontDescriptor);
- fdata = awtJNI_GetFontData(env, font, &err);
-
- makeTag(fdata->flist[fdnumber].charset_name, fdnumber, tag);
-
- stringData = (char *)(*env)->GetPrimitiveArrayCritical(env, data, NULL);
- if(stringData != NULL) {
- unsigned char* buf = stringData;
- int len;
- char *offsetStringData;
-
- offsetStringData = stringData + (4 * sizeof(char));
-#ifdef __linux__
- len = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
- /* Motif XmStringCreate() API requests "text must be a NULL-terminated
- string" and its implementation uses "strlen()" to calculate the length
- of the text string. Unfortunately when we deal with iso10646 font
- on linux, the "text" is requested to be encoded in UTF16, which has the
- posibility of including code points like "0xYY00" ("0xYY" + "0x00") that
- causes problem when XmStringCreate() calls _XmStringNCreate() without
- specifying a specific text lenth (see Motif XmString.c). The workaround is
- to call _XmStringNCreate() directly with specific text length at this
- cirsumstance.
- */
- if (strstr(fdata->flist[fdnumber].charset_name, "UnicodeBigUnmarked"))
- xmtmp1 = unicodeXmStringCreate(offsetStringData, tag, len);
- else
- xmtmp1 = XmStringCreate(offsetStringData, tag);
- if (xmstr == NULL)
- xmstr = xmtmp1;
- else {
- xmtmp2 = XmStringConcat(xmstr, xmtmp1);
- XmStringFree(xmtmp1);
- XmStringFree(xmstr);
- xmstr = xmtmp2;
- }
-#else
- if(xmstr == NULL) {
- xmstr = XmStringCreate(offsetStringData, tag);
- }
- else {
- xmtmp1 = XmStringCreate(offsetStringData, tag);
- xmtmp2 = XmStringConcat(xmstr, xmtmp1);
- XmStringFree(xmtmp1);
- XmStringFree(xmstr);
- xmstr = xmtmp2;
- }
-#endif
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, data, stringData, JNI_ABORT);
- (*env)->DeleteLocalRef(env, fontDescriptor);
- (*env)->DeleteLocalRef(env, data);
- }
- (*env)->PopLocalFrame(env, NULL);
- return xmstr;
-}
-
-/*
- * Find the character encoding for a given font and register that encoding
- * with the given tag. The encoding is the last two fields of the XLFD of
- * the font (converted to uppercase).
- */
-static void registerEncoding(char *xlfd, char *tag)
-{
- char *e = xlfd + strlen(xlfd);
- char *ret = NULL;
-
- do { --e; } while (e != xlfd && *e != '-');
- do { --e; } while (e != xlfd && *e != '-');
- if (e != xlfd) {
- char *encoding = strdup(++e);
- char *u = NULL;
-
- for (u = encoding; *u != '\0'; ++u) {
- if (islower(*u)) {
- *u = toupper(*u);
- }
- }
-
- /*
- * Motif will core dump on or otherwise mishandle unknown (or
- * non-standard) character encodings (in conversion to compound
- * text, bug 4122785). Register Sun private encodings for
- * Symbol or dingbat fonts as ISO8859-1, which is a lie,
- * but produces predictable results.
- */
- if (strncmp(encoding, "SUN-", 4) == 0) {
- free(encoding);
- encoding = strdup("ISO8859-1");
- }
- ret = XmRegisterSegmentEncoding(tag, encoding);
- if (ret != NULL)
- XtFree(ret);
- free(encoding);
- }
-}
-
-
-XmFontList
-awtJNI_GetFontList(JNIEnv * env, jobject font)
-{
- int32_t i;
- XmFontListEntry fle;
- XmFontList fontlist;
- XFontStruct *xf = NULL;
- int32_t size;
- struct FontData *fdata = NULL;
- char *err = NULL, tag[BUFSIZ];
-
- fdata = awtJNI_GetFontData(env, font, &err);
-
- makeTag(fdata->flist[0].charset_name, 0, tag);
-
- size = (int32_t) (*env)->GetIntField(env, font, fontIDs.size);
-
- if (fdata->flist[0].load == 0) {
- xf = loadFont(awt_display, fdata->flist[0].xlfd, size * 10);
-
- if (xf == NULL) {
- /* printf("Cannot load font: %s\n", fdata->list[0].xlfd); */
- } else {
- fdata->flist[0].xfont = xf;
- fdata->flist[0].load = 1;
-
- if (xf->min_byte1 == 0 && xf->max_byte1 == 0)
- fdata->flist[0].index_length = 1;
- else
- fdata->flist[0].index_length = 2;
- }
- }
- registerEncoding(fdata->flist[0].xlfd, tag);
- fle = XmFontListEntryCreate(tag, XmFONT_IS_FONT,
- (XtPointer) fdata->flist[0].xfont);
-
- fontlist = XmFontListAppendEntry(NULL, fle);
- /*
- * Some versions of motif have a bug in
- * XmFontListEntryFree() which causes it to free more than it
- * should. Use XtFree() is used instead. See O'Reilly's
- * Motif Reference Manual for more information.
- */
- XmFontListEntryFree(&fle);
-
- for (i = 1; i < fdata->charset_num; i++) {
- makeTag(fdata->flist[i].charset_name, i, tag);
-
- if (fdata->flist[i].load == 0) {
- xf = loadFont(awt_display, fdata->flist[i].xlfd, size * 10);
-
- if (xf == NULL) {
- /* printf("Cannot load font: %s\n", fdata->flist[0].xlfd); */
- continue;
- }
- fdata->flist[i].xfont = xf;
- fdata->flist[i].load = 1;
- if (xf->min_byte1 == 0 && xf->max_byte1 == 0) {
- fdata->flist[i].index_length = 1;
- } else {
- fdata->flist[i].index_length = 2;
- }
- }
- registerEncoding(fdata->flist[i].xlfd, tag);
- fle = XmFontListEntryCreate(tag, XmFONT_IS_FONT,
- (XtPointer) fdata->flist[i].xfont);
- fontlist = XmFontListAppendEntry(fontlist, fle);
- /*
- * Some versions of motif have a bug in
- * XmFontListEntryFree() which causes it to free more than it
- * should. Use XtFree() instead. See O'Reilly's
- * Motif Reference Manual for more information.
- */
- XmFontListEntryFree(&fle);
- }
-
- return fontlist;
-}
-#endif
/* #define FONT_DEBUG 2 */
XFontSet
@@ -625,7 +209,7 @@
size = (*env)->GetIntField(env, font, fontIDs.size) * 10;
peer = (*env)->CallObjectMethod(env,font,fontIDs.getPeer);
- xfsname = (*env)->GetObjectField(env, peer, mFontPeerIDs.xfsname);
+ xfsname = (*env)->GetObjectField(env, peer, xFontPeerIDs.xfsname);
if (JNU_IsNull(env, xfsname))
xfontset = "";
@@ -703,9 +287,6 @@
int32_t length;
XFontStruct *xf = NULL;
jobjectArray dataArray = NULL;
-#ifndef XAWT
- DASSERT(!awt_currentThreadIsPrivileged(env));
-#endif
if ((*env)->EnsureLocalCapacity(env, 3) < 0)
return 0;
--- a/jdk/src/solaris/native/sun/awt/multi_font.h Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/multi_font.h Thu Dec 15 19:52:13 2011 -0800
@@ -29,13 +29,8 @@
#define _MULTI_FONT_H_
#ifndef HEADLESS
-jobject awtJNI_GetFont(JNIEnv *env,jobject this);
jboolean awtJNI_IsMultiFont(JNIEnv *env,jobject this);
jboolean awtJNI_IsMultiFontMetrics(JNIEnv *env,jobject this);
-#ifndef XAWT
-XmString awtJNI_MakeMultiFontString(JNIEnv *env,jstring s,jobject font);
-XmFontList awtJNI_GetFontList(JNIEnv *env,jobject font);
-#endif
XFontSet awtJNI_MakeFontSet(JNIEnv *env,jobject font);
struct FontData *awtJNI_GetFontData(JNIEnv *env,jobject font, char **errmsg);
int32_t awtJNI_GetMFStringWidth(JNIEnv * env, jcharArray s, int32_t offset,
--- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c Thu Dec 15 19:52:13 2011 -0800
@@ -45,8 +45,6 @@
extern UnlockFunc OGLSD_Unlock;
extern DisposeFunc OGLSD_Dispose;
-extern struct MComponentPeerIDs mComponentPeerIDs;
-
extern void
OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
@@ -86,34 +84,12 @@
oglsdo->activeBuffer = GL_FRONT;
oglsdo->needsInit = JNI_TRUE;
-#ifdef XAWT
if (peer != NULL) {
glxsdo->window = JNU_CallMethodByName(env, NULL, peer,
"getContentWindow", "()J").j;
} else {
glxsdo->window = 0;
}
-#else
- if (peer != NULL) {
- struct ComponentData *cdata;
- cdata = (struct ComponentData *)
- JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
- if (cdata == NULL) {
- free(glxsdo);
- JNU_ThrowNullPointerException(env, "Component data missing");
- return;
- }
- if (cdata->widget == NULL) {
- free(glxsdo);
- JNU_ThrowInternalError(env, "Widget is NULL in initOps");
- return;
- }
- glxsdo->widget = cdata->widget;
- } else {
- glxsdo->widget = NULL;
- }
-#endif
-
glxsdo->configData = (AwtGraphicsConfigDataPtr)jlong_to_ptr(aData);
if (glxsdo->configData == NULL) {
free(glxsdo);
@@ -331,11 +307,7 @@
{
GLXSDOps *glxsdo;
Window window;
-#ifdef XAWT
XWindowAttributes attr;
-#else
- Widget widget;
-#endif
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_InitOGLWindow");
@@ -352,7 +324,6 @@
return JNI_FALSE;
}
-#ifdef XAWT
window = glxsdo->window;
if (window == 0) {
J2dRlsTraceLn(J2D_TRACE_ERROR,
@@ -363,22 +334,6 @@
XGetWindowAttributes(awt_display, window, &attr);
oglsdo->width = attr.width;
oglsdo->height = attr.height;
-#else
- widget = glxsdo->widget;
- if (widget == NULL) {
- J2dTraceLn(J2D_TRACE_WARNING, "OGLSD_InitOGLWindow: widget is null");
- }
-
- if (!XtIsRealized(widget)) {
- J2dRlsTraceLn(J2D_TRACE_ERROR,
- "OGLSD_InitOGLWindow: widget is unrealized");
- return JNI_FALSE;
- }
-
- window = XtWindow(widget);
- oglsdo->width = widget->core.width;
- oglsdo->height = widget->core.height;
-#endif
oglsdo->drawableType = OGLSD_WINDOW;
oglsdo->isOpaque = JNI_TRUE;
--- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.h Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.h Thu Dec 15 19:52:13 2011 -0800
@@ -38,16 +38,11 @@
* The GLXSDOps structure contains the GLX-specific information for a given
* OGLSurfaceData. It is referenced by the native OGLSDOps structure.
*
- * Window window; (used in XAWT only)
+ * Window window;
* For onscreen windows, we maintain a reference to that window's associated
* XWindow handle here. Offscreen surfaces have no associated Window, so for
* those surfaces, this value will simply be zero.
*
- * Widget widget; (used in MAWT only)
- * For onscreen windows, we maintain a reference to that window's associated
- * Widget handle here. Offscreen surfaces have no associated Widget, so for
- * those surfaces, this value will simply be zero.
- *
* Drawable xdrawable;
* If a GLXDrawable has a corresponding X11 Drawable, it is stored here. For
* example, each GLXWindow has an associated Window and each GLXPixmap has an
@@ -63,11 +58,7 @@
* created.
*/
typedef struct _GLXSDOps {
-#ifdef XAWT
Window window;
-#else
- Widget widget;
-#endif
Drawable xdrawable;
GLXDrawable drawable;
struct _AwtGraphicsConfigData *configData;
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c Thu Dec 15 19:52:13 2011 -0800
@@ -64,9 +64,6 @@
static DisposeFunc X11SD_Dispose;
static GetPixmapBgFunc X11SD_GetPixmapWithBg;
static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg;
-#ifndef XAWT
-extern struct MComponentPeerIDs mComponentPeerIDs;
-#endif
extern int J2DXErrHandler(Display *display, XErrorEvent *xerr);
extern AwtGraphicsConfigDataPtr
getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
@@ -263,31 +260,12 @@
xsdo->sdOps.Dispose = X11SD_Dispose;
xsdo->GetPixmapWithBg = X11SD_GetPixmapWithBg;
xsdo->ReleasePixmapWithBg = X11SD_ReleasePixmapWithBg;
-#ifndef XAWT
- if (peer != NULL) {
- struct ComponentData *cdata;
- cdata = (struct ComponentData *)
- JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
- if (cdata == NULL) {
- JNU_ThrowNullPointerException(env, "Component data missing");
- return;
- }
- if (cdata->widget == NULL) {
- JNU_ThrowInternalError(env, "Widget is NULL in initOps");
- return;
- }
- xsdo->widget = cdata->widget;
- } else {
- xsdo->widget = NULL;
- }
-#else
xsdo->widget = NULL;
if (peer != NULL) {
xsdo->drawable = JNU_CallMethodByName(env, NULL, peer, "getWindow", "()J").j;
} else {
xsdo->drawable = 0;
}
-#endif
xsdo->depth = depth;
xsdo->dgaAvailable = dgaAvailable;
xsdo->isPixmap = JNI_FALSE;
@@ -775,14 +753,6 @@
if (xsdo->isPixmap == JNI_TRUE) {
return SD_FAILURE;
}
-#ifndef XAWT
- if (!XtIsRealized(xsdo->widget)) {
- J2dTraceLn(J2D_TRACE_WARNING, "X11SD_InitWindow: widget is unrealized");
- /* AWT_UNLOCK(); unlock it in caller */
- return SD_FAILURE;
- }
- xsdo->drawable = XtWindow(xsdo->widget);
-#endif
xsdo->cData = xsdo->configData->color_data;
return SD_SUCCESS;
@@ -804,9 +774,7 @@
SurfaceData_ThrowInvalidPipeException(env, "bounds changed");
return SD_FAILURE;
}
-#ifdef XAWT
xsdo->cData = xsdo->configData->color_data;
-#endif
if (xsdo->drawable == 0 && X11SD_InitWindow(env, xsdo) == SD_FAILURE) {
AWT_UNLOCK();
return SD_FAILURE;
@@ -1081,30 +1049,6 @@
int tmpx, tmpy;
Window tmpchild;
-#ifndef XAWT
- Widget w = xsdo->widget;
-
- x1 = y1 = 0;
- for (; w != NULL && ! XtIsShell(w); w = w->core.parent) {
- x1 += w->core.x + w->core.border_width;
- y1 += w->core.y + w->core.border_width;
- }
- if (w == NULL) {
- return FALSE;
- }
-
- /*
- * REMIND: We should not be offsetting here by border_width
- * but for some unknown reason if we do not do that the
- * results will be off exactly by border_width. We were unable
- * to find cause of this.
- */
- (void) XTranslateCoordinates(XtDisplay(w), XtWindow(w),
- RootWindowOfScreen(XtScreen(w)),
- (int) w->core.border_width,
- (int) w->core.border_width,
- &tmpx, &tmpy, &tmpchild);
-#else
Window window = (Window)(xsdo->drawable); /* is always a Window */
XWindowAttributes winAttr;
@@ -1118,7 +1062,6 @@
0, 0, &tmpx, &tmpy, &tmpchild)) {
return FALSE;
}
-#endif
x1 = -(x1 + tmpx);
y1 = -(y1 + tmpy);
@@ -1150,89 +1093,6 @@
static int
X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds, X11SDOps *xsdo)
{
-#ifndef XAWT
- int x1, y1, x2, y2, px1, py1, px2, py2, child_x, child_y;
- Widget current_widget, child_widget;
-
- XWindowAttributes attr;
- Window ignore_root, current_window, *ignore_children;
- unsigned int pborder, ignore_uint;
-
- x1 = bounds->x1;
- y1 = bounds->y1;
- x2 = bounds->x2;
- y2 = bounds->y2;
-
- px1 = py1 = 0;
-
- child_widget = xsdo->widget;
- current_widget = XtParent(xsdo->widget);
- while (current_widget != NULL && !XtIsShell(current_widget)) {
- px1 = px1 - (child_widget->core.x + child_widget->core.border_width);
- py1 = py1 - (child_widget->core.y + child_widget->core.border_width);
- px2 = px1 + current_widget->core.width;
- py2 = py1 + current_widget->core.height;
- x1 = MAX(x1, px1);
- y1 = MAX(y1, py1);
- x2 = MIN(x2, px2);
- y2 = MIN(y2, py2);
- if ((x1 >= x2) || (y1 >= y2)) {
- return FALSE;
- }
-
- child_widget = current_widget;
- current_widget = current_widget->core.parent;
- }
-
- if (current_widget == NULL) {
- XQueryTree(awt_display,
- XtWindow(child_widget),
- &ignore_root,
- ¤t_window,
- &ignore_children,
- &ignore_uint);
- XFree(ignore_children);
- } else {
- current_window = XtWindow(current_widget);
- }
-
- child_x = child_widget->core.x + child_widget->core.border_width;
- child_y = child_widget->core.y + child_widget->core.border_width;
- while (current_window != 0) {
- px1 = px1 - child_x;
- py1 = py1 - child_y;
- if (!XGetGeometry(awt_display, current_window, &ignore_root,
- &child_x, &child_y,
- (unsigned int *)&px2, (unsigned int *)&py2,
- &pborder, &ignore_uint)) {
- return FALSE;
- }
- child_x += pborder;
- child_y += pborder;
- px2 += px1;
- py2 += py1;
-
- x1 = MAX(x1, px1);
- y1 = MAX(y1, py1);
- x2 = MIN(x2, px2);
- y2 = MIN(y2, py2);
- if ((x1 >= x2) || (y1 >= y2)) {
- return FALSE;
- }
- XQueryTree(awt_display,
- current_window,
- &ignore_root,
- ¤t_window,
- &ignore_children,
- &ignore_uint);
- XFree(ignore_children);
- }
-
- b->x1 = x1;
- b->y1 = y1;
- b->x2 = x2;
- b->y2 = y2;
-#endif
return TRUE;
}
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h Thu Dec 15 19:52:13 2011 -0800
@@ -30,6 +30,10 @@
#include <jdga.h>
+#ifdef HEADLESS
+#include "GLXGraphicsConfig.h"
+#endif
+
#include <X11/extensions/Xrender.h>
/**
--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c Thu Dec 15 19:52:13 2011 -0800
@@ -39,7 +39,6 @@
#include "awt_p.h"
#include "awt_Component.h"
#include "awt_MenuComponent.h"
-#include "awt_KeyboardFocusManager.h"
#include "awt_Font.h"
#include "sun_awt_X11_XToolkit.h"
@@ -47,6 +46,8 @@
#include "java_awt_TrayIcon.h"
#include <X11/extensions/XTest.h>
+#include <unistd.h>
+
uint32_t awt_NumLockMask = 0;
Boolean awt_ModLockIsShiftLock = False;
@@ -72,19 +73,17 @@
struct MenuComponentIDs menuComponentIDs;
-struct KeyboardFocusManagerIDs keyboardFocusManagerIDs;
-
#ifndef HEADLESS
extern Display* awt_init_Display(JNIEnv *env, jobject this);
-extern struct MFontPeerIDs mFontPeerIDs;
+struct XFontPeerIDs xFontPeerIDs;
JNIEXPORT void JNICALL
Java_sun_awt_X11_XFontPeer_initIDs
(JNIEnv *env, jclass cls)
{
- mFontPeerIDs.xfsname =
+ xFontPeerIDs.xfsname =
(*env)->GetFieldID(env, cls, "xfsname", "Ljava/lang/String;");
}
#endif /* !HEADLESS */
@@ -1087,3 +1086,38 @@
return local_num_buttons;
}
+
+/*
+ * Class: sun_awt_X11_XWindowPeer
+ * Method: getJvmPID
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_sun_awt_X11_XWindowPeer_getJvmPID
+(JNIEnv *env, jclass cls)
+{
+ /* Return the JVM's PID. */
+ return getpid();
+}
+
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 1024 /* Overestimated */
+#endif
+
+/*
+ * Class: sun_awt_X11_XWindowPeer
+ * Method: getLocalHostname
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_sun_awt_X11_XWindowPeer_getLocalHostname
+(JNIEnv *env, jclass cls)
+{
+ /* Return the machine's FQDN. */
+ char hostname[HOST_NAME_MAX + 1];
+ if (gethostname(hostname, HOST_NAME_MAX + 1) == 0) {
+ hostname[HOST_NAME_MAX] = '\0';
+ jstring res = (*env)->NewStringUTF(env, hostname);
+ return res;
+ }
+
+ return (jstring)NULL;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7108598
+ * @summary Container.paint/KeyboardFocusManager.clearMostRecentFocusOwner methods deadlock
+ * @library ../../regtesthelpers
+ * @author Oleg Pekhovskiy
+ * @build Util
+ * @run main/timeout=20 PaintSetEnabledDeadlock
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import test.java.awt.regtesthelpers.Util;
+
+public class PaintSetEnabledDeadlock extends Frame {
+
+ final TestPanel panel;
+ final Button button;
+
+ public static void main(String[] args) {
+ PaintSetEnabledDeadlock frame = new PaintSetEnabledDeadlock();
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+
+ Robot robot = Util.createRobot();
+ robot.setAutoDelay(100);
+ robot.setAutoWaitForIdle(true);
+
+ for (int i = 0; i < 20; ++i) {
+ Util.clickOnComp(frame.panel, robot);
+ Util.clickOnComp(frame.button, robot);
+ }
+
+ frame.panel.stop();
+ frame.dispose();
+
+ System.out.println("Test passed.");
+ }
+
+ public PaintSetEnabledDeadlock() {
+ super("7108598 test");
+ setLayout(new GridLayout(1, 2));
+ addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ panel.stop();
+ System.exit(0);
+ }
+ });
+ panel = new TestPanel();
+ add(panel);
+ button = new Button("Enable");
+ button.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ panel.setEnabled(true);
+ panel.sync();
+ panel.repaint();
+ }
+ });
+ add(button);
+ }
+}
+
+class TestPanel extends Panel implements Runnable {
+
+ Image image = null;
+ Thread thread = null;
+ volatile boolean active = true;
+ final Object sync = new Object();
+ Panel panel = this;
+
+ public TestPanel() {
+ addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ synchronized (panel) {
+ sync();
+ panel.setEnabled(false);
+ }
+ panel.repaint();
+ }
+ });
+ thread = new Thread(this);
+ thread.start();
+ }
+
+ @Override
+ public void paint(Graphics paramGraphics) {
+ synchronized (getTreeLock()) {
+ Rectangle rect = getBounds();
+ if (image == null) {
+ image = createImage(rect.width, rect.height);
+ }
+
+ if (image != null) {
+ paramGraphics.drawImage(image, 0, 0, this);
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ while (active) {
+ try {
+ synchronized (sync) {
+ sync.wait();
+ }
+ } catch (InterruptedException ex) {
+ }
+ if (active) {
+ draw();
+ }
+ }
+ }
+
+ public void stop() {
+ active = false;
+ try {
+ synchronized (sync) {
+ sync.notify();
+ }
+ synchronized (thread) {
+ thread.wait();
+ }
+ } catch (InterruptedException ex) {
+ }
+ }
+
+ public void draw() {
+ synchronized (getTreeLock()) {
+ if (image != null) {
+ Graphics localGraphics = image.getGraphics();
+ Dimension size = getSize();
+ localGraphics.setColor(isEnabled() ? Color.green : Color.red);
+ localGraphics.fillRect(0, 0, size.width, size.height);
+ super.paint(localGraphics);
+ localGraphics.dispose();
+ getTreeLock().notifyAll();
+ }
+ }
+ }
+
+ public void sync() {
+ synchronized (sync) {
+ sync.notify();
+ }
+ }
+}
--- a/jdk/test/java/beans/Beans/6669869/TestDesignTime.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/test/java/beans/Beans/6669869/TestDesignTime.java Thu Dec 15 19:52:13 2011 -0800
@@ -29,7 +29,6 @@
*/
import java.beans.Beans;
-import sun.awt.SunToolkit;
public class TestDesignTime implements Runnable {
public static void main(String[] args) throws InterruptedException {
@@ -44,7 +43,6 @@
}
public void run() {
- SunToolkit.createNewAppContext();
if (Beans.isDesignTime()) {
throw new Error("shared DesignTime property");
}
--- a/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java Thu Dec 15 19:52:13 2011 -0800
@@ -30,7 +30,6 @@
import java.awt.GraphicsEnvironment;
import java.beans.Beans;
-import sun.awt.SunToolkit;
public class TestGuiAvailable implements Runnable {
public static void main(String[] args) throws InterruptedException {
@@ -45,7 +44,6 @@
}
public void run() {
- SunToolkit.createNewAppContext();
if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
throw new Error("shared GuiAvailable property");
}
--- a/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java Thu Dec 15 19:52:13 2011 -0800
@@ -41,8 +41,6 @@
import java.lang.ref.Reference;
import java.lang.reflect.Field;
-import sun.awt.SunToolkit;
-
public class TestBeanInfo implements Runnable {
private static final String[] SEARCH_PATH = { "infos" }; // NON-NLS: package name
@@ -81,9 +79,6 @@
private boolean passed;
public void run() {
- if (this.passed) {
- SunToolkit.createNewAppContext();
- }
Introspector.flushCaches();
test(FirstBean.class, FirstBeanBeanInfo.class);
@@ -98,7 +93,5 @@
test(SecondBean.class, SecondBeanBeanInfo.class);
test(ThirdBean.class, null);
test(ThirdBeanBeanInfo.class, ThirdBeanBeanInfo.class);
-
- this.passed = true;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/7064279/Test7064279.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7064279
+ * @summary Tests that Introspector does not have strong references to context class loader
+ * @author Sergey Malenkov
+ */
+
+import java.beans.Introspector;
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+public class Test7064279 {
+
+ public static void main(String[] args) throws Exception {
+ WeakReference ref = new WeakReference(test("test.jar", "test.Test"));
+ try {
+ int[] array = new int[1024];
+ while (true) {
+ array = new int[array.length << 1];
+ }
+ }
+ catch (OutOfMemoryError error) {
+ System.gc();
+ }
+ if (null != ref.get()) {
+ throw new Error("ClassLoader is not released");
+ }
+ }
+
+ private static Object test(String jarName, String className) throws Exception {
+ StringBuilder sb = new StringBuilder(256);
+ sb.append("file:");
+ sb.append(System.getProperty("test.src", "."));
+ sb.append(File.separatorChar);
+ sb.append(jarName);
+
+ ClassLoader newLoader = new URLClassLoader(new URL[] { new URL(sb.toString()) });
+ ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+
+ Thread.currentThread().setContextClassLoader(newLoader);
+ test(newLoader.loadClass(className));
+ Thread.currentThread().setContextClassLoader(oldLoader);
+
+ return newLoader;
+ }
+
+ private static void test(Class type) throws Exception {
+ Introspector.getBeanInfo(type);
+ }
+}
Binary file jdk/test/java/beans/Introspector/7064279/test.jar has changed
--- a/jdk/test/java/beans/Introspector/Test6660539.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/test/java/beans/Introspector/Test6660539.java Thu Dec 15 19:52:13 2011 -0800
@@ -28,8 +28,6 @@
* @author Sergey Malenkov
*/
-import sun.awt.SunToolkit;
-
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
@@ -49,7 +47,6 @@
}
public void run() {
- SunToolkit.createNewAppContext();
for (PropertyDescriptor pd : getPropertyDescriptors()) {
if (pd.getDisplayName().equals(NAME))
throw new Error("shared BeanInfo cache");
--- a/jdk/test/java/beans/Introspector/TestTypeResolver.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/test/java/beans/Introspector/TestTypeResolver.java Thu Dec 15 19:52:13 2011 -0800
@@ -29,6 +29,7 @@
import com.sun.beans.TypeResolver;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Method;
@@ -170,6 +171,22 @@
public int hashCode() {
return hash(name) ^ hash(gd) ^ Arrays.hashCode(bounds);
}
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+ return false; // not used
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+ return null; // not used
+ }
+
+ public Annotation[] getAnnotations() {
+ return null; // not used
+ }
+
+ public Annotation[] getDeclaredAnnotations() {
+ return null; // not used
+ }
}
private static class ClassTypeVariable extends TypeVariableImpl<Class<?>> {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyChangeSupport/Test7087429.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7087429
+ * @summary Tests IllegalArgumentException from the PropertyChangeEvent constructor
+ * @author Sergey Malenkov
+ */
+
+import java.beans.PropertyChangeEvent;
+
+public final class Test7087429 {
+ public static void main(String[] args) {
+ try {
+ new PropertyChangeEvent(null, null, null, null);
+ }
+ catch (IllegalArgumentException exception) {
+ if (exception.getMessage().equals("null source")) {
+ return;
+ }
+ }
+ throw new Error("IllegalArgumentException expected");
+ }
+}
--- a/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java Thu Dec 15 19:52:13 2011 -0800
@@ -36,7 +36,6 @@
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
-import sun.awt.SunToolkit;
import sun.beans.editors.BooleanEditor;
import sun.beans.editors.ByteEditor;
import sun.beans.editors.ColorEditor;
@@ -77,12 +76,7 @@
}
}
- private boolean passed;
-
public void run() {
- if (this.passed) {
- SunToolkit.createNewAppContext();
- }
PropertyEditorManager.registerEditor(ThirdBean.class, ThirdBeanEditor.class);
test(FirstBean.class, FirstBeanEditor.class);
@@ -135,7 +129,5 @@
test(Color.class, null);
test(Font.class, null);
test(Enumeration.class, EnumEditor.class);
-
- this.passed = true;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyEditor/Test7087876.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7087876
+ * @summary Tests spec of the createPropertyEditor method
+ * @author Sergey Malenkov
+ */
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.beans.PropertyEditorSupport;
+
+public class Test7087876 {
+
+ public static void main(String[] args) throws IntrospectionException {
+ PropertyDescriptor pd = new PropertyDescriptor("value", Bean.class);
+ pd.setPropertyEditorClass(Editor.class);
+ pd.createPropertyEditor(new Bean());
+ }
+
+ public static class Bean {
+ private String value;
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+
+ public static class Editor extends PropertyEditorSupport {
+ private Editor() {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/Test7092744.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7092744
+ * @summary Tests for ambiguous methods
+ * @author Sergey Malenkov
+ */
+
+public class Test7092744 extends AbstractTest {
+
+ public static void main(String[] args) {
+ new Test7092744().test(true);
+ }
+
+ protected Object getObject() {
+ return new Bean();
+ }
+
+ protected Object getAnotherObject() {
+ Bean bean = new Bean();
+ bean.setValue(99);
+ return bean;
+ }
+
+ public static interface I<T extends Number> {
+
+ T getValue();
+
+ void setValue(T value);
+ }
+
+ public static class Bean implements I<Integer> {
+
+ private Integer value;
+
+ public Integer getValue() {
+ return this.value;
+ }
+
+ public void setValue(Integer value) {
+ this.value = value;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4865918
+ * @summary REGRESSION:JCK1.4a-runtime api/javax_swing/interactive/JScrollBarTests.html#JScrollBar
+ * @author Andrey Pikalev
+ * @run main bug4865918
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import sun.awt.SunToolkit;
+
+public class bug4865918 {
+
+ private static TestScrollBar sbar;
+
+ public static void main(String[] argv) throws Exception {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+
+ toolkit.realSync();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ sbar.pressMouse();
+ }
+ });
+
+ toolkit.realSync();
+
+ int value = getValue();
+
+ if (value != 9) {
+ throw new Error("The scrollbar block increment is incorect");
+ }
+ }
+
+ private static int getValue() throws Exception {
+ final int[] result = new int[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result[0] = sbar.getValue();
+ }
+ });
+
+ return result[0];
+ }
+
+ private static void createAndShowGUI() {
+ JFrame frame = new JFrame("bug4865918");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ sbar = new TestScrollBar(JScrollBar.HORIZONTAL, -1, 10, -100, 100);
+ sbar.setPreferredSize(new Dimension(200, 20));
+ sbar.setBlockIncrement(10);
+
+ frame.getContentPane().add(sbar);
+ frame.pack();
+ frame.setVisible(true);
+
+ }
+
+ static class TestScrollBar extends JScrollBar {
+
+ public TestScrollBar(int orientation, int value, int extent,
+ int min, int max) {
+ super(orientation, value, extent, min, max);
+
+ }
+
+ public void pressMouse() {
+ MouseEvent me = new MouseEvent(sbar,
+ MouseEvent.MOUSE_PRESSED,
+ (new Date()).getTime(),
+ MouseEvent.BUTTON1_MASK,
+ 3 * getWidth() / 4, getHeight() / 2,
+ 1, true);
+ processMouseEvent(me);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4624207
+ * @summary JTabbedPane mnemonics don't work from outside the tabbed pane
+ * @author Oleg Mokhovikov
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main bug4624207
+ */
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import java.awt.*;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
+import sun.awt.SunToolkit;
+
+public class bug4624207 implements ChangeListener, FocusListener {
+
+ private static volatile boolean stateChanged = false;
+ private static volatile boolean focusGained = false;
+ private static JTextField txtField;
+ private static JTabbedPane tab;
+ private static Object listener;
+
+ public void stateChanged(ChangeEvent e) {
+ System.out.println("stateChanged called");
+ stateChanged = true;
+ }
+
+ public void focusGained(FocusEvent e) {
+ System.out.println("focusGained called");
+ focusGained = true;
+ }
+
+ public void focusLost(FocusEvent e) {
+ System.out.println("focusLost called");
+ focusGained = false;
+ }
+
+ public static void main(String[] args) throws Exception {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+
+ toolkit.realSync();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ txtField.requestFocus();
+ }
+ });
+
+ toolkit.realSync();
+
+ if (!focusGained) {
+ throw new RuntimeException("Couldn't gain focus for text field");
+ }
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ tab.addChangeListener((ChangeListener) listener);
+ txtField.removeFocusListener((FocusListener) listener);
+ }
+ });
+
+ toolkit.realSync();
+
+ if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
+ Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
+ } else {
+ Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
+ }
+
+ toolkit.realSync();
+
+ if (!stateChanged || tab.getSelectedIndex() != 1) {
+ throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
+ }
+ }
+
+ private static void createAndShowGUI() {
+ tab = new JTabbedPane();
+ tab.add("Tab1", new JButton("Button1"));
+ tab.add("Tab2", new JButton("Button2"));
+ tab.setMnemonicAt(0, KeyEvent.VK_T);
+ tab.setMnemonicAt(1, KeyEvent.VK_B);
+
+ JFrame frame = new JFrame();
+ frame.getContentPane().add(tab, BorderLayout.CENTER);
+ txtField = new JTextField();
+ frame.getContentPane().add(txtField, BorderLayout.NORTH);
+ listener = new bug4624207();
+ txtField.addFocusListener((FocusListener) listener);
+ frame.pack();
+ frame.setVisible(true);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTable/6263446/bug6263446.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6263446
+ * @summary Tests that double-clicking to edit a cell doesn't select the content.
+ * @author Shannon Hickey
+ * @run main bug6263446
+ */
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.table.*;
+import sun.awt.SunToolkit;
+
+public class bug6263446 {
+
+ private static JTable table;
+ private static final String FIRST = "AAAAA";
+ private static final String SECOND = "BB";
+ private static final String ALL = FIRST + " " + SECOND;
+ private static Robot robot;
+
+ public static void main(String[] args) throws Exception {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ robot = new Robot();
+ robot.setAutoDelay(50);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+
+
+ toolkit.realSync();
+
+ Point point = getClickPoint();
+ robot.mouseMove(point.x, point.y);
+ toolkit.realSync();
+
+ click(1);
+ toolkit.realSync();
+ assertEditing(false);
+
+ click(2);
+ toolkit.realSync();
+ checkSelectedText(null);
+
+ click(3);
+ toolkit.realSync();
+ checkSelectedText(FIRST);
+
+
+ click(4);
+ toolkit.realSync();
+ checkSelectedText(ALL);
+
+ setClickCountToStart(1);
+
+ click(1);
+ toolkit.realSync();
+ checkSelectedText(null);
+
+ click(2);
+ toolkit.realSync();
+ checkSelectedText(FIRST);
+
+ click(3);
+ toolkit.realSync();
+ checkSelectedText(ALL);
+
+ setClickCountToStart(3);
+
+ click(1);
+ toolkit.realSync();
+ assertEditing(false);
+
+ click(2);
+ toolkit.realSync();
+ assertEditing(false);
+
+ click(3);
+ toolkit.realSync();
+ checkSelectedText(null);
+
+ click(4);
+ toolkit.realSync();
+ checkSelectedText(FIRST);
+
+ click(5);
+ toolkit.realSync();
+ checkSelectedText(ALL);
+
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ table.editCellAt(0, 0);
+ }
+ });
+
+ toolkit.realSync();
+ assertEditing(true);
+
+ click(2);
+ toolkit.realSync();
+ checkSelectedText(FIRST);
+
+ }
+
+ private static void checkSelectedText(String sel) throws Exception {
+ assertEditing(true);
+ checkSelection(sel);
+ cancelCellEditing();
+ assertEditing(false);
+ }
+
+ private static void setClickCountToStart(final int clicks) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ DefaultCellEditor editor =
+ (DefaultCellEditor) table.getDefaultEditor(String.class);
+ editor.setClickCountToStart(clicks);
+ }
+ });
+
+ }
+
+ private static void cancelCellEditing() throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ table.getCellEditor().cancelCellEditing();
+ }
+ });
+ }
+
+ private static void checkSelection(final String sel) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ DefaultCellEditor editor =
+ (DefaultCellEditor) table.getDefaultEditor(String.class);
+ JTextField field = (JTextField) editor.getComponent();
+ String text = field.getSelectedText();
+ if (sel == null) {
+ if (text != null && text.length() != 0) {
+ throw new RuntimeException("Nothing should be selected,"
+ + " but \"" + text + "\" is selected.");
+ }
+ } else if (!sel.equals(text)) {
+ throw new RuntimeException("\"" + sel + "\" should be "
+ + "selected, but \"" + text + "\" is selected.");
+ }
+ }
+ });
+ }
+
+ private static void assertEditing(final boolean editing) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ if (editing && !table.isEditing()) {
+ throw new RuntimeException("Table should be editing");
+ }
+ if (!editing && table.isEditing()) {
+ throw new RuntimeException("Table should not be editing");
+ }
+ }
+ });
+ }
+
+ private static Point getClickPoint() throws Exception {
+ final Point[] result = new Point[1];
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ Rectangle rect = table.getCellRect(0, 0, false);
+ Point point = new Point(rect.x + rect.width / 5,
+ rect.y + rect.height / 2);
+ SwingUtilities.convertPointToScreen(point, table);
+ result[0] = point;
+ }
+ });
+
+ return result[0];
+ }
+
+ private static void click(int times) {
+ robot.delay(500);
+ for (int i = 0; i < times; i++) {
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+ }
+
+ private static TableModel createTableModel() {
+ String[] columnNames = {"Column 0"};
+ String[][] data = {{ALL}};
+
+ return new DefaultTableModel(data, columnNames);
+ }
+
+ private static void createAndShowGUI() {
+ JFrame frame = new JFrame("bug6263446");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ table = new JTable(createTableModel());
+ frame.add(table);
+ frame.pack();
+ frame.setVisible(true);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6276087
+ * @author Romain Guy
+ * @summary Tests opacity of a popup menu.
+ */
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import sun.awt.SunToolkit;
+
+public class NonOpaquePopupMenuTest extends JFrame {
+
+ private static JMenu fileMenu;
+
+ public NonOpaquePopupMenuTest() {
+ getContentPane().setBackground(java.awt.Color.RED);
+ JMenuBar menuBar = new JMenuBar();
+ fileMenu = new JMenu("File");
+ JMenuItem menuItem = new JMenuItem("New");
+ menuBar.add(fileMenu);
+ setJMenuBar(menuBar);
+
+ fileMenu.add(menuItem);
+ fileMenu.getPopupMenu().setOpaque(false);
+
+ setSize(new Dimension(640, 480));
+ setVisible(true);
+ }
+
+ public static void main(String[] args) throws Throwable {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
+ robot.setAutoDelay(250);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ new NonOpaquePopupMenuTest();
+ }
+ });
+
+ toolkit.realSync();
+
+ Point p = getMenuClickPoint();
+ robot.mouseMove(p.x, p.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+
+ toolkit.realSync();
+
+ if (isParentOpaque()) {
+ throw new RuntimeException("Popup menu parent is opaque");
+ }
+
+ }
+
+ private static boolean isParentOpaque() throws Exception {
+ final boolean result[] = new boolean[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ result[0] = fileMenu.getPopupMenu().getParent().isOpaque();
+ }
+ });
+
+ return result[0];
+ }
+
+ private static Point getMenuClickPoint() throws Exception {
+ final Point[] result = new Point[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ Point p = fileMenu.getLocationOnScreen();
+ Dimension size = fileMenu.getSize();
+
+ result[0] = new Point(p.x + size.width / 2,
+ p.y + size.height / 2);
+ }
+ });
+
+ return result[0];
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/metal/MetalLookAndFeel/5073047/bug5073047.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 5073407
+ * @summary Tests 5073407
+ * @author Scott Violet
+ */
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.metal.*;
+
+public class bug5073047 {
+
+ public static void main(String[] args) throws Exception{
+ MyTheme theme = new MyTheme();
+ MetalLookAndFeel.setCurrentTheme(theme);
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ if (UIManager.get("Button.font") != theme.ctf) {
+ throw new RuntimeException("Unexpected font");
+ }
+ }
+
+ private static class MyTheme extends DefaultMetalTheme {
+ public final FontUIResource ctf = new FontUIResource(
+ super.getControlTextFont().deriveFont(40.0f));
+ public FontUIResource getControlTextFont() {
+ return ctf;
+ }
+ }
+}
--- a/jdk/test/javax/swing/regtesthelpers/Util.java Tue Dec 13 15:41:47 2011 -0800
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java Thu Dec 15 19:52:13 2011 -0800
@@ -140,4 +140,17 @@
return null;
}
+
+ /**
+ * Hits keys by robot.
+ */
+ public static void hitKeys(Robot robot, int... keys) {
+ for (int i = 0; i < keys.length; i++) {
+ robot.keyPress(keys[i]);
+ }
+
+ for (int i = keys.length - 1; i >= 0; i--) {
+ robot.keyRelease(keys[i]);
+ }
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/DefaultCaret/6938583/bug6938583.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Portions Copyright (c) 2011 IBM Corporation
+ */
+
+/*
+ * @test
+ * @bug 6938583
+ * @summary Unexpected NullPointerException when use CodeIM demo on windows
+ * @author LittleE
+ */
+
+import javax.swing.*;
+import javax.swing.text.DefaultCaret;
+import java.awt.event.MouseEvent;
+
+public class bug6938583 {
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ JTextArea jta = new JTextArea();
+ DefaultCaret dc = new DefaultCaret();
+ jta.setCaret(dc);
+ dc.deinstall(jta);
+ dc.mouseClicked(new MouseEvent(jta, MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, 0, false));
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test Jan 16, 2003
+ * @bug 4278839
+ * @summary Incorrect cursor movement between words at the end of line
+ * @author Anton Nashatyrev
+ * @library ../../../regtesthelpers
+ * @build Util
+ * @run main bug4278839
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import sun.awt.SunToolkit;
+
+public class bug4278839 extends JFrame {
+
+ private static boolean passed = true;
+ private static JTextArea area;
+ private static Robot robo;
+ private static SunToolkit toolkit;
+
+ public static void main(String[] args) {
+ try {
+
+ toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ robo = new Robot();
+ robo.setAutoDelay(100);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+
+ toolkit.realSync();
+
+ clickMouse();
+ toolkit.realSync();
+
+
+ if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
+ Util.hitKeys(robo, KeyEvent.VK_HOME);
+ } else {
+ Util.hitKeys(robo, KeyEvent.VK_CONTROL, KeyEvent.VK_HOME);
+ }
+ toolkit.realSync();
+
+ passed &= moveCaret(true) == 1;
+ passed &= moveCaret(true) == 5;
+ passed &= moveCaret(true) == 8;
+ passed &= moveCaret(true) == 9;
+ passed &= moveCaret(true) == 13;
+ passed &= moveCaret(true) == 16;
+ passed &= moveCaret(true) == 17;
+ passed &= moveCaret(false) == 16;
+ passed &= moveCaret(false) == 13;
+ passed &= moveCaret(false) == 9;
+ passed &= moveCaret(false) == 8;
+ passed &= moveCaret(false) == 5;
+ passed &= moveCaret(false) == 1;
+ passed &= moveCaret(false) == 0;
+
+ } catch (Exception e) {
+ throw new RuntimeException("Test failed because of an exception:",
+ e);
+ }
+
+ if (!passed) {
+ throw new RuntimeException("Test failed.");
+ }
+ }
+
+ private static int moveCaret(boolean right) throws Exception {
+ Util.hitKeys(robo, getCtrlKey(),
+ right ? KeyEvent.VK_RIGHT : KeyEvent.VK_LEFT);
+ toolkit.realSync();
+
+ final int[] result = new int[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ result[0] = area.getCaretPosition();
+ }
+ });
+
+ int pos = result[0];
+ return pos;
+ }
+
+ private static void clickMouse() throws Exception {
+ final Rectangle result[] = new Rectangle[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result[0] = new Rectangle(area.getLocationOnScreen(), area.getSize());
+ }
+ });
+
+ Rectangle rect = result[0];
+
+ robo.mouseMove(rect.x + rect.width / 2, rect.y + rect.width / 2);
+ robo.mousePress(InputEvent.BUTTON1_MASK);
+ }
+
+ /**
+ * Gets a control key related to the used Look & Feel
+ * Returns VK_ALT for Aqua and VK_CONTROL for others
+ */
+ public static int getCtrlKey() {
+
+ if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
+ return KeyEvent.VK_ALT;
+ }
+
+ return KeyEvent.VK_CONTROL;
+ }
+
+ private static void createAndShowGUI() {
+ JFrame frame = new JFrame();
+ frame.setTitle("Bug# 4278839");
+ frame.setSize(200, 200);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ area = new JTextArea("\naaa bbb\nccc ddd\n");
+ frame.getContentPane().add(new JScrollPane(area));
+ frame.setVisible(true);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/JTextComponent/5074573/bug5074573.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 5074573
+ * @summary tests delte-next-word and delete-prev-word actions for all text compnents and all look&feels
+ * @author Igor Kushnirskiy
+ * @run main bug5074573
+ */
+
+import java.util.*;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.text.*;
+import sun.awt.SunToolkit;
+
+public class bug5074573 {
+
+ private static JTextComponent textComponent;
+ final static String testString = "123 456 789";
+ final static String resultString = "456 ";
+ final static List<Class<? extends JTextComponent>> textClasses = Arrays.asList(
+ JTextArea.class, JEditorPane.class, JTextPane.class,
+ JTextField.class, JFormattedTextField.class, JPasswordField.class);
+
+ public static void main(String[] args) throws Exception {
+ for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+ UIManager.setLookAndFeel(info.getClassName());
+ System.out.println(info);
+ for (Class<? extends JTextComponent> clazz : textClasses) {
+ boolean res = test(clazz);
+ if (!res && clazz != JPasswordField.class) {
+ throw new RuntimeException("failed");
+ }
+ }
+ }
+ }
+
+ static boolean test(final Class<? extends JTextComponent> textComponentClass) throws Exception {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
+ robot.setAutoWaitForIdle(true);
+ robot.setAutoDelay(50);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ initialize(textComponentClass);
+ }
+ });
+
+ toolkit.realSync();
+
+ // Remove selection from JTextField components for the Aqua Look & Feel
+ if (textComponent instanceof JTextField && "Aqua".equals(UIManager.getLookAndFeel().getID())) {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ Caret caret = textComponent.getCaret();
+ int dot = caret.getDot();
+ textComponent.select(dot, dot);
+ }
+ });
+
+ toolkit.realSync();
+ }
+
+ robot.keyPress(getCtrlKey());
+ robot.keyPress(KeyEvent.VK_BACK_SPACE);
+ robot.keyRelease(KeyEvent.VK_BACK_SPACE);
+ robot.keyRelease(getCtrlKey());
+ toolkit.realSync();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ Caret caret = textComponent.getCaret();
+ caret.setDot(0);
+ }
+ });
+ toolkit.realSync();
+
+ robot.keyPress(getCtrlKey());
+ robot.keyPress(KeyEvent.VK_DELETE);
+ robot.keyRelease(KeyEvent.VK_DELETE);
+ robot.keyRelease(getCtrlKey());
+ toolkit.realSync();
+
+ return resultString.equals(getText());
+ }
+
+ private static String getText() throws Exception {
+ final String[] result = new String[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result[0] = textComponent.getText();
+ }
+ });
+
+ return result[0];
+ }
+
+ /**
+ * Gets a control key related to the used Look & Feel
+ * Returns VK_ALT for Aqua and VK_CONTROL for others
+ */
+ public static int getCtrlKey() {
+
+ if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
+ return KeyEvent.VK_ALT;
+ }
+
+ return KeyEvent.VK_CONTROL;
+ }
+
+ private static void initialize(Class<? extends JTextComponent> textComponentClass) {
+ try {
+ JFrame frame = new JFrame();
+ textComponent = textComponentClass.newInstance();
+ textComponent.setText(testString);
+ frame.add(textComponent);
+ frame.pack();
+ frame.setVisible(true);
+ textComponent.requestFocus();
+ Caret caret = textComponent.getCaret();
+ caret.setDot(textComponent.getDocument().getLength());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 5043626
+ * @summary Tests pressing Home or Ctrl+Home set cursor to invisible element <head>
+ * @author Alexander Potochkin
+ * @library ../../../../regtesthelpers
+ * @build Util
+ * @run main bug5043626
+ */
+
+import java.awt.Robot;
+import java.awt.Toolkit;
+import javax.swing.*;
+import javax.swing.text.Document;
+import javax.swing.text.BadLocationException;
+import java.awt.event.KeyEvent;
+import sun.awt.SunToolkit;
+
+public class bug5043626 {
+
+ private static Document doc;
+ private static Robot robot;
+
+ public static void main(String[] args) throws Exception {
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ robot = new Robot();
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+
+ toolkit.realSync();
+
+ Util.hitKeys(robot, KeyEvent.VK_HOME);
+ Util.hitKeys(robot, KeyEvent.VK_1);
+
+ toolkit.realSync();
+
+ String test = getText();
+
+ if (!"1test".equals(test)) {
+ throw new RuntimeException("Begin line action set cursor inside <head> tag");
+ }
+
+ Util.hitKeys(robot, KeyEvent.VK_HOME);
+ Util.hitKeys(robot, KeyEvent.VK_2);
+
+ toolkit.realSync();
+
+ test = getText();
+
+ if (!"21test".equals(test)) {
+ throw new RuntimeException("Begin action set cursor inside <head> tag");
+ }
+ }
+
+ private static String getText() throws Exception {
+ final String[] result = new String[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ try {
+ result[0] = doc.getText(0, doc.getLength()).trim();
+ } catch (BadLocationException ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ return result[0];
+ }
+
+ private static void createAndShowGUI() {
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ JEditorPane editorPane = new JEditorPane();
+ editorPane.setContentType("text/html");
+ editorPane.setText("test");
+ editorPane.setEditable(true);
+ frame.add(editorPane);
+ frame.pack();
+ frame.setVisible(true);
+ doc = editorPane.getDocument();
+ editorPane.setCaretPosition(doc.getLength());
+ }
+}
--- a/langtools/.hgtags Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/.hgtags Thu Dec 15 19:52:13 2011 -0800
@@ -136,3 +136,4 @@
f2d6ed25857dfa7f269ac66e13666d648cb988c6 jdk8-b12
ae25163501bc7477cd907e26a006a6f1b05fdb6d jdk8-b13
58f1325d72b2bacc901f5189ee5e4e81e81ea657 jdk8-b14
+07599bd780cab1f40da7915e1dc6774629b0cf8c jdk8-b15
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a lambda expression.
+ *
+ * For example:
+ * <pre>
+ * ()->{}
+ * (List<String> ls)->ls.size()
+ * (x,y)-> { return x + y; }
+ * </pre>
+ */
+public interface LambdaExpressionTree extends ExpressionTree {
+
+ /**
+ * Lambda expressions come in two forms: (i) expression lambdas, whose body
+ * is an expression, and (ii) statement lambdas, whose body is a block
+ */
+ public enum BodyKind {
+ /** enum constant for expression lambdas */
+ EXPRESSION,
+ /** enum constant for statement lambdas */
+ STATEMENT;
+ }
+
+ List<? extends VariableTree> getParameters();
+ Tree getBody();
+ BodyKind getBodyKind();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.tree;
+
+import java.util.List;
+
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for a member reference expression.
+ *
+ * For example:
+ * <pre>
+ * <em>expression</em> # <em>[ identifier | new ]</em>
+ * </pre>
+ *
+ * @see JSR 292
+ */
+public interface MemberReferenceTree extends ExpressionTree {
+
+ /**
+ * There are two kinds of member references: (i) method references and
+ * (ii) constructor references
+ */
+ public enum ReferenceMode {
+ /** enum constant for method references */
+ INVOKE,
+ /** enum constant for constructor references */
+ NEW
+ }
+ ReferenceMode getMode();
+ ExpressionTree getQualifierExpression();
+ Name getName();
+ List<? extends ExpressionTree> getTypeArguments();
+}
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java Thu Dec 15 19:52:13 2011 -0800
@@ -132,6 +132,11 @@
MEMBER_SELECT(MemberSelectTree.class),
/**
+ * Used for instances of {@link MemberReferenceTree}.
+ */
+ MEMBER_REFERENCE(MemberReferenceTree.class),
+
+ /**
* Used for instances of {@link ForLoopTree}.
*/
FOR_LOOP(ForLoopTree.class),
@@ -187,6 +192,11 @@
NEW_CLASS(NewClassTree.class),
/**
+ * Used for instances of {@link LambdaExpressionTree}.
+ */
+ LAMBDA_EXPRESSION(LambdaExpressionTree.class),
+
+ /**
* Used for instances of {@link ParenthesizedTree}.
*/
PARENTHESIZED(ParenthesizedTree.class),
--- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Thu Dec 15 19:52:13 2011 -0800
@@ -85,9 +85,11 @@
R visitModifiers(ModifiersTree node, P p);
R visitNewArray(NewArrayTree node, P p);
R visitNewClass(NewClassTree node, P p);
+ R visitLambdaExpression(LambdaExpressionTree node, P p);
R visitParenthesized(ParenthesizedTree node, P p);
R visitReturn(ReturnTree node, P p);
R visitMemberSelect(MemberSelectTree node, P p);
+ R visitMemberReference(MemberReferenceTree node, P p);
R visitEmptyStatement(EmptyStatementTree node, P p);
R visitSwitch(SwitchTree node, P p);
R visitSynchronized(SynchronizedTree node, P p);
--- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Thu Dec 15 19:52:13 2011 -0800
@@ -172,6 +172,10 @@
return defaultAction(node, p);
}
+ public R visitLambdaExpression(LambdaExpressionTree node, P p) {
+ return defaultAction(node, p);
+ }
+
public R visitParenthesized(ParenthesizedTree node, P p) {
return defaultAction(node, p);
}
@@ -208,6 +212,10 @@
return defaultAction(node, p);
}
+ public R visitMemberReference(MemberReferenceTree node, P p) {
+ return defaultAction(node, p);
+ }
+
public R visitIdentifier(IdentifierTree node, P p) {
return defaultAction(node, p);
}
--- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Thu Dec 15 19:52:13 2011 -0800
@@ -285,6 +285,12 @@
return r;
}
+ public R visitLambdaExpression(LambdaExpressionTree node, P p) {
+ R r = scan(node.getParameters(), p);
+ r = scanAndReduce(node.getBody(), p, r);
+ return r;
+ }
+
public R visitParenthesized(ParenthesizedTree node, P p) {
return scan(node.getExpression(), p);
}
@@ -333,6 +339,12 @@
return scan(node.getExpression(), p);
}
+ public R visitMemberReference(MemberReferenceTree node, P p) {
+ R r = scan(node.getQualifierExpression(), p);
+ r = scanAndReduce(node.getTypeArguments(), p, r);
+ return r;
+ }
+
public R visitIdentifier(IdentifierTree node, P p) {
return null;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Thu Dec 15 19:52:13 2011 -0800
@@ -194,6 +194,12 @@
public boolean allowObjectToPrimitiveCast() {
return compareTo(JDK1_7) >= 0;
}
+ public boolean allowLambda() {
+ return compareTo(JDK1_8) >= 0;
+ }
+ public boolean allowMethodReferences() {
+ return compareTo(JDK1_8) >= 0;
+ }
public static SourceVersion toSourceVersion(Source source) {
switch(source) {
case JDK1_2:
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Dec 15 19:52:13 2011 -0800
@@ -1975,6 +1975,16 @@
result = check(tree, owntype, VAL, pkind, pt);
}
+ @Override
+ public void visitLambda(JCLambda that) {
+ throw new UnsupportedOperationException("Lambda expression not supported yet");
+ }
+
+ @Override
+ public void visitReference(JCMemberReference that) {
+ throw new UnsupportedOperationException("Member references not supported yet");
+ }
+
public void visitParens(JCParens tree) {
Type owntype = attribTree(tree.expr, env, pkind, pt);
result = check(tree, owntype, pkind, pkind, pt);
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Thu Dec 15 19:52:13 2011 -0800
@@ -637,6 +637,10 @@
lexError(pos, "unclosed.str.lit");
}
break loop;
+ case '#':
+ reader.scanChar();
+ tk = TokenKind.HASH;
+ break loop;
default:
if (isSpecial(reader.ch)) {
scanOperator();
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Dec 15 19:52:13 2011 -0800
@@ -27,6 +27,8 @@
import java.util.*;
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
+
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.parser.Tokens.*;
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
@@ -110,6 +112,10 @@
this.allowDiamond = source.allowDiamond();
this.allowMulticatch = source.allowMulticatch();
this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true);
+ this.allowLambda = source.allowLambda() &&
+ fac.options.isSet("allowLambda");
+ this.allowMethodReferences = source.allowMethodReferences() &&
+ fac.options.isSet("allowMethodReferences");
this.keepDocComments = keepDocComments;
docComments = keepDocComments ? new HashMap<JCTree,String>() : null;
this.keepLineMap = keepLineMap;
@@ -166,6 +172,14 @@
*/
boolean allowStringFolding;
+ /** Switch: should we recognize lambda expressions?
+ */
+ boolean allowLambda;
+
+ /** Switch: should we allow method/constructor references?
+ */
+ boolean allowMethodReferences;
+
/** Switch: should we keep docComments?
*/
boolean keepDocComments;
@@ -203,6 +217,30 @@
token = S.token();
}
+ protected boolean peekToken(TokenKind tk) {
+ return S.token(1).kind == tk;
+ }
+
+ protected boolean peekToken(TokenKind tk1, TokenKind tk2) {
+ return S.token(1).kind == tk1 &&
+ S.token(2).kind == tk2;
+ }
+
+ protected boolean peekToken(TokenKind tk1, TokenKind tk2, TokenKind tk3) {
+ return S.token(1).kind == tk1 &&
+ S.token(2).kind == tk2 &&
+ S.token(3).kind == tk3;
+ }
+
+ protected boolean peekToken(TokenKind... kinds) {
+ for (int lookahead = 0 ; lookahead < kinds.length ; lookahead++) {
+ if (S.token(lookahead + 1).kind != kinds[lookahead]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
/* ---------- error recovery -------------- */
private JCErroneous errorTree;
@@ -749,7 +787,7 @@
top++;
topOp = token;
nextToken();
- odStack[top] = (topOp.kind == INSTANCEOF) ? parseType() : term3();
+ odStack[top] = (topOp.kind == INSTANCEOF) ? parseType() : term3NoParams();
while (top > 0 && prec(topOp.kind) >= prec(token.kind)) {
odStack[top-1] = makeOp(topOp.pos, topOp.kind, odStack[top-1],
odStack[top]);
@@ -849,7 +887,10 @@
* | [TypeArguments] THIS [Arguments]
* | [TypeArguments] SUPER SuperSuffix
* | NEW [TypeArguments] Creator
+ * | "(" Arguments ")" "->" ( Expression | Block )
+ * | Ident "->" ( Expression | Block )
* | Ident { "." Ident }
+ * | Expression3 MemberReferenceSuffix
* [ "[" ( "]" BracketsOpt "." CLASS | Expression "]" )
* | Arguments
* | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator )
@@ -890,60 +931,87 @@
mode = EXPR;
t = literal(names.hyphen, pos);
} else {
- t = term3();
+ t = term3NoParams();
return F.at(pos).Unary(unoptag(tk), t);
}
} else return illegal();
break;
case LPAREN:
if (typeArgs == null && (mode & EXPR) != 0) {
- nextToken();
- mode = EXPR | TYPE | NOPARAMS;
- t = term3();
- if ((mode & TYPE) != 0 && token.kind == LT) {
- // Could be a cast to a parameterized type
- JCTree.Tag op = JCTree.Tag.LT;
- int pos1 = token.pos;
+ if (peekToken(FINAL) ||
+ peekToken(RPAREN) ||
+ peekToken(IDENTIFIER, COMMA) ||
+ peekToken(IDENTIFIER, RPAREN, ARROW)) {
+ //implicit n-ary lambda
+ t = lambdaExpressionOrStatement(true, peekToken(FINAL), pos);
+ break;
+ } else {
nextToken();
- mode &= (EXPR | TYPE);
- mode |= TYPEARG;
- JCExpression t1 = term3();
- if ((mode & TYPE) != 0 &&
- (token.kind == COMMA || token.kind == GT)) {
- mode = TYPE;
- ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
- args.append(t1);
- while (token.kind == COMMA) {
+ mode = EXPR | TYPE;
+ t = term3NoParams();
+ if ((mode & TYPE) != 0 && token.kind == LT) {
+ // Could be a cast to a parameterized type
+ JCTree.Tag op = JCTree.Tag.LT;
+ int pos1 = token.pos;
+ nextToken();
+ mode &= (EXPR | TYPE);
+ mode |= TYPEARG;
+ JCExpression t1 = term3();
+ if ((mode & TYPE) != 0 &&
+ (token.kind == COMMA || token.kind == GT)) {
+ mode = TYPE;
+ ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
+ args.append(t1);
+ while (token.kind == COMMA) {
+ nextToken();
+ args.append(typeArgument());
+ }
+ accept(GT);
+ t = toP(F.at(pos1).TypeApply(t, args.toList()));
+ checkGenerics();
+ mode = EXPR | TYPE; //could be a lambda or a method ref or a cast to a type
+ t = term3Rest(t, typeArgs);
+ if (token.kind == IDENTIFIER || token.kind == ELLIPSIS) {
+ //explicit lambda (w/ generic type)
+ mode = EXPR;
+ JCModifiers mods = F.at(token.pos).Modifiers(Flags.PARAMETER);
+ if (token.kind == ELLIPSIS) {
+ mods.flags = Flags.VARARGS;
+ t = to(F.at(token.pos).TypeArray(t));
+ nextToken();
+ }
+ t = lambdaExpressionOrStatement(variableDeclaratorId(mods, t), pos);
+ break;
+ }
+ } else {
+ Assert.check((mode & EXPR) != 0);
+ mode = EXPR;
+ JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
+ t = F.at(pos1).Binary(op, t, e);
+ t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
+ }
+ } else if ((mode & TYPE) != 0 &&
+ (token.kind == IDENTIFIER || token.kind == ELLIPSIS)) {
+ //explicit lambda (w/ non-generic type)
+ mode = EXPR;
+ JCModifiers mods = F.at(token.pos).Modifiers(Flags.PARAMETER);
+ if (token.kind == ELLIPSIS) {
+ mods.flags = Flags.VARARGS;
+ t = to(F.at(token.pos).TypeArray(t));
nextToken();
- args.append(typeArgument());
}
- accept(GT);
- t = toP(F.at(pos1).TypeApply(t, args.toList()));
- checkGenerics();
- while (token.kind == DOT) {
- nextToken();
- mode = TYPE;
- t = toP(F.at(token.pos).Select(t, ident()));
- t = typeArgumentsOpt(t);
- }
- t = bracketsOpt(toP(t));
- } else if ((mode & EXPR) != 0) {
- mode = EXPR;
- JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
- t = F.at(pos1).Binary(op, t, e);
+ t = lambdaExpressionOrStatement(variableDeclaratorId(mods, t), pos);
+ break;
+ } else {
t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
- } else {
- accept(GT);
}
}
- else {
- t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
- }
+
accept(RPAREN);
lastmode = mode;
mode = EXPR;
if ((lastmode & EXPR) == 0) {
- JCExpression t1 = term3();
+ JCExpression t1 = term3NoParams();
return F.at(pos).TypeCast(t, t1);
} else if ((lastmode & TYPE) != 0) {
switch (token.kind) {
@@ -953,14 +1021,16 @@
case INTLITERAL: case LONGLITERAL: case FLOATLITERAL:
case DOUBLELITERAL: case CHARLITERAL: case STRINGLITERAL:
case TRUE: case FALSE: case NULL:
- case NEW: case IDENTIFIER: case ASSERT: case ENUM:
+ case NEW: case IDENTIFIER: case ASSERT: case ENUM:
case BYTE: case SHORT: case CHAR: case INT:
case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case VOID:
- JCExpression t1 = term3();
+ JCExpression t1 = term3NoParams();
return F.at(pos).TypeCast(t, t1);
}
}
- } else return illegal();
+ } else {
+ return illegal();
+ }
t = toP(F.at(pos).Parens(t));
break;
case THIS:
@@ -1003,75 +1073,122 @@
break;
case IDENTIFIER: case ASSERT: case ENUM:
if (typeArgs != null) return illegal();
- t = toP(F.at(token.pos).Ident(ident()));
- loop: while (true) {
- pos = token.pos;
- switch (token.kind) {
- case LBRACKET:
- nextToken();
- if (token.kind == RBRACKET) {
+ if ((mode & EXPR) != 0 && peekToken(ARROW)) {
+ t = lambdaExpressionOrStatement(false, false, pos);
+ } else {
+ t = toP(F.at(token.pos).Ident(ident()));
+ loop: while (true) {
+ pos = token.pos;
+ switch (token.kind) {
+ case LBRACKET:
nextToken();
- t = bracketsOpt(t);
- t = toP(F.at(pos).TypeArray(t));
- t = bracketsSuffix(t);
- } else {
+ if (token.kind == RBRACKET) {
+ nextToken();
+ t = bracketsOpt(t);
+ t = toP(F.at(pos).TypeArray(t));
+ t = bracketsSuffix(t);
+ } else {
+ if ((mode & EXPR) != 0) {
+ mode = EXPR;
+ JCExpression t1 = term();
+ t = to(F.at(pos).Indexed(t, t1));
+ }
+ accept(RBRACKET);
+ }
+ break loop;
+ case LPAREN:
if ((mode & EXPR) != 0) {
mode = EXPR;
- JCExpression t1 = term();
- t = to(F.at(pos).Indexed(t, t1));
+ t = arguments(typeArgs, t);
+ typeArgs = null;
+ }
+ break loop;
+ case DOT:
+ nextToken();
+ int oldmode = mode;
+ mode &= ~NOPARAMS;
+ typeArgs = typeArgumentsOpt(EXPR);
+ mode = oldmode;
+ if ((mode & EXPR) != 0) {
+ switch (token.kind) {
+ case CLASS:
+ if (typeArgs != null) return illegal();
+ mode = EXPR;
+ t = to(F.at(pos).Select(t, names._class));
+ nextToken();
+ break loop;
+ case THIS:
+ if (typeArgs != null) return illegal();
+ mode = EXPR;
+ t = to(F.at(pos).Select(t, names._this));
+ nextToken();
+ break loop;
+ case SUPER:
+ mode = EXPR;
+ t = to(F.at(pos).Select(t, names._super));
+ t = superSuffix(typeArgs, t);
+ typeArgs = null;
+ break loop;
+ case NEW:
+ if (typeArgs != null) return illegal();
+ mode = EXPR;
+ int pos1 = token.pos;
+ nextToken();
+ if (token.kind == LT) typeArgs = typeArguments(false);
+ t = innerCreator(pos1, typeArgs, t);
+ typeArgs = null;
+ break loop;
+ }
}
- accept(RBRACKET);
- }
- break loop;
- case LPAREN:
- if ((mode & EXPR) != 0) {
- mode = EXPR;
- t = arguments(typeArgs, t);
- typeArgs = null;
+ // typeArgs saved for next loop iteration.
+ t = toP(F.at(pos).Select(t, ident()));
+ break;
+// case LT:
+// if ((mode & (TYPE | NOPARAMS)) == 0) {
+// //could be an unbound method reference whose qualifier
+// //is a generic type i.e. A<S>#m
+// mode = EXPR | TYPE;
+// JCTree.Tag op = JCTree.Tag.LT;
+// int pos1 = token.pos;
+// nextToken();
+// mode |= EXPR | TYPE | TYPEARG;
+// JCExpression t1 = term3();
+// if ((mode & TYPE) != 0 &&
+// (token.kind == COMMA || token.kind == GT)) {
+// mode = TYPE;
+// ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
+// args.append(t1);
+// while (token.kind == COMMA) {
+// nextToken();
+// args.append(typeArgument());
+// }
+// accept(GT);
+// t = toP(F.at(pos1).TypeApply(t, args.toList()));
+// checkGenerics();
+// while (token.kind == DOT) {
+// nextToken();
+// mode = TYPE;
+// t = toP(F.at(token.pos).Select(t, ident()));
+// t = typeArgumentsOpt(t);
+// }
+// if (token.kind != HASH) {
+// //method reference expected here
+// t = illegal();
+// }
+// mode = EXPR;
+// break;
+// } else if ((mode & EXPR) != 0) {
+// //rollback - it was a binary expression
+// mode = EXPR;
+// JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
+// t = F.at(pos1).Binary(op, t, e);
+// t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
+// }
+// }
+// break loop;
+ default:
+ break loop;
}
- break loop;
- case DOT:
- nextToken();
- int oldmode = mode;
- mode &= ~NOPARAMS;
- typeArgs = typeArgumentsOpt(EXPR);
- mode = oldmode;
- if ((mode & EXPR) != 0) {
- switch (token.kind) {
- case CLASS:
- if (typeArgs != null) return illegal();
- mode = EXPR;
- t = to(F.at(pos).Select(t, names._class));
- nextToken();
- break loop;
- case THIS:
- if (typeArgs != null) return illegal();
- mode = EXPR;
- t = to(F.at(pos).Select(t, names._this));
- nextToken();
- break loop;
- case SUPER:
- mode = EXPR;
- t = to(F.at(pos).Select(t, names._super));
- t = superSuffix(typeArgs, t);
- typeArgs = null;
- break loop;
- case NEW:
- if (typeArgs != null) return illegal();
- mode = EXPR;
- int pos1 = token.pos;
- nextToken();
- if (token.kind == LT) typeArgs = typeArguments(false);
- t = innerCreator(pos1, typeArgs, t);
- typeArgs = null;
- break loop;
- }
- }
- // typeArgs saved for next loop iteration.
- t = toP(F.at(pos).Select(t, ident()));
- break;
- default:
- break loop;
}
}
if (typeArgs != null) illegal();
@@ -1105,6 +1222,19 @@
default:
return illegal();
}
+ return term3Rest(t, typeArgs);
+ }
+
+ JCExpression term3NoParams() {
+ try {
+ mode |= NOPARAMS;
+ return term3();
+ } finally {
+ mode &= ~NOPARAMS;
+ }
+ }
+
+ JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
if (typeArgs != null) illegal();
while (true) {
int pos1 = token.pos;
@@ -1149,6 +1279,11 @@
t = argumentsOpt(typeArgs, typeArgumentsOpt(t));
typeArgs = null;
}
+ } else if ((mode & EXPR) != 0 && token.kind == HASH) {
+ mode = EXPR;
+ if (typeArgs != null) return illegal();
+ accept(HASH);
+ t = memberReferenceSuffix(pos1, t);
} else {
break;
}
@@ -1162,12 +1297,59 @@
return toP(t);
}
+ JCExpression lambdaExpressionOrStatement(JCVariableDecl firstParam, int pos) {
+ ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
+ params.append(firstParam);
+ JCVariableDecl lastParam = firstParam;
+ while ((lastParam.mods.flags & Flags.VARARGS) == 0 && token.kind == COMMA) {
+ nextToken();
+ params.append(lastParam = formalParameter());
+ }
+ accept(RPAREN);
+ return lambdaExpressionOrStatementRest(params.toList(), pos);
+ }
+
+ JCExpression lambdaExpressionOrStatement(boolean hasParens, boolean explicitParams, int pos) {
+ List<JCVariableDecl> params = explicitParams ?
+ formalParameters() :
+ implicitParameters(hasParens);
+
+ return lambdaExpressionOrStatementRest(params, pos);
+ }
+
+ JCExpression lambdaExpressionOrStatementRest(List<JCVariableDecl> args, int pos) {
+ if (token.kind != ARROW) {
+ //better error recovery
+ return F.at(pos).Erroneous(args);
+ }
+
+ checkLambda();
+ accept(ARROW);
+
+ return token.kind == LBRACE ?
+ lambdaStatement(args, pos, pos) :
+ lambdaExpression(args, pos);
+ }
+
+ JCExpression lambdaStatement(List<JCVariableDecl> args, int pos, int pos2) {
+ JCBlock block = block(pos2, 0);
+ return toP(F.at(pos).Lambda(args, block));
+ }
+
+ JCExpression lambdaExpression(List<JCVariableDecl> args, int pos) {
+ JCTree expr = parseExpression();
+ return toP(F.at(pos).Lambda(args, expr));
+ }
+
/** SuperSuffix = Arguments | "." [TypeArguments] Ident [Arguments]
*/
JCExpression superSuffix(List<JCExpression> typeArgs, JCExpression t) {
nextToken();
if (token.kind == LPAREN || typeArgs != null) {
t = arguments(typeArgs, t);
+ } else if (token.kind == HASH) {
+ if (typeArgs != null) return illegal();
+ t = memberReferenceSuffix(t);
} else {
int pos = token.pos;
accept(DOT);
@@ -1377,6 +1559,36 @@
return t;
}
+ /**
+ * MemberReferenceSuffix = "#" [TypeArguments] Ident
+ * | "#" [TypeArguments] "new"
+ */
+ JCExpression memberReferenceSuffix(JCExpression t) {
+ int pos1 = token.pos;
+ accept(HASH);
+ return memberReferenceSuffix(pos1, t);
+ }
+
+ JCExpression memberReferenceSuffix(int pos1, JCExpression t) {
+ checkMethodReferences();
+ mode = EXPR;
+ List<JCExpression> typeArgs = null;
+ if (token.kind == LT) {
+ typeArgs = typeArguments(false);
+ }
+ Name refName = null;
+ ReferenceMode refMode = null;
+ if (token.kind == NEW) {
+ refMode = ReferenceMode.NEW;
+ refName = names.init;
+ nextToken();
+ } else {
+ refMode = ReferenceMode.INVOKE;
+ refName = ident();
+ }
+ return toP(F.at(t.getStartPosition()).Reference(refMode, refName, t, typeArgs));
+ }
+
/** Creator = Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
*/
JCExpression creator(int newpos, List<JCExpression> typeArgs) {
@@ -2392,7 +2604,7 @@
* @param mods The modifiers starting the class declaration
* @param dc The documentation comment for the class, or null.
*/
- JCClassDecl classDeclaration(JCModifiers mods, String dc) {
+ protected JCClassDecl classDeclaration(JCModifiers mods, String dc) {
int pos = token.pos;
accept(CLASS);
Name name = ident();
@@ -2421,7 +2633,7 @@
* @param mods The modifiers starting the interface declaration
* @param dc The documentation comment for the interface, or null.
*/
- JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
+ protected JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
int pos = token.pos;
accept(INTERFACE);
Name name = ident();
@@ -2444,7 +2656,7 @@
* @param mods The modifiers starting the enum declaration
* @param dc The documentation comment for the enum, or null.
*/
- JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
+ protected JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
int pos = token.pos;
accept(ENUM);
Name name = ident();
@@ -2666,7 +2878,7 @@
* ConstructorDeclaratorRest =
* "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody
*/
- JCTree methodDeclaratorRest(int pos,
+ protected JCTree methodDeclaratorRest(int pos,
JCModifiers mods,
JCExpression type,
Name name,
@@ -2779,6 +2991,24 @@
return params.toList();
}
+ List<JCVariableDecl> implicitParameters(boolean hasParens) {
+ if (hasParens) {
+ accept(LPAREN);
+ }
+ ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
+ if (token.kind != RPAREN && token.kind != ARROW) {
+ params.append(implicitParameter());
+ while (token.kind == COMMA) {
+ nextToken();
+ params.append(implicitParameter());
+ }
+ }
+ if (hasParens) {
+ accept(RPAREN);
+ }
+ return params.toList();
+ }
+
JCModifiers optFinal(long flags) {
JCModifiers mods = modifiersOpt();
checkNoMods(mods.flags & ~(Flags.FINAL | Flags.DEPRECATED));
@@ -2801,6 +3031,11 @@
return variableDeclaratorId(mods, type);
}
+ protected JCVariableDecl implicitParameter() {
+ JCModifiers mods = F.at(token.pos).Modifiers(Flags.PARAMETER);
+ return variableDeclaratorId(mods, null);
+ }
+
/* ---------- auxiliary methods -------------- */
void error(int pos, String key, Object ... args) {
@@ -3024,6 +3259,18 @@
allowTWR = true;
}
}
+ void checkLambda() {
+ if (!allowLambda) {
+ log.error(token.pos, "lambda.not.supported.in.source", source.name);
+ allowLambda = true;
+ }
+ }
+ void checkMethodReferences() {
+ if (!allowMethodReferences) {
+ log.error(token.pos, "method.references.not.supported.in.source", source.name);
+ allowMethodReferences = true;
+ }
+ }
/*
* a functional source tree and end position mappings
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Lexer.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Lexer.java Thu Dec 15 19:52:13 2011 -0800
@@ -50,6 +50,11 @@
Token token();
/**
+ * Return token with given lookahead.
+ */
+ Token token(int lookahead);
+
+ /**
* Return the last character position of the previous token.
*/
Token prevToken();
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Thu Dec 15 19:52:13 2011 -0800
@@ -26,8 +26,9 @@
package com.sun.tools.javac.parser;
import java.nio.*;
+import java.util.List;
+import java.util.ArrayList;
-import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.Position.LineMap;
import com.sun.tools.javac.parser.JavaTokenizer.*;
@@ -53,6 +54,10 @@
*/
private Token prevToken;
+ /** Buffer of saved tokens (used during lookahead)
+ */
+ private List<Token> savedTokens = new ArrayList<Token>();
+
private JavaTokenizer tokenizer;
/**
* Create a scanner from the input array. This method might
@@ -80,16 +85,35 @@
}
public Token token() {
- return token;
+ return token(0);
}
+ public Token token(int lookahead) {
+ if (lookahead == 0) {
+ return token;
+ } else {
+ ensureLookahead(lookahead);
+ return savedTokens.get(lookahead - 1);
+ }
+ }
+ //where
+ private void ensureLookahead(int lookahead) {
+ for (int i = savedTokens.size() ; i < lookahead ; i ++) {
+ savedTokens.add(tokenizer.readToken());
+ }
+ }
+
public Token prevToken() {
return prevToken;
}
public void nextToken() {
prevToken = token;
- token = tokenizer.readToken();
+ if (!savedTokens.isEmpty()) {
+ token = savedTokens.remove(0);
+ } else {
+ token = tokenizer.readToken();
+ }
}
public Token split() {
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java Thu Dec 15 19:52:13 2011 -0800
@@ -176,6 +176,8 @@
TRUE("true", Tag.NAMED),
FALSE("false", Tag.NAMED),
NULL("null", Tag.NAMED),
+ ARROW("->"),
+ HASH("#"),
LPAREN("("),
RPAREN(")"),
LBRACE("{"),
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Dec 15 19:52:13 2011 -0800
@@ -1945,6 +1945,16 @@
strings in switch are not supported in -source {0}\n\
(use -source 7 or higher to enable strings in switch)
+# 0: string
+compiler.err.lambda.not.supported.in.source=\
+ lambda expressions are not supported in -source {0}\n\
+ (use -source 8 or higher to enable lambda expressions)
+
+# 0: string
+compiler.err.method.references.not.supported.in.source=\
+ method references are not supported in -source {0}\n\
+ (use -source 8 or higher to enable method references)
+
########################################
# Diagnostics for verbose resolution
# used by Resolve (debug only)
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Thu Dec 15 19:52:13 2011 -0800
@@ -41,6 +41,8 @@
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.parser.EndPosTable;
import com.sun.source.tree.*;
+import com.sun.source.tree.LambdaExpressionTree.BodyKind;
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
import static com.sun.tools.javac.code.BoundKind.*;
import static com.sun.tools.javac.tree.JCTree.Tag.*;
@@ -198,6 +200,10 @@
*/
NEWARRAY,
+ /** Lambda expression, of type Lambda.
+ */
+ LAMBDA,
+
/** Parenthesized subexpressions, of type Parens.
*/
PARENS,
@@ -222,6 +228,10 @@
*/
SELECT,
+ /** Member references, of type Reference.
+ */
+ REFERENCE,
+
/** Simple identifiers, of type Ident.
*/
IDENT,
@@ -1487,6 +1497,56 @@
}
/**
+ * A lambda expression.
+ */
+ public static class JCLambda extends JCExpression implements LambdaExpressionTree {
+
+ public List<JCVariableDecl> params;
+ public JCTree body;
+ public Type targetType;
+ public boolean canCompleteNormally = true;
+ public List<Type> inferredThrownTypes;
+
+ public JCLambda(List<JCVariableDecl> params,
+ JCTree body) {
+ this.params = params;
+ this.body = body;
+ }
+ @Override
+ public Tag getTag() {
+ return LAMBDA;
+ }
+ @Override
+ public void accept(Visitor v) {
+ v.visitLambda(this);
+ }
+ @Override
+ public <R, D> R accept(TreeVisitor<R, D> v, D d) {
+ return v.visitLambdaExpression(this, d);
+ }
+ public Kind getKind() {
+ return Kind.LAMBDA_EXPRESSION;
+ }
+ public JCTree getBody() {
+ return body;
+ }
+ public java.util.List<? extends VariableTree> getParameters() {
+ return params;
+ }
+ @Override
+ public JCLambda setType(Type type) {
+ super.setType(type);
+ return this;
+ }
+ @Override
+ public BodyKind getBodyKind() {
+ return body.hasTag(BLOCK) ?
+ BodyKind.STATEMENT :
+ BodyKind.EXPRESSION;
+ }
+ }
+
+ /**
* A parenthesized subexpression ( ... )
*/
public static class JCParens extends JCExpression implements ParenthesizedTree {
@@ -1747,6 +1807,46 @@
}
/**
+ * Selects a member expression.
+ */
+ public static class JCMemberReference extends JCExpression implements MemberReferenceTree {
+ public ReferenceMode mode;
+ public Name name;
+ public JCExpression expr;
+ public List<JCExpression> typeargs;
+ public Type targetType;
+ public Symbol sym;
+
+ protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
+ this.mode = mode;
+ this.name = name;
+ this.expr = expr;
+ this.typeargs = typeargs;
+ }
+ @Override
+ public void accept(Visitor v) { v.visitReference(this); }
+
+ public Kind getKind() { return Kind.MEMBER_REFERENCE; }
+ @Override
+ public ReferenceMode getMode() { return mode; }
+ @Override
+ public JCExpression getQualifierExpression() { return expr; }
+ @Override
+ public Name getName() { return name; }
+ @Override
+ public List<JCExpression> getTypeArguments() { return typeargs; }
+
+ @Override
+ public <R,D> R accept(TreeVisitor<R,D> v, D d) {
+ return v.visitMemberReference(this, d);
+ }
+ @Override
+ public Tag getTag() {
+ return REFERENCE;
+ }
+ }
+
+ /**
* An identifier
* @param idname the name
* @param sym the symbol
@@ -2271,6 +2371,7 @@
public void visitApply(JCMethodInvocation that) { visitTree(that); }
public void visitNewClass(JCNewClass that) { visitTree(that); }
public void visitNewArray(JCNewArray that) { visitTree(that); }
+ public void visitLambda(JCLambda that) { visitTree(that); }
public void visitParens(JCParens that) { visitTree(that); }
public void visitAssign(JCAssign that) { visitTree(that); }
public void visitAssignop(JCAssignOp that) { visitTree(that); }
@@ -2280,6 +2381,7 @@
public void visitTypeTest(JCInstanceOf that) { visitTree(that); }
public void visitIndexed(JCArrayAccess that) { visitTree(that); }
public void visitSelect(JCFieldAccess that) { visitTree(that); }
+ public void visitReference(JCMemberReference that) { visitTree(that); }
public void visitIdent(JCIdent that) { visitTree(that); }
public void visitLiteral(JCLiteral that) { visitTree(that); }
public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Thu Dec 15 19:52:13 2011 -0800
@@ -28,6 +28,8 @@
import java.io.*;
import java.util.*;
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
+
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.code.*;
@@ -907,6 +909,17 @@
}
}
+ public void visitLambda(JCLambda tree) {
+ try {
+ print("(");
+ printExprs(tree.params);
+ print(")->");
+ printExpr(tree.body);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
public void visitParens(JCParens tree) {
try {
print("(");
@@ -1052,6 +1065,21 @@
}
}
+ public void visitReference(JCMemberReference tree) {
+ try {
+ printExpr(tree.expr);
+ print("#");
+ if (tree.typeargs != null) {
+ print("<");
+ printExprs(tree.typeargs);
+ print(">");
+ }
+ print(tree.getMode() == ReferenceMode.INVOKE ? tree.name : "new");
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
public void visitIdent(JCIdent tree) {
try {
print(tree.name);
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Thu Dec 15 19:52:13 2011 -0800
@@ -271,6 +271,13 @@
return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
}
+ public JCTree visitLambdaExpression(LambdaExpressionTree node, P p) {
+ JCLambda t = (JCLambda) node;
+ List<JCVariableDecl> params = copy(t.params, p);
+ JCTree body = copy(t.body, p);
+ return M.at(t.pos).Lambda(params, body);
+ }
+
public JCTree visitParenthesized(ParenthesizedTree node, P p) {
JCParens t = (JCParens) node;
JCExpression expr = copy(t.expr, p);
@@ -289,6 +296,13 @@
return M.at(t.pos).Select(selected, t.name);
}
+ public JCTree visitMemberReference(MemberReferenceTree node, P p) {
+ JCMemberReference t = (JCMemberReference) node;
+ JCExpression expr = copy(t.expr, p);
+ List<JCExpression> typeargs = copy(t.typeargs, p);
+ return M.at(t.pos).Reference(t.mode, t.name, expr, typeargs);
+ }
+
public JCTree visitEmptyStatement(EmptyStatementTree node, P p) {
JCSkip t = (JCSkip) node;
return M.at(t.pos).Skip();
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Dec 15 19:52:13 2011 -0800
@@ -227,6 +227,34 @@
}
}
+ /**
+ * Return true if the AST corresponds to a static select of the kind A.B
+ */
+ public static boolean isStaticSelector(JCTree base, Names names) {
+ if (base == null)
+ return false;
+ switch (base.getTag()) {
+ case IDENT:
+ JCIdent id = (JCIdent)base;
+ return id.name != names._this &&
+ id.name != names._super &&
+ isStaticSym(base);
+ case SELECT:
+ return isStaticSym(base) &&
+ isStaticSelector(((JCFieldAccess)base).selected, names);
+ case TYPEAPPLY:
+ return true;
+ default:
+ return false;
+ }
+ }
+ //where
+ private static boolean isStaticSym(JCTree tree) {
+ Symbol sym = symbol(tree);
+ return (sym.kind == Kinds.TYP ||
+ sym.kind == Kinds.PCK);
+ }
+
/** Return true if a tree represents the null literal. */
public static boolean isNull(JCTree tree) {
if (!tree.hasTag(LITERAL))
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Thu Dec 15 19:52:13 2011 -0800
@@ -351,6 +351,14 @@
return tree;
}
+ public JCLambda Lambda(List<JCVariableDecl> params,
+ JCTree body)
+ {
+ JCLambda tree = new JCLambda(params, body);
+ tree.pos = pos;
+ return tree;
+ }
+
public JCParens Parens(JCExpression expr) {
JCParens tree = new JCParens(expr);
tree.pos = pos;
@@ -405,6 +413,13 @@
return tree;
}
+ public JCMemberReference Reference(JCMemberReference.ReferenceMode mode, Name name,
+ JCExpression expr, List<JCExpression> typeargs) {
+ JCMemberReference tree = new JCMemberReference(mode, name, expr, typeargs);
+ tree.pos = pos;
+ return tree;
+ }
+
public JCIdent Ident(Name name) {
JCIdent tree = new JCIdent(name, null);
tree.pos = pos;
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java Thu Dec 15 19:52:13 2011 -0800
@@ -212,6 +212,11 @@
scan(tree.elems);
}
+ public void visitLambda(JCLambda tree) {
+ scan(tree.body);
+ scan(tree.params);
+ }
+
public void visitParens(JCParens tree) {
scan(tree.expr);
}
@@ -254,6 +259,11 @@
scan(tree.selected);
}
+ public void visitReference(JCMemberReference tree) {
+ scan(tree.expr);
+ scan(tree.typeargs);
+ }
+
public void visitIdent(JCIdent tree) {
}
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Thu Dec 15 19:52:13 2011 -0800
@@ -282,6 +282,12 @@
result = tree;
}
+ public void visitLambda(JCLambda tree) {
+ tree.params = translate(tree.params);
+ tree.body = translate(tree.body);
+ result = tree;
+ }
+
public void visitNewArray(JCNewArray tree) {
tree.elemtype = translate(tree.elemtype);
tree.dims = translate(tree.dims);
@@ -340,6 +346,11 @@
result = tree;
}
+ public void visitReference(JCMemberReference tree) {
+ tree.expr = translate(tree.expr);
+ result = tree;
+ }
+
public void visitIdent(JCIdent tree) {
result = tree;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7120266.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7120266
+ * @summary javac fails to compile hotspot code
+ * @compile T7120266.java
+ */
+
+class T7120266 {
+ void test(int i, int len) { that(i < len, "oopmap"); }
+ void that(boolean b, String s) { };
+}
--- a/langtools/test/tools/javac/diags/examples/CatchWithoutTry.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/test/tools/javac/diags/examples/CatchWithoutTry.java Thu Dec 15 19:52:13 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,6 @@
// key: compiler.err.catch.without.try
// key: compiler.err.expected
-// key: compiler.err.not.stmt
class CatchWithoutTry {
void m() {
--- a/langtools/test/tools/javac/diags/examples/IllegalChar.java Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/test/tools/javac/diags/examples/IllegalChar.java Thu Dec 15 19:52:13 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,5 +24,5 @@
// key: compiler.err.illegal.char
class IllegalChar {
- int i = #;
+ int i = `;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LambdaNotSupported.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.lambda.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+class LambdaNotSupported {
+ S s = ()->{};
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/MethodReferencesNotSupported.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.method.references.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+class MethodReferencesNotSupported {
+ S s = A#foo;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotAStatement.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.not.stmt
+
+class NotAStatement {
+ void m() {
+ x + 1;
+ }
+}
--- a/langtools/test/tools/javac/generics/rare/6665356/T6665356.out Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/test/tools/javac/generics/rare/6665356/T6665356.out Thu Dec 15 19:52:13 2011 -0800
@@ -1,5 +1,5 @@
T6665356.java:17:37: compiler.err.improperly.formed.type.param.missing
T6665356.java:18:40: compiler.err.improperly.formed.type.inner.raw.param
-T6665356.java:26:23: compiler.err.improperly.formed.type.param.missing
+T6665356.java:26:22: compiler.err.improperly.formed.type.param.missing
T6665356.java:27:25: compiler.err.improperly.formed.type.inner.raw.param
4 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaParserTest.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7115050
+ * @summary Add parser support for lambda expressions
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class LambdaParserTest {
+
+ static int checkCount = 0;
+
+ enum LambdaKind {
+ NILARY_EXPR("()->x"),
+ NILARY_STMT("()->{ return x; }"),
+ ONEARY_SHORT_EXPR("x->x"),
+ ONEARY_SHORT_STMT("x->{ return x; }"),
+ ONEARY_EXPR("(#M1 #T1 x)->x"),
+ ONEARY_STMT("(#M1 #T1 x)->{ return x; }"),
+ TWOARY_EXPR("(#M1 #T1 x, #M2 #T2 y)->x"),
+ TWOARY_STMT("(#M1 #T1 x, #M2 #T2 y)->{ return x; }");
+
+ String lambdaTemplate;
+
+ LambdaKind(String lambdaTemplate) {
+ this.lambdaTemplate = lambdaTemplate;
+ }
+
+ String getLambdaString(LambdaParameterKind pk1, LambdaParameterKind pk2,
+ ModifierKind mk1, ModifierKind mk2) {
+ return lambdaTemplate.replaceAll("#M1", mk1.modifier)
+ .replaceAll("#M2", mk2.modifier)
+ .replaceAll("#T1", pk1.parameterType)
+ .replaceAll("#T2", pk2.parameterType);
+ }
+
+ int arity() {
+ switch (this) {
+ case NILARY_EXPR:
+ case NILARY_STMT: return 0;
+ case ONEARY_SHORT_EXPR:
+ case ONEARY_SHORT_STMT:
+ case ONEARY_EXPR:
+ case ONEARY_STMT: return 1;
+ case TWOARY_EXPR:
+ case TWOARY_STMT: return 2;
+ default: throw new AssertionError("Invalid lambda kind " + this);
+ }
+ }
+
+ boolean isShort() {
+ return this == ONEARY_SHORT_EXPR ||
+ this == ONEARY_SHORT_STMT;
+ }
+ }
+
+ enum LambdaParameterKind {
+ IMPLICIT(""),
+ EXPLIICT_SIMPLE("A"),
+ EXPLICIT_VARARGS("A..."),
+ EXPLICIT_GENERIC1("A<X>"),
+ EXPLICIT_GENERIC3("A<? extends X, ? super Y>");
+
+ String parameterType;
+
+ LambdaParameterKind(String parameterType) {
+ this.parameterType = parameterType;
+ }
+
+ boolean explicit() {
+ return this != IMPLICIT;
+ }
+ }
+
+ enum ModifierKind {
+ NONE(""),
+ FINAL("final"),
+ PUBLIC("public");
+
+ String modifier;
+
+ ModifierKind(String modifier) {
+ this.modifier = modifier;
+ }
+
+ boolean compatibleWith(LambdaParameterKind pk) {
+ switch (this) {
+ case PUBLIC: return false;
+ case FINAL: return pk != LambdaParameterKind.IMPLICIT;
+ case NONE: return true;
+ default: throw new AssertionError("Invalid modifier kind " + this);
+ }
+ }
+ }
+
+ enum ExprKind {
+ NONE("#L#S"),
+ SINGLE_PAREN1("(#L#S)"),
+ SINGLE_PAREN2("(#L)#S"),
+ DOUBLE_PAREN1("((#L#S))"),
+ DOUBLE_PAREN2("((#L)#S)"),
+ DOUBLE_PAREN3("((#L))#S");
+
+ String expressionTemplate;
+
+ ExprKind(String expressionTemplate) {
+ this.expressionTemplate = expressionTemplate;
+ }
+
+ String expressionString(LambdaParameterKind pk1, LambdaParameterKind pk2,
+ ModifierKind mk1, ModifierKind mk2, LambdaKind lk, SubExprKind sk) {
+ return expressionTemplate.replaceAll("#L", lk.getLambdaString(pk1, pk2, mk1, mk2))
+ .replaceAll("#S", sk.subExpression);
+ }
+ }
+
+ enum SubExprKind {
+ NONE(""),
+ SELECT_FIELD(".f"),
+ SELECT_METHOD(".f()"),
+ SELECT_NEW(".new Foo()"),
+ POSTINC("++"),
+ POSTDEC("--");
+
+ String subExpression;
+
+ SubExprKind(String subExpression) {
+ this.subExpression = subExpression;
+ }
+ }
+
+ public static void main(String... args) throws Exception {
+
+ //create default shared JavaCompiler - reused across multiple compilations
+ JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+ StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+ for (LambdaKind lk : LambdaKind.values()) {
+ for (LambdaParameterKind pk1 : LambdaParameterKind.values()) {
+ if (lk.arity() < 1 && pk1 != LambdaParameterKind.IMPLICIT) continue;
+ for (LambdaParameterKind pk2 : LambdaParameterKind.values()) {
+ if (lk.arity() < 2 && pk2 != LambdaParameterKind.IMPLICIT) continue;
+ for (ModifierKind mk1 : ModifierKind.values()) {
+ if (mk1 != ModifierKind.NONE && lk.isShort()) continue;
+ if (lk.arity() < 1 && mk1 != ModifierKind.NONE) continue;
+ for (ModifierKind mk2 : ModifierKind.values()) {
+ if (lk.arity() < 2 && mk2 != ModifierKind.NONE) continue;
+ for (SubExprKind sk : SubExprKind.values()) {
+ for (ExprKind ek : ExprKind.values()) {
+ new LambdaParserTest(pk1, pk2, mk1, mk2, lk, sk, ek)
+ .run(comp, fm);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ System.out.println("Total check executed: " + checkCount);
+ }
+
+ LambdaParameterKind pk1;
+ LambdaParameterKind pk2;
+ ModifierKind mk1;
+ ModifierKind mk2;
+ LambdaKind lk;
+ SubExprKind sk;
+ ExprKind ek;
+ JavaSource source;
+ DiagnosticChecker diagChecker;
+
+ LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2, ModifierKind mk1,
+ ModifierKind mk2, LambdaKind lk, SubExprKind sk, ExprKind ek) {
+ this.pk1 = pk1;
+ this.pk2 = pk2;
+ this.mk1 = mk1;
+ this.mk2 = mk2;
+ this.lk = lk;
+ this.sk = sk;
+ this.ek = ek;
+ this.source = new JavaSource();
+ this.diagChecker = new DiagnosticChecker();
+ }
+
+ class JavaSource extends SimpleJavaFileObject {
+
+ String template = "class Test {\n" +
+ " SAM s = #E;\n" +
+ "}";
+
+ String source;
+
+ public JavaSource() {
+ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+ source = template.replaceAll("#E", ek.expressionString(pk1, pk2, mk1, mk2, lk, sk));
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return source;
+ }
+ }
+
+ void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+ JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+ Arrays.asList("-XDallowLambda"), null, Arrays.asList(source));
+ try {
+ ct.parse();
+ } catch (Throwable ex) {
+ throw new AssertionError("Error thron when parsing the following source:\n" + source.getCharContent(true));
+ }
+ check();
+ }
+
+ void check() {
+ checkCount++;
+
+ boolean errorExpected = (lk.arity() > 0 && !mk1.compatibleWith(pk1)) ||
+ (lk.arity() > 1 && !mk2.compatibleWith(pk2));
+
+ if (lk.arity() == 2 &&
+ (pk1.explicit() != pk2.explicit() ||
+ pk1 == LambdaParameterKind.EXPLICIT_VARARGS)) {
+ errorExpected = true;
+ }
+
+ if (errorExpected != diagChecker.errorFound) {
+ throw new Error("invalid diagnostics for source:\n" +
+ source.getCharContent(true) +
+ "\nFound error: " + diagChecker.errorFound +
+ "\nExpected error: " + errorExpected);
+ }
+ }
+
+ static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+ boolean errorFound;
+
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+ errorFound = true;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7115052
+ * @ignore 7120266
+ * @summary Add parser support for method references
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class MethodReferenceParserTest {
+
+ static int checkCount = 0;
+
+ enum ReferenceKind {
+ METHOD_REF("#Q##Gm"),
+ CONSTRUCTOR_REF("#Q##Gnew"),
+ ERR_SUPER("#Q##Gsuper"),
+ ERR_METH0("#Q##Gm()"),
+ ERR_METH1("#Q##Gm(X)"),
+ ERR_CONSTR0("#Q##Gnew()"),
+ ERR_CONSTR1("#Q##Gnew(X)");
+
+ String referenceTemplate;
+
+ ReferenceKind(String referenceTemplate) {
+ this.referenceTemplate = referenceTemplate;
+ }
+
+ String getReferenceString(QualifierKind qk, GenericKind gk) {
+ return referenceTemplate
+ .replaceAll("#Q", qk.qualifier)
+ .replaceAll("#G", gk.typeParameters);
+ }
+
+ boolean erroneous() {
+ switch (this) {
+ case ERR_SUPER:
+ case ERR_METH0:
+ case ERR_METH1:
+ case ERR_CONSTR0:
+ case ERR_CONSTR1:
+ return true;
+ default: return false;
+ }
+ }
+ }
+
+ enum GenericKind {
+ NONE(""),
+ ONE("<X>"),
+ TWO("<X,Y>");
+
+ String typeParameters;
+
+ GenericKind(String typeParameters) {
+ this.typeParameters = typeParameters;
+ }
+ }
+
+ enum QualifierKind {
+ THIS("this"),
+ SUPER("super"),
+ NEW("new Foo()"),
+ METHOD("m()"),
+ FIELD("a.f"),
+ UBOUND_SIMPLE("A"),
+ UNBOUND_GENERIC1("A<X>"),
+ UNBOUND_GENERIC2("A<X, Y>"),
+ UNBOUND_GENERIC3("A<? extends X, ? super Y>");
+
+ String qualifier;
+
+ QualifierKind(String qualifier) {
+ this.qualifier = qualifier;
+ }
+ }
+
+ enum ExprKind {
+ NONE("#R#S"),
+ SINGLE_PAREN1("(#R#S)"),
+ SINGLE_PAREN2("(#R)#S"),
+ DOUBLE_PAREN1("((#R#S))"),
+ DOUBLE_PAREN2("((#R)#S)"),
+ DOUBLE_PAREN3("((#R))#S");
+
+ String expressionTemplate;
+
+ ExprKind(String expressionTemplate) {
+ this.expressionTemplate = expressionTemplate;
+ }
+
+ String expressionString(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) {
+ return expressionTemplate
+ .replaceAll("#R", rk.getReferenceString(qk, gk))
+ .replaceAll("#S", sk.subExpression);
+ }
+ }
+
+ enum SubExprKind {
+ NONE(""),
+ SELECT_FIELD(".f"),
+ SELECT_METHOD(".f()"),
+ SELECT_NEW(".new Foo()"),
+ POSTINC("++"),
+ POSTDEC("--");
+
+ String subExpression;
+
+ SubExprKind(String subExpression) {
+ this.subExpression = subExpression;
+ }
+ }
+
+ public static void main(String... args) throws Exception {
+
+ //create default shared JavaCompiler - reused across multiple compilations
+ JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+ StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+ for (ReferenceKind rk : ReferenceKind.values()) {
+ for (QualifierKind qk : QualifierKind.values()) {
+ for (GenericKind gk : GenericKind.values()) {
+ for (SubExprKind sk : SubExprKind.values()) {
+ for (ExprKind ek : ExprKind.values()) {
+ new MethodReferenceParserTest(rk, qk, gk, sk, ek).run(comp, fm);
+ }
+ }
+ }
+ }
+ }
+ System.out.println("Total check executed: " + checkCount);
+ }
+
+ ReferenceKind rk;
+ QualifierKind qk;
+ GenericKind gk;
+ SubExprKind sk;
+ ExprKind ek;
+ JavaSource source;
+ DiagnosticChecker diagChecker;
+
+ MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek) {
+ this.rk = rk;
+ this.qk = qk;
+ this.gk = gk;
+ this.sk = sk;
+ this.ek = ek;
+ this.source = new JavaSource();
+ this.diagChecker = new DiagnosticChecker();
+ }
+
+ class JavaSource extends SimpleJavaFileObject {
+
+ String template = "class Test {\n" +
+ " SAM s = #E;\n" +
+ "}";
+
+ String source;
+
+ public JavaSource() {
+ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+ source = template.replaceAll("#E", ek.expressionString(rk, qk, gk, sk));
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return source;
+ }
+ }
+
+ void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+ JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+ Arrays.asList("-XDallowMethodReferences"), null, Arrays.asList(source));
+ try {
+ ct.parse();
+ } catch (Throwable ex) {
+ throw new AssertionError("Error thrown when parsing the following source:\n" + source.getCharContent(true));
+ }
+ check();
+ }
+
+ void check() {
+ checkCount++;
+
+ if (diagChecker.errorFound != rk.erroneous()) {
+ throw new Error("invalid diagnostics for source:\n" +
+ source.getCharContent(true) +
+ "\nFound error: " + diagChecker.errorFound +
+ "\nExpected error: " + rk.erroneous());
+ }
+ }
+
+ static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+ boolean errorFound;
+
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+ errorFound = true;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/parser/JavacParserTest.java Thu Dec 15 19:52:13 2011 -0800
@@ -0,0 +1,883 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7073631
+ * @summary tests error and diagnostics positions
+ * @author Jan Lahoda
+ */
+
+import com.sun.source.tree.BinaryTree;
+import com.sun.source.tree.BlockTree;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.ErroneousTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.ExpressionTree;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.ModifiersTree;
+import com.sun.source.tree.StatementTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.Tree.Kind;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.tree.WhileLoopTree;
+import com.sun.source.util.SourcePositions;
+import com.sun.source.util.TreeScanner;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.tree.JCTree;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class JavacParserTest extends TestCase {
+ final JavaCompiler tool;
+ public JavacParserTest(String testName) {
+ tool = ToolProvider.getSystemJavaCompiler();
+ System.out.println("java.home=" + System.getProperty("java.home"));
+ }
+
+ static class MyFileObject extends SimpleJavaFileObject {
+
+ private String text;
+
+ public MyFileObject(String text) {
+ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+ this.text = text;
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return text;
+ }
+ }
+ /*
+ * converts Windows to Unix style LFs for comparing strings
+ */
+ private String normalize(String in) {
+ return in.replace(System.getProperty("line.separator"), "\n");
+ }
+
+ public CompilationUnitTree getCompilationUnitTree(String code) throws IOException {
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ return cut;
+ }
+
+ public List<String> getErroneousTreeValues(ErroneousTree node) {
+
+ List<String> values = new ArrayList<>();
+ if (node.getErrorTrees() != null) {
+ for (Tree t : node.getErrorTrees()) {
+ values.add(t.toString());
+ }
+ } else {
+ throw new RuntimeException("ERROR: No Erroneous tree "
+ + "has been created.");
+ }
+ return values;
+ }
+
+ public void testPositionForSuperConstructorCalls() throws IOException {
+ assert tool != null;
+
+ String code = "package test; public class Test {public Test() {super();}}";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+ MethodTree method =
+ (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
+ ExpressionStatementTree es =
+ (ExpressionStatementTree) method.getBody().getStatements().get(0);
+
+ final int esStartPos = code.indexOf(es.toString());
+ final int esEndPos = esStartPos + es.toString().length();
+ assertEquals("testPositionForSuperConstructorCalls",
+ esStartPos, pos.getStartPosition(cut, es));
+ assertEquals("testPositionForSuperConstructorCalls",
+ esEndPos, pos.getEndPosition(cut, es));
+
+ MethodInvocationTree mit = (MethodInvocationTree) es.getExpression();
+
+ final int mitStartPos = code.indexOf(mit.toString());
+ final int mitEndPos = mitStartPos + mit.toString().length();
+ assertEquals("testPositionForSuperConstructorCalls",
+ mitStartPos, pos.getStartPosition(cut, mit));
+ assertEquals("testPositionForSuperConstructorCalls",
+ mitEndPos, pos.getEndPosition(cut, mit));
+
+ final int methodStartPos = mitStartPos;
+ final int methodEndPos = methodStartPos + mit.getMethodSelect().toString().length();
+ assertEquals("testPositionForSuperConstructorCalls",
+ methodStartPos, pos.getStartPosition(cut, mit.getMethodSelect()));
+ assertEquals("testPositionForSuperConstructorCalls",
+ methodEndPos, pos.getEndPosition(cut, mit.getMethodSelect()));
+
+ }
+
+ public void testPositionForEnumModifiers() throws IOException {
+
+ String code = "package test; public enum Test {A;}";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ ModifiersTree mt = clazz.getModifiers();
+
+ assertEquals("testPositionForEnumModifiers",
+ 38 - 24, pos.getStartPosition(cut, mt));
+ assertEquals("testPositionForEnumModifiers",
+ 44 - 24, pos.getEndPosition(cut, mt));
+ }
+
+ public void testNewClassWithEnclosing() throws IOException {
+
+
+ String code = "package test; class Test { " +
+ "class d {} private void method() { " +
+ "Object o = Test.this.new d(); } }";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ ExpressionTree est =
+ ((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
+
+ assertEquals("testNewClassWithEnclosing",
+ 97 - 24, pos.getStartPosition(cut, est));
+ assertEquals("testNewClassWithEnclosing",
+ 114 - 24, pos.getEndPosition(cut, est));
+ }
+
+ public void testPreferredPositionForBinaryOp() throws IOException {
+
+ String code = "package test; public class Test {"
+ + "private void test() {"
+ + "Object o = null; boolean b = o != null && o instanceof String;"
+ + "} private Test() {}}";
+
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ MethodTree method = (MethodTree) clazz.getMembers().get(0);
+ VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1);
+ BinaryTree cond = (BinaryTree) condSt.getInitializer();
+
+ JCTree condJC = (JCTree) cond;
+ int condStartPos = code.indexOf("&&");
+ assertEquals("testPreferredPositionForBinaryOp",
+ condStartPos, condJC.pos);
+ }
+
+ public void testPositionBrokenSource126732a() throws IOException {
+ String[] commands = new String[]{
+ "return Runnable()",
+ "do { } while (true)",
+ "throw UnsupportedOperationException()",
+ "assert true",
+ "1 + 1",};
+
+ for (String command : commands) {
+
+ String code = "package test;\n"
+ + "public class Test {\n"
+ + " public static void test() {\n"
+ + " " + command + " {\n"
+ + " new Runnable() {\n"
+ + " };\n"
+ + " }\n"
+ + "}";
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
+ null, null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ MethodTree method = (MethodTree) clazz.getMembers().get(0);
+ List<? extends StatementTree> statements =
+ method.getBody().getStatements();
+
+ StatementTree ret = statements.get(0);
+ StatementTree block = statements.get(1);
+
+ Trees t = Trees.instance(ct);
+ int len = code.indexOf(command + " {") + (command + " ").length();
+ assertEquals(command, len,
+ t.getSourcePositions().getEndPosition(cut, ret));
+ assertEquals(command, len,
+ t.getSourcePositions().getStartPosition(cut, block));
+ }
+ }
+
+ public void testPositionBrokenSource126732b() throws IOException {
+ String[] commands = new String[]{
+ "break",
+ "break A",
+ "continue ",
+ "continue A",};
+
+ for (String command : commands) {
+
+ String code = "package test;\n"
+ + "public class Test {\n"
+ + " public static void test() {\n"
+ + " while (true) {\n"
+ + " " + command + " {\n"
+ + " new Runnable() {\n"
+ + " };\n"
+ + " }\n"
+ + " }\n"
+ + "}";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
+ null, null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ MethodTree method = (MethodTree) clazz.getMembers().get(0);
+ List<? extends StatementTree> statements =
+ ((BlockTree) ((WhileLoopTree) method.getBody().getStatements().get(0)).getStatement()).getStatements();
+
+ StatementTree ret = statements.get(0);
+ StatementTree block = statements.get(1);
+
+ Trees t = Trees.instance(ct);
+ int len = code.indexOf(command + " {") + (command + " ").length();
+ assertEquals(command, len,
+ t.getSourcePositions().getEndPosition(cut, ret));
+ assertEquals(command, len,
+ t.getSourcePositions().getStartPosition(cut, block));
+ }
+ }
+
+ public void testErrorRecoveryForEnhancedForLoop142381() throws IOException {
+
+ String code = "package test; class Test { " +
+ "private void method() { " +
+ "java.util.Set<String> s = null; for (a : s) {} } }";
+
+ final List<Diagnostic<? extends JavaFileObject>> errors =
+ new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+ new DiagnosticListener<JavaFileObject>() {
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ errors.add(diagnostic);
+ }
+ }, null, null, Arrays.asList(new MyFileObject(code)));
+
+ CompilationUnitTree cut = ct.parse().iterator().next();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ StatementTree forStatement =
+ ((MethodTree) clazz.getMembers().get(0)).getBody().getStatements().get(1);
+
+ assertEquals("testErrorRecoveryForEnhancedForLoop142381",
+ Kind.ENHANCED_FOR_LOOP, forStatement.getKind());
+ assertFalse("testErrorRecoveryForEnhancedForLoop142381", errors.isEmpty());
+ }
+
+ public void testPositionAnnotationNoPackage187551() throws IOException {
+
+ String code = "\n@interface Test {}";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ Trees t = Trees.instance(ct);
+
+ assertEquals("testPositionAnnotationNoPackage187551",
+ 1, t.getSourcePositions().getStartPosition(cut, clazz));
+ }
+
+ public void testPositionsSane() throws IOException {
+ performPositionsSanityTest("package test; class Test { " +
+ "private void method() { " +
+ "java.util.List<? extends java.util.List<? extends String>> l; " +
+ "} }");
+ performPositionsSanityTest("package test; class Test { " +
+ "private void method() { " +
+ "java.util.List<? super java.util.List<? super String>> l; " +
+ "} }");
+ performPositionsSanityTest("package test; class Test { " +
+ "private void method() { " +
+ "java.util.List<? super java.util.List<?>> l; } }");
+ }
+
+ private void performPositionsSanityTest(String code) throws IOException {
+
+ final List<Diagnostic<? extends JavaFileObject>> errors =
+ new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+ new DiagnosticListener<JavaFileObject>() {
+
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ errors.add(diagnostic);
+ }
+ }, null, null, Arrays.asList(new MyFileObject(code)));
+
+ final CompilationUnitTree cut = ct.parse().iterator().next();
+ final Trees trees = Trees.instance(ct);
+
+ new TreeScanner<Void, Void>() {
+
+ private long parentStart = 0;
+ private long parentEnd = Integer.MAX_VALUE;
+
+ @Override
+ public Void scan(Tree node, Void p) {
+ if (node == null) {
+ return null;
+ }
+
+ long start = trees.getSourcePositions().getStartPosition(cut, node);
+
+ if (start == (-1)) {
+ return null; //synthetic tree
+ }
+ assertTrue(node.toString() + ":" + start + "/" + parentStart,
+ parentStart <= start);
+
+ long prevParentStart = parentStart;
+
+ parentStart = start;
+
+ long end = trees.getSourcePositions().getEndPosition(cut, node);
+
+ assertTrue(node.toString() + ":" + end + "/" + parentEnd,
+ end <= parentEnd);
+
+ long prevParentEnd = parentEnd;
+
+ parentEnd = end;
+
+ super.scan(node, p);
+
+ parentStart = prevParentStart;
+ parentEnd = prevParentEnd;
+
+ return null;
+ }
+
+ private void assertTrue(String message, boolean b) {
+ if (!b) fail(message);
+ }
+ }.scan(cut, null);
+ }
+
+ public void testCorrectWilcardPositions() throws IOException {
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { List<? extends List<? extends String>> l; } }",
+
+ Arrays.asList("List<? extends List<? extends String>> l;",
+ "List<? extends List<? extends String>>",
+ "List",
+ "? extends List<? extends String>",
+ "List<? extends String>",
+ "List",
+ "? extends String",
+ "String"));
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { List<? super List<? super String>> l; } }",
+
+ Arrays.asList("List<? super List<? super String>> l;",
+ "List<? super List<? super String>>",
+ "List",
+ "? super List<? super String>",
+ "List<? super String>",
+ "List",
+ "? super String",
+ "String"));
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { List<? super List<?>> l; } }",
+
+ Arrays.asList("List<? super List<?>> l;",
+ "List<? super List<?>>",
+ "List",
+ "? super List<?>",
+ "List<?>",
+ "List",
+ "?"));
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { " +
+ "List<? extends List<? extends List<? extends String>>> l; } }",
+
+ Arrays.asList("List<? extends List<? extends List<? extends String>>> l;",
+ "List<? extends List<? extends List<? extends String>>>",
+ "List",
+ "? extends List<? extends List<? extends String>>",
+ "List<? extends List<? extends String>>",
+ "List",
+ "? extends List<? extends String>",
+ "List<? extends String>",
+ "List",
+ "? extends String",
+ "String"));
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { " +
+ "List<? extends List<? extends List<? extends String >>> l; } }",
+ Arrays.asList("List<? extends List<? extends List<? extends String >>> l;",
+ "List<? extends List<? extends List<? extends String >>>",
+ "List",
+ "? extends List<? extends List<? extends String >>",
+ "List<? extends List<? extends String >>",
+ "List",
+ "? extends List<? extends String >",
+ "List<? extends String >",
+ "List",
+ "? extends String",
+ "String"));
+ }
+
+ public void performWildcardPositionsTest(final String code,
+ List<String> golden) throws IOException {
+
+ final List<Diagnostic<? extends JavaFileObject>> errors =
+ new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+ new DiagnosticListener<JavaFileObject>() {
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ errors.add(diagnostic);
+ }
+ }, null, null, Arrays.asList(new MyFileObject(code)));
+
+ final CompilationUnitTree cut = ct.parse().iterator().next();
+ final List<String> content = new LinkedList<String>();
+ final Trees trees = Trees.instance(ct);
+
+ new TreeScanner<Void, Void>() {
+ @Override
+ public Void scan(Tree node, Void p) {
+ if (node == null) {
+ return null;
+ }
+ long start = trees.getSourcePositions().getStartPosition(cut, node);
+
+ if (start == (-1)) {
+ return null; //synthetic tree
+ }
+ long end = trees.getSourcePositions().getEndPosition(cut, node);
+ String s = code.substring((int) start, (int) end);
+ content.add(s);
+
+ return super.scan(node, p);
+ }
+ }.scan(((MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0)).getBody().getStatements().get(0), null);
+
+ assertEquals("performWildcardPositionsTest",golden.toString(),
+ content.toString());
+ }
+
+ public void testStartPositionForMethodWithoutModifiers() throws IOException {
+
+ String code = "package t; class Test { <T> void t() {} }";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ MethodTree mt = (MethodTree) clazz.getMembers().get(0);
+ Trees t = Trees.instance(ct);
+ int start = (int) t.getSourcePositions().getStartPosition(cut, mt);
+ int end = (int) t.getSourcePositions().getEndPosition(cut, mt);
+
+ assertEquals("testStartPositionForMethodWithoutModifiers",
+ "<T> void t() {}", code.substring(start, end));
+ }
+
+ public void testStartPositionEnumConstantInit() throws IOException {
+
+ String code = "package t; enum Test { AAA; }";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ VariableTree enumAAA = (VariableTree) clazz.getMembers().get(0);
+ Trees t = Trees.instance(ct);
+ int start = (int) t.getSourcePositions().getStartPosition(cut,
+ enumAAA.getInitializer());
+
+ assertEquals("testStartPositionEnumConstantInit", -1, start);
+ }
+
+ public void testVariableInIfThen1() throws IOException {
+
+ String code = "package t; class Test { " +
+ "private static void t(String name) { " +
+ "if (name != null) String nn = name.trim(); } }";
+
+ DiagnosticCollector<JavaFileObject> coll =
+ new DiagnosticCollector<JavaFileObject>();
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ ct.parse();
+
+ List<String> codes = new LinkedList<String>();
+
+ for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+ codes.add(d.getCode());
+ }
+
+ assertEquals("testVariableInIfThen1",
+ Arrays.<String>asList("compiler.err.variable.not.allowed"),
+ codes);
+ }
+
+ public void testVariableInIfThen2() throws IOException {
+
+ String code = "package t; class Test { " +
+ "private static void t(String name) { " +
+ "if (name != null) class X {} } }";
+ DiagnosticCollector<JavaFileObject> coll =
+ new DiagnosticCollector<JavaFileObject>();
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ ct.parse();
+
+ List<String> codes = new LinkedList<String>();
+
+ for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+ codes.add(d.getCode());
+ }
+
+ assertEquals("testVariableInIfThen2",
+ Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
+ }
+
+ public void testVariableInIfThen3() throws IOException {
+
+ String code = "package t; class Test { "+
+ "private static void t(String name) { " +
+ "if (name != null) abstract } }";
+ DiagnosticCollector<JavaFileObject> coll =
+ new DiagnosticCollector<JavaFileObject>();
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ ct.parse();
+
+ List<String> codes = new LinkedList<String>();
+
+ for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+ codes.add(d.getCode());
+ }
+
+ assertEquals("testVariableInIfThen3",
+ Arrays.<String>asList("compiler.err.illegal.start.of.expr"),
+ codes);
+ }
+
+ //see javac bug #6882235, NB bug #98234:
+ public void testMissingExponent() throws IOException {
+
+ String code = "\nclass Test { { System.err.println(0e); } }";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ assertNotNull(ct.parse().iterator().next());
+ }
+
+ public void testTryResourcePos() throws IOException {
+
+ final String code = "package t; class Test { " +
+ "{ try (java.io.InputStream in = null) { } } }";
+
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+
+ new TreeScanner<Void, Void>() {
+ @Override
+ public Void visitVariable(VariableTree node, Void p) {
+ if ("in".contentEquals(node.getName())) {
+ JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
+ System.out.println(node.getName() + "," + var.pos);
+ assertEquals("testTryResourcePos", "in = null) { } } }",
+ code.substring(var.pos));
+ }
+ return super.visitVariable(node, p);
+ }
+ }.scan(cut, null);
+ }
+
+ public void testVarPos() throws IOException {
+
+ final String code = "package t; class Test { " +
+ "{ java.io.InputStream in = null; } }";
+
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+
+ new TreeScanner<Void, Void>() {
+
+ @Override
+ public Void visitVariable(VariableTree node, Void p) {
+ if ("in".contentEquals(node.getName())) {
+ JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
+ assertEquals("testVarPos","in = null; } }",
+ code.substring(var.pos));
+ }
+ return super.visitVariable(node, p);
+ }
+ }.scan(cut, null);
+ }
+
+ // expected erroneous tree: int x = y;(ERROR);
+ public void testOperatorMissingError() throws IOException {
+
+ String code = "package test; public class ErrorTest { "
+ + "void method() { int x = y z } }";
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+ final List<String> values = new ArrayList<>();
+ final List<String> expectedValues =
+ new ArrayList<>(Arrays.asList("[z]"));
+
+ new TreeScanner<Void, Void>() {
+
+ @Override
+ public Void visitErroneous(ErroneousTree node, Void p) {
+
+ values.add(getErroneousTreeValues(node).toString());
+ return null;
+
+ }
+ }.scan(cut, null);
+
+ assertEquals("testSwitchError: The Erroneous tree "
+ + "error values: " + values
+ + " do not match expected error values: "
+ + expectedValues, values, expectedValues);
+ }
+
+ //expected erroneous tree: String s = (ERROR);
+ public void testMissingParenthesisError() throws IOException {
+
+ String code = "package test; public class ErrorTest { "
+ + "void f() {String s = new String; } }";
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+ final List<String> values = new ArrayList<>();
+ final List<String> expectedValues =
+ new ArrayList<>(Arrays.asList("[new String()]"));
+
+ new TreeScanner<Void, Void>() {
+
+ @Override
+ public Void visitErroneous(ErroneousTree node, Void p) {
+
+ values.add(getErroneousTreeValues(node).toString());
+ return null;
+ }
+ }.scan(cut, null);
+
+ assertEquals("testSwitchError: The Erroneous tree "
+ + "error values: " + values
+ + " do not match expected error values: "
+ + expectedValues, values, expectedValues);
+ }
+
+ //expected erroneous tree: package test; (ERROR)(ERROR)
+ public void testMissingClassError() throws IOException {
+
+ String code = "package Test; clas ErrorTest { "
+ + "void f() {String s = new String(); } }";
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+ final List<String> values = new ArrayList<>();
+ final List<String> expectedValues =
+ new ArrayList<>(Arrays.asList("[, clas]", "[]"));
+
+ new TreeScanner<Void, Void>() {
+
+ @Override
+ public Void visitErroneous(ErroneousTree node, Void p) {
+
+ values.add(getErroneousTreeValues(node).toString());
+ return null;
+ }
+ }.scan(cut, null);
+
+ assertEquals("testSwitchError: The Erroneous tree "
+ + "error values: " + values
+ + " do not match expected error values: "
+ + expectedValues, values, expectedValues);
+ }
+
+ //expected erroneous tree: void m1(int i) {(ERROR);{(ERROR);}
+ public void testSwitchError() throws IOException {
+
+ String code = "package test; public class ErrorTest { "
+ + "int numDays; void m1(int i) { switchh {i} { case 1: "
+ + "numDays = 31; break; } } }";
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+ final List<String> values = new ArrayList<>();
+ final List<String> expectedValues =
+ new ArrayList<>(Arrays.asList("[switchh]", "[i]"));
+
+ new TreeScanner<Void, Void>() {
+
+ @Override
+ public Void visitErroneous(ErroneousTree node, Void p) {
+
+ values.add(getErroneousTreeValues(node).toString());
+ return null;
+ }
+ }.scan(cut, null);
+
+ assertEquals("testSwitchError: The Erroneous tree "
+ + "error values: " + values
+ + " do not match expected error values: "
+ + expectedValues, values, expectedValues);
+ }
+
+ //expected erroneous tree: class ErrorTest {(ERROR)
+ public void testMethodError() throws IOException {
+
+ String code = "package Test; class ErrorTest { "
+ + "static final void f) {String s = new String(); } }";
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+ final List<String> values = new ArrayList<>();
+ final List<String> expectedValues =
+ new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));
+
+ new TreeScanner<Void, Void>() {
+
+ @Override
+ public Void visitErroneous(ErroneousTree node, Void p) {
+
+ values.add(normalize(getErroneousTreeValues(node).toString()));
+ return null;
+ }
+ }.scan(cut, null);
+
+ assertEquals("testMethodError: The Erroneous tree "
+ + "error value: " + values
+ + " does not match expected error values: "
+ + expectedValues, values, expectedValues);
+ }
+
+ void testsNotWorking() throws IOException {
+
+ // Fails with nb-javac, needs further investigation
+ testPositionBrokenSource126732a();
+ testPositionBrokenSource126732b();
+
+ // Fails, these tests yet to be addressed
+ testVariableInIfThen1();
+ testVariableInIfThen2();
+ testPositionForEnumModifiers();
+ testStartPositionEnumConstantInit();
+ }
+ void testPositions() throws IOException {
+ testPositionsSane();
+ testCorrectWilcardPositions();
+ testPositionAnnotationNoPackage187551();
+ testPositionForSuperConstructorCalls();
+ testPreferredPositionForBinaryOp();
+ testStartPositionForMethodWithoutModifiers();
+ testVarPos();
+ testVariableInIfThen3();
+ testMissingExponent();
+ testTryResourcePos();
+ testOperatorMissingError();
+ testMissingParenthesisError();
+ testMissingClassError();
+ testSwitchError();
+ testMethodError();
+ }
+
+ public static void main(String... args) throws IOException {
+ JavacParserTest jpt = new JavacParserTest("JavacParserTest");
+ jpt.testPositions();
+ System.out.println("PASS");
+ }
+}
+
+abstract class TestCase {
+
+ void assertEquals(String message, int i, int pos) {
+ if (i != pos) {
+ fail(message);
+ }
+ }
+
+ void assertFalse(String message, boolean empty) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ void assertEquals(String message, int i, long l) {
+ if (i != l) {
+ fail(message + ":" + i + ":" + l);
+ }
+ }
+
+ void assertEquals(String message, Object o1, Object o2) {
+ System.out.println(o1);
+ System.out.println(o2);
+ if (o1 != null && o2 != null && !o1.equals(o2)) {
+ fail(message);
+ }
+ if (o1 == null && o2 != null) {
+ fail(message);
+ }
+ }
+
+ void assertNotNull(Object o) {
+ if (o == null) {
+ fail();
+ }
+ }
+
+ void fail() {
+ fail("test failed");
+ }
+
+ void fail(String message) {
+ throw new RuntimeException(message);
+ }
+}
--- a/langtools/test/tools/javac/parser/netbeans/JavacParserTest.java Tue Dec 13 15:41:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,716 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 7073631
- * @summary tests error and diagnostics positions
- * @author jan.lahoda@oracle.com
- */
-
-import com.sun.source.tree.BinaryTree;
-import com.sun.source.tree.BlockTree;
-import com.sun.source.tree.ClassTree;
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.ExpressionStatementTree;
-import com.sun.source.tree.ExpressionTree;
-import com.sun.source.tree.MethodInvocationTree;
-import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.ModifiersTree;
-import com.sun.source.tree.StatementTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.tree.Tree.Kind;
-import com.sun.source.tree.VariableTree;
-import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
-import com.sun.source.util.Trees;
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.tree.JCTree;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticCollector;
-import javax.tools.DiagnosticListener;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-import javax.tools.ToolProvider;
-
-public class JavacParserTest extends TestCase {
- final JavaCompiler tool;
- public JavacParserTest(String testName) {
- tool = ToolProvider.getSystemJavaCompiler();
- System.out.println("java.home=" + System.getProperty("java.home"));
- }
-
- static class MyFileObject extends SimpleJavaFileObject {
-
- private String text;
-
- public MyFileObject(String text) {
- super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
- this.text = text;
- }
-
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors) {
- return text;
- }
- }
-
- public void testPositionForSuperConstructorCalls() throws IOException {
- assert tool != null;
-
- String code = "package test; public class Test {public Test() {super();}}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- SourcePositions pos = Trees.instance(ct).getSourcePositions();
-
- MethodTree method =
- (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
- ExpressionStatementTree es =
- (ExpressionStatementTree) method.getBody().getStatements().get(0);
-
- assertEquals("testPositionForSuperConstructorCalls",
- 72 - 24, pos.getStartPosition(cut, es));
- assertEquals("testPositionForSuperConstructorCalls",
- 80 - 24, pos.getEndPosition(cut, es));
-
- MethodInvocationTree mit = (MethodInvocationTree) es.getExpression();
-
- assertEquals("testPositionForSuperConstructorCalls",
- 72 - 24, pos.getStartPosition(cut, mit));
- assertEquals("testPositionForSuperConstructorCalls",
- 79 - 24, pos.getEndPosition(cut, mit));
-
- assertEquals("testPositionForSuperConstructorCalls",
- 72 - 24, pos.getStartPosition(cut, mit.getMethodSelect()));
- assertEquals("testPositionForSuperConstructorCalls",
- 77 - 24, pos.getEndPosition(cut, mit.getMethodSelect()));
-
- }
-
- public void testPositionForEnumModifiers() throws IOException {
-
- String code = "package test; public enum Test {A;}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- SourcePositions pos = Trees.instance(ct).getSourcePositions();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- ModifiersTree mt = clazz.getModifiers();
-
- assertEquals("testPositionForEnumModifiers",
- 38 - 24, pos.getStartPosition(cut, mt));
- assertEquals("testPositionForEnumModifiers",
- 44 - 24, pos.getEndPosition(cut, mt));
- }
-
- public void testNewClassWithEnclosing() throws IOException {
-
-
- String code = "package test; class Test { " +
- "class d {} private void method() { " +
- "Object o = Test.this.new d(); } }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- SourcePositions pos = Trees.instance(ct).getSourcePositions();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- ExpressionTree est =
- ((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
-
- assertEquals("testNewClassWithEnclosing",
- 97 - 24, pos.getStartPosition(cut, est));
- assertEquals("testNewClassWithEnclosing",
- 114 - 24, pos.getEndPosition(cut, est));
- }
-
- public void testPreferredPositionForBinaryOp() throws IOException {
-
- String code = "package test; public class Test {" +
- "private void test() {" +
- "Object o = null; boolean b = o != null && o instanceof String;" +
- "} private Test() {}}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- MethodTree method = (MethodTree) clazz.getMembers().get(0);
- VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1);
- BinaryTree cond = (BinaryTree) condSt.getInitializer();
-
- JCTree condJC = (JCTree) cond;
-
- assertEquals("testNewClassWithEnclosing",
- 117 - 24, condJC.pos);
- }
-
- public void testPositionBrokenSource126732a() throws IOException {
- String[] commands = new String[]{
- "return Runnable()",
- "do { } while (true)",
- "throw UnsupportedOperationException()",
- "assert true",
- "1 + 1",};
-
- for (String command : commands) {
-
- String code = "package test;\n"
- + "public class Test {\n"
- + " public static void test() {\n"
- + " " + command + " {\n"
- + " new Runnable() {\n"
- + " };\n"
- + " }\n"
- + "}";
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
- null, null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- MethodTree method = (MethodTree) clazz.getMembers().get(0);
- List<? extends StatementTree> statements =
- method.getBody().getStatements();
-
- StatementTree ret = statements.get(0);
- StatementTree block = statements.get(1);
-
- Trees t = Trees.instance(ct);
- int len = code.indexOf(command + " {") + (command + " ").length();
- assertEquals(command, len,
- t.getSourcePositions().getEndPosition(cut, ret));
- assertEquals(command, len,
- t.getSourcePositions().getStartPosition(cut, block));
- }
- }
-
- public void testPositionBrokenSource126732b() throws IOException {
- String[] commands = new String[]{
- "break",
- "break A",
- "continue ",
- "continue A",};
-
- for (String command : commands) {
-
- String code = "package test;\n"
- + "public class Test {\n"
- + " public static void test() {\n"
- + " while (true) {\n"
- + " " + command + " {\n"
- + " new Runnable() {\n"
- + " };\n"
- + " }\n"
- + " }\n"
- + "}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
- null, null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- MethodTree method = (MethodTree) clazz.getMembers().get(0);
- List<? extends StatementTree> statements =
- ((BlockTree) ((WhileLoopTree) method.getBody().getStatements().get(0)).getStatement()).getStatements();
-
- StatementTree ret = statements.get(0);
- StatementTree block = statements.get(1);
-
- Trees t = Trees.instance(ct);
- int len = code.indexOf(command + " {") + (command + " ").length();
- assertEquals(command, len,
- t.getSourcePositions().getEndPosition(cut, ret));
- assertEquals(command, len,
- t.getSourcePositions().getStartPosition(cut, block));
- }
- }
-
- public void testErrorRecoveryForEnhancedForLoop142381() throws IOException {
-
- String code = "package test; class Test { " +
- "private void method() { " +
- "java.util.Set<String> s = null; for (a : s) {} } }";
-
- final List<Diagnostic<? extends JavaFileObject>> errors =
- new LinkedList<Diagnostic<? extends JavaFileObject>>();
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
- new DiagnosticListener<JavaFileObject>() {
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- errors.add(diagnostic);
- }
- }, null, null, Arrays.asList(new MyFileObject(code)));
-
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- StatementTree forStatement =
- ((MethodTree) clazz.getMembers().get(0)).getBody().getStatements().get(1);
-
- assertEquals("testErrorRecoveryForEnhancedForLoop142381",
- Kind.ENHANCED_FOR_LOOP, forStatement.getKind());
- assertFalse("testErrorRecoveryForEnhancedForLoop142381", errors.isEmpty());
- }
-
- public void testPositionAnnotationNoPackage187551() throws IOException {
-
- String code = "\n@interface Test {}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- CompilationUnitTree cut = ct.parse().iterator().next();
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- Trees t = Trees.instance(ct);
-
- assertEquals("testPositionAnnotationNoPackage187551",
- 1, t.getSourcePositions().getStartPosition(cut, clazz));
- }
-
- public void testPositionsSane() throws IOException {
- performPositionsSanityTest("package test; class Test { " +
- "private void method() { " +
- "java.util.List<? extends java.util.List<? extends String>> l; " +
- "} }");
- performPositionsSanityTest("package test; class Test { " +
- "private void method() { " +
- "java.util.List<? super java.util.List<? super String>> l; " +
- "} }");
- performPositionsSanityTest("package test; class Test { " +
- "private void method() { " +
- "java.util.List<? super java.util.List<?>> l; } }");
- }
-
- private void performPositionsSanityTest(String code) throws IOException {
-
- final List<Diagnostic<? extends JavaFileObject>> errors =
- new LinkedList<Diagnostic<? extends JavaFileObject>>();
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
- new DiagnosticListener<JavaFileObject>() {
-
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- errors.add(diagnostic);
- }
- }, null, null, Arrays.asList(new MyFileObject(code)));
-
- final CompilationUnitTree cut = ct.parse().iterator().next();
- final Trees trees = Trees.instance(ct);
-
- new TreeScanner<Void, Void>() {
-
- private long parentStart = 0;
- private long parentEnd = Integer.MAX_VALUE;
-
- @Override
- public Void scan(Tree node, Void p) {
- if (node == null) {
- return null;
- }
-
- long start = trees.getSourcePositions().getStartPosition(cut, node);
-
- if (start == (-1)) {
- return null; //synthetic tree
- }
- assertTrue(node.toString() + ":" + start + "/" + parentStart,
- parentStart <= start);
-
- long prevParentStart = parentStart;
-
- parentStart = start;
-
- long end = trees.getSourcePositions().getEndPosition(cut, node);
-
- assertTrue(node.toString() + ":" + end + "/" + parentEnd,
- end <= parentEnd);
-
- long prevParentEnd = parentEnd;
-
- parentEnd = end;
-
- super.scan(node, p);
-
- parentStart = prevParentStart;
- parentEnd = prevParentEnd;
-
- return null;
- }
-
- private void assertTrue(String message, boolean b) {
- if (!b) fail(message);
- }
- }.scan(cut, null);
- }
-
- public void testCorrectWilcardPositions() throws IOException {
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { List<? extends List<? extends String>> l; } }",
-
- Arrays.asList("List<? extends List<? extends String>> l;",
- "List<? extends List<? extends String>>",
- "List",
- "? extends List<? extends String>",
- "List<? extends String>",
- "List",
- "? extends String",
- "String"));
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { List<? super List<? super String>> l; } }",
-
- Arrays.asList("List<? super List<? super String>> l;",
- "List<? super List<? super String>>",
- "List",
- "? super List<? super String>",
- "List<? super String>",
- "List",
- "? super String",
- "String"));
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { List<? super List<?>> l; } }",
-
- Arrays.asList("List<? super List<?>> l;",
- "List<? super List<?>>",
- "List",
- "? super List<?>",
- "List<?>",
- "List",
- "?"));
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { " +
- "List<? extends List<? extends List<? extends String>>> l; } }",
-
- Arrays.asList("List<? extends List<? extends List<? extends String>>> l;",
- "List<? extends List<? extends List<? extends String>>>",
- "List",
- "? extends List<? extends List<? extends String>>",
- "List<? extends List<? extends String>>",
- "List",
- "? extends List<? extends String>",
- "List<? extends String>",
- "List",
- "? extends String",
- "String"));
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { " +
- "List<? extends List<? extends List<? extends String >>> l; } }",
- Arrays.asList("List<? extends List<? extends List<? extends String >>> l;",
- "List<? extends List<? extends List<? extends String >>>",
- "List",
- "? extends List<? extends List<? extends String >>",
- "List<? extends List<? extends String >>",
- "List",
- "? extends List<? extends String >",
- "List<? extends String >",
- "List",
- "? extends String",
- "String"));
- }
-
- public void performWildcardPositionsTest(final String code,
- List<String> golden) throws IOException {
-
- final List<Diagnostic<? extends JavaFileObject>> errors =
- new LinkedList<Diagnostic<? extends JavaFileObject>>();
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
- new DiagnosticListener<JavaFileObject>() {
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- errors.add(diagnostic);
- }
- }, null, null, Arrays.asList(new MyFileObject(code)));
-
- final CompilationUnitTree cut = ct.parse().iterator().next();
- final List<String> content = new LinkedList<String>();
- final Trees trees = Trees.instance(ct);
-
- new TreeScanner<Void, Void>() {
- @Override
- public Void scan(Tree node, Void p) {
- if (node == null) {
- return null;
- }
- long start = trees.getSourcePositions().getStartPosition(cut, node);
-
- if (start == (-1)) {
- return null; //synthetic tree
- }
- long end = trees.getSourcePositions().getEndPosition(cut, node);
- String s = code.substring((int) start, (int) end);
- content.add(s);
-
- return super.scan(node, p);
- }
- }.scan(((MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0)).getBody().getStatements().get(0), null);
-
- assertEquals("performWildcardPositionsTest",golden.toString(),
- content.toString());
- }
-
- public void testStartPositionForMethodWithoutModifiers() throws IOException {
-
- String code = "package t; class Test { <T> void t() {} }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- MethodTree mt = (MethodTree) clazz.getMembers().get(0);
- Trees t = Trees.instance(ct);
- int start = (int) t.getSourcePositions().getStartPosition(cut, mt);
- int end = (int) t.getSourcePositions().getEndPosition(cut, mt);
-
- assertEquals("testStartPositionForMethodWithoutModifiers",
- "<T> void t() {}", code.substring(start, end));
- }
-
- public void testStartPositionEnumConstantInit() throws IOException {
-
- String code = "package t; enum Test { AAA; }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- VariableTree enumAAA = (VariableTree) clazz.getMembers().get(0);
- Trees t = Trees.instance(ct);
- int start = (int) t.getSourcePositions().getStartPosition(cut,
- enumAAA.getInitializer());
-
- assertEquals("testStartPositionEnumConstantInit", -1, start);
- }
-
- public void testVariableInIfThen1() throws IOException {
-
- String code = "package t; class Test { " +
- "private static void t(String name) { " +
- "if (name != null) String nn = name.trim(); } }";
-
- DiagnosticCollector<JavaFileObject> coll =
- new DiagnosticCollector<JavaFileObject>();
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- ct.parse();
-
- List<String> codes = new LinkedList<String>();
-
- for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
- codes.add(d.getCode());
- }
-
- assertEquals("testVariableInIfThen1",
- Arrays.<String>asList("compiler.err.variable.not.allowed"),
- codes);
- }
-
- public void testVariableInIfThen2() throws IOException {
-
- String code = "package t; class Test { " +
- "private static void t(String name) { " +
- "if (name != null) class X {} } }";
- DiagnosticCollector<JavaFileObject> coll =
- new DiagnosticCollector<JavaFileObject>();
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- ct.parse();
-
- List<String> codes = new LinkedList<String>();
-
- for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
- codes.add(d.getCode());
- }
-
- assertEquals("testVariableInIfThen2",
- Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
- }
-
- public void testVariableInIfThen3() throws IOException {
-
- String code = "package t; class Test { "+
- "private static void t(String name) { " +
- "if (name != null) abstract } }";
- DiagnosticCollector<JavaFileObject> coll =
- new DiagnosticCollector<JavaFileObject>();
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- ct.parse();
-
- List<String> codes = new LinkedList<String>();
-
- for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
- codes.add(d.getCode());
- }
-
- assertEquals("testVariableInIfThen3",
- Arrays.<String>asList("compiler.err.illegal.start.of.expr"),
- codes);
- }
-
- //see javac bug #6882235, NB bug #98234:
- public void testMissingExponent() throws IOException {
-
- String code = "\nclass Test { { System.err.println(0e); } }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- assertNotNull(ct.parse().iterator().next());
- }
-
- public void testTryResourcePos() throws IOException {
-
- final String code = "package t; class Test { " +
- "{ try (java.io.InputStream in = null) { } } }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- new TreeScanner<Void, Void>() {
- @Override
- public Void visitVariable(VariableTree node, Void p) {
- if ("in".contentEquals(node.getName())) {
- JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
- System.out.println(node.getName() + "," + var.pos);
- assertEquals("testTryResourcePos", "in = null) { } } }",
- code.substring(var.pos));
- }
- return super.visitVariable(node, p);
- }
- }.scan(cut, null);
- }
-
- public void testVarPos() throws IOException {
-
- final String code = "package t; class Test { " +
- "{ java.io.InputStream in = null; } }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- new TreeScanner<Void, Void>() {
-
- @Override
- public Void visitVariable(VariableTree node, Void p) {
- if ("in".contentEquals(node.getName())) {
- JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
- assertEquals("testVarPos","in = null; } }",
- code.substring(var.pos));
- }
- return super.visitVariable(node, p);
- }
- }.scan(cut, null);
- }
-
- void testsNotWorking() throws IOException {
-
- // Fails with nb-javac, needs further investigation
- testPositionBrokenSource126732a();
- testPositionBrokenSource126732b();
-
- // Fails, these tests yet to be addressed
- testVariableInIfThen1();
- testVariableInIfThen2();
- testPositionForEnumModifiers();
- testStartPositionEnumConstantInit();
- }
- void testPositions() throws IOException {
- testPositionsSane();
- testCorrectWilcardPositions();
- testPositionAnnotationNoPackage187551();
- testPositionForSuperConstructorCalls();
- testPreferredPositionForBinaryOp();
- testStartPositionForMethodWithoutModifiers();
- testVarPos();
- testVariableInIfThen3();
- testTryResourcePos();
- }
-
- public static void main(String... args) throws IOException {
- JavacParserTest jpt = new JavacParserTest("JavacParserTest");
- jpt.testPositions();
- System.out.println("PASS");
- }
-}
-
-abstract class TestCase {
-
- void assertEquals(String message, int i, int pos) {
- if (i != pos) {
- fail(message);
- }
- }
-
- void assertFalse(String message, boolean empty) {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- void assertEquals(String message, int i, long l) {
- if (i != l) {
- fail(message + ":" + i + ":" + l);
- }
- }
-
- void assertEquals(String message, Object o1, Object o2) {
- System.out.println(o1);
- System.out.println(o2);
- if (o1 != null && o2 != null && !o1.equals(o2)) {
- fail(message);
- }
- if (o1 == null && o2 != null) {
- fail(message);
- }
- }
-
- void assertNotNull(Object o) {
- if (o == null) {
- fail();
- }
- }
-
- void fail() {
- fail("test failed");
- }
-
- void fail(String message) {
- throw new RuntimeException(message);
- }
-}
--- a/langtools/test/tools/javac/quid/T6999438.out Tue Dec 13 15:41:47 2011 -0800
+++ b/langtools/test/tools/javac/quid/T6999438.out Thu Dec 15 19:52:13 2011 -0800
@@ -1,4 +1,4 @@
-T6999438.java:8:9: compiler.err.illegal.char: 35
+T6999438.java:8:8: compiler.err.expected: token.identifier
T6999438.java:8:10: compiler.err.illegal.start.of.type
T6999438.java:8:25: compiler.err.expected: token.identifier
T6999438.java:8:26: compiler.err.expected: ';'