-
Notifications
You must be signed in to change notification settings - Fork 567
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
X11: Implement putting things into the clipboard #1851
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit renames the current Clipboard to ClipboardState and adds a new Clipboard(Rc<RefCell<ClipboardState>>). This is in preparation for setting the clipboard contents where we need to keep the clipboard contents in ClipboardState. Signed-off-by: Uli Schlachter <[email protected]>
Signed-off-by: Uli Schlachter <[email protected]>
Fixes: linebender#937 Signed-off-by: Uli Schlachter <[email protected]>
Signed-off-by: Uli Schlachter <[email protected]>
Signed-off-by: Uli Schlachter <[email protected]>
Lots of cases of: Error: --> druid-shell/src/platform/x11/clipboard.rs:428:49 | 428 | fn handle_property_notify(&mut self, event: &PropertyNotifyEvent) -> Result<(), ReplyOrIdError> { | ^^^^^^^^^^^^^^^^^^^^ help: consider passing by value instead: `PropertyNotifyEvent` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref error: this argument (16 byte) is passed by reference, but would be more efficient if passed by value (limit: 16 byte) Signed-off-by: Uli Schlachter <[email protected]>
Seems like fixing the clippy warnings made rustfmt change its mind on the proper formatting... Signed-off-by: Uli Schlachter <[email protected]>
maan2003
reviewed
Jul 5, 2021
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.
Thanks! Really happy to see x11 backend moving forward. Just some minor nits:
Signed-off-by: Uli Schlachter <[email protected]>
maan2003
reviewed
Jul 8, 2021
psychon
force-pushed
the
x11-put-clipboard2
branch
from
July 8, 2021 15:55
87247dd
to
c385063
Compare
maan2003
approved these changes
Jul 8, 2021
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.
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #937: The X11 platform now fully supports the clipboard.
When putting things into the clipboard, a new (invisible (= not mapped)) window is created and this window becomes the selection owner. Nothing else "x11-y" happens, so the clipboard contents are just kept in memory. Later, we might get
SelectionRequest
events, which are replied to by setting a window property and sending an event. INCR requests (for "incremental" (for "lots of data")) are again more complicated, just as when getting the clipboard contents.Another complication are self-transfer: If we own the CLIPBOARD selection and request the clipboard contents, we would hang: The X11 server sends us an event that something wants a selection transfer, but the code would just put the event into a queue and not answer it. I briefly tried to implement "we still have to handle these requests", but ran into borrowing problems (the code for getting the selection and handling selection requests had conflicting borrows). Since it is way easier this way anyway, I implement a short-circuit: When we are the selection owner, "nothing X11" is done and we just directly provide the requested data.
Testing done with the following program and pasting into
gvim
(I also tested without thewhile
loop for non-INCR transfers):