带有框的pygtk窗口,忽略所有X(鼠标)事件(传递它们)

时间:2023-01-24 15:11:03

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?)

我想做以下操作:创建一个全屏,始终在顶部pygtk窗口,其中webkit小部件显示一些html,但是有一个完全透明的框,以便下面的窗口可见。 (这似乎是可能的:是否可以使用WebKit在清晰的背景上呈现Web内容?)

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.

我想要的是(有时)将透明框中出现的所有鼠标事件传递到应用程序窗口下方的窗口,以便我可以正常地与它们进行交互。因此,不仅视觉上透明,而且对鼠标事件也是透明的。

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.

从理论上讲,我想我可以通过pygtk Eventbox捕获我感兴趣的所有事件,使用wnck在我的下方找到窗口,并使用python-xlib将此事件传递给它。

This doesn't exactly seem like the most elegant solution; is there a better way?

这似乎不是最优雅的解决方案;有没有更好的办法?

1 个解决方案

#1


5  

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.

转发事件不会像你猜到的那样有效;它创造了很多竞争条件,而且一些应用程序无论如何都会忽略来自XSendEvent的东西。

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).

你可以做的是设置输入形状掩码。请参阅http://www.x.org/releases/current/doc/xextproto/shape.html,然后查看/usr/include/X11/extensions/Xfixes.h中的XFixesSetWindowShapeRegion(),它可以让您指定一个形状“kind “(这里你想要ShapeInput)。

Something like:

就像是:

XRectangle rect;
XserverRegion region = XFixesCreateRegion(display, &rect, 1);
XFixesSetWindowShapeRegion(display, window, ShapeInput, 0, 0, region);
XFixesDestroyRegion(display, region);

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.

设置ShapeInput的能力“只有”5-6岁,所以如果你关心真正糟糕的旧版X11,你可能会受到冲击。

#1


5  

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.

转发事件不会像你猜到的那样有效;它创造了很多竞争条件,而且一些应用程序无论如何都会忽略来自XSendEvent的东西。

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).

你可以做的是设置输入形状掩码。请参阅http://www.x.org/releases/current/doc/xextproto/shape.html,然后查看/usr/include/X11/extensions/Xfixes.h中的XFixesSetWindowShapeRegion(),它可以让您指定一个形状“kind “(这里你想要ShapeInput)。

Something like:

就像是:

XRectangle rect;
XserverRegion region = XFixesCreateRegion(display, &rect, 1);
XFixesSetWindowShapeRegion(display, window, ShapeInput, 0, 0, region);
XFixesDestroyRegion(display, region);

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.

设置ShapeInput的能力“只有”5-6岁,所以如果你关心真正糟糕的旧版X11,你可能会受到冲击。