Пример #1
0
        static void Main(string[] args)
        {
            var display         = WlDisplay.Connect(null);
            var registry        = display.GetRegistry();
            var registryHandler = new RegistryHandler(registry);

            registry.Events = registryHandler;
            display.Dispatch();
            display.Roundtrip();
            var globals = registryHandler.GetGlobals();

            var compositor = registryHandler.Bind(WlCompositor.BindFactory, WlCompositor.InterfaceName,
                                                  WlCompositor.InterfaceVersion);

            display.Roundtrip();
            var shell = registryHandler.Bind(WlShell.BindFactory, WlShell.InterfaceName, WlShell.InterfaceVersion);

            display.Roundtrip();
            var surface      = compositor.CreateSurface();
            var shellSurface = shell.GetShellSurface(surface);

            shellSurface.SetTitle("Test");
            surface.Commit();
            display.Dispatch();
            display.Roundtrip();
        }
Пример #2
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.");
            }
        }
Пример #3
0
        public WaylandClientConnection(string display = null)
            : base(ConnectToDisplay(display), new WaylandClientObjectMap())
        {
            uint id = ObjectMap.AllocateId();

            Display        = new WlDisplay(id, 1, this);
            Display.Error += (display, objectId, code, message) =>
            {
                throw new WaylandProtocolException(objectId, code, message);
            };
            Display.DeleteId += (display, id) =>
            {
                this.DeallocateId(id);
            };
            ObjectMap[id] = Display;
        }