wayland: Refactor clipboard implementation (#12405)
Fixes https://github.com/zed-industries/zed/issues/12054 Replaces the `copypasta`/`smithay-clipboard` implementation with a new, custom one TODO list: - [x] Cleanup code - [x] Remove `smithay-clipboard` - [x] Add more mime types to the supported list Release Notes: - Fixed drag and drop on Gnome - Fixed clipboard paste on Hyprland
This commit is contained in:
parent
b55961b57a
commit
f6fa6600bc
10 changed files with 491 additions and 175 deletions
|
@ -12,7 +12,7 @@ use std::{
|
|||
|
||||
use ::util::ResultExt;
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use copypasta::{ClipboardContext, ClipboardProvider};
|
||||
use clipboard_win::{get_clipboard_string, set_clipboard_string};
|
||||
use futures::channel::oneshot::{self, Receiver};
|
||||
use itertools::Itertools;
|
||||
use parking_lot::RwLock;
|
||||
|
@ -502,16 +502,14 @@ impl Platform for WindowsPlatform {
|
|||
|
||||
fn write_to_clipboard(&self, item: ClipboardItem) {
|
||||
if item.text.len() > 0 {
|
||||
let mut ctx = ClipboardContext::new().unwrap();
|
||||
ctx.set_contents(item.text().to_owned()).unwrap();
|
||||
set_clipboard_string(item.text()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn read_from_clipboard(&self) -> Option<ClipboardItem> {
|
||||
let mut ctx = ClipboardContext::new().unwrap();
|
||||
let content = ctx.get_contents().ok()?;
|
||||
let text = get_clipboard_string().ok()?;
|
||||
Some(ClipboardItem {
|
||||
text: content,
|
||||
text,
|
||||
metadata: None,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue