From edad24c257c1264e2d0c05b04798b6c90515831e Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 15 Apr 2023 23:43:41 +0100 Subject: Screencopy: unify frame and client between impls + event Adds a new event to both hooks and ipc: screencopy --- src/protocols/Screencopy.hpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/protocols/Screencopy.hpp') diff --git a/src/protocols/Screencopy.hpp b/src/protocols/Screencopy.hpp index 77d2b5c3..17b5ed0b 100644 --- a/src/protocols/Screencopy.hpp +++ b/src/protocols/Screencopy.hpp @@ -5,21 +5,42 @@ #include #include +#include "../managers/HookSystemManager.hpp" class CMonitor; -struct SScreencopyClient { - int ref = 0; - wl_resource* resource = nullptr; +enum eClientOwners +{ + CLIENT_SCREENCOPY = 0, + CLIENT_TOPLEVEL_EXPORT +}; + +class CScreencopyClient { + public: + CScreencopyClient(); + ~CScreencopyClient(); + + int ref = 0; + wl_resource* resource = nullptr; + + eClientOwners clientOwner = CLIENT_SCREENCOPY; + + int frameCounter = 0; + int framesInLastHalfSecond = 0; + std::chrono::system_clock::time_point lastMeasure; + bool sentScreencast = false; + + void onTick(); + HOOK_CALLBACK_FN* tickCallback = nullptr; - bool operator==(const SScreencopyClient& other) const { + bool operator==(const CScreencopyClient& other) const { return resource == other.resource; } }; struct SScreencopyFrame { wl_resource* resource = nullptr; - SScreencopyClient* client = nullptr; + CScreencopyClient* client = nullptr; uint32_t shmFormat = 0; uint32_t dmabufFormat = 0; @@ -34,6 +55,7 @@ struct SScreencopyFrame { wlr_buffer* buffer = nullptr; CMonitor* pMonitor = nullptr; + CWindow* pWindow = nullptr; bool operator==(const SScreencopyFrame& other) const { return resource == other.resource && client == other.client; @@ -45,7 +67,7 @@ class CScreencopyProtocolManager { CScreencopyProtocolManager(); void bindManager(wl_client* client, void* data, uint32_t version, uint32_t id); - void removeClient(SScreencopyClient* client, bool force = false); + void removeClient(CScreencopyClient* client, bool force = false); void removeFrame(SScreencopyFrame* frame, bool force = false); void displayDestroy(); @@ -59,7 +81,7 @@ class CScreencopyProtocolManager { private: wl_global* m_pGlobal = nullptr; std::list m_lFrames; - std::list m_lClients; + std::list m_lClients; wl_listener m_liDisplayDestroy; -- cgit v1.2.3