Xlib python: cannot map firefox menus

2019-08-14 12:56发布

问题:

I'm making a small window manager based on:

simplewm.py https://github.com/mpnordland/Mozzarella/blob/master/cheesewm.py~

I'm trying to get firefox working but have been unable to get the unmapped windows (which are the firefox menu/right click options) to appear.

I have tried window.map() however that only makes the menu flicker and disappear again. It also causes an event of "Xlib.X.UnmapNotify"

When I right click (or click the menu) in firefox it causes 2 xlib events:

    Xlib.protocol.event.ClientMessage(type = 161, window = <Xlib.display.Window 0x010005a9>, client_type = 343, data = (32, array('I', [0L, 383L, 0L, 0L, 0L])), sequence_number = 3106)


    Xlib.protocol.event.UnmapNotify(window = <Xlib.display.Window 0x010005a9>, type = 146, event = <Xlib.display.Window 0x00000292>, sequence_number = 3108, from_configure = 0)

So it would appear Firefox is unmapping the menus I'm trying to map... :/

回答1:

Found it!

The issue is with the window focus. Firefox will not allow the menu or right click dialog box to stay open unless the input focus is set on the main Firefox window.

window.set_input_focus(Xlib.X.RevertToPointerRoot, Xlib.X.CurrentTime)


回答2:

I've been searching for a solution for about a week too and this helped.

More specifically set_input_focus() has to be called on the main client window when you get an EnterNotify on the frame window. (That is, in a focus-follows-mouse mode). It doesn't seem to matter whether you use RevertToPointerRoot or RevertToParent.