From bafc1193ee70de2acb417322930277d19677bc5a Mon Sep 17 00:00:00 2001 From: Caoimhe Date: Tue, 23 May 2023 19:40:19 +0100 Subject: [PATCH] SpiceAgent: Don't send ClipboardGrab if the shared clipboard is disabled The spice server will ignore any clipboard-related messages if we don't have the appropriate capabilities, but I think it's better for us to do less CPU churning whenever the user copies something to their clipboard. It also stops the spice server from warning in the console about a clipboard grab message being recieved when the capability was never announced. --- Userland/Services/SpiceAgent/SpiceAgent.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Services/SpiceAgent/SpiceAgent.cpp b/Userland/Services/SpiceAgent/SpiceAgent.cpp index 895c6753d6..ff06168fef 100644 --- a/Userland/Services/SpiceAgent/SpiceAgent.cpp +++ b/Userland/Services/SpiceAgent/SpiceAgent.cpp @@ -53,6 +53,12 @@ ErrorOr SpiceAgent::start() ErrorOr SpiceAgent::on_clipboard_update(String const& mime_type) { + // NOTE: If we indicate that we don't support clipboard by demand, the spice server will ignore our messages, + // but it will do some ugly debug logging.. so let's just not send anything instead. + if (!m_capabilities.contains_slow(Capability::ClipboardByDemand)) { + return {}; + } + // If we just copied something to the clipboard, we shouldn't do anything here. if (m_clipboard_dirty) { m_clipboard_dirty = false;