Also, the actual ICCCM would probably come in handy when dealing with the raw X window properties:

On Wed, Jun 1, 2011 at 00:16, David Bronke <> wrote:
I actually have dealt with this before, in a PyQt/PySide application. ( - sorry for the ridiclously ugly code) If you want to use PyQt or PySide, you'll want something like the following:
win.setWindowFlags(QtCore.Qt.Widget | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.WindowStaysOnTopHint)

From what I remember of the ICCCM, the properties your Gtk+2 code was setting basically mean this:
You should be able to set the exact same properties from Python-Xlib with no problem; check /usr/include/netwm_def.h or the docs at for the enum values and more info.

On Tue, May 31, 2011 at 19:07, Mike Meyer <> wrote:
On Wed, 1 Jun 2011 01:08:39 +0200
Benjamin Trias <> wrote:

> Thanks for the documentation references! In the meantime i discovered
> the ICCCM documentation, which brings light on much of the X
> protocols.

The ICCCM is client<->client stuff - and from X's point of view, the
window manager is a client. Since you're trying to convince a window
manager to do something for you (also a client), this is a good place
to look.

> > > I've found it is quite hard to achieve this using Python so far. I
> > > managed with Gtk+2, but Gtk+3's PyGI does not allow to do that
> > > anymore. PyQt, PySide, PyWx, PyGame and Kivy do not allow this kind of
> > > interaction with X either. That's really sad imo.
> >
> > How did you do this with Gtk+2? That may be enough of a hint for us to
> > figure out how to do it with Xlib (after all, Gtk+2 had to be using
> > Xlib calls at some point).
> Using Gtk+2 i did:
> import gtk
> class PyGtkWidgetDockExample:
>     def __init__(self):
>         self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
>         self.window.set_default_size(100, gtk.gdk.screen_height())
>         self.window.move(gtk.gdk.screen_width()-100, 0)

I think this is the one you want:

>         self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
>         self.window.window.property_change("_NET_WM_STRUT", "CARDINAL", 32,
>             gtk.gdk.PROP_MODE_REPLACE, [0, 100, 0, 0])
> app = PyGtkWidgetDockExample()
> gtk.main()

> In Gtk 3 however, there is no Gtk.Window().window object (a Gdk.Window
> in fact) and there is no Gdk.Window().property_change() in PyGIand
> i've been explained it had to do with the kind of data that had to be
> passed into it, which was too much hassle for making Python bindings.

Is there a set_type_hint or equivalent? The property you are changing
tells the window manager how to size the window, which you can
probably do other ways. The type hint "TYPE_HINT_DOCK" should
translate into NET_WM_WINDOW_TYPE_DOCK at some point, which tells the
window manager that this window is a dock, please make sure it stays
on top.

> > What you're trying to do sounds more like functionality from the
> > window manager, not the windowing system per se.

Turns out this is right - you're using ICCCM to tell the window
manager to do what you want. This isn't something I (or anyone else
using python-xlib) have dealt with before.

> In the light of the above code, it seems X Window should be able to do
> what i want. Hopefully i can get Python Xlib to do that for me.

I think you can do that. My guess (and it's really no more than that)
is that want to set the NET_WM_WINDOW_TYPE property on the Window to
include NET_WM_WINDOW_TYPE_DOCK. The docs you pointed at provide
other atoms to plug into that list that might be interesting.

The python-xlib window object has a change_property method that should
let you do this once you've got the window set up.

However.... the ICCCM Atom values aren't in python-xlib (yet). Adding
them (for a quick hack) should be easy - just find the actual values
(I couldn't find them on my system, but I don't think I have an ICCCM
compliant window manager installed), and add them to Xlib/

Doing this right would probably involve an ICCCM directory (and
possibly others to support it) with files to hold the various
values. Doesn't look like there are any new types, so it's still not
to bad.

> > Depending on what you have in mind, a modern paned window manager
> > might be a better solution to your problem.
> What i have in mind is to make a panel-like application, to replace
> Gnome 2's panel and make a dock.

This is pretty much what that property (among others) is meant for.

Mike Meyer <>    
Independent Software developer/SCM consultant, email for more information.

O< ascii ribbon campaign - stop html mail -

Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
python-xlib-users mailing list