From a033a20062940f018f41fa15cf6c5d4131c99372 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 15 Dec 2021 21:25:43 +0200 Subject: [PATCH] more startup improvements --visibility: simplify and improve code for restoring and saving values --enable visibility mode early on the startup sequence --enable windows tracking after startup phase has ended --windows tracking respect also view geometry changes and not only window changes from the desktop environment --- app/view/visibilitymanager.cpp | 68 ++++++---------------- app/view/visibilitymanager.h | 1 - app/view/windowstracker/windowstracker.cpp | 13 +++-- app/wm/tracker/windowstracker.cpp | 14 +++++ app/wm/tracker/windowstracker.h | 2 + 5 files changed, 44 insertions(+), 54 deletions(-) diff --git a/app/view/visibilitymanager.cpp b/app/view/visibilitymanager.cpp index 75280eed6..cb42b824f 100644 --- a/app/view/visibilitymanager.cpp +++ b/app/view/visibilitymanager.cpp @@ -114,8 +114,6 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view) publishFrameExtents(forceUpdate); } - m_timerStartUp.setInterval(4000); - m_timerStartUp.setSingleShot(true); m_timerShow.setSingleShot(true); m_timerHide.setSingleShot(true); @@ -146,6 +144,14 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view) connect(&m_timerBlockStrutsUpdate, &QTimer::timeout, this, [&]() { updateStrutsBasedOnLayoutsAndActivities(); }); restoreConfig(); + + //! connect save values after they have been restored + connect(this, &VisibilityManager::enableKWinEdgesChanged, this, &VisibilityManager::saveConfig); + connect(this, &VisibilityManager::modeChanged, this, &VisibilityManager::saveConfig); + connect(this, &VisibilityManager::raiseOnDesktopChanged, this, &VisibilityManager::saveConfig); + connect(this, &VisibilityManager::raiseOnActivityChanged, this, &VisibilityManager::saveConfig); + connect(this, &VisibilityManager::timerShowChanged, this, &VisibilityManager::saveConfig); + connect(this, &VisibilityManager::timerHideChanged, this, &VisibilityManager::saveConfig); } VisibilityManager::~VisibilityManager() @@ -209,8 +215,11 @@ void VisibilityManager::setViewOnFrontLayer() void VisibilityManager::setMode(Latte::Types::Visibility mode) { - if (m_mode == mode) + if (m_mode == mode) { return; + } + + qDebug() << "Updating visibility mode to :::: " << mode; Q_ASSERT_X(mode != Types::None, staticMetaObject.className(), "set visibility to Types::None"); @@ -367,8 +376,6 @@ void VisibilityManager::setMode(Latte::Types::Visibility mode) break; } - m_latteView->containment()->config().writeEntry("visibility", static_cast(m_mode)); - emit modeChanged(); } @@ -977,8 +984,9 @@ void VisibilityManager::dodgeAllWindows() void VisibilityManager::saveConfig() { - if (!m_latteView->containment()) + if (!m_latteView->containment()) { return; + } auto config = m_latteView->containment()->config(); @@ -987,58 +995,20 @@ void VisibilityManager::saveConfig() config.writeEntry("timerHide", m_timerHideInterval); config.writeEntry("raiseOnDesktopChange", m_raiseOnDesktopChange); config.writeEntry("raiseOnActivityChange", m_raiseOnActivityChange); + config.writeEntry("visibility", static_cast(m_mode)); - m_latteView->containment()->configNeedsSaving(); } void VisibilityManager::restoreConfig() { - if (!m_latteView || !m_latteView->containment()){ - return; - } - auto config = m_latteView->containment()->config(); - m_timerShow.setInterval(config.readEntry("timerShow", 0)); - m_timerHideInterval = qMax(HIDEMINIMUMINTERVAL, config.readEntry("timerHide", 700)); - emit timerShowChanged(); - emit timerHideChanged(); - - m_enableKWinEdgesFromUser = config.readEntry("enableKWinEdges", true); - emit enableKWinEdgesChanged(); - + setTimerHide(qMax(HIDEMINIMUMINTERVAL, config.readEntry("timerHide", 700))); + setTimerShow(config.readEntry("timerShow", 0)); + setEnableKWinEdges(config.readEntry("enableKWinEdges", true)); setRaiseOnDesktop(config.readEntry("raiseOnDesktopChange", false)); setRaiseOnActivity(config.readEntry("raiseOnActivityChange", false)); - auto storedMode = (Types::Visibility)(m_latteView->containment()->config().readEntry("visibility", (int)(Types::DodgeActive))); - - if (storedMode == Types::AlwaysVisible) { - qDebug() << "Loading visibility mode: Always Visible , on startup..."; - setMode(Types::AlwaysVisible); - } else { - connect(&m_timerStartUp, &QTimer::timeout, this, [&]() { - if (!m_latteView || !m_latteView->containment()) { - return; - } - - Types::Visibility fMode = (Types::Visibility)(m_latteView->containment()->config().readEntry("visibility", (int)(Types::DodgeActive))); - qDebug() << "Loading visibility mode:" << fMode << " on startup..."; - setMode(fMode); - }); - connect(m_latteView->containment(), &Plasma::Containment::userConfiguringChanged - , this, [&](bool configuring) { - if (configuring && m_timerStartUp.isActive()) - m_timerStartUp.start(100); - }); - - m_timerStartUp.start(); - } - - connect(m_latteView->containment(), &Plasma::Containment::userConfiguringChanged - , this, [&](bool configuring) { - if (!configuring) { - saveConfig(); - } - }); + setMode((Types::Visibility)(config.readEntry("visibility", (int)(Types::DodgeActive)))); } bool VisibilityManager::containsMouse() const diff --git a/app/view/visibilitymanager.h b/app/view/visibilitymanager.h index 8c640af7c..3466a07fd 100644 --- a/app/view/visibilitymanager.h +++ b/app/view/visibilitymanager.h @@ -220,7 +220,6 @@ private: QTimer m_timerShow; QTimer m_timerHide; - QTimer m_timerStartUp; QTimer m_timerPublishFrameExtents; //! This timer is very important because it blocks how fast struts are updated. //! By using this timer we help the window manager in order to correspond to new diff --git a/app/view/windowstracker/windowstracker.cpp b/app/view/windowstracker/windowstracker.cpp index ad68d860a..fbdaae070 100644 --- a/app/view/windowstracker/windowstracker.cpp +++ b/app/view/windowstracker/windowstracker.cpp @@ -8,6 +8,7 @@ // local #include "currentscreentracker.h" #include "allscreenstracker.h" +#include "../positioner.h" #include "../view.h" #include "../../lattecorona.h" #include "../../wm/tracker/windowstracker.h" @@ -34,10 +35,14 @@ WindowsTracker::WindowsTracker(Latte::View *parent) } }); - m_wm->windowsTracker()->addView(m_latteView); - - emit allScreensChanged(); - emit currentScreenChanged(); + connect(m_latteView->positioner(), &Positioner::startupFinished, this, [&]() { + //! During startup phase windows tracking is not enabled and does not + //! influence startup sequence at all. At the same time to windows tracking + //! takes place during startup and as such startup time is reduced + m_wm->windowsTracker()->addView(m_latteView); + emit allScreensChanged(); + emit currentScreenChanged(); + }); } WindowsTracker::~WindowsTracker() diff --git a/app/wm/tracker/windowstracker.cpp b/app/wm/tracker/windowstracker.cpp index be06a1b8b..b4c04e275 100644 --- a/app/wm/tracker/windowstracker.cpp +++ b/app/wm/tracker/windowstracker.cpp @@ -41,6 +41,11 @@ Windows::Windows(AbstractWindowInterface *parent) m_updateApplicationDataTimer.setSingleShot(true); connect(&m_updateApplicationDataTimer, &QTimer::timeout, this, &Windows::updateApplicationData); + //! delayed update all hints + m_updateAllHintsTimer.setInterval(300); + m_updateAllHintsTimer.setSingleShot(true); + connect(&m_updateAllHintsTimer, &QTimer::timeout, this, &Windows::updateAllHints); + init(); } @@ -169,6 +174,7 @@ void Windows::addView(Latte::View *view) connect(view, &Latte::View::isTouchingBottomViewAndIsBusyChanged, this, &Windows::updateExtraViewHints); connect(view, &Latte::View::isTouchingTopViewAndIsBusyChanged, this, &Windows::updateExtraViewHints); + connect(view, &Latte::View::absoluteGeometryChanged, this, &Windows::updateAllHintsAfterTimer); updateAllHints(); @@ -821,6 +827,14 @@ void Windows::updateScreenGeometries() } } +void Windows::updateAllHintsAfterTimer() +{ + if (!m_updateAllHintsTimer.isActive()) { + updateAllHints(); + m_updateAllHintsTimer.start(); + } +} + void Windows::updateAllHints() { for (const auto view : m_views.keys()) { diff --git a/app/wm/tracker/windowstracker.h b/app/wm/tracker/windowstracker.h index d1c14295b..f3cf10cf1 100644 --- a/app/wm/tracker/windowstracker.h +++ b/app/wm/tracker/windowstracker.h @@ -127,6 +127,7 @@ private: void cleanupFaultyWindows(); void updateAllHints(); + void updateAllHintsAfterTimer(); //! Views void updateHints(Latte::View *view); @@ -182,6 +183,7 @@ private: QMap m_windows; + QTimer m_updateAllHintsTimer; //! Some applications delay their application name/icon identification //! such as Libreoffice that updates its StartupWMClass after //! its startup