public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
* 64-bit Clipboard troubles
@ 2013-06-09 18:59 David Stacey
  2013-06-10 13:30 ` Jon TURNEY
  0 siblings, 1 reply; 11+ messages in thread
From: David Stacey @ 2013-06-09 18:59 UTC (permalink / raw)
  To: cygwin-xfree

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

I am trying to package keepassx for 64-bit Cygwin, and have noticed a 
difference between the way the clipboard functions under 32-bit and 
64-bit Cygwin/X. Essentially, keepassx is an encrypted password database 
that copies your username and password to the clipboard. Then, you can 
paste these into a web site (say) to log in.

When I run keepassx (both 32-bit and 64-bit builds) using the 32-bit 
version of XWin, keepassx copies the username and password to the 
clipboard, and these can be pasted into a native Windows web browser 
(e.g. Firefox). However, when I run keepassx (again, both 32-bit and 
64-bit builds) using the 64-bit version of XWin, the procedure breaks: I 
instruct keepassx to copy to the clipboard, but when I paste in the web 
browser, no test is pasted.

I attempted to write a testcase programme to access the clipboard in 
various ways. The programme doesn't work as I had quite intended (which 
is almost certainly down to my limited understanding of how the 
clipboard works in X), but it does highlight differences between 32-bit 
and 64-bit XWin, so I have attached it in case it is useful.

The testcase programme reads and writes to the clipboard using two 
techniques - either through Qt4 (identical to the code used in keepassx) 
or by accessing /dev/clipboard. The difference comes when writing to the 
clipboard by writing to /dev/clipboard and then reading it back using 
Qt4 - under 32-bit XWin this succeeds (i.e. the correct text is read 
back), but under 64-bit XWin an empty string is read.

I mentioned that my testcase programme doesn't quite work as I intended: 
writing to the clipboard using Qt4 and reading it back by reading 
/dev/clipboard fails when using both 32-bit and 64-bit XWin. I don't 
understand why, but this is probably down to my own limited 
understanding of the clipboard in X.

Here is my environment: I'm running Windows 7 Ultimate x64 SP1.
32-bit Cygwin: Qt4-4.8.4-2 with xorg-server-1.14.1-1
64-bit Cygwin: Qt4-4.8.4-3 with xorg-server-1.14.1-1
The two Cygwin installations are installed side-by-side.

The 32-bit build of keepassx can be found in your favourite Cygwin 
mirror; if you need the 64-bit build then you can download it here:

BASEURL=http://dl.dropbox.com/sh/7y1yn4whbyho9a7
wget --no-check-certificate --no-host-directories --force-directories 
--cut-dirs=6 \
${BASEURL}/gMetoiuG3_/64bit/release/KDE/keepassx/keepassx-0.4.3-1-src.tar.bz2 
\
${BASEURL}/faOgOyuoYS/64bit/release/KDE/keepassx/keepassx-0.4.3-1.tar.bz2 \
${BASEURL}/xaqPOGFz3J/64bit/release/KDE/keepassx/setup.hint \
${BASEURL}/U82Dz9jF1S/64bit/release/KDE/keepassx/keepassx-debuginfo/keepassx-debuginfo-0.4.3-1.tar.bz2 
\
${BASEURL}/J4n6_izWKV/64bit/release/KDE/keepassx/keepassx-debuginfo/setup.hint

As the behaviour is different depending on whether I start 'XWin 
-multiwindow' on 32-bit or 64-bit Cygwin, I am posting here. If this is 
nothing to do with the xfree list then please accept my apologies and I 
will take the discussion to the main Cygwin list.

Apologies also for the length of the post, but hopefully there's enough 
information here to help to track down the cause of the problem.

Many thanks in advance for your help,

Dave.


[-- Attachment #2: qt4_clip.cpp --]
[-- Type: text/x-c++src, Size: 4397 bytes --]

// Compile: g++ -I/usr/include/qt4 -L/usr/lib/qt4/lib -o qt4_clip qt4_clip.cpp -lQtGui -lQtCore
#include <QtCore/QString>
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
#include <fstream>
#include <iostream>
#include <string>
#include <unistd.h>

// Abstract class to define a generic clipboard accessor.
class CClipboardAccess
{
public:
	explicit CClipboardAccess(const std::string &name) : Name(name) {}
	virtual ~CClipboardAccess() {}
	inline const std::string& GetName() const { return this->Name; }

	virtual void ClearClipboard() const = 0;
	virtual void SetClipboard(const std::string &str) const = 0;
	virtual std::string GetClipboard() const = 0;

private:
	std::string Name;
};

// A class to access the clipboard using the Qt QClipboard.
class CQtClipboardAccess : public CClipboardAccess
{
public:
	explicit CQtClipboardAccess(QApplication &app) : CClipboardAccess("QClipboard"), pApp(&app), pClip(QApplication::clipboard()) {}
	virtual ~CQtClipboardAccess() {}

	virtual void ClearClipboard() const
	{
		this->pApp->processEvents();
		this->pClip->clear(QClipboard::Clipboard);
		if (this->pClip->supportsSelection())
			this->pClip->clear(QClipboard::Selection);
	}

	virtual void SetClipboard(const std::string &str) const
	{
		this->pApp->processEvents();
		this->pClip->setText(str.c_str(), QClipboard::Clipboard);
		if (this->pClip->supportsSelection())
			this->pClip->setText(str.c_str(), QClipboard::Selection);
	}

	virtual std::string GetClipboard() const
	{
		this->pApp->processEvents();
		return this->pClip->text(QClipboard::Clipboard).toStdString();
	}

private:
	QApplication *pApp;
	QClipboard *pClip;
};

// A class to access the clipboard by reading / writing to '/dev/clipboard'.
class CCygwinClipboardAccess : public CClipboardAccess
{
public:
	CCygwinClipboardAccess() : CClipboardAccess("/dev/clipboard") {}
	virtual ~CCygwinClipboardAccess() {}

	virtual void ClearClipboard() const
	{
		this->SetClipboard("");
	}

	virtual void SetClipboard(const std::string &str) const
	{
		std::ofstream out(this->GetName().c_str());
		if (!out)
			std::cerr << "Unable to write to '" << this->GetName() << "'." << std::endl;
		else
			out << str;
	}

	virtual std::string GetClipboard() const
	{
		std::string line;
		std::ifstream in(this->GetName().c_str());
		if (!in)
			std::cerr << "Unable to read '" << this->GetName() << "'." << std::endl;
		else
			std::getline(in, line);
		return line;
	}
};

class CTest : public QApplication
{
public:
	CTest(int argc, char **pargv) : QApplication(argc, pargv) {}
	virtual ~CTest() {}

	void GoTest()
	{
		CQtClipboardAccess qt_clip(*this);
		CCygwinClipboardAccess cygwin_clip;

		// The tests.
		//
		// With 64-bit XWin, test 3 always fails, but for 32-bit XWin the same test passes.
		// This is true, irrespective of whether this code is compiled and run from 32-bit Cygwin or 64-bit Cygwin.
		//
		// Test 2 always fails, but I don't understand why.
		// Tests 1 and 4 always pass.
		this->RunTest(qt_clip,     qt_clip,     "Mary had a little lamb");
		this->RunTest(qt_clip,     cygwin_clip, "Whose fleece was as white as snow");
		this->RunTest(cygwin_clip, qt_clip,     "And everywhere that Mary went");
		this->RunTest(cygwin_clip, cygwin_clip, "The lamb was sure to go");
	}

private:
	// Procedure to run a test.
	// The string in 'str' is written to the clipboard using 'write'.
	// Then the clipboard is read using 'read'.
	// The string read should match 'str', i.e. we read back from the clipboard the same string we wrote to it.
	void RunTest(const CClipboardAccess &write, const CClipboardAccess &read, const std::string &str)
	{
		static unsigned int count = 0;
		std::cout << std::endl << "TEST " << (++count)
		          << ": Write using " << write.GetName()
				  << ", read using " << read.GetName() << '.' << std::endl;

		write.ClearClipboard();
		sleep(1);
		read.ClearClipboard();
		sleep(1);

		std::cout << ">>> Setting " << write.GetName() << " to '" << str << "'." << std::endl;
		write.SetClipboard(str);
		sleep(1);
		const std::string result = read.GetClipboard();
		std::cout << ">>> Read " << read.GetName() << " = '" << result << "'." << std::endl;

		if (result == str)
			std::cout << ">>> OK - strings match." << std::endl;
		else
			std::cout << "*** FAILED." << std::endl;
	}
};

int main(int argc, char **pargv)
{
	CTest test(argc, pargv);
	test.GoTest();
	return 0;
}


[-- Attachment #3: 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] 11+ messages in thread

* Re: 64-bit Clipboard troubles
  2013-06-09 18:59 64-bit Clipboard troubles David Stacey
@ 2013-06-10 13:30 ` Jon TURNEY
  2013-06-10 21:39   ` David Stacey
  0 siblings, 1 reply; 11+ messages in thread
From: Jon TURNEY @ 2013-06-10 13:30 UTC (permalink / raw)
  To: cygwin-xfree; +Cc: drstacey

On 09/06/2013 19:59, David Stacey wrote:
> I am trying to package keepassx for 64-bit Cygwin, and have noticed a 
> difference between the way the clipboard functions under 32-bit and 64-bit 
> Cygwin/X. Essentially, keepassx is an encrypted password database that
> copies your username and password to the clipboard. Then, you can paste
> these into a web site (say) to log in.
> 
> When I run keepassx (both 32-bit and 64-bit builds) using the 32-bit
> version of XWin, keepassx copies the username and password to the
> clipboard, and these can be pasted into a native Windows web browser (e.g.
> Firefox). However, when I run keepassx (again, both 32-bit and 64-bit
> builds) using the 64-bit version of XWin, the procedure breaks: I instruct
> keepassx to copy to the clipboard, but when I paste in the web browser, no
> text is pasted.

Sorry, integration between the native and X clipboards is broken in 64-bit XWin.

Unfortunately, this is rather complex to fix and I haven't found the time to
do so yet.

> I mentioned that my testcase programme doesn't quite work as I intended:
> writing to the clipboard using Qt4 and reading it back by reading
> /dev/clipboard fails when using both 32-bit and 64-bit XWin. I don't
> understand why, but this is probably down to my own limited understanding
> of the clipboard in X.

Thanks for writing this useful testcase.

>From a brief glance, the test looks well formed, so I'll also try to take a
look at why test 2 always fails, I guess this indicates some bug in the
clipboard integration.

-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
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] 11+ messages in thread

* Re: 64-bit Clipboard troubles
  2013-06-10 13:30 ` Jon TURNEY
@ 2013-06-10 21:39   ` David Stacey
  2013-06-21 12:33     ` Jon TURNEY
  0 siblings, 1 reply; 11+ messages in thread
From: David Stacey @ 2013-06-10 21:39 UTC (permalink / raw)
  To: cygwin-xfree

On 10/06/13 14:30, Jon TURNEY wrote:
> On 09/06/2013 19:59, David Stacey wrote:
>> >I am trying to package keepassx for 64-bit Cygwin, and have noticed a
>> >difference between the way the clipboard functions under 32-bit and 64-bit
>> >Cygwin/X. Essentially, keepassx is an encrypted password database that
>> >copies your username and password to the clipboard. Then, you can paste
>> >these into a web site (say) to log in.
>> >
>> >When I run keepassx (both 32-bit and 64-bit builds) using the 32-bit
>> >version of XWin, keepassx copies the username and password to the
>> >clipboard, and these can be pasted into a native Windows web browser (e.g.
>> >Firefox). However, when I run keepassx (again, both 32-bit and 64-bit
>> >builds) using the 64-bit version of XWin, the procedure breaks: I instruct
>> >keepassx to copy to the clipboard, but when I paste in the web browser, no
>> >text is pasted.
> Sorry, integration between the native and X clipboards is broken in 64-bit XWin.
>
> Unfortunately, this is rather complex to fix and I haven't found the time to
> do so yet.

Thank you for your reply. I've sent an RFU for keepassx along with a 
link to your reply. If and when you tie the two clipboards together, 
keepassx should just start working - there shouldn't be a need to 
rebuild it, but I'll do that if necessary.

Thanks again,

Dave.


--
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] 11+ messages in thread

* Re: 64-bit Clipboard troubles
  2013-06-10 21:39   ` David Stacey
@ 2013-06-21 12:33     ` Jon TURNEY
  2013-06-21 18:02       ` David Stacey
  2013-09-22  2:39       ` Clipboard periodically breaks Matt D.
  0 siblings, 2 replies; 11+ messages in thread
From: Jon TURNEY @ 2013-06-21 12:33 UTC (permalink / raw)
  To: cygwin-xfree; +Cc: drstacey

On 10/06/2013 22:39, David Stacey wrote:
> On 10/06/13 14:30, Jon TURNEY wrote:
>> On 09/06/2013 19:59, David Stacey wrote:
>>> >I am trying to package keepassx for 64-bit Cygwin, and have noticed a
>>> >difference between the way the clipboard functions under 32-bit and 64-bit
>>> >Cygwin/X. Essentially, keepassx is an encrypted password database that
>>> >copies your username and password to the clipboard. Then, you can paste
>>> >these into a web site (say) to log in.
>>> >
>>> >When I run keepassx (both 32-bit and 64-bit builds) using the 32-bit
>>> >version of XWin, keepassx copies the username and password to the
>>> >clipboard, and these can be pasted into a native Windows web browser (e.g.
>>> >Firefox). However, when I run keepassx (again, both 32-bit and 64-bit
>>> >builds) using the 64-bit version of XWin, the procedure breaks: I instruct
>>> >keepassx to copy to the clipboard, but when I paste in the web browser, no
>>> >text is pasted.
>> Sorry, integration between the native and X clipboards is broken in 64-bit
>> XWin.
>>
>> Unfortunately, this is rather complex to fix and I haven't found the time to
>> do so yet.
> 
> Thank you for your reply. I've sent an RFU for keepassx along with a link to
> your reply. If and when you tie the two clipboards together, keepassx should
> just start working - there shouldn't be a need to rebuild it, but I'll do that
> if necessary.

This should be working as of xserver 1.14.1-2.  Please test if you can and let
me know if there are any problems.

On 10/06/2013 14:30, Jon TURNEY wrote:
>> I mentioned that my testcase programme doesn't quite work as I intended:
>> > writing to the clipboard using Qt4 and reading it back by reading
>> > /dev/clipboard fails when using both 32-bit and 64-bit XWin. I don't
>> > understand why, but this is probably down to my own limited understanding
>> > of the clipboard in X.
> Thanks for writing this useful testcase.
>
> From a brief glance, the test looks well formed, so I'll also try to take a
> look at why test 2 always fails, I guess this indicates some bug in the
> clipboard integration.

Looking again, I think maybe that the problem with test 2 is that it's
necessary for Qt's main event loop to be running for pastes from the X
clipboard to work.


-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
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] 11+ messages in thread

* Re: 64-bit Clipboard troubles
  2013-06-21 12:33     ` Jon TURNEY
@ 2013-06-21 18:02       ` David Stacey
  2013-09-22  2:39       ` Clipboard periodically breaks Matt D.
  1 sibling, 0 replies; 11+ messages in thread
From: David Stacey @ 2013-06-21 18:02 UTC (permalink / raw)
  To: cygwin-xfree

On 21/06/13 13:33, Jon TURNEY wrote:
> On 10/06/2013 22:39, David Stacey wrote:
>> >On 10/06/13 14:30, Jon TURNEY wrote:
>>> >>On 09/06/2013 19:59, David Stacey wrote:
>>>>> >>> >I am trying to package keepassx for 64-bit Cygwin, and have noticed a
>>>>> >>> >difference between the way the clipboard functions under 32-bit and 64-bit
>>>>> >>> >Cygwin/X. Essentially, keepassx is an encrypted password database that
>>>>> >>> >copies your username and password to the clipboard. Then, you can paste
>>>>> >>> >these into a web site (say) to log in.
>>>>> >>> >
>>>>> >>> >When I run keepassx (both 32-bit and 64-bit builds) using the 32-bit
>>>>> >>> >version of XWin, keepassx copies the username and password to the
>>>>> >>> >clipboard, and these can be pasted into a native Windows web browser (e.g.
>>>>> >>> >Firefox). However, when I run keepassx (again, both 32-bit and 64-bit
>>>>> >>> >builds) using the 64-bit version of XWin, the procedure breaks: I instruct
>>>>> >>> >keepassx to copy to the clipboard, but when I paste in the web browser, no
>>>>> >>> >text is pasted.
>>> >>Sorry, integration between the native and X clipboards is broken in 64-bit
>>> >>XWin.
>>> >>
>>> >>Unfortunately, this is rather complex to fix and I haven't found the time to
>>> >>do so yet.
>> >
>> >Thank you for your reply. I've sent an RFU for keepassx along with a link to
>> >your reply. If and when you tie the two clipboards together, keepassx should
>> >just start working - there shouldn't be a need to rebuild it, but I'll do that
>> >if necessary.
> This should be working as of xserver 1.14.1-2.  Please test if you can and let
> me know if there are any problems.

Thank you for implementing this functionality. I have tested xserver 
1.14.1-2 and can confirm that this is working - keepassx can copy URLs, 
usernames and passwords into the Windows clipboard.

Many thanks once again,

Dave.


--
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] 11+ messages in thread

* Clipboard periodically breaks
  2013-06-21 12:33     ` Jon TURNEY
  2013-06-21 18:02       ` David Stacey
@ 2013-09-22  2:39       ` Matt D.
  2013-09-22  3:11         ` Matt D.
       [not found]         ` <524454A6.8030503@dronecode.org.uk>
  1 sibling, 2 replies; 11+ messages in thread
From: Matt D. @ 2013-09-22  2:39 UTC (permalink / raw)
  To: cygwin-xfree

I often keep gedit sessions open on remote servers for maintaining 
various scripts. The problem I've encountered is that after a while I 
can no longer copy/paste between X and Windows.

For example, I'll copy in windows and attempt to paste in gedit but 
nothing will happen. However, if I then proceed to copy something in 
gedit it will immediate "paste" that in place of where I had previously 
tried to paste from Windows.

Sometimes I can get it working again by bombarding the clipboard with 
copy/pastes from both X and Windows. But most of the time I have to exit 
the ssh session and reconnect.

Is this a known problem?

I am using the Cygwin x32 with the latest packages.


Matt D.

--
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] 11+ messages in thread

* Re: Clipboard periodically breaks
  2013-09-22  2:39       ` Clipboard periodically breaks Matt D.
@ 2013-09-22  3:11         ` Matt D.
       [not found]         ` <524454A6.8030503@dronecode.org.uk>
  1 sibling, 0 replies; 11+ messages in thread
From: Matt D. @ 2013-09-22  3:11 UTC (permalink / raw)
  To: cygwin-xfree

Here is an example screen capture and repeatable bug of the clipboard 
breaking.

Synopsis: Copy from Windows, highlight text in gedit, clipboard breaks 
(paste doesn't work). Proceed to copy from gedit and suddenly that text 
gets pasted. Sometimes it will just start pasting while a selection is 
being made.. ??

Download the video here in Xvid format:

http://codespunk.com/files/upload/cygwinx_clipboard_breaking_xvid.avi


Matt D.

On 9/21/2013 10:38 PM, Matt D. wrote:
> I often keep gedit sessions open on remote servers for maintaining
> various scripts. The problem I've encountered is that after a while I
> can no longer copy/paste between X and Windows.
>
> For example, I'll copy in windows and attempt to paste in gedit but
> nothing will happen. However, if I then proceed to copy something in
> gedit it will immediate "paste" that in place of where I had previously
> tried to paste from Windows.
>
> Sometimes I can get it working again by bombarding the clipboard with
> copy/pastes from both X and Windows. But most of the time I have to exit
> the ssh session and reconnect.
>
> Is this a known problem?
>
> I am using the Cygwin x32 with the latest packages.
>
>
> Matt D.
>
> --
> 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/
>
>
>

--
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] 11+ messages in thread

* Re: Clipboard periodically breaks
       [not found]         ` <524454A6.8030503@dronecode.org.uk>
@ 2013-09-27  0:35           ` Matt D.
  2013-10-21 14:46             ` Reinier Post
  0 siblings, 1 reply; 11+ messages in thread
From: Matt D. @ 2013-09-27  0:35 UTC (permalink / raw)
  To: cygwin-xfree

Jon,

Thanks for looking into this. I can confirm that your changes correct 
the issue where highlighting next would cause arbitrary pastes to occur. 
Good work!

I also concede that there does not seem to be a good solution to 
transparently fix the two-to-one clipboard issue; as XWin may indeed be 
able to interpret calls to X's two clipboards, there wouldn't be any 
reasonable way for it to identify which clipboard is actually being used.

However, an environment variable that tells it which clipboard to use 
would provide an immediate solution and be used used on a 
per-application basis. For example, I can use aliases when launching 
programs:

$ xclip=clipboard1 gedit $@ (monitor only clipboard 1)
$ xclip=clipboard2 gedit $@ (monitor only clipboard 2)

No option would indicate that both clipboard 1 and clipboard 2 would be 
handled as they are now.

I'm not familiar with X programming but I'm assuming here that it would 
be possible for xclip to read from a particular process's own 
environment (rather than xclip's own) while processing a clipboard event 
to do this.

What do you think?


Matt D.

On 9/26/2013 11:37 AM, Jon TURNEY wrote:
>> In-Reply-To: <51C44820.4010307@dronecode.org.uk>
>
> Please start a new thread for a new subject.
>
> On 22/09/2013 03:38, Matt D. wrote:
>> I often keep gedit sessions open on remote servers for maintaining various
>>   scripts. The problem I've encountered is that after a while I can no
>> longer copy/paste between X and Windows.
>>
>> For example, I'll copy in windows and attempt to paste in gedit but nothing
>> will happen. However, if I then proceed to copy something in gedit it will
>> immediate "paste" that in place of where I had previously tried to paste
>> from Windows.
>>
>> Sometimes I can get it working again by bombarding the clipboard with
>> copy/pastes from both X and Windows. But most of the time I have to exit
>> the ssh session and reconnect.
>>
>> Is this a known problem?
>
> We know there are bugs, but we don't know what they all are :-)
>
>> Here is an example screen capture and repeatable bug of the clipboard
>> breaking.
>>
>> Synopsis: Copy from Windows, highlight text in gedit, clipboard breaks
>> (paste doesn't work). Proceed to copy from gedit and suddenly that text
>> gets pasted. Sometimes it will just start pasting while a selection is
>> being made.. ??
>>
>> Download the video here in Xvid format:
>>
>> http://codespunk.com/files/upload/cygwinx_clipboard_breaking_xvid.avi
>
> Thanks for this.
>
> There's definitely a bug here when stuff fails to paste.
>
> You are also having difficulties because of a limitation of the current
> clipboard implementation I'll try to explain:
>
> As [1] tries to explain, there are 2 X selections of interest, the PRIMARY
> selection (the highlighted text) and the CLIPBOARD selection (the cut/copied
> text) (and some X applications only use one or the other), but only 1 windows
> clipboard.
>
> When you update the PRIMARY selection, by highlighting that text, it is made
> available for pasting from the Windows clipboard, which means that the
> previous Windows clipboard contents are removed.  When you then go to paste,
> since the Windows clipboard contents have changed to the selected text, that's
> what you get in the CLIPBOARD selection.
>
> This is far from idea, but the proposed solutions I've seen so far aren't any
> better:
>
> i) Don't monitor the PRIMARY selection.  This breaks with any application
> which only uses the PRIMARY selection (e.g. xterm, emacs in default
> configurations)
> ii) Use some more complex heuristic than 'most recently changed owner' for
> choosing which selection to make available in the Windows clipboard.  It's
> very hard to know if this will make things better on average.
>
> I've fixed something else that might be related to the paste failure, so
> please try the latest snapshot [2],[3].
>
> If you can still reproduce your problem with that, can you please try:
>
> * run XWin with the -noclipboard flag added to your usual flags.
> * Then run xwinclip, which should produce some useful logs when you reproduce
> your problem.
>
> [1] http://x.cygwin.com/docs/ug/using-clipboard-integration.html
> [2] ftp://cygwin.com/pub/cygwinx/XWin.20130924-git-d5a9aea0e48a088b.exe.bz2
> [3] ftp://cygwin.com/pub/cygwinx/xwinclip.20130924-git-d5a9aea0e48a088b.exe.bz2
>

--
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] 11+ messages in thread

* Re: Clipboard periodically breaks
  2013-09-27  0:35           ` Matt D.
@ 2013-10-21 14:46             ` Reinier Post
  2013-10-21 22:37               ` Matt D.
  2013-11-21 17:51               ` Jon TURNEY
  0 siblings, 2 replies; 11+ messages in thread
From: Reinier Post @ 2013-10-21 14:46 UTC (permalink / raw)
  To: cygwin-xfree

On Thu Sep 26 20:35:21 2013, matt@codespunk.com (Matt D.) wrote:
> Jon,
> 
> Thanks for looking into this. I can confirm that your changes
> correct the issue where highlighting next would cause arbitrary
> pastes to occur. Good work!
> 
> I also concede that there does not seem to be a good solution to
> transparently fix the two-to-one clipboard issue; as XWin may indeed
> be able to interpret calls to X's two clipboards, there wouldn't be
> any reasonable way for it to identify which clipboard is actually
> being used.

I'm reading this wich much interest: for me, too, copy-pasting
between Windows applications and Cygwin xterms to break after some time,
and this has been happening for a year or so.

I'm not aware of doing anything special to cause it to break,
but the only way I know how to fix it is to restart X.
This is with recent Cygwin packages on Windows 7.

I haven't tested with a newer build of the X server.

> However, an environment variable that tells it which clipboard to
> use would provide an immediate solution and be used used on a
> per-application basis. For example, I can use aliases when launching
> programs:
> 
> $ xclip=clipboard1 gedit $@ (monitor only clipboard 1)
> $ xclip=clipboard2 gedit $@ (monitor only clipboard 2)
> 
> No option would indicate that both clipboard 1 and clipboard 2 would
> be handled as they are now.
> 
> I'm not familiar with X programming but I'm assuming here that it
> would be possible for xclip to read from a particular process's own
> environment (rather than xclip's own) while processing a clipboard
> event to do this.
> 
> What do you think?

As an interested bystander, I have no doubt that that type of
specific solution to specific clipboard interaction problems can
possibly work, but using them will require detailed knowledge of how
the X and Windows clipboards interact.

My question is different: is it possible to implement the interaction
in such a way that a user such as me, who is not aware of any subtleties,
can get consistency, in the sense that all copy-paste actions between
X an Windows that work when X is started continue to work in the same way
for the duration of the session?

> Matt D.

-- 
Reinier Post
TU Eindhoven

--
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] 11+ messages in thread

* Re: Clipboard periodically breaks
  2013-10-21 14:46             ` Reinier Post
@ 2013-10-21 22:37               ` Matt D.
  2013-11-21 17:51               ` Jon TURNEY
  1 sibling, 0 replies; 11+ messages in thread
From: Matt D. @ 2013-10-21 22:37 UTC (permalink / raw)
  To: cygwin-xfree

Reinier,

This was indeed fixed in the last version of XWin. Try updating.

However, copy/paste for large blocks of text seems to have broken.


Matt D.

On 10/21/2013 10:46 AM, Reinier Post wrote:
> On Thu Sep 26 20:35:21 2013, matt@codespunk.com (Matt D.) wrote:
>> Jon,
>>
>> Thanks for looking into this. I can confirm that your changes
>> correct the issue where highlighting next would cause arbitrary
>> pastes to occur. Good work!
>>
>> I also concede that there does not seem to be a good solution to
>> transparently fix the two-to-one clipboard issue; as XWin may indeed
>> be able to interpret calls to X's two clipboards, there wouldn't be
>> any reasonable way for it to identify which clipboard is actually
>> being used.
>
> I'm reading this wich much interest: for me, too, copy-pasting
> between Windows applications and Cygwin xterms to break after some time,
> and this has been happening for a year or so.
>
> I'm not aware of doing anything special to cause it to break,
> but the only way I know how to fix it is to restart X.
> This is with recent Cygwin packages on Windows 7.
>
> I haven't tested with a newer build of the X server.
>
>> However, an environment variable that tells it which clipboard to
>> use would provide an immediate solution and be used used on a
>> per-application basis. For example, I can use aliases when launching
>> programs:
>>
>> $ xclip=clipboard1 gedit $@ (monitor only clipboard 1)
>> $ xclip=clipboard2 gedit $@ (monitor only clipboard 2)
>>
>> No option would indicate that both clipboard 1 and clipboard 2 would
>> be handled as they are now.
>>
>> I'm not familiar with X programming but I'm assuming here that it
>> would be possible for xclip to read from a particular process's own
>> environment (rather than xclip's own) while processing a clipboard
>> event to do this.
>>
>> What do you think?
>
> As an interested bystander, I have no doubt that that type of
> specific solution to specific clipboard interaction problems can
> possibly work, but using them will require detailed knowledge of how
> the X and Windows clipboards interact.
>
> My question is different: is it possible to implement the interaction
> in such a way that a user such as me, who is not aware of any subtleties,
> can get consistency, in the sense that all copy-paste actions between
> X an Windows that work when X is started continue to work in the same way
> for the duration of the session?
>
>> Matt D.
>

--
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] 11+ messages in thread

* Re: Clipboard periodically breaks
  2013-10-21 14:46             ` Reinier Post
  2013-10-21 22:37               ` Matt D.
@ 2013-11-21 17:51               ` Jon TURNEY
  1 sibling, 0 replies; 11+ messages in thread
From: Jon TURNEY @ 2013-11-21 17:51 UTC (permalink / raw)
  To: cygwin-xfree; +Cc: matt

> On Thu Sep 26 20:35:21 2013, Matt D. wrote:
>> However, an environment variable that tells it which clipboard to
>> use would provide an immediate solution and be used used on a
>> per-application basis. For example, I can use aliases when launching
>> programs:
>>
>> $ xclip=clipboard1 gedit $@ (monitor only clipboard 1)
>> $ xclip=clipboard2 gedit $@ (monitor only clipboard 2)
>>
>> No option would indicate that both clipboard 1 and clipboard 2 would
>> be handled as they are now.
>>
>> I'm not familiar with X programming but I'm assuming here that it
>> would be possible for xclip to read from a particular process's own
>> environment (rather than xclip's own) while processing a clipboard
>> event to do this.
>>
>> What do you think?

This is not straightforward to implement and is not really a good solution as
it won't work for remote X clients.

In theory, it might be possible to annotate the X client window with a
property which tells XWin/xwinclip how to treat it's clipboard use, but since
the clipboard-owning window is often a hidden one, getting that property on
there poses problems.

Hopefully the -noprimary option makes this less of an issue.

-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
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] 11+ messages in thread

end of thread, other threads:[~2013-11-21 17:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-09 18:59 64-bit Clipboard troubles David Stacey
2013-06-10 13:30 ` Jon TURNEY
2013-06-10 21:39   ` David Stacey
2013-06-21 12:33     ` Jon TURNEY
2013-06-21 18:02       ` David Stacey
2013-09-22  2:39       ` Clipboard periodically breaks Matt D.
2013-09-22  3:11         ` Matt D.
     [not found]         ` <524454A6.8030503@dronecode.org.uk>
2013-09-27  0:35           ` Matt D.
2013-10-21 14:46             ` Reinier Post
2013-10-21 22:37               ` Matt D.
2013-11-21 17:51               ` Jon TURNEY

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).