There are Globals and every Global's
handle() points back to the object that the compositor created.
For example when a new monitor is connected by plugging in an HDMI cable the kernel will tell the compositor-process about that via DRM.
The compositor should then create a
Wrapland::Server::Output object that represent the new display. The
Output::Private of the class is an instance of
Wayland::Global<Output> so the
handle() must point back to the
This object of type
Output exists exactly once (per D_isplay if you run multiple Wayland servers simultaneously) for this specific monitor and is represented in libwayland as a wl_global.
libwayland will announce this wl_global to all connected clients and these might want to bind to the global so they can interact with it via the Wayland protocol. When some client C binds to some Global G here in the Global class we create a new object of type
Resource<..> that represents the boundedness of Global G by the client C. Note that C can bind G as often as it likes, each time a new Resource is created for the bind.
So to repeat: the
Wayland::Global<Output>::handle() gives you the
Output object. Client bound globals are wl_resources and this allows access to the global in some well-defined way on a per-client basis.
So what about the
Resource<..>::handle()? As said above objects of type
Resource<..> might represent a bound global. But they can also represent other things: The usual case is an object, that a client requests to be created by the compositor.
For example through the Compositor Global some client C might ask the compositor to create a new Surface object for C that C then can use in subsequent requests to put buffers on for depiction of pixels and so on.
The created Surface object is in libwayland a single wl_resource that has some interface and so on to make requests and deliver events in a defined manner. Such a Surface S does not represent anything else than itself and the single wl_resource in libwayland (that's different to a wl_global and the many wl_resources created from it). The
Surface::Private field of the Surface object is an instance of
Wayland::Resource<Surface> and the
Resource<..>::handle() points back to the Surface S that only one single wl_resource is associated with (in contrast to Globals).
By the way if you look closely at the Resource class the
Resource::handle() function is only defined when the Resource does not represent a bound Global. When it does represent one you have a
Resource::global() function to access the Global.