[Development] QFreedesktopApplication

Ilya Fedin fedin-ilja2010 at ya.ru
Sun Apr 24 19:06:12 CEST 2022

On Sun, 24 Apr 2022 07:53:49 -0700
Thiago Macieira <thiago.macieira at intel.com> wrote:

> Hello Ilya
> Please explain why we need this API in the first place. If an
> application requires a Qt event loop that links to GLib and use
> GMainLoop, then they can easily link to glib directly themselves and
> access GApplication. So why isn't this an option?
> Is it because it's not a nice, Qt-ish C++ API? Would creating a
> library that wraps this and a few other GLib APIs solve this problem?
> Or does it need access to internals in Qt? If so, what ones?  

Yeah, it needs access to Qt internals for startup notifications (which
are required to not to hit WM's focus prevention mechanism). 

> Or, inversely, does Qt need to do something so GApplication is
> accessible? There's no match to "GApplication" in qtbase today. Would
> adding this code without a front-end API suffice?

The key methods are beforeEmit/afterEmit, they're protected, but
there's a problem that it's necessary to run some user code after
GApplication construction and before g_application_run as
g_application_quit requires re-construction of the GApplication
instance to run it again, so it's all in processEvents and
setFlags/setConstructedHandler/setFinalizeHandler from public
interfaces are required at least.

> Have you investigated what happens to existing Qt + GLib hybrid
> applications when your code gets added?

I don't know any... Do you?

> On another note, just what is org.freedesktop.Application? There are
> ZERO references to it on freedesktop.org. If this isn't well-defined,
> should we adventure into it? If this is a D-Bus API, then the
> questions above about accessing the interface and implementing the
> server side of it apply: can we have it without a front-end API?

It's a part of the Desktop Entry Specification[1]. It's used by most
gtk & KDE applications. gtk ones use GApplication, KDE ones use

> In fact, if it is a D-Bus API, should we have it even if the GLib
> event dispatchers aren't active?

Well, the point it's not just org.freedesktop.Application. GApplication
also provides multiple notification protocol implementations and
integration between them and the o.fd.Application spec (as I mentioned
before). It's the main reason I need GApplication as libnotify is really
outdated and there's no other alternative (except of KDE libs-dependent
KNotifications and implementing all the specs by hand which are not
real alternatives IMO). GApplication provides implementations of
multiple nice specifications at once and integrates them, so I thought
why not to use it when it's available...


More information about the Development mailing list