Skip to content
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

linux: use GTK_USE_PORTAL=1 to support the XDG Desktop Portal #126113

Closed
wants to merge 1 commit into from
Closed

linux: use GTK_USE_PORTAL=1 to support the XDG Desktop Portal #126113

wants to merge 1 commit into from

Conversation

tristan957
Copy link

@tristan957 tristan957 commented Jun 12, 2021

Electron 14 will have support for file managers through the XDG Desktop
Portal Specification. In order to explicitly opt into support assuming
a user has an xdg-desktop-portal-* package installed, GTK needs to be
told to use it. This will allow for alternative file managers on KDE or
wlroots-based systems.

This PR fixes #50386 amongst others, once VSCode adopts Electron v14.

resources/linux/bin/code.sh Outdated Show resolved Hide resolved
@Ashark
Copy link

Ashark commented Oct 17, 2021

@tristan957 I have built the vscodium (also tried vscodium-git from aur) with your patch. And it did not work. Then I have found out how to check electron version of app (from here). Surprisingly, it was 13.5.1. But I only have the electron package in system, which is currently v15.2.0. So it looks like vscodium brings its own electron 13.

Now the question is, is it possible to switch it to use system's version of electron?

@deepak1556 deepak1556 added this to the November 2021 milestone Oct 29, 2021
@deepak1556 deepak1556 mentioned this pull request Nov 16, 2021
1 task
deepak1556
deepak1556 previously approved these changes Feb 10, 2022
Copy link
Contributor

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM following Electron 16 update to main branch.

@tristan957
Copy link
Author

Oh I did submit this PR...

Still wonder how necessary it is, but it probably wouldn't hurt.

@deepak1556
Copy link
Contributor

yeah considering this more of a good thing to have with no negative side effects, I am fine with the change. Thanks for the PR!

@tristan957
Copy link
Author

tristan957 commented Feb 10, 2022

Should we set GTK_USE_PORTAL=1 unconditionally?

Edit: Oh wait...now I get it. Yea this is fine :). Didn't even remember the code

Is using export here correct? Probably don't want to pollute the parent environment.

@deepak1556
Copy link
Contributor

Is using export here correct? Probably don't want to pollute the parent environment.

Yeah you are right, can you update the PR. Thanks!

Btw, this code path will get executed only user launches the application from the cli, if they are triggered from launchers then we might need to set it up in https://github.com/microsoft/vscode/blob/main/resources/linux/code.desktop

@tristan957
Copy link
Author

I think that should do it?

Electron 14 will have support for file managers through the XDG Desktop
Portal Specification. In order to explicitly opt into support assuming
a user has an xdg-desktop-portal-* package installed, GTK needs to be
told to use it. This will allow for alternative file managers on KDE or
wlroots-based systems.
@deepak1556
Copy link
Contributor

I don't have a good way to verify this on my machine, would you be willing to verify the fix if I were to make a custom build from this branch ? Thanks!

@tristan957
Copy link
Author

I could give it a go. Need to break out my dbus-foo

@Moonlight63
Copy link

I just tried this on code-insiders build on electron 16. It didn't work.

@tristan957
Copy link
Author

What didn't work?

@deepak1556 deepak1556 modified the milestones: February 2022, March 2022 Feb 24, 2022
@Moonlight63
Copy link

Sorry, using the gtk protal env var didn't allow vscode to use the plasma filepicker when I tried it. I have since switched back to gnome so it no longer affects me, but I wonder if anyone else has gotten it working?

@tristan957
Copy link
Author

@Moonlight63 are you using a version of VSCode with electron >= v14 and do you have xdg-desktop-portal-kde installed?

@Moonlight63
Copy link

Yes, I did. I had vs code insiders and other applications like Firefox did respect the portal, but vs code still ignored it. Like I said, I just switched back to gnome.

Copy link

@sonnyp sonnyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTK_USE_PORTAL was a debug flag and shouldn't be used. It has been moved to a flag in GDK_DEBUG for clarity.

Here is a small recap

Thanks to @tristan957 (thanks!) work in electron/electron#19159, Electron already use the native Linux file picker if it's running in a sandboxed env (Snap / Flatpak).

IIRC in order for Electron to always use the native file picker, even when not running sandboxed, Electron needs to swap GtkFileChooserNative for the new GtkFileDialog.

However, GtkFileDialog is only available in Gtk 4.10 . I don't know what Electron policy is regarding dependencies.

Should I file an issue on the Electron repository, and we can pick it up there?

I suggest closing this PR as it won't do anything.

@deepak1556
Copy link
Contributor

Thanks for summarizing @sonnyp. Agree with closing this PR, as for gtk4 support it is currently tracked under electron/electron#33690

Additionally we would want to refactor the file dialog impl in Electron to reuse Chromium's impl, ref electron/electron#35110 (comment). I am looking into that as part of #146422

@deepak1556 deepak1556 closed this Apr 28, 2023
@tristan957 tristan957 deleted the gtk-use-portal branch April 28, 2023 15:05
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I set Dolphin as default file manager, but VSCode opens Nautilus instead of Dolphin
6 participants