diff --git a/kcmkwin/kwinoptions/windows.cpp b/kcmkwin/kwinoptions/windows.cpp
index 3dbe15ee82..c6a3a6bc7d 100644
--- a/kcmkwin/kwinoptions/windows.cpp
+++ b/kcmkwin/kwinoptions/windows.cpp
@@ -119,7 +119,7 @@ KFocusConfig::KFocusConfig(bool _standAlone, KConfig *_config, QWidget * parent)
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
index d1f0fb0d00..73b709b7bc 100644
--- a/kcmkwin/kwinscreenedges/monitor.cpp
+++ b/kcmkwin/kwinscreenedges/monitor.cpp
@@ -26,20 +26,45 @@ along with this program. If not, see .
#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
index 716b000b2c..2859d673e6 100644
--- a/kcmkwin/kwintabbox/layoutpreview.cpp
+++ b/kcmkwin/kwintabbox/layoutpreview.cpp
@@ -25,6 +25,7 @@ along with this program. If not, see .
#include
#include
#include
+#include
#include
#include
#include
@@ -243,7 +244,8 @@ void SwitcherItem::setCurrentIndex(int index)
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
index f1827ee7cf..bc64d73991 100644
--- a/kcmkwin/kwintabbox/main.cpp
+++ b/kcmkwin/kwintabbox/main.cpp
@@ -145,7 +145,7 @@ KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args)
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 {