jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java
changeset 1962 6c293d33645b
parent 439 3488710b02f8
child 2471 71401ceec494
equal deleted inserted replaced
1961:436a5a828d9f 1962:6c293d33645b
   977      * Activate automatic grab on first ButtonPress,
   977      * Activate automatic grab on first ButtonPress,
   978      * deactivate on full mouse release
   978      * deactivate on full mouse release
   979      */
   979      */
   980     public void handleButtonPressRelease(XEvent xev) {
   980     public void handleButtonPressRelease(XEvent xev) {
   981         XButtonEvent xbe = xev.get_xbutton();
   981         XButtonEvent xbe = xev.get_xbutton();
   982         final int buttonState = xbe.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask
   982         int buttonState = 0;
   983             | XConstants.Button3Mask | XConstants.Button4Mask | XConstants.Button5Mask);
   983         for (int i = 0; i<XToolkit.getNumMouseButtons(); i++){
       
   984             // A bug in WM implementation: extra buttons doesn't have state!=0 as they should on Release message.
       
   985             if ((i != 4) && (i != 5)){
       
   986                 buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]);
       
   987             }
       
   988         }
   984         switch (xev.get_type()) {
   989         switch (xev.get_type()) {
   985         case XConstants.ButtonPress:
   990         case XConstants.ButtonPress:
   986             if (buttonState == 0) {
   991             if (buttonState == 0) {
   987                 XAwtState.setAutoGrabWindow(this);
   992                 XAwtState.setAutoGrabWindow(this);
   988             }
   993             }
  1009     }
  1014     }
  1010     /**
  1015     /**
  1011      * Checks ButtonRelease released all Mouse buttons
  1016      * Checks ButtonRelease released all Mouse buttons
  1012      */
  1017      */
  1013     static boolean isFullRelease(int buttonState, int button) {
  1018     static boolean isFullRelease(int buttonState, int button) {
  1014         switch (button) {
  1019         if (button < 0 || button > XToolkit.getNumMouseButtons()) {
  1015         case XConstants.Button1:
  1020             return buttonState == 0;
  1016             return buttonState == XConstants.Button1Mask;
  1021         } else {
  1017         case XConstants.Button2:
  1022             return buttonState == XConstants.buttonsMask[button - 1];
  1018             return buttonState == XConstants.Button2Mask;
  1023         }
  1019         case XConstants.Button3:
       
  1020             return buttonState == XConstants.Button3Mask;
       
  1021         case XConstants.Button4:
       
  1022             return buttonState == XConstants.Button4Mask;
       
  1023         case XConstants.Button5:
       
  1024             return buttonState == XConstants.Button5Mask;
       
  1025         }
       
  1026         return buttonState == 0;
       
  1027     }
  1024     }
  1028 
  1025 
  1029     static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) {
  1026     static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) {
  1030         switch (ev.get_type()) {
  1027         switch (ev.get_type()) {
  1031           case XConstants.ButtonPress:
  1028           case XConstants.ButtonPress: