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

Provide system clipboard handling API on Window #2156

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jan 20, 2022

  1. Provide system clipboard handling API on Window

    Clipboard handling is essential for system window handling and also is a
    complicated task to be implemented and handled properly. So abstracting
    this code into a windowing library like `winit` is the most sensible
    thing to do.
    
    While it could be offloaded to crates like copypasta[1] the result is
    always not good enough[2][3] and it also results in
    overengineering[4] (look at its codebase size and compare to what we've
    got in winit for Wayland and how much better the handling is done in
    winit).
    
    The new API is on the `Window` and is the following:
    
    ```rust
    pub fn set_clipboard_content<C: AsRef<[u8]> + 'static>(
        &self,
        content:
        C, mimes: HashSet<String>);
    
    pub fn request_clipboard_content(
        &self,
        mimes: HashSet<String>,
        metadata: Option<std::sync::Arc<ClipboardMetadata>>);
    ```
    
    And also on `WindowExtUnix` where added similar methods to get primary
    selection content (The one on middle mouse button).
    
    Working with clipboard is async and loading it is in resulted window
    event in `event::WindowEvent::ClipboardContent`.
    
    The use of metadata is due to provide ability to identify requested
    load from system's clipboard.
    
    [1] - https://github.com/alacritty/copypasta.
    [2] - alacritty/alacritty#3108
    [3] - alacritty/alacritty#3601
    [4] - https://github.com/Smithay/smithay-clipboard
    kchibisov committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    8b3b5df View commit details
    Browse the repository at this point in the history