2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2015-04-08 08:25:51 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2015-04-08 08:25:51 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2015-04-08 08:25:51 +00:00
|
|
|
#ifndef KWIN_UDEV_H
|
|
|
|
#define KWIN_UDEV_H
|
2015-04-08 08:45:52 +00:00
|
|
|
#include <memory>
|
2015-05-05 15:58:09 +00:00
|
|
|
#include <kwin_export.h>
|
2015-04-08 08:25:51 +00:00
|
|
|
|
2020-10-05 21:05:55 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <QVector>
|
|
|
|
|
2021-04-29 05:36:26 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2015-04-08 08:25:51 +00:00
|
|
|
struct udev;
|
2015-04-08 08:45:52 +00:00
|
|
|
struct udev_device;
|
2015-04-23 13:08:24 +00:00
|
|
|
struct udev_monitor;
|
2015-04-08 08:25:51 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
2015-04-23 13:08:24 +00:00
|
|
|
class Udev;
|
2015-04-08 08:45:52 +00:00
|
|
|
|
2015-05-05 15:58:09 +00:00
|
|
|
class KWIN_EXPORT UdevDevice
|
2015-04-08 08:45:52 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
UdevDevice(udev_device *device);
|
|
|
|
~UdevDevice();
|
|
|
|
|
2021-04-30 07:05:49 +00:00
|
|
|
QString devNode() const;
|
2021-04-28 18:30:16 +00:00
|
|
|
dev_t devNum() const;
|
2015-04-23 13:07:30 +00:00
|
|
|
const char *property(const char *key);
|
|
|
|
bool hasProperty(const char *key, const char *value);
|
2021-04-27 11:49:53 +00:00
|
|
|
QString action() const;
|
2015-04-08 08:45:52 +00:00
|
|
|
|
2021-04-12 17:53:50 +00:00
|
|
|
QMap<QByteArray, QByteArray> properties() const;
|
2021-04-26 13:18:41 +00:00
|
|
|
bool isBootVga() const;
|
2021-04-12 17:53:50 +00:00
|
|
|
|
2015-04-08 08:45:52 +00:00
|
|
|
operator udev_device*() const {
|
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
operator udev_device*() {
|
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
typedef std::unique_ptr<UdevDevice> Ptr;
|
|
|
|
|
|
|
|
private:
|
2021-04-12 18:09:10 +00:00
|
|
|
udev_device *const m_device;
|
2015-04-08 08:45:52 +00:00
|
|
|
};
|
|
|
|
|
2015-05-05 15:58:09 +00:00
|
|
|
class KWIN_EXPORT UdevMonitor
|
2015-04-23 13:08:24 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit UdevMonitor(Udev *udev);
|
|
|
|
~UdevMonitor();
|
|
|
|
|
|
|
|
int fd() const;
|
|
|
|
bool isValid() const {
|
|
|
|
return m_monitor != nullptr;
|
|
|
|
}
|
|
|
|
void filterSubsystemDevType(const char *subSystem, const char *devType = nullptr);
|
|
|
|
void enable();
|
|
|
|
UdevDevice::Ptr getDevice();
|
|
|
|
|
|
|
|
private:
|
|
|
|
udev_monitor *m_monitor;
|
|
|
|
};
|
|
|
|
|
2015-05-05 15:58:09 +00:00
|
|
|
class KWIN_EXPORT Udev
|
2015-04-08 08:25:51 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Udev();
|
|
|
|
~Udev();
|
|
|
|
|
|
|
|
bool isValid() const {
|
|
|
|
return m_udev != nullptr;
|
|
|
|
}
|
2020-10-05 21:05:55 +00:00
|
|
|
std::vector<UdevDevice::Ptr> listGPUs();
|
|
|
|
std::vector<UdevDevice::Ptr> listFramebuffers();
|
2015-04-08 08:45:52 +00:00
|
|
|
UdevDevice::Ptr deviceFromSyspath(const char *syspath);
|
2015-04-23 13:08:24 +00:00
|
|
|
UdevMonitor *monitor();
|
2015-04-08 08:25:51 +00:00
|
|
|
operator udev*() const {
|
|
|
|
return m_udev;
|
|
|
|
}
|
|
|
|
operator udev*() {
|
|
|
|
return m_udev;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
struct udev *m_udev;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|