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
|
#include "XDGBell.hpp"
#include "core/Compositor.hpp"
#include "../desktop/view/Window.hpp"
#include "../managers/EventManager.hpp"
#include "../Compositor.hpp"
CXDGSystemBellManagerResource::CXDGSystemBellManagerResource(UP<CXdgSystemBellV1>&& resource) : m_resource(std::move(resource)) {
if UNLIKELY (!good())
return;
m_resource->setDestroy([this](CXdgSystemBellV1* r) { PROTO::xdgBell->destroyResource(this); });
m_resource->setOnDestroy([this](CXdgSystemBellV1* r) { PROTO::xdgBell->destroyResource(this); });
m_resource->setRing([](CXdgSystemBellV1* r, wl_resource* surface) {
if (!surface) {
g_pEventManager->postEvent(SHyprIPCEvent{
.event = "bell",
.data = "",
});
return;
}
const auto SURFACE = CWLSurfaceResource::fromResource(surface);
if (!SURFACE) {
g_pEventManager->postEvent(SHyprIPCEvent{
.event = "bell",
.data = "",
});
return;
}
for (const auto& w : g_pCompositor->m_windows) {
if (!w->m_isMapped || w->m_isX11 || !w->m_xdgSurface || !w->wlSurface())
continue;
if (w->wlSurface()->resource() == SURFACE) {
g_pEventManager->postEvent(SHyprIPCEvent{
.event = "bell",
.data = std::format("{:x}", rc<uintptr_t>(w.get())),
});
return;
}
}
g_pEventManager->postEvent(SHyprIPCEvent{
.event = "bell",
.data = "",
});
});
}
bool CXDGSystemBellManagerResource::good() {
return m_resource->resource();
}
CXDGSystemBellProtocol::CXDGSystemBellProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
;
}
void CXDGSystemBellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = WP<CXDGSystemBellManagerResource>{m_managers.emplace_back(makeUnique<CXDGSystemBellManagerResource>(makeUnique<CXdgSystemBellV1>(client, ver, id)))};
if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client);
return;
}
}
void CXDGSystemBellProtocol::destroyResource(CXDGSystemBellManagerResource* res) {
std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; });
}
|