rfd icon indicating copy to clipboard operation
rfd copied to clipboard

[BUG] Dialog not showing up with `xdg-desktop-portal > 1.16`

Open RenjiSann opened this issue 1 year ago • 13 comments

Hi, I am running Arch Linux, with the 6.1 LTS kernel. I have the xdg-desktop-portal (1.18.0) installed with the xdg-desktop-portal-gtk (1.15.1) backend.

When compiling rfd with the xdg-portal feature, the dialog won't show up. I was able to make it work by downgrading xdg-desktop-portal to version 1.16, though, so this might be some breaking API changes.

Kind regards,

RenjiSann avatar Nov 02 '23 13:11 RenjiSann

For references, here are my main.rs and Cargo.toml. I also add that everything works well when using the default feature flags with the gtk backend.

use rfd::FileDialog;

fn main() {
    println!("Hello, world!");

    let files = FileDialog::new()
        .set_directory("/")
        .pick_file();

    println!("files: {:?}", files);
}
[package]
name = "test"
version = "0.1.0"
edition = "2021"


[dependencies]
rfd = { version = "0.12.1", default-features = false, features = [
    "xdg-portal",
] }

RenjiSann avatar Nov 02 '23 13:11 RenjiSann

I'm having similar issues. The main difference in my setup is I'm using xdg-desktop-portal-hyprland as the backend instead of -gtk.

alerque avatar Nov 02 '23 14:11 alerque

I have encountered this problem in tauri with xdg-desktop-portal-hyprland

LIMPIX31 avatar Nov 25 '23 18:11 LIMPIX31

running cargo run --example save --no-default-features --features xdg-portal works on both my desktop arch box running gnome and xdg-desktop-portal 1.18.2 as well as my fedora laptop running the same configuration

Friz64 avatar Nov 27 '23 20:11 Friz64

Name         : xdg-desktop-portal
Version      : 1.18.2
Name         : xdg-desktop-portal-gtk
Version      : 1.15.1
Name         : xdg-desktop-portal-gnome
Version      : 45.0

Works fine here.

@alerque

The main difference in my setup is I'm using xdg-desktop-portal-hyprland as the backend instead of -gtk.

hyperland portal does not provide a file picker, or anything beyond screen sharing. You have to have a portal that does next to hyperland portal. (You can, and should run both)

I have encountered this problem in tauri with xdg-desktop-portal-hyprland

@LIMPIX31 Probably same as above

(PS. just don't mistake freedesktop's gtk portal for gnome portal, as the former one will most likely not work for you on hyperland)

EDIT: Yep. hyperland wiki says the same thing: https://wiki.hyprland.org/Useful-Utilities/Hyprland-desktop-portal/#installing

PolyMeilex avatar Nov 27 '23 21:11 PolyMeilex

Hello,

I come from Tauri v2 alpha here, and open a Dialog freeze the application. I'm using archlinux with wayland and hyprland, seems to be related to this. With the taui v1.3 version I don't have the problem.

Blist avatar Dec 15 '23 14:12 Blist

Hello,

I come from Tauri v2 alpha here, and open a Dialog freeze the application. I'm using archlinux with wayland and hyprland, seems to be related to this. With the taui v1.3 version I don't have the problem.

The same. I have tried different versions of rfd and xdg-desktop-portal but no result.

LIMPIX31 avatar Dec 15 '23 14:12 LIMPIX31

That's unrelated, Tauri does not use xdp backend

PolyMeilex avatar Dec 15 '23 15:12 PolyMeilex

For me a workaround is to pin the rfd version to 0.12.0: rfd = "=0.12.0"

Change this to a newer version (e.g. 0.12.1) causes this issue again.

mibuthu avatar Feb 18 '24 20:02 mibuthu

How about master? We updated ashpd perhaps that helps somehow

PolyMeilex avatar Feb 18 '24 23:02 PolyMeilex

With master: rfd = { git = "https://github.com/PolyMeilex/rfd.git", branch = "master" } I still have the same issue as with version 0.12.1 or 0.13.0

mibuthu avatar Feb 19 '24 16:02 mibuthu

How about now? Either master or new 0.14 XDG Backend now has zenity fallback. And XDG Backend is not the default, without the need to enable any features.

PolyMeilex avatar Feb 19 '24 20:02 PolyMeilex

Great, for me the issue is solved with version 0.14.0.

==============

Some more information from my testing in the last days: I my case it seems to be an issue with a combination of rfd with some other framework (in my case slint).

The following minimal code was also working with the problematic versions 0.12.1 and 0.13.0:

use std::path::PathBuf;

fn main() {
	rfd();
}

fn rfd() {
    let current_dir = PathBuf::from("/tmp");
    println!("Current dir: {}", current_dir.display());
    let new_dir: PathBuf = rfd::FileDialog::new()
        .set_title("Folder selection")
        .set_directory(&current_dir)
        .pick_folder()
        .unwrap_or(current_dir)
        .to_string_lossy()
        .to_string()
        .into();
    println!("New dir: {}", new_dir.display());
}

But adding slint to the party with the following code, the problem was reproducible:

use std::path::PathBuf;

slint::slint!{
	import { Button } from "std-widgets.slint";

    export component HelloWorld {
        callback rfd;
        
        Button {
            text: "rfd";
            clicked => { rfd() }
        }
    }
}

fn main() {
	let app = HelloWorld::new().unwrap();
	app.on_rfd({
		move || {
			rfd()
		}
	});
	app.run().unwrap();
}

fn rfd() {
    let current_dir = PathBuf::from("/tmp");
    println!("Current dir: {}", current_dir.display());
    let new_dir: PathBuf = rfd::FileDialog::new()
        .set_title("Folder selection")
        .set_directory(&current_dir)
        .pick_folder()
        .unwrap_or(current_dir)
        .to_string_lossy()
        .to_string()
        .into();
    println!("New dir: {}", new_dir.display());
}

mibuthu avatar Feb 26 '24 18:02 mibuthu