changeset 2918:b0d1ef182650

6829267: Regression test java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java fails in RHEL5 Reviewed-by: art, anthony
author dav
date Fri, 01 Oct 2010 15:10:32 +0400
parents 8afd49c55619
children 70a73fc061d9
files src/solaris/classes/sun/awt/X11/XToolkit.java src/windows/native/sun/windows/awt_DesktopProperties.cpp src/windows/native/sun/windows/awt_Toolkit.cpp src/windows/native/sun/windows/awt_Toolkit.h test/java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java
diffstat 5 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/awt/X11/XToolkit.java	Thu Sep 30 21:06:53 2010 +0400
+++ b/src/solaris/classes/sun/awt/X11/XToolkit.java	Fri Oct 01 15:10:32 2010 +0400
@@ -1482,8 +1482,19 @@
         try {
             if (numberOfButtons == 0) {
                 numberOfButtons = getNumberOfButtonsImpl();
+                numberOfButtons = (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
+                //4th and 5th buttons are for wheel and shouldn't be reported as buttons.
+                //If we have more than 3 physical buttons and a wheel, we report N-2 buttons.
+                //If we have 3 physical buttons and a wheel, we report 3 buttons.
+                //If we have 1,2,3 physical buttons, we report it as is i.e. 1,2 or 3 respectively.
+                if (numberOfButtons >=5) {
+                    numberOfButtons -= 2;
+                } else if (numberOfButtons == 4 || numberOfButtons ==5){
+                    numberOfButtons = 3;
+                }
             }
-            return (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
+            //Assume don't have to re-query the number again and again.
+            return numberOfButtons;
         } finally {
             awtUnlock();
         }
--- a/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Thu Sep 30 21:06:53 2010 +0400
+++ b/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Fri Oct 01 15:10:32 2010 +0400
@@ -505,7 +505,8 @@
     SetIntegerProperty(TEXT("win.drag.width"), cxdrag);
     SetIntegerProperty(TEXT("win.drag.height"), cydrag);
     SetIntegerProperty(TEXT("DnD.gestureMotionThreshold"), max(cxdrag, cydrag)/2);
-    SetIntegerProperty(TEXT("awt.mouse.numButtons"), GetSystemMetrics(SM_CMOUSEBUTTONS));
+    SetIntegerProperty(TEXT("awt.mouse.numButtons"), AwtToolkit::GetNumberOfButtons());
+
     SetIntegerProperty(TEXT("awt.multiClickInterval"), GetDoubleClickTime());
 
     // BEGIN cross-platform properties
--- a/src/windows/native/sun/windows/awt_Toolkit.cpp	Thu Sep 30 21:06:53 2010 +0400
+++ b/src/windows/native/sun/windows/awt_Toolkit.cpp	Fri Oct 01 15:10:32 2010 +0400
@@ -133,6 +133,8 @@
 
 static LPCTSTR szAwtToolkitClassName = TEXT("SunAwtToolkit");
 
+static const int MOUSE_BUTTONS_WINDOWS_SUPPORTED = 5; //three standard buttons + XBUTTON1 + XBUTTON2.
+
 UINT AwtToolkit::GetMouseKeyState()
 {
     static BOOL mbSwapped = ::GetSystemMetrics(SM_SWAPBUTTON);
@@ -2310,5 +2312,9 @@
 
 JNIEXPORT jint JNICALL Java_sun_awt_windows_WToolkit_getNumberOfButtonsImpl
 (JNIEnv *, jobject self) {
-    return GetSystemMetrics(SM_CMOUSEBUTTONS);
+    return AwtToolkit::GetNumberOfButtons();
 }
+
+UINT AwtToolkit::GetNumberOfButtons() {
+    return MOUSE_BUTTONS_WINDOWS_SUPPORTED;
+}
--- a/src/windows/native/sun/windows/awt_Toolkit.h	Thu Sep 30 21:06:53 2010 +0400
+++ b/src/windows/native/sun/windows/awt_Toolkit.h	Fri Oct 01 15:10:32 2010 +0400
@@ -185,6 +185,7 @@
     BOOL IsDynamicLayoutActive();
     BOOL areExtraMouseButtonsEnabled();
     void setExtraMouseButtonsEnabled(BOOL enable);
+    static UINT GetNumberOfButtons();
 
     INLINE BOOL localPump() { return m_localPump; }
     INLINE BOOL VerifyComponents() { return FALSE; } // TODO: Use new DebugHelper class to set this flag
--- a/test/java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java	Thu Sep 30 21:06:53 2010 +0400
+++ b/test/java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java	Fri Oct 01 15:10:32 2010 +0400
@@ -90,7 +90,7 @@
         int [] buttonMasks = new int[MouseInfo.getNumberOfButtons()]; // = InputEvent.getButtonDownMasks();
         for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
             buttonMasks[i] = InputEvent.getMaskForButton(i+1);
-            System.out.println("TEST: "+buttonMasks[i]);
+            System.out.println("TEST: buttonMasks["+ i +"] = " + buttonMasks[i]);
         }
 
         for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){