summaryrefslogtreecommitdiff
path: root/src/desktop/view/LayerSurface.hpp
blob: a8cc7acd226b030179b5bf9e65733b4781cb5f22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#pragma once

#include <string>
#include "../../defines.hpp"
#include "WLSurface.hpp"
#include "View.hpp"
#include "../rule/layerRule/LayerRuleApplicator.hpp"
#include "../../helpers/AnimatedVariable.hpp"
#include "../../render/Framebuffer.hpp"

class CLayerShellResource;

namespace Desktop::View {

    class CLayerSurface : public IView {
      public:
        static PHLLS create(SP<CLayerShellResource>);
        static PHLLS fromView(SP<IView>);

      private:
        CLayerSurface(SP<CLayerShellResource>);

      public:
        virtual ~CLayerSurface();

        virtual eViewType           type() const;
        virtual bool                visible() const;
        virtual std::optional<CBox> logicalBox() const;
        virtual bool                desktopComponent() const;
        virtual std::optional<CBox> surfaceLogicalBox() const;

        bool                        isFadedOut();
        int                         popupsCount();

        PHLANIMVAR<Vector2D>        m_realPosition;
        PHLANIMVAR<Vector2D>        m_realSize;
        PHLANIMVAR<float>           m_alpha;

        WP<CLayerShellResource>     m_layerSurface;

        // the header providing the enum type cannot be imported here
        int                                     m_interactivity = 0;

        bool                                    m_mapped = false;
        uint32_t                                m_layer  = 0;

        PHLMONITORREF                           m_monitor;

        bool                                    m_fadingOut       = false;
        bool                                    m_readyToDelete   = false;
        bool                                    m_noProcess       = false;
        bool                                    m_aboveFullscreen = true;

        UP<Desktop::Rule::CLayerRuleApplicator> m_ruleApplicator;

        PHLLSREF                                m_self;

        CBox                                    m_geometry = {0, 0, 0, 0};
        Vector2D                                m_position;
        std::string                             m_namespace = "";
        SP<Desktop::View::CPopup>               m_popupHead;

        SP<Render::IFramebuffer>                m_snapshotFB;

        pid_t                                   getPID();

        void                                    onDestroy();
        void                                    onMap();
        void                                    onUnmap();
        void                                    onCommit();
        MONITORID                               monitorID();

      private:
        struct {
            CHyprSignalListener destroy;
            CHyprSignalListener map;
            CHyprSignalListener unmap;
            CHyprSignalListener commit;
        } m_listeners;

        void registerCallbacks();

        // For the list lookup
        bool operator==(const CLayerSurface& rhs) const {
            return m_layerSurface == rhs.m_layerSurface && m_monitor == rhs.m_monitor;
        }
    };

    inline bool valid(PHLLS l) {
        return l;
    }

    inline bool valid(PHLLSREF l) {
        return l;
    }

    inline bool validMapped(PHLLS l) {
        if (!valid(l))
            return false;
        return l->aliveAndVisible();
    }

    inline bool validMapped(PHLLSREF l) {
        if (!valid(l))
            return false;
        return l->aliveAndVisible();
    }

}