Hyprland/src/protocols/VirtualPointer.hpp

78 lines
1.9 KiB
C++
Raw Normal View History

2024-05-03 02:27:59 +02:00
#pragma once
#include <memory>
#include <vector>
#include <cstdint>
#include <array>
#include "WaylandProtocol.hpp"
#include "wlr-virtual-pointer-unstable-v1.hpp"
#include "../helpers/signal/Signal.hpp"
#include "../devices/IPointer.hpp"
#include "../helpers/Monitor.hpp"
2024-05-03 02:27:59 +02:00
class CVirtualPointerV1Resource {
2024-05-03 02:27:59 +02:00
public:
2024-07-29 16:27:09 +02:00
CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> resource_, WP<CMonitor> boundOutput_);
~CVirtualPointerV1Resource();
2024-05-03 02:27:59 +02:00
struct {
CSignal destroy;
CSignal move;
CSignal warp;
CSignal button;
CSignal axis;
CSignal frame;
CSignal swipeBegin;
CSignal swipeUpdate;
CSignal swipeEnd;
CSignal pinchBegin;
CSignal pinchUpdate;
CSignal pinchEnd;
CSignal holdBegin;
CSignal holdEnd;
2024-05-03 02:27:59 +02:00
} events;
2024-07-29 16:27:09 +02:00
bool good();
wl_client* client();
2024-07-29 16:27:09 +02:00
std::string name;
WP<CMonitor> boundOutput;
2024-05-03 02:27:59 +02:00
private:
SP<CZwlrVirtualPointerV1> resource;
2024-05-03 02:27:59 +02:00
uint32_t axis = 0;
2024-05-03 02:27:59 +02:00
std::array<IPointer::SAxisEvent, 2> axisEvents;
2024-05-03 02:27:59 +02:00
};
class CVirtualPointerProtocol : public IWaylandProtocol {
public:
CVirtualPointerProtocol(const wl_interface* iface, const int& ver, const std::string& name);
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
struct {
CSignal newPointer; // SP<CVirtualPointerV1Resource>
2024-05-03 02:27:59 +02:00
} events;
private:
void onManagerResourceDestroy(wl_resource* res);
void destroyResource(CVirtualPointerV1Resource* pointer);
2024-07-29 16:27:09 +02:00
void onCreatePointer(CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id, WP<CMonitor> output);
2024-05-03 02:27:59 +02:00
//
std::vector<UP<CZwlrVirtualPointerManagerV1>> m_vManagers;
std::vector<SP<CVirtualPointerV1Resource>> m_vPointers;
2024-05-03 02:27:59 +02:00
friend class CVirtualPointerV1Resource;
2024-05-03 02:27:59 +02:00
};
namespace PROTO {
inline UP<CVirtualPointerProtocol> virtualPointer;
};