| Index: ui/ozone/platform/dri/chromeos/display_event_listener_udev.cc
|
| diff --git a/ui/ozone/platform/dri/chromeos/display_event_listener_udev.cc b/ui/ozone/platform/dri/chromeos/display_event_listener_udev.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..481ea3d2a465328e0ffce665d5939ff958425c5a
|
| --- /dev/null
|
| +++ b/ui/ozone/platform/dri/chromeos/display_event_listener_udev.cc
|
| @@ -0,0 +1,44 @@
|
| +// 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/ozone/platform/dri/chromeos/display_event_listener_udev.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "ui/events/ozone/device_udev.h"
|
| +
|
| +namespace ui {
|
| +
|
| +namespace {
|
| +const char kSubsystemDrm[] = "drm";
|
| +} // namespace
|
| +
|
| +DisplayEventListenerUdev::DisplayEventListenerUdev(DeviceUdev* udev)
|
| + : udev_(udev) {}
|
| +
|
| +DisplayEventListenerUdev::~DisplayEventListenerUdev() {
|
| + udev_->UnregisterDeviceMonitor(this);
|
| + callback_.Reset();
|
| +}
|
| +
|
| +void DisplayEventListenerUdev::StartMonitoring(
|
| + const DisplayEventCallback& callback) {
|
| + callback_ = callback;
|
| +
|
| + if (!udev_->RegisterDeviceMonitor(this, kSubsystemDrm))
|
| + LOG(ERROR) << "Failed to start monitoring changes to DRM via Udev";
|
| +}
|
| +
|
| +void DisplayEventListenerUdev::HandleUdevEvent(scoped_udev_device device) {
|
| + const char* device_path = udev_device_get_devnode(device.get());
|
| + const char* action = udev_device_get_action(device.get());
|
| + const char* hotplug = udev_device_get_property_value(device.get(), "HOTPLUG");
|
| +
|
| + if (!device_path || !action || !hotplug)
|
| + return;
|
| +
|
| + if (!strcmp(action, "change") && !strcmp(hotplug, "1"))
|
| + callback_.Run();
|
| +}
|
| +
|
| +} // namespace ui
|
|
|