Alexandre Julliard : winex11: Implement the UpdateClipboard entry point to refresh the cache.

Alexandre Julliard julliard at winehq.org
Fri Sep 23 10:25:16 CDT 2016


Module: wine
Branch: master
Commit: adf96003a50a42b074ddb8c33c79052414d73db4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=adf96003a50a42b074ddb8c33c79052414d73db4

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Sep 23 14:07:59 2016 +0900

winex11: Implement the UpdateClipboard entry point to refresh the cache.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/clipboard.c      | 74 +++++++++++----------------------------
 dlls/winex11.drv/winex11.drv.spec |  1 +
 2 files changed, 22 insertions(+), 53 deletions(-)

diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index 9e1c8a3..cc4f92f 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -95,6 +95,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(clipboard);
 #define SELECTION_RETRIES 500  /* wait for .5 seconds */
 #define SELECTION_WAIT    1000 /* us */
 
+#define SELECTION_UPDATE_DELAY 2000   /* delay between checks of the X11 selection */
+
 /* Selection masks */
 #define S_NOSELECTION    0
 #define S_PRIMARY        1
@@ -224,10 +226,6 @@ static unsigned int nb_current_x11_formats;
 static struct list data_list = LIST_INIT( data_list );
 static UINT ClipDataCount = 0;
 
-/*
- * Clipboard sequence number
- */
-static UINT wSeqNo = 0;
 
 /**************************************************************************
  *                Internal Clipboard implementation methods
@@ -587,39 +585,6 @@ static void X11DRV_CLIPBOARD_FreeData(LPWINE_CLIPDATA lpData)
 
 
 /**************************************************************************
- *			X11DRV_CLIPBOARD_UpdateCache
- */
-static BOOL X11DRV_CLIPBOARD_UpdateCache(void)
-{
-    BOOL bret = TRUE;
-
-    if (!selectionAcquired)
-    {
-        DWORD seqno = GetClipboardSequenceNumber();
-
-        if (!seqno)
-        {
-            ERR("Failed to retrieve clipboard information.\n");
-            bret = FALSE;
-        }
-        else if (wSeqNo < seqno)
-        {
-            empty_clipboard();
-
-            if (X11DRV_CLIPBOARD_QueryAvailableData(thread_init_display()) < 0)
-            {
-                ERR("Failed to cache clipboard data owned by another process.\n");
-                bret = FALSE;
-            }
-            wSeqNo = seqno;
-        }
-    }
-
-    return bret;
-}
-
-
-/**************************************************************************
  *			X11DRV_CLIPBOARD_RenderFormat
  */
 static BOOL X11DRV_CLIPBOARD_RenderFormat(Display *display, LPWINE_CLIPDATA lpData)
@@ -2379,8 +2344,6 @@ void CDECL X11DRV_EmptyClipboard(void)
  */
 BOOL CDECL X11DRV_SetClipboardData(UINT wFormat, HANDLE hData, BOOL owner)
 {
-    if (!owner) X11DRV_CLIPBOARD_UpdateCache();
-
     return X11DRV_CLIPBOARD_InsertClipboardData( wFormat, hData );
 }
 
@@ -2390,10 +2353,6 @@ BOOL CDECL X11DRV_SetClipboardData(UINT wFormat, HANDLE hData, BOOL owner)
  */
 INT CDECL X11DRV_CountClipboardFormats(void)
 {
-    X11DRV_CLIPBOARD_UpdateCache();
-
-    TRACE(" count=%d\n", ClipDataCount);
-
     return ClipDataCount;
 }
 
@@ -2405,10 +2364,6 @@ UINT CDECL X11DRV_EnumClipboardFormats(UINT wFormat)
 {
     struct list *ptr = NULL;
 
-    TRACE("(%04X)\n", wFormat);
-
-    X11DRV_CLIPBOARD_UpdateCache();
-
     if (!wFormat)
     {
         ptr = list_head( &data_list );
@@ -2431,10 +2386,6 @@ BOOL CDECL X11DRV_IsClipboardFormatAvailable(UINT wFormat)
 {
     BOOL bRet = FALSE;
 
-    TRACE("(%04X)\n", wFormat);
-
-    X11DRV_CLIPBOARD_UpdateCache();
-
     if (wFormat != 0 && X11DRV_CLIPBOARD_LookupData(wFormat))
         bRet = TRUE;
 
@@ -2453,8 +2404,6 @@ HANDLE CDECL X11DRV_GetClipboardData(UINT wFormat)
 
     TRACE("(%04X)\n", wFormat);
 
-    X11DRV_CLIPBOARD_UpdateCache();
-
     if ((lpRender = X11DRV_CLIPBOARD_LookupData(wFormat)))
     {
         if ( !lpRender->hData )
@@ -2469,6 +2418,25 @@ HANDLE CDECL X11DRV_GetClipboardData(UINT wFormat)
 
 
 /**************************************************************************
+ *		X11DRV_UpdateClipboard
+ */
+void CDECL X11DRV_UpdateClipboard(void)
+{
+    static ULONG last_update;
+    ULONG now;
+
+    if (selectionAcquired) return;
+    now = GetTickCount();
+    if ((int)(now - last_update) <= SELECTION_UPDATE_DELAY) return;
+    last_update = now;
+
+    empty_clipboard();
+    if (X11DRV_CLIPBOARD_QueryAvailableData(thread_init_display()) < 0)
+        ERR("Failed to cache clipboard data owned by another process.\n");
+}
+
+
+/**************************************************************************
  *		ResetSelectionOwner
  *
  * Called when the thread owning the selection is destroyed and we need to
diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec
index 54afd83..a3e847c 100644
--- a/dlls/winex11.drv/winex11.drv.spec
+++ b/dlls/winex11.drv/winex11.drv.spec
@@ -47,6 +47,7 @@
 @ cdecl SetWindowText(long wstr) X11DRV_SetWindowText
 @ cdecl ShowWindow(long long ptr long) X11DRV_ShowWindow
 @ cdecl SysCommand(long long long) X11DRV_SysCommand
+@ cdecl UpdateClipboard() X11DRV_UpdateClipboard
 @ cdecl UpdateLayeredWindow(long ptr ptr) X11DRV_UpdateLayeredWindow
 @ cdecl WindowMessage(long long long long) X11DRV_WindowMessage
 @ cdecl WindowPosChanging(long long long ptr ptr ptr ptr) X11DRV_WindowPosChanging




More information about the wine-cvs mailing list