summaryrefslogtreecommitdiffstats
path: root/ui/base/touch
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-20 20:53:58 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-20 20:53:58 +0000
commit8a6aaa7c2cf610f4b050b7558156598291120043 (patch)
tree7e59aad073072fb0277089e2bf7f9dd6e26bb2e8 /ui/base/touch
parent8f49214de9a79ed39c043579c7aca3ab515d6d9d (diff)
downloadchromium_src-8a6aaa7c2cf610f4b050b7558156598291120043.zip
chromium_src-8a6aaa7c2cf610f4b050b7558156598291120043.tar.gz
chromium_src-8a6aaa7c2cf610f4b050b7558156598291120043.tar.bz2
chromeos: Put touch-event support behind a flag (--enable-touch-events) until it's more baked.
BUG=122884 TEST=none Review URL: https://chromiumcodereview.appspot.com/10165008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133273 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/touch')
-rw-r--r--ui/base/touch/touch_factory.cc16
-rw-r--r--ui/base/touch/touch_factory.h6
2 files changed, 19 insertions, 3 deletions
diff --git a/ui/base/touch/touch_factory.cc b/ui/base/touch/touch_factory.cc
index ea2731f..ef7b710 100644
--- a/ui/base/touch/touch_factory.cc
+++ b/ui/base/touch/touch_factory.cc
@@ -10,9 +10,11 @@
#include <X11/extensions/XIproto.h>
#include "base/basictypes.h"
+#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "ui/base/ui_base_switches.h"
#include "ui/base/x/x11_util.h"
namespace {
@@ -84,6 +86,7 @@ TouchFactory* TouchFactory::GetInstance() {
TouchFactory::TouchFactory()
: is_cursor_visible_(true),
+ touch_events_allowed_(false),
cursor_timer_(),
pointer_device_lookup_(),
touch_device_available_(false),
@@ -122,6 +125,12 @@ TouchFactory::TouchFactory()
evmask.mask_len = sizeof(mask);
evmask.mask = mask;
XISelectEvents(display, ui::GetX11RootWindow(), &evmask, 1);
+
+ CommandLine* cmdline = CommandLine::ForCurrentProcess();
+ if (cmdline->HasSwitch(switches::kTouchOptimizedUI) ||
+ cmdline->HasSwitch(switches::kEnableTouchEvents)) {
+ touch_events_allowed_ = true;
+ }
}
TouchFactory::~TouchFactory() {
@@ -215,7 +224,7 @@ bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
if (event->evtype == XI_TouchBegin ||
event->evtype == XI_TouchUpdate ||
event->evtype == XI_TouchEnd) {
- return touch_device_lookup_[xiev->sourceid];
+ return touch_events_allowed_ && IsTouchDevice(xiev->deviceid);
}
#endif
if (event->evtype != XI_ButtonPress &&
@@ -223,7 +232,10 @@ bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
event->evtype != XI_Motion)
return true;
- return pointer_device_lookup_[xiev->deviceid];
+ if (!pointer_device_lookup_[xiev->deviceid])
+ return false;
+
+ return IsTouchDevice(xiev->deviceid) ? touch_events_allowed_ : true;
}
void TouchFactory::SetupXI2ForXWindow(Window window) {
diff --git a/ui/base/touch/touch_factory.h b/ui/base/touch/touch_factory.h
index cfd4747..cb05460 100644
--- a/ui/base/touch/touch_factory.h
+++ b/ui/base/touch/touch_factory.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -155,6 +155,10 @@ class UI_EXPORT TouchFactory {
// is immediately displayed.
bool is_cursor_visible_;
+ // Touch events are currently disabled by default. It can be turned on using
+ // |kEnableTouchEvents| switch.
+ bool touch_events_allowed_;
+
// The cursor is hidden if it is idle for a certain amount time. This timer
// is used to keep track of the idleness.
base::OneShotTimer<TouchFactory> cursor_timer_;