summaryrefslogtreecommitdiff
path: root/src/desktop/Constraint.hpp
blob: 34690217f6c0f9a627881e382872a1009b16f6eb (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
#pragma once

#include "../includes.hpp"
#include "../helpers/Region.hpp"
#include "../helpers/WLListener.hpp"

class CWLSurface;

class CConstraint {
  public:
    CConstraint(wlr_pointer_constraint_v1* constraint, CWLSurface* owner);
    ~CConstraint();

    void        onCommit();
    void        onDestroy();
    void        onSetRegion();
    CRegion     logicConstraintRegion();
    bool        isLocked();
    Vector2D    logicPositionHint();

    void        deactivate();
    void        activate();
    bool        active();

    CWLSurface* owner();

  private:
    bool                       m_bActive = false;
    CWLSurface*                m_pOwner  = nullptr;
    wlr_pointer_constraint_v1* m_pConstraint;

    CRegion                    m_rRegion;
    bool                       m_bHintSet             = false;
    Vector2D                   m_vPositionHint        = {-1, -1};
    Vector2D                   m_vCursorPosOnActivate = {-1, -1};

    // for oneshot constraints that have been activated once
    bool m_bDead = false;

    DYNLISTENER(destroyConstraint);
    DYNLISTENER(setConstraintRegion);

    void initSignals();
};