File indexing completed on 2024-04-28 05:31:06

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef VIEWSUBWINDOW_H
0007 #define VIEWSUBWINDOW_H
0008 
0009 // local
0010 #include "../../lattecorona.h"
0011 #include "../../wm/windowinfowrap.h"
0012 
0013 // Qt
0014 #include <QObject>
0015 #include <QQuickView>
0016 #include <QTimer>
0017 
0018 namespace KWayland {
0019 namespace Client {
0020 class PlasmaShellSurface;
0021 }
0022 }
0023 
0024 namespace Latte {
0025 class Corona;
0026 class View;
0027 }
0028 
0029 namespace Latte {
0030 namespace ViewPart {
0031 
0032 //! What is the importance of this class?
0033 //!
0034 //! This window is responsible to provide a common window base for ViewPart::Helpers
0035 
0036 class SubWindow : public QQuickView
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     SubWindow(Latte::View *view, QString debugType);
0042     ~SubWindow() override;
0043 
0044     int location();
0045     int thickness() const;
0046 
0047     QString validTitle() const;
0048 
0049     void hideWithMask();
0050     void showWithMask();
0051 
0052     Latte::View *parentView();
0053     Latte::WindowSystem::WindowId trackedWindowId();
0054 
0055     KWayland::Client::PlasmaShellSurface *surface();
0056 
0057 signals:
0058     void forcedShown(); //[workaround] forced shown to avoid a KWin issue that hides windows when activities are stopped
0059     void calculatedGeometryChanged();
0060 
0061 protected:
0062     bool event(QEvent *ev) override;
0063 
0064     virtual QString validTitlePrefix() const;
0065 
0066     //! it is used to update m_calculatedGeometry correctly
0067     virtual void updateGeometry() = 0;
0068 
0069 private slots:
0070     void startGeometryTimer();
0071     void fixGeometry();
0072     void updateWaylandId();
0073 
0074 private:
0075     void setupWaylandIntegration();
0076 
0077 protected:
0078     bool m_debugMode{false};
0079     bool m_inDelete{false};
0080 
0081     int m_thickness{2};
0082 
0083     QString m_debugType;
0084 
0085     QRect m_calculatedGeometry;
0086 
0087     //! [workaround] colors in order to help masking to apply immediately
0088     //! for some reason when the window in with no content the mask is not
0089     //! update immediately
0090     QColor m_hideColor;
0091     QColor m_showColor;
0092 
0093     QTimer m_fixGeometryTimer;
0094 
0095     //! HACK: Timers in order to handle KWin faulty
0096     //! behavior that hides Views when closing Activities
0097     //! with no actual reason
0098     QTimer m_visibleHackTimer1;
0099     QTimer m_visibleHackTimer2;
0100     //! Connections for the KWin visibility hack
0101     QList<QMetaObject::Connection> connectionsHack;
0102 
0103     Latte::View *m_latteView{nullptr};
0104 
0105     QPointer<Latte::Corona> m_corona;
0106 
0107     Latte::WindowSystem::WindowId m_trackedWindowId;
0108     KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr};
0109 };
0110 
0111 }
0112 }
0113 #endif