public X11CursorFactory(IntPtr display) { _display = display; _nullCursor = GetNullCursor(display); _cursors = Enum.GetValues(typeof(CursorFontShape)).Cast <CursorFontShape>() .ToDictionary(id => id, id => XLib.XCreateFontCursor(_display, id)); }
private WindowTransparencyLevel UpdateAtomsAndGetTransparency() { if (_requestedLevel >= WindowTransparencyLevel.Blur) { if (!_blurAtomsAreSet) { IntPtr value = IntPtr.Zero; XLib.XChangeProperty(_x11.Display, _window, _x11.Atoms._KDE_NET_WM_BLUR_BEHIND_REGION, _x11.Atoms.XA_CARDINAL, 32, PropertyMode.Replace, ref value, 1); _blurAtomsAreSet = true; } } else { if (_blurAtomsAreSet) { XLib.XDeleteProperty(_x11.Display, _window, _x11.Atoms._KDE_NET_WM_BLUR_BEHIND_REGION); _blurAtomsAreSet = false; } } if (!_globals.IsCompositionEnabled) { return(WindowTransparencyLevel.None); } if (_requestedLevel >= WindowTransparencyLevel.Blur && CanBlur) { return(WindowTransparencyLevel.Blur); } return(WindowTransparencyLevel.Transparent); }
public XImageCursor(IntPtr display, IBitmapImpl bitmap, PixelPoint hotSpot) { var size = Marshal.SizeOf <XcursorImage>() + (bitmap.PixelSize.Width * bitmap.PixelSize.Height * 4); var runtimePlatform = AvaloniaLocator.Current.GetService <IRuntimePlatform>() ?? throw new InvalidOperationException("Unable to locate IRuntimePlatform"); var platformRenderInterface = AvaloniaLocator.Current.GetService <IPlatformRenderInterface>() ?? throw new InvalidOperationException("Unable to locate IPlatformRenderInterface"); _pixelSize = bitmap.PixelSize; _blob = runtimePlatform.AllocBlob(size); var image = (XcursorImage *)_blob.Address; image->version = 1; image->size = Marshal.SizeOf <XcursorImage>(); image->width = bitmap.PixelSize.Width; image->height = bitmap.PixelSize.Height; image->xhot = hotSpot.X; image->yhot = hotSpot.Y; image->pixels = (IntPtr)(image + 1); using (var renderTarget = platformRenderInterface.CreateRenderTarget(new[] { this })) using (var ctx = renderTarget.CreateDrawingContext(null)) { var r = new Rect(_pixelSize.ToSize(1)); ctx.DrawBitmap(RefCountable.CreateUnownedNotClonable(bitmap), 1, r, r); } Handle = XLib.XcursorImageLoadCursor(display, _blob.Address); }
public X11CursorFactory(IntPtr display) { _display = display; _nullCursor = GetNullCursor(display); _cursors = GetAllCursorShapes() .ToDictionary(id => id, id => XLib.XCreateFontCursor(_display, id)); }
private static IntPtr GetNullCursor(IntPtr display) { XColor color = new XColor(); IntPtr window = XLib.XRootWindow(display, 0); IntPtr pixmap = XLib.XCreateBitmapFromData(display, window, NullCursorData, 1, 1); return(XLib.XCreatePixmapCursor(display, pixmap, pixmap, ref color, ref color, 0, 0)); }
public string GetAtomName(IntPtr atom) { if (_atomsToNames.TryGetValue(atom, out var rv)) { return(rv); } var name = XLib.GetAtomName(_display, atom); if (name == null) { return(null); } _atomsToNames[atom] = name; _namesToAtoms[name] = atom; return(name); }
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"); } }
public static void Init() { XLib.XSetErrorHandler(s_errorHandlerDelegate); }
public override void Dispose() { XLib.XcursorImageDestroy(Handle); _blob.Dispose(); }