Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1601)

Unified Diff: chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc

Issue 2638903003: Updates touch calibration API and plumbs through the native touch calibration method (Closed)
Patch Set: Resolving comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc
diff --git a/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc b/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc
index 542cd271bf496cfca82c719ebe78c9e392bd2d79..57bbe91f5751ae5ecce2f234efb9e81cc4e4a8b3 100644
--- a/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc
+++ b/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc
@@ -7,6 +7,7 @@
#include "ash/shell.h"
#include "ash/touch/ash_touch_transform_controller.h"
#include "base/memory/ptr_util.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
@@ -32,6 +33,12 @@ void TouchCalibratorController::OnDisplayConfigurationChanged() {
StopCalibration();
}
+void TouchCalibratorController::AddCallback(
+ const TouchCalibratorController::TouchCalibrationCallback& callback) {
+ has_callback_ = true;
+ callback_ = callback;
+}
+
void TouchCalibratorController::StartCalibration(
const display::Display& target_display) {
is_calibrating_ = true;
@@ -64,6 +71,7 @@ void TouchCalibratorController::StopCalibration() {
if (!is_calibrating_)
return;
is_calibrating_ = false;
+
ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration(
@@ -83,8 +91,14 @@ void TouchCalibratorController::OnKeyEvent(ui::KeyEvent* key) {
if (!is_calibrating_)
return;
// Detect ESC key press.
- if (key->type() == ui::ET_KEY_PRESSED && key->key_code() == ui::VKEY_ESCAPE)
+ if (key->type() == ui::ET_KEY_PRESSED && key->key_code() == ui::VKEY_ESCAPE) {
+ if (has_callback_) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(callback_, false));
+ has_callback_ = false;
+ }
StopCalibration();
+ }
key->StopPropagation();
}
@@ -108,6 +122,11 @@ void TouchCalibratorController::OnTouchEvent(ui::TouchEvent* touch) {
ash::Shell::GetInstance()->display_manager()->SetTouchCalibrationData(
target_display_.id(), touch_point_quad_,
target_screen_calibration_view->size());
+ if (has_callback_) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(callback_, true));
+ has_callback_ = false;
+ }
return;
}

Powered by Google App Engine
This is Rietveld 408576698