示例#1
0
 public Randr15ScreensImpl(AvaloniaX11Platform platform, X11ScreensUserSettings settings)
 {
     _settings = settings;
     _x11      = platform.Info;
     _window   = CreateEventWindow(platform, OnEvent);
     XRRSelectInput(_x11.Display, _window, RandrEventMask.RRScreenChangeNotify);
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
            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)
                    });
                }

                Screens = new[] { new X11Screen(new PixelRect(0, 0, 1920, 1280), true, "Default", null, settings.GlobalScaleFactor) };
            }