diff --git a/app/mainwindow.h b/app/mainwindow.h --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -172,6 +172,10 @@ int getScreen(); QRect getDesktopGeometry(); + // get a better value from plasmashell through dbus in wayland case + QRect m_availableScreenRect; + void _toggleWindowState(); + void showStartupPopup(); void updateUseTranslucency(); diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -54,7 +54,10 @@ #include #include #include +#include +#include #include +#include #if HAVE_X11 #include @@ -1098,6 +1101,23 @@ } void MainWindow::toggleWindowState() +{ + if (m_isWayland) { + QDBusInterface strutManager(QStringLiteral("org.kde.plasmashell"), QStringLiteral("/StrutManager"), QStringLiteral("org.kde.PlasmaShell.StrutManager")); + QDBusPendingCall async = strutManager.asyncCall(QStringLiteral("availableScreenRect"), QGuiApplication::screens().at(getScreen())->name()); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [=]() { + QDBusPendingReply reply = *watcher; + m_availableScreenRect = reply.isValid() ? reply.value() : QRect(); + _toggleWindowState(); + watcher->deleteLater(); + }); + } else { + _toggleWindowState(); + } +} + +void MainWindow::_toggleWindowState() { bool visible = isVisible(); @@ -1442,8 +1462,9 @@ return screenGeometry; if (m_isWayland) { - // on Wayland it's not possible to get the work area - return screenGeometry; + // on Wayland it's not possible to get the work area from KWindowSystem + // but plasmashell provides this through dbus + return m_availableScreenRect.isValid() ? m_availableScreenRect : screenGeometry; } if (QGuiApplication::screens().count() > 1)