SUMMARY Portal documentation (https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.portal.Inhibit) prescribe that in order to remove the inhibition, the client must call Close() on the returned handle. After a quick look at src/inhibit.cpp (and comparing it to xdg-desktop-portal-gtk) I am pretty sure no reply is prepared. This means that the client hangs on and finally crashes. STEPS TO REPRODUCE 1. run /lib/xdg-desktop-portal-kde --verbose 2. run my quick demo: https://gist.github.com/carlocastoldi/b52a3434c36b8bf185afe4a545ff90d8 3. click on the GUI bottom twice. One for inhibiting and one for stopping the inhibition 4. make sure the Close() call is received by xdg-desktop-portal-kde 5. Wait for a certain amount of seconds Make sure to run my demo on X11, as on Wayland I take advantage of xdg-foreign to export the toplevel handle and Kwin does not yet support it (I don't even know if there is any plans to) OBSERVED RESULT dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken EXPECTED RESULT The inhibition is cancelled and a reply is sent back to the application ADDITIONAL INFORMATION This bug report and demo is done with the goal to ease the usage of portals by host applications (and not!) as i think they can play a really important role in the interoperability between gnu/linux environments. I'd be happy to share ideas & code with someone who sees the same potential! For further info: https://github.com/flatpak/xdg-desktop-portal/issues/579
It is implemented here [1] and it's been used by my test app here [2]. I just tested it and it works just fine. [1] - https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/blob/master/src/request.cpp [2] - https://invent.kde.org/libraries/xdg-portal-test-kde/-/blob/master/src/portaltest.cpp#L342
I tried your portal-test as host application and it works for me as well. At this point I don't know what to change in my demo.. I am fairly new to dbus and I cannot explain to myself why it works on GNOME, but it does not on KDE. Would you please be so kind to try helping me debugging it? I am using python dbus API + Gtk because I'd like to then write a merge request for a Gtk app written in python P.S. I also tried to make an asynchronous call to Close(), but it didn't help. It just changed the error it displayed to GDBus.Error:org.freedesktop.DBus.Error.UnknownObject: No such object path '/org/freedesktop/portal/desktop/request/1_204/t' where 1_204/t is the handle returned by Inhibit
actually: i think the UnknownObject error is due to the fact that i tried to click the toggle multiple times trying to close the request. The first time still gets org.freedesktop.DBus.Error.NoReply, so there is really no change with asynch calls
I tried your app, but it doesn't even inhibit the session. Clicking on the button doesn't do anything for me.
On KDE? That's strange, powerdevil seems to detect it on my system: https://i.imgur.com/eEJUAVh.png I assume the systems has installed: Gtk4, dbus-python and python-gobject
I'm on Wayland, that will be the reason why it doesn't work.
with GDK_BACKEND=X11 I get: Traceback (most recent call last): File "/home/jgrulich/foo.py", line 59, in <lambda> self.connect('activate', lambda app: app.on_activate()) File "/home/jgrulich/foo.py", line 75, in on_activate self.win = Gtk.Window(application=self, title="A window") File "/usr/lib/python3.9/site-packages/gi/overrides/Gtk.py", line 519, in __init__ raise RuntimeError( RuntimeError: Gtk couldn't be initialized. Use Gtk.init_check() if you want to handle this case.
Could the X11 error due to the fact that the DISPLAY variable is not set? On Wayland you may want to try this version of the demo, where I don't try to get toplevel's handle to pass to the Portal: https://pastebin.com/raw/tziTenUa
It does release inhibition when I close the app. method call time=1620039298.850438 sender=:1.42 -> destination=:1.56 serial=1330 path=/org/freedesktop/portal/desktop/request/1_384/t; interface=org.freedesktop.impl.portal.Request; member=Close method call time=1620039298.850706 sender=:1.56 -> destination=org.kde.Solid.PowerManagement serial=1506 path=/org/kde/Solid/PowerManagement/PolicyAgent; interface=org.kde.Solid.PowerManagement.PolicyAgent; member=ReleaseInhibition uint32 323
Yes, I noticed that! But I think it's the Portal that un-inhibits the session when it detects the peer has exited. But I don't make the Close() call on exit
Oh I just realised that in my demo it is not clear that if you click a second time on "Toggle Inhibtion", it uninhibits the session. That is what caused me problems.
Fixed with https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/commit/8e21923f57f3c216885dfb80ef8aeaafe415a24e.
Confirming the fix works for me as well! Many thanks ^^