[Spice-devel] [PATCH spice 07/17] Move checking for on demand clipboard cap closer to sending of agent messages

Hans de Goede hdegoede at redhat.com
Mon Oct 4 03:34:58 PDT 2010


This way the events will always get generated and other things
(such as clipboard ownership administration, see the next patches)
can be done in repsonse to the events, even though no message will be send.

This patch also removes the !_agent_caps check from the capability
checks, this is not needed as VD_AGENT_HAS_CAPABILITY checks _agent_caps_size
which will be 0 when _agent_caps is NULL.
---
 client/red_client.cpp |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/client/red_client.cpp b/client/red_client.cpp
index 99e79a5..666de40 100644
--- a/client/red_client.cpp
+++ b/client/red_client.cpp
@@ -818,6 +818,13 @@ void RedClient::do_send_agent_clipboard()
 
 void RedClient::send_agent_clipboard_message(uint32_t message_type, uint32_t size, void* data)
 {
+    if (!_agent_connected)
+        return;
+
+    if (!VD_AGENT_HAS_CAPABILITY(_agent_caps, _agent_caps_size,
+                                 VD_AGENT_CAP_CLIPBOARD_BY_DEMAND))
+        return;
+
     Message* message = new Message(SPICE_MSGC_MAIN_AGENT_DATA);
     VDAgentMessage* msg = (VDAgentMessage*)
       spice_marshaller_reserve_space(message->marshaller(), sizeof(VDAgentMessage) + size);
@@ -835,20 +842,12 @@ void RedClient::send_agent_clipboard_message(uint32_t message_type, uint32_t siz
 
 void RedClient::on_clipboard_grab(uint32_t *types, uint32_t type_count)
 {
-    if (!_agent_caps || !VD_AGENT_HAS_CAPABILITY(_agent_caps, _agent_caps_size,
-                                                 VD_AGENT_CAP_CLIPBOARD_BY_DEMAND)) {
-        return;
-    }
     AutoRef<ClipboardGrabEvent> event(new ClipboardGrabEvent(types, type_count));
     get_process_loop().push_event(*event);
 }
 
 void RedClient::on_clipboard_request(uint32_t type)
 {
-    if (!_agent_caps || !VD_AGENT_HAS_CAPABILITY(_agent_caps, _agent_caps_size,
-                                                 VD_AGENT_CAP_CLIPBOARD_BY_DEMAND)) {
-        return;
-    }
     AutoRef<ClipboardRequestEvent> event(new ClipboardRequestEvent(type));
     get_process_loop().push_event(*event);
 }
@@ -859,6 +858,9 @@ void RedClient::on_clipboard_notify(uint32_t type, uint8_t* data, int32_t size)
     if (!_agent_connected) {
         return;
     }
+    if (!VD_AGENT_HAS_CAPABILITY(_agent_caps, _agent_caps_size,
+                                 VD_AGENT_CAP_CLIPBOARD_BY_DEMAND))
+        return;
     if (_agent_out_msg) {
         DBG(0, "clipboard change is already pending");
         return;
-- 
1.7.2.2



More information about the Spice-devel mailing list