Bug 1345355 - Don't register a window as touch-enabled if there's no touch device supported. r?jimm
MozReview-Commit-ID: IycX3e0I5TQ
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -51,16 +51,17 @@ user_pref("security.warn_viewing_mixed",
user_pref("app.update.enabled", false);
user_pref("app.update.staging.enabled", false);
user_pref("app.update.url.android", "");
// Make sure GMPInstallManager won't hit the network.
user_pref("media.gmp-manager.url.override", "http://%(server)s/dummy-gmp-manager.xml");
user_pref("media.gmp-manager.updateEnabled", false);
user_pref("dom.w3c_touch_events.enabled", 1);
user_pref("layout.accessiblecaret.enabled_on_touch", false);
+user_pref("test.force_register_touch_windows", true);
user_pref("dom.webcomponents.enabled", true);
user_pref("dom.webcomponents.customelements.enabled", true);
user_pref("dom.htmlimports.enabled", true);
// Existing tests assume there is no font size inflation.
user_pref("font.size.inflation.emPerLine", 0);
user_pref("font.size.inflation.minTwips", 0);
// Disable the caret blinking so we get stable snapshot
user_pref("ui.caretBlinkTime", -1);
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -1699,16 +1699,25 @@ void nsWindow::SetThemeRegion()
/**************************************************************
*
* SECTION: Touch and APZ-related functions
*
**************************************************************/
void nsWindow::RegisterTouchWindow() {
+ if (!WinUtils::IsTouchDeviceSupportPresent() &&
+ !Preferences::GetBool("test.force_register_touch_windows", false)) {
+ // If we don't have any touch support on the device, don't
+ // register any touch windows because it'll consume WM_GESTURE
+ // events from other devices.
+ // For testing purposes we have a pref to override this behaviour
+ // and force the registration of touch windows.
+ return;
+ }
mTouchWindow = true;
mGesture.RegisterTouchWindow(mWnd);
::EnumChildWindows(mWnd, nsWindow::RegisterTouchForDescendants, 0);
}
BOOL CALLBACK nsWindow::RegisterTouchForDescendants(HWND aWnd, LPARAM aMsg) {
nsWindow* win = WinUtils::GetNSWindowPtr(aWnd);
if (win)