jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
changeset 2810 fa49c6a06baf
parent 2803 e0fa1a27f1c1
child 3083 1954edd3b7a7
equal deleted inserted replaced
2809:b373581f6507 2810:fa49c6a06baf
    83     //Is it allowed to generate events assigned to extra mouse buttons.
    83     //Is it allowed to generate events assigned to extra mouse buttons.
    84     //Set to true by default.
    84     //Set to true by default.
    85     private static boolean areExtraMouseButtonsEnabled = true;
    85     private static boolean areExtraMouseButtonsEnabled = true;
    86 
    86 
    87     /**
    87     /**
    88      * Number of buttons.
       
    89      * By default it's taken from the system. If system value does not
       
    90      * fit into int type range, use our own MAX_BUTTONS_SUPPORT value.
       
    91      */
       
    92     private static int numberOfButtons = 0;
       
    93 
       
    94     /* XFree standard mention 24 buttons as maximum:
       
    95      * http://www.xfree86.org/current/mouse.4.html
       
    96      * We workaround systems supporting more than 24 buttons.
       
    97      * Otherwise, we have to use long type values as masks
       
    98      * which leads to API change.
       
    99      */
       
   100     private static int MAX_BUTTONS_SUPPORT = 24;
       
   101 
       
   102     /**
       
   103      * True when the x settings have been loaded.
    88      * True when the x settings have been loaded.
   104      */
    89      */
   105     private boolean loadedXSettings;
    90     private boolean loadedXSettings;
   106 
    91 
   107     /**
    92     /**
  1456         // Don't want to call getMultiClickTime() if we are headless
  1441         // Don't want to call getMultiClickTime() if we are headless
  1457         if (!GraphicsEnvironment.isHeadless()) {
  1442         if (!GraphicsEnvironment.isHeadless()) {
  1458             desktopProperties.put("awt.multiClickInterval",
  1443             desktopProperties.put("awt.multiClickInterval",
  1459                                   Integer.valueOf(getMultiClickTime()));
  1444                                   Integer.valueOf(getMultiClickTime()));
  1460             desktopProperties.put("awt.mouse.numButtons",
  1445             desktopProperties.put("awt.mouse.numButtons",
  1461                                   Integer.valueOf(getNumMouseButtons()));
  1446                                   Integer.valueOf(getNumberOfButtons()));
  1462         }
  1447         }
  1463     }
  1448     }
  1464 
  1449 
  1465     public static int getNumMouseButtons() {
  1450     /**
       
  1451      * This method runs through the XPointer and XExtendedPointer array.
       
  1452      * XExtendedPointer has priority because on some systems XPointer
       
  1453      * (which is assigned to the virtual pointer) reports the maximum
       
  1454      * capabilities of the mouse pointer (i.e. 32 physical buttons).
       
  1455      */
       
  1456     private native synchronized int getNumberOfButtonsImpl();
       
  1457 
       
  1458     @Override
       
  1459     public int getNumberOfButtons(){
  1466         awtLock();
  1460         awtLock();
  1467         try {
  1461         try {
  1468             if (numberOfButtons == 0) {
  1462             if (numberOfButtons == 0) {
  1469                 numberOfButtons = Math.min(
  1463                 numberOfButtons = getNumberOfButtonsImpl();
  1470                     XlibWrapper.XGetPointerMapping(XToolkit.getDisplay(), 0, 0),
  1464             }
  1471                     MAX_BUTTONS_SUPPORT);
  1465             return (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
  1472             }
       
  1473             return numberOfButtons;
       
  1474         } finally {
  1466         } finally {
  1475             awtUnlock();
  1467             awtUnlock();
  1476         }
  1468         }
  1477     }
  1469     }
  1478 
  1470