Skip to content

Commit f6fa74c

Browse files
authored
Don't enable arboard on iOS (#7663)
`arboard` [doesn't support support iOS yet](1Password/arboard#103), so this PR adds iOS to the conditions that prevent `arboard` from being enabled. Launching an app on a physical device results in a long timeout (~8s) while trying to connect to the X11 server (the timeout is immediate when launching on a simulator), with the following trace: ``` egui_winit::clipboard: Failed to initialize arboard clipboard: Unknown error while interacting with the clipboard: X11 server connection timed out because it was unreachable ``` <!-- Please read the "Making a PR" section of [`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md) before opening a Pull Request! * Keep your PR:s small and focused. * The PR title is what ends up in the changelog, so make it descriptive! * If applicable, add a screenshot or gif. * If it is a non-trivial addition, consider adding a demo for it to `egui_demo_lib`, or a new example. * Do NOT open PR:s from your `master` branch, as that makes it hard for maintainers to test and add commits to your PR. * Remember to run `cargo fmt` and `cargo clippy`. * Open the PR as a draft until you have self-reviewed it and run `./scripts/check.sh`. * When you have addressed a PR comment, mark it as resolved. Please be patient! I will review your PR, but my time is limited! --> * [x] I have followed the instructions in the PR template
1 parent 30eb38e commit f6fa74c

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

crates/egui-winit/src/clipboard.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ use raw_window_handle::RawDisplayHandle;
55
/// If the "clipboard" feature is off, or we cannot connect to the OS clipboard,
66
/// then a fallback clipboard that just works within the same app is used instead.
77
pub struct Clipboard {
8-
#[cfg(all(feature = "arboard", not(target_os = "android")))]
8+
#[cfg(all(
9+
not(any(target_os = "android", target_os = "ios")),
10+
feature = "arboard",
11+
))]
912
arboard: Option<arboard::Clipboard>,
1013

1114
#[cfg(all(
@@ -28,7 +31,10 @@ impl Clipboard {
2831
/// Construct a new instance
2932
pub fn new(_raw_display_handle: Option<RawDisplayHandle>) -> Self {
3033
Self {
31-
#[cfg(all(feature = "arboard", not(target_os = "android")))]
34+
#[cfg(all(
35+
not(any(target_os = "android", target_os = "ios")),
36+
feature = "arboard",
37+
))]
3238
arboard: init_arboard(),
3339

3440
#[cfg(all(
@@ -68,7 +74,10 @@ impl Clipboard {
6874
};
6975
}
7076

71-
#[cfg(all(feature = "arboard", not(target_os = "android")))]
77+
#[cfg(all(
78+
not(any(target_os = "android", target_os = "ios")),
79+
feature = "arboard",
80+
))]
7281
if let Some(clipboard) = &mut self.arboard {
7382
return match clipboard.get_text() {
7483
Ok(text) => Some(text),
@@ -98,7 +107,10 @@ impl Clipboard {
98107
return;
99108
}
100109

101-
#[cfg(all(feature = "arboard", not(target_os = "android")))]
110+
#[cfg(all(
111+
not(any(target_os = "android", target_os = "ios")),
112+
feature = "arboard",
113+
))]
102114
if let Some(clipboard) = &mut self.arboard {
103115
if let Err(err) = clipboard.set_text(text) {
104116
log::error!("arboard copy/cut error: {err}");
@@ -110,7 +122,10 @@ impl Clipboard {
110122
}
111123

112124
pub fn set_image(&mut self, image: &egui::ColorImage) {
113-
#[cfg(all(feature = "arboard", not(target_os = "android")))]
125+
#[cfg(all(
126+
not(any(target_os = "android", target_os = "ios")),
127+
feature = "arboard",
128+
))]
114129
if let Some(clipboard) = &mut self.arboard {
115130
if let Err(err) = clipboard.set_image(arboard::ImageData {
116131
width: image.width(),
@@ -130,7 +145,10 @@ impl Clipboard {
130145
}
131146
}
132147

133-
#[cfg(all(feature = "arboard", not(target_os = "android")))]
148+
#[cfg(all(
149+
not(any(target_os = "android", target_os = "ios")),
150+
feature = "arboard",
151+
))]
134152
fn init_arboard() -> Option<arboard::Clipboard> {
135153
profiling::function_scope!();
136154

0 commit comments

Comments
 (0)