Changeset View
Changeset View
Standalone View
Standalone View
backends/kwayland/waylandoutput.h
1 | /************************************************************************************* | 1 | /************************************************************************* | ||
---|---|---|---|---|---|
2 | * Copyright 2014-2015 Sebastian Kügler <sebas@kde.org> * | 2 | Copyright © 2014-2015 Sebastian Kügler <sebas@kde.org> | ||
3 | * * | 3 | Copyright © 2019-2020 Roman Gilg <subdiff@gmail.com> | ||
4 | * This library is free software; you can redistribute it and/or * | 4 | | ||
5 | * modify it under the terms of the GNU Lesser General Public * | 5 | This library is free software; you can redistribute it and/or | ||
6 | * License as published by the Free Software Foundation; either * | 6 | modify it under the terms of the GNU Lesser General Public | ||
7 | * version 2.1 of the License, or (at your option) any later version. * | 7 | License as published by the Free Software Foundation; either | ||
8 | * * | 8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | * This library is distributed in the hope that it will be useful, * | 9 | | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 10 | This library is distributed in the hope that it will be useful, | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * Lesser General Public License for more details. * | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * * | 13 | Lesser General Public License for more details. | ||
14 | * You should have received a copy of the GNU Lesser General Public * | 14 | | ||
15 | * License along with this library; if not, write to the Free Software * | 15 | You should have received a copy of the GNU Lesser General Public | ||
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | 16 | License along with this library; if not, write to the Free Software | ||
17 | *************************************************************************************/ | 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | **************************************************************************/ | ||||
18 | #pragma once | 19 | #pragma once | ||
19 | 20 | | |||
20 | #include "waylandconfig.h" | 21 | #include <kscreen/output.h> | ||
21 | 22 | | |||
22 | #include "abstractbackend.h" | 23 | #include "kscreen_wayland_export.h" | ||
23 | #include "output.h" | | |||
24 | 24 | | |||
25 | #include <KWayland/Client/outputdevice.h> | 25 | #include <QString> | ||
26 | #include <KWayland/Client/registry.h> | | |||
27 | | ||||
28 | #include <QLoggingCategory> | | |||
29 | #include <QScreen> | | |||
30 | #include <QSize> | | |||
31 | | ||||
32 | namespace KWayland | | |||
33 | { | | |||
34 | namespace Client | | |||
35 | { | | |||
36 | class OutputConfiguration; | | |||
37 | } | | |||
38 | } | | |||
39 | 26 | | |||
40 | namespace KScreen | 27 | namespace KScreen | ||
41 | { | 28 | { | ||
29 | class WaylandInterface; | ||||
42 | 30 | | |||
43 | class WaylandOutput : public QObject | 31 | class KSCREEN_WAYLAND_EXPORT WaylandOutput : public QObject | ||
44 | { | 32 | { | ||
45 | Q_OBJECT | 33 | Q_OBJECT | ||
46 | 34 | | |||
47 | public: | 35 | public: | ||
48 | explicit WaylandOutput(quint32 id, WaylandConfig *parent = nullptr); | 36 | explicit WaylandOutput(quint32 id, QObject *parent = nullptr); | ||
49 | ~WaylandOutput() override = default; | 37 | ~WaylandOutput() override = default; | ||
50 | 38 | | |||
51 | KScreen::OutputPtr toKScreenOutput(); | 39 | KScreen::OutputPtr toKScreenOutput(); | ||
52 | void updateKScreenOutput(KScreen::OutputPtr &output); | 40 | virtual void updateKScreenOutput(KScreen::OutputPtr &output) = 0; | ||
53 | | ||||
54 | quint32 id() const; | | |||
55 | QString name() const; | | |||
56 | bool enabled() const; | | |||
57 | 41 | | |||
58 | KWayland::Client::OutputDevice* outputDevice() const; | 42 | virtual quint32 id() const; | ||
59 | void createOutputDevice(KWayland::Client::Registry *registry, quint32 name, quint32 version); | 43 | virtual QByteArray edid() const = 0; | ||
44 | virtual bool enabled() const = 0; | ||||
45 | virtual QRectF geometry() const = 0; | ||||
60 | 46 | | |||
61 | bool setWlConfig(KWayland::Client::OutputConfiguration *wlConfig, | 47 | KScreen::Output::Type guessType(const QString &type, const QString &name) const; | ||
62 | const KScreen::OutputPtr &output); | | |||
63 | 48 | | |||
64 | Q_SIGNALS: | 49 | Q_SIGNALS: | ||
65 | void deviceRemoved(); | 50 | void dataReceived(); | ||
66 | | ||||
67 | void complete(); | | |||
68 | // only emitted after complete signal | | |||
69 | void changed(); | 51 | void changed(); | ||
52 | void removed(); | ||||
70 | 53 | | |||
71 | private: | 54 | private: | ||
72 | void showOutput(); | | |||
73 | QString modeName(const KWayland::Client::OutputDevice::Mode &m) const; | | |||
74 | | ||||
75 | quint32 m_id; | 55 | quint32 m_id; | ||
76 | KWayland::Client::OutputDevice *m_device; | | |||
77 | KWayland::Client::Registry *m_registry; | | |||
78 | 56 | | |||
79 | // left-hand-side: KScreen::Mode, right-hand-side: KWayland's mode.id | 57 | // left-hand-side: KScreen::Mode, right-hand-side: Compositor's mode id | ||
80 | QMap<QString, int> m_modeIdMap; | 58 | QMap<QString, int> m_modeIdMap; | ||
81 | }; | 59 | }; | ||
82 | 60 | | |||
83 | } | 61 | } | ||
84 | | ||||
85 | KSCREEN_EXPORT QDebug operator<<(QDebug dbg, const KScreen::WaylandOutput *output); | |