summaryrefslogtreecommitdiff
path: root/src/event/EventBus.hpp
blob: 40a6fc926c9c95e6aad3d176f8628df1d94ee5f3 (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
#pragma once

#include "../helpers/memory/Memory.hpp"
#include "../helpers/signal/Signal.hpp"
#include "../helpers/math/Math.hpp"

#include "../devices/IPointer.hpp"
#include "../devices/IKeyboard.hpp"
#include "../devices/Tablet.hpp"
#include "../devices/ITouch.hpp"

#include "../desktop/DesktopTypes.hpp"

#include "../SharedDefs.hpp"

namespace Desktop {
    enum eFocusReason : uint8_t;
}
namespace Event {
    struct SCallbackInfo {
        bool cancelled = false; /* on cancellable events, will cancel the event. */
    };

    class CEventBus {
      public:
        CEventBus()  = default;
        ~CEventBus() = default;

        template <typename... Args>
        using Event = CSignalT<Args...>;

        template <typename... Args>
        using Cancellable = CSignalT<Args..., SCallbackInfo&>;

        struct {
            Event<> ready;
            Event<> tick;
            Event<> start;
            Event<> exit;

            struct {
                Event<PHLWINDOW>                        open;
                Event<PHLWINDOW>                        openEarly;
                Event<PHLWINDOW>                        destroy;
                Event<PHLWINDOW>                        close;
                Event<PHLWINDOW>                        kill;
                Event<PHLWINDOW, Desktop::eFocusReason> active;
                Event<PHLWINDOW>                        urgent;
                Event<PHLWINDOW>                        title;
                Event<PHLWINDOW>                        class_;
                Event<PHLWINDOW>                        pin;
                Event<PHLWINDOW>                        fullscreen;
                Event<PHLWINDOW>                        updateRules;
                Event<PHLWINDOW, PHLWORKSPACE>          moveToWorkspace;
            } window;

            struct {
                Event<PHLLS> opened;
                Event<PHLLS> closed;
                Event<PHLLS> updateRules;
            } layer;

            struct {
                struct {
                    Cancellable<Vector2D>               move;
                    Cancellable<IPointer::SButtonEvent> button;
                    Cancellable<IPointer::SAxisEvent>   axis;
                } mouse;

                struct {
                    Cancellable<IKeyboard::SKeyEvent>        key;
                    Event<SP<IKeyboard>, const std::string&> layout;
                    Event<SP<CWLSurfaceResource>>            focus;
                } keyboard;

                struct {
                    Cancellable<CTablet::SAxisEvent>      axis;
                    Cancellable<CTablet::SButtonEvent>    button;
                    Cancellable<CTablet::SProximityEvent> proximity;
                    Cancellable<CTablet::STipEvent>       tip;
                } tablet;

                struct {
                    Cancellable<ITouch::SCancelEvent> cancel;
                    Cancellable<ITouch::SDownEvent>   down;
                    Cancellable<ITouch::SUpEvent>     up;
                    Cancellable<ITouch::SMotionEvent> motion;
                } touch;
            } input;

            struct {
                Event<PHLMONITOR>   preChecks;
                Event<PHLMONITOR>   pre;
                Event<eRenderStage> stage;
            } render;

            struct {
                Event<bool /* state start/stop */, uint8_t /* eScreenshareType */, const std::string& /* name */> state;
            } screenshare;

            struct {
                struct {
                    Cancellable<IPointer::SSwipeBeginEvent>  begin;
                    Cancellable<IPointer::SSwipeEndEvent>    end;
                    Cancellable<IPointer::SSwipeUpdateEvent> update;
                } swipe;

                struct {
                    Cancellable<IPointer::SPinchBeginEvent>  begin;
                    Cancellable<IPointer::SPinchEndEvent>    end;
                    Cancellable<IPointer::SPinchUpdateEvent> update;
                } pinch;
            } gesture;

            struct {
                Event<PHLMONITOR> newMon;
                Event<PHLMONITOR> preAdded;
                Event<PHLMONITOR> added;
                Event<PHLMONITOR> preRemoved;
                Event<PHLMONITOR> removed;
                Event<PHLMONITOR> preCommit;
                Event<PHLMONITOR> focused;

                Event<>           layoutChanged;
            } monitor;

            struct {
                Event<PHLWORKSPACE, PHLMONITOR> moveToMonitor;
                Event<PHLWORKSPACE>             active;
                Event<PHLWORKSPACEREF>          created;
                Event<PHLWORKSPACEREF>          removed;
            } workspace;

            struct {
                Event<> preReload;
                Event<> reloaded;
            } config;

            struct {
                Event<const std::string&> submap;
            } keybinds;

        } m_events;
    };

    UP<CEventBus>& bus();
};