Пример #1
0
        protected override void Initialize()
        {
            _xkbContext = XkbCommon.xkb_context_new();
            if (_xkbContext == null)
            {
                throw new OpenWindowException("Failed to create xkbcommon context.");
            }

            LogDebug("Connecting to display...");

            _wlDisplay = WlDisplay.Connect();
            if (_wlDisplay.IsNull)
            {
                var error = WaylandClient.wl_display_get_error(null);
                throw new OpenWindowException($"Failed to connect to Wayland display ({error}).");
            }
            _wlDisplay.SetListener(DisplayErrorCallback, null);

            LogDebug("Connected to display.");

            WaylandBindings.Load();
            XdgShellBindings.Load();
            XdgDecorationUnstableV1Bindings.Load();
            ViewporterBindings.Load();

            _wlRegistry = _wlDisplay.GetRegistry();

            if (_wlRegistry.IsNull)
            {
                throw new OpenWindowException("Failed to get Wayland registry.");
            }

            LogDebug("Got registry.");

            _wlRegistry.SetListener(RegistryGlobalCallback, RegistryGlobalRemoveCallback);

            LogDebug("Initiating first display roundtrip.");
            _wlDisplay.Roundtrip();

            LogDebug("Initiating second display roundtrip.");
            _wlDisplay.Roundtrip();

            if (_wlCompositor.IsNull)
            {
                throw new OpenWindowException("Server did not advertise a compositor.");
            }
            if (_xdgWmBase.IsNull)
            {
                if (_wlShellAvailable)
                {
                    LogError("Server did not advertise xdg_wm_base, but it advertised a wl_shell. wl_shell is deprecated and not supported by OpenWindow.");
                }
                throw new OpenWindowException("Server did not advertise xdg_wm_base.");
            }
        }
Пример #2
0
 public static extern xkb_keymap *xkb_keymap_new_from_string(xkb_context *context, byte *str, int format, int flags = XKB_KEYMAP_COMPILE_NO_FLAGS);
Пример #3
0
 public static extern void xkb_context_unref(xkb_context *ctx);