public void Initialize(X11PlatformOptions options) { Options = options; XInitThreads(); Display = XOpenDisplay(IntPtr.Zero); DeferredDisplay = XOpenDisplay(IntPtr.Zero); OrphanedWindow = XCreateSimpleWindow(Display, XDefaultRootWindow(Display), 0, 0, 1, 1, 0, IntPtr.Zero, IntPtr.Zero); if (Display == IntPtr.Zero) { throw new Exception("XOpenDisplay failed"); } XError.Init(); Info = new X11Info(Display, DeferredDisplay); Globals = new X11Globals(this); //TODO: log if (options.UseDBusMenu) { DBusHelper.TryInitialize(); } AvaloniaLocator.CurrentMutable.BindToSelf(this) .Bind <IWindowingPlatform>().ToConstant(this) .Bind <IPlatformThreadingInterface>().ToConstant(new X11PlatformThreading(this)) .Bind <IRenderTimer>().ToConstant(new SleepLoopRenderTimer(60)) .Bind <IRenderLoop>().ToConstant(new RenderLoop()) .Bind <PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Control)) .Bind <IKeyboardDevice>().ToFunc(() => KeyboardDevice) .Bind <IStandardCursorFactory>().ToConstant(new X11CursorFactory(Display)) .Bind <IClipboard>().ToConstant(new X11Clipboard(this)) .Bind <IPlatformSettings>().ToConstant(new PlatformSettingsStub()) .Bind <IPlatformIconLoader>().ToConstant(new X11IconLoader(Info)) .Bind <ISystemDialogImpl>().ToConstant(new GtkSystemDialog()) .Bind <IMountedVolumeInfoProvider>().ToConstant(new LinuxMountedVolumeInfoProvider()); X11Screens = Avalonia.X11.X11Screens.Init(this); Screens = new X11Screens(X11Screens); if (Info.XInputVersion != null) { var xi2 = new XI2Manager(); if (xi2.Init(this)) { XI2 = xi2; } } if (options.UseGpu) { if (options.UseEGL) { EglGlPlatformFeature.TryInitialize(); } else { GlxGlPlatformFeature.TryInitialize(Info, Options.GlProfiles); } } }
/// <summary> /// Initializes the specified options. /// </summary> /// <param name="options">The options.</param> /// <exception cref="Exception">XOpenDisplay failed</exception> public void Initialize(X11PlatformOptions options) { Options = options; XInitThreads(); Display = XOpenDisplay(IntPtr.Zero); DeferredDisplay = XOpenDisplay(IntPtr.Zero); if (Display == IntPtr.Zero) { throw new Exception("XOpenDisplay failed"); } XError.Init(); Info = new X11Info(Display, DeferredDisplay); //TODO: log if (options.UseDBusMenu) { DBusHelper.TryInitialize(); } AvaloniaLocator.CurrentMutable.BindToSelf(this) .Bind <IWindowingPlatform>().ToConstant(this) .Bind <IPlatformThreadingInterface>().ToConstant(new X11PlatformThreading(this)) .Bind <IRenderTimer>().ToConstant(new DefaultRenderTimer(60)) .Bind <IRenderLoop>().ToConstant(new RenderLoop()) #pragma warning disable CS0618 // Type or member is obsolete .Bind <PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(InputModifiers.Control)) #pragma warning restore CS0618 // Type or member is obsolete .Bind <IKeyboardDevice>().ToFunc(() => KeyboardDevice) .Bind <IStandardCursorFactory>().ToConstant(new X11CursorFactory(Display)) .Bind <IClipboard>().ToConstant(new X11Clipboard(this)) .Bind <IPlatformSettings>().ToConstant(new PlatformSettingsStub()) .Bind <IPlatformIconLoader>().ToConstant(new X11IconLoader(Info)) .Bind <ISystemDialogImpl>().ToConstant(new GtkSystemDialog()) .Bind <IMountedVolumeInfoProvider>().ToConstant(new LinuxMountedVolumeInfoProvider()); X11Screens = IronyModManager.Platform.x11.X11Screens.Init(this); Screens = new X11Screens(X11Screens); if (Info.XInputVersion != null) { var xi2 = new XI2Manager(); if (xi2.Init(this)) { XI2 = xi2; } } if (options.UseGpu) { if (options.UseEGL) { EglGlPlatformFeature.TryInitialize(); } else { GlxGlPlatformFeature.TryInitialize(Info); } } }
public static void Initialize() { AvaloniaLocator.CurrentMutable.Bind <IWindowingPlatformGlFeature>().ToFunc(() => { if (!s_attemptedToInitialize) { EglFeature = EglGlPlatformFeature.TryCreate(() => new AngleWin32EglDisplay()); s_attemptedToInitialize = true; } return(EglFeature); }); }
public void Initialize(X11PlatformOptions options) { XInitThreads(); Display = XOpenDisplay(IntPtr.Zero); DeferredDisplay = XOpenDisplay(IntPtr.Zero); if (Display == IntPtr.Zero) { throw new Exception("XOpenDisplay failed"); } XError.Init(); Info = new X11Info(Display, DeferredDisplay); AvaloniaLocator.CurrentMutable.BindToSelf(this) .Bind <IWindowingPlatform>().ToConstant(this) .Bind <IPlatformThreadingInterface>().ToConstant(new X11PlatformThreading(this)) .Bind <IRenderTimer>().ToConstant(new DefaultRenderTimer(60)) .Bind <IRenderLoop>().ToConstant(new RenderLoop()) .Bind <PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(InputModifiers.Control)) .Bind <IKeyboardDevice>().ToFunc(() => KeyboardDevice) .Bind <IStandardCursorFactory>().ToConstant(new X11CursorFactory(Display)) .Bind <IClipboard>().ToConstant(new X11Clipboard(this)) .Bind <IPlatformSettings>().ToConstant(new PlatformSettingsStub()) .Bind <IPlatformIconLoader>().ToConstant(new X11IconLoader(Info)) .Bind <ISystemDialogImpl>().ToConstant(new GtkSystemDialog()); X11Screens = Avalonia.X11.X11Screens.Init(this); Screens = new X11Screens(X11Screens); if (Info.XInputVersion != null) { var xi2 = new XI2Manager(); if (xi2.Init(this)) { XI2 = xi2; } } if (options.UseGpu) { if (options.UseEGL) { EglGlPlatformFeature.TryInitialize(); } else { GlxGlPlatformFeature.TryInitialize(Info); } } Options = options; }
public static void Initialize(Gtk3PlatformOptions options) { Resolver.Custom = options.CustomResolver; UseDeferredRendering = EnvOption("USE_DEFERRED_RENDERING", true, options.UseDeferredRendering); var useGpu = EnvOption("USE_GPU", false, options.UseGpuAcceleration); if (!s_gtkInitialized) { try { X11.XInitThreads(); }catch {} Resolver.Resolve(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { using (var backends = new Utf8Buffer("x11")) Native.GdkSetAllowedBackends?.Invoke(backends); } Native.GtkInit(0, IntPtr.Zero); var disp = Native.GdkGetDefaultDisplay(); DisplayClassName = Utf8Buffer.StringFromPtr(Native.GTypeName(Marshal.ReadIntPtr(Marshal.ReadIntPtr(disp)))); using (var utf = new Utf8Buffer("avalonia.app." + Guid.NewGuid())) App = Native.GtkApplicationNew(utf, 0); //Mark current thread as UI thread s_tlsMarker = true; s_gtkInitialized = true; } AvaloniaLocator.CurrentMutable.Bind <IWindowingPlatform>().ToConstant(Instance) .Bind <IClipboard>().ToSingleton <ClipboardImpl>() .Bind <IStandardCursorFactory>().ToConstant(new CursorFactory()) .Bind <IKeyboardDevice>().ToConstant(Keyboard) .Bind <IPlatformSettings>().ToConstant(Instance) .Bind <IPlatformThreadingInterface>().ToConstant(Instance) .Bind <ISystemDialogImpl>().ToSingleton <SystemDialog>() .Bind <IRenderLoop>().ToConstant(new RenderLoop()) .Bind <IRenderTimer>().ToConstant(new DefaultRenderTimer(60)) .Bind <PlatformHotkeyConfiguration>().ToSingleton <PlatformHotkeyConfiguration>() .Bind <IPlatformIconLoader>().ToConstant(new PlatformIconLoader()); if (useGpu) { EglGlPlatformFeature.TryInitialize(); } }