带有忽略所有 X(鼠标)事件(通过它们)的框的 pygtk 窗口 [英] pygtk window with box that ignores all X(mouse)events (passes them through)
问题描述
我想执行以下操作:创建一个全屏的、始终位于顶部的 pygtk 窗口,其中包含一个显示一些 html 的 webkit 小部件,但带有一个完全透明的框,以便下面的窗口可见.(这似乎是可能的:是否可以使用 WebKit 在清晰的背景上呈现 Web 内容?)
I'd like to do the following: Create a fullscreen, always on top pygtk window with a webkit widget displaying some html, but with a box that is completely transparent, so that the windows below are visible. (This seems to be possible: Is it possible to render web content over a clear background using WebKit?)
我想要的是(有时)将透明框中发生的所有鼠标事件传递到我的应用程序窗口下方的窗口,以便我可以正常与它们交互.所以不仅视觉上透明,而且对鼠标事件也是透明的.
What I'd like is to (sometimes) pass all mouse events that occur in the transparent box down to the windows below my application's window, so that I can interact with them normally. So not just visually transparent, but also transparent to mouse events.
理论上,我想我可以用 pygtk Eventbox 捕捉所有我感兴趣的事件,用 wnck 找到我正下方的窗口,然后用 python-xlib 将这个事件传递给它.
Theoretically, I suppose I could catch all events I am interested in with a pygtk Eventbox, find the window directly below mine with wnck, and pass this event to it with python-xlib.
这看起来并不是最优雅的解决方案;有没有更好的办法?
This doesn't exactly seem like the most elegant solution; is there a better way?
推荐答案
转发事件不会像你想象的那样工作;它会产生很多竞争条件,并且一些应用程序无论如何都会忽略来自 XSendEvent
的内容.
Forwarding the events won't work well as you guessed; it creates a lot of race conditions, and some apps will ignore stuff from XSendEvent
anyway.
您可以做的是设置输入形状掩码.请参阅 http://www.x.org/releases/current/doc/xextproto/shape.html 然后查看 /usr/include/X11/extensions/Xfixes.h
中的 XFixesSetWindowShapeRegion()
,它允许您指定形状种类"(这里你需要 ShapeInput
).
What you can do is set the input shape mask. See http://www.x.org/releases/current/doc/xextproto/shape.html and then look at XFixesSetWindowShapeRegion()
in /usr/include/X11/extensions/Xfixes.h
which lets you specify a shape "kind" (here you want ShapeInput
).
类似于:
XRectangle rect;
XserverRegion region = XFixesCreateRegion(display, &rect, 1);
XFixesSetWindowShapeRegion(display, window, ShapeInput, 0, 0, region);
XFixesDestroyRegion(display, region);
设置 ShapeInput
的能力只有"5-6 岁,所以如果你关心 X11 的旧版本真的很糟糕,你可能会被灌输.
The ability to set ShapeInput
is "only" 5-6 years old so if you care about really crappy old versions of X11, you might be hosed.
这篇关于带有忽略所有 X(鼠标)事件(通过它们)的框的 pygtk 窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!