From 15520888d92d67c8ee1eba8b3b5c3b4bfddf184e Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 22 Oct 2021 11:14:18 +0300 Subject: [PATCH] kwineffects: Drop numScreens property The screen count can be retrieved by checking the number of items in the EffectHandler.screens property. The replacement for the numberScreensChanged signal are the screenAdded and the screenRemoved signals. The main motivation behind this change is to clean up the screens api and reduce the number of usages of the Screens class. --- autotests/mock_effectshandler.h | 3 --- src/effects.cpp | 6 ------ src/effects.h | 1 - src/effects/desktopgrid/desktopgrid.cpp | 3 ++- src/effects/presentwindows/presentwindows.cpp | 15 +++++++++------ src/effects/presentwindows/presentwindows.h | 1 + src/effects/slide/slide.cpp | 4 +++- src/libkwineffects/kwineffects.h | 7 ------- 8 files changed, 15 insertions(+), 25 deletions(-) diff --git a/autotests/mock_effectshandler.h b/autotests/mock_effectshandler.h index 3c819ff9bb..4d2e088708 100644 --- a/autotests/mock_effectshandler.h +++ b/autotests/mock_effectshandler.h @@ -152,9 +152,6 @@ public: int numberOfDesktops() const override { return 0; } - int numScreens() const override { - return 0; - } bool optionRollOverDesktops() const override { return false; } diff --git a/src/effects.cpp b/src/effects.cpp index f6f50f4911..9242aabf8d 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -188,7 +188,6 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) &KWin::EffectsHandler::sessionStateChanged); connect(vds, &VirtualDesktopManager::countChanged, this, &EffectsHandler::numberDesktopsChanged); connect(Cursors::self()->mouse(), &Cursor::mouseChanged, this, &EffectsHandler::mouseChanged); - connect(Screens::self(), &Screens::countChanged, this, &EffectsHandler::numberScreensChanged); connect(Screens::self(), &Screens::sizeChanged, this, &EffectsHandler::virtualScreenSizeChanged); connect(Screens::self(), &Screens::geometryChanged, this, &EffectsHandler::virtualScreenGeometryChanged); #ifdef KWIN_BUILD_ACTIVITIES @@ -1195,11 +1194,6 @@ EffectScreen *EffectsHandlerImpl::activeScreen() const return EffectScreenImpl::get(workspace()->activeOutput()); } -int EffectsHandlerImpl::numScreens() const -{ - return Screens::self()->count(); -} - QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectScreen *screen, int desktop) const { const VirtualDesktop *virtualDesktop; diff --git a/src/effects.h b/src/effects.h index 72a3ff507b..b298b8962b 100644 --- a/src/effects.h +++ b/src/effects.h @@ -141,7 +141,6 @@ public: void addRepaint(const QRegion& r) override; void addRepaint(int x, int y, int w, int h) override; EffectScreen *activeScreen() const override; - int numScreens() const override; QRect clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const override; QRect clientArea(clientAreaOption, const EffectWindow* c) const override; QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const override; diff --git a/src/effects/desktopgrid/desktopgrid.cpp b/src/effects/desktopgrid/desktopgrid.cpp index cf7e563c67..c505ba1882 100644 --- a/src/effects/desktopgrid/desktopgrid.cpp +++ b/src/effects/desktopgrid/desktopgrid.cpp @@ -118,7 +118,8 @@ DesktopGridEffect::DesktopGridEffect() connect(effects, &EffectsHandler::windowDeleted, this, &DesktopGridEffect::slotWindowDeleted); connect(effects, &EffectsHandler::numberDesktopsChanged, this, &DesktopGridEffect::slotNumberDesktopsChanged); connect(effects, &EffectsHandler::windowFrameGeometryChanged, this, &DesktopGridEffect::slotWindowFrameGeometryChanged); - connect(effects, &EffectsHandler::numberScreensChanged, this, &DesktopGridEffect::setup); + connect(effects, &EffectsHandler::screenAdded, this, &DesktopGridEffect::setup); + connect(effects, &EffectsHandler::screenRemoved, this, &DesktopGridEffect::setup); connect(effects, &EffectsHandler::screenAboutToLock, this, [this]() { deactivate(); diff --git a/src/effects/presentwindows/presentwindows.cpp b/src/effects/presentwindows/presentwindows.cpp index 31b15a5d1a..50ee02ba09 100644 --- a/src/effects/presentwindows/presentwindows.cpp +++ b/src/effects/presentwindows/presentwindows.cpp @@ -99,12 +99,8 @@ PresentWindowsEffect::PresentWindowsEffect() connect(effects, &EffectsHandler::windowDeleted, this, &PresentWindowsEffect::slotWindowDeleted); connect(effects, &EffectsHandler::windowFrameGeometryChanged, this, &PresentWindowsEffect::slotWindowFrameGeometryChanged); connect(effects, &EffectsHandler::propertyNotify, this, &PresentWindowsEffect::slotPropertyNotify); - connect(effects, &EffectsHandler::numberScreensChanged, this, - [this] { - if (isActive()) - reCreateGrids(); - } - ); + connect(effects, &EffectsHandler::screenAdded, this, &PresentWindowsEffect::maybeRecreateGrids); + connect(effects, &EffectsHandler::screenRemoved, this, &PresentWindowsEffect::maybeRecreateGrids); connect(effects, &EffectsHandler::screenAboutToLock, this, [this]() { setActive(false); }); @@ -2027,6 +2023,13 @@ bool PresentWindowsEffect::isActive() const return (m_activated || m_motionManager.managingWindows()) && !effects->isScreenLocked(); } +void PresentWindowsEffect::maybeRecreateGrids() +{ + if (isActive()) { + reCreateGrids(); + } +} + void PresentWindowsEffect::reCreateGrids() { m_gridSizes.clear(); diff --git a/src/effects/presentwindows/presentwindows.h b/src/effects/presentwindows/presentwindows.h index e4a14d0053..79c3d6b94d 100644 --- a/src/effects/presentwindows/presentwindows.h +++ b/src/effects/presentwindows/presentwindows.h @@ -214,6 +214,7 @@ protected: // Window rearranging void rearrangeWindows(); void reCreateGrids(); + void maybeRecreateGrids(); void calculateWindowTransformations(EffectWindowList windowlist, EffectScreen *screen, WindowMotionManager& motionManager, bool external = false); void calculateWindowTransformationsClosest(EffectWindowList windowlist, EffectScreen *screen, diff --git a/src/effects/slide/slide.cpp b/src/effects/slide/slide.cpp index 5777963079..c9cc15c916 100644 --- a/src/effects/slide/slide.cpp +++ b/src/effects/slide/slide.cpp @@ -33,7 +33,9 @@ SlideEffect::SlideEffect() this, &SlideEffect::windowDeleted); connect(effects, &EffectsHandler::numberDesktopsChanged, this, &SlideEffect::stop); - connect(effects, &EffectsHandler::numberScreensChanged, + connect(effects, &EffectsHandler::screenAdded, + this, &SlideEffect::stop); + connect(effects, &EffectsHandler::screenRemoved, this, &SlideEffect::stop); } diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index 5e7497f4dd..dd25a0849e 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -778,7 +778,6 @@ class KWINEFFECTS_EXPORT EffectsHandler : public QObject Q_PROPERTY(int desktops READ numberOfDesktops WRITE setNumberOfDesktops NOTIFY numberDesktopsChanged) Q_PROPERTY(bool optionRollOverDesktops READ optionRollOverDesktops) Q_PROPERTY(KWin::EffectScreen *activeScreen READ activeScreen) - Q_PROPERTY(int numScreens READ numScreens NOTIFY numberScreensChanged) /** * Factor by which animation speed in the effect should be modified (multiplied). * If configurable in the effect itself, the option should have also 'default' @@ -1025,7 +1024,6 @@ public: virtual bool optionRollOverDesktops() const = 0; virtual EffectScreen *activeScreen() const = 0; // Xinerama - virtual int numScreens() const = 0; // Xinerama virtual QRect clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const = 0; virtual QRect clientArea(clientAreaOption, const EffectWindow* c) const = 0; virtual QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const = 0; @@ -1408,11 +1406,6 @@ Q_SIGNALS: * @since 4.7 */ void numberDesktopsChanged(uint old); - /** - * Signal emitted when the number of screens changed. - * @since 5.0 - */ - void numberScreensChanged(); /** * Signal emitted when the desktop showing ("dashboard") state changed * The desktop is risen to the keepAbove layer, you may want to elevate