Send the clipboard over the libportal InputCapture portal. Only built if the installed libportal has clipboard support. AI disclosure: Claude was used on both sides of this work. - Peter Hutterer: "The second commit was purely written by Claude after I stared at this for too long without seeing any hope of getting started. Turns out Claude wrote something that at least looks correct and it does work. It needs review but also needs knowledge of deskflow's internals that I don't have..." - Nick Bolton: Claude also assisted with the follow-up work listed below (image copy/paste, session re-request, race fixes, size/mime validation, and CMake detection). Server side (Wayland host, Peter Hutterer): - Initial scaffolding for inputcapture clipboard support, guarded so it only builds when the portal exposes the clipboard API. - Integrate clipboard data into the inputcapture session so the host clipboard can be offered to the remote (the Claude-written commit referenced above). Client side (Wayland receiver, KoljaFrahm): - Receive clipboard data from the server and feed it into the local clipboard through libportal. Built on the reference code by Peter: https://github.com/whot/libportal-clipboard-test/tree/main Build integration and rebase (Chris Rizzitello, sithlord48): - Add the original CMake check for libportal/clipboard.h to define HAVE_LIBPORTAL_CLIPBOARD, and guard the libportal clipboard use on it. - Update the code style and rebase onto the updated input capture session persistence: https://github.com/deskflow/deskflow/pull/9415 Image support and reliability fixes (Nick Bolton): - Support image copy/paste in addition to text, so screenshots and other image clipboard contents work both ways through inputcapture. - Re-request the input capture session when it comes up without a clipboard, so new testers with existing sessions can get clipboard functionality without needing to clear the session. - Defer clipboard reads until the input capture session is active, avoiding races where reads happen before the portal is ready. - Fix assorted style issues in original commit to match conventions. - Check the configured clipboard size limit and validate incoming mime types before forwarding inputcapture clipboard data. - Switch the CMake clipboard probe to check_symbol_exists so detection matches what the compiler actually sees in the headers. Co-authored-by: Nick Bolton <nick@symless.com> Co-authored-by: KoljaFrahm <GitHub.Kolja@dfgh.net> Co-authored-by: Chris Rizzitello <sithlord48@gmail.com>
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
/*
|
|
* Deskflow -- mouse and keyboard sharing utility
|
|
* SPDX-FileCopyrightText: (C) 2026 Red Hat, Inc.
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "deskflow/ClipboardTypes.h"
|
|
#include "deskflow/IClipboard.h"
|
|
|
|
namespace deskflow {
|
|
|
|
//! EI/Portal clipboard implementation
|
|
/*!
|
|
This class implements a clipboard for EI (libei) and portal-based input capture.
|
|
It stores clipboard data in memory for the specified clipboard ID.
|
|
*/
|
|
class EiClipboard : public IClipboard
|
|
{
|
|
public:
|
|
explicit EiClipboard(ClipboardID id);
|
|
~EiClipboard() override = default;
|
|
|
|
//! Get clipboard ID
|
|
ClipboardID getID() const
|
|
{
|
|
return m_id;
|
|
}
|
|
|
|
//! @name IClipboard overrides
|
|
//@{
|
|
bool empty() override;
|
|
void add(Format, const std::string &data) override;
|
|
bool open(Time) const override;
|
|
void close() const override;
|
|
Time getTime() const override;
|
|
bool has(Format) const override;
|
|
std::string get(Format) const override;
|
|
//@}
|
|
|
|
private:
|
|
ClipboardID m_id;
|
|
mutable bool m_open = false;
|
|
mutable Time m_time = 0;
|
|
bool m_owner = false;
|
|
Time m_timeOwned = 0;
|
|
bool m_added[static_cast<int>(Format::TotalFormats)] = {false, false, false};
|
|
std::string m_data[static_cast<int>(Format::TotalFormats)] = {"", "", ""};
|
|
};
|
|
|
|
} // namespace deskflow
|