From 5781c97a1751e8e889b30dcce4641fb30508e072 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 2 Oct 2010 12:46:26 +0200 Subject: Move checking for on demand clipboard cap closer to sending of agent messages 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 file changed, 10 insertions(+), 8 deletions(-) (limited to 'client/red_client.cpp') diff --git a/client/red_client.cpp b/client/red_client.cpp index 99e79a50..666de40c 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 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 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; -- cgit