File indexing completed on 2024-11-10 04:57:12

0001 /*
0002     SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "effect/quickeffect.h"
0010 
0011 #include <QKeySequence>
0012 
0013 class QAction;
0014 
0015 namespace KWin
0016 {
0017 
0018 class WindowViewEffect : public QuickSceneEffect
0019 {
0020     Q_OBJECT
0021     Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged)
0022     Q_PROPERTY(int layout READ layout NOTIFY layoutChanged)
0023     Q_PROPERTY(bool ignoreMinimized READ ignoreMinimized NOTIFY ignoreMinimizedChanged)
0024     Q_PROPERTY(PresentWindowsMode mode READ mode NOTIFY modeChanged)
0025     Q_PROPERTY(qreal partialActivationFactor READ partialActivationFactor NOTIFY partialActivationFactorChanged)
0026     Q_PROPERTY(bool gestureInProgress READ gestureInProgress NOTIFY gestureInProgressChanged)
0027     Q_PROPERTY(QString searchText MEMBER m_searchText NOTIFY searchTextChanged)
0028     Q_PROPERTY(QList<QUuid> selectedIds MEMBER m_windowIds NOTIFY selectedIdsChanged)
0029 
0030 public:
0031     enum PresentWindowsMode {
0032         ModeAllDesktops, // Shows windows of all desktops
0033         ModeCurrentDesktop, // Shows windows on current desktop
0034         ModeWindowGroup, // Shows windows selected via property
0035         ModeWindowClass, // Shows all windows of same class as selected class
0036         ModeWindowClassCurrentDesktop, // Shows windows of same class on current desktop
0037     };
0038     Q_ENUM(PresentWindowsMode)
0039 
0040     enum class Status {
0041         Inactive,
0042         Activating,
0043         Deactivating,
0044         Active
0045     };
0046 
0047     WindowViewEffect();
0048     ~WindowViewEffect() override;
0049 
0050     int animationDuration() const;
0051     void setAnimationDuration(int duration);
0052 
0053     int layout() const;
0054     void setLayout(int layout);
0055 
0056     bool ignoreMinimized() const;
0057 
0058     void reconfigure(ReconfigureFlags) override;
0059     int requestedEffectChainPosition() const override;
0060     void grabbedKeyboardEvent(QKeyEvent *e) override;
0061     bool borderActivated(ElectricBorder border) override;
0062 
0063     qreal partialActivationFactor() const;
0064     void setPartialActivationFactor(qreal factor);
0065 
0066     bool gestureInProgress() const;
0067     void setGestureInProgress(bool gesture);
0068 
0069     void setMode(PresentWindowsMode mode);
0070     void toggleMode(PresentWindowsMode mode);
0071     PresentWindowsMode mode() const;
0072 
0073 public Q_SLOTS:
0074     void activate(const QStringList &windowIds);
0075     void activate();
0076     void deactivate(int timeout);
0077 
0078     void partialActivate(qreal factor);
0079     void cancelPartialActivate();
0080     void partialDeactivate(qreal factor);
0081     void cancelPartialDeactivate();
0082 
0083 Q_SIGNALS:
0084     void animationDurationChanged();
0085     void partialActivationFactorChanged();
0086     void gestureInProgressChanged();
0087     void modeChanged();
0088     void layoutChanged();
0089     void ignoreMinimizedChanged();
0090     void searchTextChanged();
0091     void selectedIdsChanged();
0092 
0093 private:
0094     void realDeactivate();
0095     void setSelectedIds(const QList<QUuid> &ids);
0096 
0097     QTimer *m_shutdownTimer;
0098     QList<QUuid> m_windowIds;
0099 
0100     // User configuration settings
0101     QAction *m_exposeAction = nullptr;
0102     QAction *m_exposeAllAction = nullptr;
0103     QAction *m_exposeClassAction = nullptr;
0104     QAction *m_exposeClassCurrentDesktopAction = nullptr;
0105     QAction *m_realtimeToggleAction = nullptr;
0106     // Shortcut - needed to toggle the effect
0107     QList<QKeySequence> m_shortcut;
0108     QList<QKeySequence> m_shortcutAll;
0109     QList<QKeySequence> m_shortcutClass;
0110     QList<QKeySequence> m_shortcutClassCurrentDesktop;
0111     QList<ElectricBorder> m_borderActivate;
0112     QList<ElectricBorder> m_borderActivateAll;
0113     QList<ElectricBorder> m_borderActivateClass;
0114     QList<ElectricBorder> m_borderActivateClassCurrentDesktop;
0115     QList<ElectricBorder> m_touchBorderActivate;
0116     QList<ElectricBorder> m_touchBorderActivateAll;
0117     QList<ElectricBorder> m_touchBorderActivateClass;
0118     QList<ElectricBorder> m_touchBorderActivateClassCurrentDesktop;
0119     QString m_searchText;
0120     Status m_status = Status::Inactive;
0121     qreal m_partialActivationFactor = 0;
0122     PresentWindowsMode m_mode;
0123     int m_animationDuration = 400;
0124     int m_layout = 1;
0125     bool m_gestureInProgress = false;
0126 };
0127 
0128 } // namespace KWin