pythonxlibewmhopenbox

Can I use _NET_WM_WINDOW_TYPE_DOCK EWHM extension in openbox?


Openbox is stated to be EWMH compliant here. I want to use this compliance layer to implement a decoration-less window, as proposed on this question's best answer.

As such, I am trying to build a simple window using python and Xlib that uses the _NET_WM_WINDOW_TYPE_DOCK type hint to get rid of the window decorations. But the process fails with the following code :

from Xlib import X, display
d = display.Display()
s = d.screen()
w = s.root.create_window(10, 10, 100, 100, 1, s.root_depth, background_pixel=s.black_pixel, event_mask=X.ExposureMask|X.KeyPressMask)
int_atom = d.intern_atom('int')
wm_window_type = d.intern_atom('_NET_WM_WINDOW_TYPE')
wm_window_type_dock = d.intern_atom('_NET_WM_WINDOW_TYPE_DOCK')
w.change_property(wm_window_type, int_atom, 32, [wm_window_type_dock, ], X.PropModeReplace)
w.map()
d.next_event()
d.next_event()

print(w.get_full_property(wm_window_type, X.AnyPropertyType).value[0])
print(wm_window_type_dock)

The window shows up but still has decorations. The two last print statements both return 434, so I guess the window does have a valid EWMH window_type. So the question is twofold:


Solution

  • Well, it took me some 12 hours to find the answer :

    I was using the wrong atom in change_property. The call should have read :

    w.change_property(wm_window_type, Xatom.ATOM, 32, [wm_window_type_dock, ], X.PropModeReplace)
    

    So, with the relevant import statement, the whole code becomes :

    from Xlib import X, Xatom, display
    d = display.Display()
    s = d.screen()
    w = s.root.create_window(10, 10, 100, 100, 1, s.root_depth, background_pixel=s.black_pixel, event_mask=X.ExposureMask|X.KeyPressMask)
    wm_window_type = d.intern_atom('_NET_WM_WINDOW_TYPE')
    wm_window_type_dock = d.intern_atom('_NET_WM_WINDOW_TYPE_DOCK')
    w.change_property(wm_window_type, Xatom.ATOM, 32, [wm_window_type_dock, ], X.PropModeReplace)
    w.map()
    d.next_event()
    d.next_event()
    print(w.get_full_property(wm_window_type, Xatom.ATOM).value[0])
    print(wm_window_type_dock)
    

    Which works as expected (note that if your screen's background is black, you should change the background_pixel value to see anything at all).