6750288: Regression after 6315717. ArrayIndexOutOfBoundsException.
Reviewed-by: dcherepanov, denis
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Fri Oct 03 10:33:11 2008 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Tue Oct 07 16:34:27 2008 +0400
@@ -79,6 +79,21 @@
private static boolean areExtraMouseButtonsEnabled = true;
/**
+ * Number of buttons.
+ * By default it's taken from the system. If system value does not
+ * fit into int type range, use our own MAX_BUTTONS_SUPPORT value.
+ */
+ private static int numberOfButtons = 0;
+
+ /* XFree standard mention 24 buttons as maximum:
+ * http://www.xfree86.org/current/mouse.4.html
+ * We workaround systems supporting more than 24 buttons.
+ * Otherwise, we have to use long type values as masks
+ * which leads to API change.
+ */
+ private static int MAX_BUTTONS_SUPPORT = 24;
+
+ /**
* True when the x settings have been loaded.
*/
private boolean loadedXSettings;
@@ -1393,7 +1408,12 @@
public static int getNumMouseButtons() {
awtLock();
try {
- return XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0);
+ if (numberOfButtons == 0) {
+ numberOfButtons = Math.min(
+ XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0),
+ MAX_BUTTONS_SUPPORT);
+ }
+ return numberOfButtons;
} finally {
awtUnlock();
}