-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x11: Add support for getting clipboard contents
This commit implements X11 clipboard transfers as specified in ICCCM. This allows to get the contents of the clipboard. X11/ICCM call the underlying mechanism "selections". This works with ConvertSelection requests. The X11 server forwards these requests to the selection owner which then uses SendEvent requests to answer. Thus, this requires some way to blockingly wait for events. For this purpose, a FIFO queue (VecDeque) of pending events is introduced. When waiting for the "right" event, "wrong" events are pushed to this queue for later processing. Doing selection transfers requires an up-to-date-ish X11 timestamp. Thus, the Application now tracks a timestamp and updates it whenever it gets a newer timestamp. As an unrelated refactor, this changes the X11 screen number to be saved as usize instead of i32. This saves a couple of unnecessary casts. I didn't want to do this too much in this commit, so screen_num() still returns i32 instead of usize, even though I think it should be an usize. Besides the above, the actual selection transfer is fully contained in clipboard.rs. The basic steps for getting the selection contents are: - create an invisible window (used for the reply) - send a ConvertSelection request with this window - wait for a SelectionNotify event (at this point, the selection owner set a property on the window) - get the contents of the property from the window - in case the selection contents are larger than allowed for window properties, the property as type INCR. This indicates an "incremental transfer" which works as follows: - every time the property is deleted, the selection owner creates a new property with the next chunk of the property - thus, we have to wait for PropertyNotify events for our special window and react to them by getting the next piece of data Signed-off-by: Uli Schlachter <[email protected]>
- Loading branch information
Showing
3 changed files
with
270 additions
and
29 deletions.
There are no files selected for viewing
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 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
Oops, something went wrong.