-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Automagical copy paste #1174
Conversation
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:
|
There was a problem hiding this 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:
- Fix up the lint errors (see the travis build)
- Could you add some tests for this?
- 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(); |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 ) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes of course, follow this: https://bugs.chromium.org/p/chromium/issues/detail?id=949926&q=clipboard&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified
There I described how to reproduce the bug.
} | ||
if ( UI.needToCheckClipboardChange ) { | ||
UI.copyFromLocalClipboard(); | ||
} |
There was a problem hiding this comment.
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.
A good guide for git commit messages can be found here: |
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. |
Hi @bulldozier no problem, I put the "Work in Progress" tag on this for now then. |
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
@bulldozier, any progress? And those commits that were added seem unrelated. |
@bulldozier are you still interested in getting this merged? |
I will eventually circle back around to this and fix a few things. The code
is not ready for merge.
…On Thu, Feb 7, 2019 at 3:18 AM Samuel Mannehed ***@***.***> wrote:
@bulldozier <https://github.com/bulldozier> are you still interested in
getting this merged?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1174 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AHC8dNMrahfeZifavVmrDqg-J7lXVnLKks5vLAuVgaJpZM4ZBohk>
.
|
Hi! |
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 |
Closing due to lack of activity. |
No description provided.