Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Flatpak on Wayland: say why a paste finds nothing, and how to paste anyway (#5031) (#5279)

Nicolas Falesy8bed609ef045
diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rs
index 80f0b2d3a..fcacf81b2 100644
--- a/apps/photocraft/src/services.rs
+++ b/apps/photocraft/src/services.rs
@@ -6,7 +6,7 @@ use photocraft_doc::{Document, Layer, Size};
use photocraft_format::RecoveryStore;
use photocraft_geom::Rect;
use photocraft_ui_egui::{FileDialogAnswer, FileDialogReply, FileDialogRequest, Recoverable, Services};
-use std::cell::RefCell;
+use std::cell::{Cell, RefCell};
use std::future::Future;
use std::path::{Path, PathBuf};
use std::pin::Pin;
@@ -493,6 +493,7 @@ fn shell_word(s: &str) -> String {
pub fn native(automation: Option<photocraft_automation::AuthorizedWorkspace>) -> Services {
let clip: Rc<RefCell<Option<arboard::Clipboard>>> = Rc::default();
+ let clip_unreadable: Rc<Cell<bool>> = Rc::default();
let automation_read = automation.clone().map(|workspace| {
Box::new(move |path: &str| {
let bytes = workspace.read(path).map_err(|error| error.to_string())?;
@@ -566,11 +567,19 @@ pub fn native(automation: Option<photocraft_automation::AuthorizedWorkspace>) ->
}),
clipboard_get_image: Some({
let clip = clip.clone();
+ let unreadable = clip_unreadable.clone();
Box::new(move || {
let mut slot = clip.try_borrow_mut().ok()?;
let cb = match slot.as_mut() {
Some(c) => c,
- None => slot.insert(arboard::Clipboard::new().ok()?),
+ None => {
+ // arboard opens only when some backend works. In a Flatpak on Wayland none
+ // does (#5031): the sandbox hides the data-control protocol from it, and
+ // `--socket=fallback-x11` gives no X server while a compositor runs.
+ let opened = arboard::Clipboard::new();
+ unreadable.set(opened.is_err());
+ slot.insert(opened.ok()?)
+ }
};
// Copied files first: Finder also puts the file's icon on the clipboard as an
// image, which would otherwise paste instead of the file.
@@ -586,6 +595,7 @@ pub fn native(automation: Option<photocraft_automation::AuthorizedWorkspace>) ->
None
})
}),
+ clipboard_unreadable: Some(Box::new(move || clip_unreadable.get())),
load_prefs: Some(Box::new(|| std::fs::read_to_string(prefs_file()?).ok())),
photoshop_shortcuts: Some(Box::new(|| crate::photoshop_settings::live_keyboard_shortcuts(&|k| std::env::var_os(k)))),
save_prefs: Some(Box::new(|text: &str| write_atomic(&prefs_file().ok_or("no config directory")?, text.as_bytes()))),
diff --git a/contributors/people.toml b/contributors/people.toml
index 34c50d4d9..bc3533777 100644
--- a/contributors/people.toml
+++ b/contributors/people.toml
@@ -159,6 +159,9 @@ sync_github_name = false
real_name = "Ufuk Efe"
sync_github_name = true
+[people.nicolasfalesy]
+sync_github_name = true
+
[people.sidney]
real_name = "Sidney Markowitz"
sync_github_name = true
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index 7894c0094..f6046fc20 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -3798,6 +3798,10 @@ navigator Zoom Zvětšení
# View › Guides › right-click a guide
Edit Selected Guides Upravit vybraná vodítka
Clear Selected Guides Vymazat vybraná vodítka
+ Pasting from other apps is unavailable Vkládání z jiných aplikací není k dispozici
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft v této relaci nemá přístup k systémové schránce. Na Waylandu sandbox Flatpaku skrývá protokol, přes který se čtou obrázky z jiných aplikací.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Chcete-li vkládat z jiných aplikací, spusťte PhotoCraft pod XWaylandem: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Není co vložit: PhotoCraft zde nemůže číst systémovou schránku
Delete this set Smazat tuto sadu
New Set… Nová sada…
PhotoCraft Defaults Výchozí PhotoCraft
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index 6468ef3bf..0ad7366c4 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -3194,6 +3194,10 @@ curves Smooth Glätten
# View › Guides › right-click a guide
Edit Selected Guides Ausgewählte Hilfslinien bearbeiten
Clear Selected Guides Ausgewählte Hilfslinien löschen
+ Pasting from other apps is unavailable Einfügen aus anderen Apps ist nicht verfügbar
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft kann in dieser Sitzung nicht auf die Systemzwischenablage zugreifen. Unter Wayland verbirgt eine Flatpak-Sandbox das Protokoll, über das Bilder aus anderen Apps gelesen werden.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Um aus anderen Apps einzufügen, starte PhotoCraft unter XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Nichts einzufügen: PhotoCraft kann die Systemzwischenablage hier nicht lesen
Delete this set Diesen Satz löschen
New Set… Neuer Satz…
PhotoCraft Defaults PhotoCraft-Standard
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index 0a0f1fda2..83621629f 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -3890,6 +3890,10 @@ curves Smooth Εξομάλυνση
# View › Guides › right-click a guide
Edit Selected Guides Επεξεργασία επιλεγμένων οδηγών
Clear Selected Guides Απαλοιφή επιλεγμένων οδηγών
+ Pasting from other apps is unavailable Η επικόλληση από άλλες εφαρμογές δεν είναι διαθέσιμη
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. Το PhotoCraft δεν έχει πρόσβαση στο πρόχειρο του συστήματος σε αυτή τη συνεδρία. Στο Wayland, το sandbox του Flatpak κρύβει το πρωτόκολλο μέσω του οποίου διαβάζονται εικόνες από άλλες εφαρμογές.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Για επικόλληση από άλλες εφαρμογές, ξεκινήστε το PhotoCraft σε XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Τίποτα για επικόλληση: το PhotoCraft δεν μπορεί να διαβάσει εδώ το πρόχειρο του συστήματος
Delete this set Διαγραφή αυτού του συνόλου
New Set… Νέο σύνολο…
PhotoCraft Defaults Προεπιλογές PhotoCraft
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index ba1183354..e23b4e84c 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -4152,6 +4152,10 @@ navigator Zoom Zoom
# View › Guides › right-click a guide
Edit Selected Guides Editar guías seleccionadas
Clear Selected Guides Borrar guías seleccionadas
+ Pasting from other apps is unavailable Pegar desde otras aplicaciones no está disponible
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft no puede acceder al portapapeles del sistema en esta sesión. En Wayland, el entorno aislado de Flatpak oculta el protocolo con el que se leen las imágenes de otras aplicaciones.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Para pegar desde otras aplicaciones, inicia PhotoCraft en XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Nada que pegar: PhotoCraft no puede leer aquí el portapapeles del sistema
Delete this set Eliminar este conjunto
New Set… Nuevo conjunto…
PhotoCraft Defaults Valores por defecto de PhotoCraft
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index 12bafb51d..3bcca7037 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -3196,6 +3196,10 @@ curves Smooth Lisser
# View › Guides › right-click a guide
Edit Selected Guides Modifier les repères sélectionnés
Clear Selected Guides Effacer les repères sélectionnés
+ Pasting from other apps is unavailable Le collage depuis d’autres applications est indisponible
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft ne peut pas accéder au presse-papiers du système dans cette session. Sous Wayland, le bac à sable Flatpak masque le protocole par lequel les images des autres applications sont lues.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Pour coller depuis d’autres applications, lancez PhotoCraft sous XWayland : `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Rien à coller : PhotoCraft ne peut pas lire ici le presse-papiers du système
Delete this set Supprimer ce jeu
New Set… Nouveau jeu…
PhotoCraft Defaults Valeurs par défaut de PhotoCraft
diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv
index c670182e6..4907e2da0 100644
--- a/crates/ui-egui/src/i18n/hu.tsv
+++ b/crates/ui-egui/src/i18n/hu.tsv
@@ -4109,6 +4109,10 @@ cameraRaw Yellow Sárga
# View › Guides › right-click a guide
Edit Selected Guides Kijelölt segédvonalak szerkesztése
Clear Selected Guides Kijelölt segédvonalak törlése
+ Pasting from other apps is unavailable A beillesztés más alkalmazásokból nem érhető el
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. A PhotoCraft ebben a munkamenetben nem fér hozzá a rendszer vágólapjához. Waylanden a Flatpak homokozó elrejti azt a protokollt, amelyen keresztül más alkalmazások képei olvashatók.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Ha más alkalmazásokból szeretne beilleszteni, indítsa a PhotoCraftot XWayland alatt: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Nincs mit beilleszteni: a PhotoCraft itt nem tudja olvasni a rendszer vágólapját
Delete this set Készlet törlése
New Set… Új készlet…
PhotoCraft Defaults PhotoCraft alapértelmezések
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index 5142781b0..fc0d66afa 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -3183,6 +3183,10 @@ curves Smooth Haluskan
# View › Guides › right-click a guide
Edit Selected Guides Edit Panduan Terpilih
Clear Selected Guides Hapus Panduan Terpilih
+ Pasting from other apps is unavailable Menempel dari aplikasi lain tidak tersedia
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft tidak dapat mengakses papan klip sistem dalam sesi ini. Di Wayland, sandbox Flatpak menyembunyikan protokol yang digunakan untuk membaca gambar dari aplikasi lain.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Untuk menempel dari aplikasi lain, jalankan PhotoCraft di bawah XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Tidak ada yang ditempel: PhotoCraft tidak dapat membaca papan klip sistem di sini
Delete this set Hapus set ini
New Set… Set Baru…
PhotoCraft Defaults Bawaan PhotoCraft
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index 9ccb67dd8..609469635 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -4311,6 +4311,10 @@ shape Appearance Aspetto
# View › Guides › right-click a guide
Edit Selected Guides Modifica guide selezionate
Clear Selected Guides Cancella guide selezionate
+ Pasting from other apps is unavailable Incollare da altre app non è disponibile
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft non può accedere agli appunti di sistema in questa sessione. Su Wayland, la sandbox di Flatpak nasconde il protocollo con cui vengono lette le immagini delle altre app.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Per incollare da altre app, avvia PhotoCraft in XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Niente da incollare: qui PhotoCraft non può leggere gli appunti di sistema
Delete this set Elimina questo set
New Set… Nuovo set…
PhotoCraft Defaults Predefiniti di PhotoCraft
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index 372cd0690..39a38a114 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -3866,6 +3866,10 @@ curves Smooth スムーズ
# View › Guides › right-click a guide
Edit Selected Guides 選択したガイドを編集
Clear Selected Guides 選択したガイドを消去
+ Pasting from other apps is unavailable 他のアプリからの貼り付けは利用できません
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. このセッションでは PhotoCraft がシステムのクリップボードにアクセスできません。Wayland では、Flatpak のサンドボックスが他のアプリの画像を読み取るためのプロトコルを隠します。
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` 他のアプリから貼り付けるには、XWayland 上で PhotoCraft を起動してください: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here 貼り付けるものがありません: ここでは PhotoCraft がシステムのクリップボードを読み取れません
Delete this set このセットを削除
New Set… 新規セット…
PhotoCraft Defaults PhotoCraft 初期設定
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index 60f50975a..241c81bef 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -3370,6 +3370,10 @@ curves Smooth 매끄럽게
# View › Guides › right-click a guide
Edit Selected Guides 선택한 안내선 편집
Clear Selected Guides 선택한 안내선 지우기
+ Pasting from other apps is unavailable 다른 앱에서 붙여넣기를 사용할 수 없습니다
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. 이 세션에서는 PhotoCraft가 시스템 클립보드에 접근할 수 없습니다. Wayland에서는 Flatpak 샌드박스가 다른 앱의 이미지를 읽는 데 쓰이는 프로토콜을 숨깁니다.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` 다른 앱에서 붙여넣으려면 XWayland에서 PhotoCraft를 실행하세요: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here 붙여넣을 내용 없음: 여기서는 PhotoCraft가 시스템 클립보드를 읽을 수 없습니다
Delete this set 이 세트 삭제
New Set… 새 세트…
PhotoCraft Defaults PhotoCraft 기본값
diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv
index 18c37120e..e0dd17ff5 100644
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@ -3950,6 +3950,10 @@ curves Smooth Vloeiend maken
# View › Guides › right-click a guide
Edit Selected Guides Geselecteerde hulplijnen bewerken
Clear Selected Guides Geselecteerde hulplijnen wissen
+ Pasting from other apps is unavailable Plakken vanuit andere apps is niet beschikbaar
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft heeft in deze sessie geen toegang tot het systeemklembord. Onder Wayland verbergt een Flatpak-sandbox het protocol waarmee afbeeldingen uit andere apps worden gelezen.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Om vanuit andere apps te plakken, start je PhotoCraft onder XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Niets om te plakken: PhotoCraft kan het systeemklembord hier niet lezen
Delete this set Deze set verwijderen
New Set… Nieuwe set…
PhotoCraft Defaults PhotoCraft-standaard
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index ca1f466d8..10435771f 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -3788,6 +3788,10 @@ curves Smooth Wygładź
# View › Guides › right-click a guide
Edit Selected Guides Edytuj zaznaczone prowadnice
Clear Selected Guides Usuń zaznaczone prowadnice
+ Pasting from other apps is unavailable Wklejanie z innych aplikacji jest niedostępne
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft nie ma w tej sesji dostępu do schowka systemowego. W Waylandzie piaskownica Flatpaka ukrywa protokół, przez który odczytywane są obrazy z innych aplikacji.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Aby wklejać z innych aplikacji, uruchom PhotoCraft pod XWaylandem: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Nie ma czego wkleić: PhotoCraft nie może tutaj odczytać schowka systemowego
Delete this set Usuń ten zestaw
New Set… Nowy zestaw…
PhotoCraft Defaults Domyślne PhotoCraft
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index 6f98a4362..f4dc857f7 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -3980,6 +3980,10 @@ layerLabel No Color Sem cor
# View › Guides › right-click a guide
Edit Selected Guides Editar guias selecionadas
Clear Selected Guides Limpar guias selecionadas
+ Pasting from other apps is unavailable Colar de outros aplicativos não está disponível
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. O PhotoCraft não consegue acessar a área de transferência do sistema nesta sessão. No Wayland, a sandbox do Flatpak oculta o protocolo pelo qual as imagens de outros aplicativos são lidas.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Para colar de outros aplicativos, execute o PhotoCraft no XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Nada para colar: o PhotoCraft não consegue ler a área de transferência do sistema aqui
Delete this set Excluir este conjunto
New Set… Novo conjunto…
PhotoCraft Defaults Padrões do PhotoCraft
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 1fd816bf9..b497b4185 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -3161,6 +3161,10 @@ curves Smooth Сгладить
# View › Guides › right-click a guide
Edit Selected Guides Изменить выбранные направляющие
Clear Selected Guides Удалить выбранные направляющие
+ Pasting from other apps is unavailable Вставка из других приложений недоступна
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. В этом сеансе PhotoCraft не может получить доступ к системному буферу обмена. В Wayland песочница Flatpak скрывает протокол, через который читаются изображения из других приложений.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Чтобы вставлять из других приложений, запустите PhotoCraft под XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Нечего вставить: здесь PhotoCraft не может прочитать системный буфер обмена
Delete this set Удалить этот набор
New Set… Новый набор…
PhotoCraft Defaults Стандартные PhotoCraft
diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv
index a9ff4435b..dc3608c51 100644
--- a/crates/ui-egui/src/i18n/sr.tsv
+++ b/crates/ui-egui/src/i18n/sr.tsv
@@ -4263,6 +4263,10 @@ shape Appearance Izgled
# View › Guides › right-click a guide
Edit Selected Guides Uredi izabrane vodilje
Clear Selected Guides Ukloni izabrane vodilje
+ Pasting from other apps is unavailable Lepljenje iz drugih aplikacija nije dostupno
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft u ovoj sesiji ne može da pristupi sistemskoj ostavi. Na Wayland-u, Flatpak sandbox skriva protokol preko kog se čitaju slike iz drugih aplikacija.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Da biste lepili iz drugih aplikacija, pokrenite PhotoCraft pod XWayland-om: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Nema šta da se nalepi: PhotoCraft ovde ne može da čita sistemsku ostavu
Delete this set Obriši ovaj skup
New Set… Novi skup…
PhotoCraft Defaults Podrazumevano za PhotoCraft
diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv
index fb4b426c2..5e5326f9f 100644
--- a/crates/ui-egui/src/i18n/tr.tsv
+++ b/crates/ui-egui/src/i18n/tr.tsv
@@ -3920,6 +3920,10 @@ cameraData Lens Lens
# View › Guides › right-click a guide
Edit Selected Guides Seçili Kılavuzları Düzenle
Clear Selected Guides Seçili Kılavuzları Temizle
+ Pasting from other apps is unavailable Diğer uygulamalardan yapıştırma kullanılamıyor
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft bu oturumda sistem panosuna erişemiyor. Wayland'de Flatpak korumalı alanı, diğer uygulamalardaki görüntülerin okunduğu protokolü gizler.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Diğer uygulamalardan yapıştırmak için PhotoCraft'ı XWayland altında başlatın: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Yapıştırılacak bir şey yok: PhotoCraft burada sistem panosunu okuyamıyor
Delete this set Bu Kümeyi Sil
New Set… Yeni Küme…
PhotoCraft Defaults PhotoCraft Varsayılanları
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index d8510183d..cc3df8834 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -3889,6 +3889,10 @@ curves Smooth Згладити
# View › Guides › right-click a guide
Edit Selected Guides Редагувати вибрані напрямні
Clear Selected Guides Очистити вибрані напрямні
+ Pasting from other apps is unavailable Вставлення з інших застосунків недоступне
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. У цьому сеансі PhotoCraft не має доступу до системного буфера обміну. У Wayland пісочниця Flatpak приховує протокол, через який читаються зображення з інших застосунків.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Щоб вставляти з інших застосунків, запустіть PhotoCraft під XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Нічого вставити: тут PhotoCraft не може прочитати системний буфер обміну
Delete this set Видалити цей набір
New Set… Новий набір…
PhotoCraft Defaults Стандартні PhotoCraft
diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv
index a1106bbbc..d19e3d576 100644
--- a/crates/ui-egui/src/i18n/vi.tsv
+++ b/crates/ui-egui/src/i18n/vi.tsv
@@ -3676,6 +3676,10 @@ curves Smooth Làm mượt
# View › Guides › right-click a guide
Edit Selected Guides Sửa đường căn đã chọn
Clear Selected Guides Xóa đường căn đã chọn
+ Pasting from other apps is unavailable Không thể dán từ ứng dụng khác
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft không truy cập được bộ nhớ tạm của hệ thống trong phiên này. Trên Wayland, sandbox của Flatpak ẩn giao thức dùng để đọc hình ảnh từ ứng dụng khác.
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` Để dán từ ứng dụng khác, hãy khởi động PhotoCraft dưới XWayland: `{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here Không có gì để dán: PhotoCraft không thể đọc bộ nhớ tạm của hệ thống ở đây
Delete this set Xóa bộ này
New Set… Bộ mới…
PhotoCraft Defaults Mặc định của PhotoCraft
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index c10a287de..675a54450 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -2811,6 +2811,10 @@ curves Smooth 平滑
# View › Guides › right-click a guide
Edit Selected Guides 编辑所选参考线
Clear Selected Guides 清除所选参考线
+ Pasting from other apps is unavailable 无法从其他应用粘贴
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft 在此会话中无法访问系统剪贴板。在 Wayland 上,Flatpak 沙盒会隐藏读取其他应用图像所用的协议。
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` 要从其他应用粘贴,请在 XWayland 下启动 PhotoCraft:`{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here 没有可粘贴的内容:PhotoCraft 在此无法读取系统剪贴板
Delete this set 删除此组
New Set… 新建组…
PhotoCraft Defaults PhotoCraft 默认值
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index 82015e575..982fa9731 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -2796,6 +2796,10 @@ curves Smooth 平滑
# View › Guides › right-click a guide
Edit Selected Guides 編輯所選參考線
Clear Selected Guides 清除所選參考線
+ Pasting from other apps is unavailable 無法從其他應用程式貼上
+ PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through. PhotoCraft 在此工作階段中無法存取系統剪貼簿。在 Wayland 上,Flatpak 沙盒會隱藏讀取其他應用程式影像所用的協定。
+ To paste from other apps, start PhotoCraft under XWayland: `{command}` 若要從其他應用程式貼上,請在 XWayland 下啟動 PhotoCraft:`{command}`
+ Nothing to paste: PhotoCraft can't read the system clipboard here 沒有可貼上的內容:PhotoCraft 在此無法讀取系統剪貼簿
Delete this set 刪除此組合
New Set… 新增組合…
PhotoCraft Defaults PhotoCraft 預設值
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index fb2c42eaa..89f293a2c 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -403,6 +403,8 @@ pub type EncodePngFn = Box<dyn Fn(u32, u32, &[u8]) -> Result<Vec<u8>, String>>;
pub type ClipboardSetFn = Box<dyn FnMut(u32, u32, &[u8]) -> Result<(), String>>;
/// Read an RGBA8 image from the OS clipboard.
pub type ClipboardGetFn = Box<dyn FnMut() -> Option<(u32, u32, Vec<u8>)>>;
+/// Whether the last clipboard read found no way to reach the OS clipboard at all.
+pub type ClipboardUnreadableFn = Box<dyn Fn() -> bool>;
/// Shared queue of (file name, bytes) delivered asynchronously.
pub type Inbox = std::sync::Arc<std::sync::Mutex<Vec<(String, Vec<u8>)>>>;
/// Read the saved preferences text (`None` when there is none yet).
@@ -507,6 +509,9 @@ pub struct Services {
/// OS clipboard images: copies go out, screenshots and images from other apps come in.
pub clipboard_set_image: Option<ClipboardSetFn>,
pub clipboard_get_image: Option<ClipboardGetFn>,
+ /// True when the last `clipboard_get_image` read had no clipboard to read, as in a Flatpak on
+ /// Wayland (#5031), rather than a clipboard that holds no image. `None` where that can't happen.
+ pub clipboard_unreadable: Option<ClipboardUnreadableFn>,
/// Preferences persistence: the platform config directory on native, browser storage on
/// the web (see `prefs_ui`).
pub load_prefs: Option<LoadTextFn>,
@@ -1136,6 +1141,11 @@ impl PhotocraftApp {
self.import_os_clipboard();
}
if self.session.clipboard.is_none() && self.services.clipboard_get_image.is_some() {
+ if self.services.clipboard_unreadable.as_ref().is_some_and(|unreadable| unreadable()) {
+ // The clipboard may well hold an image that can't be reached: say why.
+ notices::clipboard_unreadable(self);
+ return Ok(serde_json::json!({"pasted": false}));
+ }
// Enabled on the strength of the OS clipboard, which held no image: a quiet no-op.
let message = "Nothing to paste: the clipboard holds no image";
self.ui.status = tl!(message).into();
diff --git a/crates/ui-egui/src/notices.rs b/crates/ui-egui/src/notices.rs
index cd974fbbe..76cdc7b9b 100644
--- a/crates/ui-egui/src/notices.rs
+++ b/crates/ui-egui/src/notices.rs
@@ -8,6 +8,7 @@ use serde::{Deserialize, Serialize};
use crate::PhotocraftApp;
const WAYLAND_FILE_DROP_DISMISSED: &str = "ui.waylandFileDropGuidanceDismissed";
+const CLIPBOARD_UNREADABLE: &str = "Pasting from other apps is unavailable";
/// At most this many notices are kept; older ones drop off.
pub const MAX_NOTICES: usize = 3;
/// Lines shown per notice before "…and N more".
@@ -91,6 +92,30 @@ pub fn wayland_file_drop_guidance(app: &mut PhotocraftApp) {
}
}
+/// A paste found no clipboard to read (#5031). In a Flatpak on Wayland the sandbox hides the
+/// data-control protocol that other apps' images are read through, and there is no X server to
+/// fall back to, so the clipboard may hold an image all the same. Say so, and give the command
+/// that starts this install under XWayland, where the X11 clipboard works, when there is one.
+pub fn clipboard_unreadable(app: &mut PhotocraftApp) {
+ app.ui.status = tl!("Nothing to paste: PhotoCraft can't read the system clipboard here").into();
+ app.ui.status_error = false;
+ if app.ui.notices.iter().any(|notice| notice.title == CLIPBOARD_UNREADABLE) {
+ return;
+ }
+ // English templates, translated when drawn, as in `wayland_file_drop_guidance`.
+ let mut lines =
+ vec!["PhotoCraft can't reach the system clipboard in this session. On Wayland, a Flatpak sandbox hides the protocol that images from other apps are read through.".to_owned()];
+ let mut args = Vec::new();
+ if let Some(command) = &app.services.xwayland_command {
+ lines.push("To paste from other apps, start PhotoCraft under XWayland: `{command}`".to_owned());
+ args.push(("command".to_owned(), command.clone()));
+ }
+ let id = post(app, CLIPBOARD_UNREADABLE, lines, false, None);
+ if let Some(notice) = app.ui.notices.iter_mut().find(|notice| notice.id == id) {
+ notice.args = args;
+ }
+}
+
/// A full refresh of document `doc` fell back to the CPU compositor (`reason`, the GPU's) and took
/// `ms`. The canvas doesn't respond while it runs, so once per document say why it was slow and
/// which edits will do it again (#1015).
@@ -278,6 +303,37 @@ mod tests {
assert_eq!(crate::i18n::tr(crate::i18n::Lang::EN, &notice.title), "Native file drag-and-drop is unavailable");
}
+ /// #5031: a paste that can't reach the clipboard (a Flatpak on Wayland) says why and how to
+ /// paste anyway, once while shown; a clipboard that simply holds no image stays a quiet no-op.
+ #[test]
+ fn unreadable_clipboard_paste_explains_the_sandbox() {
+ let command = "flatpak run --nosocket=wayland --socket=x11 ai.storyteller.photocraft";
+ let services = |unreadable: bool| Services {
+ clipboard_get_image: Some(Box::new(|| None)),
+ clipboard_unreadable: Some(Box::new(move || unreadable)),
+ xwayland_command: Some(command.to_string()),
+ ..Default::default()
+ };
+ let ctx = egui::Context::default();
+ let mut app = PhotocraftApp::new(Session::new(), services(true));
+ for _ in 0..2 {
+ let r = crate::menus::invoke(&mut app, &ctx, "edit.paste", serde_json::json!({})).unwrap();
+ assert_eq!(r["pasted"], serde_json::json!(false));
+ }
+ assert_eq!(app.ui.status, "Nothing to paste: PhotoCraft can't read the system clipboard here");
+ let shown: Vec<_> = app.ui.notices.iter().filter(|notice| notice.title == CLIPBOARD_UNREADABLE).collect();
+ assert_eq!(shown.len(), 1, "a second paste doesn't stack another notice");
+ let guidance = english(shown[0]);
+ assert!(guidance.contains(&format!("under XWayland: `{command}`")), "{guidance}");
+ let es = crate::i18n::Lang::from_code("es").unwrap();
+ assert!(shown[0].lines.iter().chain([&shown[0].title]).all(|line| crate::i18n::tr(es, line) != *line), "every line is a catalog template");
+
+ let mut empty = PhotocraftApp::new(Session::new(), services(false));
+ crate::menus::invoke(&mut empty, &ctx, "edit.paste", serde_json::json!({})).unwrap();
+ assert_eq!(empty.ui.status, "Nothing to paste: the clipboard holds no image");
+ assert!(empty.ui.notices.iter().all(|notice| notice.title != CLIPBOARD_UNREADABLE));
+ }
+
/// A notice's lines in English with their arguments filled in.
fn english(notice: &Notice) -> String {
let args: Vec<(&str, &str)> = notice.args.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();