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

GTK Shell: Manually get/set textual data in clipboard #1695

Conversation

ForLoveOfCats
Copy link
Collaborator

@ForLoveOfCats ForLoveOfCats commented Apr 4, 2021

Fixes #981

It seems that newlines were not being mangled on the outbound direction, only on the inbound. By manually retrieving the text and converting to a string we avoid GTK from performing that behavior when getting clipboard contents. This also appears to work on Wayland in both Plasma 5 KWin and Weston.

Verification that this behaves correctly on X11 and Wayland would be appreciated :)

@ForLoveOfCats ForLoveOfCats added shell/gtk concerns the GTK backend S-needs-review waits for review labels Apr 4, 2021
@ForLoveOfCats ForLoveOfCats force-pushed the GtkClipboardNewlineNormalizationFix branch 3 times, most recently from 6480337 to a40f334 Compare April 5, 2021 23:20
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

Looks good!

druid-shell/src/platform/gtk/clipboard.rs Outdated Show resolved Hide resolved
@ForLoveOfCats ForLoveOfCats force-pushed the GtkClipboardNewlineNormalizationFix branch 2 times, most recently from 482b602 to c51facd Compare April 6, 2021 21:05
@ForLoveOfCats ForLoveOfCats force-pushed the GtkClipboardNewlineNormalizationFix branch from c51facd to 596f711 Compare April 6, 2021 21:15
@ForLoveOfCats
Copy link
Collaborator Author

Okay so after playing with this some more I realized that the newline chars were being mangled by GTK but only on application shutdown due to some interaction with the clipboard manager. This PR now also manually provides the textual data to the requesting application instead of using GTK's clipboard.set_text. I wish I had caught this earlier but the X11 clipboard has so many strange edge cases and interactions so I simply didn't think about how it looked post-application exit 🤷

@ForLoveOfCats ForLoveOfCats requested a review from cmyr April 6, 2021 21:37
@ForLoveOfCats ForLoveOfCats changed the title GTK Shell: Manually retrieve textual data from clipboard GTK Shell: Manually get/set textual data in clipboard Apr 6, 2021
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

Looks good!

@ForLoveOfCats ForLoveOfCats merged commit 46c6414 into linebender:master Apr 7, 2021
@maan2003 maan2003 removed the S-needs-review waits for review label May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shell/gtk concerns the GTK backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strange clipboard carriage return behavior
3 participants