Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automagical copy paste #1174

Closed
wants to merge 5 commits into from

Conversation

bulldozier
Copy link

No description provided.

@samhed
Copy link
Member

samhed commented Dec 6, 2018

Hi @bulldozier, and thanks for the pull request.

I believe that we could certainly improve on our clipboard feature and make it more convenient. I did have a quick look at your code but didn't have time to test it yet. For starters I have one request and one question:

  1. Please provide a description for your feature here in the PR.

  2. app/ui.js does already have a popup-message function called "showStatus()". While I didn't look into details about how your new overlay message works, I don't want to have another function doing the same thing. Could showStatus() be used instead?

Copy link
Member

@CendioOssman CendioOssman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The principle with an automatic clipboard is nice. But there are some details that need fixing. Also:

  1. Fix up the lint errors (see the travis build)
  2. Could you add some tests for this?
  3. Please try to improve the commit messages. Anyone browsing through the log should be able to quickly tell what this is about.

app/ui.js Outdated
@@ -936,12 +938,43 @@ const UI = {
}
},

readClipboard(callback) {
var readfuture = navigator.clipboard.readText();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API isn't available everywhere, so we need some handling here when it isn't.

app/ui.js Outdated
},

enterVncClick(e) {
UI.readClipboard(text => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not merge readClipboard() directly in to this function? It doesn't seem to be called elsewhere.

app/ui.js Outdated
enterVncClick(e) {
UI.readClipboard(text => {
document.getElementById('noVNC_clipboard_text').value = text;
UI.rfb.clipboardPasteFrom(text);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this step needed? Don't we get a notification when we change the value?

copyFromLocalClipboard() {
UI.readClipboard(text => {
var clipVal = document.getElementById('noVNC_clipboard_text').value;
if ( clipVal != text ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is essential, otherwise we have no mechanism that avoids just blindly overwriting the server clipboard whenever focus changes.

However this is still a hack, so I think we should reference the clipboardchange event and that we're waiting for browsers to implement it.

document.getElementById('noVNC_clipboard_text').value = e.detail.text;
Log.Debug("<< UI.clipboardReceive");
var curvalue = document.getElementById('noVNC_clipboard_text').value;
if (curvalue != e.detail.text) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎

We should always update the local clipboard on a proper event.

document.addEventListener('focus', UI.focusVNC);
document.addEventListener('focusout', UI.focusoutVNC);
document.addEventListener('mousemove', UI.mouseMoveVNC);
document.addEventListener('mousedown', UI.mouseDownVNC);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need all of these events? Isn't it sufficient with just focus?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered while implementing the clipboard feature that the Chrome API clipboard.readText() is still buggy. It fails sometimes (not-deterministic why) with undefined error. When using all these events here to try to read it, it mostly works. I reported the bug to the Chrome community and suggest not implement this feature until it doesn't work properly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's disappointing. Do you have a link?

Copy link

@akamos akamos Apr 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
if ( UI.needToCheckClipboardChange ) {
UI.copyFromLocalClipboard();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't hijack existing (and unrelated) event handlers.

@CendioOssman
Copy link
Member

A good guide for git commit messages can be found here:

https://chris.beams.io/posts/git-commit/

@bulldozier
Copy link
Author

Thanks for all the feedback. I am working on fixing all the issues. Also, I didn't actually mean to submit the pull request yet.

@samhed samhed added the WIP label Dec 10, 2018
@samhed
Copy link
Member

samhed commented Dec 10, 2018

Hi @bulldozier no problem, I put the "Work in Progress" tag on this for now then.

bukzor and others added 3 commits December 19, 2018 16:29
It's really hard to say why that code was ever added.
It just makes everything work wrong when using macos.
Fix keyboard for macos users
@CendioOssman
Copy link
Member

@bulldozier, any progress?

And those commits that were added seem unrelated.

@samhed
Copy link
Member

samhed commented Feb 7, 2019

@bulldozier are you still interested in getting this merged?

@bulldozier
Copy link
Author

bulldozier commented Feb 7, 2019 via email

@akamos
Copy link

akamos commented Apr 3, 2019

Hi!
We would require this feature in our project, but as @bulldozier mentioned the code is still not ready to merge. I would like to use this code base of him and make it ready to get merged into master.
How can I proceed? Should I use the forked version of @bulldozier or should I create a new clean fork from master and copy/paste the code base from @bulldozier and create a new pull request with clean messages as required?

@CendioOssman
Copy link
Member

We want a clean history, so in this case I'd say to "copy" his code and finish things. Make sure to give proper attribution though, e.g. in the commit message or using multiple --author.

@samhed
Copy link
Member

samhed commented Dec 20, 2019

Closing due to lack of activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants