-
Notifications
You must be signed in to change notification settings - Fork 70
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
XDG Parenting Support #46
Comments
@PolyMeilex should be fixed from ashpd side, the wayland part is very untested but it should work i guess. Please give it a try and let me know how that goes, if all goes as expected I will do another beta and then aim for a 0.2 release. |
Thanks for the heads-up! |
Just a small update for bystanders. I'm not going to depend on ashpd parenting support until we finish work on wayland-rs-0.30 release, we can't have alpha deps in the tree, especially as dynamically changing ones as wayland-rs 0.30 rework. |
With that issue closed a while back, what is the current status of this? I've recently started using |
Yeah, we released wayland-rs 0.30 a while ago, and ashpd already updated to it, so the only thing left is to wire it up in RFD xdg desktop backend |
@PolyMeilex I had a look into this, but I think it's a little beyond me due to my still limited Rust experience. I got the following to compile, but I'm not sure if this is the desired approach: diff --git a/Cargo.toml b/Cargo.toml
index 10f7ca2..a6ab94d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@ repository = "https://github.com/PolyMeilex/rfd"
documentation = "https://docs.rs/rfd"
[features]
-default = ["gtk3"]
+default = ["xdg-portal"]
file-handle-inner = []
gtk3 = ["gtk-sys", "glib-sys", "gobject-sys"]
xdg-portal = ["ashpd", "urlencoding", "pollster", "async-io", "futures-util"]
@@ -46,7 +46,7 @@ async-io = { version = "1.3", optional = true }
futures-util = { version = "0.3", optional = true, default-features = false, features = ["io"] }
# XDG Desktop Portal
-ashpd = { version = "0.6", optional = true }
+ashpd = { version = "0.6", optional = true, features = ["raw_handle"] }
urlencoding = { version = "2.1.0", optional = true }
pollster = { version = "0.3", optional = true }
# GTK
diff --git a/src/backend/xdg_desktop_portal.rs b/src/backend/xdg_desktop_portal.rs
index 0bbabad..0bf9242 100644
--- a/src/backend/xdg_desktop_portal.rs
+++ b/src/backend/xdg_desktop_portal.rs
@@ -61,8 +61,15 @@ impl AsyncFilePickerDialogImpl for FileDialog {
}
fn pick_files_async(self) -> DialogFutureType<Option<Vec<FileHandle>>> {
+ let identifier = if let Some(parent) = self.parent {
+ Some(block_on(ashpd::WindowIdentifier::from_raw_handle(&parent, None)))
+ } else {
+ None
+ };
+
Box::pin(async {
OpenFileRequest::default()
+ .identifier(identifier)
.accept_label("Pick file(s)")
.multiple(true)
.title( Open questions for me:
|
set_parent Should accept
Not sure to be honest, haven't looked into what it does on X and Wayland, perhaps it does some roundtrips to the display server, but I suppose it should not take significant amounts of time. |
On X it doesn't require any server communication, on Wayland it spawns a thread to do a request + response with the server to generate the ID: src/window_identifier/wayland.rs#L87-L94 It should be possible to do this without any blocking by ensuring the window object (whatever it may be) stays alive as long as the future is alive. But to do that safely I think would require updating to use the borrowing traits. Otherwise the |
bilelmoussaoui/ashpd#40
The text was updated successfully, but these errors were encountered: