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.
This commit is contained in:
Aleix Pol 2022-05-17 02:51:46 +02:00
parent ad74b8cd59
commit f4c704a904

View file

@ -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();
}