Bug 538189 - Tweak conditions for enabling the Synaptics hack r=jmathies a=asa
authorCameron McCormack <cam@mcc.id.au>
Tue, 30 Aug 2011 09:49:46 +1200
changeset 73072 1d02edaa92bc16976949d5109cd5b2dd517ac971
parent 73071 4d360d0794dc54791a550752a5751b0d23f66c5a
child 73073 e8c0eb11e0c1c5b85f6859ef87ac73bd58682420
push id184
push usercmccormack@mozilla.com
push dateMon, 29 Aug 2011 21:51:05 +0000
treeherdermozilla-beta@1d02edaa92bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies, asa
bugs538189
milestone7.0
Bug 538189 - Tweak conditions for enabling the Synaptics hack r=jmathies a=asa
widget/src/windows/nsWindow.cpp
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -8825,19 +8825,22 @@ PRBool nsWindow::UseTrackPointHack()
   return GetInputWorkaroundPref("ui.trackpoint_hack.enabled",
                                 sDefaultTrackPointHack);
 }
 
 static PRBool
 HasRegistryKey(HKEY aRoot, PRUnichar* aName)
 {
   HKEY key;
-  LONG result = ::RegOpenKeyExW(aRoot, aName, 0, KEY_READ, &key);
-  if (result != ERROR_SUCCESS)
-    return PR_FALSE;
+  LONG result = ::RegOpenKeyExW(aRoot, aName, 0, KEY_READ | KEY_WOW64_32KEY, &key);
+  if (result != ERROR_SUCCESS) {
+    result = ::RegOpenKeyExW(aRoot, aName, 0, KEY_READ | KEY_WOW64_64KEY, &key);
+    if (result != ERROR_SUCCESS)
+      return PR_FALSE;
+  }
   ::RegCloseKey(key);
   return PR_TRUE;
 }
 
 /**
  * Gets the value of a string-typed registry value.
  *
  * @param aRoot The registry root to search in.
@@ -8853,19 +8856,22 @@ HasRegistryKey(HKEY aRoot, PRUnichar* aN
 static PRBool
 GetRegistryKey(HKEY aRoot, PRUnichar* aKeyName, PRUnichar* aValueName, PRUnichar* aBuffer, DWORD aBufferLength)
 {
   if (!aKeyName) {
     return PR_FALSE;
   }
 
   HKEY key;
-  LONG result = ::RegOpenKeyExW(aRoot, aKeyName, NULL, KEY_READ, &key);
-  if (result != ERROR_SUCCESS)
-    return PR_FALSE;
+  LONG result = ::RegOpenKeyExW(aRoot, aKeyName, NULL, KEY_READ | KEY_WOW64_32KEY, &key);
+  if (result != ERROR_SUCCESS) {
+    result = ::RegOpenKeyExW(aRoot, aKeyName, NULL, KEY_READ | KEY_WOW64_64KEY, &key);
+    if (result != ERROR_SUCCESS)
+      return PR_FALSE;
+  }
   DWORD type;
   result = ::RegQueryValueExW(key, aValueName, NULL, &type, (BYTE*) aBuffer, &aBufferLength);
   ::RegCloseKey(key);
   if (result != ERROR_SUCCESS || type != REG_SZ)
     return PR_FALSE;
   if (aBuffer)
     aBuffer[aBufferLength / sizeof(*aBuffer) - 1] = 0;
   return PR_TRUE;
@@ -8879,17 +8885,22 @@ IsObsoleteSynapticsDriver()
                                    L"Software\\Synaptics\\SynTP\\Install",
                                    L"DriverVersion",
                                    buf,
                                    sizeof buf);
   if (!foundKey)
     return PR_FALSE;
 
   int majorVersion = wcstol(buf, NULL, 10);
-  return majorVersion < 15;
+  int minorVersion = 0;
+  PRUnichar* p = wcschr(buf, L'.');
+  if (p) {
+    minorVersion = wcstol(p + 1, NULL, 10);
+  }
+  return majorVersion < 15 || majorVersion == 15 && minorVersion == 0;
 }
 
 static PRInt32
 GetElantechDriverMajorVersion()
 {
   PRUnichar buf[40];
   // The driver version is found in one of these two registry keys.
   PRBool foundKey = GetRegistryKey(HKEY_CURRENT_USER,