Draft: comdlg32: Use XDG Desktop Portal for native file dialogs
This adds XDG desktop portal integration for Wine file dialogs, with compatibility fallbacks, and solves https://bugs.winehq.org/show_bug.cgi?id=51134
I used an LLM to create the patches, the wiki does not contain an LLM policy, so I don't know if this is eligible to be merged at all.
I used the following sources:
- https://github.com/MicrosoftDocs/win32 which contains the markdown sources for e.g.
- https://github.com/MicrosoftDocs/sdk-api which contains the markdown sources for e.g.
- https://github.com/flatpak/xdg-desktop-portal
- https://github.com/notepad-plus-plus/notepad-plus-plus to determine what calls are made when choosing Save As, since it initially didn't work
- Wine logs from manual testing after adding extensive TRACE calls:
- Wine
notepad.exe:GetOpenFileNameW/GetSaveFileNameWvia portal - Wine
wordpad.exe:GetOpenFileNameW/GetSaveFileNameWvia portal -
hammerplusplus.exe(32-bit):IFileDialog(IFileDialog2_fnShow) Open/Save As via portal -
SumatraPDF.exe: Open viaGetOpenFileNameWin auto; Save As usesGetSaveFileNameWand falls back in case of the auto policy, but uses portal when forced (WINE_FORCE_PORTAL=1) -
notepad++.exe:IFileDialog(IFileDialog2_fnShow) Save As via portal after result-path handling fixes
- Wine
Implementation:
- Add a portal backend in
comdlg32for file open/save requests - Add portal handling for
GetOpenFileNameW,GetOpenFileNameA,GetSaveFileNameW, andGetSaveFileNameAwhen requests are compatible with portal features - Route compatible
IFileDialog/IFileOpenDialog/IFileSaveDialogpaths through the portal - Keep native Wine dialogs in case of unsupported/customized dialog options
- Add a combobox to
winecfgto select the policy for XDG Desktop Portal file dialogs: auto / always / never


