/// <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="X11Clipboard" /> class.
 /// </summary>
 /// <param name="platform">The platform.</param>
 public X11Clipboard(AvaloniaX11Platform platform)
 {
     _x11    = platform.Info;
     _handle = CreateEventWindow(platform, OnEvent);
     _avaloniaSaveTargetsAtom = XInternAtom(_x11.Display, "AVALONIA_SAVE_TARGETS_PROPERTY_ATOM", false);
     _textAtoms = new[]
     {
         _x11.Atoms.XA_STRING,
         _x11.Atoms.OEMTEXT,
         _x11.Atoms.UTF8_STRING,
         _x11.Atoms.UTF16_STRING
     }.Where(a => a != IntPtr.Zero).ToArray();
 }
Example #4
0
        /// <summary>
        /// Initializes the specified platform.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool Init(AvaloniaX11Platform platform)
        {
            _platform   = platform;
            _x11        = platform.Info;
            _multitouch = platform.Options?.EnableMultiTouch ?? false;
            var devices = (XIDeviceInfo *)XIQueryDevice(_x11.Display,
                                                        (int)XiPredefinedDeviceId.XIAllMasterDevices, out int num);

            for (var c = 0; c < num; c++)
            {
                if (devices[c].Use == XiDeviceType.XIMasterPointer)
                {
                    _pointerDevice = new PointerDeviceInfo(devices[c]);
                    break;
                }
            }
            if (_pointerDevice == null)
            {
                return(false);
            }

            /*
             * int mask = 0;
             *
             * XISetMask(ref mask, XiEventType.XI_DeviceChanged);
             * var emask = new XIEventMask
             * {
             *  Mask = &mask,
             *  Deviceid = _pointerDevice.Id,
             *  MaskLen = XiEventMaskLen
             * };
             *
             * if (XISelectEvents(_x11.Display, _x11.RootWindow, &emask, 1) != Status.Success)
             *  return false;
             * return true;
             */
            return(XiSelectEvents(_x11.Display, _x11.RootWindow, new Dictionary <int, List <XiEventType> >
            {
                [_pointerDevice.Id] = new List <XiEventType>
                {
                    XiEventType.XI_DeviceChanged
                }
            }) == Status.Success);
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="X11PlatformThreading" /> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <exception cref="IronyModManager.Platform.x11.X11Exception">epoll_create1 failed
        /// or
        /// Unable to attach X11 connection handle to epoll
        /// or
        /// Unable to attach signal pipe to epoll</exception>
        public X11PlatformThreading(AvaloniaX11Platform platform)
        {
            _platform      = platform;
            _display       = platform.Display;
            _eventHandlers = platform.Windows;
            _mainThread    = Thread.CurrentThread;
            var fd = XLib.XConnectionNumber(_display);
            var ev = new epoll_event()
            {
                events = EPOLLIN,
                data   = { u32 = (int)EventCodes.X11 }
            };

            _epoll = epoll_create1(0);
            if (_epoll == -1)
            {
                throw new X11Exception("epoll_create1 failed");
            }

            if (epoll_ctl(_epoll, EPOLL_CTL_ADD, fd, ref ev) == -1)
            {
                throw new X11Exception("Unable to attach X11 connection handle to epoll");
            }

            var fds = stackalloc int[2];

            pipe2(fds, O_NONBLOCK);
            _sigread  = fds[0];
            _sigwrite = fds[1];

            ev = new epoll_event
            {
                events = EPOLLIN,
                data   = { u32 = (int)EventCodes.Signal }
            };
            if (epoll_ctl(_epoll, EPOLL_CTL_ADD, _sigread, ref ev) == -1)
            {
                throw new X11Exception("Unable to attach signal pipe to epoll");
            }
        }