From f4c704a9049b150ed6d8db6cb4d2ee404d316f48 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 17 May 2022 02:51:46 +0200 Subject: [PATCH] screenedges kcm: Fix initial screen detection Use QWidget::screen instead of having own code to fetch the screen. It works better this way before the window is initialised. --- src/kcmkwin/kwinscreenedges/monitor.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/kcmkwin/kwinscreenedges/monitor.cpp b/src/kcmkwin/kwinscreenedges/monitor.cpp index eda4aafa58..2318253c60 100644 --- a/src/kcmkwin/kwinscreenedges/monitor.cpp +++ b/src/kcmkwin/kwinscreenedges/monitor.cpp @@ -25,26 +25,11 @@ 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(); + QScreen *screen = widget->screen(); + if (screen) { + return screen; } return QGuiApplication::primaryScreen(); @@ -73,6 +58,8 @@ Monitor::Monitor(QWidget *parent) hidden[i] = false; grp[i] = new QActionGroup(this); } + QRect avail = screenFromWidget(this)->geometry(); + setRatio((qreal)avail.width() / (qreal)avail.height()); checkSize(); }