diff options
| author | Ikalco <73481042+ikalco@users.noreply.github.com> | 2026-02-22 06:30:11 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-22 12:30:11 +0000 |
| commit | b4ee4674f9a74e3d602c7fb17bc09f79d221583c (patch) | |
| tree | 294bbb207c44e778dd78afda65cbd79181f04124 /src/protocols/Screencopy.hpp | |
| parent | 93dbf884261efcb387e920b1cd0e4ed5b288bc3a (diff) | |
protocols: implement image-capture-source-v1 and image-copy-capture-v1 (#11709)
Implements the new screencopy protocols
Diffstat (limited to 'src/protocols/Screencopy.hpp')
| -rw-r--r-- | src/protocols/Screencopy.hpp | 86 |
1 files changed, 25 insertions, 61 deletions
diff --git a/src/protocols/Screencopy.hpp b/src/protocols/Screencopy.hpp index 54b0d28c..3659c753 100644 --- a/src/protocols/Screencopy.hpp +++ b/src/protocols/Screencopy.hpp @@ -1,25 +1,19 @@ #pragma once -#include "../defines.hpp" -#include "./types/Buffer.hpp" -#include "wlr-screencopy-unstable-v1.hpp" #include "WaylandProtocol.hpp" +#include "wlr-screencopy-unstable-v1.hpp" -#include <list> -#include <vector> -#include "../managers/HookSystemManager.hpp" -#include "../helpers/time/Timer.hpp" #include "../helpers/time/Time.hpp" -#include "../render/Framebuffer.hpp" -#include "../managers/eventLoop/EventLoopTimer.hpp" +#include "./types/Buffer.hpp" #include <aquamarine/buffer/Buffer.hpp> +#include <vector> + class CMonitor; class IHLBuffer; - -enum eClientOwners { - CLIENT_SCREENCOPY = 0, - CLIENT_TOPLEVEL_EXPORT +namespace Screenshare { + class CScreenshareSession; + class CScreenshareFrame; }; class CScreencopyClient { @@ -27,24 +21,13 @@ class CScreencopyClient { CScreencopyClient(SP<CZwlrScreencopyManagerV1> resource_); ~CScreencopyClient(); - bool good(); - wl_client* client(); - - WP<CScreencopyClient> m_self; - eClientOwners m_clientOwner = CLIENT_SCREENCOPY; - - CTimer m_lastFrame; - int m_frameCounter = 0; + bool good(); private: SP<CZwlrScreencopyManagerV1> m_resource; + WP<CScreencopyClient> m_self; - int m_framesInLastHalfSecond = 0; - CTimer m_lastMeasure; - bool m_sentScreencast = false; - - SP<HOOK_CALLBACK_FN> m_tickCallback; - void onTick(); + wl_client* m_savedClient = nullptr; void captureOutput(uint32_t frame, int32_t overlayCursor, wl_resource* output, CBox box); @@ -53,38 +36,30 @@ class CScreencopyClient { class CScreencopyFrame { public: - CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource, int32_t overlay_cursor, wl_resource* output, CBox box); - - bool good(); + CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource, WP<Screenshare::CScreenshareSession> session, bool overlayCursor); - WP<CScreencopyFrame> m_self; - WP<CScreencopyClient> m_client; + bool good(); private: - SP<CZwlrScreencopyFrameV1> m_resource; + SP<CZwlrScreencopyFrameV1> m_resource; + WP<CScreencopyFrame> m_self; + WP<CScreencopyClient> m_client; - PHLMONITORREF m_monitor; - bool m_overlayCursor = false; - bool m_withDamage = false; + WP<Screenshare::CScreenshareSession> m_session; + UP<Screenshare::CScreenshareFrame> m_frame; - CHLBufferReference m_buffer; - bool m_bufferDMA = false; - uint32_t m_shmFormat = 0; - uint32_t m_dmabufFormat = 0; - int m_shmStride = 0; - CBox m_box = {}; + CHLBufferReference m_buffer; + Time::steady_tp m_timestamp; + bool m_overlayCursor = true; - // if we have a pending perm, hold the buffer. - CFramebuffer m_tempFb; + struct { + CHyprSignalListener stopped; + } m_listeners; - void copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer); - void copyDmabuf(std::function<void(bool)> callback); - bool copyShm(); - void renderMon(); - void storeTempFB(); - void share(); + void shareFrame(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer, bool withDamage); friend class CScreencopyProtocol; + friend class CScreencopyClient; }; class CScreencopyProtocol : public IWaylandProtocol { @@ -95,21 +70,10 @@ class CScreencopyProtocol : public IWaylandProtocol { void destroyResource(CScreencopyClient* resource); void destroyResource(CScreencopyFrame* resource); - void onOutputCommit(PHLMONITOR pMonitor); - private: std::vector<SP<CScreencopyFrame>> m_frames; - std::vector<WP<CScreencopyFrame>> m_framesAwaitingWrite; std::vector<SP<CScreencopyClient>> m_clients; - void shareAllFrames(PHLMONITOR pMonitor); - void shareFrame(CScreencopyFrame* frame); - void sendFrameDamage(CScreencopyFrame* frame); - bool copyFrameDmabuf(CScreencopyFrame* frame); - bool copyFrameShm(CScreencopyFrame* frame, const Time::steady_tp& now); - - uint32_t drmFormatForMonitor(PHLMONITOR pMonitor); - friend class CScreencopyFrame; friend class CScreencopyClient; }; |
