Changeset View
Changeset View
Standalone View
Standalone View
tests/kwayland/waylandtestserver.cpp
Show All 30 Lines | |||||
31 | 31 | | |||
32 | Q_LOGGING_CATEGORY(KSCREEN_WAYLAND_TESTSERVER, "kscreen.kwayland.testserver") | 32 | Q_LOGGING_CATEGORY(KSCREEN_WAYLAND_TESTSERVER, "kscreen.kwayland.testserver") | ||
33 | 33 | | |||
34 | using namespace KScreen; | 34 | using namespace KScreen; | ||
35 | using namespace KWayland::Server; | 35 | using namespace KWayland::Server; | ||
36 | 36 | | |||
37 | WaylandTestServer::WaylandTestServer(QObject *parent) | 37 | WaylandTestServer::WaylandTestServer(QObject *parent) | ||
38 | : QObject(parent) | 38 | : QObject(parent) | ||
39 | , m_configFile(TEST_DATA + QStringLiteral("default.json")) | 39 | , m_configFile(QLatin1String(TEST_DATA) + QLatin1String("default.json")) | ||
davidedmundson: shouldn't that be a QStringLiteral? | |||||
gladhorn: Concatenation is still faster with latin1string. | |||||
40 | , m_display(nullptr) | 40 | , m_display(nullptr) | ||
41 | , m_outputManagement(nullptr) | 41 | , m_outputManagement(nullptr) | ||
42 | , m_dpmsManager(nullptr) | 42 | , m_dpmsManager(nullptr) | ||
43 | , m_suspendChanges(false) | 43 | , m_suspendChanges(false) | ||
44 | , m_waiting(nullptr) | 44 | , m_waiting(nullptr) | ||
45 | { | 45 | { | ||
46 | } | 46 | } | ||
47 | 47 | | |||
48 | WaylandTestServer::~WaylandTestServer() | 48 | WaylandTestServer::~WaylandTestServer() | ||
49 | { | 49 | { | ||
50 | stop(); | 50 | stop(); | ||
51 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << "Wayland server shut down."; | 51 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << "Wayland server shut down."; | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | void WaylandTestServer::start() | 54 | void WaylandTestServer::start() | ||
55 | { | 55 | { | ||
56 | using namespace KWayland::Server; | 56 | using namespace KWayland::Server; | ||
57 | delete m_display; | 57 | delete m_display; | ||
58 | m_display = new KWayland::Server::Display(this); | 58 | m_display = new KWayland::Server::Display(this); | ||
59 | if (qgetenv("WAYLAND_DISPLAY").isEmpty()) { | 59 | if (qgetenv("WAYLAND_DISPLAY").isEmpty()) { | ||
60 | m_display->setSocketName(s_socketName); | 60 | m_display->setSocketName(s_socketName); | ||
61 | } else { | 61 | } else { | ||
62 | m_display->setSocketName(qgetenv("WAYLAND_DISPLAY").constData()); | 62 | m_display->setSocketName(QString::fromLatin1(qgetenv("WAYLAND_DISPLAY"))); | ||
63 | } | 63 | } | ||
64 | m_display->start(); | 64 | m_display->start(); | ||
65 | 65 | | |||
66 | auto manager = m_display->createDpmsManager(); | 66 | auto manager = m_display->createDpmsManager(); | ||
67 | manager->create(); | 67 | manager->create(); | ||
68 | 68 | | |||
69 | m_outputManagement = m_display->createOutputManagement(); | 69 | m_outputManagement = m_display->createOutputManagement(); | ||
70 | m_outputManagement->create(); | 70 | m_outputManagement->create(); | ||
71 | connect(m_outputManagement, &OutputManagementInterface::configurationChangeRequested, this, &WaylandTestServer::configurationChangeRequested); | 71 | connect(m_outputManagement, &OutputManagementInterface::configurationChangeRequested, this, &WaylandTestServer::configurationChangeRequested); | ||
72 | 72 | | |||
73 | KScreen::WaylandConfigReader::outputsFromConfig(m_configFile, m_display, m_outputs); | 73 | KScreen::WaylandConfigReader::outputsFromConfig(m_configFile, m_display, m_outputs); | ||
74 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << QString("export WAYLAND_DISPLAY="+m_display->socketName()); | 74 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << QStringLiteral("export WAYLAND_DISPLAY=") + m_display->socketName(); | ||
75 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << QString("You can specify the WAYLAND_DISPLAY for this server by exporting it in the environment"); | 75 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << QStringLiteral("You can specify the WAYLAND_DISPLAY for this server by exporting it in the environment"); | ||
76 | //showOutputs(); | 76 | //showOutputs(); | ||
77 | } | 77 | } | ||
78 | 78 | | |||
79 | void WaylandTestServer::stop() | 79 | void WaylandTestServer::stop() | ||
80 | { | 80 | { | ||
81 | Q_FOREACH (const auto &o, m_outputs) { | 81 | Q_FOREACH (const auto &o, m_outputs) { | ||
82 | delete o; | 82 | delete o; | ||
83 | } | 83 | } | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | |||||
163 | 163 | | |||
164 | void WaylandTestServer::showOutputs() | 164 | void WaylandTestServer::showOutputs() | ||
165 | { | 165 | { | ||
166 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << "******** Wayland server running: " << m_outputs.count() << " outputs. ********"; | 166 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << "******** Wayland server running: " << m_outputs.count() << " outputs. ********"; | ||
167 | foreach (auto o, m_outputs) { | 167 | foreach (auto o, m_outputs) { | ||
168 | bool enabled = (o->enabled() == KWayland::Server::OutputDeviceInterface::Enablement::Enabled); | 168 | bool enabled = (o->enabled() == KWayland::Server::OutputDeviceInterface::Enablement::Enabled); | ||
169 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " * Output id: " << o->uuid(); | 169 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " * Output id: " << o->uuid(); | ||
170 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Enabled: " << (enabled ? "enabled" : "disabled"); | 170 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Enabled: " << (enabled ? "enabled" : "disabled"); | ||
171 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Name: " << QString("%2-%3").arg(o->manufacturer(), o->model()); | 171 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Name: " << QStringLiteral("%2-%3").arg(o->manufacturer(), o->model()); | ||
172 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Mode: " << modeString(o, o->currentModeId()); | 172 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Mode: " << modeString(o, o->currentModeId()); | ||
173 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Pos: " << o->globalPosition(); | 173 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Pos: " << o->globalPosition(); | ||
174 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Edid: " << o->edid(); | 174 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << " Edid: " << o->edid(); | ||
175 | // << o->currentMode().size(); | 175 | // << o->currentMode().size(); | ||
176 | 176 | | |||
177 | } | 177 | } | ||
178 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << "******************************************************"; | 178 | qCDebug(KSCREEN_WAYLAND_TESTSERVER) << "******************************************************"; | ||
179 | } | 179 | } | ||
180 | 180 | | |||
181 | QString WaylandTestServer::modeString(KWayland::Server::OutputDeviceInterface* outputdevice, int mid) | 181 | QString WaylandTestServer::modeString(KWayland::Server::OutputDeviceInterface* outputdevice, int mid) | ||
182 | { | 182 | { | ||
183 | QString s; | 183 | QString s; | ||
184 | QString ids; | 184 | QString ids; | ||
185 | int _i = 0; | 185 | int _i = 0; | ||
186 | Q_FOREACH (const auto &_m, outputdevice->modes()) { | 186 | Q_FOREACH (const auto &_m, outputdevice->modes()) { | ||
187 | _i++; | 187 | _i++; | ||
188 | if (_i < 6) { | 188 | if (_i < 6) { | ||
189 | ids.append(QString::number(_m.id) + ", "); | 189 | ids.append(QString::number(_m.id) + QLatin1String(", ")); | ||
190 | } else { | 190 | } else { | ||
191 | ids.append("."); | 191 | ids.append(QLatin1Char('.')); | ||
192 | } | 192 | } | ||
193 | if (_m.id == mid) { | 193 | if (_m.id == mid) { | ||
194 | s = QString("%1x%2 @%3").arg(QString::number(_m.size.width()), \ | 194 | s = QStringLiteral("%1x%2 @%3").arg(QString::number(_m.size.width()), \ | ||
195 | QString::number(_m.size.height()), QString::number(_m.refreshRate)); | 195 | QString::number(_m.size.height()), QString::number(_m.refreshRate)); | ||
196 | } | 196 | } | ||
197 | } | 197 | } | ||
198 | return QString("[%1] %2 (%4 modes: %3)").arg(QString::number(mid), s, ids, QString::number(outputdevice->modes().count())); | 198 | return QStringLiteral("[%1] %2 (%4 modes: %3)").arg(QString::number(mid), s, ids, QString::number(outputdevice->modes().count())); | ||
199 | 199 | | |||
200 | } | 200 | } |
shouldn't that be a QStringLiteral?