-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
fix: revert required portal version for file chooser dialogs #44426
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to tweak the lambda capture to fix a the build, but otherwise looks good
2024-10-28T16:06:16.0232728Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:304:26: error: variable 'xdg_portal_required_version' cannot be implicitly captured in a lambda with no capture-default specified
2024-10-28T16:06:16.0234398Z 304 | xdg_portal_required_version) {
2024-10-28T16:06:16.0235038Z | ^
2024-10-28T16:06:16.0236274Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:279:18: note: 'xdg_portal_required_version' declared here
2024-10-28T16:06:16.0237693Z 279 | unsigned int xdg_portal_required_version) {
2024-10-28T16:06:16.0238343Z | ^
2024-10-28T16:06:16.0239107Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:11: note: lambda expression begins here
2024-10-28T16:06:16.0257715Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0258347Z | ^
2024-10-28T16:06:16.0259550Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: capture 'xdg_portal_required_version' by value
2024-10-28T16:06:16.0260754Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0261332Z | ^
2024-10-28T16:06:16.0261795Z | xdg_portal_required_version
2024-10-28T16:06:16.0263318Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: capture 'xdg_portal_required_version' by reference
2024-10-28T16:06:16.0264786Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0265383Z | ^
2024-10-28T16:06:16.0265861Z | &xdg_portal_required_version
2024-10-28T16:06:16.0266833Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: default capture by value
2024-10-28T16:06:16.0267775Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0268299Z | ^
2024-10-28T16:06:16.0268662Z | =
2024-10-28T16:06:16.0269428Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: default capture by reference
2024-10-28T16:06:16.0270436Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0271011Z | ^
2024-10-28T16:06:16.0271410Z | &
2024-10-28T16:06:16.0273104Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:311:68: error: variable 'xdg_portal_required_version' cannot be implicitly captured in a lambda with no capture-default specified
2024-10-28T16:06:16.0275101Z 311 | VLOG(1) << "File chooser portal expected version: " << xdg_portal_required_version;
2024-10-28T16:06:16.0276082Z | ^
2024-10-28T16:06:16.0277430Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:279:18: note: 'xdg_portal_required_version' declared here
2024-10-28T16:06:16.0278864Z 279 | unsigned int xdg_portal_required_version) {
2024-10-28T16:06:16.0279470Z | ^
2024-10-28T16:06:16.0280276Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:11: note: lambda expression begins here
2024-10-28T16:06:16.0281219Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0281756Z | ^
2024-10-28T16:06:16.0282850Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: capture 'xdg_portal_required_version' by value
2024-10-28T16:06:16.0283949Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0284514Z | ^
2024-10-28T16:06:16.0284949Z | xdg_portal_required_version
2024-10-28T16:06:16.0286220Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: capture 'xdg_portal_required_version' by reference
2024-10-28T16:06:16.0287410Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0287985Z | ^
2024-10-28T16:06:16.0288440Z | &xdg_portal_required_version
2024-10-28T16:06:16.0289419Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: default capture by value
2024-10-28T16:06:16.0290697Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0291290Z | ^
2024-10-28T16:06:16.0291669Z | =
2024-10-28T16:06:16.0292501Z ../../ui/shell_dialogs/select_file_dialog_linux_portal.cc:291:12: note: default capture by reference
2024-10-28T16:06:16.0293563Z 291 | [](scoped_refptr<dbus::Bus> bus,
2024-10-28T16:06:16.0294133Z | ^
2024-10-28T16:06:16.0294535Z | &
2024-10-28T16:06:16.0294919Z 2 errors generated.
docs/api/command-line-switches.md
Outdated
|
||
Sets the minimum required version of XDG portal implementation to `version` | ||
inorder to use the portal backend for file dialogs on linux. Current | ||
default is set to `4`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who is the intended consumer for this switch? Application developers, users, or both? For the recent bump to v4, is this so application users can switch back the behavior if they require it?
I also wonder if we should consider reverting the default to v3. #43570 contained an undocument breaking change in behavior that application developers may not be expecting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should revert the default, since it looks like the change was accepted upstream (see https://chromium-review.googlesource.com/c/chromium/src/+/5786982), but we probably should document this as a breaking change, at least retroactively, so people know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VerteDinde I do think (in agreement w/ deepak below) that we should change back the default, since as of now v4 is so rarely available that every app might be required to float this flag for potentially years.
Sorry for the delay, I was testing some idea to see if we can repurpose the function Rethinking this PR, based on the conversations from #43819 it seems the affected scenarios with the portal version bump is harder to recover (generic filechooser inside the flatpak application is opened without read/write access to any file on the host) than the scenario with
|
ebc72ab
to
ee73cf9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
Have a question for clarity, but won't block merging this.
+// Version 4 includes support for current_folder option to the OpenFile method via | ||
+// https://github.com/flatpak/xdg-desktop-portal/commit/71165a5. | ||
+constexpr int kXdgPortalRequiredVersion = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a suggestion in the GH issue about querying for the available portal version rather than hardcoding to 3 or 4. Would that be a viable approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SelectFileDialogLinuxPortal::CheckPortalAvailabilityOnBusThread already performs this check, the hardcoded value is the minimum value we check against to use the portal path. The issue is we don't know if a version of portal supports the feature on an interface by querying and this availability check is performed once when the application initializes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, LGTM, just a small grammar correction and I also wonder if we should be more explicit about explaining that the portal version needs to be 4 or greater to use defaultPath
.
docs/api/dialog.md
Outdated
@@ -181,6 +191,11 @@ The `window` argument allows the dialog to attach itself to a parent window, mak | |||
The `filters` specifies an array of file types that can be displayed, see | |||
`dialog.showOpenDialog` for an example. | |||
|
|||
**Note:** On Linux `defaultPath` is not supported when using portal file chooser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultPath
is only unsupported on versions <4 for open dialogs - save dialogs work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching.
For reference, flatpak/xdg-desktop-portal#796
@deepak1556 i think a rebase should fix windows |
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
097811d
to
fde1bdc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more grammar nit.
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Release Notes Persisted
|
I was unable to backport this PR to "33-x-y" cleanly; |
I was unable to backport this PR to "32-x-y" cleanly; |
I have automatically backported this PR to "34-x-y", please check out #44681 |
Description of Change
3
, to help address [Bug]: Electron 32.1 does not use the portals inside a flatpak application #43819xdg-portal-required-version
flag for application developers to control the portal usage (ex: requires support ofcurrent_folder
)default_path
is performed then log a warning pointing to the above flag.Release Notes
Notes: fix file chooser dialogs for flaptak applications