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 |