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

8281384: Random chars on paste from Windows clipboard #1724

Closed
wants to merge 10 commits into from
Original file line number Diff line number Diff line change
@@ -204,8 +204,11 @@ _bstr_t getMime(CLIPFORMAT cf)
int create_mime_stuff()
{
addPair(GLASS_TEXT_PLAIN, CF_UNICODETEXT);
addPair(GLASS_TEXT_PLAIN_LOCALE, CF_UNICODETEXT);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like those changes made JFX unaware of text data ready to be pasted from "outside" - running your test program and trying to paste something to a TextBox (ex. in HelloTextBoxClipboard) doesn't work anymore (Paste popup menu option is disabled, Ctrl+V does nothing, whereas both were possible to do on master). I checked that these mime stuff changes are at fault.

My guess now would be that these mime_stuff changes have to be reverted and the actual change should happen as we request Clipboard data - probably a condition changing clipboard format cf from CF_TEXT and CF_OEMTEXT to CF_UNICODETEXT right before we call me.Load() in PopMemory(). Please check if that is in fact the case before committing though, I'm not 100% sure if that would work.

If that works, a comment explaining why we do this clipboard format swap would also come in handy for future generations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't check if replacing cf with CF_UNICODETEXT there works, as probably that flavor is already always prioritized.

My test for the early NUL terminator explicitly only sets CF_TEXT, but is converted to unicode.

Copy link
Contributor

@lukostyra lukostyra Mar 28, 2025

Choose a reason for hiding this comment

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

I did give it some tries and it did indeed seem to prioritize CF_UNICODETEXT. I suspect we could leave it be without any extra conditions or changes then.

Let's revert the mime_stuff changes then, because they do break something, and then leave it as it is.

addPair(GLASS_IMAGE, CF_JAVA_BITMAP);
addPair(GLASS_FILE_LIST, CF_HDROP);
addPair(MS_LOCALE, CF_LOCALE);
addPair(MS_OEMTEXT, CF_UNICODETEXT);
Mime2oscfstrPair *p = pairs;
for (int i = 0; i < sizeof(pairs)/sizeof(*pairs); ++i, ++p) {
addPair(p->mime, ::RegisterClipboardFormat(p->osString));