[Spice-devel] [PATCH] vdagent: remove clipboard_changer hack

Arnon Gilboa agilboa at redhat.com
Wed Oct 6 07:41:44 PDT 2010


Instead of keeping a flag, we simply check wether the new owner is usor not
---
 vdagent/vdagent.cpp |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 32ad102..6c5f73a 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -83,7 +83,6 @@ private:
     static VDAgent* _singleton;
     HWND _hwnd;
     HWND _hwnd_next_viewer;
-    bool _clipboard_changer;
     int _clipboard_owner;
     DWORD _buttons_state;
     LONG _mouse_x;
@@ -128,7 +127,6 @@ VDAgent* VDAgent::get()
 VDAgent::VDAgent()
     : _hwnd (NULL)
     , _hwnd_next_viewer (NULL)
-    , _clipboard_changer (true)
     , _clipboard_owner (owner_none)
     , _buttons_state (0)
     , _mouse_x (0)
@@ -875,7 +873,6 @@ bool VDAgent::handle_clipboard_grab(VDAgentClipboardGrab* clipboard_grab)
     if (!OpenClipboard(_hwnd)) {
         return false;
     }
-    _clipboard_changer = true;
     EmptyClipboard();
     SetClipboardData(format, NULL);
     CloseClipboard();
@@ -1199,12 +1196,13 @@ LRESULT CALLBACK VDAgent::wnd_proc(HWND hwnd, UINT message, WPARAM wparam, LPARA
         }
         break;
     case WM_DRAWCLIPBOARD:
-        if (!a->_clipboard_changer) {
+        if (a->_hwnd != GetClipboardOwner()) {
+            a->set_clipboard_owner(a->owner_none);
             a->on_clipboard_grab();
-        } else {
-            a->_clipboard_changer = false;
         }
-        SendMessage(a->_hwnd_next_viewer, message, wparam, lparam);
+        if (a->_hwnd_next_viewer) {
+            SendMessage(a->_hwnd_next_viewer, message, wparam, lparam);
+        }
         break;
     case WM_RENDERFORMAT:
         a->on_clipboard_request((UINT)wparam);
-- 
1.5.5.6



More information about the Spice-devel mailing list