File indexing completed on 2024-05-12 05:33:57

0001 /*
0002  *  SPDX-FileCopyrightText: 2014-2015 Sebastian Kügler <sebas@kde.org>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QObject>
0010 
0011 // KWayland
0012 #include <KWayland/Server/compositor_interface.h>
0013 #include <KWayland/Server/display.h>
0014 #include <KWayland/Server/dpms_interface.h>
0015 #include <KWayland/Server/outputconfiguration_interface.h>
0016 #include <KWayland/Server/outputdevice_interface.h>
0017 #include <KWayland/Server/outputmanagement_interface.h>
0018 #include <KWayland/Server/seat_interface.h>
0019 #include <KWayland/Server/shell_interface.h>
0020 
0021 namespace KScreen
0022 {
0023 static const QString s_socketName = QStringLiteral("libkscreen-test-wayland-backend-0");
0024 
0025 using namespace KWayland::Server;
0026 
0027 class WaylandTestServer : public QObject
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     explicit WaylandTestServer(QObject *parent = nullptr);
0033     ~WaylandTestServer() override;
0034 
0035     void setConfig(const QString &configfile);
0036     void start();
0037     void stop();
0038 
0039     void showOutputs();
0040     KWayland::Server::Display *display();
0041     QList<KWayland::Server::OutputDeviceInterface *> outputs() const;
0042 
0043     int outputCount() const;
0044 
0045     void suspendChanges(bool suspend);
0046 
0047 Q_SIGNALS:
0048     void outputsChanged();
0049 
0050     void started();
0051 
0052     void configReceived();
0053     void configChanged();
0054 
0055 private Q_SLOTS:
0056     void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *configurationInterface);
0057 
0058 private:
0059     static QString modeString(KWayland::Server::OutputDeviceInterface *outputdevice, int mid);
0060     QString m_configFile;
0061     KWayland::Server::Display *m_display;
0062     QList<KWayland::Server::OutputDeviceInterface *> m_outputs;
0063     KWayland::Server::OutputManagementInterface *m_outputManagement;
0064     KWayland::Server::DpmsManagerInterface *m_dpmsManager;
0065     bool m_suspendChanges;
0066     KWayland::Server::OutputConfigurationInterface *m_waiting;
0067 };
0068 
0069 } // namespace