File indexing completed on 2025-04-20 13:26:14
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 WAYLANDINTERFACE_H 0022 #define WAYLANDINTERFACE_H 0023 0024 // local 0025 #include <config-latte.h> 0026 #include "abstractwindowinterface.h" 0027 #include "windowinfowrap.h" 0028 0029 // Qt 0030 #include <QMap> 0031 #include <QObject> 0032 0033 // KDE 0034 #include <KWayland/Client/registry.h> 0035 #include <KWayland/Client/connection_thread.h> 0036 #include <KWayland/Client/plasmawindowmanagement.h> 0037 #include <KWayland/Client/plasmashell.h> 0038 #include <KWayland/Client/surface.h> 0039 #include <KWindowInfo> 0040 #include <KWindowEffects> 0041 0042 0043 namespace Latte { 0044 class Corona; 0045 namespace Private { 0046 //! this class is used to create the struts inside wayland 0047 class GhostWindow; 0048 } 0049 } 0050 0051 namespace Latte { 0052 namespace WindowSystem { 0053 0054 class WaylandInterface : public AbstractWindowInterface 0055 { 0056 Q_OBJECT 0057 0058 public: 0059 explicit WaylandInterface(QObject *parent = nullptr); 0060 ~WaylandInterface() override; 0061 0062 void setViewExtraFlags(QWindow &view) override; 0063 void setViewStruts(QWindow &view, const QRect &rect 0064 , Plasma::Types::Location location) override; 0065 void setWindowOnActivities(QWindow &view, const QStringList &activities) override; 0066 0067 void removeViewStruts(QWindow &view) const override; 0068 0069 WindowId activeWindow() const override; 0070 WindowInfoWrap requestInfo(WindowId wid) const override; 0071 WindowInfoWrap requestInfoActive() const override; 0072 0073 void setKeepAbove(const QDialog &dialog, bool above = true) const override; 0074 void skipTaskBar(const QDialog &dialog) const override; 0075 void slideWindow(QWindow &view, Slide location) const override; 0076 void enableBlurBehind(QWindow &view) const override; 0077 0078 void requestActivate(WindowId wid) const override; 0079 void requestClose(WindowId wid) const override; 0080 void requestMoveWindow(WindowId wid, QPoint from) const override; 0081 void requestToggleIsOnAllDesktops(WindowId wid) const override; 0082 void requestToggleKeepAbove(WindowId wid) const override; 0083 void requestToggleMinimized(WindowId wid) const override; 0084 void requestToggleMaximized(WindowId wid) const override; 0085 0086 bool windowCanBeDragged(WindowId wid) const override; 0087 bool windowCanBeMaximized(WindowId wid) const override; 0088 0089 QIcon iconFor(WindowId wid) const; 0090 WindowId winIdFor(QString appId, QRect geometry) const override; 0091 AppData appDataFor(WindowId wid) const override; 0092 0093 void setActiveEdge(QWindow *view, bool active) const override; 0094 0095 void switchToNextVirtualDesktop() const override; 0096 void switchToPreviousVirtualDesktop() const override; 0097 0098 void registerIgnoredWindow(WindowId wid) override; 0099 void unregisterIgnoredWindow(WindowId wid) override; 0100 0101 void initWindowManagement(KWayland::Client::PlasmaWindowManagement *windowManagement); 0102 0103 #if KF5_VERSION_MINOR >= 52 0104 //! VirtualDesktopsSupport 0105 void initVirtualDesktopManagement(KWayland::Client::PlasmaVirtualDesktopManagement *virtualDesktopManagement); 0106 #endif 0107 0108 private slots: 0109 void updateWindow(); 0110 void windowUnmapped(); 0111 0112 private: 0113 void init(); 0114 bool isValidWindow(const KWayland::Client::PlasmaWindow *w) const; 0115 bool isPlasmaDesktop(const KWayland::Client::PlasmaWindow *w) const; 0116 bool isPlasmaPanel(const KWayland::Client::PlasmaWindow *w) const; 0117 void windowCreatedProxy(KWayland::Client::PlasmaWindow *w); 0118 void trackWindow(KWayland::Client::PlasmaWindow *w); 0119 void untrackWindow(KWayland::Client::PlasmaWindow *w); 0120 0121 KWayland::Client::PlasmaWindow *windowFor(WindowId wid) const; 0122 KWayland::Client::PlasmaShell *waylandCoronaInterface() const; 0123 0124 #if KF5_VERSION_MINOR >= 52 0125 //! VirtualDesktopsSupport 0126 void setCurrentDesktop(QString desktop); 0127 void addDesktop(const QString &id, quint32 position); 0128 #endif 0129 0130 private: 0131 friend class Private::GhostWindow; 0132 mutable QMap<WindowId, Private::GhostWindow *> m_ghostWindows; 0133 0134 KWayland::Client::PlasmaWindowManagement *m_windowManagement{nullptr}; 0135 0136 #if KF5_VERSION_MINOR >= 52 0137 //! VirtualDesktopsSupport 0138 KWayland::Client::PlasmaVirtualDesktopManagement *m_virtualDesktopManagement{nullptr}; 0139 QStringList m_desktops; 0140 #endif 0141 0142 Latte::Corona *m_corona{nullptr}; 0143 }; 0144 0145 } 0146 } 0147 0148 #endif // WAYLANDINTERFACE_H 0149 0150