/// <summary> /// Detects the environment. /// </summary> /// <returns>X11ScreensUserSettings.</returns> public static X11ScreensUserSettings DetectEnvironment() { var globalFactor = Environment.GetEnvironmentVariable("AVALONIA_GLOBAL_SCALE_FACTOR"); var screenFactors = Environment.GetEnvironmentVariable("AVALONIA_SCREEN_SCALE_FACTORS"); if (globalFactor == null && screenFactors == null) { return(null); } var rv = new X11ScreensUserSettings { GlobalScaleFactor = TryParse(globalFactor) ?? 1 }; try { if (!string.IsNullOrWhiteSpace(screenFactors)) { rv.NamedScaleFactors = screenFactors.Split(';').Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => x.Split('=')).ToDictionary(x => x[0], x => double.Parse(x[1], CultureInfo.InvariantCulture)); } } catch { //Ignore } return(rv); }
/// <summary> /// Initializes a new instance of the <see cref="Randr15ScreensImpl" /> class. /// </summary> /// <param name="platform">The platform.</param> /// <param name="settings">The settings.</param> public Randr15ScreensImpl(AvaloniaX11Platform platform, X11ScreensUserSettings settings) { _settings = settings; _x11 = platform.Info; _window = CreateEventWindow(platform, OnEvent); XRRSelectInput(_x11.Display, _window, RandrEventMask.RRScreenChangeNotify); }
/// <summary> /// Initializes the specified platform. /// </summary> /// <param name="platform">The platform.</param> /// <returns>IX11Screens.</returns> public static IX11Screens Init(AvaloniaX11Platform platform) { var info = platform.Info; var settings = X11ScreensUserSettings.Detect(); var impl = (info.RandrVersion != null && info.RandrVersion >= new Version(1, 5)) ? new Randr15ScreensImpl(platform, settings) : (IX11Screens) new FallbackScreensImpl(info, settings); return(impl); }
/// <summary> /// Initializes a new instance of the <see cref="FallbackScreensImpl" /> class. /// </summary> /// <param name="info">The information.</param> /// <param name="settings">The settings.</param> public FallbackScreensImpl(X11Info info, X11ScreensUserSettings settings) { if (XGetGeometry(info.Display, info.RootWindow, out var geo)) { Screens = UpdateWorkArea(info, new[] { new X11Screen(new PixelRect(0, 0, geo.width, geo.height), true, "Default", null, settings.GlobalScaleFactor) }); } else { Screens = new[] { new X11Screen(new PixelRect(0, 0, 1920, 1280), true, "Default", null, settings.GlobalScaleFactor) }; } }