aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Window.hpp
blob: 0ee164dc807ab953f5abf4f95f9d2a5812f0cf47 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#pragma once

#include "defines.hpp"
#include "events/Events.hpp"
#include "helpers/SubsurfaceTree.hpp"
#include "helpers/AnimatedVariable.hpp"
#include "render/decorations/IHyprWindowDecoration.hpp"
#include <deque>

struct SWindowSpecialRenderData {
    float alpha = 1.f;
    float alphaInactive = -1.f; // -1 means unset

    // set by the layout
    bool rounding = true;
    bool border = true;
};  

struct SWindowAdditionalConfigData {
    std::string animationStyle = "";
    int rounding = -1; // -1 means no
    bool forceNoBlur = false;
    bool forceOpaque = false;
};

class CWindow {
public:
    CWindow();
    ~CWindow();

    DYNLISTENER(commitWindow);
    DYNLISTENER(mapWindow);
    DYNLISTENER(unmapWindow);
    DYNLISTENER(destroyWindow);
    DYNLISTENER(setTitleWindow);
    DYNLISTENER(setGeometryX11U);
    DYNLISTENER(fullscreenWindow);
    DYNLISTENER(newPopupXDG);
    DYNLISTENER(requestMove);
    DYNLISTENER(requestMinimize);
    DYNLISTENER(requestMaximize);
    DYNLISTENER(requestResize);
    DYNLISTENER(activateX11);
    DYNLISTENER(configureX11);
    DYNLISTENER(toplevelClose);
    DYNLISTENER(toplevelActivate);
    DYNLISTENER(toplevelFullscreen);
   // DYNLISTENER(newSubsurfaceWindow);

    union {
        wlr_xdg_surface* xdg;
        wlr_xwayland_surface* xwayland;
    } m_uSurface;

    // this is the position and size of the "bounding box"
    Vector2D            m_vPosition = Vector2D(0,0);
    Vector2D            m_vSize = Vector2D(0,0);

    // this is the real position and size used to draw the thing
    CAnimatedVariable m_vRealPosition;
    CAnimatedVariable m_vRealSize;

    // for not spamming the protocols
    Vector2D            m_vReportedPosition;
    Vector2D            m_vReportedSize;

    // for restoring floating statuses
    Vector2D            m_vLastFloatingSize;

    // this is used for pseudotiling
    bool                m_bIsPseudotiled = false;
    Vector2D            m_vPseudoSize = Vector2D(0,0);

    uint64_t        m_iTags = 0;
    bool            m_bIsFloating = false;
    bool            m_bDraggingTiled = false; // for dragging around tiled windows
    bool            m_bIsFullscreen = false;
    uint64_t        m_iMonitorID = -1;
    std::string     m_szTitle = "";
    int             m_iWorkspaceID = -1;

    bool            m_bIsMapped = false;

    bool            m_bRequestsFloat = false;

    // This is for fullscreen apps
    bool            m_bCreatedOverFullscreen = false;

    // XWayland stuff
    bool            m_bIsX11 = false;
    bool            m_bMappedX11 = false;
    CWindow*        m_pX11Parent = nullptr;
    uint64_t        m_iX11Type = 0;
    bool            m_bIsModal = false;
    bool            m_bX11DoesntWantBorders = false;
    bool            m_bX11ShouldntFocus = false;
    //

    // For nofocus
    bool            m_bNoFocus = false;
    bool            m_bNoInitialFocus = false;

    // initial fullscreen
    bool            m_bWantsInitialFullscreen = false;

    SSurfaceTreeNode* m_pSurfaceTree = nullptr;

    // Animated border
    CAnimatedVariable m_cRealBorderColor;

    // Fade in-out
    CAnimatedVariable m_fAlpha;
    bool            m_bFadingOut = false;
    bool            m_bReadyToDelete = false;
    Vector2D        m_vOriginalClosedPos; // these will be used for calculations later on in
    Vector2D        m_vOriginalClosedSize; // drawing the closing animations

    // For hidden windows and stuff
    bool            m_bHidden = false;

    // for proper cycling. While cycling we can't just move the pointers, so we need to keep track of the last cycled window.
    CWindow*        m_pLastCycledWindow = nullptr;

    // Foreign Toplevel proto
    wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;

    // Window decorations
    std::deque<std::unique_ptr<IHyprWindowDecoration>> m_dWindowDecorations;
    std::vector<IHyprWindowDecoration*> m_vDecosToRemove;

    // Special render data, rules, etc
    SWindowSpecialRenderData m_sSpecialRenderData;
    SWindowAdditionalConfigData m_sAdditionalConfigData;

    // for alpha
    CAnimatedVariable m_fActiveInactiveAlpha;

    // animated shadow color
    CAnimatedVariable m_cRealShadowColor;

    // for toplevel monitor events
    uint64_t          m_iLastToplevelMonitorID = -1;
    uint64_t          m_iLastSurfaceMonitorID = -1;

    // For the list lookup
    bool operator==(const CWindow& rhs) {
        return m_uSurface.xdg == rhs.m_uSurface.xdg && m_uSurface.xwayland == rhs.m_uSurface.xwayland && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize && m_bFadingOut == rhs.m_bFadingOut;
    }

    // methods
    wlr_box         getFullWindowBoundingBox();
    wlr_box         getWindowIdealBoundingBoxIgnoreReserved();
    void            updateWindowDecos();
    pid_t           getPID();
    IHyprWindowDecoration* getDecorationByType(eDecorationType);
    void            createToplevelHandle();
    void            destroyToplevelHandle();
    void            updateToplevel();
    void            updateSurfaceOutputs();
    void            moveToWorkspace(int);
};