idle-inhibit: move to new impl
This commit is contained in:
parent
e823b5d693
commit
d9fe1d0f58
14 changed files with 154 additions and 68 deletions
63
src/protocols/IdleInhibit.hpp
Normal file
63
src/protocols/IdleInhibit.hpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include "WaylandProtocol.hpp"
|
||||
#include "idle-inhibit-unstable-v1.hpp"
|
||||
#include "../helpers/signal/Signal.hpp"
|
||||
|
||||
class CIdleInhibitorResource;
|
||||
|
||||
class CIdleInhibitor {
|
||||
public:
|
||||
CIdleInhibitor(SP<CIdleInhibitorResource> resource_, wlr_surface* surf_);
|
||||
|
||||
struct {
|
||||
CHyprSignalListener destroy;
|
||||
} listeners;
|
||||
|
||||
WP<CIdleInhibitorResource> resource;
|
||||
wlr_surface* surface = nullptr;
|
||||
};
|
||||
|
||||
class CIdleInhibitorResource {
|
||||
public:
|
||||
CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, wlr_surface* surface_);
|
||||
~CIdleInhibitorResource();
|
||||
|
||||
SP<CIdleInhibitor> inhibitor;
|
||||
|
||||
struct {
|
||||
CSignal destroy;
|
||||
} events;
|
||||
|
||||
private:
|
||||
SP<CZwpIdleInhibitorV1> resource;
|
||||
wlr_surface* surface = nullptr;
|
||||
|
||||
DYNLISTENER(surfaceDestroy);
|
||||
};
|
||||
|
||||
class CIdleInhibitProtocol : public IWaylandProtocol {
|
||||
public:
|
||||
CIdleInhibitProtocol(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);
|
||||
|
||||
void onManagerResourceDestroy(wl_resource* res);
|
||||
void onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, wlr_surface* surface);
|
||||
|
||||
void removeInhibitor(CIdleInhibitorResource*);
|
||||
|
||||
struct {
|
||||
CSignal newIdleInhibitor; // data: SP<CIdleInhibitor>
|
||||
} events;
|
||||
|
||||
private:
|
||||
std::vector<UP<CZwpIdleInhibitManagerV1>> m_vManagers;
|
||||
std::vector<SP<CIdleInhibitorResource>> m_vInhibitors;
|
||||
};
|
||||
|
||||
namespace PROTO {
|
||||
inline UP<CIdleInhibitProtocol> idleInhibit;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue