简体   繁体   中英

Python: Xlib — How can I raise(bring to top) windows?

I've tried using:

   win.configure(stack_mode=X.TopIf)
   win.set_input_focus(X.RevertToParent, X.CurrentTime)

However even without any focus loss prevention on my window manager this does not work, does anyone know of another way to do this? Xlib or not.

There is a command-line tool called wmctrl which allows you to interact with EWMH/NetWM-compatible X window managers.

For example,

wmctrl -l

lists all the windows managed by the window manager, and

wmctrl -a Mozilla 

makes active the first window in the list which has the string "Mozilla" in its title. There are other ways to select windows; the above is just an example.

wmctrl enables you to move and resize windows too.

Try this:

window=Display().screen().root.query_pointer().child
window.set_input_focus(X.RevertToParent, X.CurrentTime)
window.configure(stack_mode=X.Above)

Perhaps this is the solution:
[Xlib] Force Raise/Map/Focus a given Window

A solution given (follow the thread) involves using wnck, which in Python is a part of the Gtk+ bindings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM