summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorwnwen@chromium.org <wnwen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 09:57:00 +0000
committerwnwen@chromium.org <wnwen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 09:57:00 +0000
commit0222b1b486fef6f91245c1ba273d11aef75976cb (patch)
treecd5685bfeb61432e9bd0cd857a4a1b6c22bc7fdf /ui
parent0662c8ccf91675e8b00b953f57855938b5b49151 (diff)
downloadchromium_src-0222b1b486fef6f91245c1ba273d11aef75976cb.zip
chromium_src-0222b1b486fef6f91245c1ba273d11aef75976cb.tar.gz
chromium_src-0222b1b486fef6f91245c1ba273d11aef75976cb.tar.bz2
bezels: Ignore events from side bezels by default (new flag).
When the new EnableTouchSideBezels flag is not explicitly enabled, touch events from the side bezels (if any) will be ignored and the slots they previously occupied will be freed for other events. This potentially allows turning on the side bezels through firmware at a later time and have no impact on users unless they choose to enable the events to be propagated through the use of this new flag. If any noise issues from the side bezels are still prevalent, they will not affect users who have not explicitly turned on this flag. BUG=chromium:263382 TEST=When firmware is turned on but flag off or default, events starting on the bezel are ignored. Touch ids start at 0 even when fingers are on the bezel. Review URL: https://chromiumcodereview.appspot.com/19736005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/root_window_host_x11.cc30
-rw-r--r--ui/base/ui_base_switches.cc3
-rw-r--r--ui/base/ui_base_switches.h1
-rw-r--r--ui/base/x/events_x.cc2
4 files changed, 35 insertions, 1 deletions
diff --git a/ui/aura/root_window_host_x11.cc b/ui/aura/root_window_host_x11.cc
index 1a0fc5c..0d00318 100644
--- a/ui/aura/root_window_host_x11.cc
+++ b/ui/aura/root_window_host_x11.cc
@@ -81,6 +81,15 @@ const char* kAtomsToCache[] = {
return target;
}
+#if defined(USE_XI2_MT)
+bool IsSideBezelsEnabled() {
+ static bool side_bezels_enabled =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kTouchSideBezels) == "1";
+ return side_bezels_enabled;
+}
+#endif
+
void SelectEventsForRootWindow() {
Display* display = ui::GetXDisplay();
::Window root_window = ui::GetX11RootWindow();
@@ -203,6 +212,19 @@ class TouchEventCalibrate : public base::MessagePumpObserver {
base::MessageLoopForUI::current()->RemoveObserver(this);
}
+#if defined(USE_XI2_MT)
+ bool IsEventOnSideBezels(
+ const base::NativeEvent& xev,
+ const gfx::Rect& bounds) {
+ if (!left_ && !right_)
+ return false;
+
+ gfx::Point location = ui::EventLocationFromNative(xev);
+ int x = location.x();
+ return x < left_ || x > bounds.width() - right_;
+ }
+#endif // defined(USE_XI2_MT)
+
// Modify the location of the |event|,
// expanding it from |bounds| to (|bounds| + bezels).
// Required when touchscreen is bigger than screen (i.e. has bezels),
@@ -928,6 +950,14 @@ void RootWindowHostX11::DispatchXI2Event(const base::NativeEvent& event) {
case ui::ET_TOUCH_PRESSED:
case ui::ET_TOUCH_CANCELLED:
case ui::ET_TOUCH_RELEASED: {
+#if defined(USE_XI2_MT)
+ // Ignore events from the bezel when the side bezel flag is not explicitly
+ // enabled.
+ if (!IsSideBezelsEnabled() &&
+ touch_calibrate_->IsEventOnSideBezels(xev, bounds_)) {
+ break;
+ }
+#endif // defined(USE_XI2_MT)
ui::TouchEvent touchev(xev);
#if defined(OS_CHROMEOS)
if (base::chromeos::IsRunningOnChromeOS()) {
diff --git a/ui/base/ui_base_switches.cc b/ui/base/ui_base_switches.cc
index ed4ffd2..28c4f71 100644
--- a/ui/base/ui_base_switches.cc
+++ b/ui/base/ui_base_switches.cc
@@ -90,6 +90,9 @@ const char kTouchOptimizedUIEnabled[] = "enabled";
// disabled: never optimized for touch.
const char kTouchOptimizedUIDisabled[] = "disabled";
+// Enables touch events on the side bezels.
+const char kTouchSideBezels[] = "touch-side-bezels";
+
#if defined(USE_XI2_MT)
// The calibration factors given as "<left>,<right>,<top>,<bottom>".
const char kTouchCalibration[] = "touch-calibration";
diff --git a/ui/base/ui_base_switches.h b/ui/base/ui_base_switches.h
index 856d57f..0ef550f 100644
--- a/ui/base/ui_base_switches.h
+++ b/ui/base/ui_base_switches.h
@@ -37,6 +37,7 @@ UI_EXPORT extern const char kTouchOptimizedUI[];
UI_EXPORT extern const char kTouchOptimizedUIAuto[];
UI_EXPORT extern const char kTouchOptimizedUIDisabled[];
UI_EXPORT extern const char kTouchOptimizedUIEnabled[];
+UI_EXPORT extern const char kTouchSideBezels[];
#if defined(USE_XI2_MT)
UI_EXPORT extern const char kTouchCalibration[];
diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc
index cfed6ce..3fb5ab3 100644
--- a/ui/base/x/events_x.cc
+++ b/ui/base/x/events_x.cc
@@ -629,7 +629,7 @@ int GetTouchId(const base::NativeEvent& xev) {
double tracking_id;
if (!manager->GetEventData(
*xev, ui::DeviceDataManager::DT_TOUCH_TRACKING_ID, &tracking_id)) {
- LOG(ERROR) << "Could not get the slot ID for the event. Using 0.";
+ LOG(ERROR) << "Could not get the tracking ID for the event. Using 0.";
} else {
slot = factory->GetSlotForTrackingID(tracking_id);
ui::EventType type = ui::EventTypeFromNative(xev);