Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pygtk window with box that ignores all X(mouse)events (passes them through)

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.

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?

like image 779
Rumex Avatar asked Jan 28 '12 15:01

Rumex


People also ask

What are the signals emitted by the gtkwindow widget?

The gtk.Window widget emits the following signals − This is emitted when the default child widget of window is activated usually by the user pressing the Return or Enter key. This is emitted when the child widget with the focus is activated usually by the user pressing the Space key.

What is the use of an object in GTK window?

An object of the gtk.Window class provides a widget that users commonly think of as a Wwindow. This widget is a container hence, it can hold one child widget. It provides a displayable area decorated with title bar and resizing controls.

What are the important methods of the gtkwindow class?

Some of the important methods of the gtk.Window class are listed below − This sets the "title" property of the gtk.window to the value specified by the title. The title of a window will be displayed in its title bar. This returns the title of a window if set. This sets the position of window. The predefined position constants are −

How to get the focus of the widget in the window?

This is emitted when the child widget with the focus is activated usually by the user pressing the Space key. This is emitted when the focus is changed within the window's child widgets when the user presses the Tab, the Shift+Tab or the Up, Down, Left or Right arrow keys. This is emitted when the focus changes to widget in window.


1 Answers

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.

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

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.

like image 89
Havoc P Avatar answered Sep 21 '22 07:09

Havoc P