Skip to content

Commit

Permalink
feat(server): introduce output manager
Browse files Browse the repository at this point in the history
Add a new class that holds objects relevant for outputs. This can be extended
in the future.
  • Loading branch information
romangg committed Mar 21, 2023
1 parent 879c0e5 commit e2f5e12
Show file tree
Hide file tree
Showing 23 changed files with 187 additions and 79 deletions.
6 changes: 4 additions & 2 deletions autotests/client/drm_lease_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ void drm_lease_v1_test::init()
server.display->start();
QVERIFY(server.display->running());

server.globals.output_manager
= std::make_unique<Wrapland::Server::output_manager>(*server.display);
server.display->createShm();
server.globals.drm_lease_device_v1
= std::make_unique<Wrapland::Server::drm_lease_device_v1>(server.display.get());
Expand Down Expand Up @@ -209,7 +211,7 @@ void drm_lease_v1_test::test_connectors()
std::vector<std::unique_ptr<Wrapland::Server::output>> server_outputs;
auto add_output = [&server_outputs, this] {
server_outputs.emplace_back(
std::make_unique<Wrapland::Server::output>(server.display.get()));
std::make_unique<Wrapland::Server::output>(*server.globals.output_manager));
};

add_output();
Expand Down Expand Up @@ -289,7 +291,7 @@ void drm_lease_v1_test::test_lease()
std::vector<std::unique_ptr<Wrapland::Server::output>> server_outputs;
auto add_output = [&server_outputs, this] {
server_outputs.emplace_back(
std::make_unique<Wrapland::Server::output>(server.display.get()));
std::make_unique<Wrapland::Server::output>(*server.globals.output_manager));
};

add_output();
Expand Down
6 changes: 4 additions & 2 deletions autotests/client/layer_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ private Q_SLOTS:
private:
struct {
std::unique_ptr<Wrapland::Server::Display> display;
Wrapland::Server::globals globals;
std::unique_ptr<Wrapland::Server::output> output;
Wrapland::Server::globals globals;
} server;

QThread* m_thread{nullptr};
Expand All @@ -73,14 +73,16 @@ void layer_shell_test::init()
server.display->start();
QVERIFY(server.display->running());

server.globals.output_manager
= std::make_unique<Wrapland::Server::output_manager>(*server.display);
server.display->createShm();
server.globals.compositor
= std::make_unique<Wrapland::Server::Compositor>(server.display.get());
server.globals.layer_shell_v1
= std::make_unique<Wrapland::Server::LayerShellV1>(server.display.get());
server.globals.xdg_shell = std::make_unique<Wrapland::Server::XdgShell>(server.display.get());

server.output = std::make_unique<Wrapland::Server::output>(server.display.get());
server.output = std::make_unique<Wrapland::Server::output>(*server.globals.output_manager);
server.output->set_enabled(true);
server.output->done();

Expand Down
5 changes: 4 additions & 1 deletion autotests/client/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.

#include "../../server/display.h"
#include "../../server/dpms.h"
#include "../../server/output_manager.h"

#include <wayland-client-protocol.h>

Expand Down Expand Up @@ -62,6 +63,7 @@ private Q_SLOTS:
struct {
std::unique_ptr<Wrapland::Server::Display> display;
std::unique_ptr<Wrapland::Server::output> output;
std::unique_ptr<Wrapland::Server::output_manager> output_manager;
} server;

Clt::ConnectionThread* m_connection;
Expand All @@ -85,8 +87,9 @@ void TestOutput::init()
server.display->start();
QVERIFY(server.display->running());

server.output_manager = std::make_unique<Wrapland::Server::output_manager>(*server.display);
Srv::output_metadata meta{.name = "HDMI-A", .make = "Foocorp", .model = "Barmodel"};
server.output = std::make_unique<Wrapland::Server::output>(meta, server.display.get());
server.output = std::make_unique<Wrapland::Server::output>(meta, *server.output_manager);

QCOMPARE(server.output->mode_size(), QSize());
QCOMPARE(server.output->refresh_rate(), 60000);
Expand Down
6 changes: 5 additions & 1 deletion autotests/client/output_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.

#include "../../server/display.h"
#include "../../server/output.h"
#include "../../server/output_manager.h"

#include <wayland-client-protocol.h>

Expand Down Expand Up @@ -58,6 +59,7 @@ private Q_SLOTS:
struct {
std::unique_ptr<Wrapland::Server::Display> display;
std::unique_ptr<Wrapland::Server::output> output;
std::unique_ptr<Wrapland::Server::output_manager> output_manager;
} server;

std::string m_name = "HDMI-A";
Expand All @@ -84,6 +86,8 @@ TestOutputDevice::TestOutputDevice(QObject* parent)
void TestOutputDevice::init()
{
server.display = std::make_unique<Wrapland::Server::Display>();
server.output_manager = std::make_unique<Wrapland::Server::output_manager>(*server.display);

server.display->set_socket_name(std::string(socket_name));
server.display->start();
QVERIFY(server.display->running());
Expand All @@ -93,7 +97,7 @@ void TestOutputDevice::init()
.model = m_model,
.serial_number = m_serialNumber,
.physical_size = {200, 100}};
server.output = std::make_unique<Wrapland::Server::output>(meta, server.display.get());
server.output = std::make_unique<Wrapland::Server::output>(meta, *server.output_manager);

Srv::output_mode m0;
m0.id = 0;
Expand Down
30 changes: 16 additions & 14 deletions autotests/client/output_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ private Q_SLOTS:

struct {
std::unique_ptr<Wrapland::Server::Display> display;
Wrapland::Server::globals globals;
std::unique_ptr<Wrapland::Server::output> output;
Wrapland::Server::globals globals;
} server;

Clt::Registry* m_registry = nullptr;
Expand Down Expand Up @@ -113,9 +113,11 @@ void TestOutputManagement::init()
server.display->start();
QVERIFY(server.display->running());

server.globals.output_manager
= std::make_unique<Wrapland::Server::output_manager>(*server.display);
server.globals.compositor
= std::make_unique<Wrapland::Server::Compositor>(server.display.get());
server.output = std::make_unique<Wrapland::Server::output>(server.display.get());
server.output = std::make_unique<Wrapland::Server::output>(*server.globals.output_manager);

Srv::output_mode m0;
m0.id = 0;
Expand Down Expand Up @@ -147,7 +149,7 @@ void TestOutputManagement::init()
server.output->set_enabled(true);
server.output->done();

server.globals.output_management_v1
server.globals.output_manager->management_v1
= std::make_unique<Wrapland::Server::OutputManagementV1>(server.display.get());

// setup connection
Expand Down Expand Up @@ -292,10 +294,10 @@ void TestOutputManagement::testBasicMemoryManagement()
{
createConfig();

QSignalSpy serverApplySpy(server.globals.output_management_v1.get(),
QSignalSpy serverApplySpy(server.globals.output_manager->management_v1.get(),
&Srv::OutputManagementV1::configurationChangeRequested);
Srv::OutputConfigurationV1* configurationInterface = nullptr;
connect(server.globals.output_management_v1.get(),
connect(server.globals.output_manager->management_v1.get(),
&Srv::OutputManagementV1::configurationChangeRequested,
[=, &configurationInterface](Srv::OutputConfigurationV1* c) {
configurationInterface = c;
Expand All @@ -319,7 +321,7 @@ void TestOutputManagement::testRemoval()
QSignalSpy outputManagementRemovedSpy(m_registry, &Clt::Registry::outputManagementV1Removed);
QVERIFY(outputManagementRemovedSpy.isValid());

server.globals.output_management_v1.reset();
server.globals.output_manager->management_v1.reset();
QVERIFY(outputManagementRemovedSpy.wait(200));
QCOMPARE(outputManagementRemovedSpy.first().first(), m_announcedSpy->first().first());
QVERIFY(!m_registry->hasInterface(Clt::Registry::Interface::OutputManagementV1));
Expand All @@ -332,7 +334,7 @@ void TestOutputManagement::testApplied()
QVERIFY(m_outputConfiguration->isValid());
QSignalSpy appliedSpy(m_outputConfiguration, &Clt::OutputConfigurationV1::applied);

connect(server.globals.output_management_v1.get(),
connect(server.globals.output_manager->management_v1.get(),
&Srv::OutputManagementV1::configurationChangeRequested,
[=](Srv::OutputConfigurationV1* configurationInterface) {
configurationInterface->setApplied();
Expand All @@ -348,7 +350,7 @@ void TestOutputManagement::testFailed()
QVERIFY(m_outputConfiguration->isValid());
QSignalSpy failedSpy(m_outputConfiguration, &Clt::OutputConfigurationV1::failed);

connect(server.globals.output_management_v1.get(),
connect(server.globals.output_manager->management_v1.get(),
&Srv::OutputManagementV1::configurationChangeRequested,
[=](Srv::OutputConfigurationV1* configurationInterface) {
configurationInterface->setFailed();
Expand Down Expand Up @@ -391,13 +393,13 @@ void TestOutputManagement::testMultipleSettings()
QSignalSpy outputChangedSpy(output, &Clt::OutputDeviceV1::changed);

Srv::OutputConfigurationV1* configurationInterface;
connect(server.globals.output_management_v1.get(),
connect(server.globals.output_manager->management_v1.get(),
&Srv::OutputManagementV1::configurationChangeRequested,
[=, &configurationInterface](Srv::OutputConfigurationV1* c) {
applyPendingChanges(c);
configurationInterface = c;
});
QSignalSpy serverApplySpy(server.globals.output_management_v1.get(),
QSignalSpy serverApplySpy(server.globals.output_manager->management_v1.get(),
&Srv::OutputManagementV1::configurationChangeRequested);
QVERIFY(serverApplySpy.isValid());

Expand Down Expand Up @@ -443,7 +445,7 @@ void TestOutputManagement::testConfigFailed()
QVERIFY(config->isValid());
QVERIFY(output->isValid());

QSignalSpy serverApplySpy(server.globals.output_management_v1.get(),
QSignalSpy serverApplySpy(server.globals.output_manager->management_v1.get(),
&Srv::OutputManagementV1::configurationChangeRequested);
QVERIFY(serverApplySpy.isValid());
QSignalSpy outputChangedSpy(output, &Clt::OutputDeviceV1::changed);
Expand All @@ -459,7 +461,7 @@ void TestOutputManagement::testConfigFailed()

config->apply();

connect(server.globals.output_management_v1.get(),
connect(server.globals.output_manager->management_v1.get(),
&Srv::OutputManagementV1::configurationChangeRequested,
[=](Srv::OutputConfigurationV1* c) { c->setFailed(); });

Expand All @@ -483,7 +485,7 @@ void TestOutputManagement::testExampleConfig()
// config->setGeometry(output, QRectF(QPoint(-1, -1), output->geometry().size()));

QSignalSpy configAppliedSpy(config, &Clt::OutputConfigurationV1::applied);
connect(server.globals.output_management_v1.get(),
connect(server.globals.output_manager->management_v1.get(),
&Srv::OutputManagementV1::configurationChangeRequested,
[=](Srv::OutputConfigurationV1* c) { c->setApplied(); });
config->apply();
Expand All @@ -503,7 +505,7 @@ void TestOutputManagement::testScale()
config->apply();

QSignalSpy configAppliedSpy(config, &OutputConfiguration::applied);
connect(server.globals.output_management_v1.get(), &Srv::OutputManagementV1::configurationChangeRequested, [=](Srv::OutputConfigurationV1 *c) {
connect(server.globals.output_manager->management_v1.get(), &Srv::OutputManagementV1::configurationChangeRequested, [=](Srv::OutputConfigurationV1 *c) {
applyPendingChanges(c);
c->setApplied();
});
Expand Down
4 changes: 3 additions & 1 deletion autotests/client/plasma_window_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ void TestWindowManagement::init()
QVERIFY(m_registry->isValid());
m_registry->setup();

server.globals.output_manager
= std::make_unique<Wrapland::Server::output_manager>(*server.display);
server.globals.compositor
= std::make_unique<Wrapland::Server::Compositor>(server.display.get());
QVERIFY(compositorSpy.wait());
Expand Down Expand Up @@ -859,7 +861,7 @@ void TestWindowManagement::testSendToOutput()
QSignalSpy outputAnnouncedSpy(m_registry, &Wrapland::Client::Registry::outputAnnounced);
QVERIFY(outputAnnouncedSpy.isValid());

auto srv_output = std::make_unique<Srv::output>(server.display.get());
auto srv_output = std::make_unique<Srv::output>(*server.globals.output_manager);
srv_output->set_enabled(true);
srv_output->done();

Expand Down
6 changes: 4 additions & 2 deletions autotests/client/presentation_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ private Q_SLOTS:
private:
struct {
std::unique_ptr<Wrapland::Server::Display> display;
Wrapland::Server::globals globals;
std::unique_ptr<Wrapland::Server::output> output;
Wrapland::Server::globals globals;
} server;

Client::ConnectionThread* m_connection;
Expand Down Expand Up @@ -89,12 +89,14 @@ void TestPresentationTime::init()

server.display->createShm();

server.globals.output_manager
= std::make_unique<Wrapland::Server::output_manager>(*server.display);
server.globals.compositor
= std::make_unique<Wrapland::Server::Compositor>(server.display.get());
server.globals.presentation_manager
= std::make_unique<Wrapland::Server::PresentationManager>(server.display.get());

server.output = std::make_unique<Wrapland::Server::output>(server.display.get());
server.output = std::make_unique<Wrapland::Server::output>(*server.globals.output_manager);
server.output->set_enabled(true);
server.output->done();

Expand Down
20 changes: 11 additions & 9 deletions autotests/client/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,12 @@ void TestWaylandRegistry::init()
server.display->start();

server.display->createShm();

server.globals.output_manager
= std::make_unique<Wrapland::Server::output_manager>(*server.display);
server.globals.compositor
= std::make_unique<Wrapland::Server::Compositor>(server.display.get());
server.globals.outputs.emplace_back(
std::make_unique<Wrapland::Server::output>(server.display.get()));
std::make_unique<Wrapland::Server::output>(*server.globals.output_manager));
server.globals.seats.emplace_back(
std::make_unique<Wrapland::Server::Seat>(server.display.get()));
server.globals.subcompositor
Expand All @@ -181,8 +182,8 @@ void TestWaylandRegistry::init()
= std::make_unique<Wrapland::Server::data_control_manager_v1>(server.display.get());
server.globals.drm_lease_device_v1
= std::make_unique<Wrapland::Server::drm_lease_device_v1>(server.display.get());
server.globals.output_management_v1
= std::make_unique<Wrapland::Server::OutputManagementV1>(server.display.get());
server.globals.output_manager->create_management_v1();
server.globals.output_manager->create_xdg_manager();
server.globals.blur_manager
= std::make_unique<Wrapland::Server::BlurManager>(server.display.get());
server.globals.contrast_manager
Expand Down Expand Up @@ -229,6 +230,7 @@ void TestWaylandRegistry::init()

void TestWaylandRegistry::cleanup()
{
server = {};
}

void TestWaylandRegistry::testCreate()
Expand Down Expand Up @@ -728,7 +730,7 @@ void TestWaylandRegistry::testRemoval()
QSignalSpy outputManagementRemovedSpy(&registry, SIGNAL(outputManagementV1Removed(quint32)));
QVERIFY(outputManagementRemovedSpy.isValid());

server.globals.output_management_v1.reset();
server.globals.output_manager->management_v1.reset();
QVERIFY(outputManagementRemovedSpy.wait());
QCOMPARE(outputManagementRemovedSpy.first().first(),
outputManagementAnnouncedSpy.first().first());
Expand Down Expand Up @@ -1030,7 +1032,7 @@ void TestWaylandRegistry::testAnnounceMultiple()
QSignalSpy outputAnnouncedSpy(&registry, &Registry::outputAnnounced);
QVERIFY(outputAnnouncedSpy.isValid());

auto output1 = std::make_unique<Wrapland::Server::output>(server.display.get());
auto output1 = std::make_unique<Wrapland::Server::output>(*server.globals.output_manager);
output1->set_enabled(true);
output1->done();
QVERIFY(outputAnnouncedSpy.wait());
Expand All @@ -1044,7 +1046,7 @@ void TestWaylandRegistry::testAnnounceMultiple()
QCOMPARE(registry.interface(Registry::Interface::Output).version,
outputAnnouncedSpy.first().last().value<quint32>());

auto output2 = std::make_unique<Wrapland::Server::output>(server.display.get());
auto output2 = std::make_unique<Wrapland::Server::output>(*server.globals.output_manager);
output2->set_enabled(true);
output2->done();
QVERIFY(outputAnnouncedSpy.wait());
Expand Down Expand Up @@ -1111,7 +1113,7 @@ void TestWaylandRegistry::testAnnounceMultipleOutputDeviceV1s()
QSignalSpy outputDeviceAnnouncedSpy(&registry, &Registry::outputDeviceV1Announced);
QVERIFY(outputDeviceAnnouncedSpy.isValid());

auto device1 = std::make_unique<Wrapland::Server::output>(server.display.get());
auto device1 = std::make_unique<Wrapland::Server::output>(*server.globals.output_manager);
QVERIFY(outputDeviceAnnouncedSpy.wait());

QCOMPARE(registry.interfaces(Registry::Interface::OutputDeviceV1).count(), 2);
Expand All @@ -1124,7 +1126,7 @@ void TestWaylandRegistry::testAnnounceMultipleOutputDeviceV1s()
QCOMPARE(registry.interface(Registry::Interface::OutputDeviceV1).version,
outputDeviceAnnouncedSpy.first().last().value<quint32>());

auto device2 = std::make_unique<Wrapland::Server::output>(server.display.get());
auto device2 = std::make_unique<Wrapland::Server::output>(*server.globals.output_manager);
QVERIFY(outputDeviceAnnouncedSpy.wait());
QCOMPARE(registry.interfaces(Registry::Interface::OutputDeviceV1).count(), 3);
QCOMPARE(registry.interfaces(Registry::Interface::OutputDeviceV1).last().name,
Expand Down
4 changes: 3 additions & 1 deletion autotests/client/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ void TestSurface::init()
server.display->start();
QVERIFY(server.display->running());

server.globals.output_manager
= std::make_unique<Wrapland::Server::output_manager>(*server.display);
server.display->createShm();
server.globals.compositor
= std::make_unique<Wrapland::Server::Compositor>(server.display.get());
Expand Down Expand Up @@ -1125,7 +1127,7 @@ void TestSurface::testOutput()
QSignalSpy outputAnnouncedSpy(&registry, &Wrapland::Client::Registry::outputAnnounced);
QVERIFY(outputAnnouncedSpy.isValid());

auto serverOutput = new Wrapland::Server::output(server.display.get());
auto serverOutput = new Wrapland::Server::output(*server.globals.output_manager);
serverOutput->set_enabled(true);
serverOutput->done();

Expand Down
Loading

0 comments on commit e2f5e12

Please sign in to comment.