File indexing completed on 2025-01-12 13:32:45
0001 /* 0002 * Copyright 2016 Smith AR <audoban@openmailbox.org> 0003 * Michail Vourlakos <mvourlakos@gmail.com> 0004 * 0005 * This file is part of Latte-Dock 0006 * 0007 * Latte-Dock is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU General Public License as 0009 * published by the Free Software Foundation; either version 2 of 0010 * the License, or (at your option) any later version. 0011 * 0012 * Latte-Dock is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 * GNU General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU General Public License 0018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0019 */ 0020 0021 #ifndef ABSTRACTWINDOWINTERFACE_H 0022 #define ABSTRACTWINDOWINTERFACE_H 0023 0024 // local 0025 #include "schemecolors.h" 0026 #include "tasktools.h" 0027 #include "windowinfowrap.h" 0028 #include "tracker/windowstracker.h" 0029 #include "../liblatte2/types.h" 0030 #include "../liblatte2/extras.h" 0031 0032 // C++ 0033 #include <unordered_map> 0034 #include <list> 0035 0036 // Qt 0037 #include <QObject> 0038 #include <QWindow> 0039 #include <QDialog> 0040 #include <QMap> 0041 #include <QRect> 0042 #include <QPoint> 0043 #include <QPointer> 0044 #include <QScreen> 0045 #include <QTimer> 0046 0047 // KDE 0048 #include <KSharedConfig> 0049 #include <KActivities/Consumer> 0050 0051 // Plasma 0052 #include <Plasma> 0053 0054 namespace Latte { 0055 class Corona; 0056 namespace WindowSystem { 0057 namespace Tracker { 0058 class Schemes; 0059 class Windows; 0060 } 0061 } 0062 } 0063 0064 namespace Latte { 0065 namespace WindowSystem { 0066 0067 class AbstractWindowInterface : public QObject 0068 { 0069 Q_OBJECT 0070 0071 public: 0072 enum class Slide 0073 { 0074 None, 0075 Top, 0076 Left, 0077 Bottom, 0078 Right, 0079 }; 0080 0081 explicit AbstractWindowInterface(QObject *parent = nullptr); 0082 virtual ~AbstractWindowInterface(); 0083 0084 virtual void setViewExtraFlags(QWindow &view) = 0; 0085 virtual void setViewStruts(QWindow &view, const QRect &rect 0086 , Plasma::Types::Location location) = 0; 0087 virtual void setWindowOnActivities(QWindow &window, const QStringList &activities) = 0; 0088 0089 virtual void removeViewStruts(QWindow &view) const = 0; 0090 0091 virtual WindowId activeWindow() const = 0; 0092 virtual WindowInfoWrap requestInfo(WindowId wid) const = 0; 0093 virtual WindowInfoWrap requestInfoActive() const = 0; 0094 0095 virtual void setKeepAbove(const QDialog &dialog, bool above = true) const = 0; 0096 virtual void skipTaskBar(const QDialog &dialog) const = 0; 0097 virtual void slideWindow(QWindow &view, Slide location) const = 0; 0098 virtual void enableBlurBehind(QWindow &view) const = 0; 0099 virtual void setActiveEdge(QWindow *view, bool active) const = 0; 0100 0101 virtual void requestActivate(WindowId wid) const = 0; 0102 virtual void requestClose(WindowId wid) const = 0; 0103 virtual void requestMoveWindow(WindowId wid, QPoint from) const = 0; 0104 virtual void requestToggleIsOnAllDesktops(WindowId wid) const = 0; 0105 virtual void requestToggleKeepAbove(WindowId wid) const = 0; 0106 virtual void requestToggleMinimized(WindowId wid) const = 0; 0107 virtual void requestToggleMaximized(WindowId wid) const = 0; 0108 0109 virtual bool windowCanBeDragged(WindowId wid) const = 0; 0110 virtual bool windowCanBeMaximized(WindowId wid) const = 0; 0111 0112 virtual QIcon iconFor(WindowId wid) const = 0; 0113 virtual WindowId winIdFor(QString appId, QRect geometry) const = 0; 0114 virtual AppData appDataFor(WindowId wid) const = 0; 0115 0116 bool inCurrentDesktopActivity(const WindowInfoWrap &winfo) const; 0117 0118 bool isIgnored(const WindowId &wid); 0119 bool isRegisteredPlasmaPanel(const WindowId &wid); 0120 0121 QString currentDesktop() const; 0122 QString currentActivity() const; 0123 0124 virtual void registerIgnoredWindow(WindowId wid); 0125 virtual void unregisterIgnoredWindow(WindowId wid); 0126 0127 void registerPlasmaPanel(WindowId wid); 0128 void unregisterPlasmaPanel(WindowId wid); 0129 0130 void switchToNextActivity(); 0131 void switchToPreviousActivity(); 0132 0133 virtual void switchToNextVirtualDesktop() const = 0; 0134 virtual void switchToPreviousVirtualDesktop() const = 0; 0135 0136 Latte::Corona *corona(); 0137 Tracker::Schemes *schemesTracker(); 0138 Tracker::Windows *windowsTracker() const; 0139 0140 signals: 0141 void activeWindowChanged(WindowId wid); 0142 void windowChanged(WindowId winfo); 0143 void windowAdded(WindowId wid); 0144 void windowRemoved(WindowId wid); 0145 void currentDesktopChanged(); 0146 void currentActivityChanged(); 0147 0148 void latteWindowAdded(); 0149 0150 protected: 0151 QString m_currentDesktop; 0152 QString m_currentActivity; 0153 0154 //! windows that must be ignored from tracking, a good example are Latte::Views and 0155 //! their Configuration windows 0156 QList<WindowId> m_ignoredWindows; 0157 //! identified plasma panels 0158 QList<WindowId> m_plasmaPanels; 0159 0160 QPointer<KActivities::Consumer> m_activities; 0161 0162 //! Sending too fast plenty of signals for the same window 0163 //! has no reason and can create HIGH CPU usage. This Timer 0164 //! can delay the batch sending of signals for the same window 0165 WindowId m_windowChangedWaiting; 0166 QTimer m_windowWaitingTimer; 0167 0168 //! Plasma taskmanager rules ile 0169 KSharedConfig::Ptr rulesConfig; 0170 0171 void considerWindowChanged(WindowId wid); 0172 0173 bool isPlasmaDesktop(const QRect &wGeometry) const; 0174 bool isPlasmaPanel(const QRect &wGeometry) const; 0175 0176 private slots: 0177 void windowRemovedSlot(WindowId wid); 0178 0179 private: 0180 Latte::Corona *m_corona; 0181 Tracker::Schemes *m_schemesTracker; 0182 Tracker::Windows *m_windowsTracker; 0183 }; 0184 0185 } 0186 } 0187 0188 #endif // ABSTRACTWINDOWINTERFACE_H