Jack Bates
2016-10-15 15:25:14 UTC
How do I get the *new* active window after a FocusInEvent?
The following is my attempt, but I get the *old* active window instead.
My goal is to automatically move the mouse to the new active window when
I change active windows, say by pressing Alt-Tab or closing the old
active window.
The following is my attempt, but I get the *old* active window instead.
My goal is to automatically move the mouse to the new active window when
I change active windows, say by pressing Alt-Tab or closing the old
active window.
#!/usr/bin/env python3
import xcffib
from xcffib.xproto import CW
from xcffib.xproto import EventMask
from xcffib.xproto import FocusInEvent
conn = xcffib.connect()
setup = conn.get_setup()
conn.core.ChangeWindowAttributes(
screen.root,
CW.EventMask,
[
EventMask.FocusChange,
],
)
conn.flush()
event = conn.wait_for_event()
reply = conn.core.GetInputFocus().reply()
conn.core.WarpPointer(
xcffib.XCB_NONE,
reply.focus,
xcffib.XCB_NONE,
xcffib.XCB_NONE,
xcffib.XCB_NONE,
xcffib.XCB_NONE,
0,
0,
)
conn.flush()
import xcffib
from xcffib.xproto import CW
from xcffib.xproto import EventMask
from xcffib.xproto import FocusInEvent
conn = xcffib.connect()
setup = conn.get_setup()
conn.core.ChangeWindowAttributes(
screen.root,
CW.EventMask,
[
EventMask.FocusChange,
],
)
conn.flush()
event = conn.wait_for_event()
reply = conn.core.GetInputFocus().reply()
conn.core.WarpPointer(
xcffib.XCB_NONE,
reply.focus,
xcffib.XCB_NONE,
xcffib.XCB_NONE,
xcffib.XCB_NONE,
xcffib.XCB_NONE,
0,
0,
)
conn.flush()