summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorafakhry <afakhry@chromium.org>2015-11-18 17:50:06 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-19 01:50:49 +0000
commitb2794c1972bddd3fc1f3d4afcb079f8e4b504c49 (patch)
treee65f962b0bbf793b696fc359208d48430c4c2b48
parent4d39af826ffde2d6f1f83d7496f0ad8ec4e03e31 (diff)
downloadchromium_src-b2794c1972bddd3fc1f3d4afcb079f8e4b504c49.zip
chromium_src-b2794c1972bddd3fc1f3d4afcb079f8e4b504c49.tar.gz
chromium_src-b2794c1972bddd3fc1f3d4afcb079f8e4b504c49.tar.bz2
Fix a regression in checking the status of the touch events.
When the #touch-events flag is set to Automatic, we ought to check whether there's actually a touch device present. BUG=555390,555746,556390 Review URL: https://codereview.chromium.org/1453813003 Cr-Commit-Position: refs/heads/master@{#360472}
-rw-r--r--chrome/browser/chromeos/system/input_device_settings_impl_ozone.cc2
-rw-r--r--chrome/browser/chromeos/system/input_device_settings_impl_x11.cc2
-rw-r--r--content/browser/renderer_host/legacy_render_widget_host_win.cc2
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc2
-rw-r--r--ui/base/BUILD.gn4
-rw-r--r--ui/base/touch/touch_enabled.cc51
-rw-r--r--ui/base/touch/touch_enabled.h18
-rw-r--r--ui/base/ui_base.gyp2
-rw-r--r--ui/events/base_event_utils.cc37
-rw-r--r--ui/events/base_event_utils.h11
-rw-r--r--ui/events/devices/x11/touch_factory_x11.cc46
-rw-r--r--ui/events/devices/x11/touch_factory_x11.h3
-rw-r--r--ui/views/win/hwnd_message_handler.cc2
13 files changed, 133 insertions, 49 deletions
diff --git a/chrome/browser/chromeos/system/input_device_settings_impl_ozone.cc b/chrome/browser/chromeos/system/input_device_settings_impl_ozone.cc
index 3a3d98e..b32f5f0 100644
--- a/chrome/browser/chromeos/system/input_device_settings_impl_ozone.cc
+++ b/chrome/browser/chromeos/system/input_device_settings_impl_ozone.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "content/public/browser/browser_thread.h"
+#include "ui/events/base_event_utils.h"
#include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h"
@@ -136,6 +137,7 @@ void InputDeviceSettingsImplOzone::SetInternalTouchpadEnabled(bool enabled) {
void InputDeviceSettingsImplOzone::SetTouchscreensEnabled(bool enabled) {
input_controller_->SetTouchscreensEnabled(enabled);
+ ui::SetTouchEventsCrOsMasterSwitch(enabled);
}
} // namespace
diff --git a/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc b/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc
index 2167403..fb5393c 100644
--- a/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc
+++ b/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc
@@ -294,7 +294,7 @@ void InputDeviceSettingsImplX11::SetInternalTouchpadEnabled(bool enabled) {
}
void InputDeviceSettingsImplX11::SetTouchscreensEnabled(bool enabled) {
- ui::SetTouchEventsEnabled(enabled);
+ ui::SetTouchEventsCrOsMasterSwitch(enabled);
}
void InputDeviceSettingsImplX11::GenerateTouchpadArguments(
diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.cc b/content/browser/renderer_host/legacy_render_widget_host_win.cc
index 7f8abac..bd0101d 100644
--- a/content/browser/renderer_host/legacy_render_widget_host_win.cc
+++ b/content/browser/renderer_host/legacy_render_widget_host_win.cc
@@ -13,10 +13,10 @@
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/common/content_switches.h"
+#include "ui/base/touch/touch_enabled.h"
#include "ui/base/view_prop.h"
#include "ui/base/win/internal_constants.h"
#include "ui/base/win/window_event_target.h"
-#include "ui/events/base_event_utils.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/win/direct_manipulation.h"
#include "ui/gfx/win/dpi.h"
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index a3dcee9..29e5e68 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -79,8 +79,8 @@
#include "storage/browser/fileapi/isolated_context.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/touch/touch_device.h"
+#include "ui/base/touch/touch_enabled.h"
#include "ui/base/ui_base_switches.h"
-#include "ui/events/base_event_utils.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/native_theme/native_theme_switches.h"
diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn
index 2350505..61caad5 100644
--- a/ui/base/BUILD.gn
+++ b/ui/base/BUILD.gn
@@ -202,6 +202,8 @@ component("base") {
"touch/touch_device.h",
"touch/touch_editing_controller.cc",
"touch/touch_editing_controller.h",
+ "touch/touch_enabled.cc",
+ "touch/touch_enabled.h",
"ui_base_export.h",
"ui_base_exports.cc",
"ui_base_paths.cc",
@@ -735,8 +737,8 @@ test("ui_base_unittests") {
if (build_ime) {
sources += [
"ime/candidate_window_unittest.cc",
- "ime/composition_text_unittest.cc",
"ime/chromeos/character_composer_unittest.cc",
+ "ime/composition_text_unittest.cc",
"ime/input_method_base_unittest.cc",
"ime/input_method_chromeos_unittest.cc",
"ime/remote_input_method_win_unittest.cc",
diff --git a/ui/base/touch/touch_enabled.cc b/ui/base/touch/touch_enabled.cc
new file mode 100644
index 0000000..492588a
--- /dev/null
+++ b/ui/base/touch/touch_enabled.cc
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/touch/touch_enabled.h"
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "ui/base/touch/touch_device.h"
+#include "ui/base/ui_base_switches.h"
+#include "ui/events/base_event_utils.h"
+#include "ui/events/event_switches.h"
+
+namespace ui {
+
+namespace {
+
+bool ComputeTouchStatus() {
+ auto* command_line = base::CommandLine::ForCurrentProcess();
+ const std::string touch_enabled_switch =
+ command_line->HasSwitch(switches::kTouchEvents) ?
+ command_line->GetSwitchValueASCII(switches::kTouchEvents) :
+ switches::kTouchEventsAuto;
+
+ if (touch_enabled_switch.empty() ||
+ touch_enabled_switch == switches::kTouchEventsEnabled) {
+ return true;
+ }
+
+ if (touch_enabled_switch == switches::kTouchEventsAuto)
+ return IsTouchDevicePresent();
+
+ DLOG_IF(ERROR, touch_enabled_switch != switches::kTouchEventsDisabled) <<
+ "Invalid --touch-events option: " << touch_enabled_switch;
+ return false;
+}
+
+} // namespace
+
+bool AreTouchEventsEnabled() {
+ static bool touch_status = ComputeTouchStatus();
+
+#if defined(OS_CHROMEOS)
+ return touch_status && GetTouchEventsCrOsMasterSwitch();
+#else
+ return touch_status;
+#endif // !defined(OS_CHROMEOS)
+}
+
+} // namespace ui
+
diff --git a/ui/base/touch/touch_enabled.h b/ui/base/touch/touch_enabled.h
new file mode 100644
index 0000000..3d91c3a
--- /dev/null
+++ b/ui/base/touch/touch_enabled.h
@@ -0,0 +1,18 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_TOUCH_TOUCH_ENABLED_H_
+#define UI_BASE_TOUCH_TOUCH_ENABLED_H_
+
+#include "ui/base/ui_base_export.h"
+
+namespace ui {
+
+// Returns true if the touch-enabled flag is enabled, or if it is set to auto
+// and a touch device is present.
+UI_BASE_EXPORT bool AreTouchEventsEnabled();
+
+} // namespace ui
+
+#endif // UI_BASE_TOUCH_TOUCH_ENABLED_H_
diff --git a/ui/base/ui_base.gyp b/ui/base/ui_base.gyp
index d18c1f1e..565faed3 100644
--- a/ui/base/ui_base.gyp
+++ b/ui/base/ui_base.gyp
@@ -291,6 +291,8 @@
'touch/touch_device_win.cc',
'touch/touch_editing_controller.cc',
'touch/touch_editing_controller.h',
+ 'touch/touch_enabled.cc',
+ 'touch/touch_enabled.h',
'ui_base_export.h',
'ui_base_exports.cc',
'ui_base_paths.cc',
diff --git a/ui/events/base_event_utils.cc b/ui/events/base_event_utils.cc
index 622d2f2..846b6df 100644
--- a/ui/events/base_event_utils.cc
+++ b/ui/events/base_event_utils.cc
@@ -21,30 +21,6 @@ bool touch_events_enabled = true;
const int kSystemKeyModifierMask = EF_ALT_DOWN | EF_COMMAND_DOWN;
#else
const int kSystemKeyModifierMask = EF_ALT_DOWN;
-
-// Retrieves the status of the touch screen events from the command line on Non-
-// ChromeOS platforms.
-bool ComputeTouchStatus() {
- const base::CommandLine& command_line =
- *base::CommandLine::ForCurrentProcess();
- const std::string touch_enabled_switch =
- command_line.HasSwitch(switches::kTouchEvents) ?
- command_line.GetSwitchValueASCII(switches::kTouchEvents) :
- switches::kTouchEventsAuto;
-
- if (touch_enabled_switch.empty() ||
- touch_enabled_switch == switches::kTouchEventsEnabled ||
- touch_enabled_switch == switches::kTouchEventsAuto) {
- return true;
- }
-
- if (touch_enabled_switch == switches::kTouchEventsDisabled)
- return false;
-
- LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch;
- return false;
-}
-
#endif // defined(OS_CHROMEOS)
} // namespace
@@ -70,20 +46,15 @@ bool IsSystemKeyModifier(int flags) {
#if defined(OS_CHROMEOS)
-void SetTouchEventsEnabled(bool enabled) {
+void SetTouchEventsCrOsMasterSwitch(bool enabled) {
touch_events_enabled = enabled;
}
-#endif // defined(OS_CHROMEOS)
-
-bool AreTouchEventsEnabled() {
-#if defined(OS_CHROMEOS)
- return touch_events_enabled;
-#else
- static bool touch_events_enabled = ComputeTouchStatus();
+bool GetTouchEventsCrOsMasterSwitch() {
return touch_events_enabled;
-#endif // !defined(OS_CHROMEOS)
}
+#endif // defined(OS_CHROMEOS)
+
} // namespace ui
diff --git a/ui/events/base_event_utils.h b/ui/events/base_event_utils.h
index f659580..ef02739 100644
--- a/ui/events/base_event_utils.h
+++ b/ui/events/base_event_utils.h
@@ -18,15 +18,12 @@ EVENTS_BASE_EXPORT uint32 GetNextTouchEventId();
EVENTS_BASE_EXPORT bool IsSystemKeyModifier(int flags);
#if defined(OS_CHROMEOS)
-// Sets the status of touch events to |enabled| on ChromeOS only. Non-ChromeOS
-// platforms depend on the state of the |kTouchEvents| flags.
-EVENTS_BASE_EXPORT void SetTouchEventsEnabled(bool enabled);
+// On ChromeOS, touch events can be turned off completely using a debug
+// accelerator using the following functions.
+EVENTS_BASE_EXPORT void SetTouchEventsCrOsMasterSwitch(bool enabled);
+EVENTS_BASE_EXPORT bool GetTouchEventsCrOsMasterSwitch();
#endif // defined(OS_CHROMEOS)
-// Returns true if the touch events are enabled. On non-ChromeOS platforms, this
-// depends on the state of the |kTouchEvents| flags.
-EVENTS_BASE_EXPORT bool AreTouchEventsEnabled();
-
} // namespace ui
#endif // UI_EVENTS_BASE_EVENT_UTILS_H_
diff --git a/ui/events/devices/x11/touch_factory_x11.cc b/ui/events/devices/x11/touch_factory_x11.cc
index d0cc991..6718550 100644
--- a/ui/events/devices/x11/touch_factory_x11.cc
+++ b/ui/events/devices/x11/touch_factory_x11.cc
@@ -27,11 +27,25 @@
namespace ui {
+namespace {
+
+bool IsTouchEventsFlagDisabled() {
+ auto* command_line = base::CommandLine::ForCurrentProcess();
+ bool touch_flag_status = command_line->HasSwitch(switches::kTouchEvents) &&
+ command_line->GetSwitchValueASCII(switches::kTouchEvents) ==
+ switches::kTouchEventsDisabled;
+ return touch_flag_status;
+}
+
+} // namespace
+
+
TouchFactory::TouchFactory()
: pointer_device_lookup_(),
touch_device_list_(),
virtual_core_keyboard_device_(-1),
- id_generator_(0) {
+ id_generator_(0),
+ touch_events_disabled_(IsTouchEventsFlagDisabled()) {
if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available())
return;
@@ -143,6 +157,13 @@ bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data);
XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event);
+#if defined(OS_CHROMEOS)
+ const bool is_touch_disabled = touch_events_disabled_ &&
+ !GetTouchEventsCrOsMasterSwitch();
+#else
+ const bool is_touch_disabled = touch_events_disabled_;
+#endif // defined(OS_CHROMEOS)
+
if (event->evtype == XI_TouchBegin ||
event->evtype == XI_TouchUpdate ||
event->evtype == XI_TouchEnd) {
@@ -159,7 +180,7 @@ bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
bool is_from_master_or_float = touch_device_list_[xiev->deviceid];
bool is_from_slave_device = !is_from_master_or_float
&& xiev->sourceid == xiev->deviceid;
- return ui::AreTouchEventsEnabled() &&
+ return !is_touch_disabled &&
IsTouchDevice(xiev->deviceid) &&
!is_from_slave_device;
}
@@ -179,7 +200,7 @@ bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
if (!pointer_device_lookup_[xiev->deviceid])
return false;
- return IsTouchDevice(xiev->deviceid) ? ui::AreTouchEventsEnabled() : true;
+ return IsTouchDevice(xiev->deviceid) ? !is_touch_disabled : true;
}
void TouchFactory::SetupXI2ForXWindow(Window window) {
@@ -266,7 +287,14 @@ void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) {
}
bool TouchFactory::IsTouchDevicePresent() {
- return ui::AreTouchEventsEnabled() && touch_device_lookup_.any();
+#if defined(OS_CHROMEOS)
+ const bool is_touch_disabled = touch_events_disabled_ &&
+ !GetTouchEventsCrOsMasterSwitch();
+#else
+ const bool is_touch_disabled = touch_events_disabled_;
+#endif // defined(OS_CHROMEOS)
+
+ return !is_touch_disabled && touch_device_lookup_.any();
}
void TouchFactory::ResetForTest() {
@@ -275,6 +303,11 @@ void TouchFactory::ResetForTest() {
touch_device_list_.clear();
touchscreen_ids_.clear();
id_generator_.ResetForTest();
+ touch_events_disabled_ = false;
+
+#if defined(OS_CHROMEOS)
+ SetTouchEventsCrOsMasterSwitch(true);
+#endif // defined(OS_CHROMEOS)
}
void TouchFactory::SetTouchDeviceForTest(
@@ -287,6 +320,11 @@ void TouchFactory::SetTouchDeviceForTest(
touch_device_lookup_[*iter] = true;
touch_device_list_[*iter] = true;
}
+ touch_events_disabled_ = false;
+
+#if defined(OS_CHROMEOS)
+ SetTouchEventsCrOsMasterSwitch(true);
+#endif // defined(OS_CHROMEOS)
}
void TouchFactory::SetPointerDeviceForTest(
diff --git a/ui/events/devices/x11/touch_factory_x11.h b/ui/events/devices/x11/touch_factory_x11.h
index eb2620b..1f113ea 100644
--- a/ui/events/devices/x11/touch_factory_x11.h
+++ b/ui/events/devices/x11/touch_factory_x11.h
@@ -137,6 +137,9 @@ class EVENTS_DEVICES_EXPORT TouchFactory {
// Associate each device ID with its master device ID.
std::map<int, int> device_master_id_list_;
+ // Indicates whether touch events are explicitly disabled.
+ bool touch_events_disabled_;
+
DISALLOW_COPY_AND_ASSIGN(TouchFactory);
};
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index 67b939c..035df76 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -14,13 +14,13 @@
#include "base/trace_event/trace_event.h"
#include "base/win/scoped_gdi_object.h"
#include "base/win/windows_version.h"
+#include "ui/base/touch/touch_enabled.h"
#include "ui/base/view_prop.h"
#include "ui/base/win/internal_constants.h"
#include "ui/base/win/lock_state.h"
#include "ui/base/win/mouse_wheel_util.h"
#include "ui/base/win/shell.h"
#include "ui/base/win/touch_input.h"
-#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_code_conversion_win.h"