diff --git a/src/kcmkwin/kwinscreenedges/monitor.cpp b/src/kcmkwin/kwinscreenedges/monitor.cpp index baf13c883c..eda4aafa58 100644 --- a/src/kcmkwin/kwinscreenedges/monitor.cpp +++ b/src/kcmkwin/kwinscreenedges/monitor.cpp @@ -53,8 +53,6 @@ static QScreen *screenFromWidget(const QWidget *widget) Monitor::Monitor(QWidget *parent) : ScreenPreviewWidget(parent) { - QRect avail = screenFromWidget(this)->geometry(); - setRatio((qreal)avail.width() / (qreal)avail.height()); for (int i = 0; i < 8; ++i) { @@ -97,6 +95,17 @@ void Monitor::resizeEvent(QResizeEvent *e) checkSize(); } +bool Monitor::event(QEvent *event) +{ + const bool r = ScreenPreviewWidget::event(event); + if (event->type() == QEvent::ScreenChangeInternal) { + QRect avail = screenFromWidget(this)->geometry(); + setRatio((qreal)avail.width() / (qreal)avail.height()); + checkSize(); + } + return r; +} + void Monitor::checkSize() { QRect contentsRect = previewRect(); diff --git a/src/kcmkwin/kwinscreenedges/monitor.h b/src/kcmkwin/kwinscreenedges/monitor.h index cdebc585f9..3dc7ee8d44 100644 --- a/src/kcmkwin/kwinscreenedges/monitor.h +++ b/src/kcmkwin/kwinscreenedges/monitor.h @@ -65,6 +65,7 @@ Q_SIGNALS: protected: void resizeEvent(QResizeEvent *e) override; + bool event(QEvent *event) override; private: class Corner;