summaryrefslogtreecommitdiff
path: root/src/protocols/ToplevelExport.hpp
diff options
context:
space:
mode:
authorIkalco <73481042+ikalco@users.noreply.github.com>2026-02-22 06:30:11 -0600
committerGitHub <noreply@github.com>2026-02-22 12:30:11 +0000
commitb4ee4674f9a74e3d602c7fb17bc09f79d221583c (patch)
tree294bbb207c44e778dd78afda65cbd79181f04124 /src/protocols/ToplevelExport.hpp
parent93dbf884261efcb387e920b1cd0e4ed5b288bc3a (diff)
protocols: implement image-capture-source-v1 and image-copy-capture-v1 (#11709)
Implements the new screencopy protocols
Diffstat (limited to 'src/protocols/ToplevelExport.hpp')
-rw-r--r--src/protocols/ToplevelExport.hpp71
1 files changed, 28 insertions, 43 deletions
diff --git a/src/protocols/ToplevelExport.hpp b/src/protocols/ToplevelExport.hpp
index 44704d84..38dec784 100644
--- a/src/protocols/ToplevelExport.hpp
+++ b/src/protocols/ToplevelExport.hpp
@@ -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);
-
- bool good();
+ CToplevelExportFrame(SP<CHyprlandToplevelExportFrameV1> resource, WP<Screenshare::CScreenshareSession> session, bool overlayCursor);
- 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;
+
+ WP<Screenshare::CScreenshareSession> m_session;
+ UP<Screenshare::CScreenshareFrame> m_frame;
- PHLWINDOW m_window;
- bool m_cursorOverlayRequested = false;
- bool m_ignoreDamage = false;
+ CHLBufferReference m_buffer;
+ Time::steady_tp m_timestamp;
- CHLBufferReference m_buffer;
- bool m_bufferDMA = false;
- uint32_t m_shmFormat = 0;
- uint32_t m_dmabufFormat = 0;
- int m_shmStride = 0;
- CBox m_box = {};
+ struct {
+ CHyprSignalListener stopped;
+ } m_listeners;
- 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;
+ 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;
};