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

Unified Diff: ash/display/display_change_observer_chromeos.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: . 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: ash/display/display_change_observer_chromeos.cc
diff --git a/ash/display/display_change_observer_chromeos.cc b/ash/display/display_change_observer_chromeos.cc
index 1df63bde4077daa23ac49c71c0b65a5a4fb49cd4..10274dff95c87d9bb5b3c173e6694fd087882fd4 100644
--- a/ash/display/display_change_observer_chromeos.cc
+++ b/ash/display/display_change_observer_chromeos.cc
@@ -14,6 +14,7 @@
#include "ash/display/display_layout_store.h"
#include "ash/display/display_manager.h"
#include "ash/shell.h"
+#include "ash/touch/touchscreen_util.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "grit/ash_strings.h"
@@ -22,6 +23,8 @@
#include "ui/display/types/chromeos/display_mode.h"
#include "ui/display/types/chromeos/display_snapshot.h"
#include "ui/display/util/display_util.h"
+#include "ui/events/device_data_manager.h"
+#include "ui/events/touchscreen_device.h"
#include "ui/gfx/display.h"
namespace ash {
@@ -147,9 +150,11 @@ std::vector<DisplayMode> DisplayChangeObserver::GetExternalDisplayModeList(
DisplayChangeObserver::DisplayChangeObserver() {
Shell::GetInstance()->AddShellObserver(this);
+ ui::DeviceDataManager::GetInstance()->AddObserver(this);
}
DisplayChangeObserver::~DisplayChangeObserver() {
+ ui::DeviceDataManager::GetInstance()->RemoveObserver(this);
Shell::GetInstance()->RemoveShellObserver(this);
}
@@ -222,10 +227,6 @@ void DisplayChangeObserver::OnDisplayModeChanged(
new_info.set_device_scale_factor(device_scale_factor);
new_info.SetBounds(display_bounds);
new_info.set_native(true);
- new_info.set_touch_support(state.touch_device_id == 0 ?
- gfx::Display::TOUCH_SUPPORT_UNAVAILABLE :
- gfx::Display::TOUCH_SUPPORT_AVAILABLE);
- new_info.set_touch_device_id(state.touch_device_id);
new_info.set_is_aspect_preserving_scaling(
state.display->is_aspect_preserving_scaling());
@@ -241,6 +242,7 @@ void DisplayChangeObserver::OnDisplayModeChanged(
->GetAvailableColorCalibrationProfiles(id));
}
+ AssociateTouchscreens(&displays);
// DisplayManager can be null during the boot.
Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
}
@@ -262,4 +264,25 @@ float DisplayChangeObserver::FindDeviceScaleFactor(float dpi) {
return 1.0f;
}
+void DisplayChangeObserver::OnInputDeviceConfigurationChanged() {
+ std::vector<DisplayInfo> display_infos;
+ DisplayManager* display_manager =
+ ash::Shell::GetInstance()->display_manager();
+ const std::vector<gfx::Display>& displays = display_manager->displays();
+ // Reuse the current state in DisplayManager and re-associate the displays
+ // with the touchscreens.
+ for (size_t i = 0; i < displays.size(); ++i) {
+ DisplayInfo display = display_manager->GetDisplayInfo(displays[i].id());
+ // Unset the touchscreen configuration since we'll be rematching them from
+ // scratch.
+ display.set_touch_device_id(ui::TouchscreenDevice::kInvalidId);
+ display.set_touch_support(gfx::Display::TOUCH_SUPPORT_UNKNOWN);
+
+ display_infos.push_back(display);
+ }
+
+ AssociateTouchscreens(&display_infos);
+ display_manager->OnNativeDisplaysChanged(display_infos);
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698