From 9b00e93efb197bb215390d9f96204a9f20ffb262 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 6 Oct 2010 18:54:31 +0200 Subject: spicec: don't send agent messages directly from ClipboardListener callbacks ClipboardListener callbacks can run from another thread then the main channel loop thread, where agent messages are normally dispatched from. So they may not send agent messages directly, instead they should post events to the main channel loop. --- client/red_client.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'client/red_client.cpp') diff --git a/client/red_client.cpp b/client/red_client.cpp index 0650e35a..cf2ee354 100644 --- a/client/red_client.cpp +++ b/client/red_client.cpp @@ -101,6 +101,21 @@ void ClipboardRequestEvent::response(AbstractProcessLoop& events_loop) VD_AGENT_CLIPBOARD_REQUEST, sizeof(request), &request); } +void ClipboardNotifyEvent::response(AbstractProcessLoop& events_loop) +{ + static_cast(events_loop.get_owner())->send_agent_clipboard_notify_message( + _type, _data, _size); +} + +void ClipboardReleaseEvent::response(AbstractProcessLoop& events_loop) +{ + if (Platform::get_clipboard_owner() != Platform::owner_client) + return; + + static_cast(events_loop.get_owner())->send_agent_clipboard_message( + VD_AGENT_CLIPBOARD_RELEASE, 0, NULL); +} + Migrate::Migrate(RedClient& client) : _client (client) , _running (false) @@ -860,6 +875,18 @@ void RedClient::on_clipboard_request(uint32_t type) } void RedClient::on_clipboard_notify(uint32_t type, uint8_t* data, int32_t size) +{ + AutoRef event(new ClipboardNotifyEvent(type, data, size)); + get_process_loop().push_event(*event); +} + +void RedClient::on_clipboard_release() +{ + AutoRef event(new ClipboardReleaseEvent()); + get_process_loop().push_event(*event); +} + +void RedClient::send_agent_clipboard_notify_message(uint32_t type, uint8_t *data, uint32_t size) { ASSERT(size && data); if (!_agent_connected) { @@ -892,12 +919,6 @@ void RedClient::on_clipboard_notify(uint32_t type, uint8_t* data, int32_t size) } } -void RedClient::on_clipboard_release() -{ - if (Platform::get_clipboard_owner() == Platform::owner_client) - send_agent_clipboard_message(VD_AGENT_CLIPBOARD_RELEASE, 0, NULL); -} - void RedClient::set_mouse_mode(uint32_t supported_modes, uint32_t current_mode) { if (current_mode != _mouse_mode) { -- cgit