http://bugs.winehq.org/show_bug.cgi?id=15122
Summary: Clipboard functions don't work in console applications Product: Wine Version: CVS/GIT Platform: All OS/Version: All Status: UNCONFIRMED Severity: normal Priority: P2 Component: winex11.drv AssignedTo: wine-bugs@winehq.org ReportedBy: dmitry@zend.com
Created an attachment (id=15827) --> (http://bugs.winehq.org/attachment.cgi?id=15827) proposed patch
My favorite console file manager FAR (http://www.farmanager.com/) almost work under wineconsole except for clipboard operations (<Ctrl-Ins>, <Shift-Ins> in FAR's internal editor and command line).
I run it with the following command on Fedora-8/x86.
$ wineconsole --backend=user ~/.wine/drive_c/Program\ Files/FAR/Far.exe
The reason of the problem is loss of SelectionRequest/SelectionClear X11 events.
I've attached a patch which fixes the problem. May be it looks like a hack, but anyway it can help to fix the problem in better way.
It would be nice to have the problem fixed in next Wine release.
http://bugs.winehq.org/show_bug.cgi?id=15122
Dmitry Timoshkov dmitry@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- OS/Version|All |other Platform|All |Other
http://bugs.winehq.org/show_bug.cgi?id=15122
Dmitry Timoshkov dmitry@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|winex11.drv |-unknown
--- Comment #1 from Dmitry Timoshkov dmitry@codeweavers.com 2008-09-04 08:56:04 --- If the component is winex11.drv why did you add other changes?
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #2 from Dmitry Stogov dmitry@zend.com 2008-09-04 09:04:29 --- The components are "winex11.drv" and "kernel32", but Bugzilla doesn't allow to specify both.
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #3 from Dmitry Timoshkov dmitry@codeweavers.com 2008-09-04 09:48:21 --- Why do you need the kernel32 changes?
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #4 from Dmitry Stogov dmitry@zend.com 2008-09-04 10:36:11 --- X11 clipboard events are processed by X11DRV_MsgWaitForMultipleObjectsEx() but it is not called by console applications which use kernel32 functions to get keyboard input (PeekConsoleInput/ReadConsoleInput).
http://bugs.winehq.org/show_bug.cgi?id=15122
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch
--- Comment #5 from Austin English austinenglish@gmail.com 2008-09-04 14:59:48 --- patches should be submitted to wine-patches@winehq.org
http://bugs.winehq.org/show_bug.cgi?id=15122
Sergiy Zuban s.zuban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |s.zuban@gmail.com
--- Comment #6 from Sergiy Zuban s.zuban@gmail.com 2008-12-08 09:55:09 --- bug still exists in 1.1.10 and it reflects on Thunderbird (at least for 2.0.0.17-18) functionality.
Steps to reproduce: 1. copy to clipboard something in Far manager 2. try to compose new message (or reply to existing one) in Thunderbird 3. you'll notice that Thunderbird freezes for about 5 seconds 4. then, anytime you tries to past from clipboard to message editor you'll see the same 5-6 seconds freezing.
To avoid freezing I have to always copy something (from application running not under wine) to clipboard and only after that reply to message. I have no idea why it reflects on Thunderbird only.
http://bugs.winehq.org/show_bug.cgi?id=15122
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #7 from Dmitry Stogov dmitry@zend.com 2009-01-12 03:08:01 --- Any chance of applying the proposed patch?
http://bugs.winehq.org/show_bug.cgi?id=15122
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|CVS/GIT |unspecified
--- Comment #8 from Austin English austinenglish@gmail.com 2009-01-20 02:40:13 --- Removing deprecated CVS/GIT version tag. Please retest in current git. If the bug is still present in today's wine, but was not present in some earlier version of wine, please update version field to earliest known version of wine that had the bug. Thanks!
http://bugs.winehq.org/show_bug.cgi?id=15122
Dmitry Stogov dmitry@zend.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |1.1.13
--- Comment #9 from Dmitry Stogov dmitry@zend.com 2009-01-20 08:15:23 --- The bug exists in the latest release (1.1.13) as well as in CVS/GIT HEAD.
http://bugs.winehq.org/show_bug.cgi?id=15122
Dmitry Timoshkov dmitry@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|1.1.13 |unspecified
--- Comment #10 from Dmitry Timoshkov dmitry@codeweavers.com 2009-01-20 10:48:45 --- The bug is supposed to have an original Wine version it was reported for.
http://bugs.winehq.org/show_bug.cgi?id=15122
Dmitry Stogov dmitry@zend.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |1.1.4
http://bugs.winehq.org/show_bug.cgi?id=15122
Dmitry V Ilyin wine@doty.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |wine@doty.ru
--- Comment #11 from Dmitry V Ilyin wine@doty.ru 2009-02-08 01:05:02 --- Is there a chance that this patch will be accepted in the wine git-tree?
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #12 from Dmitry Timoshkov dmitry@codeweavers.com 2009-02-08 01:36:36 --- (In reply to comment #11)
Is there a chance that this patch will be accepted in the wine git-tree?
Once the author sends it to wine-patches - there is a chance.
http://bugs.winehq.org/show_bug.cgi?id=15122
Eric Pouech eric.pouech@orange.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |eric.pouech@orange.fr
--- Comment #13 from Eric Pouech eric.pouech@orange.fr 2009-02-08 08:01:26 --- I don't see any reason for the changes in kernel32 anyway, the window is managed by wineconsole, not the application itself would moving the GetInputState() calls to wineconsole also work ?
http://bugs.winehq.org/show_bug.cgi?id=15122
Sic Volo sickvolo@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |sickvolo@gmail.com
--- Comment #14 from Sic Volo sickvolo@gmail.com 2009-03-10 15:43:30 --- This bug is confirmed for wine 1.1.16 on Ubuntu 8.10 32bit
http://bugs.winehq.org/show_bug.cgi?id=15122
Sergiy Zuban s.zuban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1
--- Comment #15 from Sergiy Zuban s.zuban@gmail.com 2009-03-14 03:31:48 --- *** This bug has been confirmed by popular vote. ***
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #16 from Sergiy Zuban s.zuban@gmail.com 2009-03-14 03:46:56 --- as I wrote before this bug complicates my everyday life, because it reflects on Mozilla products functionality. Just copy something to clipboard in Far and try either: compose message in Thunderbird or view page source in Firefox. In my case window freezes for more then 10 seconds - it's very annoying and I'd like to somehow force Wine developers to get time and take a look on this bug with more attention. The first step - change bug status to confirmed :)
Is there another way (without changing kernel32) to fix it? Maybe in that case patch won't be rejected?
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #17 from Dmitry Timoshkov dmitry@codeweavers.com 2009-03-16 00:36:02 --- (In reply to comment #16)
Is there another way (without changing kernel32) to fix it? Maybe in that case patch won't be rejected?
See Comment #13.
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #18 from Dmitry Stogov dmitry@zend.com 2009-03-16 06:36:51 --- The FAR uses its own clipboard witch has nothing common with wineconsole window. For example SetClipboardData() is handled by X11DRV_SetClipboardData() in context of FAR process (no winconsole). The problem that FAR doesn't use message loop, it uses kernel32 API calls for console input (PeekConcoleInput/ReadConsoleInput) and as result control is never reached X11DRV_MsgWaitForMultipleObjectsEx() that handles X11 selection events and implements clipboard operations.
My patch just adds calls to X11DRV_MsgWaitForMultipleObjectsEx() (through GetInputState) to console input routines.
I'm not a wine/Windows/X11 hacker so I don't know if it's possible to fix the bug in the other way.
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #19 from Sic Volo sickvolo@gmail.com 2009-04-14 11:33:29 --- This bug IS a limitation/bug of the wineconsole. In order for any console application to communicate with the windows console it needs to call PeekConcoleInput/ReadConsoleInput directly. While this works fine in Windows, under Wine it causes the aforementioned bug. It seems the calls to X11DRV_MsgWaitForMultipleObjectsEx() are not made when accessing conole directly under wine. What is a procedure for submitting a fix for kernel32?
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #20 from Dmitry Timoshkov dmitry@codeweavers.com 2009-04-15 00:34:05 --- Have you tried the solution suggested in the comment #13?
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #21 from Dmitry Stogov dmitry@zend.com 2009-04-15 02:08:00 --- It doesn't work, because FAR calls PeekConcoleInput/ReadConsoleInput directly, and these functions are defined in the kernel32.
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #22 from Dmitry Timoshkov dmitry@codeweavers.com 2009-04-15 02:34:09 --- (In reply to comment #21)
It doesn't work, because FAR calls PeekConcoleInput/ReadConsoleInput directly, and these functions are defined in the kernel32.
It doesn't matter where that APIs reside, the window is managed by wineconsole, and all console/clipboard calls go through the server. Have you actually tried to add GetInputState() calls to wineconsole?
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #23 from Dmitry Stogov dmitry@zend.com 2009-04-15 02:38:33 --- Where do you think I should add it to?
wineconsole just doesn't get control when application calls PeekConcoleInput/ReadConsoleInput.
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #24 from Dmitry Timoshkov dmitry@codeweavers.com 2009-04-15 03:26:54 --- (In reply to comment #23)
Where do you think I should add it to?
In WCUSER_MainLoop().
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #25 from Dmitry Stogov dmitry@zend.com 2009-04-15 07:02:12 --- WCUSER_MainLoop() already calls to MsgWaitForMultipleObjects(), but it doesn't help because WCUSER_MainLoop() isn't called when application calls to PeekConcoleInput/ReadConsoleInput.
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #26 from Dmitry Timoshkov dmitry@codeweavers.com 2009-04-15 08:09:50 --- (In reply to comment #25)
WCUSER_MainLoop() already calls to MsgWaitForMultipleObjects(), but it doesn't help because WCUSER_MainLoop() isn't called when application calls to PeekConcoleInput/ReadConsoleInput.
You are right.
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #27 from Sic Volo sickvolo@gmail.com 2009-04-15 13:41:55 --- What is interesting about this bug is the clipboard WILL work in FAR right after you start FAR, if you only paste into FAR. Once you do the first "copy" from FAR the clipboard breaks. Here is how to reproduce it: copy something into clipboard (select with mouse AND do ctrl-v or ctrl-ins) outside of WINE. Start a fresh copy of FAR. Paste with ctrl-v. It will work. Select something else outside of wine and try pasting into FAR again. It will work too. Now try to select something in FAR and copy it (ctrl-c or ctrl-ins). The clipboard stops working. You will not be able to either paste or copy to/from FAR anymore, until you quit it. Tested with FAR 2.0 alpha build 870 under wine 1.1.19 Could this lead us any closer to fixing it in FAR?
http://bugs.winehq.org/show_bug.cgi?id=15122
Yuri Khan yurivkhan@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |yurivkhan@gmail.com
--- Comment #28 from Yuri Khan yurivkhan@gmail.com 2009-06-17 11:03:53 --- This issue is not limited to console applications. It affects any application that does not run a message loop or otherwise cause X11DRV_MsgWaitForMultipleObjectsEx to be called. I have tested an application which has this in its message loop:
case IDM_TEST: { OpenClipboard(0); EmptyClipboard(); HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, 14); wcscpy(static_cast<wchar_t*>(GlobalLock(hMem)), L"Preved"); GlobalUnlock(hMem); SetClipboardData(CF_UNICODETEXT, hMem); CloseClipboard(); Sleep(60000); break; }
In Windows, it copies the data to the system immediately, and then fails to process messages for a minute. Meanwhile, paste operations succeed.
In wine, the clipboard data is not available until this minute passes.
I studied the code of OpenClipboard and found that in case when hWnd is 0 or does not belong to the calling thread, wine creates its own auxiliary window to act as the selection owner. This leads me to an idea that it should also spin an auxiliary thread that would run an X message loop and respond to selection requests.
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #29 from Yuri Khan yurivkhan@gmail.com 2009-06-22 01:04:19 --- Created an attachment (id=21944) --> (http://bugs.winehq.org/attachment.cgi?id=21944) Move clipboard handling to a separate thread
I have implemented my idea. My limited testing (that includes the wine notepad, FAR Manager 2.0 b981, and my own test application that (1) puts text on clipboard and sleeps for a minute; (2) puts a delay-rendered text on clipboard and handles delayed rendering messages) shows that it works.
Would someone please do a review before I send it to wine-patches?
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #30 from Dmitry Timoshkov dmitry@codeweavers.com 2009-06-22 11:51:52 --- (In reply to comment #29)
Would someone please do a review before I send it to wine-patches?
Looks OK to me (but you need to remove commented out code).
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #31 from Yuri Khan yurivkhan@gmail.com 2009-06-22 12:51:41 --- (In reply to comment #30)
Looks OK to me (but you need to remove commented out code).
OK, sent. Fixed a thread handle leak, too.
http://www.winehq.org/pipermail/wine-patches/2009-June/074634.html
http://bugs.winehq.org/show_bug.cgi?id=15122
--- Comment #32 from Yuri Khan yurivkhan@gmail.com 2009-07-20 00:13:35 --- The patch has been accepted[1] and is present in version 1.1.26. RESOLVED FIXED?
http://bugs.winehq.org/show_bug.cgi?id=15122
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #33 from Austin English austinenglish@gmail.com 2009-07-20 02:19:26 --- Fixed by http://source.winehq.org/git/wine.git/?a=commit;h=f1c131ba2731cca5139d2ffef6...
http://bugs.winehq.org/show_bug.cgi?id=15122
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #34 from Alexandre Julliard julliard@winehq.org 2009-08-07 12:28:48 --- Closing bugs fixed in 1.1.27.