Commit ae055c29 authored by Martin Seher's avatar Martin Seher Committed by Nate Graham
Browse files

On Wayland, show on active output

QCursor::pos does not work under wayland. So use active output from KWin
to determine startup screen, if not configured otherwise.

BUG: 445158
parent bf148a89
Pipeline #162825 passed with stage
in 43 seconds
......@@ -38,6 +38,7 @@
#include <QDBusConnection>
#include <QDBusInterface>
#include <QDBusPendingReply>
#include <QDBusReply>
#include <QDesktopWidget>
#include <QMenu>
#include <QPainter>
......@@ -1485,6 +1486,19 @@ void MainWindow::setFullScreen(bool state)
int MainWindow::getScreen()
{
if (!Settings::screen() || Settings::screen() > QGuiApplication::screens().length()) {
auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"),
QStringLiteral("/KWin"),
QStringLiteral("org.kde.KWin"),
QStringLiteral("activeOutputName"));
QDBusReply<QString> reply = QDBusConnection::sessionBus().call(message);
if (reply.isValid()) {
const auto screens = QGuiApplication::screens();
for (int i = 0; i < screens.size(); ++i) {
if (screens[i]->name() == reply.value())
return i;
}
}
// Right after unplugging an external monitor and the Yakuake window was on
// that monitor, QGuiApplication::screenAt() can return nullptr so we fallback on
// the first monitor.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment