protocols: implement image-capture-source-v1 and image-copy-capture-v1 (#11709)

Implements the new screencopy protocols
This commit is contained in:
Ikalco 2026-02-22 06:30:11 -06:00 committed by GitHub
parent 93dbf88426
commit b4ee4674f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 2585 additions and 1078 deletions

View file

@ -1,72 +1,63 @@
#pragma once
#include "../defines.hpp"
#include "hyprland-toplevel-export-v1.hpp"
#include "WaylandProtocol.hpp"
#include "Screencopy.hpp"
#include "hyprland-toplevel-export-v1.hpp"
#include "../helpers/time/Time.hpp"
#include "./types/Buffer.hpp"
#include <aquamarine/buffer/Buffer.hpp>
#include <vector>
class CMonitor;
namespace Screenshare {
class CScreenshareSession;
class CScreenshareFrame;
};
class CToplevelExportClient {
public:
CToplevelExportClient(SP<CHyprlandToplevelExportManagerV1> resource_);
~CToplevelExportClient();
bool good();
WP<CToplevelExportClient> m_self;
eClientOwners m_clientOwner = CLIENT_TOPLEVEL_EXPORT;
CTimer m_lastFrame;
int m_frameCounter = 0;
bool good();
private:
SP<CHyprlandToplevelExportManagerV1> m_resource;
WP<CToplevelExportClient> m_self;
int m_framesInLastHalfSecond = 0;
CTimer m_lastMeasure;
bool m_sentScreencast = false;
wl_client* m_savedClient = nullptr;
SP<HOOK_CALLBACK_FN> m_tickCallback;
void onTick();
void captureToplevel(CHyprlandToplevelExportManagerV1* pMgr, uint32_t frame, int32_t overlayCursor, PHLWINDOW handle);
void captureToplevel(uint32_t frame, int32_t overlayCursor, PHLWINDOW handle);
friend class CToplevelExportProtocol;
};
class CToplevelExportFrame {
public:
CToplevelExportFrame(SP<CHyprlandToplevelExportFrameV1> resource_, int32_t overlayCursor, PHLWINDOW pWindow);
CToplevelExportFrame(SP<CHyprlandToplevelExportFrameV1> resource, WP<Screenshare::CScreenshareSession> session, bool overlayCursor);
bool good();
WP<CToplevelExportFrame> m_self;
WP<CToplevelExportClient> m_client;
bool good();
private:
SP<CHyprlandToplevelExportFrameV1> m_resource;
SP<CHyprlandToplevelExportFrameV1> m_resource;
WP<CToplevelExportFrame> m_self;
WP<CToplevelExportClient> m_client;
PHLWINDOW m_window;
bool m_cursorOverlayRequested = false;
bool m_ignoreDamage = 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;
void copy(CHyprlandToplevelExportFrameV1* pFrame, wl_resource* buffer, int32_t ignoreDamage);
bool copyDmabuf(const Time::steady_tp& now);
bool copyShm(const Time::steady_tp& now);
void share();
bool shouldOverlayCursor() const;
struct {
CHyprSignalListener stopped;
} m_listeners;
void shareFrame(wl_resource* buffer, bool ignoreDamage);
friend class CToplevelExportProtocol;
friend class CToplevelExportClient;
};
class CToplevelExportProtocol : IWaylandProtocol {
@ -82,15 +73,9 @@ class CToplevelExportProtocol : IWaylandProtocol {
private:
std::vector<SP<CToplevelExportClient>> m_clients;
std::vector<SP<CToplevelExportFrame>> m_frames;
std::vector<WP<CToplevelExportFrame>> m_framesAwaitingWrite;
void onWindowUnmap(PHLWINDOW pWindow);
void shareFrame(CToplevelExportFrame* frame);
bool copyFrameDmabuf(CToplevelExportFrame* frame, const Time::steady_tp& now);
bool copyFrameShm(CToplevelExportFrame* frame, const Time::steady_tp& now);
void sendDamage(CToplevelExportFrame* frame);
friend class CToplevelExportClient;
friend class CToplevelExportFrame;
};