diff options
author | rbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 22:13:51 +0000 |
---|---|---|
committer | rbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 22:13:51 +0000 |
commit | ced8e8d8ccea289ce8dde43aa04617f417f63596 (patch) | |
tree | 8646bb2169b95da8d132cd9e64756aa46674582d /ui/base | |
parent | 38cd8f7f1bb2da1af74f27740caa6449ea09eb1f (diff) | |
download | chromium_src-ced8e8d8ccea289ce8dde43aa04617f417f63596.zip chromium_src-ced8e8d8ccea289ce8dde43aa04617f417f63596.tar.gz chromium_src-ced8e8d8ccea289ce8dde43aa04617f417f63596.tar.bz2 |
Don't allow "touch optimized ui" mode to change after chrome startup.
Since we don't yet properly support dynamic changing of touch optimized UI mode (see crbug.com/124399), we need to ensure the UI sees a consistent value for the life of the process to avoid painting issues like those in issue 131606.
Also output a log message if we see touch device status change after startup in order to help understand issues with some devices being slow to initialize.
Adds a temporary hack to force touch-optimized-ui mode on when command line arguments suggest we're expecting a touch screen.
BUG=131606
TEST=
Review URL: https://chromiumcodereview.appspot.com/10532161
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142493 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/layout.cc | 22 | ||||
-rw-r--r-- | ui/base/touch/touch_factory.cc | 13 | ||||
-rw-r--r-- | ui/base/touch/touch_factory.h | 3 |
3 files changed, 33 insertions, 5 deletions
diff --git a/ui/base/layout.cc b/ui/base/layout.cc index 36614fa..368a395 100644 --- a/ui/base/layout.cc +++ b/ui/base/layout.cc @@ -25,8 +25,9 @@ namespace { bool UseTouchOptimizedUI() { // If --touch-optimized-ui is specified and not set to "auto", then override // the hardware-determined setting (eg. for testing purposes). - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kTouchOptimizedUI)) { + static bool has_touch_optimized_ui = CommandLine::ForCurrentProcess()-> + HasSwitch(switches::kTouchOptimizedUI); + if (has_touch_optimized_ui) { const std::string switch_value = CommandLine::ForCurrentProcess()-> GetSwitchValueASCII(switches::kTouchOptimizedUI); @@ -47,9 +48,20 @@ bool UseTouchOptimizedUI() { return base::win::GetMetroModule() != NULL; #elif defined(USE_AURA) && defined(USE_X11) // Determine whether touch-screen hardware is currently available. - // For now we assume this won't change over the life of the process, but - // we'll probably want to support that. crbug.com/124399 - return ui::TouchFactory::GetInstance()->IsTouchDevicePresent(); + // For now we must ensure this won't change over the life of the process, + // since we don't yet support updating the UI. crbug.com/124399 + static bool has_touch_device = + ui::TouchFactory::GetInstance()->IsTouchDevicePresent(); + + // Work-around for late device detection in some cases. If we've asked for + // touch calibration then we're certainly expecting a touch screen, it must + // just not be ready yet. Force-enable touch-ui mode in this case. + static bool enable_touch_calibration = CommandLine::ForCurrentProcess()-> + HasSwitch(switches::kEnableTouchCalibration); + if (!has_touch_device && enable_touch_calibration) + has_touch_device = true; + + return has_touch_device; #else return false; #endif diff --git a/ui/base/touch/touch_factory.cc b/ui/base/touch/touch_factory.cc index a274b2d..c66bb58 100644 --- a/ui/base/touch/touch_factory.cc +++ b/ui/base/touch/touch_factory.cc @@ -34,6 +34,7 @@ TouchFactory::TouchFactory() cursor_timer_(), pointer_device_lookup_(), touch_device_available_(false), + touch_present_called_(false), touch_device_list_(), #if defined(USE_XI2_MT) min_available_slot_(0), @@ -132,6 +133,7 @@ void TouchFactory::UpdateDeviceList(Display* display) { // If XInput2 is not supported, this will return null (with count of -1) so // we assume there cannot be any touch devices. int count = 0; + bool last_touch_device_available = touch_device_available_; touch_device_available_ = false; touch_device_lookup_.reset(); touch_device_list_.clear(); @@ -187,6 +189,16 @@ void TouchFactory::UpdateDeviceList(Display* display) { } if (devices) XIFreeDeviceInfo(devices); + + if ((last_touch_device_available != touch_device_available_) && + touch_events_allowed_ && touch_present_called_) { + // Touch_device_available_ has changed after it's been queried. + // TODO(rbyers): Should dispatch an event to indicate that the availability + // of touch devices has changed. crbug.com/124399. + LOG(WARNING) << "Touch screen " + << (touch_device_available_ ? "added" : "removed") + << " after startup, which is not yet fully supported."; + } } bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { @@ -400,6 +412,7 @@ void TouchFactory::SetCursorVisible(bool show, bool start_timer) { } bool TouchFactory::IsTouchDevicePresent() { + touch_present_called_ = true; return (touch_device_available_ && touch_events_allowed_); } diff --git a/ui/base/touch/touch_factory.h b/ui/base/touch/touch_factory.h index e2c8750..b12538e 100644 --- a/ui/base/touch/touch_factory.h +++ b/ui/base/touch/touch_factory.h @@ -139,6 +139,9 @@ class UI_EXPORT TouchFactory { // Indicates whether a touch device is currently available or not. bool touch_device_available_; + // Whether IsTouchDevicePresent() has been called yet. + bool touch_present_called_; + // The list of touch devices. For testing/debugging purposes, a single-pointer // device (mouse or touch screen without sufficient X/driver support for MT) // can sometimes be treated as a touch device. The key in the map represents |