aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/helpers/Monitor.hpp
blob: 19fd476e941fc6675d53c4faee12318a3d2a2494 (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
#pragma once

#include "../defines.hpp"
#include <deque>
#include "WLClasses.hpp"
#include <vector>
#include <array>
#include <memory>

struct SMonitorRule;

class CMonitor {
public:
    Vector2D    vecPosition         = Vector2D(-1,-1); // means unset
    Vector2D    vecSize             = Vector2D(0,0);
    Vector2D    vecPixelSize        = Vector2D(0,0);
    Vector2D    vecTransformedSize  = Vector2D(0,0);

    bool        primary         = false;

    uint64_t    ID              = -1;
    int         activeWorkspace = -1;
    float       scale = 1;

    std::string szName          = "";

    Vector2D    vecReservedTopLeft = Vector2D(0,0);
    Vector2D    vecReservedBottomRight = Vector2D(0,0);

    // WLR stuff
    wlr_output* output          = nullptr;
    float       refreshRate     = 60;
    wlr_output_damage* damage   = nullptr;
    int         framesToSkip    = 0;
    int         forceFullFrames = 0;
    bool        noFrameSchedule = false;
    bool        scheduledRecalc = false;
    wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;

    bool        dpmsStatus = true;
    bool        vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.
    bool        enabled10bit = false; // as above, this can be TRUE even if 10 bit failed.
    bool        createdByUser = false;

    // will attempt DS
    CWindow*    solitaryClient = nullptr; // used for stuff like tearing / VRR

    // mirroring
    CMonitor*   pMirrorOf = nullptr;
    std::vector<CMonitor*> mirrors;

    // for the special workspace
    bool        specialWorkspaceOpen = false;

    // Double-linked list because we need to have constant mem addresses for signals
    // We have to store pointers and use raw new/delete because they might be moved between them
    // and I am lazy
    std::array<std::vector<std::unique_ptr<SLayerSurface>>, 4>   m_aLayerSurfaceLists;

    DYNLISTENER(monitorFrame);
    DYNLISTENER(monitorDestroy);
    DYNLISTENER(monitorStateRequest);

    // hack: a group = workspaces on a monitor.
    // I don't really care lol :P
    wlr_ext_workspace_group_handle_v1* pWLRWorkspaceGroupHandle = nullptr;


    // methods
    void        onConnect(bool noRule);
    void        onDisconnect();
    void        addDamage(pixman_region32_t* rg);
    void        addDamage(wlr_box* box);
    void        forceDamageEntire();
    void        setMirror(const std::string&);
    bool        isMirror();

    std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
    bool        m_bEnabled = false;
    bool        m_bRenderingInitPassed = false;

    // For the list lookup

    bool operator==(const CMonitor& rhs) {
        return vecPosition == rhs.vecPosition && vecSize == rhs.vecSize && szName == rhs.szName;
    }

private:
    void        setupDefaultWS(const SMonitorRule&);
};