summaryrefslogtreecommitdiffstats
path: root/ui/display/chromeos
diff options
context:
space:
mode:
authordnicoara <dnicoara@chromium.org>2014-09-11 08:07:06 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-11 15:10:34 +0000
commit1e77a6b0a26aecd03e8512e91cdd93befb8a66c0 (patch)
tree5e73b057b5a8c6da17e6ef59b39865e707cde16b /ui/display/chromeos
parent804526fcfb2db3525b4cc40350b69787b0658303 (diff)
downloadchromium_src-1e77a6b0a26aecd03e8512e91cdd93befb8a66c0.zip
chromium_src-1e77a6b0a26aecd03e8512e91cdd93befb8a66c0.tar.gz
chromium_src-1e77a6b0a26aecd03e8512e91cdd93befb8a66c0.tar.bz2
Move touchscreen device caching to DeviceDataManager
Rather than poll for touchscreen devices in ui/display, centralize X11 hotplug handling into ui/events and have TouchscreenDelegateImpl reuse the cached device list. In addition, DeviceDataManager will now cache all the touchscreen devices and provides an observer pattern such that we can move input event hotplugging out of ui/display entirely (this will be done in a follow-up CL). BUG=381326 Review URL: https://codereview.chromium.org/508303002 Cr-Commit-Position: refs/heads/master@{#294388}
Diffstat (limited to 'ui/display/chromeos')
-rw-r--r--ui/display/chromeos/DEPS3
-rw-r--r--ui/display/chromeos/display_configurator.cc3
-rw-r--r--ui/display/chromeos/display_configurator.h1
-rw-r--r--ui/display/chromeos/ozone/display_configurator_ozone.cc8
-rw-r--r--ui/display/chromeos/touchscreen_delegate_impl.cc10
-rw-r--r--ui/display/chromeos/touchscreen_delegate_impl.h8
-rw-r--r--ui/display/chromeos/touchscreen_delegate_impl_unittest.cc83
-rw-r--r--ui/display/chromeos/x11/display_configurator_x11.cc9
-rw-r--r--ui/display/chromeos/x11/native_display_delegate_x11.cc81
-rw-r--r--ui/display/chromeos/x11/native_display_delegate_x11.h4
-rw-r--r--ui/display/chromeos/x11/touchscreen_device_manager_x11.cc163
-rw-r--r--ui/display/chromeos/x11/touchscreen_device_manager_x11.h32
12 files changed, 78 insertions, 327 deletions
diff --git a/ui/display/chromeos/DEPS b/ui/display/chromeos/DEPS
new file mode 100644
index 0000000..fe1d98e
--- /dev/null
+++ b/ui/display/chromeos/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+ui/events",
+]
diff --git a/ui/display/chromeos/display_configurator.cc b/ui/display/chromeos/display_configurator.cc
index f25f05a..65c5402 100644
--- a/ui/display/chromeos/display_configurator.cc
+++ b/ui/display/chromeos/display_configurator.cc
@@ -11,6 +11,7 @@
#include "base/strings/stringprintf.h"
#include "base/sys_info.h"
#include "base/time/time.h"
+#include "ui/display/chromeos/touchscreen_delegate_impl.h"
#include "ui/display/display_switches.h"
#include "ui/display/types/chromeos/display_mode.h"
#include "ui/display/types/chromeos/display_snapshot.h"
@@ -199,7 +200,7 @@ void DisplayConfigurator::Init(bool is_panel_fitting_enabled) {
}
if (!touchscreen_delegate_)
- touchscreen_delegate_ = CreatePlatformTouchscreenDelegate();
+ touchscreen_delegate_.reset(new TouchscreenDelegateImpl());
}
void DisplayConfigurator::ForceInitialConfigure(
diff --git a/ui/display/chromeos/display_configurator.h b/ui/display/chromeos/display_configurator.h
index 33b378e..cae4086 100644
--- a/ui/display/chromeos/display_configurator.h
+++ b/ui/display/chromeos/display_configurator.h
@@ -257,7 +257,6 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
// Performs platform specific delegate initialization.
scoped_ptr<NativeDisplayDelegate> CreatePlatformNativeDisplayDelegate();
- scoped_ptr<TouchscreenDelegate> CreatePlatformTouchscreenDelegate();
// Updates |cached_displays_| to contain currently-connected displays. Calls
// |delegate_->GetDisplays()| and then does additional work, like finding the
diff --git a/ui/display/chromeos/ozone/display_configurator_ozone.cc b/ui/display/chromeos/ozone/display_configurator_ozone.cc
index 451a6a8..ea8f2de 100644
--- a/ui/display/chromeos/ozone/display_configurator_ozone.cc
+++ b/ui/display/chromeos/ozone/display_configurator_ozone.cc
@@ -4,9 +4,7 @@
#include "ui/display/chromeos/display_configurator.h"
-#include "ui/display/chromeos/touchscreen_delegate_impl.h"
#include "ui/display/types/chromeos/native_display_delegate.h"
-#include "ui/display/types/chromeos/touchscreen_device_manager.h"
#include "ui/ozone/public/ozone_platform.h"
namespace ui {
@@ -16,10 +14,4 @@ DisplayConfigurator::CreatePlatformNativeDisplayDelegate() {
return ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate();
}
-scoped_ptr<DisplayConfigurator::TouchscreenDelegate>
-DisplayConfigurator::CreatePlatformTouchscreenDelegate() {
- return scoped_ptr<TouchscreenDelegate>(new TouchscreenDelegateImpl(
- ui::OzonePlatform::GetInstance()->CreateTouchscreenDeviceManager()));
-}
-
} // namespace ui
diff --git a/ui/display/chromeos/touchscreen_delegate_impl.cc b/ui/display/chromeos/touchscreen_delegate_impl.cc
index dc60e3f..4114756 100644
--- a/ui/display/chromeos/touchscreen_delegate_impl.cc
+++ b/ui/display/chromeos/touchscreen_delegate_impl.cc
@@ -9,20 +9,20 @@
#include "ui/display/types/chromeos/display_mode.h"
#include "ui/display/types/chromeos/display_snapshot.h"
-#include "ui/display/types/chromeos/touchscreen_device_manager.h"
+#include "ui/events/device_data_manager.h"
namespace ui {
-TouchscreenDelegateImpl::TouchscreenDelegateImpl(
- scoped_ptr<TouchscreenDeviceManager> touch_device_manager)
- : touch_device_manager_(touch_device_manager.Pass()) {}
+TouchscreenDelegateImpl::TouchscreenDelegateImpl() {
+}
TouchscreenDelegateImpl::~TouchscreenDelegateImpl() {}
void TouchscreenDelegateImpl::AssociateTouchscreens(
std::vector<DisplayConfigurator::DisplayState>* displays) {
std::set<int> no_match_touchscreen;
- std::vector<TouchscreenDevice> devices = touch_device_manager_->GetDevices();
+ const std::vector<TouchscreenDevice>& devices =
+ DeviceDataManager::GetInstance()->touchscreen_devices();
int internal_touchscreen = -1;
for (size_t i = 0; i < devices.size(); ++i) {
diff --git a/ui/display/chromeos/touchscreen_delegate_impl.h b/ui/display/chromeos/touchscreen_delegate_impl.h
index 32e0b174..2ac2b18 100644
--- a/ui/display/chromeos/touchscreen_delegate_impl.h
+++ b/ui/display/chromeos/touchscreen_delegate_impl.h
@@ -8,17 +8,13 @@
#include "base/memory/scoped_ptr.h"
#include "ui/display/chromeos/display_configurator.h"
#include "ui/display/display_export.h"
-#include "ui/display/types/chromeos/touchscreen_device.h"
namespace ui {
-class TouchscreenDeviceManager;
-
class DISPLAY_EXPORT TouchscreenDelegateImpl
: public DisplayConfigurator::TouchscreenDelegate {
public:
- explicit TouchscreenDelegateImpl(
- scoped_ptr<TouchscreenDeviceManager> touch_device_manager);
+ TouchscreenDelegateImpl();
virtual ~TouchscreenDelegateImpl();
// DisplayConfigurator::TouchscreenDelegate overrides:
@@ -26,8 +22,6 @@ class DISPLAY_EXPORT TouchscreenDelegateImpl
std::vector<DisplayConfigurator::DisplayState>* displays) OVERRIDE;
private:
- scoped_ptr<TouchscreenDeviceManager> touch_device_manager_;
-
DISALLOW_COPY_AND_ASSIGN(TouchscreenDelegateImpl);
};
diff --git a/ui/display/chromeos/touchscreen_delegate_impl_unittest.cc b/ui/display/chromeos/touchscreen_delegate_impl_unittest.cc
index 9e80712..d480e20 100644
--- a/ui/display/chromeos/touchscreen_delegate_impl_unittest.cc
+++ b/ui/display/chromeos/touchscreen_delegate_impl_unittest.cc
@@ -10,43 +10,21 @@
#include "ui/display/chromeos/display_configurator.h"
#include "ui/display/chromeos/test/test_display_snapshot.h"
#include "ui/display/chromeos/touchscreen_delegate_impl.h"
-#include "ui/display/types/chromeos/touchscreen_device_manager.h"
+#include "ui/events/device_data_manager.h"
+#include "ui/events/device_hotplug_event_observer.h"
namespace ui {
-namespace {
-
-class MockTouchscreenDeviceManager : public TouchscreenDeviceManager {
- public:
- MockTouchscreenDeviceManager() {}
- virtual ~MockTouchscreenDeviceManager() {}
-
- void AddDevice(const TouchscreenDevice& device) {
- devices_.push_back(device);
- }
-
- // TouchscreenDeviceManager overrides:
- virtual std::vector<TouchscreenDevice> GetDevices() OVERRIDE {
- return devices_;
- }
-
- private:
- std::vector<TouchscreenDevice> devices_;
-
- DISALLOW_COPY_AND_ASSIGN(MockTouchscreenDeviceManager);
-};
-
-} // namespace
-
class TouchscreenDelegateImplTest : public testing::Test {
public:
- TouchscreenDelegateImplTest() {}
+ TouchscreenDelegateImplTest() {
+ DeviceDataManager::CreateInstance();
+ device_delegate_ = DeviceDataManager::GetInstance();
+ }
virtual ~TouchscreenDelegateImplTest() {}
virtual void SetUp() OVERRIDE {
- device_manager_ = new MockTouchscreenDeviceManager();
- delegate_.reset(new TouchscreenDelegateImpl(
- scoped_ptr<TouchscreenDeviceManager>(device_manager_)));
+ touchscreen_delegate_.reset(new TouchscreenDelegateImpl());
// Internal display will always match to internal touchscreen. If internal
// touchscreen can't be detected, it is then associated to a touch screen
@@ -82,6 +60,8 @@ class TouchscreenDelegateImplTest : public testing::Test {
}
displays_.clear();
+ device_delegate_->OnTouchscreenDevicesUpdated(
+ std::vector<TouchscreenDevice>());
}
std::vector<DisplayConfigurator::DisplayState> GetDisplayStates() {
@@ -93,9 +73,9 @@ class TouchscreenDelegateImplTest : public testing::Test {
}
protected:
- MockTouchscreenDeviceManager* device_manager_; // Not owned.
- scoped_ptr<TouchscreenDelegateImpl> delegate_;
+ scoped_ptr<TouchscreenDelegateImpl> touchscreen_delegate_;
ScopedVector<DisplaySnapshot> displays_;
+ DeviceHotplugEventObserver* device_delegate_; // Not owned.
private:
DISALLOW_COPY_AND_ASSIGN(TouchscreenDelegateImplTest);
@@ -104,19 +84,21 @@ class TouchscreenDelegateImplTest : public testing::Test {
TEST_F(TouchscreenDelegateImplTest, NoTouchscreens) {
std::vector<DisplayConfigurator::DisplayState> display_states =
GetDisplayStates();
- delegate_->AssociateTouchscreens(&display_states);
+ touchscreen_delegate_->AssociateTouchscreens(&display_states);
for (size_t i = 0; i < display_states.size(); ++i)
EXPECT_EQ(TouchscreenDevice::kInvalidId, display_states[i].touch_device_id);
}
TEST_F(TouchscreenDelegateImplTest, OneToOneMapping) {
- device_manager_->AddDevice(TouchscreenDevice(1, gfx::Size(800, 600), false));
- device_manager_->AddDevice(TouchscreenDevice(2, gfx::Size(1024, 768), false));
+ std::vector<TouchscreenDevice> devices;
+ devices.push_back(TouchscreenDevice(1, gfx::Size(800, 600), false));
+ devices.push_back(TouchscreenDevice(2, gfx::Size(1024, 768), false));
+ device_delegate_->OnTouchscreenDevicesUpdated(devices);
std::vector<DisplayConfigurator::DisplayState> display_states =
GetDisplayStates();
- delegate_->AssociateTouchscreens(&display_states);
+ touchscreen_delegate_->AssociateTouchscreens(&display_states);
EXPECT_EQ(TouchscreenDevice::kInvalidId, display_states[0].touch_device_id);
EXPECT_EQ(1, display_states[1].touch_device_id);
@@ -125,11 +107,13 @@ TEST_F(TouchscreenDelegateImplTest, OneToOneMapping) {
}
TEST_F(TouchscreenDelegateImplTest, MapToCorrectDisplaySize) {
- device_manager_->AddDevice(TouchscreenDevice(2, gfx::Size(1024, 768), false));
+ std::vector<TouchscreenDevice> devices;
+ devices.push_back(TouchscreenDevice(2, gfx::Size(1024, 768), false));
+ device_delegate_->OnTouchscreenDevicesUpdated(devices);
std::vector<DisplayConfigurator::DisplayState> display_states =
GetDisplayStates();
- delegate_->AssociateTouchscreens(&display_states);
+ touchscreen_delegate_->AssociateTouchscreens(&display_states);
EXPECT_EQ(TouchscreenDevice::kInvalidId, display_states[0].touch_device_id);
EXPECT_EQ(TouchscreenDevice::kInvalidId, display_states[1].touch_device_id);
@@ -138,12 +122,14 @@ TEST_F(TouchscreenDelegateImplTest, MapToCorrectDisplaySize) {
}
TEST_F(TouchscreenDelegateImplTest, MapWhenSizeDiffersByOne) {
- device_manager_->AddDevice(TouchscreenDevice(1, gfx::Size(801, 600), false));
- device_manager_->AddDevice(TouchscreenDevice(2, gfx::Size(1023, 768), false));
+ std::vector<TouchscreenDevice> devices;
+ devices.push_back(TouchscreenDevice(1, gfx::Size(801, 600), false));
+ devices.push_back(TouchscreenDevice(2, gfx::Size(1023, 768), false));
+ device_delegate_->OnTouchscreenDevicesUpdated(devices);
std::vector<DisplayConfigurator::DisplayState> display_states =
GetDisplayStates();
- delegate_->AssociateTouchscreens(&display_states);
+ touchscreen_delegate_->AssociateTouchscreens(&display_states);
EXPECT_EQ(TouchscreenDevice::kInvalidId, display_states[0].touch_device_id);
EXPECT_EQ(1, display_states[1].touch_device_id);
@@ -152,12 +138,14 @@ TEST_F(TouchscreenDelegateImplTest, MapWhenSizeDiffersByOne) {
}
TEST_F(TouchscreenDelegateImplTest, MapWhenSizesDoNotMatch) {
- device_manager_->AddDevice(TouchscreenDevice(1, gfx::Size(1022, 768), false));
- device_manager_->AddDevice(TouchscreenDevice(2, gfx::Size(802, 600), false));
+ std::vector<TouchscreenDevice> devices;
+ devices.push_back(TouchscreenDevice(1, gfx::Size(1022, 768), false));
+ devices.push_back(TouchscreenDevice(2, gfx::Size(802, 600), false));
+ device_delegate_->OnTouchscreenDevicesUpdated(devices);
std::vector<DisplayConfigurator::DisplayState> display_states =
GetDisplayStates();
- delegate_->AssociateTouchscreens(&display_states);
+ touchscreen_delegate_->AssociateTouchscreens(&display_states);
EXPECT_EQ(TouchscreenDevice::kInvalidId, display_states[0].touch_device_id);
EXPECT_EQ(1, display_states[1].touch_device_id);
@@ -166,13 +154,14 @@ TEST_F(TouchscreenDelegateImplTest, MapWhenSizesDoNotMatch) {
}
TEST_F(TouchscreenDelegateImplTest, MapInternalTouchscreen) {
- device_manager_->AddDevice(
- TouchscreenDevice(1, gfx::Size(1920, 1080), false));
- device_manager_->AddDevice(TouchscreenDevice(2, gfx::Size(9999, 888), true));
+ std::vector<TouchscreenDevice> devices;
+ devices.push_back(TouchscreenDevice(1, gfx::Size(1920, 1080), false));
+ devices.push_back(TouchscreenDevice(2, gfx::Size(9999, 888), true));
+ device_delegate_->OnTouchscreenDevicesUpdated(devices);
std::vector<DisplayConfigurator::DisplayState> display_states =
GetDisplayStates();
- delegate_->AssociateTouchscreens(&display_states);
+ touchscreen_delegate_->AssociateTouchscreens(&display_states);
// Internal touchscreen is always mapped to internal display.
EXPECT_EQ(2, display_states[0].touch_device_id);
diff --git a/ui/display/chromeos/x11/display_configurator_x11.cc b/ui/display/chromeos/x11/display_configurator_x11.cc
index 8d8fa5a..93c056c 100644
--- a/ui/display/chromeos/x11/display_configurator_x11.cc
+++ b/ui/display/chromeos/x11/display_configurator_x11.cc
@@ -4,9 +4,7 @@
#include "ui/display/chromeos/display_configurator.h"
-#include "ui/display/chromeos/touchscreen_delegate_impl.h"
#include "ui/display/chromeos/x11/native_display_delegate_x11.h"
-#include "ui/display/chromeos/x11/touchscreen_device_manager_x11.h"
namespace ui {
@@ -15,11 +13,4 @@ DisplayConfigurator::CreatePlatformNativeDisplayDelegate() {
return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateX11());
}
-scoped_ptr<DisplayConfigurator::TouchscreenDelegate>
-DisplayConfigurator::CreatePlatformTouchscreenDelegate() {
- return scoped_ptr<TouchscreenDelegate>(new TouchscreenDelegateImpl(
- scoped_ptr<TouchscreenDeviceManager>(
- new TouchscreenDeviceManagerX11())));
-}
-
} // namespace ui
diff --git a/ui/display/chromeos/x11/native_display_delegate_x11.cc b/ui/display/chromeos/x11/native_display_delegate_x11.cc
index 5f19ae6..8e84538 100644
--- a/ui/display/chromeos/x11/native_display_delegate_x11.cc
+++ b/ui/display/chromeos/x11/native_display_delegate_x11.cc
@@ -20,7 +20,8 @@
#include "ui/display/chromeos/x11/native_display_event_dispatcher_x11.h"
#include "ui/display/types/chromeos/native_display_observer.h"
#include "ui/display/util/x11/edid_parser_x11.h"
-#include "ui/events/platform/platform_event_observer.h"
+#include "ui/events/device_data_manager.h"
+#include "ui/events/input_device_event_observer.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/x/x11_error_tracker.h"
@@ -71,6 +72,24 @@ XRRCrtcGamma* ResampleGammaRamp(XRRCrtcGamma* gamma_ramp, int gamma_ramp_size) {
return resampled;
}
+class InputHotplugEventObserver : public InputDeviceEventObserver {
+ public:
+ explicit InputHotplugEventObserver(
+ NativeDisplayDelegateX11::HelperDelegate* delegate)
+ : delegate_(delegate) {}
+ virtual ~InputHotplugEventObserver() {}
+
+ // InputDeviceEventObserver:
+ virtual void OnInputDeviceConfigurationChanged() OVERRIDE {
+ delegate_->NotifyDisplayObservers();
+ }
+
+ private:
+ NativeDisplayDelegateX11::HelperDelegate* delegate_; // Not owned.
+
+ DISALLOW_COPY_AND_ASSIGN(InputHotplugEventObserver);
+};
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -103,48 +122,6 @@ class NativeDisplayDelegateX11::HelperDelegateX11
};
////////////////////////////////////////////////////////////////////////////////
-// NativeDisplayDelegateX11::PlatformEventObserverX11
-
-class NativeDisplayDelegateX11::PlatformEventObserverX11
- : public PlatformEventObserver {
- public:
- PlatformEventObserverX11(HelperDelegate* delegate);
- virtual ~PlatformEventObserverX11();
-
- // PlatformEventObserverX11:
- virtual void WillProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
- virtual void DidProcessEvent(const ui::PlatformEvent& event) OVERRIDE;
-
- private:
- HelperDelegate* delegate_; // Not owned.
-
- DISALLOW_COPY_AND_ASSIGN(PlatformEventObserverX11);
-};
-
-NativeDisplayDelegateX11::PlatformEventObserverX11::PlatformEventObserverX11(
- HelperDelegate* delegate)
- : delegate_(delegate) {}
-
-NativeDisplayDelegateX11::PlatformEventObserverX11::
- ~PlatformEventObserverX11() {}
-
-void NativeDisplayDelegateX11::PlatformEventObserverX11::WillProcessEvent(
- const ui::PlatformEvent& event) {
- // XI_HierarchyChanged events are special. There is no window associated with
- // these events. So process them directly from here.
- if (event->type == GenericEvent &&
- event->xgeneric.evtype == XI_HierarchyChanged) {
- VLOG(1) << "Received XI_HierarchyChanged event";
- // Defer configuring outputs to not stall event processing.
- // This also takes care of same event being received twice.
- delegate_->NotifyDisplayObservers();
- }
-}
-
-void NativeDisplayDelegateX11::PlatformEventObserverX11::DidProcessEvent(
- const ui::PlatformEvent& event) {}
-
-////////////////////////////////////////////////////////////////////////////////
// NativeDisplayDelegateX11 implementation:
NativeDisplayDelegateX11::NativeDisplayDelegateX11()
@@ -157,8 +134,11 @@ NativeDisplayDelegateX11::~NativeDisplayDelegateX11() {
if (ui::PlatformEventSource::GetInstance()) {
ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(
platform_event_dispatcher_.get());
- ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(
- platform_event_observer_.get());
+ }
+
+ if (input_hotplug_observer_) {
+ ui::DeviceDataManager::GetInstance()->RemoveObserver(
+ input_hotplug_observer_.get());
}
STLDeleteContainerPairSecondPointers(modes_.begin(), modes_.end());
@@ -172,17 +152,14 @@ void NativeDisplayDelegateX11::Initialize() {
helper_delegate_.reset(new HelperDelegateX11(this));
platform_event_dispatcher_.reset(new NativeDisplayEventDispatcherX11(
helper_delegate_.get(), xrandr_event_base));
- platform_event_observer_.reset(
- new PlatformEventObserverX11(helper_delegate_.get()));
+ input_hotplug_observer_.reset(
+ new InputHotplugEventObserver(helper_delegate_.get()));
+ ui::DeviceDataManager::GetInstance()->AddObserver(
+ input_hotplug_observer_.get());
if (ui::PlatformEventSource::GetInstance()) {
ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(
platform_event_dispatcher_.get());
-
- // We can't do this with a root window listener because XI_HierarchyChanged
- // messages don't have a target window.
- ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(
- platform_event_observer_.get());
}
}
diff --git a/ui/display/chromeos/x11/native_display_delegate_x11.h b/ui/display/chromeos/x11/native_display_delegate_x11.h
index 12bed59..76a84f4 100644
--- a/ui/display/chromeos/x11/native_display_delegate_x11.h
+++ b/ui/display/chromeos/x11/native_display_delegate_x11.h
@@ -41,6 +41,7 @@ namespace ui {
class DisplayModeX11;
class DisplaySnapshotX11;
+class InputDeviceEventObserver;
class NativeDisplayEventDispatcherX11;
class DISPLAY_EXPORT NativeDisplayDelegateX11 : public NativeDisplayDelegate {
@@ -96,7 +97,6 @@ class DISPLAY_EXPORT NativeDisplayDelegateX11 : public NativeDisplayDelegate {
private:
class HelperDelegateX11;
- class PlatformEventObserverX11;
// Parses all the modes made available by |screen_|.
void InitModes();
@@ -150,7 +150,7 @@ class DISPLAY_EXPORT NativeDisplayDelegateX11 : public NativeDisplayDelegate {
scoped_ptr<NativeDisplayEventDispatcherX11> platform_event_dispatcher_;
// Processes X11 display events that have no X11 window associated with it.
- scoped_ptr<PlatformEventObserverX11> platform_event_observer_;
+ scoped_ptr<InputDeviceEventObserver> input_hotplug_observer_;
// List of observers waiting for display configuration change events.
ObserverList<NativeDisplayObserver> observers_;
diff --git a/ui/display/chromeos/x11/touchscreen_device_manager_x11.cc b/ui/display/chromeos/x11/touchscreen_device_manager_x11.cc
deleted file mode 100644
index f613532..0000000
--- a/ui/display/chromeos/x11/touchscreen_device_manager_x11.cc
+++ /dev/null
@@ -1,163 +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/x11/touchscreen_device_manager_x11.h"
-
-#include <X11/extensions/XInput.h>
-#include <X11/extensions/XInput2.h>
-
-#include <cmath>
-#include <set>
-#include <string>
-#include <vector>
-
-#include "base/command_line.h"
-#include "base/files/file_enumerator.h"
-#include "base/logging.h"
-#include "base/process/launch.h"
-#include "base/strings/string_util.h"
-#include "base/sys_info.h"
-#include "ui/gfx/x/x11_types.h"
-
-namespace {
-
-// We consider the touchscreen to be internal if it is an I2c device.
-// With the device id, we can query X to get the device's dev input
-// node eventXXX. Then we search all the dev input nodes registered
-// by I2C devices to see if we can find eventXXX.
-bool IsTouchscreenInternal(XDisplay* dpy, int device_id) {
- using base::FileEnumerator;
- using base::FilePath;
-
- if (!base::SysInfo::IsRunningOnChromeOS())
- return false;
-
- // Input device has a property "Device Node" pointing to its dev input node,
- // e.g. Device Node (250): "/dev/input/event8"
- Atom device_node = XInternAtom(dpy, "Device Node", False);
- if (device_node == None)
- return false;
-
- Atom actual_type;
- int actual_format;
- unsigned long nitems, bytes_after;
- unsigned char* data;
- XDevice* dev = XOpenDevice(dpy, device_id);
- if (!dev)
- return false;
-
- if (XGetDeviceProperty(dpy, dev, device_node, 0, 1000, False,
- AnyPropertyType, &actual_type, &actual_format,
- &nitems, &bytes_after, &data) != Success) {
- XCloseDevice(dpy, dev);
- return false;
- }
- base::FilePath dev_node_path(reinterpret_cast<char*>(data));
- XFree(data);
- XCloseDevice(dpy, dev);
-
- std::string event_node = dev_node_path.BaseName().value();
- if (event_node.empty() ||
- !StartsWithASCII(event_node, "event", false)) {
- return false;
- }
-
- // Extract id "XXX" from "eventXXX"
- std::string event_node_id = event_node.substr(5);
-
- // I2C input device registers its dev input node at
- // /sys/bus/i2c/devices/*/input/inputXXX/eventXXX
- FileEnumerator i2c_enum(FilePath(FILE_PATH_LITERAL("/sys/bus/i2c/devices/")),
- false,
- base::FileEnumerator::DIRECTORIES);
- for (FilePath i2c_name = i2c_enum.Next();
- !i2c_name.empty();
- i2c_name = i2c_enum.Next()) {
- FileEnumerator input_enum(i2c_name.Append(FILE_PATH_LITERAL("input")),
- false,
- base::FileEnumerator::DIRECTORIES,
- FILE_PATH_LITERAL("input*"));
- for (base::FilePath input = input_enum.Next();
- !input.empty();
- input = input_enum.Next()) {
- if (input.BaseName().value().substr(5) == event_node_id)
- return true;
- }
- }
-
- return false;
-}
-
-} // namespace
-
-namespace ui {
-
-TouchscreenDeviceManagerX11::TouchscreenDeviceManagerX11()
- : display_(gfx::GetXDisplay()) {}
-
-TouchscreenDeviceManagerX11::~TouchscreenDeviceManagerX11() {}
-
-std::vector<TouchscreenDevice> TouchscreenDeviceManagerX11::GetDevices() {
- std::vector<TouchscreenDevice> devices;
- int num_devices = 0;
- Atom valuator_x = XInternAtom(display_, "Abs MT Position X", False);
- Atom valuator_y = XInternAtom(display_, "Abs MT Position Y", False);
- if (valuator_x == None || valuator_y == None)
- return devices;
-
- std::set<int> no_match_touchscreen;
- XIDeviceInfo* info = XIQueryDevice(display_, XIAllDevices, &num_devices);
- for (int i = 0; i < num_devices; i++) {
- if (!info[i].enabled || info[i].use != XIFloatingSlave)
- continue; // Assume all touchscreens are floating slaves
-
- double width = -1.0;
- double height = -1.0;
- bool is_direct_touch = false;
-
- for (int j = 0; j < info[i].num_classes; j++) {
- XIAnyClassInfo* class_info = info[i].classes[j];
-
- if (class_info->type == XIValuatorClass) {
- XIValuatorClassInfo* valuator_info =
- reinterpret_cast<XIValuatorClassInfo*>(class_info);
-
- if (valuator_x == valuator_info->label) {
- // Ignore X axis valuator with unexpected properties
- if (valuator_info->number == 0 && valuator_info->mode == Absolute &&
- valuator_info->min == 0.0) {
- width = valuator_info->max;
- }
- } else if (valuator_y == valuator_info->label) {
- // Ignore Y axis valuator with unexpected properties
- if (valuator_info->number == 1 && valuator_info->mode == Absolute &&
- valuator_info->min == 0.0) {
- height = valuator_info->max;
- }
- }
- }
-#if defined(USE_XI2_MT)
- if (class_info->type == XITouchClass) {
- XITouchClassInfo* touch_info =
- reinterpret_cast<XITouchClassInfo*>(class_info);
- is_direct_touch = touch_info->mode == XIDirectTouch;
- }
-#endif
- }
-
- // Touchscreens should have absolute X and Y axes, and be direct touch
- // devices.
- if (width > 0.0 && height > 0.0 && is_direct_touch) {
- bool is_internal = IsTouchscreenInternal(display_, info[i].deviceid);
- devices.push_back(TouchscreenDevice(info[i].deviceid,
- gfx::Size(width, height),
- is_internal));
- }
- }
-
- XIFreeDeviceInfo(info);
- return devices;
-}
-
-} // namespace ui
diff --git a/ui/display/chromeos/x11/touchscreen_device_manager_x11.h b/ui/display/chromeos/x11/touchscreen_device_manager_x11.h
deleted file mode 100644
index 594ef03..0000000
--- a/ui/display/chromeos/x11/touchscreen_device_manager_x11.h
+++ /dev/null
@@ -1,32 +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.
-
-#ifndef UI_DISPLAY_CHROMEOS_X11_TOUCHSCREEN_DEVICE_MANAGER_X11_H_
-#define UI_DISPLAY_CHROMEOS_X11_TOUCHSCREEN_DEVICE_MANAGER_X11_H_
-
-#include "base/macros.h"
-#include "ui/display/types/chromeos/touchscreen_device_manager.h"
-
-struct _XDisplay;
-typedef struct _XDisplay Display;
-
-namespace ui {
-
-class TouchscreenDeviceManagerX11 : public TouchscreenDeviceManager {
- public:
- TouchscreenDeviceManagerX11();
- virtual ~TouchscreenDeviceManagerX11();
-
- // TouchscreenDeviceManager implementation:
- virtual std::vector<TouchscreenDevice> GetDevices() OVERRIDE;
-
- private:
- Display* display_;
-
- DISALLOW_COPY_AND_ASSIGN(TouchscreenDeviceManagerX11);
-};
-
-} // namespace ui
-
-#endif // UI_DISPLAY_CHROMEOS_X11_TOUCHSCREEN_DEVICE_MANAGER_X11_H_