From 8a160078d0852ff5a2f8ec438cec1b18858e3c5d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 2 Oct 2010 16:29:36 +0200 Subject: Keep track of clipboard ownership Given that all clipboard handling is async, it is possible to for example receive a request for clipboard data from the agent while the client no longer owns the clipboard (ie a VD_AGENT_CLIPBOARD_RELEASE message is in transit to the agent). Thus it is necessary to keep track of our notion of clipboard ownership and check received clipboard messages (both from other apps on the client machine and from the agent) to see if they match our notion and if not drop, or in case were a counter message is expected nack the clipboard message. --- client/windows/platform.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'client/windows/platform.cpp') diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp index db6d18ab..db47079d 100644 --- a/client/windows/platform.cpp +++ b/client/windows/platform.cpp @@ -54,6 +54,7 @@ public: virtual void on_clipboard_grab(uint32_t *types, uint32_t type_count) {} virtual void on_clipboard_request(uint32_t type) {} virtual void on_clipboard_notify(uint32_t type, uint8_t* data, int32_t size) {} + virtual void on_clipboard_release() {} }; static DefaultClipboardListener default_clipboard_listener; @@ -856,6 +857,18 @@ void WinPlatform::exit_modal_loop() modal_loop_active = false; } +int Platform::_clipboard_owner = Platform::owner_none; + +void Platform::set_clipboard_owner(int new_owner) +{ + if (new_owner == owner_none) { + clipboard_listener->on_clipboard_release(); + + /* FIXME clear cached clipboard type info and data */ + } + _clipboard_owner = new_owner; +} + bool Platform::on_clipboard_grab(uint32_t *types, uint32_t type_count) { /* FIXME use all types rather then just the first one */ -- cgit