diff --git a/kcmkwin/kwinoptions/windows.cpp b/kcmkwin/kwinoptions/windows.cpp --- a/kcmkwin/kwinoptions/windows.cpp +++ b/kcmkwin/kwinoptions/windows.cpp @@ -119,7 +119,7 @@ void KFocusConfig::updateMultiScreen() { - m_ui->multiscreenBox->setVisible(QApplication::desktop()->screenCount() > 1); + m_ui->multiscreenBox->setVisible(QApplication::screens().count() > 1); } diff --git a/kcmkwin/kwinscreenedges/monitor.cpp b/kcmkwin/kwinscreenedges/monitor.cpp --- a/kcmkwin/kwinscreenedges/monitor.cpp +++ b/kcmkwin/kwinscreenedges/monitor.cpp @@ -26,20 +26,45 @@ #include #include -#include #include #include #include #include +#include +#include namespace KWin { +static QWindow *windowFromWidget(const QWidget *widget) +{ + QWindow *windowHandle = widget->windowHandle(); + if (windowHandle) { + return windowHandle; + } + + const QWidget *nativeParent = widget->nativeParentWidget(); + if (nativeParent) { + return nativeParent->windowHandle(); + } + + return nullptr; +} + +static QScreen *screenFromWidget(const QWidget *widget) +{ + const QWindow *windowHandle = windowFromWidget(widget); + if (windowHandle && windowHandle->screen()) { + return windowHandle->screen(); + } + + return QGuiApplication::primaryScreen(); +} + Monitor::Monitor(QWidget* parent) : ScreenPreviewWidget(parent) { - QDesktopWidget *desktop = QApplication::desktop(); - QRect avail = desktop->availableGeometry(desktop->screenNumber(this)); + QRect avail = screenFromWidget(this)->geometry(); setRatio((qreal)avail.width() / (qreal)avail.height()); for (int i = 0; i < 8; diff --git a/kcmkwin/kwintabbox/layoutpreview.cpp b/kcmkwin/kwintabbox/layoutpreview.cpp --- a/kcmkwin/kwintabbox/layoutpreview.cpp +++ b/kcmkwin/kwintabbox/layoutpreview.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -243,7 +244,8 @@ QRect SwitcherItem::screenGeometry() const { - return qApp->desktop()->screenGeometry(qApp->desktop()->primaryScreen()); + const QScreen *primaryScreen = qApp->primaryScreen(); + return primaryScreen->geometry(); } void SwitcherItem::incrementIndex() diff --git a/kcmkwin/kwintabbox/main.cpp b/kcmkwin/kwintabbox/main.cpp --- a/kcmkwin/kwintabbox/main.cpp +++ b/kcmkwin/kwintabbox/main.cpp @@ -145,7 +145,7 @@ connect(ui[i]->otherActivities, SIGNAL(clicked(bool)), SLOT(changed())); connect(ui[i]->filterScreens, SIGNAL(clicked(bool)), SLOT(changed())); - if (QApplication::desktop()->screenCount() < 2) { + if (QApplication::screens().count() < 2) { ui[i]->filterScreens->hide(); ui[i]->screenFilter->hide(); } else {