File indexing completed on 2022-11-29 15:04:29

0001 /*
0002     SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
0003     SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef WAYLANDINTERFACE_H
0008 #define WAYLANDINTERFACE_H
0009 
0010 // local
0011 #include <config-latte.h>
0012 #include "abstractwindowinterface.h"
0013 #include "windowinfowrap.h"
0014 
0015 // Qt
0016 #include <QMap>
0017 #include <QObject>
0018 
0019 // KDE
0020 #include <KWayland/Client/registry.h>
0021 #include <KWayland/Client/connection_thread.h>
0022 #include <KWayland/Client/plasmawindowmanagement.h>
0023 #include <KWayland/Client/plasmashell.h>
0024 #include <KWayland/Client/surface.h>
0025 #include <KWindowInfo>
0026 #include <KWindowEffects>
0027 
0028 
0029 namespace Latte {
0030 class Corona;
0031 namespace Private {
0032 //! this class is used to create the struts inside wayland
0033 class GhostWindow;
0034 }
0035 }
0036 
0037 namespace Latte {
0038 namespace WindowSystem {
0039 
0040 class WaylandInterface : public AbstractWindowInterface
0041 {
0042     Q_OBJECT
0043 
0044 public:
0045     explicit WaylandInterface(QObject *parent = nullptr);
0046     ~WaylandInterface() override;
0047 
0048     void setViewExtraFlags(QObject *view, bool isPanelWindow = true, Latte::Types::Visibility mode = Latte::Types::WindowsGoBelow) override;
0049     void setViewStruts(QWindow &view, const QRect &rect
0050                        , Plasma::Types::Location location) override;
0051     void setWindowOnActivities(const WindowId &wid, const QStringList &nextactivities) override;
0052 
0053     void removeViewStruts(QWindow &view) override;
0054 
0055     WindowId activeWindow() override;
0056     WindowInfoWrap requestInfo(WindowId wid) override;
0057     WindowInfoWrap requestInfoActive() override;
0058 
0059     void skipTaskBar(const QDialog &dialog) override;
0060     void slideWindow(QWindow &view, Slide location) override;
0061     void enableBlurBehind(QWindow &view) override;
0062 
0063     void requestActivate(WindowId wid) override;
0064     void requestClose(WindowId wid) override;
0065     void requestMoveWindow(WindowId wid, QPoint from) override;
0066     void requestToggleIsOnAllDesktops(WindowId wid) override;
0067     void requestToggleKeepAbove(WindowId wid) override;
0068     void requestToggleMinimized(WindowId wid) override;
0069     void requestToggleMaximized(WindowId wid) override;
0070     void setKeepAbove(WindowId wid, bool active) override;
0071     void setKeepBelow(WindowId wid, bool active) override;
0072 
0073     bool windowCanBeDragged(WindowId wid) override;
0074     bool windowCanBeMaximized(WindowId wid) override;
0075 
0076     QIcon iconFor(WindowId wid) override;
0077     WindowId winIdFor(QString appId, QRect geometry) override;
0078     WindowId winIdFor(QString appId, QString title) override;
0079 
0080     AppData appDataFor(WindowId wid) override;
0081 
0082     void setActiveEdge(QWindow *view, bool active)  override;
0083 
0084     void switchToNextVirtualDesktop() override;
0085     void switchToPreviousVirtualDesktop() override;
0086 
0087     void setFrameExtents(QWindow *view, const QMargins &margins) override;
0088     void setInputMask(QWindow *window, const QRect &rect) override;
0089 
0090     void registerIgnoredWindow(WindowId wid) override;
0091     void unregisterIgnoredWindow(WindowId wid) override;
0092 
0093     void initWindowManagement(KWayland::Client::PlasmaWindowManagement *windowManagement);
0094 
0095     //! VirtualDesktopsSupport
0096     void initVirtualDesktopManagement(KWayland::Client::PlasmaVirtualDesktopManagement *virtualDesktopManagement);
0097 
0098 
0099 private slots:
0100     void updateWindow();
0101     void windowUnmapped();
0102 
0103 private:
0104     void init();
0105     bool isAcceptableWindow(const KWayland::Client::PlasmaWindow *w);
0106     bool isValidWindow(const KWayland::Client::PlasmaWindow *w);
0107     bool isFullScreenWindow(const KWayland::Client::PlasmaWindow *w) const;
0108     bool isPlasmaPanel(const KWayland::Client::PlasmaWindow *w) const;
0109     bool isSidepanel(const KWayland::Client::PlasmaWindow *w) const;
0110     void windowCreatedProxy(KWayland::Client::PlasmaWindow *w);
0111     void trackWindow(KWayland::Client::PlasmaWindow *w);
0112     void untrackWindow(KWayland::Client::PlasmaWindow *w);
0113 
0114     KWayland::Client::PlasmaWindow *windowFor(WindowId wid);
0115     KWayland::Client::PlasmaShell *waylandCoronaInterface() const;
0116 
0117     //! VirtualDesktopsSupport
0118     void setCurrentDesktop(QString desktop);
0119     void addDesktop(const QString &id, quint32 position);
0120 
0121 
0122 private:
0123     friend class Private::GhostWindow;
0124     mutable QMap<WindowId, Private::GhostWindow *> m_ghostWindows;
0125 
0126     KWayland::Client::PlasmaWindowManagement *m_windowManagement{nullptr};
0127 
0128     //! VirtualDesktopsSupport
0129     KWayland::Client::PlasmaVirtualDesktopManagement *m_virtualDesktopManagement{nullptr};
0130     QStringList m_desktops;
0131 
0132 
0133     Latte::Corona *m_corona{nullptr};
0134 };
0135 
0136 }
0137 }
0138 
0139 #endif // WAYLANDINTERFACE_H
0140 
0141