mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 20:14:43 +02:00
6750288: Regression after 6315717. ArrayIndexOutOfBoundsException
Reviewed-by: dcherepanov, denis
This commit is contained in:
parent
bfec071cbf
commit
90f6b8301e
1 changed files with 21 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue