File chooser not focused

Hi.
In the ksnip snap (available upstream at https://github.com/ksnip/ksnip) if we select save as it opens the gtk native file chooser from the gnome extension.
The problem is that it opens in the background, not focused.
What could be the issue?

1 Like

I understand what you are saying, The FileDialog needs the correct parent widget.
I was able to reproduce the same issue with a simple qt test program.
The developer of ksnip needs to set the correct parent window to the file dialog. Setting a nullptr will not work and will result the file dialog lose focus.
Pinging : @damir

Thanks for the hint, I’ll give it a try

That doesn’t seem to be the issue, parent was already set for that dialog.
Any other ideas? Maybe using non native dialog?

Parent object must be root window. Using non-native window should not cause this issue (I tested that).

It’s an incompatibility between Qt and xdg-desktop-portal-gtk, the first sends window ID as a decimal, while the last expects a hexadecimal value:


Yep. This seems to be the problem code in Qt:

The change suggested in that xdg-desktop-portal-gtk PR would break all non-Qt clients, and it’s not clear that the problem can be reliably detected on that side since the decimal representation of an ID can also be the hexadecimal representation of a different ID.

@jriddell

The upstream patch to fix this very annoying bug is here: https://github.com/qt/qtbase/commit/acaabc9108dfe75530960cf8e3ec4f3602cd82e0.patch

I’m not too acquainted with Debian packaging, but I think adding it in https://invent.kde.org/neon/qt/qtbase/-/tree/Neon/release/debian/patches and rebuilding the framework snap(s) should do the trick.

I filed a bug @ https://bugs.kde.org/show_bug.cgi?id=444873

@jriddell And I tried my hand at including the patch: https://invent.kde.org/neon/qt/qtbase/-/merge_requests/3

Edit:

And the patch has been merged, and the problem is solved in kde-frameworks-5-qt-5-15-3-core20 for revision >= 7. This will hit stable soon, and most kde-neon applications should pick up the fix.