< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XWindow.java

Print this page




 604         //reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc.
 605         for (int i = 0; i < XConstants.buttons.length; i ++){
 606             //modifier should be added if :
 607             // 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or
 608             // 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons.
 609             // ONLY one of these conditions should be TRUE to add that modifier.
 610             if (((state & XlibUtil.getButtonMask(i + 1)) != 0) != (button == XConstants.buttons[i])){
 611                 //exclude wheel buttons from adding their numbers as modifiers
 612                 if (!isWheelMouse || !isWheel(XConstants.buttons[i])) {
 613                     modifiers |= InputEvent.getMaskForButton(i+1);
 614                 }
 615             }
 616         }
 617         return modifiers;
 618     }
 619 
 620     static boolean isWheel(int button) {
 621         // 4 and 5 buttons are usually considered assigned to a first wheel
 622         return button == XConstants.buttons[3] || button == XConstants.buttons[4];
 623     }
 624 
 625     static int getXModifiers(AWTKeyStroke stroke) {
 626         int mods = stroke.getModifiers();
 627         int res = 0;
 628         if ((mods & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) {
 629             res |= XConstants.ShiftMask;
 630         }
 631         if ((mods & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) {
 632             res |= XConstants.ControlMask;
 633         }
 634         if ((mods & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) {
 635             res |= XToolkit.altMask;
 636         }
 637         if ((mods & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) {
 638             res |= XToolkit.metaMask;
 639         }
 640         if ((mods & (InputEvent.ALT_GRAPH_DOWN_MASK | InputEvent.ALT_GRAPH_MASK)) != 0) {
 641             res |= XToolkit.modeSwitchMask;
 642         }
 643         return res;
 644     }




 604         //reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc.
 605         for (int i = 0; i < XConstants.buttons.length; i ++){
 606             //modifier should be added if :
 607             // 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or
 608             // 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons.
 609             // ONLY one of these conditions should be TRUE to add that modifier.
 610             if (((state & XlibUtil.getButtonMask(i + 1)) != 0) != (button == XConstants.buttons[i])){
 611                 //exclude wheel buttons from adding their numbers as modifiers
 612                 if (!isWheelMouse || !isWheel(XConstants.buttons[i])) {
 613                     modifiers |= InputEvent.getMaskForButton(i+1);
 614                 }
 615             }
 616         }
 617         return modifiers;
 618     }
 619 
 620     static boolean isWheel(int button) {
 621         // 4 and 5 buttons are usually considered assigned to a first wheel
 622         return button == XConstants.buttons[3] || button == XConstants.buttons[4];
 623     }
 624     @SuppressWarnings("deprecation")
 625     static int getXModifiers(AWTKeyStroke stroke) {
 626         int mods = stroke.getModifiers();
 627         int res = 0;
 628         if ((mods & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) {
 629             res |= XConstants.ShiftMask;
 630         }
 631         if ((mods & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) {
 632             res |= XConstants.ControlMask;
 633         }
 634         if ((mods & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) {
 635             res |= XToolkit.altMask;
 636         }
 637         if ((mods & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) {
 638             res |= XToolkit.metaMask;
 639         }
 640         if ((mods & (InputEvent.ALT_GRAPH_DOWN_MASK | InputEvent.ALT_GRAPH_MASK)) != 0) {
 641             res |= XToolkit.modeSwitchMask;
 642         }
 643         return res;
 644     }


< prev index next >