It may also be a GTK bug. I don’t know. But for sure, this comes exactly from this place of the code (the “There is one image with unsaved changes!” is recognizable and definitely comes from this) and I double-checked. We only set the LOGOUT flag, as pointed out by @Sid, which is documented in GTK docs as:
Inhibit ending the user session by logging out or by shutting down the computer.
So it should not inhibit sleeping for sure. It doesn’t look like we have a bug in there (well maybe — there can always be bugs!
—, but relatively to this specific issue of inhibiting sleeping, I don’t see where it could be in this small piece of code).
We could also remove the feature altogether, but on the other end, inhibiting logout while there were unsaved changes has been requested to us for years.
So that would make other people unhappy.
I looked a bit further. There are only 2 implementations on inhibit in GTK: dbus (Linux) and quartz (macOS). This is the current dbus implementation gtk_application_impl_dbus_inhibit()
: gtk/gtkapplication-dbus.c · main · GNOME / gtk · GitLab
It calls the org.freedesktop.portal.Desktop
portal and in there the Inhibit
method of org.freedesktop.portal.Inhibit
object.
Note: I see it does try to reach the org.gnome.SessionManager or org.xfce.Session.Manager portals (I’m unsure of semantic, are they portals? Services? Anyway!) first if they exist, which I assume won’t for you. You can check with a software like D-Feet or similar.
Anyway so the docs for this freedesktop portal is there: Inhibit - XDG Desktop Portal documentation
Now you should be able to test it with D-Feet (apparently now there is a new tool D-Spy too), but the syntax to set arguments always eludes me. There seems to be no basic usage tutorial after all these years. I usually can find it after a hour of search or something, but not today. I tried stuff like ("", 1, {"reason":"hello world"})
(1 would be logout inhibition, cf. the docs for further info), but anyway no much time today. I’ll let you take it from there. 
Basically I would have liked you to test, if you can find the correct syntax to send to the portal (if you do, please paste it here; I’ll bookmark this as D-Feet docs!
). The goal would be to verify if you can simply reproduce the sleep inhibition notification you got. In any case, this is a cross-desktop protocol which should work the same everywhere.