From eca9b5047ab4833cb33de81b1e75a128f5d758e1 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 6 May 2022 15:48:41 +0000 Subject: [PATCH] effects/windowview+overview: get back option to hide minimized windows Option to hide minimized windows as old present windows effect had. BUG: 441627 BUG: 453426 FIXED-IN: 5.25 --- src/effects/overview/kcm/overvieweffectkcm.ui | 21 ++++++++++++++----- src/effects/overview/overviewconfig.kcfg | 3 +++ src/effects/overview/overvieweffect.cpp | 5 +++++ src/effects/overview/overvieweffect.h | 4 ++++ src/effects/overview/qml/ScreenView.qml | 1 + .../windowview/kcm/windowvieweffectkcm.ui | 9 ++++---- src/effects/windowview/qml/main.qml | 1 + src/effects/windowview/windowviewconfig.kcfg | 3 +++ src/effects/windowview/windowvieweffect.cpp | 5 +++++ src/effects/windowview/windowvieweffect.h | 4 ++++ src/scripting/v3/clientmodel.cpp | 20 ++++++++++++++++++ src/scripting/v3/clientmodel.h | 6 ++++++ 12 files changed, 73 insertions(+), 9 deletions(-) diff --git a/src/effects/overview/kcm/overvieweffectkcm.ui b/src/effects/overview/kcm/overvieweffectkcm.ui index 6c48b251b9..361e518e7a 100644 --- a/src/effects/overview/kcm/overvieweffectkcm.ui +++ b/src/effects/overview/kcm/overvieweffectkcm.ui @@ -12,7 +12,7 @@ 0 0 455 - 177 + 201 @@ -37,7 +37,7 @@ - + @@ -45,9 +45,6 @@ 0 - - KShortcutsEditor::GlobalAction - @@ -60,6 +57,20 @@ + + + + + + + + + + + Ignore minimized windows: + + + diff --git a/src/effects/overview/overviewconfig.kcfg b/src/effects/overview/overviewconfig.kcfg index 4614cefcfb..d2b9d83307 100644 --- a/src/effects/overview/overviewconfig.kcfg +++ b/src/effects/overview/overviewconfig.kcfg @@ -13,6 +13,9 @@ 1 + + false + true diff --git a/src/effects/overview/overvieweffect.cpp b/src/effects/overview/overvieweffect.cpp index 71eab3223b..5647c17009 100644 --- a/src/effects/overview/overvieweffect.cpp +++ b/src/effects/overview/overvieweffect.cpp @@ -153,6 +153,11 @@ int OverviewEffect::layout() const return m_layout; } +bool OverviewEffect::ignoreMinimized() const +{ + return OverviewConfig::ignoreMinimized(); +} + void OverviewEffect::setLayout(int layout) { if (m_layout != layout) { diff --git a/src/effects/overview/overvieweffect.h b/src/effects/overview/overvieweffect.h index 38711b59a3..79bd09275f 100644 --- a/src/effects/overview/overvieweffect.h +++ b/src/effects/overview/overvieweffect.h @@ -16,6 +16,7 @@ class OverviewEffect : public QuickSceneEffect Q_OBJECT Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged) Q_PROPERTY(int layout READ layout NOTIFY layoutChanged) + Q_PROPERTY(bool ignoreMinimized READ ignoreMinimized NOTIFY ignoreMinimizedChanged) Q_PROPERTY(bool blurBackground READ blurBackground NOTIFY blurBackgroundChanged) Q_PROPERTY(qreal partialActivationFactor READ partialActivationFactor NOTIFY partialActivationFactorChanged) // More efficient from a property binding pov rather than binding to partialActivationFactor !== 0 @@ -33,6 +34,8 @@ public: int layout() const; void setLayout(int layout); + bool ignoreMinimized() const; + int animationDuration() const; void setAnimationDuration(int duration); @@ -53,6 +56,7 @@ Q_SIGNALS: void blurBackgroundChanged(); void partialActivationFactorChanged(); void gestureInProgressChanged(); + void ignoreMinimizedChanged(); public Q_SLOTS: void activate(); diff --git a/src/effects/overview/qml/ScreenView.qml b/src/effects/overview/qml/ScreenView.qml index 30e9a6b9ac..96ea7bcca7 100644 --- a/src/effects/overview/qml/ScreenView.qml +++ b/src/effects/overview/qml/ScreenView.qml @@ -201,6 +201,7 @@ FocusScope { desktop: KWinComponents.Workspace.currentVirtualDesktop screenName: targetScreen.name clientModel: stackModel + minimizedWindows: !effect.ignoreMinimized windowType: ~KWinComponents.ClientFilterModel.Dock & ~KWinComponents.ClientFilterModel.Desktop & ~KWinComponents.ClientFilterModel.Notification; diff --git a/src/effects/windowview/kcm/windowvieweffectkcm.ui b/src/effects/windowview/kcm/windowvieweffectkcm.ui index b55000f219..65bb17265e 100644 --- a/src/effects/windowview/kcm/windowvieweffectkcm.ui +++ b/src/effects/windowview/kcm/windowvieweffectkcm.ui @@ -45,13 +45,14 @@ 0 - - KShortcutsEditor::GlobalAction - - + + + Ignore &minimized windows + + diff --git a/src/effects/windowview/qml/main.qml b/src/effects/windowview/qml/main.qml index 3b7470c99c..48f4548ad3 100644 --- a/src/effects/windowview/qml/main.qml +++ b/src/effects/windowview/qml/main.qml @@ -115,6 +115,7 @@ Item { screenName: targetScreen.name clientModel: stackModel filter: searchField.text + minimizedWindows: !effect.ignoreMinimized windowType: ~KWinComponents.ClientFilterModel.Dock & ~KWinComponents.ClientFilterModel.Desktop & ~KWinComponents.ClientFilterModel.Notification; diff --git a/src/effects/windowview/windowviewconfig.kcfg b/src/effects/windowview/windowviewconfig.kcfg index 9ed56e4e99..d37697677d 100644 --- a/src/effects/windowview/windowviewconfig.kcfg +++ b/src/effects/windowview/windowviewconfig.kcfg @@ -13,6 +13,9 @@ 1 + + false + diff --git a/src/effects/windowview/windowvieweffect.cpp b/src/effects/windowview/windowvieweffect.cpp index a876869842..5437e00e65 100644 --- a/src/effects/windowview/windowvieweffect.cpp +++ b/src/effects/windowview/windowvieweffect.cpp @@ -167,6 +167,11 @@ void WindowViewEffect::setLayout(int layout) } } +bool WindowViewEffect::ignoreMinimized() const +{ + return WindowViewConfig::ignoreMinimized(); +} + int WindowViewEffect::requestedEffectChainPosition() const { return 70; diff --git a/src/effects/windowview/windowvieweffect.h b/src/effects/windowview/windowvieweffect.h index ff3b2b1126..f2a96f7863 100644 --- a/src/effects/windowview/windowvieweffect.h +++ b/src/effects/windowview/windowvieweffect.h @@ -20,6 +20,7 @@ class WindowViewEffect : public QuickSceneEffect Q_OBJECT Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged) Q_PROPERTY(int layout READ layout NOTIFY layoutChanged) + Q_PROPERTY(bool ignoreMinimized READ ignoreMinimized NOTIFY ignoreMinimizedChanged) Q_PROPERTY(PresentWindowsMode mode READ mode NOTIFY modeChanged) Q_PROPERTY(qreal partialActivationFactor READ partialActivationFactor NOTIFY partialActivationFactorChanged) Q_PROPERTY(bool gestureInProgress READ gestureInProgress NOTIFY gestureInProgressChanged) @@ -48,6 +49,8 @@ public: int layout() const; void setLayout(int layout); + bool ignoreMinimized() const; + void reconfigure(ReconfigureFlags) override; int requestedEffectChainPosition() const override; @@ -72,6 +75,7 @@ Q_SIGNALS: void gestureInProgressChanged(); void modeChanged(); void layoutChanged(); + void ignoreMinimizedChanged(); protected: QVariantMap initialProperties(EffectScreen *screen) override; diff --git a/src/scripting/v3/clientmodel.cpp b/src/scripting/v3/clientmodel.cpp index 345c913df0..01241ff519 100644 --- a/src/scripting/v3/clientmodel.cpp +++ b/src/scripting/v3/clientmodel.cpp @@ -226,6 +226,22 @@ void ClientFilterModel::resetWindowType() } } +void ClientFilterModel::setMinimizedWindows(bool show) +{ + if (m_showMinimizedWindows == show) { + return; + } + + m_showMinimizedWindows = show; + invalidateFilter(); + Q_EMIT minimizedWindowsChanged(); +} + +bool ClientFilterModel::minimizedWindows() const +{ + return m_showMinimizedWindows; +} + bool ClientFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { if (!m_clientModel) { @@ -288,6 +304,10 @@ bool ClientFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourc } return false; } + + if (!m_showMinimizedWindows) { + return !client->isMinimized(); + } return true; } diff --git a/src/scripting/v3/clientmodel.h b/src/scripting/v3/clientmodel.h index 35fcb82672..48fc104c9e 100644 --- a/src/scripting/v3/clientmodel.h +++ b/src/scripting/v3/clientmodel.h @@ -59,6 +59,7 @@ class ClientFilterModel : public QSortFilterProxyModel Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) Q_PROPERTY(QString screenName READ screenName WRITE setScreenName RESET resetScreenName NOTIFY screenNameChanged) Q_PROPERTY(WindowTypes windowType READ windowType WRITE setWindowType RESET resetWindowType NOTIFY windowTypeChanged) + Q_PROPERTY(bool minimizedWindows READ minimizedWindows WRITE setMinimizedWindows NOTIFY minimizedWindowsChanged) public: enum WindowType { @@ -96,6 +97,9 @@ public: void setWindowType(WindowTypes windowType); void resetWindowType(); + void setMinimizedWindows(bool show); + bool minimizedWindows() const; + protected: bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; @@ -106,6 +110,7 @@ Q_SIGNALS: void clientModelChanged(); void filterChanged(); void windowTypeChanged(); + void minimizedWindowsChanged(); private: WindowTypes windowTypeMask(Window *client) const; @@ -116,6 +121,7 @@ private: QPointer m_desktop; QString m_filter; std::optional m_windowType; + bool m_showMinimizedWindows = true; }; } // namespace ScriptingModels::V3