提交 b5c7d8c2 编写于 作者: D dav

6750288: Regression after 6315717. ArrayIndexOutOfBoundsException.

Reviewed-by: dcherepanov, denis
上级 41fecd55
......@@ -78,6 +78,21 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
//Set to true by default.
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.
*/
......@@ -1393,7 +1408,12 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
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();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册