private void RegistryGlobalRemoveCallback(void *data, wl_registry *registry, uint name)
 {
     for (var i = Globals.Count; i >= 0; i--)
     {
         if (Globals[i].Name == name)
         {
             Globals.RemoveAt(i);
             _globalsDirty = true;
             break;
         }
     }
 }
        private void RegistryGlobalCallback(void *data, wl_registry *registry, uint name, byte *ifaceUtf8, uint version)
        {
            // TODO we should only bind with the required version
            // TODO we should expose interface names in Utf8 format so we can do a direct compare without marshalling
            var iface = Util.Utf8ToString(ifaceUtf8);

            LogDebug($"Registry global announce for type '{iface}' v{version}.");

            // we store and expose all globals so users can bind whatever they want
            var global = new WaylandGlobal(iface, name, version);

            Globals.Add(global);
            _globalsDirty = true;

            switch (iface)
            {
            case WaylandBindings.wl_shell_name:
                _wlShellAvailable = true;
                break;

            case WaylandBindings.wl_output_name:
                LogDebug($"Binding WlOutput.");
                var output = _wlRegistry.Bind <wl_output>(name, WlOutput.Interface, version);
                AddDisplay(output);
                LogInfo($"Display connected with id {name}.");
                break;

            case WaylandBindings.wl_compositor_name:
                LogDebug($"Binding WlCompositor.");
                _wlCompositor = _wlRegistry.Bind <wl_compositor>(name, WlCompositor.Interface, version);
                break;

            case WaylandBindings.wl_seat_name:
                LogDebug($"Binding WlSeat.");
                _wlSeat = _wlRegistry.Bind <wl_seat>(name, WlSeat.Interface, version);
                _wlSeat.SetListener(SeatCapabilitiesCallback, SeatNameCallback);
                break;

            case XdgShellBindings.xdg_wm_base_name:
                LogDebug($"Binding XdgWmBase.");
                _xdgWmBase = _wlRegistry.Bind <xdg_wm_base>(name, XdgWmBase.Interface, version);
                _xdgWmBase.SetListener(XdgWmBasePingCallback);
                break;

            case XdgDecorationUnstableV1Bindings.zxdg_decoration_manager_v1_name:
                _xdgDecorationManager = _wlRegistry.Bind <zxdg_decoration_manager_v1>(name, ZxdgDecorationManagerV1.Interface, version);
                break;

            case ViewporterBindings.wp_viewporter_name:
                _wpViewporter = _wlRegistry.Bind <wp_viewporter>(name, WpViewporter.Interface, version);
                break;
            }
        }