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

Unified Diff: ui/display/chromeos/touchscreen_delegate_impl.cc

Issue 336863002: Moving input device hotplug event processing outside of ui/display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove TouchscreenDelegate references from display_unittests Created 6 years, 3 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: ui/display/chromeos/touchscreen_delegate_impl.cc
diff --git a/ui/display/chromeos/touchscreen_delegate_impl.cc b/ui/display/chromeos/touchscreen_delegate_impl.cc
deleted file mode 100644
index 4114756c6f73c2ad29ec726b1e41f9762a43ccf7..0000000000000000000000000000000000000000
--- a/ui/display/chromeos/touchscreen_delegate_impl.cc
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2014 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.
-
-#include "ui/display/chromeos/touchscreen_delegate_impl.h"
-
-#include <cmath>
-#include <set>
-
-#include "ui/display/types/chromeos/display_mode.h"
-#include "ui/display/types/chromeos/display_snapshot.h"
-#include "ui/events/device_data_manager.h"
-
-namespace ui {
-
-TouchscreenDelegateImpl::TouchscreenDelegateImpl() {
-}
-
-TouchscreenDelegateImpl::~TouchscreenDelegateImpl() {}
-
-void TouchscreenDelegateImpl::AssociateTouchscreens(
- std::vector<DisplayConfigurator::DisplayState>* displays) {
- std::set<int> no_match_touchscreen;
- const std::vector<TouchscreenDevice>& devices =
- DeviceDataManager::GetInstance()->touchscreen_devices();
-
- int internal_touchscreen = -1;
- for (size_t i = 0; i < devices.size(); ++i) {
- if (devices[i].is_internal) {
- internal_touchscreen = i;
- break;
- }
- }
-
- DisplayConfigurator::DisplayState* internal_state = NULL;
- for (size_t i = 0; i < displays->size(); ++i) {
- DisplayConfigurator::DisplayState* state = &(*displays)[i];
- if (state->display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL &&
- state->display->native_mode() &&
- state->touch_device_id == 0) {
- internal_state = state;
- break;
- }
- }
-
- if (internal_state && internal_touchscreen >= 0) {
- internal_state->touch_device_id = devices[internal_touchscreen].id;
- VLOG(2) << "Found internal touchscreen for internal display "
- << internal_state->display->display_id() << " touch_device_id "
- << internal_state->touch_device_id << " size "
- << devices[internal_touchscreen].size.ToString();
- }
-
- for (size_t i = 0; i < devices.size(); ++i) {
- if (internal_state &&
- internal_state->touch_device_id == devices[i].id)
- continue;
- bool found_mapping = false;
- for (size_t j = 0; j < displays->size(); ++j) {
- DisplayConfigurator::DisplayState* state = &(*displays)[j];
- const DisplayMode* mode = state->display->native_mode();
- if (state->touch_device_id != 0 || !mode)
- continue;
-
- // Allow 1 pixel difference between screen and touchscreen
- // resolutions. Because in some cases for monitor resolution
- // 1024x768 touchscreen's resolution would be 1024x768, but for
- // some 1023x767. It really depends on touchscreen's firmware
- // configuration.
- if (std::abs(mode->size().width() - devices[i].size.width()) <= 1 &&
- std::abs(mode->size().height() - devices[i].size.height()) <= 1) {
- state->touch_device_id = devices[i].id;
-
- VLOG(2) << "Found touchscreen for display "
- << state->display->display_id() << " touch_device_id "
- << state->touch_device_id << " size "
- << devices[i].size.ToString();
- found_mapping = true;
- break;
- }
- }
-
- if (!found_mapping) {
- no_match_touchscreen.insert(devices[i].id);
- VLOG(2) << "No matching display for touch_device_id "
- << devices[i].id << " size " << devices[i].size.ToString();
- }
- }
-
- // Sometimes we can't find a matching screen for the touchscreen, e.g.
- // due to the touchscreen's reporting range having no correlation with the
- // screen's resolution. In this case, we arbitrarily assign unmatched
- // touchscreens to unmatched screens.
- for (std::set<int>::iterator it = no_match_touchscreen.begin();
- it != no_match_touchscreen.end();
- ++it) {
- for (size_t i = 0; i < displays->size(); ++i) {
- DisplayConfigurator::DisplayState* state = &(*displays)[i];
- if (state->display->type() != DISPLAY_CONNECTION_TYPE_INTERNAL &&
- state->display->native_mode() != NULL &&
- state->touch_device_id == 0) {
- state->touch_device_id = *it;
- VLOG(2) << "Arbitrarily matching touchscreen "
- << state->touch_device_id << " to display "
- << state->display->display_id();
- break;
- }
- }
- }
-}
-
-} // namespace ui
« no previous file with comments | « ui/display/chromeos/touchscreen_delegate_impl.h ('k') | ui/display/chromeos/touchscreen_delegate_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698