summaryrefslogtreecommitdiff
path: root/vdagent/vdagent.cpp
diff options
context:
space:
mode:
authorArnon Gilboa <agilboa@redhat.com>2012-11-27 11:14:24 +0200
committerArnon Gilboa <agilboa@redhat.com>2012-12-09 11:24:27 +0200
commit9b5954165d1726a556706dd375e5c13b80fd36c9 (patch)
tree86b4086818be130d1c80cf491247d6302c01318e /vdagent/vdagent.cpp
parentc18859ff35c439985a6134c71e35861dd71b186e (diff)
vdagent: when SetClipboardData fails, set clipboard control event to stop wait
Currently, a SetClipboardData failure is followed by useless wait for timeout (VD_CLIPBOARD_TIMEOUT_MS). In addition, we remove the clipboard open-empty-set-close retry, which became irrelevant with the current on_clipboard_request().
Diffstat (limited to 'vdagent/vdagent.cpp')
-rw-r--r--vdagent/vdagent.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 3f1053d..2bb466d 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -643,12 +643,10 @@ bool VDAgent::handle_clipboard(VDAgentClipboard* clipboard, uint32_t size)
if (_clipboard_owner != owner_client) {
vd_printf("Received clipboard data from client while clipboard is not owned by client");
- set_control_event(CONTROL_CLIPBOARD);
- return false;
+ goto fin;
}
if (clipboard->type == VD_AGENT_CLIPBOARD_NONE) {
- set_control_event(CONTROL_CLIPBOARD);
- return false;
+ goto fin;
}
switch (clipboard->type) {
case VD_AGENT_CLIPBOARD_UTF8_TEXT:
@@ -664,20 +662,24 @@ bool VDAgent::handle_clipboard(VDAgentClipboard* clipboard, uint32_t size)
}
default:
vd_printf("Unsupported clipboard type %u", clipboard->type);
- return true;
+ goto fin;
}
format = get_clipboard_format(clipboard->type);
- if (SetClipboardData(format, clip_data)) {
- set_control_event(CONTROL_CLIPBOARD);
- return true;
- }
- // We retry clipboard open-empty-set-close only when there is a timeout in on_clipboard_request()
- if (!OpenClipboard(_hwnd)) {
- return false;
+ if (format == 0) {
+ vd_printf("Unknown clipboard format, type %u", clipboard->type);
+ goto fin;
}
- EmptyClipboard();
ret = !!SetClipboardData(format, clip_data);
- CloseClipboard();
+ if (!ret) {
+ DWORD err = GetLastError();
+ if (err == ERROR_NOT_ENOUGH_MEMORY) {
+ vd_printf("Not enough memory to set clipboard data, size %u bytes", size);
+ } else {
+ vd_printf("SetClipboardData failed: %u", err);
+ }
+ }
+fin:
+ set_control_event(CONTROL_CLIPBOARD);
return ret;
}