winex11.drv: Add TIMESTAMP to X clipboard TARGETS

Andrey Vostrikov andrey.vostrikov at cogentembedded.com
Tue Oct 29 04:13:40 CDT 2013


Hi,

This patch fixes issue I have encountered while copy-pasting text from 
wine application to VMWare guest OS.

It seems that VMWare verifies that clipboard data is most recent before 
pasting it from buffer into guest OS.
So, when some text from clipboard with TIMESTAMP target was pasted into 
VMWare guest OS it caches last timestamp value and associated text.
When you copy some text from wine app to X clipboard and try to paste it 
into VMWare guest OS cached data is pasted, because clipboard targets 
list coming from wine does not contain TIMESTAMP.

There is no problem to paste latest clipboard text into other native 
Linux app, copy it again into clipboard and paste into guest OS.

Changes were tested on OpenSUSE 12.3 x64 VMWare Player 5.0.1 with 
Windows XP, Windows 7 x64, Ubuntu 10.04 LTS x64 guest OSes.

Best regards,
Andrey
-------------- next part --------------
>From 2597be2c3b5bedd4384c0df67fea4d2a2e45d9b0 Mon Sep 17 00:00:00 2001
From: Andrey Vostrikov <av.linux.dev at gmail.com>
Date: Tue, 29 Oct 2013 12:42:13 +0400
Subject: winex11.drv: Add TIMESTAMP to clipboard TARGETS

---
 dlls/winex11.drv/clipboard.c   |    9 ++++++++-
 dlls/winex11.drv/x11drv.h      |    1 +
 dlls/winex11.drv/x11drv_main.c |    1 +
 3 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index 730b6c9..da2f6d1 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -3017,7 +3017,7 @@ static Atom X11DRV_SelectionRequest_TARGETS( Display *display, Window requestor,
     /*
      * Count the number of items we wish to expose as selection targets.
      */
-    cTargets = 1; /* Include TARGETS */
+    cTargets = 2; /* Include TARGETS and TIMESTAMP by default */
 
     if (!list_head( &data_list )) return None;
 
@@ -3036,6 +3036,7 @@ static Atom X11DRV_SelectionRequest_TARGETS( Display *display, Window requestor,
 
     i = 0;
     targets[i++] = x11drv_atom(TARGETS);
+    targets[i++] = x11drv_atom(TIMESTAMP);
 
     LIST_FOR_EACH_ENTRY( lpData, &data_list, WINE_CLIPDATA, entry )
         LIST_FOR_EACH_ENTRY( format, &format_list, WINE_CLIPFORMAT, entry )
@@ -3211,6 +3212,12 @@ static void X11DRV_HandleSelectionRequest( HWND hWnd, XSelectionRequestEvent *ev
         /* TARGETS selection request */
         rprop = X11DRV_SelectionRequest_TARGETS( display, request, event->target, rprop );
     }
+    else if(event->target == x11drv_atom(TIMESTAMP))  /*  Return event timestamp */
+    {
+        /* TIMESTAMP selection request */
+        XChangeProperty(display, request, rprop, event->target,
+                        32, PropModeReplace, (unsigned char*)&event->time, 1);
+    }
     else if(event->target == x11drv_atom(MULTIPLE))  /*  rprop contains a list of (target, property) atom pairs */
     {
         /* MULTIPLE selection request */
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 98386ce..64cec1f 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -398,6 +398,7 @@ enum x11drv_atoms
     XATOM_SELECTION_DATA,
     XATOM_TARGETS,
     XATOM_TEXT,
+    XATOM_TIMESTAMP,
     XATOM_UTF8_STRING,
     XATOM_RAW_ASCENT,
     XATOM_RAW_DESCENT,
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index a6572ba..b9e1883 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -111,6 +111,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
     "SELECTION_DATA",
     "TARGETS",
     "TEXT",
+    "TIMESTAMP",
     "UTF8_STRING",
     "RAW_ASCENT",
     "RAW_DESCENT",
-- 
1.7.0.1



More information about the wine-patches mailing list