public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
* "Paste" from clipboard can failed (XWin bug)
@ 2010-09-30 14:28 rolandc
  2010-10-23 17:11 ` Jon TURNEY
  0 siblings, 1 reply; 4+ messages in thread
From: rolandc @ 2010-09-30 14:28 UTC (permalink / raw)
  To: cygwin-xfree

[-- Attachment #1: Type: text/plain, Size: 2983 bytes --]

Hi,

>From X application, I select some text. I switch on Windows
application and I try to paste the text.
I do "Ctrl-V" => nothing happens
I do a second "Ctrl-V" => the text is pasted

This problem depends on the X application

When a "paste" occurs, XWin receives a WM_RENDERFORMAT message :
(cf. winClipboardWindowProc())

step 1/ XWin try to get the selection in COMPOUND_TEXT format
    (cf. winProcessXEventsTimeout() calls XConvertSelection("COMPOUND_TEXT "))

step 2/ If the owner of the selection (the X app) can't handle
COMPOUND_TEXT format, XWin try to get the selection in UTF8_STRING
format
    (cf. winClipboardFlushXEvents(), on receive an SelectionNotify
event with "event.xselection.property == None", XWin calls
XConvertSelection("UTF8_STRING"))

step 3/ If the owner of the selection (the X app) can't handle
UTF8_STRING format, XWin try to get the selection in XA_STRING format
    (cf. winClipboardFlushXEvents(), on receive an SelectionNotify
event with "event.xselection.property == None", XWin calls
XConvertSelection("XA_STRING"))

But there is a bug in XWin :
XWin calls winProcessXEventsTimeout() only twice. If the X app handles
only handles XA_STRING format, the "step 3" is never invoked !
As the result, XWin can't get "paste data" and log the message:
    "winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY"


XWin.log with my comment:
...
(receive WM_RENDER_FORMAT message)
winClipboardWindowProc - WM_RENDER*FORMAT - Hello.
(call XConvertSelection("COMPOUND_TEXT "))
(first call winProcessXEventsTimeout())
winClipboardFlushXEvents - SelectionNotify
winClipboardFlushXEvents - SelectionNotify - ATOM: PRIMARY
(receive event.xselection.target == atomCompoundText aka COMPOUND_TEXT)
(the X app can't handle COMPOUND_TEXT format)
winClipboardFlushXEvents - SelectionNotify - Requesting conversion of
CompoundText target.
(call XConvertSelection("UTF8_STRING") and return)
(second call winProcessXEventsTimeout())
winClipboardFlushXEvents - SelectionNotify
winClipboardFlushXEvents - SelectionNotify - ATOM: PRIMARY
(receive event.xselection.target == atomUTF8String aka UTF8_STRING)
(the X app can't handle UTF8_STRING format)
winClipboardFlushXEvents - SelectionNotify - Requesting conversion of
UTF8 target.
(call XConvertSelection("XA_STRING") and return)
(XWin can't get paste data, also it logs an error :)
(and reset the clipboard => SetClipboardData (CF_UNICODETEXT,
NULL);SetClipboardData (CF_TEXT, NULL);)
winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY
...

Solution 1 :
Call a third time the function winProcessXEventsTimeout()
(see paste_bug_solution1.patch file attached)
but this is not a very elegant solution ...

Solution 2 :
call winProcessXEventsTimeout() only one time
winProcessXEventsTimeout() must process all notification until
* time out expired
* getting the paste data
* error occurred
(see paste_bug_solution2.patch file attached)

note: the actual timeout is set to 1 second.

Greetings,

[-- Attachment #2: paste_bug_solution1.patch --]
[-- Type: application/octet-stream, Size: 709 bytes --]

diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c
old mode 100644
new mode 100755
index 9394b04..204eacc
--- a/hw/xwin/winclipboardwndproc.c
+++ b/hw/xwin/winclipboardwndproc.c
@@ -521,6 +521,19 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 						pDisplay,
 						fConvertToUnicode,
 						WIN_POLL_TIMEOUT);
+		if (WIN_XEVENTS_CONVERT == iReturn)
+		{
+			/*
+			* The selection was offered for conversion first, so we have
+			* to process a second SelectionNotify event to get the actual
+			* data in the selection.
+			*/
+			iReturn = winProcessXEventsTimeout (hwnd,
+						iWindow,
+						pDisplay,
+						fConvertToUnicode,
+						WIN_POLL_TIMEOUT);
+		}
 	  }
 	
 	/*

[-- Attachment #3: paste_bug_solution2.patch --]
[-- Type: application/octet-stream, Size: 1572 bytes --]

diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c
old mode 100644
new mode 100755
index 9394b04..18287b7
--- a/hw/xwin/winclipboardwndproc.c
+++ b/hw/xwin/winclipboardwndproc.c
@@ -42,7 +42,6 @@
  * Constants
  */
 
-#define WIN_CLIPBOARD_PROP	"cyg_clipboard_prop"
 #define WIN_POLL_TIMEOUT	1
 
 
@@ -126,10 +125,9 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
 					      iWindow,
 					      pDisplay,
 					      fUseUnicode);
-	  if (WIN_XEVENTS_NOTIFY == iReturn
-	      || WIN_XEVENTS_CONVERT == iReturn)
+	  if (WIN_XEVENTS_NOTIFY == iReturn)
 	    {
-	      /* Bail out if convert or notify processed */
+	      /* Bail out if notify processed */
 	      return iReturn;
 	    }
 	}
@@ -509,22 +507,9 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 					    pDisplay,
 					    fConvertToUnicode,
 					    WIN_POLL_TIMEOUT);
-	if (WIN_XEVENTS_CONVERT == iReturn)
-	  {
-	    /*
-	     * The selection was offered for conversion first, so we have
-	     * to process a second SelectionNotify event to get the actual
-	     * data in the selection.
-	     */
-	    iReturn = winProcessXEventsTimeout (hwnd,
-						iWindow,
-						pDisplay,
-						fConvertToUnicode,
-						WIN_POLL_TIMEOUT);
-	  }
-	
+
 	/*
-	 * The last of the up-to two calls to winProcessXEventsTimeout
+	 * The last call to winProcessXEventsTimeout
 	 * from above had better have seen a notify event, or else we
 	 * are dealing with a buggy or old X11 app.  In these cases we
 	 * have to paste some fake data to the Win32 clipboard to

[-- Attachment #4: Type: text/plain, Size: 223 bytes --]

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-18 13:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-30 14:28 "Paste" from clipboard can failed (XWin bug) rolandc
2010-10-23 17:11 ` Jon TURNEY
2010-10-28  8:05   ` rolandc
2011-10-18 13:15   ` Enoksrd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).