blob: 3e5d36abed79919ded3e772ef0167544c537509a (
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
|
#pragma once
#include "WaylandProtocol.hpp"
#include "hyprland-focus-grab-v1.hpp"
#include "macros.hpp"
#include <cstdint>
#include <unordered_map>
#include <vector>
class CFocusGrab;
class CFocusGrabSurfaceState {
public:
CFocusGrabSurfaceState(CFocusGrab* grab, wlr_surface* surface);
~CFocusGrabSurfaceState();
enum State {
PendingAddition,
PendingRemoval,
Comitted,
} state = PendingAddition;
private:
DYNLISTENER(surfaceDestroy);
};
class CFocusGrab {
public:
CFocusGrab(SP<CHyprlandFocusGrabV1> resource_);
~CFocusGrab();
bool good();
bool isSurfaceComitted(wlr_surface* surface);
void start();
void finish(bool sendCleared);
private:
void addSurface(wlr_surface* surface);
void removeSurface(wlr_surface* surface);
void eraseSurface(wlr_surface* surface);
void refocusKeyboard();
void commit();
SP<CHyprlandFocusGrabV1> resource;
std::unordered_map<wlr_surface*, UP<CFocusGrabSurfaceState>> m_mSurfaces;
// wlr_seat_pointer_grab m_sPointerGrab;
// wlr_seat_keyboard_grab m_sKeyboardGrab;
// wlr_seat_touch_grab m_sTouchGrab;
bool m_bGrabActive = false;
DYNLISTENER(pointerGrabStarted);
DYNLISTENER(keyboardGrabStarted);
DYNLISTENER(touchGrabStarted);
friend class CFocusGrabSurfaceState;
};
class CFocusGrabProtocol : public IWaylandProtocol {
public:
CFocusGrabProtocol(const wl_interface* iface, const int& var, const std::string& name);
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
private:
void onManagerResourceDestroy(wl_resource* res);
void destroyGrab(CFocusGrab* grab);
void onCreateGrab(CHyprlandFocusGrabManagerV1* pMgr, uint32_t id);
std::vector<UP<CHyprlandFocusGrabManagerV1>> m_vManagers;
std::vector<UP<CFocusGrab>> m_vGrabs;
friend class CFocusGrab;
};
namespace PROTO {
inline UP<CFocusGrabProtocol> focusGrab;
}
|