diff options
-rw-r--r-- | chrome/app/generated_resources.grd | 6 | ||||
-rw-r--r-- | chrome/browser/about_flags.cc | 9 | ||||
-rw-r--r-- | ui/aura/root_window_host_x11.cc | 30 | ||||
-rw-r--r-- | ui/base/ui_base_switches.cc | 3 | ||||
-rw-r--r-- | ui/base/ui_base_switches.h | 1 | ||||
-rw-r--r-- | ui/base/x/events_x.cc | 2 |
6 files changed, 50 insertions, 1 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 9d070cc..73e5946 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6654,6 +6654,12 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAGS_ENABLE_TCP_FAST_OPEN_DESCRIPTION" desc="Description of the flag that enables TCP Fast Open."> Enable the option to send extra authentication information in the initial SYN packet for a previously connected client, allowing faster data send start. </message> + <message name="IDS_FLAGS_ENABLE_TOUCH_SIDE_BEZELS_NAME" desc="Name of the flag that enables touch events on the side bezels."> + Enable touch events on the side bezels. + </message> + <message name="IDS_FLAGS_ENABLE_TOUCH_SIDE_BEZELS_DESCRIPTION" desc="Description of the flag to enable touch events on the side bezels."> + Touch events from the side bezels are processed rather than thrown away. + </message> <message name="IDS_FLAGS_ENABLE_TOUCH_DRAG_DROP_NAME" desc="Name of the flag that enables touch initiated drag drop."> Enable touch initiated drag and drop </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 9e5a15e..a26b939 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1335,6 +1335,15 @@ const Experiment kExperiments[] = { switches::kScrollEndEffect, "0") }, { + "enable-touch-side-bezels", + IDS_FLAGS_ENABLE_TOUCH_SIDE_BEZELS_NAME, + IDS_FLAGS_ENABLE_TOUCH_SIDE_BEZELS_DESCRIPTION, + kOsCrOS, + ENABLE_DISABLE_VALUE_TYPE_AND_VALUE( + switches::kTouchSideBezels, "1", + switches::kTouchSideBezels, "0") + }, + { "enable-touch-drag-drop", IDS_FLAGS_ENABLE_TOUCH_DRAG_DROP_NAME, IDS_FLAGS_ENABLE_TOUCH_DRAG_DROP_DESCRIPTION, 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); |