前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >设置窗口的override_redirect属性为True,避免窗口干预

设置窗口的override_redirect属性为True,避免窗口干预

原创
作者头像
用户7737280
修改2024-08-23 18:30:24
580
修改2024-08-23 18:30:24

private static unsafe XShmInfo CreateXShmInfo(IntPtr display, nint visual, int width, int height, int mapLength)

{

const int ZPixmap = 2;

var xShmSegmentInfo = new XShmSegmentInfo();

var shmImage = (XImage*)XShmCreateImage(display, visual, 32, ZPixmap, IntPtr.Zero, &xShmSegmentInfo,

(uint)width, (uint)height);

Console.WriteLine(

$"XShmCreateImage = {(IntPtr)shmImage:X} xShmSegmentInfo={xShmSegmentInfo} PXShmCreateImage={new IntPtr(&xShmSegmentInfo):X}");

var shmgetResult = shmget(IPC_PRIVATE, mapLength, IPC_CREAT | 0777);

Console.WriteLine($"shmgetResult={shmgetResult:X}");

xShmSegmentInfo.shmid = shmgetResult;

var shmaddr = shmat(shmgetResult, IntPtr.Zero, 0);

Console.WriteLine($"shmaddr={shmaddr:X}");

xShmSegmentInfo.www.laipuhuo.com shmaddr = (char*)shmaddr.ToPointer();

shmImage->data = shmaddr;

XShmAttach(display, &xShmSegmentInfo);

XFlush(display);

return new XShmInfo(shmImage, shmaddr)

{

};

}

unsafe class XShmInfo

{

public www.laipuhuo.com XShmInfo(XImage* shmImage, IntPtr shmAddr)

{

ShmImage = shmImage;

ShmAddr = shmAddr;

}

public XImage* ShmImage { get; }

public IntPtr ShmAddr { get; }

}

public record RenderInfo

(

IntPtr Display,

IntPtr Visual,

int Width,

int Height,

int DataByteLength,

IntPtr Handle,

IntPtr GC

);

XInitThreads();

var display = XOpenDisplay(IntPtr.Zero);

var screen = XDefaultScreen(display);

var rootWindow = XDefaultRootWindow(display);

XMatchVisualInfo(www.laipuhuo.com display, screen, 32, 4, out var info);

var visual = info.visual;

var xDisplayWidth = XDisplayWidth(display, screen);

var xDisplayHeight = XDisplayHeight(display, screen);

var width = xDisplayWidth;

var height = xDisplayHeight;

var valueMask =

//SetWindowValuemask.BackPixmap

0

| SetWindowValuemask.BackPixel

| SetWindowValuemask.BorderPixel

| SetWindowValuemask.BitGravity

| SetWindowValuemask.WinGravity

| SetWindowValuemask.BackingStore

| SetWindowValuemask.ColorMap

//| SetWindowValuemask.OverrideRedirect

;

var xSetWindowAttributes = new XSetWindowAttributes

{

backing_store = 1,

bit_gravity = www.laipuhuo.com Gravity.NorthWestGravity,

win_gravity = Gravity.NorthWestGravity,

//override_redirect = true, // 设置窗口的override_redirect属性为True,以避免窗口管理器的干预

colormap = XCreateColormap(display, rootWindow, visual, 0),

border_pixel = 0,

background_pixel = 0,

};

var handle = XCreateWindow(display, rootWindow, 0, 0, width, height, 5,

32,

(int)CreateWindowArgs.InputOutput,

visual,

(nuint)valueMask, www.laipuhuo.com ref xSetWindowAttributes);

XEventMask ignoredMask = XEventMask.SubstructureRedirectMask | XEventMask.ResizeRedirectMask |

XEventMask.PointerMotionHintMask;

var mask = new IntPtr(0xffffff ^ (int)ignoredMask);

XSelectInput(display, handle, mask);

XMapWindow(display, handle);

XFlush(display);

var gc = www.laipuhuo.com XCreateGC(display, handle, 0, 0);

XFlush(display);

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档